summaryrefslogtreecommitdiff
path: root/libopie2/opieui/fileselector/ofileselector.h
Unidiff
Diffstat (limited to 'libopie2/opieui/fileselector/ofileselector.h') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opieui/fileselector/ofileselector.h161
1 files changed, 161 insertions, 0 deletions
diff --git a/libopie2/opieui/fileselector/ofileselector.h b/libopie2/opieui/fileselector/ofileselector.h
new file mode 100644
index 0000000..7abe8b7
--- a/dev/null
+++ b/libopie2/opieui/fileselector/ofileselector.h
@@ -0,0 +1,161 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (C) 2002,2003 Holger Freyther <zecke@handhelds.org>
4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details.
19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29/*
30 This is based on code and ideas of
31 L. J. Potter ljp@llornkcor.com
32 Thanks a lot
33*/
34
35#ifndef OFILESELECTOR_H
36#define OFILESELECTOR_H
37
38/* OPIE */
39#include <qpe/applnk.h>
40
41/* QT */
42#include <qlist.h>
43#include <qwidget.h>
44#include <qmap.h>
45#include <qvaluelist.h>
46#include <qstringlist.h>
47
48class QLineEdit;
49class QComboBox;
50class QWidgetStack;
51class QHBox;
52
53typedef QMap<QString, QStringList> MimeTypes;
54
55namespace Opie
56{
57
58class OFileViewInterface;
59class OFileViewFileListView;
60
61class OFileSelector : public QWidget
62{
63 Q_OBJECT
64 friend class Opie::OFileViewInterface;
65 friend class Opie::OFileViewFileListView;
66
67public:
68 enum Mode { Open=1, Save=2, FileSelector=4, OPEN=1, SAVE=2, FILESELECTOR=4 };
69 // enum OldMode { OPEN=1, SAVE=2, FILESELECTOR = 4 };
70 enum Selector { Normal = 0, Extended=1, ExtendedAll =2, Default=3, NORMAL=0,EXTENDED=1, EXTENDED_ALL =2, DEFAULT=3 };
71 // enum OldSelector { NORMAL = 0, EXTENDED =1, EXTENDED_ALL = 2};
72
73 OFileSelector(QWidget* parent, int mode, int selector,
74 const QString& dirName,
75 const QString& fileName,
76 const MimeTypes& mimetypes = MimeTypes(),
77 bool newVisible = FALSE, bool closeVisible = FALSE );
78
79 OFileSelector(const QString& mimeFilter, QWidget* parent,
80 const char* name = 0, bool newVisible = TRUE, bool closeVisible = FALSE );
81 ~OFileSelector();
82
83 const DocLnk* selected();
84
85 QString selectedName()const;
86 QString selectedPath()const;
87 QString directory()const;
88
89 DocLnk selectedDocument()const;
90
91 int fileCount()const;
92 void reread();
93
94 int mode()const;
95 int selector()const;
96
97
98 void setNewVisible( bool b );
99 void setCloseVisible( bool b );
100 void setNameVisible( bool b );
101
102signals:
103 void dirSelected( const QString& );
104 void fileSelected( const DocLnk& );
105 void fileSelected( const QString& );
106 void newSelected( const DocLnk& );
107 void closeMe();
108 void ok();
109 void cancel();
110
111 /* used by the ViewInterface */
112private:
113 bool showNew()const;
114 bool showClose()const;
115 MimeTypes mimeTypes()const;
116 QStringList currentMimeType()const;
117
118private:
119 /* inits the Widgets */
120 void initUI();
121 /* inits the MimeType ComboBox content + connects signals and slots */
122 void initMime();
123 /* init the Views :) */
124 void initViews();
125
126private:
127 QLineEdit* m_lneEdit; // the LineEdit for the Name
128 QComboBox *m_cmbView, *m_cmbMime; // two ComboBoxes to select the View and MimeType
129 QWidgetStack* m_stack; // our widget stack which will contain the views
130 OFileViewInterface* currentView() const; // returns the currentView
131 OFileViewInterface* m_current; // here is the view saved
132 bool m_shNew : 1; // should we show New?
133 bool m_shClose : 1; // should we show Close?
134 MimeTypes m_mimeType; // list of mimetypes
135
136 QMap<QString, OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr
137 QHBox* m_nameBox; // the LineEdit + Label is hold here
138 QHBox* m_cmbBox; // this holds the two combo boxes
139
140 QString m_startDir;
141 int m_mode;
142 int m_selector;
143
144 struct Data; // used for future versions
145 Data *d;
146
147private slots:
148 void slotMimeTypeChanged();
149
150 /* will set the text of the lineedit and emit a fileChanged signal */
151 void slotDocLnkBridge( const DocLnk& );
152 void slotFileBridge( const QString& );
153 void slotViewChange( const QString& );
154
155 bool eventFilter (QObject *o, QEvent *e);
156
157};
158
159};
160
161#endif