25#include "tdefileitem.h"
26#include "kcombiview.h"
27#include "tdefileiconview.h"
28#include "tdefiledetailview.h"
29#include "config-tdefile.h"
35#include <tdeapplication.h>
40#include <tqvaluelist.h>
42KCombiView::KCombiView( TQWidget *parent,
const char *name)
43 : TQSplitter( parent, name),
46 m_lastViewForNextItem(0),
47 m_lastViewForPrevItem(0)
50 left->setAcceptDrops(
false);
51 left->viewport()->setAcceptDrops(
false);
52 left->setGridX( 160 );
53 left->KFileView::setViewMode( Directories );
54 left->setArrangement( TQIconView::LeftToRight );
55 left->setParentView(
this );
56 left->setAcceptDrops(
false);
57 left->installEventFilter(
this );
59 connect( sig, TQ_SIGNAL( sortingChanged( TQDir::SortSpec ) ),
60 TQ_SLOT( slotSortingChanged( TQDir::SortSpec ) ));
63KCombiView::~KCombiView()
72 right->KFileView::setViewMode( Files );
76 lst << left->gridX() + 2 * left->spacing();
78 setResizeMode( left, TQSplitter::KeepSize );
80 right->setParentView(
this );
81 right->widget()->setAcceptDrops(acceptDrops());
83 right->widget()->installEventFilter(
this );
91 if ( item->isDir() ) {
92 left->updateNumbers( item );
93 left->insertItem( item );
96 right->updateNumbers( item );
97 right->insertItem( item );
104 kdFatal() <<
"You need to call setRight( someview ) before!" << endl;
105 right->setSorting( sort );
106 left->setSorting( sort );
120 left->updateView( b );
122 right->updateView( b );
134 left->removeItem( i );
136 right->removeItem( i );
142 left->listingCompleted();
144 right->listingCompleted();
150 left->KFileView::clear();
157 left->clearSelection();
159 right->clearSelection();
171 left->invertSelection();
173 right->invertSelection();
179 return (right->isSelected( item ) || left->isSelected( item ));
182void KCombiView::setSelectionMode( KFile::SelectionMode sm )
188 kdFatal() <<
"You need to call setRight( someview ) before!" << endl;
189 right->setSelectionMode( sm );
194 left->setSelected( item, enable );
196 right->setSelected( item, enable );
201 left->setCurrentItem( item );
203 right->setCurrentItem( item );
212 return left->currentFileItem();
214 KFileView *preferredView = focusView( right );
216 if ( !item && preferredView != left )
217 item = left->currentFileItem();
224 left->ensureItemVisible( item );
226 right->ensureItemVisible( item );
229KFileItem * KCombiView::firstFileItem()
const
232 return left->firstFileItem();
234 KFileView *preferredView = focusView( left );
235 KFileView *otherView = (preferredView == left) ? right : left;
236 KFileItem *item = preferredView->firstFileItem();
238 item = otherView->firstFileItem();
243KFileItem * KCombiView::nextItem(
const KFileItem *fileItem )
const
246 return left->nextItem( fileItem );
248 KFileView *preferredView = focusView( left );
249 KFileView *otherView = (preferredView == left) ? right : left;
250 KFileItem *item = preferredView->nextItem( fileItem );
253 m_lastViewForNextItem = preferredView;
257 if ( m_lastViewForNextItem != otherView ) {
258 m_lastViewForNextItem = otherView;
259 return otherView->firstFileItem();
262 item = otherView->nextItem( fileItem );
263 m_lastViewForNextItem = otherView;
269KFileItem * KCombiView::prevItem(
const KFileItem *fileItem )
const
272 return left->nextItem( fileItem );
274 KFileView *preferredView = focusView( left );
275 KFileView *otherView = (preferredView == left) ? right : left;
276 KFileItem *item = preferredView->prevItem( fileItem );
278 m_lastViewForPrevItem = preferredView;
283 if ( m_lastViewForPrevItem != otherView ) {
284 fileItem = otherView->firstFileItem();
285 while ( otherView->nextItem( fileItem ) )
286 fileItem = otherView->nextItem( fileItem );
289 item = otherView->prevItem( fileItem );
290 m_lastViewForPrevItem = otherView;
296void KCombiView::slotSortingChanged( TQDir::SortSpec sorting )
303 TQWidget *w = focusWidget();
304 KFileView *other = (right == preferred) ? left : right;
305 return (preferred && w == preferred->
widget()) ? preferred : other;
308void KCombiView::readConfig( TDEConfig *config,
const TQString& group )
310 left->readConfig( config, group );
312 right->readConfig( config, group );
315void KCombiView::writeConfig( TDEConfig *config,
const TQString& group )
317 left->writeConfig( config, group );
319 right->writeConfig( config, group );
324 return focusView( right )->actionCollection();
327void KCombiView::setAcceptDrops(
bool b)
329 left->setAcceptDrops(b);
331 right->
widget()->setAcceptDrops(b);
332 TQSplitter::setAcceptDrops(b);
335void KCombiView::setDropOptions_impl(
int options)
337 KFileView::setDropOptions_impl(options);
338 left->setDropOptions(options);
340 right->setDropOptions(options);
343void KCombiView::virtual_hook(
int id,
void* data )
346 case VIRTUAL_SET_DROP_OPTIONS:
347 setDropOptions_impl(*(
int *)data);
350 KFileView::virtual_hook(
id, data );
354bool KCombiView::eventFilter( TQObject *o, TQEvent *e )
356 int type = e->type();
359 if ( type == TQEvent::FocusIn )
362 right->clearSelection();
363 else if ( o == right->widget() )
364 left->clearSelection();
367 return TQSplitter::eventFilter( o, e );
370#include "kcombiview.moc"
virtual void setCurrentItem(const KFileItem *)
Reimplement this to set item the current item in the view, e.g.
void setRight(KFileView *view)
Sets the view to be shown in the right.
virtual void clearSelection()
Clears any selection, unhighlights everything.
virtual void setSelected(const KFileItem *, bool)
Tells the view that it should highlight the item.
virtual void clearView()
pure virtual function, that should be implemented to clear the view.
virtual void selectAll()
Selects all items.
virtual void insertItem(KFileItem *i)
The derived view must implement this function to add the file in the widget.
virtual bool isSelected(const KFileItem *) const
virtual void setSorting(TQDir::SortSpec sort)
Sets the sorting order of the view.
virtual void clear()
Clears the view and all item lists.
virtual void removeItem(const KFileItem *)
Removes an item from the list; has to be implemented by the view.
virtual void updateView(bool)
does a repaint of the view.
virtual TDEActionCollection * actionCollection() const
virtual void listingCompleted()
This hook is called when all items of the currently listed directory are listed and inserted into the...
virtual KFileItem * currentFileItem() const
void ensureItemVisible(const KFileItem *)
pure virtual function, that should be implemented to make item i visible, i.e.
virtual void invertSelection()
Inverts the current selection, i.e.
An icon-view capable of showing KFileItem's.
virtual void updateView(bool)
does a repaint of the view.
This class defines an interface to all file views.
void setViewName(const TQString &name)
Sets the name of the view, which could be displayed somewhere.
virtual void insertItem(KFileItem *i)
The derived view must implement this function to add the file in the widget.
TQDir::SortSpec sorting() const
Returns the sorting order of the internal list.
virtual KFileItem * currentFileItem() const =0
virtual void updateView(bool f=true)
does a repaint of the view.
virtual TQWidget * widget()=0
a pure virtual function to get a TQWidget, that can be added to other widgets.
int dropOptions()
Returns the DND options in effect.
virtual void removeItem(const KFileItem *item)
Removes an item from the list; has to be implemented by the view.
virtual void setSorting(TQDir::SortSpec sort)
Sets the sorting order of the view.
virtual void clear()
Clears the view and all item lists.