libopie API Documentation

ofileselector.h

00001 /*
00002   This is based on code and ideas of
00003   L. J. Potter ljp@llornkcor.com
00004   Thanks a lot
00005 
00006 
00007                =.            This file is part of the OPIE Project
00008              .=l.            Copyright (c)  2002,2003 Holger Freyther <zecke@handhelds.org>
00009            .>+-=
00010  _;:,     .>    :=|.         This library is free software; you can
00011 .> <`_,   >  .   <=          redistribute it and/or  modify it under
00012 :`=1 )Y*s>-.--   :           the terms of the GNU Library General Public
00013 .="- .-=="i,     .._         License as published by the Free Software
00014  - .   .-<_>     .<>         Foundation; either version 2 of the License,
00015      ._= =}       :          or (at your option) any later version.
00016     .%`+i>       _;_.
00017     .i_,=:_.      -<s.       This library is distributed in the hope that
00018      +  .  -:.       =       it will be useful,  but WITHOUT ANY WARRANTY;
00019     : ..    .:,     . . .    without even the implied warranty of
00020     =_        +     =;=|`    MERCHANTABILITY or FITNESS FOR A
00021   _.=:.       :    :=>`:     PARTICULAR PURPOSE. See the GNU
00022 ..}^=.=       =       ;      Library General Public License for more
00023 ++=   -.     .`     .:       details.
00024  :     =  ...= . :.=-
00025  -.   .:....=;==+<;          You should have received a copy of the GNU
00026   -_. . .   )=.  =           Library General Public License along with
00027     --        :-=`           this library; see the file COPYING.LIB.
00028                              If not, write to the Free Software Foundation,
00029                              Inc., 59 Temple Place - Suite 330,
00030                              Boston, MA 02111-1307, USA.
00031 
00032 */
00033 
00034 
00035 #ifndef OPIE_OFILESELECTOR_FOO_H
00036 #define OPIE_OFILESELECTOR_FOO_H
00037 
00038 #include <qlist.h>
00039 #include <qwidget.h>
00040 #include <qmap.h>
00041 #include <qvaluelist.h>
00042 #include <qstringlist.h>
00043 
00044 #include <qpe/applnk.h>
00045 
00046 typedef QMap<QString, QStringList> MimeTypes;
00047 
00048 class OFileViewInterface;
00049 class OFileViewFileListView;
00050 class QLineEdit;
00051 class QComboBox;
00052 class QWidgetStack;
00053 class QHBox;
00054 
00055 
00067 class OFileSelector : public QWidget {
00068     Q_OBJECT
00069     friend class OFileViewInterface;
00070     friend class OFileViewFileListView;
00071 public:
00078     enum Mode { Open=1, Save=2, FileSelector=4, OPEN=1, SAVE=2, FILESELECTOR=4 };
00079 //    enum OldMode { OPEN=1, SAVE=2, FILESELECTOR = 4 };
00086     enum Selector { Normal = 0, Extended=1,  ExtendedAll =2, Default=3,  NORMAL=0,EXTENDED=1, EXTENDED_ALL =2, DEFAULT=3 };
00087 //    enum OldSelector { NORMAL = 0, EXTENDED =1, EXTENDED_ALL = 2};
00088 
00089 
00090     OFileSelector(QWidget* parent, int mode, int selector,
00091                   const QString& dirName,
00092                   const QString& fileName,
00093                   const MimeTypes& mimetypes = MimeTypes(),
00094                   bool newVisible = FALSE, bool closeVisible = FALSE );
00095 
00096     OFileSelector(const QString& mimeFilter, QWidget* parent,
00097                   const char* name = 0,  bool newVisible = TRUE, bool closeVisible = FALSE );
00098     ~OFileSelector();
00099 
00100     const DocLnk* selected();
00101 
00102     QString selectedName()const;
00103     QString selectedPath()const;
00104     QString directory()const;
00105 
00106     DocLnk selectedDocument()const;
00107 
00108     int fileCount()const;
00109     void reread();
00110 
00111     int mode()const;
00112     int selector()const;
00113 
00118     void setNewVisible( bool b );
00119 
00123     void setCloseVisible( bool b );
00124 
00128     void setNameVisible( bool b );
00129 
00130 signals:
00134     void dirSelected( const QString& );
00135 
00140     void fileSelected( const DocLnk& );
00141 
00146     void fileSelected( const QString& );
00147 
00151     void newSelected( const DocLnk& );
00152 
00153     void closeMe();
00154 
00159     void ok();
00160     void cancel();
00161 
00162 /* used by the ViewInterface */
00163 private:
00164     bool showNew()const;
00165     bool showClose()const;
00166     MimeTypes mimeTypes()const;
00167     QStringList currentMimeType()const;
00168 
00169 private:
00170     /* inits the Widgets */
00171     void initUI();
00172     /* inits the MimeType ComboBox content + connects signals and slots */
00173     void initMime();
00174     /* init the Views :) */
00175     void initViews();
00176 
00177 private:
00178     QLineEdit* m_lneEdit; // the LineEdit for the Name
00179     QComboBox *m_cmbView, *m_cmbMime; // two ComboBoxes to select the View and MimeType
00180     QWidgetStack* m_stack;  // our widget stack which will contain the views
00181     OFileViewInterface* currentView()const; // returns the currentView
00182     OFileViewInterface* m_current; // here is the view saved
00183     bool m_shNew   : 1; // should we show New?
00184     bool m_shClose : 1; // should we show Close?
00185     MimeTypes m_mimeType; // list of mimetypes
00186 
00187     QMap<QString, OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr
00188     QHBox* m_nameBox; // the LineEdit + Label is hold here
00189     QHBox* m_cmbBox; // this holds the two combo boxes
00190 
00191     QString m_startDir;
00192     int m_mode;
00193     int m_selector;
00194 
00195     struct Data; // used for future versions
00196     Data *d;
00197 
00198 private slots:
00199     void slotMimeTypeChanged();
00200 
00201     /* will set the text of the lineedit and emit a fileChanged signal */
00202     void slotDocLnkBridge( const DocLnk& );
00203     void slotFileBridge( const QString& );
00204     void slotViewChange( const QString& );
00205 
00206     bool eventFilter (QObject *o, QEvent *e);
00207 
00208 };
00209 
00210 #endif
KDE Logo
This file is part of the documentation for OPIE Version 1.1.
Documentation copyright © 1997-2003 the KDE developers. 2003 OPIE developers
Generated on Tue Feb 10 20:24:44 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001