summaryrefslogtreecommitdiff
authorzecke <zecke>2002-03-27 23:29:41 (UTC)
committer zecke <zecke>2002-03-27 23:29:41 (UTC)
commitf78e31382d4e4076a4fb2017c22574859e7afdb3 (patch) (unidiff)
tree595c50f9398cb9555ead7670eb74a8523c540efc
parent071d9e5431473189a41841701e25dd03b08ab2b6 (diff)
downloadopie-f78e31382d4e4076a4fb2017c22574859e7afdb3.zip
opie-f78e31382d4e4076a4fb2017c22574859e7afdb3.tar.gz
opie-f78e31382d4e4076a4fb2017c22574859e7afdb3.tar.bz2
updates
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofileselector.cc64
-rw-r--r--libopie/ofileselector.h6
2 files changed, 67 insertions, 3 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc
index 53616f7..c9abde1 100644
--- a/libopie/ofileselector.cc
+++ b/libopie/ofileselector.cc
@@ -29,35 +29,40 @@
29#include <qnamespace.h> 29#include <qnamespace.h>
30#include <qpushbutton.h> 30#include <qpushbutton.h>
31#include <qcombobox.h> 31#include <qcombobox.h>
32#include <qhbox.h> 32#include <qhbox.h>
33#include <qvbox.h> 33#include <qvbox.h>
34#include <qlayout.h> 34#include <qlayout.h>
35#include <qwidgetstack.h> 35#include <qwidgetstack.h>
36#include <qlineedit.h> 36#include <qlineedit.h>
37#include <qcheckbox.h> 37#include <qcheckbox.h>
38#include <qlabel.h> 38#include <qlabel.h>
39 39
40#include <qpe/fileselector.h> 40#include <qpe/fileselector.h>
41#include <qpe/applnk.h>
42#include <qpe/global.h>
41 43
42#include "ofileselector.h" 44#include "ofileselector.h"
43 45
44 46
45OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, 47OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName,
46 const QString &fileName, const QStringList mimetypes ) : QWidget( wid ) 48 const QString &fileName, const QStringList mimetypes ) : QWidget( wid )
47{ 49{
48 m_selector = selector; 50 m_selector = selector;
49 m_currentDir = dirName; 51 m_currentDir = dirName;
50 m_name = fileName; 52 m_name = fileName;
51 m_mimetypes = mimetypes; 53 m_mimetypes = mimetypes;
54 if( mimetypes.isEmpty() )
55 m_autoMime = true;
56
52 m_mode = mode; 57 m_mode = mode;
53 m_shTool = true; 58 m_shTool = true;
54 m_shPerm = true; 59 m_shPerm = true;
55 m_shLne = true; 60 m_shLne = true;
56 m_shChooser = true; 61 m_shChooser = true;
57 m_shYesNo = true; 62 m_shYesNo = true;
58 // for FILESELECTOR only view is interesting 63 // for FILESELECTOR only view is interesting
59 m_location = 0; 64 m_location = 0;
60 m_homeButton = 0; 65 m_homeButton = 0;
61 m_docButton = 0; 66 m_docButton = 0;
62 m_hideButton = 0; 67 m_hideButton = 0;
63 m_ok = 0; 68 m_ok = 0;
@@ -73,24 +78,25 @@ OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString
73 m_lay = 0; 78 m_lay = 0;
74 m_boxToolbar = 0; 79 m_boxToolbar = 0;
75 m_boxOk = 0; 80 m_boxOk = 0;
76 m_edit = 0; 81 m_edit = 0;
77 82
78 m_fnLabel = 0; 83 m_fnLabel = 0;
79 m_checkPerm = 0; 84 m_checkPerm = 0;
80 m_mimeCheck = 0; 85 m_mimeCheck = 0;
81 m_viewCheck = 0; 86 m_viewCheck = 0;
82 87
83 m_lay = new QVBoxLayout(this); 88 m_lay = new QVBoxLayout(this);
84 init(); 89 init();
90 m_edit->setText( fileName );
85} 91}
86 92
87// let's initialize the gui 93// let's initialize the gui
88/** 94/**
89 -------------------- 95 --------------------
90 | cmbBox Button | 96 | cmbBox Button |
91 -------------------- 97 --------------------
92 | FileSlector | 98 | FileSlector |
93 | or | 99 | or |
94 | OSelector | 100 | OSelector |
95 | | 101 | |
96 | | 102 | |
@@ -317,37 +323,91 @@ void OFileSelector::initializeChooser()
317 323
318 m_mimeCheck = new QComboBox(this, "mime check"); 324 m_mimeCheck = new QComboBox(this, "mime check");
319 m_viewCheck = new QComboBox(this, "view check"); 325 m_viewCheck = new QComboBox(this, "view check");
320 m_boxView->addWidget(m_viewCheck, 0 ); 326 m_boxView->addWidget(m_viewCheck, 0 );
321 m_boxView->insertSpacing(1, 8 ); 327 m_boxView->insertSpacing(1, 8 );
322 m_boxView->addWidget(m_mimeCheck, 0 ); 328 m_boxView->addWidget(m_mimeCheck, 0 );
323 m_lay->addLayout(m_boxView ); 329 m_lay->addLayout(m_boxView );
324 330
325 m_viewCheck->insertItem(tr("Documents") ); 331 m_viewCheck->insertItem(tr("Documents") );
326 m_viewCheck->insertItem(tr("Files") ); 332 m_viewCheck->insertItem(tr("Files") );
327 m_viewCheck->insertItem(tr("All Files") ); 333 m_viewCheck->insertItem(tr("All Files") );
328 334
335 if(!m_autoMime )
336 m_mimeCheck->insertItem(m_mimetypes.join("," ) );
337 else{ // check
338 updateMimes();
339 m_mimeCheck->insertStringList( m_mimetypes );
340 }
341
329 connect( m_viewCheck, SIGNAL(activated(const QString &) ), 342 connect( m_viewCheck, SIGNAL(activated(const QString &) ),
330 this, SLOT(slotViewCheck(const QString & ) ) ); 343 this, SLOT(slotViewCheck(const QString & ) ) );
331 344
345 connect( m_mimeCheck, SIGNAL(activated(const QString &) ),
346 this, SLOT(slotMimeCheck(const QString & ) ) );
332} 347}
348void OFileSelector::slotMimeCheck(const QString &view ){
349 if(m_selector == NORMAL ){
350 delete m_select;
351 m_select = new FileSelector(view == "All" ? QString::null : view
352 , m_stack, "fileselector", FALSE, FALSE );
353 m_stack->addWidget( m_select, NORMAL );
354 m_stack->raiseWidget( NORMAL );
355 }else{
333 356
334 357
358 }
359}
360
335void OFileSelector::slotViewCheck(const QString &view ){ 361void OFileSelector::slotViewCheck(const QString &view ){
336 qWarning("changed: show %s", view.latin1() ); 362 qWarning("changed: show %s", view.latin1() );
337 // if the current view is the one 363 // if the current view is the one
338 364 QString currMime = m_mimeCheck->currentText();
339 if( view == QString::fromLatin1("Documents") ){ 365 if( view == QString::fromLatin1("Documents") ){
340 // get the mimetype now 366 // get the mimetype now
341 // check if we're the current widget and return 367 // check if we're the current widget and return
368 delete m_select;
369 m_select = new FileSelector( currMime == "All" ? QString::null : currMime,
370 m_stack,"fileselector", FALSE, FALSE );
371 m_stack->addWidget( m_select, NORMAL );
372 m_stack->raiseWidget( NORMAL );
373 m_selector = NORMAL;
374
342 }else if(view == QString::fromLatin1("Files") ){ 375 }else if(view == QString::fromLatin1("Files") ){
343 if( m_select != 0 ){ 376 if( m_select != 0 ){
344 // remove from the stack 377 // remove from the stack
345 delete m_select; 378 delete m_select;
346 m_select = 0; 379 m_select = 0;
380 m_selector = EXTENDED;
381 // create the ListView or IconView
382
383 reparse();
347 } 384 }
348 }else if(view == QString::fromLatin1("All Files") ) { 385 }else if(view == QString::fromLatin1("All Files") ) {
349 // remove from the stack 386 // remove from the stack
350 delete m_select; 387 delete m_select;
351 m_select = 0; 388 m_select = 0;
389 m_selector = EXTENDED_ALL;
390
391 reparse();
352 }; 392 };
353}; 393};
394
395
396void OFileSelector::updateMimes() // lets check which mode is active
397 // check the current dir for items then
398{
399 m_mimetypes.clear();
400 m_mimetypes.append("All" );
401 if( m_selector == NORMAL ){
402 DocLnkSet set;
403 Global::findDocuments(&set, QString::null );
404 QListIterator<DocLnk> dit( set.children() );
405 for ( ; dit.current(); ++dit ) {
406 if( !m_mimetypes.contains((*dit)->type() ) )
407 m_mimetypes.append( (*dit)->type() );
408 }
409 }else{
410
411
412 }
413};
diff --git a/libopie/ofileselector.h b/libopie/ofileselector.h
index 3f53fa9..757a960 100644
--- a/libopie/ofileselector.h
+++ b/libopie/ofileselector.h
@@ -75,25 +75,26 @@ class OFileSelectorItem : public QListViewItem {
75 } 75 }
76 QString path()const{ 76 QString path()const{
77 return text(1 ); 77 return text(1 );
78 } 78 }
79 private: 79 private:
80 bool dir:1; 80 bool dir:1;
81}; 81};
82 82
83class OFileSelector : public QWidget { 83class OFileSelector : public QWidget {
84 Q_OBJECT 84 Q_OBJECT
85 public: 85 public:
86 enum Mode {OPEN=1, SAVE, FILESELECTOR }; 86 enum Mode {OPEN=1, SAVE, FILESELECTOR };
87 enum Selector{NORMAL=1, EXTENDED }; 87 enum Selector{NORMAL=1, EXTENDED = 2, EXTENDED_ALL =4 };
88 enum View { DIRS = 1, FILES = 2, TREE = 4, ICON = 8 };
88 OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, const QString &fileName = QString::null, const QStringList mimetypes = QStringList() ); 89 OFileSelector(QWidget *wid, int mode, int selector, const QString &dirName, const QString &fileName = QString::null, const QStringList mimetypes = QStringList() );
89 90
90 bool showToolbar() const { return m_shTool; }; 91 bool showToolbar() const { return m_shTool; };
91 bool showPermissionBar() const { return m_shPerm; }; 92 bool showPermissionBar() const { return m_shPerm; };
92 bool showLineEdit()const { return m_shLne; }; 93 bool showLineEdit()const { return m_shLne; };
93 bool showChooser( )const { return m_shChooser; }; 94 bool showChooser( )const { return m_shChooser; };
94 bool showYesCancel()const { return m_shYesNo; }; 95 bool showYesCancel()const { return m_shYesNo; };
95 void setShowYesCancel( bool show ); 96 void setShowYesCancel( bool show );
96 void setShowToolbar( bool show ); 97 void setShowToolbar( bool show );
97 void setShowPermissionBar( bool show ); 98 void setShowPermissionBar( bool show );
98 void setShowLineEdit(bool show) ; 99 void setShowLineEdit(bool show) ;
99 void setShowChooser( bool chooser ); 100 void setShowChooser( bool chooser );
@@ -114,26 +115,28 @@ class OFileSelector : public QWidget {
114 115
115 signals: 116 signals:
116 void fileSelected( const DocLnk & ); 117 void fileSelected( const DocLnk & );
117 void fileSelected( const QString & ); 118 void fileSelected( const QString & );
118 void closeMe(); 119 void closeMe();
119 void ok(); 120 void ok();
120 void cancel(); 121 void cancel();
121 122
122 protected slots: 123 protected slots:
123 void slotOk(); 124 void slotOk();
124 void slotCancel(); 125 void slotCancel();
125 void slotViewCheck(const QString & ); 126 void slotViewCheck(const QString & );
127 void slotMimeCheck(const QString & );
126 protected: 128 protected:
127 void init(); 129 void init();
130 void updateMimes();
128 int m_mode, m_selector; 131 int m_mode, m_selector;
129 QComboBox *m_location, *m_mimeCheck, *m_viewCheck; 132 QComboBox *m_location, *m_mimeCheck, *m_viewCheck;
130 QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel; 133 QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel;
131 QPushButton *m_reread, *m_up; 134 QPushButton *m_reread, *m_up;
132 QListView *m_View; 135 QListView *m_View;
133 QCheckBox *m_checkPerm; 136 QCheckBox *m_checkPerm;
134 137
135 QString m_currentDir; 138 QString m_currentDir;
136 QString m_name; 139 QString m_name;
137 QStringList m_mimetypes; 140 QStringList m_mimetypes;
138 141
139 FileSelector *m_select; 142 FileSelector *m_select;
@@ -145,24 +148,25 @@ class OFileSelector : public QWidget {
145 QHBoxLayout *m_boxOk; 148 QHBoxLayout *m_boxOk;
146 QHBoxLayout *m_boxName; 149 QHBoxLayout *m_boxName;
147 QHBoxLayout *m_boxView; 150 QHBoxLayout *m_boxView;
148 151
149 QLineEdit *m_edit; 152 QLineEdit *m_edit;
150 QLabel *m_fnLabel; 153 QLabel *m_fnLabel;
151 bool m_shTool:1; 154 bool m_shTool:1;
152 bool m_shPerm:1; 155 bool m_shPerm:1;
153 bool m_shLne:1; 156 bool m_shLne:1;
154 bool m_shChooser:1; 157 bool m_shChooser:1;
155 bool m_shYesNo:1; 158 bool m_shYesNo:1;
156 bool m_boCheckPerm:1; 159 bool m_boCheckPerm:1;
160 bool m_autoMime:1;
157 161
158 protected: 162 protected:
159 163
160 private: 164 private:
161 void delItems(); 165 void delItems();
162 void initializeName(); 166 void initializeName();
163 void initializeYes(); 167 void initializeYes();
164 void initializeChooser(); 168 void initializeChooser();
165 169
166 class OFileSelectorPrivate; 170 class OFileSelectorPrivate;
167 OFileSelectorPrivate *d; 171 OFileSelectorPrivate *d;
168 172