00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef kdiconview_h
00021 #define kdiconview_h
00022
00023 #include <tqlistview.h>
00024
00025 #include <konq_iconviewwidget.h>
00026 #include <kaction.h>
00027 #include <kfileitem.h>
00028 #include <kdirnotify.h>
00029 #include <kmessagebox.h>
00030
00031 #include <dcopclient.h>
00032
00033 class KDirLister;
00034 class KonqSettings;
00035 class KSimpleConfig;
00036 class KAccel;
00037 class KShadowEngine;
00038 class KDesktopShadowSettings;
00039
00048 class KDIconView : public KonqIconViewWidget, public KDirNotify
00049 {
00050 Q_OBJECT
00051
00052 public:
00053 KDIconView( TQWidget *parent, const char* name = 0L );
00054 ~KDIconView();
00055
00056 virtual void initConfig( bool init );
00057 void configureMedia();
00061 void start();
00062
00063 KActionCollection *actionCollection() { return &m_actionCollection; }
00064
00065 enum SortCriterion {
00066 NameCaseSensitive = 0, NameCaseInsensitive, Size, Type, Date };
00067
00068 void rearrangeIcons( SortCriterion sc, bool bSortDirectoriesFirst);
00069
00073 void rearrangeIcons();
00074
00075 void lineupIcons(TQIconView::Arrangement);
00076
00077 void setAutoAlign( bool b );
00078
00079 TQStringList selectedURLs();
00080
00081 void update( const TQString &url );
00082
00086 void saveIconPositions();
00087
00091 void recheckDesktopURL();
00092
00096 void updateWorkArea( const TQRect &wr );
00097
00101 virtual void setWallpaper(const KURL &url) { emit newWallpaper( url ); }
00102 void setLastIconPosition( const TQPoint & );
00103
00104 static KURL desktopURL();
00105
00107 virtual void FilesAdded( const KURL & directory );
00108 virtual void FilesRemoved( const KURL::List & fileList );
00109 virtual void FilesChanged( const KURL::List & ) {}
00110
00111 void startDirLister();
00112
00113 TQPoint findPlaceForIconCol( int column, int dx, int dy );
00114 TQPoint findPlaceForIconRow( int row, int dx, int dy );
00115 TQPoint findPlaceForIcon( int column, int row );
00116
00117 protected slots:
00118
00119
00120 void slotReturnPressed( TQIconViewItem *item );
00121 void slotExecuted( TQIconViewItem *item );
00122 void slotMouseButtonPressed(int _button, TQIconViewItem* _item, const TQPoint& _global);
00123 void slotMouseButtonClickedKDesktop(int _button, TQIconViewItem* _item, const TQPoint& _global);
00124 void slotContextMenuRequested(TQIconViewItem* _item, const TQPoint& _global);
00125 void slotEnableAction( const char * name, bool enabled );
00126 public slots:
00127 void slotAboutToCreate(const TQPoint &pos, const TQValueList<KIO::CopyInfo> &files);
00128 protected slots:
00129 void slotItemRenamed(TQIconViewItem*, const TQString &name);
00130
00131
00132 void slotStarted( const KURL& url );
00133 void slotCompleted();
00134 void slotNewItems( const KFileItemList& );
00135 void slotDeleteItem( KFileItem * );
00136 void slotRefreshItems( const KFileItemList& );
00137
00138
00139 void slotCut();
00140 void slotCopy();
00141 void slotTrashActivated( KAction::ActivationReason reason, Qt::ButtonState state );
00142 void slotDelete();
00143 void slotPopupPasteTo();
00144 void slotProperties();
00145
00146 void slotClipboardDataChanged();
00147
00148 void slotNewMenuActivated();
00149
00150
00151 signals:
00152 void colorDropEvent( TQDropEvent *e );
00153 void imageDropEvent( TQDropEvent *e );
00154 void newWallpaper( const KURL & );
00155 void iconMoved();
00156 void wheelRolled( int delta );
00157
00158 public slots:
00162 void lineupIcons();
00163 void slotPaste();
00164 void slotClear();
00165 void refreshIcons();
00166
00167
00168 protected:
00169 void createActions();
00170 void setupSortKeys();
00171 void initDotDirectories();
00172
00173 bool makeFriendlyText( KFileIVI *fileIVI );
00174 static TQString stripDesktopExtension( const TQString & text );
00175 bool isDesktopFile( KFileItem * _item ) const;
00176 bool isFreePosition( const TQIconViewItem *item ) const;
00177 bool isFreePosition( const TQIconViewItem *item, const TQRect& rect ) const;
00178 void moveToFreePosition(TQIconViewItem *item );
00179
00180 bool deleteGlobalDesktopFiles();
00181 void removeBuiltinIcon(TQString iconName);
00182 void fillMediaListView();
00183 void saveMediaListView();
00184
00185 static void renameDesktopFile(const TQString &path, const TQString &name);
00186
00187 void popupMenu( const TQPoint &_global, const KFileItemList& _items );
00188 virtual void showEvent( TQShowEvent *e );
00189 virtual void contentsDropEvent( TQDropEvent *e );
00190 virtual void viewportWheelEvent( TQWheelEvent * );
00191 virtual void contentsMousePressEvent( TQMouseEvent *e );
00192 virtual void mousePressEvent( TQMouseEvent *e );
00193 virtual void wheelEvent( TQWheelEvent* e );
00194
00195 private:
00196 void refreshTrashIcon();
00197
00198 static TQRect desktopRect();
00199 static void saveIconPosition(KSimpleConfig *config, int x, int y);
00200 static void readIconPosition(KSimpleConfig *config, int &x, int &y);
00201
00203 KActionCollection m_actionCollection;
00204
00206 KAccel *m_accel;
00207
00208 bool m_bNeedRepaint;
00209 bool m_bNeedSave;
00210 bool m_autoAlign;
00211
00213 bool m_hasExistingPos;
00214
00216 bool m_bEditableDesktopIcons;
00217
00219 bool m_bShowDot;
00220
00222 bool m_bVertAlign;
00223
00225 KDirLister* m_dirLister;
00226
00228 KURL::List m_mergeDirs;
00229
00231 TQStringList m_desktopDirs;
00232
00234 KSimpleConfig *m_dotDirectory;
00235
00237 TQPoint m_lastDeletedIconPos;
00238
00240 SortCriterion m_eSortCriterion;
00241 bool m_bSortDirectoriesFirst;
00242 TQStringList m_itemsAlwaysFirst;
00243
00247 KShadowEngine *m_shadowEngine;
00248
00251 TQPoint m_nextItemPos;
00252
00254 TQPoint m_dropPos;
00255
00257 TQPoint m_lastDropPos;
00258
00260 KURL m_popupURL;
00261
00263 bool m_enableMedia;
00264 TQStringList m_excludedMedia;
00265
00266
00267
00268 bool m_gotIconsArea;
00269
00270 bool m_needDesktopAlign;
00271
00272 TQListView *mMediaListView;
00273 KConfig *g_pConfig;
00274 };
00275
00276 #endif