summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/fileselector/ofileselector.cpp15
-rw-r--r--libopie2/opieui/fileselector/ofileselector_p.h4
2 files changed, 11 insertions, 8 deletions
diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp
index 01a51a2..718f743 100644
--- a/libopie2/opieui/fileselector/ofileselector.cpp
+++ b/libopie2/opieui/fileselector/ofileselector.cpp
@@ -150,245 +150,248 @@ QString OFileViewInterface::currentFileName()const
150{ 150{
151 return selector()->m_lneEdit->text(); 151 return selector()->m_lneEdit->text();
152} 152}
153 153
154QString OFileViewInterface::startDirectory()const 154QString OFileViewInterface::startDirectory()const
155{ 155{
156 return selector()->m_startDir; 156 return selector()->m_startDir;
157} 157}
158 158
159bool OFileViewInterface::allItem( const QString& item )const 159bool OFileViewInterface::allItem( const QString& item )const
160{ 160{
161 return selector()->m_allList.contains( item ); 161 return selector()->m_allList.contains( item );
162} 162}
163 163
164 164
165ODocumentFileView::ODocumentFileView( OFileSelector* selector ) 165ODocumentFileView::ODocumentFileView( OFileSelector* selector )
166 :OFileViewInterface( selector ) 166 :OFileViewInterface( selector )
167{ 167{
168 m_selector = 0; 168 m_selector = 0;
169 setName( QObject::tr("Documents") ); 169 setName( QObject::tr("Documents") );
170} 170}
171 171
172ODocumentFileView::~ODocumentFileView() 172ODocumentFileView::~ODocumentFileView()
173{ 173{
174} 174}
175 175
176QString ODocumentFileView::selectedName()const 176QString ODocumentFileView::selectedName()const
177{ 177{
178 if (!m_selector) 178 if (!m_selector)
179 return QString::null; 179 return QString::null;
180 180
181 return m_selector->selectedDocument().file(); 181 return m_selector->selectedDocument().file();
182} 182}
183 183
184QString ODocumentFileView::selectedPath()const 184QString ODocumentFileView::selectedPath()const
185{ 185{
186 return QPEApplication::documentDir(); 186 return QPEApplication::documentDir();
187} 187}
188 188
189QString ODocumentFileView::directory()const 189QString ODocumentFileView::directory()const
190{ 190{
191 return selectedPath(); 191 return selectedPath();
192} 192}
193 193
194void ODocumentFileView::reread() 194void ODocumentFileView::reread()
195{ 195{
196 if (!m_selector) 196 if (!m_selector)
197 return; 197 return;
198 198
199 m_selector->setNewVisible( showNew() ); 199 m_selector->setNewVisible( showNew() );
200 m_selector->setCloseVisible( showClose() ); 200 m_selector->setCloseVisible( showClose() );
201 m_selector->filter = currentMimeType().join(";"); 201 m_selector->filter = currentMimeType().join(";");
202 m_selector->reread(); 202 m_selector->reread();
203} 203}
204 204
205int ODocumentFileView::fileCount()const 205int ODocumentFileView::fileCount()const
206{ 206{
207 if (!m_selector) 207 if (!m_selector)
208 return -1; 208 return -1;
209 209
210 return m_selector->fileCount(); 210 return m_selector->fileCount();
211} 211}
212 212
213DocLnk ODocumentFileView::selectedDocument()const 213DocLnk ODocumentFileView::selectedDocument()const
214{ 214{
215 if (!m_selector) 215 if (!m_selector)
216 return DocLnk(); 216 return DocLnk();
217 217
218 return m_selector->selectedDocument(); 218 return m_selector->selectedDocument();
219} 219}
220 220
221QWidget* ODocumentFileView::widget( QWidget* parent ) 221QWidget* ODocumentFileView::widget( QWidget* parent )
222{ 222{
223 if (!m_selector ) 223 if (!m_selector )
224 { 224 {
225 m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() ); 225 m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() );
226 QObject::connect(m_selector, SIGNAL(fileSelected(const DocLnk&) ), 226 QObject::connect(m_selector, SIGNAL(fileSelected(const DocLnk&) ),
227 selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) ); 227 selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) );
228 QObject::connect(m_selector, SIGNAL(closeMe() ), 228 QObject::connect(m_selector, SIGNAL(closeMe() ),
229 selector(), SIGNAL(closeMe() ) ); 229 selector(), SIGNAL(closeMe() ) );
230 QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk&) ), 230 QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk&) ),
231 selector(), SIGNAL(newSelected(const DocLnk&) ) ); 231 selector(), SIGNAL(newSelected(const DocLnk&) ) );
232 } 232 }
233 233
234 return m_selector; 234 return m_selector;
235} 235}
236 236
237/* 237/*
238 * This is the file system view used 238 * This is the file system view used
239 * we use a QListView + QListViewItems for it 239 * we use a QListView + QListViewItems for it
240 */ 240 */
241 241
242OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap, 242OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap,
243 const QString& path, const QString& date, 243 const QString& path, const QString& date,
244 const QString& size, const QString& dir, 244 const QString& size, const QString& dir,
245 bool isLocked, bool isDir ) 245 bool isLocked, bool isDir )
246 : QListViewItem( view ) 246 : QListViewItem( view ), m_dir(dir), m_isDir(isDir), m_locked(isLocked)
247{ 247{
248 setPixmap(0, pixmap ); 248 setPixmap(0, pixmap );
249 setText(1, path ); 249 setText(1, path );
250 setText(2, size ); 250 setText(2, size );
251 setText(3, date ); 251 setText(3, date );
252 m_isDir = isDir;
253 m_dir = dir;
254 m_locked = isLocked;
255} 252}
256 253
257OFileSelectorItem::~OFileSelectorItem() 254OFileSelectorItem::~OFileSelectorItem()
258{ 255{
259} 256}
260 257
261bool OFileSelectorItem::isLocked()const 258bool OFileSelectorItem::isLocked()const
262{ 259{
263 return m_locked; 260 return m_locked;
264} 261}
265 262
266QString OFileSelectorItem::directory()const 263QString OFileSelectorItem::directory()const
267{ 264{
268 return m_dir; 265 return m_dir;
269} 266}
270 267
271bool OFileSelectorItem::isDir()const 268bool OFileSelectorItem::isDir()const
272{ 269{
273 return m_isDir; 270 return m_isDir;
274} 271}
275 272
276QString OFileSelectorItem::path()const 273QString OFileSelectorItem::path()const
277{ 274{
278 return text( 1 ); 275 return text( 1 );
279} 276}
280 277
281QString OFileSelectorItem::key( int id, bool )const 278QString OFileSelectorItem::key( int id, bool )const
282{ 279{
283 QString ke; 280 QString ke;
281
282 /*
283 * id = 0 ||id == 1 : Sort By Name but Directories at Top
284 * id = 2 : Sort By Size: Prepend '0' to the key
285 */
284 if( id == 0 || id == 1 ) 286 if( id == 0 || id == 1 )
285 { // name 287 { // name
286 if( m_isDir ) 288 if( m_isDir )
287 { 289 {
288 ke.append("0" ); 290 ke.append("0" );
289 ke.append( text(1) ); 291 ke.append( text(1) );
290 } 292 }
291 else 293 else
292 { 294 {
293 ke.append("1" ); 295 ke.append("1" );
294 ke.append( text(1) ); 296 ke.append( text(1) );
295 } 297 }
296 return ke; 298 return ke;
297 } 299 }else if(id == 2) {
298 else 300 return text(2).rightJustify(20, '0');
301 }else
299 return text( id ); 302 return text( id );
300 303
301} 304}
302 305
303OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, OFileSelector* sel) 306OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, OFileSelector* sel)
304 :QWidget( parent ), m_sel( sel ) 307 :QWidget( parent ), m_sel( sel )
305{ 308{
306 m_all = false; 309 m_all = false;
307 QVBoxLayout* lay = new QVBoxLayout( this ); 310 QVBoxLayout* lay = new QVBoxLayout( this );
308 m_currentDir = startDir; 311 m_currentDir = startDir;
309 312
310 /* 313 /*
311 * now we add a special bar 314 * now we add a special bar
312 * One Button For Up 315 * One Button For Up
313 * Home 316 * Home
314 * Doc 317 * Doc
315 * And a dropdown menu with FileSystems 318 * And a dropdown menu with FileSystems
316 * FUTURE: one to change dir with lineedit 319 * FUTURE: one to change dir with lineedit
317 * Bookmarks 320 * Bookmarks
318 * Create Dir 321 * Create Dir
319 */ 322 */
320 QHBox* box = new QHBox(this ); 323 QHBox* box = new QHBox(this );
321 box->setBackgroundMode( PaletteButton ); 324 box->setBackgroundMode( PaletteButton );
322 box->setSpacing( 0 ); 325 box->setSpacing( 0 );
323 326
324 QToolButton *btn = new QToolButton( box ); 327 QToolButton *btn = new QToolButton( box );
325 btn->setIconSet( Resource::loadIconSet("up") ); 328 btn->setIconSet( Resource::loadIconSet("up") );
326 connect(btn, SIGNAL(clicked() ), 329 connect(btn, SIGNAL(clicked() ),
327 this, SLOT( cdUP() ) ); 330 this, SLOT( cdUP() ) );
328 331
329 btn = new QToolButton( box ); 332 btn = new QToolButton( box );
330 btn->setIconSet( Resource::loadIconSet("home") ); 333 btn->setIconSet( Resource::loadIconSet("home") );
331 connect(btn, SIGNAL(clicked() ), 334 connect(btn, SIGNAL(clicked() ),
332 this, SLOT( cdHome() ) ); 335 this, SLOT( cdHome() ) );
333 336
334 btn = new QToolButton( box ); 337 btn = new QToolButton( box );
335 btn->setIconSet( Resource::loadIconSet("DocsIcon") ); 338 btn->setIconSet( Resource::loadIconSet("DocsIcon") );
336 connect(btn, SIGNAL(clicked() ), 339 connect(btn, SIGNAL(clicked() ),
337 this, SLOT(cdDoc() ) ); 340 this, SLOT(cdDoc() ) );
338 341
339 m_btnNew = new QToolButton( box ); 342 m_btnNew = new QToolButton( box );
340 m_btnNew->setIconSet( Resource::loadIconSet("new") ); 343 m_btnNew->setIconSet( Resource::loadIconSet("new") );
341 connect(m_btnNew, SIGNAL(clicked() ), 344 connect(m_btnNew, SIGNAL(clicked() ),
342 this, SLOT(slotNew() ) ); 345 this, SLOT(slotNew() ) );
343 346
344 347
345 m_btnClose = new QToolButton( box ); 348 m_btnClose = new QToolButton( box );
346 m_btnClose->setIconSet( Resource::loadIconSet("close") ); 349 m_btnClose->setIconSet( Resource::loadIconSet("close") );
347 connect(m_btnClose, SIGNAL(clicked() ), 350 connect(m_btnClose, SIGNAL(clicked() ),
348 selector(), SIGNAL(closeMe() ) ); 351 selector(), SIGNAL(closeMe() ) );
349 352
350 btn = new QToolButton( box ); 353 btn = new QToolButton( box );
351 btn->setIconSet( Resource::loadIconSet("cardmon/pcmcia") ); 354 btn->setIconSet( Resource::loadIconSet("cardmon/pcmcia") );
352 355
353 /* let's fill device parts */ 356 /* let's fill device parts */
354 QPopupMenu* pop = new QPopupMenu(this); 357 QPopupMenu* pop = new QPopupMenu(this);
355 connect(pop, SIGNAL( activated(int) ), 358 connect(pop, SIGNAL( activated(int) ),
356 this, SLOT(slotFSActivated(int) ) ); 359 this, SLOT(slotFSActivated(int) ) );
357 360
358 StorageInfo storage; 361 StorageInfo storage;
359 const QList<FileSystem> &fs = storage.fileSystems(); 362 const QList<FileSystem> &fs = storage.fileSystems();
360 QListIterator<FileSystem> it(fs); 363 QListIterator<FileSystem> it(fs);
361 for ( ; it.current(); ++it ) 364 for ( ; it.current(); ++it )
362 { 365 {
363 const QString disk = (*it)->name(); 366 const QString disk = (*it)->name();
364 const QString path = (*it)->path(); 367 const QString path = (*it)->path();
365 m_dev.insert( disk, path ); 368 m_dev.insert( disk, path );
366 pop->insertItem( disk ); 369 pop->insertItem( disk );
367 } 370 }
368 m_fsPop = pop; 371 m_fsPop = pop;
369 372
370 373
371 btn->setPopup( pop ); 374 btn->setPopup( pop );
372 375
373 lay->addWidget( box ); 376 lay->addWidget( box );
374 377
375 m_view = new QListView( this ); 378 m_view = new QListView( this );
376 379
377 m_view->installEventFilter(this); 380 m_view->installEventFilter(this);
378 381
379 QPEApplication::setStylusOperation( m_view->viewport(), 382 QPEApplication::setStylusOperation( m_view->viewport(),
380 QPEApplication::RightOnHold); 383 QPEApplication::RightOnHold);
381 m_view->addColumn(" " ); 384 m_view->addColumn(" " );
382 m_view->addColumn(tr("Name"), 135 ); 385 m_view->addColumn(tr("Name"), 135 );
383 m_view->addColumn(tr("Size"), -1 ); 386 m_view->addColumn(tr("Size"), -1 );
384 m_view->addColumn(tr("Date"), 60 ); 387 m_view->addColumn(tr("Date"), 60 );
385 m_view->addColumn(tr("Mime Type"), -1 ); 388 m_view->addColumn(tr("Mime Type"), -1 );
386 389
387 390
388 m_view->setSorting( 1 ); 391 m_view->setSorting( 1 );
389 m_view->setAllColumnsShowFocus( TRUE ); 392 m_view->setAllColumnsShowFocus( TRUE );
390 393
391 lay->addWidget( m_view, 1000 ); 394 lay->addWidget( m_view, 1000 );
392 connectSlots(); 395 connectSlots();
393} 396}
394 397
diff --git a/libopie2/opieui/fileselector/ofileselector_p.h b/libopie2/opieui/fileselector/ofileselector_p.h
index 790d2bd..15db916 100644
--- a/libopie2/opieui/fileselector/ofileselector_p.h
+++ b/libopie2/opieui/fileselector/ofileselector_p.h
@@ -44,151 +44,151 @@
44 * for Extended and ExtendedAll 44 * for Extended and ExtendedAll
45 * The only difference is the Lister... 45 * The only difference is the Lister...
46 * a) static object? 46 * a) static object?
47 * b) leave some object inside the OFileSelector which can be used? 47 * b) leave some object inside the OFileSelector which can be used?
48 * c) when switching views tell which view we want o have.. internally we can switch then 48 * c) when switching views tell which view we want o have.. internally we can switch then
49 * 49 *
50 * I'll take c) -zecke 50 * I'll take c) -zecke
51 */ 51 */
52 52
53typedef QMap<QString, QStringList> MimeTypes; 53typedef QMap<QString, QStringList> MimeTypes;
54 54
55/* the View Interface */ 55/* the View Interface */
56class QFileInfo; 56class QFileInfo;
57class QToolButton; 57class QToolButton;
58 58
59namespace Opie{ 59namespace Opie{
60namespace Ui{ 60namespace Ui{
61class OFileSelector; 61class OFileSelector;
62namespace Internal { 62namespace Internal {
63 63
64class OFileViewInterface 64class OFileViewInterface
65{ 65{
66public: 66public:
67 OFileViewInterface( OFileSelector* selector ); 67 OFileViewInterface( OFileSelector* selector );
68 virtual ~OFileViewInterface(); 68 virtual ~OFileViewInterface();
69 virtual QString selectedName()const = 0; 69 virtual QString selectedName()const = 0;
70 virtual QString selectedPath()const = 0; 70 virtual QString selectedPath()const = 0;
71 virtual QString directory()const = 0; 71 virtual QString directory()const = 0;
72 virtual void reread() = 0; 72 virtual void reread() = 0;
73 virtual int fileCount()const = 0; 73 virtual int fileCount()const = 0;
74 virtual DocLnk selectedDocument()const; 74 virtual DocLnk selectedDocument()const;
75 virtual QWidget* widget( QWidget* parent) = 0; 75 virtual QWidget* widget( QWidget* parent) = 0;
76 virtual void activate( const QString& ); 76 virtual void activate( const QString& );
77 QString name()const; 77 QString name()const;
78 bool allItem( const QString& )const; 78 bool allItem( const QString& )const;
79protected: 79protected:
80 OFileSelector* selector()const; 80 OFileSelector* selector()const;
81 void setName( const QString& ); 81 void setName( const QString& );
82 bool showNew()const; 82 bool showNew()const;
83 bool showClose()const; 83 bool showClose()const;
84 MimeTypes mimeTypes()const; 84 MimeTypes mimeTypes()const;
85 QStringList currentMimeType()const; 85 QStringList currentMimeType()const;
86 QString startDirectory()const; 86 QString startDirectory()const;
87protected: 87protected:
88 void ok(); 88 void ok();
89 void cancel(); 89 void cancel();
90 void closeMe(); 90 void closeMe();
91 void fileSelected( const QString& ); 91 void fileSelected( const QString& );
92 void fileSelected( const DocLnk& ); 92 void fileSelected( const DocLnk& );
93 void setCurrentFileName( const QString& ); 93 void setCurrentFileName( const QString& );
94 QString currentFileName()const; 94 QString currentFileName()const;
95 95
96private: 96private:
97 QString m_name; 97 QString m_name;
98 OFileSelector* m_selector; 98 OFileSelector* m_selector;
99}; 99};
100 100
101 101
102/* THE Document View hosting a FileSelector*/ 102/* THE Document View hosting a FileSelector*/
103class ODocumentFileView : public OFileViewInterface 103class ODocumentFileView : public OFileViewInterface
104{ 104{
105public: 105public:
106 ODocumentFileView( OFileSelector* selector ); 106 ODocumentFileView( OFileSelector* selector );
107 ~ODocumentFileView(); 107 ~ODocumentFileView();
108 108
109 QString selectedName() const; 109 QString selectedName() const;
110 QString selectedPath() const; 110 QString selectedPath() const;
111 111
112 QString directory() const; 112 QString directory() const;
113 void reread(); 113 void reread();
114 int fileCount()const; 114 int fileCount()const;
115 DocLnk selectedDocument()const; 115 DocLnk selectedDocument()const;
116 116
117 QWidget* widget( QWidget* parent ); 117 QWidget* widget( QWidget* parent );
118 118
119private: 119private:
120 mutable FileSelector* m_selector; 120 mutable FileSelector* m_selector;
121 121
122}; 122};
123 123
124 124
125class OFileSelectorItem : public QListViewItem 125class OFileSelectorItem : public QListViewItem
126{ 126{
127public: 127public:
128 OFileSelectorItem( QListView* view, const QPixmap& pixmap, 128 OFileSelectorItem( QListView* view, const QPixmap& pixmap,
129 const QString& path, const QString& date, 129 const QString& path, const QString& date,
130 const QString& size, const QString& mDir, 130 const QString& size, const QString& mDir,
131 bool isLocked = false, bool isDir = false ); 131 bool isLocked = false, bool isDir = false );
132 ~OFileSelectorItem(); 132 ~OFileSelectorItem();
133 bool isLocked()const; 133 bool isLocked()const;
134 bool isDir()const; 134 bool isDir()const;
135 QString directory()const; 135 QString directory()const;
136 QString path()const; 136 QString path()const;
137 QString key(int id, bool )const; 137 QString key(int id, bool )const;
138 138
139private: 139private:
140 bool m_locked : 1;
141 bool m_isDir : 1;
142 QString m_dir; 140 QString m_dir;
141 bool m_isDir : 1;
142 bool m_locked : 1;
143}; 143};
144 144
145class OFileViewFileListView : public QWidget 145class OFileViewFileListView : public QWidget
146{ 146{
147 Q_OBJECT 147 Q_OBJECT
148public: 148public:
149 OFileViewFileListView( QWidget* parent, const QString& dir, OFileSelector* selector ); 149 OFileViewFileListView( QWidget* parent, const QString& dir, OFileSelector* selector );
150 ~OFileViewFileListView(); 150 ~OFileViewFileListView();
151 151
152 OFileSelectorItem* currentItem()const; 152 OFileSelectorItem* currentItem()const;
153 void reread( bool all = false ); 153 void reread( bool all = false );
154 int fileCount()const; 154 int fileCount()const;
155 QString currentDir()const; 155 QString currentDir()const;
156protected: 156protected:
157 bool eventFilter (QObject *o, QEvent *e); 157 bool eventFilter (QObject *o, QEvent *e);
158private slots: 158private slots:
159 void slotNew(); // will emit newSelected 159 void slotNew(); // will emit newSelected
160 void cdUP(); 160 void cdUP();
161 void cdHome(); 161 void cdHome();
162 void cdDoc(); 162 void cdDoc();
163 void changeDir( const QString& ); 163 void changeDir( const QString& );
164 void slotCurrentChanged( QListViewItem* ); 164 void slotCurrentChanged( QListViewItem* );
165 void slotClicked(int, QListViewItem*, const QPoint&, int ); 165 void slotClicked(int, QListViewItem*, const QPoint&, int );
166 void slotFSActivated(int); 166 void slotFSActivated(int);
167 167
168protected: 168protected:
169 OFileSelector* selector(); 169 OFileSelector* selector();
170 170
171private: 171private:
172 QMap<QString, QString> m_dev; 172 QMap<QString, QString> m_dev;
173 bool m_all : 1; 173 bool m_all : 1;
174 OFileSelector* m_sel; 174 OFileSelector* m_sel;
175 QPopupMenu* m_fsPop; 175 QPopupMenu* m_fsPop;
176 bool compliesMime( const QString& ); 176 bool compliesMime( const QString& );
177 QStringList m_mimes; // used in compy mime 177 QStringList m_mimes; // used in compy mime
178 QString m_currentDir; 178 QString m_currentDir;
179 QToolButton *m_btnNew, *m_btnClose; 179 QToolButton *m_btnNew, *m_btnClose;
180 void connectSlots(); 180 void connectSlots();
181 void addFile( QFileInfo* info, bool symlink = FALSE ); 181 void addFile( QFileInfo* info, bool symlink = FALSE );
182 void addDir ( QFileInfo* info, bool symlink = FALSE ); 182 void addDir ( QFileInfo* info, bool symlink = FALSE );
183 void addSymlink( QFileInfo* info, bool = FALSE ); 183 void addSymlink( QFileInfo* info, bool = FALSE );
184 184
185 185
186private: 186private:
187 QListView* m_view; 187 QListView* m_view;
188}; 188};
189 189
190} 190}
191} 191}
192} 192}
193 193
194#endif 194#endif