23 #include <kfilepreview.h> 24 #include <kfilepreview.moc> 29 #include "config-kfile.h" 31 KFilePreview::KFilePreview(
KFileView *view, TQWidget *parent,
const char *name)
41 KFilePreview::KFilePreview(TQWidget *parent,
const char *name) :
47 KFilePreview::~KFilePreview()
56 if ( preview && preview->parentWidget() == this ) {
57 preview->reparent(0L, 0, TQPoint(0, 0),
false);
61 void KFilePreview::init(
KFileView *view )
63 setViewName( i18n(
"Preview") );
68 preview =
new TQWidget((TQSplitter*)
this,
"preview");
69 TQString tmp = i18n(
"No preview available.");
70 TQLabel *l =
new TQLabel(tmp, preview);
71 l->setMinimumSize(l->sizeHint());
73 preview->setMinimumWidth(l->sizeHint().width()+20);
74 setResizeMode(preview, TQSplitter::KeepSize);
92 view->
widget()->reparent(
this, TQPoint(0,0) );
93 view->KFileView::setViewMode(All);
94 view->setParentView(
this);
98 connect( left->signaler(), TQT_SIGNAL( fileHighlighted(
const KFileItem*) ),
99 TQT_SLOT( slotHighlighted(
const KFileItem * )));
108 void KFilePreview::setPreviewWidget(
const TQWidget *w,
const KURL &)
110 left->setOnlyDoubleClickSelectsFiles( onlyDoubleClickSelectsFiles() );
113 connect(
this, TQT_SIGNAL( showPreview(
const KURL &) ),
114 w, TQT_SLOT( showPreview(
const KURL &) ));
115 connect(
this, TQT_SIGNAL( clearPreview() ),
116 w, TQT_SLOT( clearPreview() ));
124 preview =
const_cast<TQWidget*
>(w);
125 preview->reparent((TQSplitter*)
this, 0, TQPoint(0, 0),
true);
126 preview->resize(preview->sizeHint());
133 left->insertItem(item);
138 left->setSorting( sort );
162 if ( left->isSelected( i ) )
171 left->listingCompleted();
177 left->KFileView::clear();
182 left->clearSelection();
193 left->invertSelection();
198 return left->isSelected( i );
201 void KFilePreview::setSelectionMode(KFile::SelectionMode sm) {
202 left->setSelectionMode( sm );
206 left->setSelected( item, enable );
211 left->setCurrentItem( item );
216 return left->currentFileItem();
219 void KFilePreview::slotHighlighted(
const KFileItem* item)
222 emit showPreview( item->url() );
225 const KFileItemList *items = selectedItems();
226 if ( items->count() == 1 )
227 emit showPreview( items->getFirst()->url() );
234 left->ensureItemVisible(item);
239 left->ensureItemVisible(item);
242 KFileItem * KFilePreview::firstFileItem()
const 244 return left->firstFileItem();
247 KFileItem * KFilePreview::nextItem(
const KFileItem *item )
const 249 return left->nextItem( item );
252 KFileItem * KFilePreview::prevItem(
const KFileItem *item )
const 254 return left->prevItem( item );
260 return left->actionCollection();
262 kdWarning() <<
"KFilePreview::actionCollection(): called before setFileView()." << endl;
267 void KFilePreview::readConfig( KConfig *config,
const TQString& group )
269 left->readConfig( config, group );
272 void KFilePreview::writeConfig( KConfig *config,
const TQString& group )
274 left->writeConfig( config, group );
277 void KFilePreview::virtual_hook(
int id,
void* data )
278 { KFileView::virtual_hook(
id, data ); }
virtual bool isSelected(const KFileItem *) const
virtual void insertItem(KFileItem *i)
The derived view must implement this function to add the file in the widget.
virtual KActionCollection * actionCollection() const
virtual void clearSelection()
Clears any selection, unhighlights everything.
virtual void listingCompleted()
This hook is called when all items of the currently listed directory are listed and inserted into the...
This class defines an interface to all file views.
virtual void clearView()
pure virtual function, that should be implemented to clear the view.
virtual void clear()
Clears the view and all item lists.
virtual void insertItem(KFileItem *)
The derived view must implement this function to add the file in the widget.
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 void selectAll()
Selects all items.
void ensureItemVisible(const KFileItem *)
pure virtual function, that should be implemented to make item i visible, i.e.
virtual void setCurrentItem(const KFileItem *)
Reimplement this to set item the current item in the view, e.g.
virtual TQWidget * widget()=0
a pure virtual function to get a TQWidget, that can be added to other widgets.
virtual void setSelected(const KFileItem *, bool)
Tells the view that it should highlight the item.
virtual void removeItem(const KFileItem *item)
Removes an item from the list; has to be implemented by the view.
virtual KFileItem * currentFileItem() const
virtual void setSorting(TQDir::SortSpec sort)
Sets the sorting order of the view.
virtual void setSorting(TQDir::SortSpec sort)
Sets the sorting order of the view.
virtual void invertSelection()
Inverts the current selection, i.e.
An icon-view capable of showing KFileItem's.
virtual KActionCollection * actionCollection() const
This overrides KFileView::actionCollection() by returning the actionCollection() of the KFileView (me...
void setFileView(KFileView *view)
Delets the current view and sets the view to the given view.