author | zecke <zecke> | 2002-09-15 21:22:18 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-09-15 21:22:18 (UTC) |
commit | 568c816cc66f1566b8be6ff8d246e7b1465ae61e (patch) (unidiff) | |
tree | 3c1d1f9ac7421ae27b18f580670ac1e1b8bf8a92 /libopie | |
parent | f2594358208bb2ea826bbea6afb0b3aa35947378 (diff) | |
download | opie-568c816cc66f1566b8be6ff8d246e7b1465ae61e.zip opie-568c816cc66f1566b8be6ff8d246e7b1465ae61e.tar.gz opie-568c816cc66f1566b8be6ff8d246e7b1465ae61e.tar.bz2 |
ok basicly all old functions are available again
what's now missing is the code switching Listers
and views
toggling the toolbar
filter
-rw-r--r-- | libopie/ofileselector/ofilelistview.cpp | 85 | ||||
-rw-r--r-- | libopie/ofileselector/ofilelistview.h | 7 | ||||
-rw-r--r-- | libopie/ofileselector/ofileselector.cpp | 283 | ||||
-rw-r--r-- | libopie/ofileselector/ofileselector.h | 39 | ||||
-rw-r--r-- | libopie/ofileselector/ofileview.cpp | 7 | ||||
-rw-r--r-- | libopie/ofileselector/ofileview.h | 2 |
6 files changed, 153 insertions, 270 deletions
diff --git a/libopie/ofileselector/ofilelistview.cpp b/libopie/ofileselector/ofilelistview.cpp index 7108a5b..bb15764 100644 --- a/libopie/ofileselector/ofilelistview.cpp +++ b/libopie/ofileselector/ofilelistview.cpp | |||
@@ -1,6 +1,9 @@ | |||
1 | 1 | ||
2 | #include <qheader.h> | ||
3 | |||
2 | #include <qpe/mimetype.h> | 4 | #include <qpe/mimetype.h> |
3 | #include <qpe/resource.h> | 5 | #include <qpe/resource.h> |
6 | #include <qpe/qpeapplication.h> | ||
4 | 7 | ||
5 | #include "ofileselector.h" | 8 | #include "ofileselector.h" |
6 | #include "ofileselectoritem.h" | 9 | #include "ofileselectoritem.h" |
@@ -10,7 +13,29 @@ | |||
10 | OFileListView::OFileListView( QWidget* parent, OFileSelector* sel) | 13 | OFileListView::OFileListView( QWidget* parent, OFileSelector* sel) |
11 | : QListView( parent ), OFileView( sel ) | 14 | : QListView( parent ), OFileView( sel ) |
12 | { | 15 | { |
13 | 16 | QPEApplication::setStylusOperation( viewport(), | |
17 | QPEApplication::RightOnHold); | ||
18 | addColumn(" " ); | ||
19 | addColumn(tr("Name"), 135 ); | ||
20 | addColumn(tr("Size"), -1 ); | ||
21 | addColumn(tr("Date"), 60 ); | ||
22 | addColumn(tr("Mime Type"), -1 ); | ||
23 | QHeader *head = header(); | ||
24 | head->hide(); | ||
25 | setSorting( 1 ); | ||
26 | setAllColumnsShowFocus( TRUE ); | ||
27 | |||
28 | connect(this, SIGNAL(selectionChanged() ), | ||
29 | this, SLOT(slotSelectionChanged() ) ); | ||
30 | |||
31 | connect(this, SIGNAL(currentChanged(QListViewItem *) ), | ||
32 | this, SLOT(slotCurrentChanged(QListViewItem * ) ) ); | ||
33 | |||
34 | connect(this, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ), | ||
35 | this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) ); | ||
36 | |||
37 | connect(this, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )), | ||
38 | this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) ); | ||
14 | } | 39 | } |
15 | OFileListView::~OFileListView() { | 40 | OFileListView::~OFileListView() { |
16 | 41 | ||
@@ -123,3 +148,61 @@ QStringList OFileListView::selectedPaths()const { | |||
123 | int OFileListView::fileCount() { | 148 | int OFileListView::fileCount() { |
124 | return childCount(); | 149 | return childCount(); |
125 | } | 150 | } |
151 | void OFileListView::sort() { | ||
152 | QListView::sort(); | ||
153 | } | ||
154 | void OFileListView::slotSelectionChanged() { | ||
155 | |||
156 | } | ||
157 | void OFileListView::slotCurrentChanged( QListViewItem* item) { | ||
158 | if (!item ) | ||
159 | return; | ||
160 | |||
161 | OFileSelectorItem* sel = (OFileSelectorItem*) item; | ||
162 | |||
163 | qWarning("current changed"); | ||
164 | if(!sel->isDir() ){ | ||
165 | updateLine( sel->text(1) ); | ||
166 | |||
167 | if (selector()->mode() == OFileSelector::Fileselector ) { | ||
168 | QStringList str = QStringList::split("->", sel->text(1) ); | ||
169 | QString path =sel->directory() + "/" + str[0].stripWhiteSpace(); | ||
170 | DocLnk lnk( path ); | ||
171 | fileSelected(lnk ); | ||
172 | fileSelected( path ); | ||
173 | } | ||
174 | } | ||
175 | } | ||
176 | void OFileListView::slotClicked( int button, QListViewItem* item, | ||
177 | const QPoint&, int ) { | ||
178 | if ( !item ) | ||
179 | return; | ||
180 | |||
181 | if( button != Qt::LeftButton ) | ||
182 | return; | ||
183 | |||
184 | OFileSelectorItem *sel = (OFileSelectorItem*)item; | ||
185 | |||
186 | if(!sel->isLocked() ){ | ||
187 | QStringList str = QStringList::split("->", sel->text(1) ); | ||
188 | if( sel->isDir() ){ | ||
189 | changedDir( sel->directory() + "/" + str[0].stripWhiteSpace() ); | ||
190 | }else{ | ||
191 | updateLine( str[0].stripWhiteSpace() ); | ||
192 | QString path = sel->directory(); | ||
193 | path += "/"; | ||
194 | path += str[0].stripWhiteSpace(); | ||
195 | |||
196 | DocLnk lnk( path ); | ||
197 | fileSelected( path ); | ||
198 | fileSelected( lnk ); | ||
199 | } | ||
200 | } | ||
201 | } | ||
202 | void OFileListView::slotRightButton( int button, QListViewItem* item, | ||
203 | const QPoint&, int ) { | ||
204 | if (!item || (button != Qt::RightButton )) | ||
205 | return; | ||
206 | |||
207 | /* raise contextmenu */ | ||
208 | } | ||
diff --git a/libopie/ofileselector/ofilelistview.h b/libopie/ofileselector/ofilelistview.h index c7e9223..a83d70d 100644 --- a/libopie/ofileselector/ofilelistview.h +++ b/libopie/ofileselector/ofilelistview.h | |||
@@ -32,6 +32,7 @@ public: | |||
32 | const QString& file, bool isSymlink = FALSE ); | 32 | const QString& file, bool isSymlink = FALSE ); |
33 | void cd( const QString& path ); | 33 | void cd( const QString& path ); |
34 | QWidget* widget(); | 34 | QWidget* widget(); |
35 | void sort(); | ||
35 | 36 | ||
36 | QString selectedName()const ; | 37 | QString selectedName()const ; |
37 | QStringList selectedNames()const; | 38 | QStringList selectedNames()const; |
@@ -39,7 +40,11 @@ public: | |||
39 | QString selectedPath()const; | 40 | QString selectedPath()const; |
40 | QStringList selectedPaths()const; | 41 | QStringList selectedPaths()const; |
41 | int fileCount(); | 42 | int fileCount(); |
42 | 43 | private slots: | |
44 | void slotSelectionChanged(); | ||
45 | void slotCurrentChanged(QListViewItem* ); | ||
46 | void slotClicked( int, QListViewItem*, const QPoint&, int ); | ||
47 | void slotRightButton(int, QListViewItem*, const QPoint&, int ); | ||
43 | }; | 48 | }; |
44 | 49 | ||
45 | #endif | 50 | #endif |
diff --git a/libopie/ofileselector/ofileselector.cpp b/libopie/ofileselector/ofileselector.cpp index 16ee3ee..98b61f7 100644 --- a/libopie/ofileselector/ofileselector.cpp +++ b/libopie/ofileselector/ofileselector.cpp | |||
@@ -31,22 +31,23 @@ | |||
31 | 31 | ||
32 | #include "ofileview.h" | 32 | #include "ofileview.h" |
33 | #include "ofileselector.h" | 33 | #include "ofileselector.h" |
34 | 34 | #include "olister.h" | |
35 | 35 | ||
36 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; | 36 | QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; |
37 | 37 | ||
38 | namespace { | 38 | namespace { |
39 | int indexByString( const QComboBox *box, const QString &str ){ | 39 | /* let's find the index for a specified string */ |
40 | int index= 0; | 40 | int indexByString( const QComboBox *box, const QString &str ){ |
41 | for(int i= 0; i < box->count(); i++ ){ | 41 | int index= 0; |
42 | if( str == box->text(i ) ){ | 42 | for(int i= 0; i < box->count(); i++ ){ |
43 | index= i; | 43 | /* found */ |
44 | break; | 44 | if( str == box->text(i ) ){ |
45 | } | 45 | index= i; |
46 | break; | ||
47 | } | ||
48 | } | ||
49 | return index; | ||
46 | } | 50 | } |
47 | return index; | ||
48 | } | ||
49 | |||
50 | } | 51 | } |
51 | 52 | ||
52 | OFileSelector::OFileSelector( QWidget *wid, int mode, int selector, | 53 | OFileSelector::OFileSelector( QWidget *wid, int mode, int selector, |
@@ -58,12 +59,13 @@ OFileSelector::OFileSelector( QWidget *wid, int mode, int selector, | |||
58 | m_mimetypes = mimeTypes; | 59 | m_mimetypes = mimeTypes; |
59 | if (mode == Save ) | 60 | if (mode == Save ) |
60 | m_name = fileName; | 61 | m_name = fileName; |
62 | |||
61 | initVars(); | 63 | initVars(); |
64 | |||
62 | m_mode = mode; | 65 | m_mode = mode; |
63 | m_selector = selector; | 66 | m_selector = selector; |
64 | m_currentDir = dirName; | 67 | m_currentDir = dirName; |
65 | init(); | 68 | init(); |
66 | //QTimer::singleShot(6*1000, this, SLOT( slotTest() ) ); | ||
67 | } | 69 | } |
68 | 70 | ||
69 | OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent, | 71 | OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent, |
@@ -71,6 +73,7 @@ OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent, | |||
71 | bool closeVisible ) | 73 | bool closeVisible ) |
72 | : QWidget( parent, name ) | 74 | : QWidget( parent, name ) |
73 | { | 75 | { |
76 | /* update the mimefilter */ | ||
74 | if (!mimeFilter.isEmpty() ) { | 77 | if (!mimeFilter.isEmpty() ) { |
75 | QStringList list = QStringList::split(";", mimeFilter ); | 78 | QStringList list = QStringList::split(";", mimeFilter ); |
76 | m_mimetypes.insert(mimeFilter, list ); | 79 | m_mimetypes.insert(mimeFilter, list ); |
@@ -154,6 +157,7 @@ void OFileSelector::setToolbarVisible( bool show ) | |||
154 | { | 157 | { |
155 | m_shTool = show; | 158 | m_shTool = show; |
156 | initializeListView(); // FIXME see above waste of memory | 159 | initializeListView(); // FIXME see above waste of memory |
160 | |||
157 | if(!m_shTool ){ | 161 | if(!m_shTool ){ |
158 | m_location->hide(); | 162 | m_location->hide(); |
159 | m_up->hide(); | 163 | m_up->hide(); |
@@ -632,26 +636,6 @@ void OFileSelector::initVars() | |||
632 | m_new = 0; | 636 | m_new = 0; |
633 | m_close = 0; | 637 | m_close = 0; |
634 | } | 638 | } |
635 | void OFileSelector::addFile(const QString &, QFileInfo *info, bool ) | ||
636 | { | ||
637 | if(!m_files) | ||
638 | return; | ||
639 | // if( !compliesMime(info->absFilePath(), mime ) ) | ||
640 | // return; | ||
641 | MimeType type( info->absFilePath() ); | ||
642 | if (!compliesMime( type.id() ) ) | ||
643 | return; | ||
644 | |||
645 | } | ||
646 | void OFileSelector::addDir(const QString &, QFileInfo *, bool ) | ||
647 | { | ||
648 | if(!m_dir) | ||
649 | return; | ||
650 | } | ||
651 | void OFileSelector::delItems() | ||
652 | { | ||
653 | |||
654 | } | ||
655 | void OFileSelector::initializeName() | 639 | void OFileSelector::initializeName() |
656 | { | 640 | { |
657 | /** Name Layout Line | 641 | /** Name Layout Line |
@@ -729,6 +713,7 @@ void OFileSelector::initializeChooser() | |||
729 | m_viewCheck->insertItem( tr("Documents") ); | 713 | m_viewCheck->insertItem( tr("Documents") ); |
730 | m_viewCheck->insertItem( tr("Files") ); | 714 | m_viewCheck->insertItem( tr("Files") ); |
731 | m_viewCheck->insertItem( tr("All Files") ); | 715 | m_viewCheck->insertItem( tr("All Files") ); |
716 | /* update to custom views */ | ||
732 | updateMimeCheck(); | 717 | updateMimeCheck(); |
733 | 718 | ||
734 | connect( m_viewCheck, SIGNAL( activated(const QString & ) ), | 719 | connect( m_viewCheck, SIGNAL( activated(const QString & ) ), |
@@ -814,32 +799,8 @@ void OFileSelector::initializeListView() | |||
814 | } // off toolbar | 799 | } // off toolbar |
815 | // the Main ListView | 800 | // the Main ListView |
816 | // make a QWidgetStack first so Views can share the Toolbar | 801 | // make a QWidgetStack first so Views can share the Toolbar |
817 | m_View = new QListView( m_pseudo, "Extended view"); | 802 | |
818 | QPEApplication::setStylusOperation( m_View->viewport(), | 803 | // m_pseudoLayout->addWidget( m_View, 288 ); |
819 | QPEApplication::RightOnHold); | ||
820 | m_View->addColumn(" " ); | ||
821 | m_View->addColumn(tr("Name"), 135 ); | ||
822 | m_View->addColumn(tr("Size"), -1 ); | ||
823 | m_View->addColumn(tr("Date"), 60 ); | ||
824 | m_View->addColumn(tr("Mime Type"), -1 ); | ||
825 | QHeader *header = m_View->header(); | ||
826 | header->hide(); | ||
827 | m_View->setSorting( 1 ); | ||
828 | m_View->setAllColumnsShowFocus( TRUE ); | ||
829 | |||
830 | connect(m_View, SIGNAL(selectionChanged() ), | ||
831 | this, SLOT(slotSelectionChanged() ) ); | ||
832 | |||
833 | connect(m_View, SIGNAL(currentChanged(QListViewItem *) ), | ||
834 | this, SLOT(slotCurrentChanged(QListViewItem * ) ) ); | ||
835 | |||
836 | connect(m_View, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int) ), | ||
837 | this, SLOT(slotClicked( int, QListViewItem *, const QPoint &, int) ) ); | ||
838 | |||
839 | connect(m_View, SIGNAL(mouseButtonPressed(int, QListViewItem *, const QPoint &, int )), | ||
840 | this, SLOT(slotRightButton(int, QListViewItem *, const QPoint &, int ) ) ); | ||
841 | |||
842 | m_pseudoLayout->addWidget( m_View, 288 ); | ||
843 | m_stack->addWidget( m_pseudo, Extended ); | 804 | m_stack->addWidget( m_pseudo, Extended ); |
844 | } | 805 | } |
845 | } | 806 | } |
@@ -849,7 +810,6 @@ void OFileSelector::initializePerm() | |||
849 | m_checkPerm = new QCheckBox(tr("Set Permission"), this, "perm"); | 810 | m_checkPerm = new QCheckBox(tr("Set Permission"), this, "perm"); |
850 | m_checkPerm->setChecked( false ); | 811 | m_checkPerm->setChecked( false ); |
851 | m_lay->addWidget( m_checkPerm ); | 812 | m_lay->addWidget( m_checkPerm ); |
852 | |||
853 | } | 813 | } |
854 | } | 814 | } |
855 | void OFileSelector::initPics() | 815 | void OFileSelector::initPics() |
@@ -857,6 +817,7 @@ void OFileSelector::initPics() | |||
857 | m_pixmaps = new QMap<QString,QPixmap>; | 817 | m_pixmaps = new QMap<QString,QPixmap>; |
858 | QPixmap pm = Resource::loadPixmap( "folder" ); | 818 | QPixmap pm = Resource::loadPixmap( "folder" ); |
859 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 819 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
820 | |||
860 | QPainter painter( &pm ); | 821 | QPainter painter( &pm ); |
861 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 822 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
862 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | 823 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
@@ -916,10 +877,6 @@ bool OFileSelector::compliesMime( const QString& mime ) { | |||
916 | if ( it == m_mimetypes.end() ) qWarning("not there"), list << currentText; | 877 | if ( it == m_mimetypes.end() ) qWarning("not there"), list << currentText; |
917 | else qWarning("found"), list = it.data(); | 878 | else qWarning("found"), list = it.data(); |
918 | } | 879 | } |
919 | // dump it now | ||
920 | //for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { | ||
921 | // qWarning( "%s", (*it).latin1() ); | ||
922 | //} | ||
923 | 880 | ||
924 | 881 | ||
925 | if ( list.contains(mime) ) return true; | 882 | if ( list.contains(mime) ) return true; |
@@ -945,111 +902,8 @@ void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) | |||
945 | slotFileSelected( lnk.name() ); | 902 | slotFileSelected( lnk.name() ); |
946 | // emit fileSelected( lnk ); | 903 | // emit fileSelected( lnk ); |
947 | } | 904 | } |
948 | void OFileSelector::slotSelectionChanged() | ||
949 | { | ||
950 | |||
951 | } | ||
952 | void OFileSelector::slotCurrentChanged(QListViewItem* /*item*/ ) | ||
953 | { | ||
954 | /* | ||
955 | if( item == 0 ) | ||
956 | return; | ||
957 | if( m_selector == Extended || m_selector == ExtendedAll ) { | ||
958 | OFileSelectorItem *sel = (OFileSelectorItem*) item; // start to use the C++ casts ;) | ||
959 | qWarning("current changed"); | ||
960 | if(!sel->isDir() ){ | ||
961 | if( m_shLne ) | ||
962 | m_edit->setText( sel->text(1) ); | ||
963 | |||
964 | if (m_mode == Fileselector ) { | ||
965 | QStringList str = QStringList::split("->", sel->text(1) ); | ||
966 | QString path =sel->directory() + "/" + str[0].stripWhiteSpace(); | ||
967 | emit fileSelected(path ); | ||
968 | DocLnk lnk( path ); | ||
969 | emit fileSelected(lnk ); | ||
970 | } | ||
971 | } | ||
972 | } */ | ||
973 | } | ||
974 | void OFileSelector::slotClicked( int /*button*/, QListViewItem */*item*/, const QPoint &, int) | ||
975 | |||
976 | { | ||
977 | /* | ||
978 | if ( item == 0 ) | ||
979 | return; | ||
980 | |||
981 | if( button != Qt::LeftButton ) | ||
982 | return; | ||
983 | |||
984 | switch( m_selector ){ | ||
985 | default: | ||
986 | break; | ||
987 | case Extended: // fall through | ||
988 | case ExtendedAll:{ | ||
989 | OFileSelectorItem *sel = (OFileSelectorItem*)item; | ||
990 | if(!sel->isLocked() ){ | ||
991 | QStringList str = QStringList::split("->", sel->text(1) ); | ||
992 | if( sel->isDir() ){ | ||
993 | cd( sel->directory() + "/" + str[0].stripWhiteSpace() ); | ||
994 | // if MODE Dir m_shLne set the Text | ||
995 | }else{ | ||
996 | if( m_shLne ) | ||
997 | m_edit->setText( str[0].stripWhiteSpace() ); | ||
998 | qWarning("selected here in slot clicked"); | ||
999 | emit fileSelected( sel->directory() + "/" + str[0].stripWhiteSpace() ); | ||
1000 | DocLnk lnk( sel->directory() + "/" + str[0].stripWhiteSpace() ); | ||
1001 | qWarning("file selected"); | ||
1002 | emit fileSelected( lnk ); | ||
1003 | } | ||
1004 | } | ||
1005 | break; | ||
1006 | } | ||
1007 | } */ | ||
1008 | } | ||
1009 | void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int ) | ||
1010 | { | ||
1011 | if( item == 0 ) | ||
1012 | return; | ||
1013 | 905 | ||
1014 | if( button != Qt::RightButton ) | ||
1015 | return; | ||
1016 | slotContextMenu( item ); | ||
1017 | } | ||
1018 | void OFileSelector::slotContextMenu( QListViewItem */*item*/) | ||
1019 | { | ||
1020 | |||
1021 | } | ||
1022 | void OFileSelector::slotChangedDir() | ||
1023 | { | ||
1024 | /* | ||
1025 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); | ||
1026 | if(sel->isDir() ){ | ||
1027 | QStringList str = QStringList::split("->", sel->text(1) ); | ||
1028 | cd( sel->directory() + "/" + str[0].stripWhiteSpace() ); | ||
1029 | } | ||
1030 | */ | ||
1031 | } | ||
1032 | void OFileSelector::slotOpen() | ||
1033 | { | ||
1034 | /* | ||
1035 | OFileSelectorItem *sel = (OFileSelectorItem*)m_View->currentItem(); | ||
1036 | if(!sel->isDir() ){ | ||
1037 | QStringList str = QStringList::split("->", sel->text(1) ); | ||
1038 | slotFileSelected( sel->directory() +"/" +str[0].stripWhiteSpace() ); | ||
1039 | qWarning("slot open"); | ||
1040 | // DocLnk lnk( sel->directory() + "/" + str[0].stripWhiteSpace() ); | ||
1041 | //emit fileSelected( lnk ); | ||
1042 | } | ||
1043 | */ | ||
1044 | } | ||
1045 | void OFileSelector::slotRescan() | ||
1046 | { | ||
1047 | 906 | ||
1048 | } | ||
1049 | void OFileSelector::slotRename() | ||
1050 | { | ||
1051 | reparse(); | ||
1052 | } | ||
1053 | void OFileSelector::slotDelete() | 907 | void OFileSelector::slotDelete() |
1054 | { | 908 | { |
1055 | /* | 909 | /* |
@@ -1101,14 +955,14 @@ void OFileSelector::reparse() | |||
1101 | { | 955 | { |
1102 | if( m_selector == Normal ) | 956 | if( m_selector == Normal ) |
1103 | return; | 957 | return; |
1104 | if( m_selector == Extended || m_selector == ExtendedAll ) | 958 | |
1105 | m_View->clear(); | 959 | currentView()->clear(); |
1106 | else // custom view | 960 | |
1107 | ; // currentView()->clear(); | ||
1108 | if( m_shChooser) | 961 | if( m_shChooser) |
1109 | qWarning("reparse %s", m_mimeCheck->currentText().latin1() ); | 962 | qWarning("reparse %s", m_mimeCheck->currentText().latin1() ); |
1110 | 963 | ||
1111 | QString currentMimeType; | 964 | QString currentMimeType; |
965 | |||
1112 | // let's update the mimetype | 966 | // let's update the mimetype |
1113 | if( m_autoMime ){ | 967 | if( m_autoMime ){ |
1114 | m_mimetypes.clear(); | 968 | m_mimetypes.clear(); |
@@ -1118,25 +972,8 @@ void OFileSelector::reparse() | |||
1118 | m_mimeCheck->clear(); | 972 | m_mimeCheck->clear(); |
1119 | 973 | ||
1120 | // let's find possible mimetypes | 974 | // let's find possible mimetypes |
1121 | QDir dir( m_currentDir ); | 975 | m_mimetypes = currentLister()->mimeTypes( m_currentDir ); |
1122 | dir.setFilter( QDir::Files | QDir::Readable ); | 976 | |
1123 | dir.setSorting( QDir::Size ); | ||
1124 | const QFileInfoList *list = dir.entryInfoList(); | ||
1125 | QFileInfoListIterator it( *list ); | ||
1126 | QFileInfo *fi; | ||
1127 | while( (fi=it.current() ) ) { | ||
1128 | if( fi->extension() == QString::fromLatin1("desktop") ){ | ||
1129 | ++it; | ||
1130 | continue; | ||
1131 | } | ||
1132 | MimeType type( fi->absFilePath() ); | ||
1133 | if( !m_mimetypes.contains( type.id() ) ){ | ||
1134 | //qWarning("Type %s", type.id().latin1() ); | ||
1135 | m_mimetypes.insert( type.id(), type.id() ); | ||
1136 | } | ||
1137 | |||
1138 | ++it; | ||
1139 | } | ||
1140 | // add them to the chooser | 977 | // add them to the chooser |
1141 | updateMimeCheck(); | 978 | updateMimeCheck(); |
1142 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) ); | 979 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currentMimeType ) ); |
@@ -1145,69 +982,17 @@ void OFileSelector::reparse() | |||
1145 | }else { // no autoMime | 982 | }else { // no autoMime |
1146 | // let the mimetype be set from out side the m_mimeCheck FEATURE | 983 | // let the mimetype be set from out side the m_mimeCheck FEATURE |
1147 | 984 | ||
1148 | if( m_shChooser ){ | 985 | if( m_shChooser ) |
1149 | currentMimeType = m_mimeCheck->currentText(); | 986 | currentMimeType = m_mimeCheck->currentText(); |
1150 | // updateMimeCheck(); | 987 | |
1151 | } | ||
1152 | } | 988 | } |
1153 | // now we got our mimetypes we can add the files | 989 | // now we got our mimetypes we can add the files |
1154 | 990 | ||
1155 | QDir dir( m_currentDir ); | 991 | currentLister()->reparse( m_currentDir ); |
992 | /* we're done with adding let's sort */ | ||
993 | currentView()->sort(); | ||
994 | |||
1156 | 995 | ||
1157 | int sort; | ||
1158 | if ( m_case ) | ||
1159 | sort = (QDir::IgnoreCase | QDir::Name | QDir::DirsFirst | QDir::Reversed); | ||
1160 | else | ||
1161 | sort = (QDir::Name | QDir::DirsFirst | QDir::Reversed); | ||
1162 | dir.setSorting( sort ); | ||
1163 | |||
1164 | int filter; | ||
1165 | if( m_selector == ExtendedAll /*|| m_selector ==CUSTOM_ALL */ ){ | ||
1166 | filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; | ||
1167 | }else | ||
1168 | filter = QDir::Files | QDir::Dirs | QDir::All; | ||
1169 | dir.setFilter( filter ); | ||
1170 | |||
1171 | // now go through all files | ||
1172 | const QFileInfoList *list = dir.entryInfoList(); | ||
1173 | QFileInfoListIterator it( *list ); | ||
1174 | QFileInfo *fi; | ||
1175 | while( (fi=it.current() ) ){ | ||
1176 | //qWarning("True and only" ); | ||
1177 | if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){ | ||
1178 | //qWarning(".. or ." ); | ||
1179 | ++it; | ||
1180 | continue; | ||
1181 | } | ||
1182 | if( fi->isSymLink() ){ | ||
1183 | QString file = fi->dirPath( true ) + "/" + fi->readLink(); | ||
1184 | for( int i = 0; i<=4; i++) { // 5 tries to prevent dos | ||
1185 | QFileInfo info( file ); | ||
1186 | if( !info.exists() ){ | ||
1187 | addSymlink( currentMimeType, fi, TRUE ); | ||
1188 | break; | ||
1189 | }else if( info.isDir() ){ | ||
1190 | addDir( currentMimeType, fi, TRUE ); | ||
1191 | break; | ||
1192 | }else if( info.isFile() ){ | ||
1193 | addFile( currentMimeType, fi, TRUE ); | ||
1194 | break; | ||
1195 | }else if( info.isSymLink() ){ | ||
1196 | file = info.dirPath(true ) + "/" + info.readLink() ; | ||
1197 | break; | ||
1198 | }else if( i == 4){ | ||
1199 | addSymlink( currentMimeType, fi ); | ||
1200 | } | ||
1201 | } // off for loop | ||
1202 | }else if( fi->isDir() ){ | ||
1203 | addDir( currentMimeType, fi ); | ||
1204 | }else if( fi->isFile() ){ | ||
1205 | addFile( currentMimeType, fi ); | ||
1206 | } | ||
1207 | //qWarning( "%s", fi->fileName().latin1() ); | ||
1208 | ++it; | ||
1209 | } // of while loop | ||
1210 | m_View->sort(); | ||
1211 | if( m_shTool ){ | 996 | if( m_shTool ){ |
1212 | m_location->insertItem( m_currentDir ); | 997 | m_location->insertItem( m_currentDir ); |
1213 | 998 | ||
@@ -1252,6 +1037,7 @@ void OFileSelector::internContextMenu() { | |||
1252 | } | 1037 | } |
1253 | void OFileSelector::internChangedDir( const QString& s) { | 1038 | void OFileSelector::internChangedDir( const QString& s) { |
1254 | emit dirSelected( s ); | 1039 | emit dirSelected( s ); |
1040 | cd(s ); | ||
1255 | } | 1041 | } |
1256 | void OFileSelector::internChangedDir( const QDir& s) { | 1042 | void OFileSelector::internChangedDir( const QDir& s) { |
1257 | emit dirSelected( s ); | 1043 | emit dirSelected( s ); |
@@ -1260,3 +1046,6 @@ QPixmap OFileSelector::pixmap( const QString& s ) { | |||
1260 | 1046 | ||
1261 | return (*m_pixmaps)[s]; | 1047 | return (*m_pixmaps)[s]; |
1262 | } | 1048 | } |
1049 | OLister* OFileSelector::currentLister()const { | ||
1050 | return 0l; | ||
1051 | } | ||
diff --git a/libopie/ofileselector/ofileselector.h b/libopie/ofileselector/ofileselector.h index 12af732..a7b363f 100644 --- a/libopie/ofileselector/ofileselector.h +++ b/libopie/ofileselector/ofileselector.h | |||
@@ -68,6 +68,7 @@ class QPopupMenu; | |||
68 | class QFileInfo; | 68 | class QFileInfo; |
69 | class QHBox; | 69 | class QHBox; |
70 | class OFileView; | 70 | class OFileView; |
71 | class OLister; | ||
71 | // | 72 | // |
72 | 73 | ||
73 | /* the mimetypes one name and a list of mimetypes */ | 74 | /* the mimetypes one name and a list of mimetypes */ |
@@ -337,6 +338,7 @@ class OFileSelector : public QWidget { | |||
337 | 338 | ||
338 | OFileView* currentView(); | 339 | OFileView* currentView(); |
339 | OFileView* currentView()const; | 340 | OFileView* currentView()const; |
341 | OLister* currentLister()const; | ||
340 | int filter(); | 342 | int filter(); |
341 | int sorting(); | 343 | int sorting(); |
342 | QPixmap pixmap( const QString& ); | 344 | QPixmap pixmap( const QString& ); |
@@ -369,17 +371,25 @@ class OFileSelector : public QWidget { | |||
369 | 371 | ||
370 | FileSelector* m_select; | 372 | FileSelector* m_select; |
371 | int m_mode, m_selector; | 373 | int m_mode, m_selector; |
372 | QComboBox *m_location, *m_mimeCheck, *m_viewCheck; | 374 | QComboBox *m_location, |
373 | QPushButton *m_homeButton, *m_docButton, *m_hideButton, *m_ok, *m_cancel; | 375 | *m_mimeCheck, |
374 | QPushButton *m_reread, *m_up, *m_new, *m_close; | 376 | *m_viewCheck; |
377 | |||
378 | QPushButton *m_homeButton, | ||
379 | *m_docButton, | ||
380 | *m_hideButton, | ||
381 | *m_ok, *m_cancel; | ||
382 | QPushButton *m_reread, | ||
383 | *m_up, | ||
384 | *m_new, | ||
385 | *m_close; | ||
375 | QListView *m_View; | 386 | QListView *m_View; |
376 | QCheckBox *m_checkPerm; | 387 | QCheckBox *m_checkPerm; |
377 | QWidget *m_pseudo; | 388 | QWidget *m_pseudo; |
378 | QVBoxLayout *m_pseudoLayout; | 389 | QVBoxLayout *m_pseudoLayout; |
379 | 390 | ||
380 | QString m_currentDir; | 391 | QString m_currentDir; |
381 | QString m_name; | 392 | QString m_name; |
382 | // QStringList m_mimetypes; | ||
383 | QMap<QString, QStringList> m_mimetypes; | 393 | QMap<QString, QStringList> m_mimetypes; |
384 | 394 | ||
385 | 395 | ||
@@ -388,8 +398,8 @@ class OFileSelector : public QWidget { | |||
388 | QGridLayout *m_Oselector; | 398 | QGridLayout *m_Oselector; |
389 | 399 | ||
390 | QHBox *m_boxToolbar; | 400 | QHBox *m_boxToolbar; |
391 | QHBox *m_boxOk; // (no layout anymore) wait | 401 | QHBox *m_boxOk; |
392 | QHBox *m_boxName; // (no Layout anymore) wait | 402 | QHBox *m_boxName; |
393 | QHBox *m_boxView; | 403 | QHBox *m_boxView; |
394 | 404 | ||
395 | QPopupMenu *m_custom; | 405 | QPopupMenu *m_custom; |
@@ -412,9 +422,7 @@ class OFileSelector : public QWidget { | |||
412 | bool m_showPopup : 1; | 422 | bool m_showPopup : 1; |
413 | 423 | ||
414 | void initVars(); | 424 | void initVars(); |
415 | virtual void addFile(const QString &mime, QFileInfo *info, bool symlink = FALSE ); | 425 | |
416 | virtual void addDir( const QString &mime, QFileInfo *info , bool symlink = FALSE ); | ||
417 | virtual void addSymlink(const QString &, QFileInfo *, bool = FALSE ){}; | ||
418 | void delItems(); | 426 | void delItems(); |
419 | void initializeName(); | 427 | void initializeName(); |
420 | void initializeYes(); | 428 | void initializeYes(); |
@@ -441,17 +449,8 @@ class OFileSelector : public QWidget { | |||
441 | private slots: | 449 | private slots: |
442 | void slotFileSelected(const QString & ); // not really meant to be a slot | 450 | void slotFileSelected(const QString & ); // not really meant to be a slot |
443 | void slotFileBridgeSelected( const DocLnk & ); | 451 | void slotFileBridgeSelected( const DocLnk & ); |
444 | virtual void slotSelectionChanged(); | ||
445 | virtual void slotCurrentChanged(QListViewItem* ); | ||
446 | virtual void slotClicked( int, QListViewItem *item, const QPoint &, int); | ||
447 | virtual void slotRightButton(int, QListViewItem *, const QPoint &, int ); | ||
448 | virtual void slotContextMenu( QListViewItem *item); | ||
449 | // listview above | 452 | // listview above |
450 | // popup below | 453 | // popup below |
451 | virtual void slotChangedDir(); | ||
452 | virtual void slotOpen(); | ||
453 | virtual void slotRescan(); | ||
454 | virtual void slotRename(); | ||
455 | virtual void slotDelete(); | 454 | virtual void slotDelete(); |
456 | virtual void cdUP(); | 455 | virtual void cdUP(); |
457 | virtual void slotHome(); | 456 | virtual void slotHome(); |
diff --git a/libopie/ofileselector/ofileview.cpp b/libopie/ofileselector/ofileview.cpp index 9bb40c9..38f722c 100644 --- a/libopie/ofileselector/ofileview.cpp +++ b/libopie/ofileselector/ofileview.cpp | |||
@@ -1,7 +1,8 @@ | |||
1 | #include <qlineedit.h> | ||
2 | |||
1 | #include <qpe/applnk.h> | 3 | #include <qpe/applnk.h> |
2 | 4 | ||
3 | #include "ofileselector.h" | 5 | #include "ofileselector.h" |
4 | |||
5 | #include "ofileview.h" | 6 | #include "ofileview.h" |
6 | 7 | ||
7 | 8 | ||
@@ -29,3 +30,7 @@ void OFileView::changedDir( const QDir& d ) { | |||
29 | OFileSelector* OFileView::selector() const { | 30 | OFileSelector* OFileView::selector() const { |
30 | return m_sel; | 31 | return m_sel; |
31 | } | 32 | } |
33 | void OFileView::updateLine( const QString& str ) { | ||
34 | if (m_sel->m_shLne ) | ||
35 | m_sel->m_edit->setText( str ); | ||
36 | } | ||
diff --git a/libopie/ofileselector/ofileview.h b/libopie/ofileselector/ofileview.h index 1b397f5..a4b1748 100644 --- a/libopie/ofileselector/ofileview.h +++ b/libopie/ofileselector/ofileview.h | |||
@@ -81,6 +81,7 @@ public: | |||
81 | virtual QString selectedPath()const = 0; | 81 | virtual QString selectedPath()const = 0; |
82 | virtual QStringList selectedPaths()const = 0; | 82 | virtual QStringList selectedPaths()const = 0; |
83 | virtual int fileCount() = 0; | 83 | virtual int fileCount() = 0; |
84 | virtual void sort() =0; | ||
84 | 85 | ||
85 | /*signals:*/ | 86 | /*signals:*/ |
86 | protected: | 87 | protected: |
@@ -90,6 +91,7 @@ protected: | |||
90 | void contextMenu(); | 91 | void contextMenu(); |
91 | void changedDir(const QString &); | 92 | void changedDir(const QString &); |
92 | void changedDir(const QDir & ); | 93 | void changedDir(const QDir & ); |
94 | void updateLine( const QString& ); | ||
93 | OFileSelector* selector()const; | 95 | OFileSelector* selector()const; |
94 | 96 | ||
95 | private: | 97 | private: |