• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kio

kfilepreview.cpp

Go to the documentation of this file.
00001 /* This file is part of the KDE libraries
00002     Copyright (C) 1998 Stephan Kulow <coolo@kde.org>
00003                   1998 Daniel Grana <grana@ie.iwi.unibe.ch>
00004                   2000 Werner Trobin <wtrobin@carinthia.com>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to
00018     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #include <kaction.h>
00023 #include <kfilepreview.h>
00024 #include <kfilepreview.moc>
00025 #include <klocale.h>
00026 
00027 #include <qlabel.h>
00028 
00029 #include "config-kfile.h"
00030 
00031 KFilePreview::KFilePreview(KFileView *view, QWidget *parent, const char *name)
00032     : QSplitter(parent, name), KFileView()
00033 {
00034     if ( view )
00035         init( view );
00036     else
00037         init( new KFileIconView( (QSplitter*) this, "left" ));
00038 }
00039 
00040 
00041 KFilePreview::KFilePreview(QWidget *parent, const char *name) :
00042                            QSplitter(parent, name), KFileView()
00043 {
00044     init( new KFileIconView((QSplitter*)this, "left") );
00045 }
00046 
00047 KFilePreview::~KFilePreview()
00048 {
00049     // Why copy the actions in the first place? --ellis, 13 Jan 02.
00051     //for ( uint i = 0; i < left->actionCollection()->count(); i++ )
00052     //    actionCollection()->take( left->actionCollection()->action( i ));
00053 
00054     // don't delete the preview, we can reuse it
00055     // (it will get deleted by ~KDirOperator)
00056     if ( preview && preview->parentWidget() == this ) {
00057         preview->reparent(0L, 0, QPoint(0, 0), false);
00058     }
00059 }
00060 
00061 void KFilePreview::init( KFileView *view )
00062 {
00063     setViewName( i18n("Preview") );
00064 
00065     left = 0L;
00066     setFileView( view );
00067 
00068     preview = new QWidget((QSplitter*)this, "preview");
00069     QString tmp = i18n("No preview available.");
00070     QLabel *l = new QLabel(tmp, preview);
00071     l->setMinimumSize(l->sizeHint());
00072     l->move(10, 5);
00073     preview->setMinimumWidth(l->sizeHint().width()+20);
00074     setResizeMode(preview, QSplitter::KeepSize);
00075 
00076     // Why copy the actions? --ellis, 13 Jan 02.
00077     //for ( uint i = 0; i < view->actionCollection()->count(); i++ )
00078     //    actionCollection()->insert( view->actionCollection()->action( i ));
00079 }
00080 
00081 void KFilePreview::setFileView( KFileView *view )
00082 {
00083     Q_ASSERT( view );
00084 
00085     // Why copy the actions? --ellis, 13 Jan 02.
00086     //if ( left ) { // remove any previous actions
00087     //    for ( uint i = 0; i < left->actionCollection()->count(); i++ )
00088     //        actionCollection()->take( left->actionCollection()->action( i ));
00089     //}
00090 
00091     delete left;
00092     view->widget()->reparent( this, QPoint(0,0) );
00093     view->KFileView::setViewMode(All);
00094     view->setParentView(this);
00095     view->setSorting( sorting() );
00096     left = view;
00097 
00098     connect( left->signaler(), SIGNAL( fileHighlighted(const KFileItem*) ),
00099              SLOT( slotHighlighted( const KFileItem * )));
00100 
00101     // Why copy the actions? --ellis, 13 Jan 02.
00102     //for ( uint i = 0; i < view->actionCollection()->count(); i++ )
00103     //    actionCollection()->insert( view->actionCollection()->action( i ));
00104 }
00105 
00106 // this url parameter is useless... it's the url of the current directory.
00107 // what for?
00108 void KFilePreview::setPreviewWidget(const QWidget *w, const KURL &)
00109 {
00110     left->setOnlyDoubleClickSelectsFiles( onlyDoubleClickSelectsFiles() );
00111 
00112     if (w) {
00113         connect(this, SIGNAL( showPreview(const KURL &) ),
00114                 w, SLOT( showPreview(const KURL &) ));
00115         connect( this, SIGNAL( clearPreview() ),
00116                 w, SLOT( clearPreview() ));
00117     }
00118     else {
00119         preview->hide();
00120         return;
00121     }
00122 
00123     delete preview;
00124     preview = const_cast<QWidget*>(w);
00125     preview->reparent((QSplitter*)this, 0, QPoint(0, 0), true);
00126     preview->resize(preview->sizeHint());
00127     preview->show();
00128 }
00129 
00130 void KFilePreview::insertItem(KFileItem *item)
00131 {
00132     KFileView::insertItem( item );
00133     left->insertItem(item);
00134 }
00135 
00136 void KFilePreview::setSorting( QDir::SortSpec sort )
00137 {
00138     left->setSorting( sort );
00139     KFileView::setSorting( left->sorting() );
00140 }
00141 
00142 void KFilePreview::clearView()
00143 {
00144     left->clearView();
00145     emit clearPreview();
00146 }
00147 
00148 void KFilePreview::updateView(bool b)
00149 {
00150     left->updateView(b);
00151     if(preview)
00152         preview->repaint(b);
00153 }
00154 
00155 void KFilePreview::updateView(const KFileItem *i)
00156 {
00157     left->updateView(i);
00158 }
00159 
00160 void KFilePreview::removeItem(const KFileItem *i)
00161 {
00162     if ( left->isSelected( i ) )
00163         emit clearPreview();
00164 
00165     left->removeItem(i);
00166     KFileView::removeItem( i );
00167 }
00168 
00169 void KFilePreview::listingCompleted()
00170 {
00171     left->listingCompleted();
00172 }
00173 
00174 void KFilePreview::clear()
00175 {
00176     KFileView::clear();
00177     left->KFileView::clear();
00178 }
00179 
00180 void KFilePreview::clearSelection()
00181 {
00182     left->clearSelection();
00183     emit clearPreview();
00184 }
00185 
00186 void KFilePreview::selectAll()
00187 {
00188     left->selectAll();
00189 }
00190 
00191 void KFilePreview::invertSelection()
00192 {
00193     left->invertSelection();
00194 }
00195 
00196 bool KFilePreview::isSelected( const KFileItem *i ) const
00197 {
00198     return left->isSelected( i );
00199 }
00200 
00201 void KFilePreview::setSelectionMode(KFile::SelectionMode sm) {
00202     left->setSelectionMode( sm );
00203 }
00204 
00205 void KFilePreview::setSelected(const KFileItem *item, bool enable) {
00206     left->setSelected( item, enable );
00207 }
00208 
00209 void KFilePreview::setCurrentItem( const KFileItem *item )
00210 {
00211     left->setCurrentItem( item );
00212 }
00213 
00214 KFileItem * KFilePreview::currentFileItem() const
00215 {
00216     return left->currentFileItem();
00217 }
00218 
00219 void KFilePreview::slotHighlighted(const KFileItem* item)
00220 {
00221     if ( item )
00222         emit showPreview( item->url() );
00223 
00224     else { // item = 0 -> multiselection mode
00225         const KFileItemList *items = selectedItems();
00226         if ( items->count() == 1 )
00227             emit showPreview( items->getFirst()->url() );
00228         else
00229             emit clearPreview();
00230     }
00231 
00232     // the preview widget appears and takes some space of the left view,
00233     // so we may have to scroll to make the current item visible
00234     left->ensureItemVisible(item);
00235  }
00236 
00237 void KFilePreview::ensureItemVisible(const KFileItem *item)
00238 {
00239     left->ensureItemVisible(item);
00240 }
00241 
00242 KFileItem * KFilePreview::firstFileItem() const
00243 {
00244     return left->firstFileItem();
00245 }
00246 
00247 KFileItem * KFilePreview::nextItem( const KFileItem *item ) const
00248 {
00249     return left->nextItem( item );
00250 }
00251 
00252 KFileItem * KFilePreview::prevItem( const KFileItem *item ) const
00253 {
00254     return left->prevItem( item );
00255 }
00256 
00257 KActionCollection * KFilePreview::actionCollection() const
00258 {
00259     if ( left )
00260         return left->actionCollection();
00261     else {
00262         kdWarning() << "KFilePreview::actionCollection(): called before setFileView()." << endl; //ellis
00263         return KFileView::actionCollection();
00264     }
00265 }
00266 
00267 void KFilePreview::readConfig( KConfig *config, const QString& group )
00268 {
00269     left->readConfig( config, group );
00270 }
00271 
00272 void KFilePreview::writeConfig( KConfig *config, const QString& group )
00273 {
00274     left->writeConfig( config, group );
00275 }
00276 
00277 void KFilePreview::virtual_hook( int id, void* data )
00278 { KFileView::virtual_hook( id, data ); }
00279 

kio

Skip menu "kio"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal