00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef OFILESELECTOR_H
00038 #define OFILESELECTOR_H
00039
00040
00041 #include <qpe/applnk.h>
00042
00043
00044 #include <qlist.h>
00045 #include <qwidget.h>
00046 #include <qmap.h>
00047 #include <qvaluelist.h>
00048 #include <qstringlist.h>
00049 #include <qlist.h>
00050
00051 class QLineEdit;
00052 class QComboBox;
00053 class QWidgetStack;
00054 class QHBox;
00055
00056 typedef QMap<QString, QStringList> MimeTypes;
00057
00058 namespace Opie {
00059 namespace Ui {
00060
00061 namespace Internal {
00062 class OFileViewInterface;
00063 class OFileViewFileListView;
00064 }
00065
00066
00078 class OFileSelector : public QWidget
00079 {
00080 Q_OBJECT
00081 friend class Internal::OFileViewInterface;
00082 friend class Internal::OFileViewFileListView;
00083
00084 public:
00092 enum Mode { Open = 1, Save = 2, DirectorySelector = 3, FileSelector = 4, OPEN = 1, SAVE = 2, DIRECTORYSELECTOR = 3, FILESELECTOR = 4 };
00093
00100 enum Selector { Normal = 0, Extended=1, ExtendedAll =2, Default=3, NORMAL=0,EXTENDED=1, EXTENDED_ALL =2, DEFAULT=3 };
00101
00102
00103 OFileSelector(QWidget* parent, int mode, int selector,
00104 const QString& dirName,
00105 const QString& fileName,
00106 const MimeTypes& mimetypes = MimeTypes(),
00107 bool newVisible = FALSE, bool closeVisible = FALSE );
00108
00109 OFileSelector(const QString& mimeFilter, QWidget* parent,
00110 const char* name = 0, bool newVisible = TRUE, bool closeVisible = FALSE );
00111 ~OFileSelector();
00112
00113 const DocLnk* selected();
00114
00115 QString selectedName()const;
00116 QString selectedPath()const;
00117 QString directory()const;
00118
00119 DocLnk selectedDocument()const;
00120
00121 int fileCount()const;
00122 void reread();
00123
00124 int mode()const;
00125 int selector()const;
00126
00131 void setNewVisible( bool b );
00132
00136 void setCloseVisible( bool b );
00137
00141 void setNameVisible( bool b );
00142
00143 signals:
00147 void dirSelected( const QString& );
00148
00153 void fileSelected( const DocLnk& );
00154
00159 void fileSelected( const QString& );
00160
00164 void newSelected( const DocLnk& );
00165
00166 void closeMe();
00167
00172 void ok();
00173 void cancel();
00174
00175
00176 private:
00177 bool showNew()const;
00178 bool showClose()const;
00179 MimeTypes mimeTypes()const;
00180 QStringList currentMimeType()const;
00181
00182 private:
00183
00184 void initUI();
00185
00186 void initMime();
00187
00188 void initViews();
00189
00190
00191
00192
00193
00194
00195 void registerView( const Internal::OFileViewInterface* );
00196
00197 private:
00198 QLineEdit* m_lneEdit;
00199 QComboBox *m_cmbView, *m_cmbMime;
00200 QWidgetStack* m_stack;
00201 Internal::OFileViewInterface* currentView() const;
00202 Internal::OFileViewInterface* m_current;
00203 bool m_shNew : 1;
00204 bool m_shClose : 1;
00205 MimeTypes m_mimeType;
00206
00207 QMap<QString, Internal::OFileViewInterface*> m_views;
00208
00209 QList<Internal::OFileViewInterface> m_viewsPtr;
00210 QHBox* m_nameBox;
00211 QHBox* m_cmbBox;
00212
00213 QString m_startDir;
00214 int m_mode;
00215 int m_selector;
00216
00217 QStringList m_allList;
00218
00219 struct Data;
00220 Data *d;
00221
00222 private slots:
00223 void slotMimeTypeChanged();
00224
00225
00226 void slotDocLnkBridge( const DocLnk& );
00227 void slotFileBridge( const QString& );
00228 void slotViewChange( const QString& );
00229
00230 bool eventFilter (QObject *o, QEvent *e);
00231
00232 };
00233
00234 }
00235 }
00236
00237 #endif