summaryrefslogtreecommitdiff
path: root/libopie/ofileselector.cc
authorzecke <zecke>2002-03-27 21:16:14 (UTC)
committer zecke <zecke>2002-03-27 21:16:14 (UTC)
commit7c7e333e184d93f2c6812c9a3c69f734058eabd6 (patch) (unidiff)
tree314812d45f1944b4aba50267f10486970f02e904 /libopie/ofileselector.cc
parent69b792993e0434b18a932c7ec199dc8d72b3d8fd (diff)
downloadopie-7c7e333e184d93f2c6812c9a3c69f734058eabd6.zip
opie-7c7e333e184d93f2c6812c9a3c69f734058eabd6.tar.gz
opie-7c7e333e184d93f2c6812c9a3c69f734058eabd6.tar.bz2
here comes the skeleton of the new fileselector.
Please comment on the api? Sissi are you reading this? Please send me input
Diffstat (limited to 'libopie/ofileselector.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofileselector.cc353
1 files changed, 353 insertions, 0 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc
new file mode 100644
index 0000000..53616f7
--- a/dev/null
+++ b/libopie/ofileselector.cc
@@ -0,0 +1,353 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 <>
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#include <qnamespace.h>
30#include <qpushbutton.h>
31#include <qcombobox.h>
32#include <qhbox.h>
33#include <qvbox.h>
34#include <qlayout.h>
35#include <qwidgetstack.h>
36#include <qlineedit.h>
37#include <qcheckbox.h>
38#include <qlabel.h>
39
40#include <qpe/fileselector.h>
41
42#include "ofileselector.h"
43
44
45OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName,
46 const QString &fileName, const QStringList mimetypes ) : QWidget( wid )
47{
48 m_selector = selector;
49 m_currentDir = dirName;
50 m_name = fileName;
51 m_mimetypes = mimetypes;
52 m_mode = mode;
53 m_shTool = true;
54 m_shPerm = true;
55 m_shLne = true;
56 m_shChooser = true;
57 m_shYesNo = true;
58 // for FILESELECTOR only view is interesting
59 m_location = 0;
60 m_homeButton = 0;
61 m_docButton = 0;
62 m_hideButton = 0;
63 m_ok = 0;
64 m_cancel = 0;
65 m_reread = 0;
66 m_up = 0;
67 m_View = 0;
68 m_select = 0;
69 m_stack = 0;
70
71 m_select = 0;
72 m_stack = 0;
73 m_lay = 0;
74 m_boxToolbar = 0;
75 m_boxOk = 0;
76 m_edit = 0;
77
78 m_fnLabel = 0;
79 m_checkPerm = 0;
80 m_mimeCheck = 0;
81 m_viewCheck = 0;
82
83 m_lay = new QVBoxLayout(this);
84 init();
85}
86
87// let's initialize the gui
88/**
89 --------------------
90 | cmbBox Button |
91 --------------------
92 | FileSlector |
93 | or |
94 | OSelector |
95 | |
96 | |
97 ____________________
98 | LineEdit |
99 ____________________
100 | Permission Bar |
101 ____________________
102 | ViewChoose |
103 ____________________
104 | Save Cancel|
105 ____________________
106 */
107void OFileSelector::delItems()
108{
109 QLayoutIterator it = m_lay->iterator();
110 while ( it.current() != 0 ){
111 it.deleteCurrent();
112 }
113}
114void OFileSelector::init()
115{
116
117 m_stack = new QWidgetStack(this, "wstack" );
118 m_select = new FileSelector(m_mimetypes.join(";"), m_stack, "fileselector", FALSE, FALSE );
119 m_stack->addWidget(m_select, NORMAL );
120 m_lay->addWidget(m_stack );
121 m_stack->raiseWidget(NORMAL );
122
123 if(m_shLne ){
124 initializeName();
125 }
126
127 if(m_shPerm ){
128 m_checkPerm = new QCheckBox(tr("Set Permission"), this, "Permission" );
129 m_checkPerm->setChecked( false );
130 m_lay->addWidget(m_checkPerm );
131 }
132
133 if( m_shChooser )
134 initializeChooser();
135
136 if(m_shYesNo )
137 initializeYes();
138
139
140};
141
142void OFileSelector::setShowYesCancel( bool show )
143{
144 if ( show == m_shYesNo )
145 return;
146 m_shYesNo = show;
147 if( !show ){
148 delete m_ok;
149 delete m_cancel;
150 m_ok = 0;
151 m_cancel = 0;
152 // delete m_boxOk; all ready deleted in delItems
153 }
154 updateLay(); // recreate it and save the other states
155}
156
157void OFileSelector::setShowToolbar( bool show )
158{
159 if ( m_shTool == show )
160 return;
161 /* if( show ){
162
163 }else {
164
165 }*/
166}
167
168void OFileSelector::setShowPermissionBar( bool show )
169{
170 if( show == m_shPerm )
171 return;
172
173 m_shPerm = show;
174
175 updateLay();
176}
177void OFileSelector::setShowLineEdit( bool show )
178{
179 if( show == m_shLne )
180 return;
181
182 m_shLne = show;
183 if( !show ){
184 delete m_edit;
185 delete m_fnLabel;
186 m_edit = 0;
187 m_fnLabel = 0;
188 //delete m_boxName; will be deleted
189 }
190 updateLay();
191}
192void OFileSelector::setShowChooser( bool show )
193{
194 if( show = m_shChooser )
195 return;
196 m_shChooser = show;
197 if( !show ){
198 delete m_mimeCheck;
199 delete m_viewCheck;
200 m_mimeCheck = 0;
201 m_viewCheck = 0;
202 }
203 updateLay();
204}
205QCheckBox* OFileSelector::permissionCheckbox( )
206{
207 return m_checkPerm;
208}
209bool OFileSelector::setPermission( ) const
210{
211 if( m_checkPerm == 0 )
212 return false;
213 else
214 return m_checkPerm->isChecked();
215}
216void OFileSelector::setPermissionChecked( bool check )
217{
218 if( m_checkPerm == 0 )
219 return;
220 m_checkPerm->setChecked( check );
221}
222QString OFileSelector::selectedName( )
223{
224 QString string;
225 return string;
226}
227const DocLnk* OFileSelector::selectedDocument( )const
228{
229 return 0;
230}
231void OFileSelector::updateLay()
232{
233 /* if( m_shTool )
234 //
235 else
236 // hide
237 */
238 // save the state
239 bool check = false;
240 if( m_checkPerm != 0 )
241 check = m_checkPerm->isChecked();
242 QString text;
243
244 if( m_edit != 0 )
245 text = m_edit->text();
246 // save current mimetype
247
248 delItems();
249 delete m_checkPerm;
250 delete m_edit;
251 delete m_fnLabel;
252 delete m_ok;
253 delete m_cancel;
254 delete m_mimeCheck;
255 delete m_viewCheck;
256 delete m_select; // test
257 delete m_stack;
258 //delete m_list;
259 init();
260 if( m_shLne )
261 m_edit->setText(text );
262 if( m_shPerm )
263 m_checkPerm->setChecked(check );
264}
265void OFileSelector::reparse()
266{
267
268}
269QString OFileSelector::directory()
270{
271 QString string;
272 return string;
273}
274int OFileSelector::fileCount()
275{
276 return 0;
277}
278void OFileSelector::slotOk( )
279{
280 emit ok();
281}
282void OFileSelector::slotCancel( )
283{
284 emit cancel();
285}
286
287void OFileSelector::initializeName()
288{
289 m_boxName = new QHBoxLayout(this );
290 m_edit = new QLineEdit(this );
291 m_fnLabel = new QLabel(this );
292 m_fnLabel->setText(tr("Name:") );
293 m_boxName->addWidget(m_fnLabel );
294 m_boxName->insertSpacing(1, 8 );
295 m_boxName->addWidget(m_edit, 100 );
296
297 m_lay->addLayout(m_boxName);
298}
299void OFileSelector::initializeYes()
300{
301 m_ok = new QPushButton("&Save", this, "save" );
302 m_cancel = new QPushButton("C&ancel", this, "cancel" );
303 m_boxOk = new QHBoxLayout(this );
304 m_boxOk->addWidget( m_ok, Qt::AlignHCenter );
305 m_boxOk->insertSpacing(1, 8 );
306 m_boxOk->addWidget( m_cancel, Qt::AlignHCenter);
307 m_lay->addLayout(m_boxOk );
308 connect(m_ok, SIGNAL(clicked() ),
309 this, SLOT(slotOk() ) );
310 connect(m_cancel, SIGNAL(clicked() ),
311 this, SLOT(slotCancel() ) );
312
313}
314void OFileSelector::initializeChooser()
315{
316 m_boxView = new QHBoxLayout(this );
317
318 m_mimeCheck = new QComboBox(this, "mime check");
319 m_viewCheck = new QComboBox(this, "view check");
320 m_boxView->addWidget(m_viewCheck, 0 );
321 m_boxView->insertSpacing(1, 8 );
322 m_boxView->addWidget(m_mimeCheck, 0 );
323 m_lay->addLayout(m_boxView );
324
325 m_viewCheck->insertItem(tr("Documents") );
326 m_viewCheck->insertItem(tr("Files") );
327 m_viewCheck->insertItem(tr("All Files") );
328
329 connect( m_viewCheck, SIGNAL(activated(const QString &) ),
330 this, SLOT(slotViewCheck(const QString & ) ) );
331
332}
333
334
335void OFileSelector::slotViewCheck(const QString &view ){
336 qWarning("changed: show %s", view.latin1() );
337 // if the current view is the one
338
339 if( view == QString::fromLatin1("Documents") ){
340 // get the mimetype now
341 // check if we're the current widget and return
342 }else if(view == QString::fromLatin1("Files") ){
343 if( m_select != 0 ){
344 // remove from the stack
345 delete m_select;
346 m_select = 0;
347 }
348 }else if(view == QString::fromLatin1("All Files") ) {
349 // remove from the stack
350 delete m_select;
351 m_select = 0;
352 };
353};