-rw-r--r-- | library/fileselector.cpp | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/library/fileselector.cpp b/library/fileselector.cpp index 365f383..013f43a 100644 --- a/library/fileselector.cpp +++ b/library/fileselector.cpp | |||
@@ -12,17 +12,23 @@ | |||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | |||
21 | // WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT | ||
22 | // have this class. | ||
23 | #define QTOPIA_INTERNAL_FSLP | ||
24 | |||
20 | #include "fileselector.h" | 25 | #include "fileselector.h" |
26 | #include "fileselector_p.h" | ||
21 | #include "global.h" | 27 | #include "global.h" |
22 | #include "resource.h" | 28 | #include "resource.h" |
23 | #include "config.h" | 29 | #include "config.h" |
24 | #include "applnk.h" | 30 | #include "applnk.h" |
25 | #include "storage.h" | 31 | #include "storage.h" |
26 | #include "qpemenubar.h" | 32 | #include "qpemenubar.h" |
27 | #include "qcopchannel_qws.h" | 33 | #include "qcopchannel_qws.h" |
28 | #include "lnkproperties.h" | 34 | #include "lnkproperties.h" |
@@ -51,23 +57,25 @@ FileSelectorItem::FileSelectorItem( QListView *parent, const DocLnk &f ) | |||
51 | FileSelectorItem::~FileSelectorItem() | 57 | FileSelectorItem::~FileSelectorItem() |
52 | { | 58 | { |
53 | } | 59 | } |
54 | 60 | ||
55 | class FileSelectorViewPrivate | 61 | class FileSelectorViewPrivate |
56 | { | 62 | { |
57 | public: | 63 | public: |
58 | CategoryMenu *cm; | 64 | CategoryMenu *cm; |
65 | bool m_noItems:1; | ||
59 | }; | 66 | }; |
60 | 67 | ||
61 | FileSelectorView::FileSelectorView( const QString &f, QWidget *parent, const char *name ) | 68 | FileSelectorView::FileSelectorView( const QString &f, QWidget *parent, const char *name ) |
62 | : QListView( parent, name ), filter( f ), count( 0 ) | 69 | : QListView( parent, name ), filter( f ), count( 0 ) |
63 | { | 70 | { |
64 | d = new FileSelectorViewPrivate(); | 71 | d = new FileSelectorViewPrivate(); |
65 | d->cm = 0; | 72 | d->cm = 0; |
73 | d->m_noItems = false; | ||
66 | setAllColumnsShowFocus( TRUE ); | 74 | setAllColumnsShowFocus( TRUE ); |
67 | addColumn( tr( "Name" ) ); | 75 | addColumn( tr( "Name" ) ); |
68 | header()->hide(); | 76 | header()->hide(); |
69 | 77 | ||
70 | fileManager = new FileManager; | 78 | fileManager = new FileManager; |
71 | reread(); | 79 | reread(); |
72 | QCopChannel *channel = new QCopChannel( "QPE/Card", this ); | 80 | QCopChannel *channel = new QCopChannel( "QPE/Card", this ); |
73 | connect( channel, SIGNAL(received(const QCString &, const QByteArray &)), | 81 | connect( channel, SIGNAL(received(const QCString &, const QByteArray &)), |
@@ -75,24 +83,33 @@ FileSelectorView::FileSelectorView( const QString &f, QWidget *parent, const cha | |||
75 | } | 83 | } |
76 | 84 | ||
77 | FileSelectorView::~FileSelectorView() | 85 | FileSelectorView::~FileSelectorView() |
78 | { | 86 | { |
79 | } | 87 | } |
80 | 88 | ||
81 | void FileSelectorView::reread() | 89 | void FileSelectorView::reread() |
82 | { | 90 | { |
83 | FileSelectorItem *item = (FileSelectorItem *)selectedItem(); | ||
84 | QString oldFile; | 91 | QString oldFile; |
85 | if ( item ) | 92 | FileSelectorItem *item; |
86 | oldFile = item->file().file(); | 93 | if( !d->m_noItems ) { // there are items |
94 | item = (FileSelectorItem *)selectedItem(); | ||
95 | if ( item ) | ||
96 | oldFile = item->file().file(); | ||
97 | } | ||
87 | clear(); | 98 | clear(); |
88 | DocLnkSet files; | 99 | DocLnkSet files; |
89 | Global::findDocuments(&files, filter); | 100 | Global::findDocuments(&files, filter); |
90 | count = files.children().count(); | 101 | count = files.children().count(); |
102 | if(count == 0 ){ // No Documents | ||
103 | d->m_noItems = true; | ||
104 | QListViewItem *it = new QListViewItem(this, tr("There are no files in this directory." ), "empty" ); | ||
105 | it->setSelectable(FALSE ); | ||
106 | return; | ||
107 | } | ||
91 | QListIterator<DocLnk> dit( files.children() ); | 108 | QListIterator<DocLnk> dit( files.children() ); |
92 | for ( ; dit.current(); ++dit ) { | 109 | for ( ; dit.current(); ++dit ) { |
93 | if (d->cm) | 110 | if (d->cm) |
94 | if (!d->cm->isSelected((**dit).categories())) | 111 | if (!d->cm->isSelected((**dit).categories())) |
95 | continue; | 112 | continue; |
96 | item = new FileSelectorItem( this, **dit ); | 113 | item = new FileSelectorItem( this, **dit ); |
97 | if ( item->file().file() == oldFile ) | 114 | if ( item->file().file() == oldFile ) |
98 | setCurrentItem( item ); | 115 | setCurrentItem( item ); |
@@ -232,25 +249,31 @@ void FileSelector::createNew() | |||
232 | emit newSelected( f ); | 249 | emit newSelected( f ); |
233 | emit closeMe(); | 250 | emit closeMe(); |
234 | } | 251 | } |
235 | 252 | ||
236 | void FileSelector::fileClicked( int button, QListViewItem *i, const QPoint &, int ) | 253 | void FileSelector::fileClicked( int button, QListViewItem *i, const QPoint &, int ) |
237 | { | 254 | { |
238 | if ( !i ) | 255 | if ( !i ) |
239 | return; | 256 | return; |
257 | if(i->text(1) == QString::fromLatin1("empty" ) ) | ||
258 | return; | ||
259 | |||
240 | if ( button == Qt::LeftButton ) { | 260 | if ( button == Qt::LeftButton ) { |
241 | fileClicked( i ); | 261 | fileClicked( i ); |
242 | } | 262 | } |
243 | } | 263 | } |
244 | 264 | ||
245 | void FileSelector::filePressed( int button, QListViewItem *i, const QPoint &, int ) | 265 | void FileSelector::filePressed( int button, QListViewItem *i, const QPoint &, int ) |
246 | { | 266 | { |
247 | if ( !i ) | 267 | if ( !i ) |
248 | return; | 268 | return; |
269 | if(i->text(1) == QString::fromLatin1("empty" ) ) | ||
270 | return; | ||
271 | |||
249 | if ( button == Qt::RightButton ) { | 272 | if ( button == Qt::RightButton ) { |
250 | DocLnk l = ((FileSelectorItem *)i)->file(); | 273 | DocLnk l = ((FileSelectorItem *)i)->file(); |
251 | LnkProperties prop( &l ); | 274 | LnkProperties prop( &l ); |
252 | prop.showMaximized(); | 275 | prop.showMaximized(); |
253 | prop.exec(); | 276 | prop.exec(); |
254 | d->cm->reload(); | 277 | d->cm->reload(); |
255 | reread(); | 278 | reread(); |
256 | } | 279 | } |
@@ -316,25 +339,15 @@ void FileSelector::setCloseVisible( bool b ) | |||
316 | { | 339 | { |
317 | if ( b ) | 340 | if ( b ) |
318 | buttonClose->show(); | 341 | buttonClose->show(); |
319 | else | 342 | else |
320 | buttonClose->hide(); | 343 | buttonClose->hide(); |
321 | } | 344 | } |
322 | 345 | ||
323 | /*! | 346 | /*! |
324 | Sets whether a categories menu is visible, according to \a b. | ||
325 | */ | ||
326 | void FileSelector::setCategoriesVisible( bool b ) | ||
327 | { | ||
328 | if ( b ) | ||
329 | d->mb->show(); | ||
330 | else | ||
331 | d->mb->hide(); | ||
332 | } | ||
333 | |||
334 | /*! | ||
335 | Rereads the list of files. | 347 | Rereads the list of files. |
336 | */ | 348 | */ |
337 | void FileSelector::reread() | 349 | void FileSelector::reread() |
338 | { | 350 | { |
339 | view->reread(); | 351 | view->reread(); |
340 | } | 352 | } |
353 | |||