summaryrefslogtreecommitdiff
path: root/libopie2/opieui/fileselector/ofileselector.cpp
Unidiff
Diffstat (limited to 'libopie2/opieui/fileselector/ofileselector.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/fileselector/ofileselector.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp
index 600daff..15cadd4 100644
--- a/libopie2/opieui/fileselector/ofileselector.cpp
+++ b/libopie2/opieui/fileselector/ofileselector.cpp
@@ -117,198 +117,198 @@ void OFileViewInterface::ok()
117void OFileViewInterface::cancel() 117void OFileViewInterface::cancel()
118{ 118{
119 emit selector()->cancel(); 119 emit selector()->cancel();
120} 120}
121 121
122void OFileViewInterface::closeMe() 122void OFileViewInterface::closeMe()
123{ 123{
124 emit selector()->closeMe(); 124 emit selector()->closeMe();
125} 125}
126 126
127void OFileViewInterface::fileSelected( const QString& str) 127void OFileViewInterface::fileSelected( const QString& str)
128{ 128{
129 emit selector()->fileSelected( str); 129 emit selector()->fileSelected( str);
130} 130}
131 131
132void OFileViewInterface::fileSelected( const DocLnk& lnk) 132void OFileViewInterface::fileSelected( const DocLnk& lnk)
133{ 133{
134 emit selector()->fileSelected( lnk ); 134 emit selector()->fileSelected( lnk );
135} 135}
136 136
137void OFileViewInterface::setCurrentFileName( const QString& str ) 137void OFileViewInterface::setCurrentFileName( const QString& str )
138{ 138{
139 selector()->m_lneEdit->setText( str ); 139 selector()->m_lneEdit->setText( str );
140} 140}
141 141
142QString OFileViewInterface::currentFileName()const 142QString OFileViewInterface::currentFileName()const
143{ 143{
144 return selector()->m_lneEdit->text(); 144 return selector()->m_lneEdit->text();
145} 145}
146 146
147QString OFileViewInterface::startDirectory()const 147QString OFileViewInterface::startDirectory()const
148{ 148{
149 return selector()->m_startDir; 149 return selector()->m_startDir;
150} 150}
151 151
152ODocumentFileView::ODocumentFileView( OFileSelector* selector ) 152ODocumentFileView::ODocumentFileView( OFileSelector* selector )
153 :OFileViewInterface( selector ) 153 :OFileViewInterface( selector )
154{ 154{
155 m_selector = 0; 155 m_selector = 0;
156 setName( QObject::tr("Documents") ); 156 setName( QObject::tr("Documents") );
157} 157}
158 158
159ODocumentFileView::~ODocumentFileView() 159ODocumentFileView::~ODocumentFileView()
160{ 160{
161} 161}
162 162
163QString ODocumentFileView::selectedName()const 163QString ODocumentFileView::selectedName()const
164{ 164{
165 if (!m_selector) 165 if (!m_selector)
166 return QString::null; 166 return QString::null;
167 167
168 return m_selector->selectedDocument().file(); 168 return m_selector->selectedDocument().file();
169} 169}
170 170
171QString ODocumentFileView::selectedPath()const 171QString ODocumentFileView::selectedPath()const
172{ 172{
173 return QPEApplication::documentDir(); 173 return QPEApplication::documentDir();
174} 174}
175 175
176QString ODocumentFileView::directory()const 176QString ODocumentFileView::directory()const
177{ 177{
178 return selectedPath(); 178 return selectedPath();
179} 179}
180 180
181void ODocumentFileView::reread() 181void ODocumentFileView::reread()
182{ 182{
183 if (!m_selector) 183 if (!m_selector)
184 return; 184 return;
185 185
186 m_selector->setNewVisible( showNew() ); 186 m_selector->setNewVisible( showNew() );
187 m_selector->setCloseVisible( showClose() ); 187 m_selector->setCloseVisible( showClose() );
188 m_selector->filter = currentMimeType().join(";"); 188 m_selector->filter = currentMimeType().join(";");
189 m_selector->reread(); 189 m_selector->reread();
190} 190}
191 191
192int ODocumentFileView::fileCount()const 192int ODocumentFileView::fileCount()const
193{ 193{
194 if (!m_selector) 194 if (!m_selector)
195 return -1; 195 return -1;
196 196
197 return m_selector->fileCount(); 197 return m_selector->fileCount();
198} 198}
199 199
200DocLnk ODocumentFileView::selectedDocument()const 200DocLnk ODocumentFileView::selectedDocument()const
201{ 201{
202 if (!m_selector) 202 if (!m_selector)
203 return DocLnk(); 203 return DocLnk();
204 204
205 return m_selector->selectedDocument(); 205 return m_selector->selectedDocument();
206} 206}
207 207
208QWidget* ODocumentFileView::widget( QWidget* parent ) 208QWidget* ODocumentFileView::widget( QWidget* parent )
209{ 209{
210 if (!m_selector ) 210 if (!m_selector )
211 { 211 {
212 m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() ); 212 m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() );
213 QObject::connect(m_selector, SIGNAL(fileSelected( const DocLnk& ) ), 213 QObject::connect(m_selector, SIGNAL(fileSelected(const DocLnk&) ),
214 selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) ); 214 selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) );
215 QObject::connect(m_selector, SIGNAL(closeMe() ), 215 QObject::connect(m_selector, SIGNAL(closeMe() ),
216 selector(), SIGNAL(closeMe() ) ); 216 selector(), SIGNAL(closeMe() ) );
217 QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk& ) ), 217 QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk&) ),
218 selector(), SIGNAL(newSelected(const DocLnk& ) ) ); 218 selector(), SIGNAL(newSelected(const DocLnk&) ) );
219 } 219 }
220 220
221 return m_selector; 221 return m_selector;
222} 222}
223 223
224/* 224/*
225 * This is the file system view used 225 * This is the file system view used
226 * we use a QListView + QListViewItems for it 226 * we use a QListView + QListViewItems for it
227 */ 227 */
228 228
229OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap, 229OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap,
230 const QString& path, const QString& date, 230 const QString& path, const QString& date,
231 const QString& size, const QString& dir, 231 const QString& size, const QString& dir,
232 bool isLocked, bool isDir ) 232 bool isLocked, bool isDir )
233 : QListViewItem( view ) 233 : QListViewItem( view )
234{ 234{
235 setPixmap(0, pixmap ); 235 setPixmap(0, pixmap );
236 setText(1, path ); 236 setText(1, path );
237 setText(2, size ); 237 setText(2, size );
238 setText(3, date ); 238 setText(3, date );
239 m_isDir = isDir; 239 m_isDir = isDir;
240 m_dir = dir; 240 m_dir = dir;
241 m_locked = isLocked; 241 m_locked = isLocked;
242} 242}
243 243
244OFileSelectorItem::~OFileSelectorItem() 244OFileSelectorItem::~OFileSelectorItem()
245{ 245{
246} 246}
247 247
248bool OFileSelectorItem::isLocked()const 248bool OFileSelectorItem::isLocked()const
249{ 249{
250 return m_locked; 250 return m_locked;
251} 251}
252 252
253QString OFileSelectorItem::directory()const 253QString OFileSelectorItem::directory()const
254{ 254{
255 return m_dir; 255 return m_dir;
256} 256}
257 257
258bool OFileSelectorItem::isDir()const 258bool OFileSelectorItem::isDir()const
259{ 259{
260 return m_isDir; 260 return m_isDir;
261} 261}
262 262
263QString OFileSelectorItem::path()const 263QString OFileSelectorItem::path()const
264{ 264{
265 return text( 1 ); 265 return text( 1 );
266} 266}
267 267
268QString OFileSelectorItem::key( int id, bool )const 268QString OFileSelectorItem::key( int id, bool )const
269{ 269{
270 QString ke; 270 QString ke;
271 if( id == 0 || id == 1 ) 271 if( id == 0 || id == 1 )
272 { // name 272 { // name
273 if( m_isDir ) 273 if( m_isDir )
274 { 274 {
275 ke.append("0" ); 275 ke.append("0" );
276 ke.append( text(1) ); 276 ke.append( text(1) );
277 } 277 }
278 else 278 else
279 { 279 {
280 ke.append("1" ); 280 ke.append("1" );
281 ke.append( text(1) ); 281 ke.append( text(1) );
282 } 282 }
283 return ke; 283 return ke;
284 } 284 }
285 else 285 else
286 return text( id ); 286 return text( id );
287 287
288} 288}
289 289
290OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, OFileSelector* sel) 290OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, OFileSelector* sel)
291 :QWidget( parent ), m_sel( sel ) 291 :QWidget( parent ), m_sel( sel )
292{ 292{
293 m_all = false; 293 m_all = false;
294 QVBoxLayout* lay = new QVBoxLayout( this ); 294 QVBoxLayout* lay = new QVBoxLayout( this );
295 m_currentDir = startDir; 295 m_currentDir = startDir;
296 296
297 /* 297 /*
298 * now we add a special bar 298 * now we add a special bar
299 * One Button For Up 299 * One Button For Up
300 * Home 300 * Home
301 * Doc 301 * Doc
302 * And a dropdown menu with FileSystems 302 * And a dropdown menu with FileSystems
303 * FUTURE: one to change dir with lineedit 303 * FUTURE: one to change dir with lineedit
304 * Bookmarks 304 * Bookmarks
305 * Create Dir 305 * Create Dir
306 */ 306 */
307 QHBox* box = new QHBox(this ); 307 QHBox* box = new QHBox(this );
308 box->setBackgroundMode( PaletteButton ); 308 box->setBackgroundMode( PaletteButton );
309 box->setSpacing( 0 ); 309 box->setSpacing( 0 );
310 310
311 QToolButton *btn = new QToolButton( box ); 311 QToolButton *btn = new QToolButton( box );
312 btn->setIconSet( Resource::loadIconSet("up") ); 312 btn->setIconSet( Resource::loadIconSet("up") );
313 connect(btn, SIGNAL(clicked() ), 313 connect(btn, SIGNAL(clicked() ),
314 this, SLOT( cdUP() ) ); 314 this, SLOT( cdUP() ) );
@@ -431,194 +431,194 @@ void OFileViewFileListView::reread( bool all )
431 const QFileInfoList *list = dir.entryInfoList(); 431 const QFileInfoList *list = dir.entryInfoList();
432 if (!list) 432 if (!list)
433 { 433 {
434 cdUP(); 434 cdUP();
435 return; 435 return;
436 } 436 }
437 437
438 QFileInfoListIterator it( *list ); 438 QFileInfoListIterator it( *list );
439 QFileInfo *fi; 439 QFileInfo *fi;
440 while( (fi=it.current() ) ) 440 while( (fi=it.current() ) )
441 { 441 {
442 if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ) 442 if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") )
443 { 443 {
444 ++it; 444 ++it;
445 continue; 445 continue;
446 } 446 }
447 447
448 /* 448 /*
449 * It is a symlink we try to resolve it now but don't let us attack by DOS 449 * It is a symlink we try to resolve it now but don't let us attack by DOS
450 * 450 *
451 */ 451 */
452 if( fi->isSymLink() ) 452 if( fi->isSymLink() )
453 { 453 {
454 QString file = fi->dirPath( true ) + "/" + fi->readLink(); 454 QString file = fi->dirPath( true ) + "/" + fi->readLink();
455 for( int i = 0; i<=4; i++) 455 for( int i = 0; i<=4; i++)
456 { // 5 tries to prevent dos 456 { // 5 tries to prevent dos
457 QFileInfo info( file ); 457 QFileInfo info( file );
458 if( !info.exists() ) 458 if( !info.exists() )
459 { 459 {
460 addSymlink( fi, TRUE ); 460 addSymlink( fi, TRUE );
461 break; 461 break;
462 } 462 }
463 else if( info.isDir() ) 463 else if( info.isDir() )
464 { 464 {
465 addDir( fi, TRUE ); 465 addDir( fi, TRUE );
466 break; 466 break;
467 } 467 }
468 else if( info.isFile() ) 468 else if( info.isFile() )
469 { 469 {
470 addFile( fi, TRUE ); 470 addFile( fi, TRUE );
471 break; 471 break;
472 } 472 }
473 else if( info.isSymLink() ) 473 else if( info.isSymLink() )
474 { 474 {
475 file = info.dirPath(true ) + "/" + info.readLink() ; 475 file = info.dirPath(true ) + "/" + info.readLink() ;
476 break; 476 break;
477 } 477 }
478 else if( i == 4) 478 else if( i == 4)
479 { // couldn't resolve symlink add it as symlink 479 { // couldn't resolve symlink add it as symlink
480 addSymlink( fi ); 480 addSymlink( fi );
481 } 481 }
482 } // off for loop for symlink resolving 482 } // off for loop for symlink resolving
483 } 483 }
484 else if( fi->isDir() ) 484 else if( fi->isDir() )
485 addDir( fi ); 485 addDir( fi );
486 else if( fi->isFile() ) 486 else if( fi->isFile() )
487 addFile( fi ); 487 addFile( fi );
488 488
489 ++it; 489 ++it;
490 } // of while loop 490 } // of while loop
491 m_view->sort(); 491 m_view->sort();
492 492
493} 493}
494int OFileViewFileListView::fileCount()const 494int OFileViewFileListView::fileCount()const
495{ 495{
496 return m_view->childCount(); 496 return m_view->childCount();
497} 497}
498 498
499QString OFileViewFileListView::currentDir()const 499QString OFileViewFileListView::currentDir()const
500{ 500{
501 return m_currentDir; 501 return m_currentDir;
502} 502}
503 503
504OFileSelector* OFileViewFileListView::selector() 504OFileSelector* OFileViewFileListView::selector()
505{ 505{
506 return m_sel; 506 return m_sel;
507} 507}
508 508
509bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e) 509bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e)
510{ 510{
511 if ( e->type() == QEvent::KeyPress ) 511 if ( e->type() == QEvent::KeyPress )
512 { 512 {
513 QKeyEvent *k = (QKeyEvent *)e; 513 QKeyEvent *k = (QKeyEvent *)e;
514 if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) 514 if ( (k->key()==Key_Enter) || (k->key()==Key_Return))
515 { 515 {
516 slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); 516 slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0);
517 return true; 517 return true;
518 } 518 }
519 } 519 }
520 return false; 520 return false;
521} 521}
522 522
523void OFileViewFileListView::connectSlots() 523void OFileViewFileListView::connectSlots()
524{ 524{
525 connect(m_view, SIGNAL(clicked(QListViewItem*) ), 525 connect(m_view, SIGNAL(clicked(QListViewItem*) ),
526 this, SLOT(slotCurrentChanged(QListViewItem*) ) ); 526 this, SLOT(slotCurrentChanged(QListViewItem*) ) );
527 connect(m_view, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint&, int ) ), 527 connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ),
528 this, SLOT(slotClicked(int, QListViewItem*, const QPoint&, int ) ) ); 528 this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) );
529} 529}
530 530
531void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) 531void OFileViewFileListView::slotCurrentChanged( QListViewItem* item)
532{ 532{
533 if (!item) 533 if (!item)
534 return; 534 return;
535#if 0 535#if 0
536 536
537 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); 537 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item);
538 538
539 if (!sel->isDir() ) 539 if (!sel->isDir() )
540 { 540 {
541 selector()->m_lneEdit->setText( sel->text(1) ); 541 selector()->m_lneEdit->setText( sel->text(1) );
542 // if in fileselector mode we will emit selected 542 // if in fileselector mode we will emit selected
543 if ( selector()->mode() == OFileSelector::FileSelector ) 543 if ( selector()->mode() == OFileSelector::FileSelector )
544 { 544 {
545 qWarning("slot Current Changed"); 545 qWarning("slot Current Changed");
546 QStringList str = QStringList::split("->", sel->text(1) ); 546 QStringList str = QStringList::split("->", sel->text(1) );
547 QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); 547 QString path = sel->directory() + "/" + str[0].stripWhiteSpace();
548 emit selector()->fileSelected( path ); 548 emit selector()->fileSelected( path );
549 DocLnk lnk( path ); 549 DocLnk lnk( path );
550 emit selector()->fileSelected( lnk ); 550 emit selector()->fileSelected( lnk );
551 } 551 }
552 } 552 }
553#endif 553#endif
554} 554}
555 555
556void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) 556void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int )
557{ 557{
558 if (!item || ( button != Qt::LeftButton) ) 558 if (!item || ( button != Qt::LeftButton) )
559 return; 559 return;
560 560
561 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); 561 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item);
562 if (!sel->isLocked() ) 562 if (!sel->isLocked() )
563 { 563 {
564 QStringList str = QStringList::split("->", sel->text(1) ); 564 QStringList str = QStringList::split("->", sel->text(1) );
565 if (sel->isDir() ) 565 if (sel->isDir() )
566 { 566 {
567 m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); 567 m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace();
568 emit selector()->dirSelected( m_currentDir ); 568 emit selector()->dirSelected( m_currentDir );
569 reread( m_all ); 569 reread( m_all );
570 } 570 }
571 else 571 else
572 { // file 572 { // file
573 qWarning("slot Clicked"); 573 qWarning("slot Clicked");
574 selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); 574 selector()->m_lneEdit->setText( str[0].stripWhiteSpace() );
575 QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); 575 QString path = sel->directory() + "/" + str[0].stripWhiteSpace();
576 emit selector()->fileSelected( path ); 576 emit selector()->fileSelected( path );
577 DocLnk lnk( path ); 577 DocLnk lnk( path );
578 emit selector()->fileSelected( lnk ); 578 emit selector()->fileSelected( lnk );
579 } 579 }
580 } // not locked 580 } // not locked
581} 581}
582 582
583void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) 583void OFileViewFileListView::addFile( QFileInfo* info, bool symlink )
584{ 584{
585 MimeType type( info->absFilePath() ); 585 MimeType type( info->absFilePath() );
586 if (!compliesMime( type.id() ) ) 586 if (!compliesMime( type.id() ) )
587 return; 587 return;
588 588
589 QPixmap pix = type.pixmap(); 589 QPixmap pix = type.pixmap();
590 QString dir, name; bool locked; 590 QString dir, name; bool locked;
591 if ( pix.isNull() ) 591 if ( pix.isNull() )
592 { 592 {
593 QWMatrix matrix; 593 QWMatrix matrix;
594 QPixmap pixer(Resource::loadPixmap("UnknownDocument") ); 594 QPixmap pixer(Resource::loadPixmap("UnknownDocument") );
595 matrix.scale( .4, .4 ); 595 matrix.scale( .4, .4 );
596 pix = pixer.xForm( matrix ); 596 pix = pixer.xForm( matrix );
597 } 597 }
598 dir = info->dirPath( true ); 598 dir = info->dirPath( true );
599 locked = false; 599 locked = false;
600 if ( symlink ) 600 if ( symlink )
601 name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink(); 601 name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink();
602 else 602 else
603 { 603 {
604 name = info->fileName(); 604 name = info->fileName();
605 if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || 605 if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) ||
606 ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) 606 ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) )
607 { 607 {
608 locked = true; pix = Resource::loadPixmap("locked"); 608 locked = true; pix = Resource::loadPixmap("locked");
609 } 609 }
610 } 610 }
611 (void)new OFileSelectorItem( m_view, pix, name, 611 (void)new OFileSelectorItem( m_view, pix, name,
612 info->lastModified().toString(), QString::number( info->size() ), 612 info->lastModified().toString(), QString::number( info->size() ),
613 dir, locked ); 613 dir, locked );
614} 614}
615 615
616void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) 616void OFileViewFileListView::addDir( QFileInfo* info, bool symlink )
617{ 617{
618 bool locked = false; QString name; QPixmap pix; 618 bool locked = false; QString name; QPixmap pix;
619 619
620 if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || 620 if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) ||
621 ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) 621 ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) )
622 { 622 {
623 locked = true; 623 locked = true;
624 if ( symlink ) 624 if ( symlink )
@@ -886,194 +886,194 @@ OFileSelector::OFileSelector( QWidget* parent, int mode, int sel,
886 * This a convience c'tor to just substitute the use of FileSelector 886 * This a convience c'tor to just substitute the use of FileSelector
887 */ 887 */
888OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name, 888OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const char* name,
889 bool showNew, bool showClose ) 889 bool showNew, bool showClose )
890 : QWidget( parent, name ) 890 : QWidget( parent, name )
891{ 891{
892 m_current = 0; 892 m_current = 0;
893 m_shNew = showNew; 893 m_shNew = showNew;
894 m_shClose = showClose; 894 m_shClose = showClose;
895 m_startDir = QPEApplication::documentDir(); 895 m_startDir = QPEApplication::documentDir();
896 896
897 if (!mimeFilter.isEmpty() ) 897 if (!mimeFilter.isEmpty() )
898 m_mimeType.insert(mimeFilter, QStringList::split(";", mimeFilter ) ); 898 m_mimeType.insert(mimeFilter, QStringList::split(";", mimeFilter ) );
899 899
900 m_mode = OFileSelector::FileSelector; 900 m_mode = OFileSelector::FileSelector;
901 m_selector = OFileSelector::Normal; 901 m_selector = OFileSelector::Normal;
902 902
903 initUI(); 903 initUI();
904 initMime(); 904 initMime();
905 initViews(); 905 initViews();
906 m_cmbView->setCurrentItem( 0 ); 906 m_cmbView->setCurrentItem( 0 );
907 slotViewChange( QObject::tr("Documents") ); 907 slotViewChange( QObject::tr("Documents") );
908} 908}
909 909
910/* 910/*
911 * INIT UI will set up the basic GUI 911 * INIT UI will set up the basic GUI
912 * Layout: Simple VBoxLayout 912 * Layout: Simple VBoxLayout
913 * On top a WidgetStack containing the Views... 913 * On top a WidgetStack containing the Views...
914 * - List View 914 * - List View
915 * - Document View 915 * - Document View
916 * Below we will have a Label + LineEdit 916 * Below we will have a Label + LineEdit
917 * Below we will have two ComoBoxes one for choosing the view one for 917 * Below we will have two ComoBoxes one for choosing the view one for
918 * choosing the mimetype 918 * choosing the mimetype
919 */ 919 */
920void OFileSelector::initUI() 920void OFileSelector::initUI()
921{ 921{
922 QVBoxLayout* lay = new QVBoxLayout( this ); 922 QVBoxLayout* lay = new QVBoxLayout( this );
923 923
924 m_stack = new QWidgetStack( this ); 924 m_stack = new QWidgetStack( this );
925 lay->addWidget( m_stack, 1000 ); 925 lay->addWidget( m_stack, 1000 );
926 926
927 m_nameBox = new QHBox( this ); 927 m_nameBox = new QHBox( this );
928 (void)new QLabel( tr("Name:"), m_nameBox ); 928 (void)new QLabel( tr("Name:"), m_nameBox );
929 m_lneEdit = new QLineEdit( m_nameBox ); 929 m_lneEdit = new QLineEdit( m_nameBox );
930 m_lneEdit ->installEventFilter(this); 930 m_lneEdit ->installEventFilter(this);
931 lay->addWidget( m_nameBox ); 931 lay->addWidget( m_nameBox );
932 932
933 m_cmbBox = new QHBox( this ); 933 m_cmbBox = new QHBox( this );
934 m_cmbView = new QComboBox( m_cmbBox ); 934 m_cmbView = new QComboBox( m_cmbBox );
935 m_cmbMime = new QComboBox( m_cmbBox ); 935 m_cmbMime = new QComboBox( m_cmbBox );
936 lay->addWidget( m_cmbBox ); 936 lay->addWidget( m_cmbBox );
937} 937}
938 938
939/* 939/*
940 * This will make sure that the return key in the name edit causes dialogs to close 940 * This will make sure that the return key in the name edit causes dialogs to close
941 */ 941 */
942 942
943bool OFileSelector::eventFilter (QObject *o, QEvent *e) 943bool OFileSelector::eventFilter (QObject *o, QEvent *e)
944{ 944{
945 if ( e->type() == QEvent::KeyPress ) 945 if ( e->type() == QEvent::KeyPress )
946 { 946 {
947 QKeyEvent *k = (QKeyEvent *)e; 947 QKeyEvent *k = (QKeyEvent *)e;
948 if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) 948 if ( (k->key()==Key_Enter) || (k->key()==Key_Return))
949 { 949 {
950 emit ok(); 950 emit ok();
951 return true; 951 return true;
952 } 952 }
953 } 953 }
954 return false; 954 return false;
955} 955}
956 956
957/* 957/*
958 * This will insert the MimeTypes into the Combo Box 958 * This will insert the MimeTypes into the Combo Box
959 * And also connect the changed signal 959 * And also connect the changed signal
960 * 960 *
961 * AutoMimeTyping is disabled for now. It used to reparse a dir and then set available mimetypes 961 * AutoMimeTyping is disabled for now. It used to reparse a dir and then set available mimetypes
962 */ 962 */
963void OFileSelector::initMime() 963void OFileSelector::initMime()
964{ 964{
965 MimeTypes::Iterator it; 965 MimeTypes::Iterator it;
966 for ( it = m_mimeType.begin(); it != m_mimeType.end(); ++it ) 966 for ( it = m_mimeType.begin(); it != m_mimeType.end(); ++it )
967 { 967 {
968 m_cmbMime->insertItem( it.key() ); 968 m_cmbMime->insertItem( it.key() );
969 } 969 }
970 m_cmbMime->setCurrentItem( 0 ); 970 m_cmbMime->setCurrentItem( 0 );
971 971
972 connect( m_cmbMime, SIGNAL(activated(int) ), 972 connect( m_cmbMime, SIGNAL(activated(int) ),
973 this, SLOT(slotMimeTypeChanged() ) ); 973 this, SLOT(slotMimeTypeChanged() ) );
974 974
975} 975}
976 976
977void OFileSelector::initViews() 977void OFileSelector::initViews()
978{ 978{
979 m_cmbView->insertItem( QObject::tr("Documents") ); 979 m_cmbView->insertItem( QObject::tr("Documents") );
980 m_cmbView->insertItem( QObject::tr("Files") ); 980 m_cmbView->insertItem( QObject::tr("Files") );
981 m_cmbView->insertItem( QObject::tr("All Files") ); 981 m_cmbView->insertItem( QObject::tr("All Files") );
982 connect(m_cmbView, SIGNAL(activated( const QString& ) ), 982 connect(m_cmbView, SIGNAL(activated(const QString&) ),
983 this, SLOT(slotViewChange( const QString& ) ) ); 983 this, SLOT(slotViewChange(const QString&) ) );
984 984
985 985
986 m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) ); 986 m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) );
987 987
988 /* see above why add both */ 988 /* see above why add both */
989 OFileViewInterface* in = new OFileViewFileSystem( this ); 989 OFileViewInterface* in = new OFileViewFileSystem( this );
990 m_views.insert( QObject::tr("Files"), in ); 990 m_views.insert( QObject::tr("Files"), in );
991 m_views.insert( QObject::tr("All Files"), in ); 991 m_views.insert( QObject::tr("All Files"), in );
992} 992}
993 993
994/** 994/**
995 * d'tor 995 * d'tor
996 */ 996 */
997OFileSelector::~OFileSelector() 997OFileSelector::~OFileSelector()
998{ 998{
999} 999}
1000 1000
1001 1001
1002 1002
1003/** 1003/**
1004 * Convience function for the fileselector 1004 * Convience function for the fileselector
1005 * make sure to delete the DocLnk 1005 * make sure to delete the DocLnk
1006 * 1006 *
1007 * @see DocLnk 1007 * @see DocLnk
1008 * @todo remove in ODP 1008 * @todo remove in ODP
1009 */ 1009 */
1010const DocLnk* OFileSelector::selected() 1010const DocLnk* OFileSelector::selected()
1011{ 1011{
1012 DocLnk* lnk = new DocLnk( currentView()->selectedDocument() ); 1012 DocLnk* lnk = new DocLnk( currentView()->selectedDocument() );
1013 return lnk; 1013 return lnk;
1014} 1014}
1015 1015
1016/** 1016/**
1017 * 1017 *
1018 * @return the name of the selected file 1018 * @return the name of the selected file
1019 */ 1019 */
1020QString OFileSelector::selectedName()const 1020QString OFileSelector::selectedName()const
1021{ 1021{
1022 return currentView()->selectedName(); 1022 return currentView()->selectedName();
1023} 1023}
1024 1024
1025 1025
1026/** 1026/**
1027 * @return the selected path 1027 * @return the selected path
1028 */ 1028 */
1029QString OFileSelector::selectedPath()const 1029QString OFileSelector::selectedPath()const
1030{ 1030{
1031 return currentView()->selectedPath(); 1031 return currentView()->selectedPath();
1032} 1032}
1033 1033
1034/** 1034/**
1035 * @return the directory name 1035 * @return the directory name
1036 */ 1036 */
1037QString OFileSelector::directory()const 1037QString OFileSelector::directory()const
1038{ 1038{
1039 return currentView()->directory(); 1039 return currentView()->directory();
1040} 1040}
1041 1041
1042/** 1042/**
1043 * @return a DocLnk for the selected document 1043 * @return a DocLnk for the selected document
1044 */ 1044 */
1045DocLnk OFileSelector::selectedDocument()const 1045DocLnk OFileSelector::selectedDocument()const
1046{ 1046{
1047 return currentView()->selectedDocument(); 1047 return currentView()->selectedDocument();
1048} 1048}
1049 1049
1050/** 1050/**
1051 * @return the number of items for the current view 1051 * @return the number of items for the current view
1052 */ 1052 */
1053int OFileSelector::fileCount()const 1053int OFileSelector::fileCount()const
1054{ 1054{
1055 return currentView()->fileCount(); 1055 return currentView()->fileCount();
1056} 1056}
1057 1057
1058/** 1058/**
1059 * @return reparse the file content 1059 * @return reparse the file content
1060 */ 1060 */
1061void OFileSelector::reread() 1061void OFileSelector::reread()
1062{ 1062{
1063 return currentView()->reread(); 1063 return currentView()->reread();
1064} 1064}
1065 1065
1066OFileViewInterface* OFileSelector::currentView()const 1066OFileViewInterface* OFileSelector::currentView()const
1067{ 1067{
1068 return m_current; 1068 return m_current;
1069} 1069}
1070 1070
1071bool OFileSelector::showNew()const 1071bool OFileSelector::showNew()const
1072{ 1072{
1073 return m_shNew; 1073 return m_shNew;
1074} 1074}
1075 1075
1076bool OFileSelector::showClose()const 1076bool OFileSelector::showClose()const
1077{ 1077{
1078 return m_shClose; 1078 return m_shClose;
1079} 1079}