00001
00002
00003
00004 #ifndef _SLFILESELECTOR_H_INCLUDED
00005 #define _SLFILESELECTOR_H_INCLUDED
00006
00007 #include <opie2/ofileselector.h>
00008 #include <qhbox.h>
00009 #include <qvbox.h>
00010 #include <qlistview.h>
00011 #include <qiconview.h>
00012 #include <qtoolbutton.h>
00013 #include <qfileinfo.h>
00014 #include <qtableview.h>
00015 #include <qwidgetstack.h>
00016 #include <qvaluelist.h>
00017
00018 #include <qpe/applnk.h>
00019 #include <qpe/mimetype.h>
00020 #include <sl/slmisc.h>
00021
00022 class QComboBox;
00023 class SlFileItemType;
00024 class QCopChannel;
00025
00026 struct SlFileListItemPrivate;
00027 class SlFileListItem
00028 {
00029 public:
00030 SlFileListItem(const QFileInfo&,const MimeType&);
00031 ~SlFileListItem();
00032 const QFileInfo &file() const;
00033 const MimeType &mimeType() const;
00034 const QString getItemIconFilePath() const;
00035 const QString name() const;
00036 void setName(const QString&);
00037 const QString sortKey() const;
00038 void setSortKey(const QString&);
00039 QPixmap pixmap() const;
00040 QPixmap bigPixmap() const;
00041 const QString dateString() const;
00042 const QString typeString() const;
00043 const QString bytesString() const;
00044 void setDevice();
00045 bool isDevice() const;
00046 enum ColumnItem {
00047 Name = 1,
00048 Type,
00049 Date,
00050 Bytes,
00051 Custom = 100
00052 };
00053 private:
00054 SlFileListItemPrivate *p;
00055 SlFileListItem(const SlFileListItem&);
00056 };
00057
00058 typedef QValueList<SlFileListItem*> SlFileList;
00059 typedef QValueList<SlFileListItem::ColumnItem> SlFileListColumnConf;
00060
00061 class SlFileListViewItem;
00062
00063 struct SlFileListViewPrivate;
00064 class SlFileListView : public QListView
00065 {
00066 Q_OBJECT
00067
00068 public:
00069 SlFileListView(QWidget*, const char*);
00070 ~SlFileListView();
00071 void createFileList(SlFileList&);
00072 int fileCount() const;
00073 void updateItem(SlFileListViewItem*);
00074 void createItem(SlFileListItem*);
00075 void deleteItem(const QString&);
00076 void deleteItem(SlFileListViewItem*);
00077 SlFileListViewItem* searchItem(const QString&);
00078 SlFileListColumnConf columnConf();
00079 void setColumnConf(SlFileListColumnConf&);
00080 void updateColumn();
00081 static const QString columnItemName(SlFileListItem::ColumnItem);
00082 static const SlFileListColumnConf columnItemList();
00083
00084
00085
00086 SlMisc::SlListColumnInfos columnWidthInfos();
00087
00088 protected:
00089
00090
00091 signals:
00092 void keyPressed(QKeyEvent *e,bool &isAccepted);
00093
00094 protected slots:
00095
00096 private:
00097 friend class SlFileSelector;
00098 SlFileListViewPrivate *p;
00099 SlFileListView(const SlFileListView&);
00100 };
00101
00102 class SlFileIconViewItem;
00103
00104 struct SlFileIconViewPrivate;
00105 class SlFileIconView : public QIconView
00106 {
00107 Q_OBJECT
00108
00109 public:
00110 SlFileIconView(QWidget*, const char*);
00111 ~SlFileIconView();
00112 void createFileList(SlFileList&);
00113 int fileCount() const;
00114 void updateItem(SlFileIconViewItem*);
00115 void createItem(SlFileListItem*);
00116 void deleteItem(const QString&);
00117 void deleteItem(SlFileIconViewItem*);
00118 SlFileIconViewItem* searchItem(const QString&);
00119 void setSorting(int column,bool ascending);
00120 int sortColumn() const;
00121 void repaintItemsForce();
00122 SlFileListColumnConf columnConf();
00123 void setColumnConf(SlFileListColumnConf&);
00124
00125
00126
00127 protected:
00128
00129
00130 protected slots:
00131
00132 signals:
00133 void keyPressed(QKeyEvent *e,bool &isAccepted);
00134
00135 private:
00136 friend class SlFileSelector;
00137 SlFileIconViewPrivate *p;
00138 SlFileIconView(const SlFileIconView&);
00139 };
00140
00141 class SlFileSelectorFilter : public QObject
00142 {
00143 public:
00144 SlFileSelectorFilter(QWidget *parent,const char *name=0);
00145 ~SlFileSelectorFilter();
00146
00147 virtual bool isAddToList(QFileInfo&) const = 0;
00148 private:
00149 SlFileSelectorFilter(const SlFileSelectorFilter&);
00150 };
00151
00152 typedef QList<MimeType> SlFileMimeTypeList;
00153
00154 struct SlFileSelectorPrivate;
00155 class SlFileSelector : public Opie::Ui::OFileSelector
00156 {
00157 Q_OBJECT
00158
00159 public:
00160
00161
00162 enum SlFileSelectorViewType {
00163
00164 ListView = 1,
00165
00166 IconView
00167 };
00168
00169
00170 enum SlFileOverwirteMode {
00171
00172 Overwrite = 1,
00173
00174 NewName,
00175
00176 Error
00177 };
00178 SlFileSelector(const QString &dirPath,
00179 const QString &mimefilter,
00180 QWidget *parent,
00181 const char *name);
00182 SlFileSelector(const QString ¤tFileName,
00183 SlFileSelectorViewType type,
00184 const QString &mimeFilter,
00185 SlFileListColumnConf &items,
00186 int sortColumn,bool sortAscending,
00187 SlFileSelectorFilter *filter=NULL,
00188 bool isRecursive=FALSE,
00189 QWidget *parent=NULL,
00190 const char *name=NULL,
00191 WFlags f=0);
00192 SlFileSelector(QWidget *parent=NULL,const char *name=NULL,WFlags f=0);
00193 virtual ~SlFileSelector();
00194 void createFileList();
00195 void createFileList(QDir&);
00196 int fileCount() const;
00197 const QFileInfo* selected();
00198 void modifyItem(QFileInfo*,bool);
00199 void createItem(QString&);
00200 void deleteItem(const QString&);
00201 void deleteItem();
00202 void updateItem(const QString&);
00203 SlFileListItem* searchItem(const QString&);
00204 void setSelected();
00205 void setSelected(const QString&);
00206 void ensureItemVisible();
00207 SlFileListItem* selectedItem();
00208 bool setSelectedNext(bool);
00209 bool setSelectedPrev(bool);
00210 const QString currentDir();
00211 void setSorting(int,bool);
00212 int sortColumn() const;
00213 bool ascending() const;
00214 SlFileSelectorViewType viewType();
00215 void setColumnItem(SlFileListColumnConf&);
00216 void setViewType(SlFileSelectorViewType);
00217 void setListView();
00218 void setIconView();
00219 int columnWidth(int);
00220 void setColumnWidth(int,int);
00221 static const QString columnItemName(SlFileListItem::ColumnItem);
00222 static const SlFileListColumnConf columnItemList();
00223
00224 int columns() const;
00225
00226 bool upDir();
00227 bool isTopDir();
00228
00229 void setCurrentFile(const QString&);
00230 const QString currentFile(bool isReal=FALSE);
00231 static bool copyFile(const QString&,const QString&,
00232 SlFileOverwirteMode m=Error,
00233 QString *resultName=NULL);
00234
00235 static bool copyFileCreateDir(const QString &srcName,
00236 const QString &dstName,
00237 SlFileOverwirteMode m=Error,
00238 QString *resultName=NULL);
00239 static bool moveFile(const QString&,const QString&,
00240 SlFileOverwirteMode m=Error,
00241 QString *resultName=NULL);
00242 static QString getCopyFileName(const QString&);
00243
00244 const QStringList& recent() const;
00245 void setRecent(const QStringList&);
00246
00247
00248 void setRecent(const QStringList&,bool isReplace);
00249 void setRecentEnabled(bool);
00250
00251 const QStringList& history() const;
00252 void setHistory(const QStringList&);
00253
00254
00255 void setHistory(const QStringList&,bool isReplace);
00256 bool isHistoryBackAvailable() const;
00257 bool isHistoryForwardAvailable() const;
00258 bool historyBack();
00259 bool historyForward();
00260 QPopupMenu *backHistoryPopupMenu() const;
00261 QPopupMenu *forwardHistoryPopupMenu() const;
00262 void setColumnConf(SlFileListColumnConf&);
00263
00264 void sendFileUpdateMessage(const QString&);
00265 void updateView();
00266 void recreateIcon();
00267 void focusToNext();
00268 void focusToPrev();
00269 bool rename();
00270 bool newfolder();
00271 bool del();
00272 bool duplicate();
00273 bool cut();
00274 bool copy();
00275 bool paste();
00276 void setMimeFilter(const QString &);
00277 void clearTmpFolder();
00278
00279 void setRecursive(bool,bool);
00280 bool recursive() const;
00281 void setFilter(SlFileSelectorFilter *);
00282 SlFileSelectorFilter *filter();
00283 bool isEnablePaste();
00284
00285 static bool deleteFile(const QString&);
00286 static bool deleteDir(const QDir&);
00287 static bool copyDir(const QString &srcName,const QString &dstName,
00288 SlFileOverwirteMode m=Error);
00289 static bool moveDir(const QString&,const QString&,
00290 SlFileOverwirteMode m=Error);
00291 static QString getCopyDirName(const QString &);
00292 static bool makeDir(const QString &path);
00293
00294 static uint size(const QString &fName);
00295 static uint fileFree(const QString &fName);
00296
00297
00298
00299 enum DesktopMode {
00300
00301 HideDesktop = 1,
00302
00303 ShowAll,
00304
00305 FileTab
00306 };
00307 void setDesktopMode(DesktopMode mode);
00308 void setEnabledSystemChannel(bool);
00309 void showUpDirBtn(bool);
00310 void showWritableFile(bool);
00311
00312
00313 void setEnableSD(bool);
00314 void setEnableCF(bool);
00315 bool getEnableSD();
00316 bool getEnableCF();
00317
00318
00319
00320
00321 void sendKeyPressEvent( QKeyEvent *e );
00322
00323 void setScale(int scale);
00324 int scale() const;
00325
00326 SlMisc::SlListColumnInfos columnWidthInfos();
00327
00328
00329
00330 enum FocusMode {
00331
00332 Auto = 1,
00333
00334 ByTab,
00335
00336 ByCommand
00337 };
00338 void setFocusMode(FocusMode mode);
00339
00340 void adjustContentsSize();
00341
00342 static void updateFile(const QString &filename);
00343
00344 bool delFile(const QString &mymsg);
00345
00346 bool isIncludedFile(const QString &filename);
00347
00348 signals:
00349
00350
00351 void selectionChanged(const QFileInfo &file,bool isDevice);
00352
00353
00354 void fileSelected(const QFileInfo &file);
00355
00356
00357 void dirOpened(const QDir &dir);
00358
00359
00360 void enabledPaste(bool);
00361
00362
00363 void columnWidthChanged(int column,int oldSize,int newSize);
00364
00365
00366 void itemRightPressed(const QFileInfo &file,const QPoint &pos);
00367
00368
00369 void selectionLost();
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392 protected:
00393 void focusInEvent(QFocusEvent*);
00394 void show();
00395 void keyPressEvent( QKeyEvent *e );
00396
00397 private:
00398 void openDirInside(QDir&);
00399 void createMyPda();
00400 void init();
00401 SlFileSelectorPrivate *p;
00402 SlFileSelector(const SlFileSelector&);
00403 ulong focusWidgets() const;
00404 QWidget* nextFocus(QWidget *,bool) const;
00405 bool focusToTheWidget(QWidget *);
00406 };
00407
00408 #endif
00409
00410
00411
00412
00413