Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ofileselector.h

Go to the documentation of this file.
00001 /*
00002                              This file is part of the Opie Project
00003 
00004                              Copyright (C) 2002,2003 Holger Freyther <zecke@handhelds.org>
00005               =.
00006             .=l.
00007            .>+-=
00008  _;:,     .>    :=|.         This program is free software; you can
00009 .> <`_,   >  .   <=          redistribute it and/or  modify it under
00010 :`=1 )Y*s>-.--   :           the terms of the GNU Library General Public
00011 .="- .-=="i,     .._         License as published by the Free Software
00012  - .   .-<_>     .<>         Foundation; either version 2 of the License,
00013      ._= =}       :          or (at your option) any later version.
00014     .%`+i>       _;_.
00015     .i_,=:_.      -<s.       This program is distributed in the hope that
00016      +  .  -:.       =       it will be useful,  but WITHOUT ANY WARRANTY;
00017     : ..    .:,     . . .    without even the implied warranty of
00018     =_        +     =;=|`    MERCHANTABILITY or FITNESS FOR A
00019   _.=:.       :    :=>`:     PARTICULAR PURPOSE. See the GNU
00020 ..}^=.=       =       ;      Library General Public License for more
00021 ++=   -.     .`     .:       details.
00022     :     =  ...= . :.=-
00023  -.   .:....=;==+<;          You should have received a copy of the GNU
00024   -_. . .   )=.  =           Library General Public License along with
00025     --        :-=`           this library; see the file COPYING.LIB.
00026                              If not, write to the Free Software Foundation,
00027                              Inc., 59 Temple Place - Suite 330,
00028                              Boston, MA 02111-1307, USA.
00029 */
00030 
00031 /*
00032   This is based on code and ideas of
00033   L. J. Potter ljp@llornkcor.com
00034   Thanks a lot
00035 */
00036 
00037 #ifndef OFILESELECTOR_H
00038 #define OFILESELECTOR_H
00039 
00040 /* OPIE */
00041 #include <qpe/applnk.h>
00042 
00043 /* QT */
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     //    enum OldMode { OPEN=1, SAVE=2, FILESELECTOR = 4 };
00100     enum Selector { Normal = 0, Extended=1,  ExtendedAll =2, Default=3,  NORMAL=0,EXTENDED=1, EXTENDED_ALL =2, DEFAULT=3 };
00101     //    enum OldSelector { NORMAL = 0, EXTENDED =1, EXTENDED_ALL = 2};
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     /* used by the ViewInterface */
00176 private:
00177     bool showNew()const;
00178     bool showClose()const;
00179     MimeTypes mimeTypes()const;
00180     QStringList currentMimeType()const;
00181 
00182 private:
00183     /* inits the Widgets */
00184     void initUI();
00185     /* inits the MimeType ComboBox content + connects signals and slots */
00186     void initMime();
00187     /* init the Views :) */
00188     void initViews();
00189 
00190 
00191     /*
00192      * register a view for deletion.
00193      * This happens on creation of a OFileViewInterface
00194      */
00195     void registerView( const Internal::OFileViewInterface* );
00196 
00197 private:
00198     QLineEdit* m_lneEdit; // the LineEdit for the Name
00199     QComboBox *m_cmbView, *m_cmbMime; // two ComboBoxes to select the View and MimeType
00200     QWidgetStack* m_stack;  // our widget stack which will contain the views
00201     Internal::OFileViewInterface* currentView() const; // returns the currentView
00202     Internal::OFileViewInterface* m_current; // here is the view saved
00203     bool m_shNew   : 1; // should we show New?
00204     bool m_shClose : 1; // should we show Close?
00205     MimeTypes m_mimeType; // list of mimetypes
00206 
00207     QMap<QString, Internal::OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr
00208     /* views register themselves automatically */
00209     QList<Internal::OFileViewInterface> m_viewsPtr;
00210     QHBox* m_nameBox; // the LineEdit + Label is hold here
00211     QHBox* m_cmbBox; // this holds the two combo boxes
00212 
00213     QString m_startDir;
00214     int m_mode;
00215     int m_selector;
00216 
00217     QStringList m_allList;
00218 
00219     struct Data; // used for future versions
00220     Data *d;
00221 
00222 private slots:
00223     void slotMimeTypeChanged();
00224 
00225     /* will set the text of the lineedit and emit a fileChanged signal */
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

Generated on Sat Nov 5 16:16:25 2005 for OPIE by  doxygen 1.4.2