summaryrefslogtreecommitdiff
path: root/libopie2/opieui
Unidiff
Diffstat (limited to 'libopie2/opieui') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/fileselector/ofileselector.cpp19
-rw-r--r--libopie2/opieui/fileselector/ofileselector.h10
2 files changed, 24 insertions, 5 deletions
diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp
index 5528aed..b06defd 100644
--- a/libopie2/opieui/fileselector/ofileselector.cpp
+++ b/libopie2/opieui/fileselector/ofileselector.cpp
@@ -17,99 +17,101 @@
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details. 19++=   -.     .`     .: details.
20 :     =  ...= . :.=- 20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
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 {
65OFileViewInterface::OFileViewInterface( OFileSelector* selector ) 65OFileViewInterface::OFileViewInterface( OFileSelector* _selector )
66 : m_selector( selector ) 66 : m_selector( _selector )
67{} 67{
68 selector()->registerView( this );
69}
68 70
69OFileViewInterface::~OFileViewInterface() 71OFileViewInterface::~OFileViewInterface()
70{} 72{}
71 73
72QString OFileViewInterface::name()const 74QString OFileViewInterface::name()const
73{ 75{
74 return m_name; 76 return m_name;
75} 77}
76 78
77void OFileViewInterface::setName( const QString& name ) 79void OFileViewInterface::setName( const QString& name )
78{ 80{
79 m_name = name; 81 m_name = name;
80} 82}
81 83
82OFileSelector* OFileViewInterface::selector()const 84OFileSelector* OFileViewInterface::selector()const
83{ 85{
84 return m_selector; 86 return m_selector;
85} 87}
86 88
87DocLnk OFileViewInterface::selectedDocument()const 89DocLnk OFileViewInterface::selectedDocument()const
88{ 90{
89 return DocLnk( selectedName() ); 91 return DocLnk( selectedName() );
90} 92}
91 93
92bool OFileViewInterface::showNew()const 94bool OFileViewInterface::showNew()const
93{ 95{
94 return selector()->showNew(); 96 return selector()->showNew();
95} 97}
96 98
97bool OFileViewInterface::showClose()const 99bool OFileViewInterface::showClose()const
98{ 100{
99 return selector()->showClose(); 101 return selector()->showClose();
100} 102}
101 103
102MimeTypes OFileViewInterface::mimeTypes()const 104MimeTypes OFileViewInterface::mimeTypes()const
103{ 105{
104 return selector()->mimeTypes(); 106 return selector()->mimeTypes();
105} 107}
106 108
107QStringList OFileViewInterface::currentMimeType()const 109QStringList OFileViewInterface::currentMimeType()const
108{ 110{
109 return selector()->currentMimeType(); 111 return selector()->currentMimeType();
110} 112}
111 113
112void OFileViewInterface::activate( const QString& ) 114void OFileViewInterface::activate( const QString& )
113{ 115{
114 // not implemented here 116 // not implemented here
115} 117}
@@ -466,97 +468,97 @@ void OFileViewFileListView::reread( bool all )
466 break; 468 break;
467 } 469 }
468 else if( info.isDir() ) 470 else if( info.isDir() )
469 { 471 {
470 addDir( fi, TRUE ); 472 addDir( fi, TRUE );
471 break; 473 break;
472 } 474 }
473 else if( info.isFile() ) 475 else if( info.isFile() )
474 { 476 {
475 addFile( fi, TRUE ); 477 addFile( fi, TRUE );
476 break; 478 break;
477 } 479 }
478 else if( info.isSymLink() ) 480 else if( info.isSymLink() )
479 { 481 {
480 file = info.dirPath(true ) + "/" + info.readLink() ; 482 file = info.dirPath(true ) + "/" + info.readLink() ;
481 break; 483 break;
482 } 484 }
483 else if( i == 4) 485 else if( i == 4)
484 { // couldn't resolve symlink add it as symlink 486 { // couldn't resolve symlink add it as symlink
485 addSymlink( fi ); 487 addSymlink( fi );
486 } 488 }
487 } // off for loop for symlink resolving 489 } // off for loop for symlink resolving
488 } 490 }
489 else if( fi->isDir() ) 491 else if( fi->isDir() )
490 addDir( fi ); 492 addDir( fi );
491 else if( fi->isFile() ) 493 else if( fi->isFile() )
492 addFile( fi ); 494 addFile( fi );
493 495
494 ++it; 496 ++it;
495 } // of while loop 497 } // of while loop
496 m_view->sort(); 498 m_view->sort();
497 499
498} 500}
499int OFileViewFileListView::fileCount()const 501int OFileViewFileListView::fileCount()const
500{ 502{
501 return m_view->childCount(); 503 return m_view->childCount();
502} 504}
503 505
504QString OFileViewFileListView::currentDir()const 506QString OFileViewFileListView::currentDir()const
505{ 507{
506 return m_currentDir; 508 return m_currentDir;
507} 509}
508 510
509OFileSelector* OFileViewFileListView::selector() 511OFileSelector* OFileViewFileListView::selector()
510{ 512{
511 return m_sel; 513 return m_sel;
512} 514}
513 515
514bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e) 516bool OFileViewFileListView::eventFilter (QObject *, QEvent *e)
515{ 517{
516 if ( e->type() == QEvent::KeyPress ) 518 if ( e->type() == QEvent::KeyPress )
517 { 519 {
518 QKeyEvent *k = (QKeyEvent *)e; 520 QKeyEvent *k = (QKeyEvent *)e;
519 if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) 521 if ( (k->key()==Key_Enter) || (k->key()==Key_Return))
520 { 522 {
521 slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); 523 slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0);
522 return true; 524 return true;
523 } 525 }
524 } 526 }
525 return false; 527 return false;
526} 528}
527 529
528void OFileViewFileListView::connectSlots() 530void OFileViewFileListView::connectSlots()
529{ 531{
530 connect(m_view, SIGNAL(clicked(QListViewItem*) ), 532 connect(m_view, SIGNAL(clicked(QListViewItem*) ),
531 this, SLOT(slotCurrentChanged(QListViewItem*) ) ); 533 this, SLOT(slotCurrentChanged(QListViewItem*) ) );
532 connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ), 534 connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ),
533 this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) ); 535 this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) );
534} 536}
535 537
536void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) 538void OFileViewFileListView::slotCurrentChanged( QListViewItem* item)
537{ 539{
538 if (!item) 540 if (!item)
539 return; 541 return;
540#if 0 542#if 0
541 543
542 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); 544 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item);
543 545
544 if (!sel->isDir() ) 546 if (!sel->isDir() )
545 { 547 {
546 selector()->m_lneEdit->setText( sel->text(1) ); 548 selector()->m_lneEdit->setText( sel->text(1) );
547 // if in fileselector mode we will emit selected 549 // if in fileselector mode we will emit selected
548 if ( selector()->mode() == OFileSelector::FileSelector ) 550 if ( selector()->mode() == OFileSelector::FileSelector )
549 { 551 {
550 odebug << "slot Current Changed" << oendl; 552 odebug << "slot Current Changed" << oendl;
551 QStringList str = QStringList::split("->", sel->text(1) ); 553 QStringList str = QStringList::split("->", sel->text(1) );
552 QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); 554 QString path = sel->directory() + "/" + str[0].stripWhiteSpace();
553 emit selector()->fileSelected( path ); 555 emit selector()->fileSelected( path );
554 DocLnk lnk( path ); 556 DocLnk lnk( path );
555 emit selector()->fileSelected( lnk ); 557 emit selector()->fileSelected( lnk );
556 } 558 }
557 } 559 }
558#endif 560#endif
559} 561}
560 562
561void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) 563void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int )
562{ 564{
@@ -902,152 +904,159 @@ OFileSelector::OFileSelector( const QString& mimeFilter, QWidget* parent, const
902 m_startDir = QPEApplication::documentDir(); 904 m_startDir = QPEApplication::documentDir();
903 905
904 if (!mimeFilter.isEmpty() ) 906 if (!mimeFilter.isEmpty() )
905 m_mimeType.insert(mimeFilter, QStringList::split(";", mimeFilter ) ); 907 m_mimeType.insert(mimeFilter, QStringList::split(";", mimeFilter ) );
906 908
907 m_mode = OFileSelector::FileSelector; 909 m_mode = OFileSelector::FileSelector;
908 m_selector = OFileSelector::Normal; 910 m_selector = OFileSelector::Normal;
909 911
910 initUI(); 912 initUI();
911 initMime(); 913 initMime();
912 initViews(); 914 initViews();
913 m_cmbView->setCurrentItem( 0 ); 915 m_cmbView->setCurrentItem( 0 );
914 slotViewChange( QObject::tr("Documents") ); 916 slotViewChange( QObject::tr("Documents") );
915} 917}
916 918
917/* 919/*
918 * INIT UI will set up the basic GUI 920 * INIT UI will set up the basic GUI
919 * Layout: Simple VBoxLayout 921 * Layout: Simple VBoxLayout
920 * On top a WidgetStack containing the Views... 922 * On top a WidgetStack containing the Views...
921 * - List View 923 * - List View
922 * - Document View 924 * - Document View
923 * Below we will have a Label + LineEdit 925 * Below we will have a Label + LineEdit
924 * Below we will have two ComoBoxes one for choosing the view one for 926 * Below we will have two ComoBoxes one for choosing the view one for
925 * choosing the mimetype 927 * choosing the mimetype
926 */ 928 */
927void OFileSelector::initUI() 929void OFileSelector::initUI()
928{ 930{
929 QVBoxLayout* lay = new QVBoxLayout( this ); 931 QVBoxLayout* lay = new QVBoxLayout( this );
930 932
931 m_stack = new QWidgetStack( this ); 933 m_stack = new QWidgetStack( this );
932 lay->addWidget( m_stack, 1000 ); 934 lay->addWidget( m_stack, 1000 );
933 935
934 m_nameBox = new QHBox( this ); 936 m_nameBox = new QHBox( this );
935 (void)new QLabel( tr("Name:"), m_nameBox ); 937 (void)new QLabel( tr("Name:"), m_nameBox );
936 m_lneEdit = new QLineEdit( m_nameBox ); 938 m_lneEdit = new QLineEdit( m_nameBox );
937 m_lneEdit ->installEventFilter(this); 939 m_lneEdit ->installEventFilter(this);
938 lay->addWidget( m_nameBox ); 940 lay->addWidget( m_nameBox );
939 941
940 m_cmbBox = new QHBox( this ); 942 m_cmbBox = new QHBox( this );
941 m_cmbView = new QComboBox( m_cmbBox ); 943 m_cmbView = new QComboBox( m_cmbBox );
942 m_cmbMime = new QComboBox( m_cmbBox ); 944 m_cmbMime = new QComboBox( m_cmbBox );
943 lay->addWidget( m_cmbBox ); 945 lay->addWidget( m_cmbBox );
944} 946}
945 947
946/* 948/*
947 * This will make sure that the return key in the name edit causes dialogs to close 949 * This will make sure that the return key in the name edit causes dialogs to close
948 */ 950 */
949 951
950bool OFileSelector::eventFilter (QObject *o, QEvent *e) 952bool OFileSelector::eventFilter (QObject *, QEvent *e)
951{ 953{
952 if ( e->type() == QEvent::KeyPress ) 954 if ( e->type() == QEvent::KeyPress )
953 { 955 {
954 QKeyEvent *k = (QKeyEvent *)e; 956 QKeyEvent *k = (QKeyEvent *)e;
955 if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) 957 if ( (k->key()==Key_Enter) || (k->key()==Key_Return))
956 { 958 {
957 emit ok(); 959 emit ok();
958 return true; 960 return true;
959 } 961 }
960 } 962 }
961 return false; 963 return false;
962} 964}
963 965
964/* 966/*
965 * This will insert the MimeTypes into the Combo Box 967 * This will insert the MimeTypes into the Combo Box
966 * And also connect the changed signal 968 * And also connect the changed signal
967 * 969 *
968 * AutoMimeTyping is disabled for now. It used to reparse a dir and then set available mimetypes 970 * AutoMimeTyping is disabled for now. It used to reparse a dir and then set available mimetypes
969 */ 971 */
970void OFileSelector::initMime() 972void OFileSelector::initMime()
971{ 973{
972 MimeTypes::Iterator it; 974 MimeTypes::Iterator it;
973 for ( it = m_mimeType.begin(); it != m_mimeType.end(); ++it ) 975 for ( it = m_mimeType.begin(); it != m_mimeType.end(); ++it )
974 { 976 {
975 m_cmbMime->insertItem( it.key() ); 977 m_cmbMime->insertItem( it.key() );
976 } 978 }
977 m_cmbMime->setCurrentItem( 0 ); 979 m_cmbMime->setCurrentItem( 0 );
978 980
979 connect( m_cmbMime, SIGNAL(activated(int) ), 981 connect( m_cmbMime, SIGNAL(activated(int) ),
980 this, SLOT(slotMimeTypeChanged() ) ); 982 this, SLOT(slotMimeTypeChanged() ) );
981 983
982} 984}
983 985
984void OFileSelector::initViews() 986void OFileSelector::initViews()
985{ 987{
986 m_cmbView->insertItem( QObject::tr("Documents") ); 988 m_cmbView->insertItem( QObject::tr("Documents") );
987 m_cmbView->insertItem( QObject::tr("Files") ); 989 m_cmbView->insertItem( QObject::tr("Files") );
988 m_cmbView->insertItem( QObject::tr("All Files") ); 990 m_cmbView->insertItem( QObject::tr("All Files") );
989 connect(m_cmbView, SIGNAL(activated(const QString&) ), 991 connect(m_cmbView, SIGNAL(activated(const QString&) ),
990 this, SLOT(slotViewChange(const QString&) ) ); 992 this, SLOT(slotViewChange(const QString&) ) );
991 993
992 994
993 m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) ); 995 m_views.insert( QObject::tr("Documents"), new ODocumentFileView(this) );
994 996
995 /* see above why add both */ 997 /* see above why add both */
996 OFileViewInterface* in = new OFileViewFileSystem( this ); 998 OFileViewInterface* in = new OFileViewFileSystem( this );
997 m_views.insert( QObject::tr("Files"), in ); 999 m_views.insert( QObject::tr("Files"), in );
998 m_views.insert( QObject::tr("All Files"), in ); 1000 m_views.insert( QObject::tr("All Files"), in );
999} 1001}
1000 1002
1003void OFileSelector::registerView( const Internal::OFileViewInterface* iface ) {
1004 m_viewsPtr.append( iface );
1005}
1006
1007
1001/** 1008/**
1002 * d'tor 1009 * d'tor
1003 */ 1010 */
1004OFileSelector::~OFileSelector() 1011OFileSelector::~OFileSelector()
1005{ 1012{
1013 m_viewsPtr.setAutoDelete( true );
1014 m_viewsPtr.clear();
1006} 1015}
1007 1016
1008 1017
1009 1018
1010/** 1019/**
1011 * Convience function for the fileselector 1020 * Convience function for the fileselector
1012 * make sure to delete the DocLnk 1021 * make sure to delete the DocLnk
1013 * 1022 *
1014 * @see DocLnk 1023 * @see DocLnk
1015 * @todo remove in ODP 1024 * @todo remove in ODP
1016 */ 1025 */
1017const DocLnk* OFileSelector::selected() 1026const DocLnk* OFileSelector::selected()
1018{ 1027{
1019 DocLnk* lnk = new DocLnk( currentView()->selectedDocument() ); 1028 DocLnk* lnk = new DocLnk( currentView()->selectedDocument() );
1020 return lnk; 1029 return lnk;
1021} 1030}
1022 1031
1023/** 1032/**
1024 * 1033 *
1025 * @return the name of the selected file 1034 * @return the name of the selected file
1026 */ 1035 */
1027QString OFileSelector::selectedName()const 1036QString OFileSelector::selectedName()const
1028{ 1037{
1029 return currentView()->selectedName(); 1038 return currentView()->selectedName();
1030} 1039}
1031 1040
1032 1041
1033/** 1042/**
1034 * @return the selected path 1043 * @return the selected path
1035 */ 1044 */
1036QString OFileSelector::selectedPath()const 1045QString OFileSelector::selectedPath()const
1037{ 1046{
1038 return currentView()->selectedPath(); 1047 return currentView()->selectedPath();
1039} 1048}
1040 1049
1041/** 1050/**
1042 * @return the directory name 1051 * @return the directory name
1043 */ 1052 */
1044QString OFileSelector::directory()const 1053QString OFileSelector::directory()const
1045{ 1054{
1046 return currentView()->directory(); 1055 return currentView()->directory();
1047} 1056}
1048 1057
1049/** 1058/**
1050 * @return a DocLnk for the selected document 1059 * @return a DocLnk for the selected document
1051 */ 1060 */
1052DocLnk OFileSelector::selectedDocument()const 1061DocLnk OFileSelector::selectedDocument()const
1053{ 1062{
diff --git a/libopie2/opieui/fileselector/ofileselector.h b/libopie2/opieui/fileselector/ofileselector.h
index 8bcd9ee..de2b98a 100644
--- a/libopie2/opieui/fileselector/ofileselector.h
+++ b/libopie2/opieui/fileselector/ofileselector.h
@@ -1,94 +1,95 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (C) 2002,2003 Holger Freyther <zecke@handhelds.org> 3             .=l. Copyright (C) 2002,2003 Holger Freyther <zecke@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29/* 29/*
30 This is based on code and ideas of 30 This is based on code and ideas of
31 L. J. Potter ljp@llornkcor.com 31 L. J. Potter ljp@llornkcor.com
32 Thanks a lot 32 Thanks a lot
33*/ 33*/
34 34
35#ifndef OFILESELECTOR_H 35#ifndef OFILESELECTOR_H
36#define OFILESELECTOR_H 36#define OFILESELECTOR_H
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/applnk.h> 39#include <qpe/applnk.h>
40 40
41/* QT */ 41/* QT */
42#include <qlist.h> 42#include <qlist.h>
43#include <qwidget.h> 43#include <qwidget.h>
44#include <qmap.h> 44#include <qmap.h>
45#include <qvaluelist.h> 45#include <qvaluelist.h>
46#include <qstringlist.h> 46#include <qstringlist.h>
47#include <qlist.h>
47 48
48class QLineEdit; 49class QLineEdit;
49class QComboBox; 50class QComboBox;
50class QWidgetStack; 51class QWidgetStack;
51class QHBox; 52class QHBox;
52 53
53typedef QMap<QString, QStringList> MimeTypes; 54typedef QMap<QString, QStringList> MimeTypes;
54 55
55namespace Opie { 56namespace Opie {
56namespace Ui { 57namespace Ui {
57 58
58namespace Internal { 59namespace Internal {
59class OFileViewInterface; 60class OFileViewInterface;
60class OFileViewFileListView; 61class OFileViewFileListView;
61} 62}
62 63
63 64
64/** 65/**
65 * @short a dropin replacement for the FileSelector 66 * @short a dropin replacement for the FileSelector
66 * 67 *
67 * This class is first used insert the OFileDialog. 68 * This class is first used insert the OFileDialog.
68 * It supports multiple view and mimetype filtering for now. 69 * It supports multiple view and mimetype filtering for now.
69 * 70 *
70 * @see OFileDialog 71 * @see OFileDialog
71 * @see FileSelector 72 * @see FileSelector
72 * @author zecke 73 * @author zecke
73 * @version 0.1 74 * @version 0.1
74 */ 75 */
75class OFileSelector : public QWidget 76class OFileSelector : public QWidget
76{ 77{
77 Q_OBJECT 78 Q_OBJECT
78 friend class Internal::OFileViewInterface; 79 friend class Internal::OFileViewInterface;
79 friend class Internal::OFileViewFileListView; 80 friend class Internal::OFileViewFileListView;
80 81
81public: 82public:
82 /** 83 /**
83 * The Mode of the Fileselector 84 * The Mode of the Fileselector
84 * Open = Open A File 85 * Open = Open A File
85 * Save = Save a File 86 * Save = Save a File
86 * FILESELECTOR = As A GUI in a screen to select a file 87 * FILESELECTOR = As A GUI in a screen to select a file
87 */ 88 */
88 enum Mode { Open=1, Save=2, FileSelector=4, OPEN=1, SAVE=2, FILESELECTOR=4 }; 89 enum Mode { Open=1, Save=2, FileSelector=4, OPEN=1, SAVE=2, FILESELECTOR=4 };
89 // enum OldMode { OPEN=1, SAVE=2, FILESELECTOR = 4 }; 90 // enum OldMode { OPEN=1, SAVE=2, FILESELECTOR = 4 };
90 /** 91 /**
91 * Normal = The old FileSelector 92 * Normal = The old FileSelector
92 * Extended = Dir View 93 * Extended = Dir View
93 * ExtendedAll = Dir View with all hidden files 94 * ExtendedAll = Dir View with all hidden files
94 * Default = What the vendor considers best 95 * Default = What the vendor considers best
@@ -138,85 +139,94 @@ public:
138 139
139signals: 140signals:
140 /** 141 /**
141 * dirSelected is emitted whenever changed into a different dir 142 * dirSelected is emitted whenever changed into a different dir
142 */ 143 */
143 void dirSelected( const QString& ); 144 void dirSelected( const QString& );
144 145
145 /** 146 /**
146 * fileSelected is emitted when a file is selected 147 * fileSelected is emitted when a file is selected
147 * it uses a DocLnk as parameter 148 * it uses a DocLnk as parameter
148 */ 149 */
149 void fileSelected( const DocLnk& ); 150 void fileSelected( const DocLnk& );
150 151
151 /** 152 /**
152 * fileSelected is emitted when a file is selected 153 * fileSelected is emitted when a file is selected
153 * the complete path is a parameter 154 * the complete path is a parameter
154 */ 155 */
155 void fileSelected( const QString& ); 156 void fileSelected( const QString& );
156 157
157 /** 158 /**
158 * Create a new File with a DocLnk 159 * Create a new File with a DocLnk
159 */ 160 */
160 void newSelected( const DocLnk& ); 161 void newSelected( const DocLnk& );
161 162
162 void closeMe(); 163 void closeMe();
163 164
164 /** 165 /**
165 * Ok is emitted on a Qt::Key_Return or Q::Key_Enter 166 * Ok is emitted on a Qt::Key_Return or Q::Key_Enter
166 * in the line edit 167 * in the line edit
167 */ 168 */
168 void ok(); 169 void ok();
169 void cancel(); 170 void cancel();
170 171
171 /* used by the ViewInterface */ 172 /* used by the ViewInterface */
172private: 173private:
173 bool showNew()const; 174 bool showNew()const;
174 bool showClose()const; 175 bool showClose()const;
175 MimeTypes mimeTypes()const; 176 MimeTypes mimeTypes()const;
176 QStringList currentMimeType()const; 177 QStringList currentMimeType()const;
177 178
178private: 179private:
179 /* inits the Widgets */ 180 /* inits the Widgets */
180 void initUI(); 181 void initUI();
181 /* inits the MimeType ComboBox content + connects signals and slots */ 182 /* inits the MimeType ComboBox content + connects signals and slots */
182 void initMime(); 183 void initMime();
183 /* init the Views :) */ 184 /* init the Views :) */
184 void initViews(); 185 void initViews();
185 186
187
188 /*
189 * register a view for deletion.
190 * This happens on creation of a OFileViewInterface
191 */
192 void registerView( const Internal::OFileViewInterface* );
193
186private: 194private:
187 QLineEdit* m_lneEdit; // the LineEdit for the Name 195 QLineEdit* m_lneEdit; // the LineEdit for the Name
188 QComboBox *m_cmbView, *m_cmbMime; // two ComboBoxes to select the View and MimeType 196 QComboBox *m_cmbView, *m_cmbMime; // two ComboBoxes to select the View and MimeType
189 QWidgetStack* m_stack; // our widget stack which will contain the views 197 QWidgetStack* m_stack; // our widget stack which will contain the views
190 Internal::OFileViewInterface* currentView() const; // returns the currentView 198 Internal::OFileViewInterface* currentView() const; // returns the currentView
191 Internal::OFileViewInterface* m_current; // here is the view saved 199 Internal::OFileViewInterface* m_current; // here is the view saved
192 bool m_shNew : 1; // should we show New? 200 bool m_shNew : 1; // should we show New?
193 bool m_shClose : 1; // should we show Close? 201 bool m_shClose : 1; // should we show Close?
194 MimeTypes m_mimeType; // list of mimetypes 202 MimeTypes m_mimeType; // list of mimetypes
195 203
196 QMap<QString, Internal::OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr 204 QMap<QString, Internal::OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr
205 /* views register themselves automatically */
206 QList<Internal::OFileViewInterface> m_viewsPtr;
197 QHBox* m_nameBox; // the LineEdit + Label is hold here 207 QHBox* m_nameBox; // the LineEdit + Label is hold here
198 QHBox* m_cmbBox; // this holds the two combo boxes 208 QHBox* m_cmbBox; // this holds the two combo boxes
199 209
200 QString m_startDir; 210 QString m_startDir;
201 int m_mode; 211 int m_mode;
202 int m_selector; 212 int m_selector;
203 213
204 struct Data; // used for future versions 214 struct Data; // used for future versions
205 Data *d; 215 Data *d;
206 216
207private slots: 217private slots:
208 void slotMimeTypeChanged(); 218 void slotMimeTypeChanged();
209 219
210 /* will set the text of the lineedit and emit a fileChanged signal */ 220 /* will set the text of the lineedit and emit a fileChanged signal */
211 void slotDocLnkBridge( const DocLnk& ); 221 void slotDocLnkBridge( const DocLnk& );
212 void slotFileBridge( const QString& ); 222 void slotFileBridge( const QString& );
213 void slotViewChange( const QString& ); 223 void slotViewChange( const QString& );
214 224
215 bool eventFilter (QObject *o, QEvent *e); 225 bool eventFilter (QObject *o, QEvent *e);
216 226
217}; 227};
218 228
219} 229}
220} 230}
221 231
222#endif 232#endif