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., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef __konqdirpart_h 00021 #define __konqdirpart_h 00022 00023 #include <tqstring.h> 00024 #include <kparts/part.h> 00025 #include <kparts/browserextension.h> 00026 #include <kfileitem.h> 00027 #include <kdatastream.h> 00028 #include <kio/global.h> 00029 #include <libkonq_export.h> 00030 00031 class KDirLister; 00032 namespace KParts { class BrowserExtension; } 00033 class KonqPropsView; 00034 class TQScrollView; 00035 class KAction; 00036 class KToggleAction; 00037 class KonqDirPartBrowserExtension; 00038 00039 class LIBKONQ_EXPORT KonqDirPart: public KParts::ReadOnlyPart 00040 { 00041 Q_OBJECT 00042 00043 friend class KonqDirPartBrowserExtension; 00044 00045 public: 00046 KonqDirPart( TQObject *parent, const char *name ); 00047 00048 virtual ~KonqDirPart(); 00049 00053 void setBrowserExtension( KonqDirPartBrowserExtension * extension ) 00054 { m_extension = extension; } 00055 00056 KonqDirPartBrowserExtension * extension() 00057 { return m_extension; } 00058 00062 void setDirLister( KDirLister* lister ); 00063 // TODO KDE4 create the KDirLister here and simplify the parts? 00064 00065 TQScrollView * scrollWidget(); 00066 00067 virtual void saveState( TQDataStream &stream ); 00068 virtual void restoreState( TQDataStream &stream ); 00069 00073 void lmbClicked( KFileItem * fileItem ); 00074 00077 void mmbClicked( KFileItem * fileItem ); 00078 00079 void setNameFilter( const TQString & nameFilter ) { m_nameFilter = nameFilter; } 00080 00081 TQString nameFilter() const { return m_nameFilter; } 00082 00083 void setFilesToSelect( const TQStringList & filesToSelect ) { m_filesToSelect = filesToSelect; } 00084 00099 void setMimeFilter (const TQStringList& filters); 00100 00105 TQStringList mimeFilter() const; 00106 00107 00108 KonqPropsView * props() const { return m_pProps; } 00109 00113 virtual void disableIcons( const KURL::List & lst ) = 0; 00114 00119 void resetCount(); 00120 00124 void newItems( const KFileItemList & entries ); 00125 00129 void deleteItem( KFileItem * fileItem ); 00130 00134 void emitTotalCount(); 00135 00136 // ##### TODO KDE 4: remove! 00145 void emitCounts( const KFileItemList & lst, bool selectionChanged ); 00146 00154 void emitCounts( const KFileItemList & lst ); 00155 00156 void emitMouseOver( const KFileItem * item ); 00157 00163 void updatePasteAction(); 00164 00170 virtual void newIconSize( int size ); 00171 00176 void setIconSize( int size ); 00177 00181 void setFindPart( KParts::ReadOnlyPart * part ); 00182 00183 KParts::ReadOnlyPart * findPart() const { return m_findPart; } 00184 00185 virtual const KFileItem * currentItem() = 0; // { return 0L; } 00186 00187 virtual KFileItemList selectedFileItems() { return KFileItemList(); } 00188 00193 bool closeURL (); 00194 00195 signals: 00196 00200 void aboutToOpenURL(); 00201 00206 void findOpen( KonqDirPart * ); 00207 00212 void findOpened( KonqDirPart * ); 00213 00217 void findClosed( KonqDirPart * ); 00218 00223 void itemsAdded( const KFileItemList& ); 00224 00229 void itemRemoved( const KFileItem* ); 00230 00235 void itemsFilteredByMime( const KFileItemList& ); 00236 00237 public slots: 00238 00243 bool openURL (const KURL&); 00244 00250 void slotFindClosed(); 00251 00255 void slotStartAnimationSearching(); 00256 00260 void slotStopAnimationSearching(); 00261 00262 void slotBackgroundSettings(); 00263 00268 void slotClipboardDataChanged(); 00269 00270 void slotIncIconSize(); 00271 void slotDecIconSize(); 00272 00273 void slotIconSizeToggled( bool ); 00274 00275 // slots connected to the directory lister - or to the kfind interface 00276 virtual void slotStarted() = 0; 00277 virtual void slotCanceled() = 0; 00278 virtual void slotCompleted() = 0; 00279 virtual void slotNewItems( const KFileItemList& ) = 0; 00280 virtual void slotDeleteItem( KFileItem * ) = 0; 00281 virtual void slotRefreshItems( const KFileItemList& ) = 0; 00282 virtual void slotClear() = 0; 00283 virtual void slotRedirection( const KURL & ) = 0; 00284 00285 private slots: 00286 void slotIconChanged(int group); 00287 protected: 00292 virtual bool doOpenURL( const KURL& ) = 0; 00293 virtual bool doCloseURL () = 0; 00294 00295 protected: 00296 00297 TQString m_nameFilter; 00298 TQStringList m_filesToSelect; 00299 00300 KonqPropsView * m_pProps; 00301 00302 KAction *m_paIncIconSize; 00303 KAction *m_paDecIconSize; 00304 KToggleAction *m_paDefaultIcons; 00305 KToggleAction *m_paHugeIcons; 00306 KToggleAction *m_paLargeIcons; 00307 KToggleAction *m_paMediumIcons; 00308 KToggleAction *m_paSmallIcons; 00309 00310 KParts::ReadOnlyPart * m_findPart; 00311 KonqDirPartBrowserExtension * m_extension; 00312 00313 // Remove all those in KDE4 00314 int m_iIconSize[5]; 00315 KIO::filesize_t m_lDirSize; 00316 uint m_lFileCount; 00317 uint m_lDirCount; 00318 00319 private: 00320 void saveFindState( TQDataStream& ); 00321 void restoreFindState( TQDataStream& ); 00322 00323 void adjustIconSizes(); 00324 00325 class KonqDirPartPrivate; 00326 KonqDirPartPrivate* d; 00327 }; 00328 00329 class LIBKONQ_EXPORT KonqDirPartBrowserExtension : public KParts::BrowserExtension 00330 { 00331 public: 00332 KonqDirPartBrowserExtension( KonqDirPart* dirPart ) 00333 : KParts::BrowserExtension( dirPart ) 00334 , m_dirPart( dirPart ) 00335 {} 00336 00344 virtual void saveState( TQDataStream &stream ); 00345 virtual void restoreState( TQDataStream &stream ); 00346 00347 private: 00348 KonqDirPart* m_dirPart; 00349 }; 00350 00351 #endif