summaryrefslogtreecommitdiff
authoralwin <alwin>2005-03-24 13:28:49 (UTC)
committer alwin <alwin>2005-03-24 13:28:49 (UTC)
commit29da9a4477210843435cbea3ede0d520775fe1a5 (patch) (unidiff)
tree487b26273bcdb8e29cd3f591955e8469d01c0da7
parent4fbd94e2fd6432bb15e24e40be59426b309cbb9d (diff)
downloadopie-29da9a4477210843435cbea3ede0d520775fe1a5.zip
opie-29da9a4477210843435cbea3ede0d520775fe1a5.tar.gz
opie-29da9a4477210843435cbea3ede0d520775fe1a5.tar.bz2
the filesystem-menu will executed when click on the filsystem-button
not when hold the pen on it.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/fileselector/ofileselector.cpp18
-rw-r--r--libopie2/opieui/fileselector/ofileselector_p.h2
2 files changed, 14 insertions, 6 deletions
diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp
index 74aca96..dbba4b9 100644
--- a/libopie2/opieui/fileselector/ofileselector.cpp
+++ b/libopie2/opieui/fileselector/ofileselector.cpp
@@ -22,98 +22,98 @@
22  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27 27
28*/ 28*/
29 29
30/* hacky but we need to get FileSelector::filter */ 30/* hacky but we need to get FileSelector::filter */
31#define private public 31#define private public
32#include <qpe/fileselector.h> 32#include <qpe/fileselector.h>
33#undef private 33#undef private
34 34
35#include "ofileselector_p.h" 35#include "ofileselector_p.h"
36 36
37/* OPIE */ 37/* OPIE */
38#include <opie2/ofileselector.h> 38#include <opie2/ofileselector.h>
39#include <opie2/odebug.h> 39#include <opie2/odebug.h>
40 40
41#include <qpe/qpeapplication.h> 41#include <qpe/qpeapplication.h>
42#include <qpe/mimetype.h> 42#include <qpe/mimetype.h>
43#include <qpe/resource.h> 43#include <qpe/resource.h>
44#include <qpe/storage.h> 44#include <qpe/storage.h>
45 45
46/* QT */ 46/* QT */
47#include <qcombobox.h> 47#include <qcombobox.h>
48#include <qdir.h> 48#include <qdir.h>
49#include <qhbox.h> 49#include <qhbox.h>
50#include <qheader.h> 50#include <qheader.h>
51#include <qlabel.h> 51#include <qlabel.h>
52#include <qlayout.h> 52#include <qlayout.h>
53#include <qlineedit.h> 53#include <qlineedit.h>
54#include <qlistview.h> 54#include <qlistview.h>
55#include <qpopupmenu.h> 55#include <qpopupmenu.h>
56#include <qwidgetstack.h> 56#include <qwidgetstack.h>
57#include <qregexp.h> 57#include <qregexp.h>
58#include <qobjectlist.h> 58#include <qobjectlist.h>
59 59
60using namespace Opie::Ui::Internal; 60using namespace Opie::Ui::Internal;
61 61
62namespace Opie { 62namespace Opie {
63namespace Ui { 63namespace Ui {
64namespace Internal { 64namespace Internal {
65/* 65/*
66 * Create a path by adding a '/'/QDir::seperator in between 66 * Create a path by adding a '/'/QDir::seperator in between
67 * base and ending, but only if base is not empty 67 * base and ending, but only if base is not empty
68 */ 68 */
69static inline QString createNewPath(const QString& base, const QString &ending) { 69static inline QString createNewPath(const QString& base, const QString &ending) {
70 return base == QString::fromLatin1("/") ? 70 return base == QString::fromLatin1("/") ?
71 base + ending : base + "/" + ending; 71 base + ending : base + "/" + ending;
72} 72}
73 73
74 74
75OFileViewInterface::OFileViewInterface( OFileSelector* _selector ) 75OFileViewInterface::OFileViewInterface( OFileSelector* _selector )
76 : m_selector( _selector ) 76 : m_selector( _selector )
77{ 77{
78 selector()->registerView( this ); 78 selector()->registerView( this );
79} 79}
80 80
81OFileViewInterface::~OFileViewInterface() 81OFileViewInterface::~OFileViewInterface()
82{} 82{}
83 83
84QString OFileViewInterface::name()const 84QString OFileViewInterface::name()const
85{ 85{
86 return m_name; 86 return m_name;
87} 87}
88 88
89void OFileViewInterface::setName( const QString& name ) 89void OFileViewInterface::setName( const QString& name )
90{ 90{
91 m_name = name; 91 m_name = name;
92} 92}
93 93
94OFileSelector* OFileViewInterface::selector()const 94OFileSelector* OFileViewInterface::selector()const
95{ 95{
96 return m_selector; 96 return m_selector;
97} 97}
98 98
99DocLnk OFileViewInterface::selectedDocument()const 99DocLnk OFileViewInterface::selectedDocument()const
100{ 100{
101 return DocLnk( selectedName() ); 101 return DocLnk( selectedName() );
102} 102}
103 103
104bool OFileViewInterface::showNew()const 104bool OFileViewInterface::showNew()const
105{ 105{
106 return selector()->showNew(); 106 return selector()->showNew();
107} 107}
108 108
109bool OFileViewInterface::showClose()const 109bool OFileViewInterface::showClose()const
110{ 110{
111 return selector()->showClose(); 111 return selector()->showClose();
112} 112}
113 113
114MimeTypes OFileViewInterface::mimeTypes()const 114MimeTypes OFileViewInterface::mimeTypes()const
115{ 115{
116 return selector()->mimeTypes(); 116 return selector()->mimeTypes();
117} 117}
118 118
119QStringList OFileViewInterface::currentMimeType()const 119QStringList OFileViewInterface::currentMimeType()const
@@ -243,213 +243,219 @@ QWidget* ODocumentFileView::widget( QWidget* parent )
243 243
244 return m_selector; 244 return m_selector;
245} 245}
246 246
247/* 247/*
248 * This is the file system view used 248 * This is the file system view used
249 * we use a QListView + QListViewItems for it 249 * we use a QListView + QListViewItems for it
250 */ 250 */
251 251
252OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap, 252OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap,
253 const QString& path, const QString& date, 253 const QString& path, const QString& date,
254 const QString& size, const QString& dir, 254 const QString& size, const QString& dir,
255 bool isLocked, bool isDir ) 255 bool isLocked, bool isDir )
256 : QListViewItem( view ), m_dir(dir), m_isDir(isDir), m_locked(isLocked) 256 : QListViewItem( view ), m_dir(dir), m_isDir(isDir), m_locked(isLocked)
257{ 257{
258 setPixmap(0, pixmap ); 258 setPixmap(0, pixmap );
259 setText(1, path ); 259 setText(1, path );
260 setText(2, size ); 260 setText(2, size );
261 setText(3, date ); 261 setText(3, date );
262} 262}
263 263
264OFileSelectorItem::~OFileSelectorItem() 264OFileSelectorItem::~OFileSelectorItem()
265{ 265{
266} 266}
267 267
268bool OFileSelectorItem::isLocked()const 268bool OFileSelectorItem::isLocked()const
269{ 269{
270 return m_locked; 270 return m_locked;
271} 271}
272 272
273QString OFileSelectorItem::directory()const 273QString OFileSelectorItem::directory()const
274{ 274{
275 return m_dir; 275 return m_dir;
276} 276}
277 277
278bool OFileSelectorItem::isDir()const 278bool OFileSelectorItem::isDir()const
279{ 279{
280 return m_isDir; 280 return m_isDir;
281} 281}
282 282
283QString OFileSelectorItem::path()const 283QString OFileSelectorItem::path()const
284{ 284{
285 return text( 1 ); 285 return text( 1 );
286} 286}
287 287
288QString OFileSelectorItem::key( int id, bool )const 288QString OFileSelectorItem::key( int id, bool )const
289{ 289{
290 QString ke; 290 QString ke;
291 291
292 /* 292 /*
293 * id = 0 ||id == 1 : Sort By Name but Directories at Top 293 * id = 0 ||id == 1 : Sort By Name but Directories at Top
294 * id = 2 : Sort By Size: Prepend '0' to the key 294 * id = 2 : Sort By Size: Prepend '0' to the key
295 */ 295 */
296 if( id == 0 || id == 1 ) 296 if( id == 0 || id == 1 )
297 { // name 297 { // name
298 if( m_isDir ) 298 if( m_isDir )
299 { 299 {
300 ke.append("0" ); 300 ke.append("0" );
301 ke.append( text(1) ); 301 ke.append( text(1) );
302 } 302 }
303 else 303 else
304 { 304 {
305 ke.append("1" ); 305 ke.append("1" );
306 ke.append( text(1) ); 306 ke.append( text(1) );
307 } 307 }
308 return ke; 308 return ke;
309 }else if(id == 2) { 309 }else if(id == 2) {
310 return text(2).rightJustify(20, '0'); 310 return text(2).rightJustify(20, '0');
311 }else 311 }else
312 return text( id ); 312 return text( id );
313 313
314} 314}
315 315
316OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, OFileSelector* sel) 316OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, OFileSelector* sel)
317 :QWidget( parent ), m_sel( sel ) 317 :QWidget( parent ), m_sel( sel )
318{ 318{
319 m_all = false; 319 m_all = false;
320 QVBoxLayout* lay = new QVBoxLayout( this ); 320 QVBoxLayout* lay = new QVBoxLayout( this );
321 m_currentDir = startDir; 321 m_currentDir = startDir;
322 322
323 /* 323 /*
324 * now we add a special bar 324 * now we add a special bar
325 * One Button For Up 325 * One Button For Up
326 * Home 326 * Home
327 * Doc 327 * Doc
328 * And a dropdown menu with FileSystems 328 * And a dropdown menu with FileSystems
329 * FUTURE: one to change dir with lineedit 329 * FUTURE: one to change dir with lineedit
330 * Bookmarks 330 * Bookmarks
331 * Create Dir 331 * Create Dir
332 */ 332 */
333 QHBox* box = new QHBox(this ); 333 QHBox* box = new QHBox(this );
334 box->setBackgroundMode( PaletteButton ); 334 box->setBackgroundMode( PaletteButton );
335 box->setSpacing( 0 ); 335 box->setSpacing( 0 );
336 336
337 QToolButton *btn = new QToolButton( box ); 337 QToolButton *btn = new QToolButton( box );
338 btn->setIconSet( Resource::loadIconSet("up") ); 338 btn->setIconSet( Resource::loadIconSet("up") );
339 connect(btn, SIGNAL(clicked() ), 339 connect(btn, SIGNAL(clicked() ),
340 this, SLOT( cdUP() ) ); 340 this, SLOT( cdUP() ) );
341 341
342 btn = new QToolButton( box ); 342 btn = new QToolButton( box );
343 btn->setIconSet( Resource::loadIconSet("home") ); 343 btn->setIconSet( Resource::loadIconSet("home") );
344 connect(btn, SIGNAL(clicked() ), 344 connect(btn, SIGNAL(clicked() ),
345 this, SLOT( cdHome() ) ); 345 this, SLOT( cdHome() ) );
346 346
347 btn = new QToolButton( box ); 347 btn = new QToolButton( box );
348 btn->setIconSet( Resource::loadIconSet("DocsIcon") ); 348 btn->setIconSet( Resource::loadIconSet("DocsIcon") );
349 connect(btn, SIGNAL(clicked() ), 349 connect(btn, SIGNAL(clicked() ),
350 this, SLOT(cdDoc() ) ); 350 this, SLOT(cdDoc() ) );
351 351
352 m_btnNew = new QToolButton( box ); 352 m_btnNew = new QToolButton( box );
353 m_btnNew->setIconSet( Resource::loadIconSet("new") ); 353 m_btnNew->setIconSet( Resource::loadIconSet("new") );
354 connect(m_btnNew, SIGNAL(clicked() ), 354 connect(m_btnNew, SIGNAL(clicked() ),
355 this, SLOT(slotNew() ) ); 355 this, SLOT(slotNew() ) );
356 356
357 357
358 m_btnClose = new QToolButton( box ); 358 m_btnClose = new QToolButton( box );
359 m_btnClose->setIconSet( Resource::loadIconSet("close") ); 359 m_btnClose->setIconSet( Resource::loadIconSet("close") );
360 connect(m_btnClose, SIGNAL(clicked() ), 360 connect(m_btnClose, SIGNAL(clicked() ),
361 selector(), SIGNAL(closeMe() ) ); 361 selector(), SIGNAL(closeMe() ) );
362 362
363 btn = new QToolButton( box ); 363 btn = new QToolButton( box );
364 btn->setIconSet( Resource::loadIconSet("cardmon/pcmcia") ); 364 btn->setIconSet( Resource::loadIconSet("cardmon/pcmcia") );
365 365
366 m_fsButton = btn;
366 /* let's fill device parts */ 367 /* let's fill device parts */
367 QPopupMenu* pop = new QPopupMenu(this); 368 QPopupMenu* pop = new QPopupMenu(this);
368 connect(pop, SIGNAL( activated(int) ), 369 connect(pop, SIGNAL( activated(int) ),
369 this, SLOT(slotFSActivated(int) ) ); 370 this, SLOT(slotFSActivated(int) ) );
370 371
371 StorageInfo storage; 372 StorageInfo storage;
372 const QList<FileSystem> &fs = storage.fileSystems(); 373 const QList<FileSystem> &fs = storage.fileSystems();
373 QListIterator<FileSystem> it(fs); 374 QListIterator<FileSystem> it(fs);
374 for ( ; it.current(); ++it ) 375 for ( ; it.current(); ++it )
375 { 376 {
376 const QString disk = (*it)->name(); 377 const QString disk = (*it)->name();
377 const QString path = (*it)->path(); 378 const QString path = (*it)->path();
378 m_dev.insert( disk, path ); 379 m_dev.insert( disk, path );
379 pop->insertItem( disk ); 380 pop->insertItem( disk );
380 } 381 }
381 m_fsPop = pop; 382 m_fsPop = pop;
382 383
383 384 connect(btn,SIGNAL(pressed()),this,SLOT(slotFSpressed()));
384 btn->setPopup( pop );
385 385
386 lay->addWidget( box ); 386 lay->addWidget( box );
387 387
388 m_view = new QListView( this ); 388 m_view = new QListView( this );
389 389
390 m_view->installEventFilter(this); 390 m_view->installEventFilter(this);
391 391
392 QPEApplication::setStylusOperation( m_view->viewport(), 392 QPEApplication::setStylusOperation( m_view->viewport(),
393 QPEApplication::RightOnHold); 393 QPEApplication::RightOnHold);
394 m_view->addColumn(" " ); 394 m_view->addColumn(" " );
395 m_view->addColumn(tr("Name"), 135 ); 395 m_view->addColumn(tr("Name"), 135 );
396 m_view->addColumn(tr("Size"), -1 ); 396 m_view->addColumn(tr("Size"), -1 );
397 m_view->addColumn(tr("Date"), 60 ); 397 m_view->addColumn(tr("Date"), 60 );
398 m_view->addColumn(tr("Mime Type"), -1 ); 398 m_view->addColumn(tr("Mime Type"), -1 );
399 399
400 400
401 m_view->setSorting( 1 ); 401 m_view->setSorting( 1 );
402 m_view->setAllColumnsShowFocus( TRUE ); 402 m_view->setAllColumnsShowFocus( TRUE );
403 403
404 lay->addWidget( m_view, 1000 ); 404 lay->addWidget( m_view, 1000 );
405 connectSlots(); 405 connectSlots();
406} 406}
407 407
408void OFileViewFileListView::slotFSpressed()
409{
410 m_fsPop->exec(QPoint( QCursor::pos().x(), QCursor::pos().y()));
411 m_fsButton->setDown(false);
412}
413
408OFileViewFileListView::~OFileViewFileListView() 414OFileViewFileListView::~OFileViewFileListView()
409{ 415{
410} 416}
411 417
412void OFileViewFileListView::slotNew() 418void OFileViewFileListView::slotNew()
413{ 419{
414 DocLnk lnk; 420 DocLnk lnk;
415 emit selector()->newSelected( lnk ); 421 emit selector()->newSelected( lnk );
416} 422}
417 423
418OFileSelectorItem* OFileViewFileListView::currentItem()const 424OFileSelectorItem* OFileViewFileListView::currentItem()const
419{ 425{
420 QListViewItem* item = m_view->currentItem(); 426 QListViewItem* item = m_view->currentItem();
421 if (!item ) 427 if (!item )
422 return 0l; 428 return 0l;
423 429
424 return static_cast<OFileSelectorItem*>(item); 430 return static_cast<OFileSelectorItem*>(item);
425} 431}
426 432
427void OFileViewFileListView::reread( bool all ) 433void OFileViewFileListView::reread( bool all )
428{ 434{
429 m_view->clear(); 435 m_view->clear();
430 436
431 if (selector()->showClose() ) 437 if (selector()->showClose() )
432 m_btnClose->show(); 438 m_btnClose->show();
433 else 439 else
434 m_btnClose->hide(); 440 m_btnClose->hide();
435 441
436 if (selector()->showNew() ) 442 if (selector()->showNew() )
437 m_btnNew->show(); 443 m_btnNew->show();
438 else 444 else
439 m_btnNew->hide(); 445 m_btnNew->hide();
440 446
441 m_mimes = selector()->currentMimeType(); 447 m_mimes = selector()->currentMimeType();
442 m_all = all; 448 m_all = all;
443 449
444 QDir dir( m_currentDir ); 450 QDir dir( m_currentDir );
445 if (!dir.exists() ) 451 if (!dir.exists() )
446 return; 452 return;
447 453
448 dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); 454 dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed );
449 int filter; 455 int filter;
450 filter = QDir::Dirs; 456 filter = QDir::Dirs;
451 if ( selector()->mode() != OFileSelector::DIRECTORYSELECTOR ) 457 if ( selector()->mode() != OFileSelector::DIRECTORYSELECTOR )
452 filter = filter | QDir::Files | QDir::All; 458 filter = filter | QDir::Files | QDir::All;
453 459
454 if ( m_all ) 460 if ( m_all )
455 filter = filter | QDir::Hidden; 461 filter = filter | QDir::Hidden;
diff --git a/libopie2/opieui/fileselector/ofileselector_p.h b/libopie2/opieui/fileselector/ofileselector_p.h
index 15db916..94216a0 100644
--- a/libopie2/opieui/fileselector/ofileselector_p.h
+++ b/libopie2/opieui/fileselector/ofileselector_p.h
@@ -119,76 +119,78 @@ public:
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 QString m_dir; 140 QString m_dir;
141 bool m_isDir : 1; 141 bool m_isDir : 1;
142 bool m_locked : 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 void slotFSpressed();
167 168
168protected: 169protected:
169 OFileSelector* selector(); 170 OFileSelector* selector();
170 171
171private: 172private:
172 QMap<QString, QString> m_dev; 173 QMap<QString, QString> m_dev;
173 bool m_all : 1; 174 bool m_all : 1;
174 OFileSelector* m_sel; 175 OFileSelector* m_sel;
175 QPopupMenu* m_fsPop; 176 QPopupMenu* m_fsPop;
176 bool compliesMime( const QString& ); 177 bool compliesMime( const QString& );
177 QStringList m_mimes; // used in compy mime 178 QStringList m_mimes; // used in compy mime
178 QString m_currentDir; 179 QString m_currentDir;
179 QToolButton *m_btnNew, *m_btnClose; 180 QToolButton *m_btnNew, *m_btnClose;
181 QToolButton *m_fsButton;
180 void connectSlots(); 182 void connectSlots();
181 void addFile( QFileInfo* info, bool symlink = FALSE ); 183 void addFile( QFileInfo* info, bool symlink = FALSE );
182 void addDir ( QFileInfo* info, bool symlink = FALSE ); 184 void addDir ( QFileInfo* info, bool symlink = FALSE );
183 void addSymlink( QFileInfo* info, bool = FALSE ); 185 void addSymlink( QFileInfo* info, bool = FALSE );
184 186
185 187
186private: 188private:
187 QListView* m_view; 189 QListView* m_view;
188}; 190};
189 191
190} 192}
191} 193}
192} 194}
193 195
194#endif 196#endif