libkonq Library API Documentation

konq_dirpart.h

00001 /* This file is part of the KDE projects
00002    Copyright (C) 2000 David Faure <faure@kde.org>
00003 
00004    This program is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012     General Public License for more details.
00013 
00014    You should have received a copy of the GNU General Public License
00015    along with this program; see the file COPYING.  If not, write to
00016    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017    Boston, MA 02111-1307, USA.
00018 */
00019 
00020 #ifndef __konqdirpart_h
00021 #define __konqdirpart_h
00022 
00023 #include <qstring.h>
00024 #include <kparts/part.h>
00025 #include <kparts/browserextension.h>
00026 #include <kfileitem.h>
00027 
00028 namespace KParts { class BrowserExtension; }
00029 class KonqPropsView;
00030 class QScrollView;
00031 class KAction;
00032 class KToggleAction;
00033 class KonqDirPartBrowserExtension;
00034 
00035 class KonqDirPart: public KParts::ReadOnlyPart
00036 {
00037     Q_OBJECT
00038     
00039     friend class KonqDirPartBrowserExtension;
00040     
00041 public:
00042     KonqDirPart( QObject *parent, const char *name );
00043 
00044     virtual ~KonqDirPart();
00045 
00049     void setBrowserExtension( KonqDirPartBrowserExtension * extension )
00050       { m_extension = extension; }
00051 
00052     KonqDirPartBrowserExtension * extension()
00053       { return m_extension; }
00054 
00055     QScrollView * scrollWidget();
00056 
00057     virtual void saveState( QDataStream &stream );
00058     virtual void restoreState( QDataStream &stream );
00059 
00063     void lmbClicked( KFileItem * fileItem );
00064 
00067     void mmbClicked( KFileItem * fileItem );
00068 
00069     void setNameFilter( const QString & nameFilter ) { m_nameFilter = nameFilter; }
00070 
00071     QString nameFilter() const { return m_nameFilter; }
00072 
00087     void setMimeFilter (const QStringList& filters);
00088 
00093     QStringList mimeFilter() const;
00094 
00095 
00096     KonqPropsView * props() const { return m_pProps; }
00097 
00101     virtual void disableIcons( const KURL::List & lst ) = 0;
00102 
00107     void resetCount()
00108     {
00109         m_lDirSize = 0;
00110         m_lFileCount = 0;
00111         m_lDirCount = 0;
00112     }
00113 
00117     void newItems( const KFileItemList & entries );
00118 
00122     void deleteItem( KFileItem * fileItem );
00123 
00127     void emitTotalCount();
00128 
00134     void emitCounts( const KFileItemList & lst, bool selectionChanged );
00135 
00136     void emitMouseOver( const KFileItem * item );
00137 
00143     void updatePasteAction();
00144 
00150     virtual void newIconSize( int size );
00151 
00156     void setIconSize( int size );
00157 
00161     void setFindPart( KParts::ReadOnlyPart * part );
00162 
00163     KParts::ReadOnlyPart * findPart() const { return m_findPart; }
00164 
00165     virtual const KFileItem * currentItem() = 0; // { return 0L; }
00166 
00167     virtual KFileItemList selectedFileItems() { return KFileItemList(); }
00168 
00173     bool closeURL ();
00174 
00175 signals:
00176 
00180     void aboutToOpenURL();
00181 
00186     void findOpen( KonqDirPart * );
00187 
00192     void findOpened( KonqDirPart * );
00193 
00197     void findClosed( KonqDirPart * );
00198 
00203     void itemsAdded( const KFileItemList& );
00204 
00209     void itemRemoved( const KFileItem* );
00210 
00215     void itemsFilteredByMime( const KFileItemList& );
00216 
00217 public slots:
00218 
00223      bool openURL (const KURL&);
00224 
00230     void slotFindClosed();
00231 
00235     void slotStartAnimationSearching();
00236 
00240     void slotStopAnimationSearching();
00241 
00242     void slotBackgroundColor();
00243 
00244     void slotBackgroundImage();
00245 
00250     void slotClipboardDataChanged();
00251 
00252     void slotIncIconSize();
00253     void slotDecIconSize();
00254 
00255     void slotIconSizeToggled( bool );
00256 
00257     // slots connected to the directory lister - or to the kfind interface
00258     virtual void slotStarted() = 0;
00259     virtual void slotCanceled() = 0;
00260     virtual void slotCompleted() = 0;
00261     virtual void slotNewItems( const KFileItemList& ) = 0;
00262     virtual void slotDeleteItem( KFileItem * ) = 0;
00263     virtual void slotRefreshItems( const KFileItemList& ) = 0;
00264     virtual void slotClear() = 0;
00265     virtual void slotRedirection( const KURL & ) = 0;
00266 
00267 protected:
00272     virtual bool doOpenURL( const KURL& ) = 0;
00273     virtual bool doCloseURL () = 0;
00274 
00275 protected:
00276 
00277     QString m_nameFilter;
00278 
00279     KonqPropsView * m_pProps;
00280 
00281     KAction *m_paIncIconSize;
00282     KAction *m_paDecIconSize;
00283     KToggleAction *m_paDefaultIcons;
00284     KToggleAction *m_paHugeIcons;
00285     KToggleAction *m_paLargeIcons;
00286     KToggleAction *m_paMediumIcons;
00287     KToggleAction *m_paSmallIcons;
00288 
00289     KParts::ReadOnlyPart * m_findPart;
00290     KonqDirPartBrowserExtension * m_extension;
00291 
00292     int m_iIconSize[5];
00293 
00294     long long m_lDirSize;
00295     uint m_lFileCount;
00296     uint m_lDirCount;
00297     //bool m_bMultipleItemsSelected;
00298 
00299 private:
00300     void saveFindState( QDataStream& );
00301     void restoreFindState( QDataStream& );
00302     
00303     class KonqDirPartPrivate;
00304     KonqDirPartPrivate* d;
00305 };
00306 
00307 class KonqDirPartBrowserExtension : public KParts::BrowserExtension
00308 {
00309 public:
00310     KonqDirPartBrowserExtension( KonqDirPart* dirPart )
00311         : KParts::BrowserExtension( dirPart )
00312         , m_dirPart( dirPart )
00313     {}
00314     
00315     // For restoration of the find part to work correctly, we need
00316     // the state to be saved and restored in the following order:
00317     // 1. KonqDirPart (and derived classes)
00318     // 2. BrowserExtension (which calls openURL())
00319     // 3. Find part
00320     //
00321     // This is handled below. If your KonqDirPart-derived class needs
00322     // to save and restore state, you should override KonqDirPart::saveState
00323     // and KonqDirPart::restoreState, not the following methods.
00324     virtual void saveState( QDataStream &stream )
00325     {
00326         m_dirPart->saveState( stream );
00327         KParts::BrowserExtension::saveState( stream );
00328         m_dirPart->saveFindState( stream );
00329     }
00330 
00331     virtual void restoreState( QDataStream &stream )
00332     {
00333         m_dirPart->restoreState( stream );
00334         KParts::BrowserExtension::restoreState( stream );
00335         m_dirPart->restoreFindState( stream );
00336     }
00337 
00338 private:
00339     KonqDirPart* m_dirPart;
00340 };
00341 
00342 #endif
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Thu Jan 29 23:03:28 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001