-rw-r--r-- | libopie/ofileselector.cc | 123 | ||||
-rw-r--r-- | libopie/ofileselector.h | 15 |
2 files changed, 111 insertions, 27 deletions
diff --git a/libopie/ofileselector.cc b/libopie/ofileselector.cc index cb18039..d1f1e1f 100644 --- a/libopie/ofileselector.cc +++ b/libopie/ofileselector.cc | |||
@@ -43,4 +43,6 @@ | |||
43 | #include <qpopupmenu.h> | 43 | #include <qpopupmenu.h> |
44 | #include <qcursor.h> | 44 | #include <qcursor.h> |
45 | #include <qstringlist.h> | ||
46 | #include <qmessagebox.h> | ||
45 | 47 | ||
46 | #include <qpe/qpeapplication.h> | 48 | #include <qpe/qpeapplication.h> |
@@ -135,4 +137,5 @@ OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString | |||
135 | m_edit->setText( fileName ); | 137 | m_edit->setText( fileName ); |
136 | } | 138 | } |
139 | |||
137 | void OFileSelector::initPics() | 140 | void OFileSelector::initPics() |
138 | { | 141 | { |
@@ -152,5 +155,6 @@ void OFileSelector::initPics() | |||
152 | m_pixmaps->insert("symlinkedlocked", pm2 ); | 155 | m_pixmaps->insert("symlinkedlocked", pm2 ); |
153 | 156 | ||
154 | }; | 157 | } |
158 | |||
155 | // let's initialize the gui | 159 | // let's initialize the gui |
156 | /** | 160 | /** |
@@ -180,4 +184,5 @@ void OFileSelector::delItems() | |||
180 | } | 184 | } |
181 | } | 185 | } |
186 | |||
182 | void OFileSelector::init() | 187 | void OFileSelector::init() |
183 | { | 188 | { |
@@ -217,5 +222,5 @@ void OFileSelector::init() | |||
217 | 222 | ||
218 | 223 | ||
219 | }; | 224 | } |
220 | 225 | ||
221 | void OFileSelector::setYesCancelVisible( bool show ) | 226 | void OFileSelector::setYesCancelVisible( bool show ) |
@@ -262,4 +267,5 @@ void OFileSelector::setPermissionBarVisible( bool show ) | |||
262 | updateLay(); | 267 | updateLay(); |
263 | } | 268 | } |
269 | |||
264 | void OFileSelector::setLineEditVisible( bool show ) | 270 | void OFileSelector::setLineEditVisible( bool show ) |
265 | { | 271 | { |
@@ -277,4 +283,5 @@ void OFileSelector::setLineEditVisible( bool show ) | |||
277 | updateLay(); | 283 | updateLay(); |
278 | } | 284 | } |
285 | |||
279 | void OFileSelector::setChooserVisible( bool show ) | 286 | void OFileSelector::setChooserVisible( bool show ) |
280 | { | 287 | { |
@@ -290,8 +297,10 @@ void OFileSelector::setChooserVisible( bool show ) | |||
290 | updateLay(); | 297 | updateLay(); |
291 | } | 298 | } |
299 | |||
292 | QCheckBox* OFileSelector::permissionCheckbox( ) | 300 | QCheckBox* OFileSelector::permissionCheckbox( ) |
293 | { | 301 | { |
294 | return m_checkPerm; | 302 | return m_checkPerm; |
295 | } | 303 | } |
304 | |||
296 | void OFileSelector::setCaseSensetive( bool caSe ) | 305 | void OFileSelector::setCaseSensetive( bool caSe ) |
297 | { | 306 | { |
@@ -299,8 +308,10 @@ void OFileSelector::setCaseSensetive( bool caSe ) | |||
299 | reparse(); | 308 | reparse(); |
300 | } | 309 | } |
310 | |||
301 | void OFileSelector::setShowFiles(bool files ){ | 311 | void OFileSelector::setShowFiles(bool files ){ |
302 | m_files = files; | 312 | m_files = files; |
303 | reparse(); | 313 | reparse(); |
304 | } | 314 | } |
315 | |||
305 | void OFileSelector::setPopupMenu(QPopupMenu *pop ) | 316 | void OFileSelector::setPopupMenu(QPopupMenu *pop ) |
306 | { | 317 | { |
@@ -308,4 +319,5 @@ void OFileSelector::setPopupMenu(QPopupMenu *pop ) | |||
308 | m_custom = pop; | 319 | m_custom = pop; |
309 | } | 320 | } |
321 | |||
310 | bool OFileSelector::setPermission( ) const | 322 | bool OFileSelector::setPermission( ) const |
311 | { | 323 | { |
@@ -315,4 +327,5 @@ bool OFileSelector::setPermission( ) const | |||
315 | return m_checkPerm->isChecked(); | 327 | return m_checkPerm->isChecked(); |
316 | } | 328 | } |
329 | |||
317 | void OFileSelector::setPermissionChecked( bool check ) | 330 | void OFileSelector::setPermissionChecked( bool check ) |
318 | { | 331 | { |
@@ -321,4 +334,5 @@ void OFileSelector::setPermissionChecked( bool check ) | |||
321 | m_checkPerm->setChecked( check ); | 334 | m_checkPerm->setChecked( check ); |
322 | } | 335 | } |
336 | |||
323 | QString OFileSelector::selectedName( )const | 337 | QString OFileSelector::selectedName( )const |
324 | { | 338 | { |
@@ -335,4 +349,5 @@ QString OFileSelector::selectedName( )const | |||
335 | return string; | 349 | return string; |
336 | } | 350 | } |
351 | |||
337 | QStringList OFileSelector::selectedNames()const | 352 | QStringList OFileSelector::selectedNames()const |
338 | { | 353 | { |
@@ -340,4 +355,5 @@ QStringList OFileSelector::selectedNames()const | |||
340 | return list; | 355 | return list; |
341 | } | 356 | } |
357 | |||
342 | DocLnk OFileSelector::selectedDocument( )const | 358 | DocLnk OFileSelector::selectedDocument( )const |
343 | { | 359 | { |
@@ -386,4 +402,5 @@ void OFileSelector::updateLay() | |||
386 | m_checkPerm->setChecked(check ); | 402 | m_checkPerm->setChecked(check ); |
387 | } | 403 | } |
404 | |||
388 | // let's update the mimetypes. Use the current mimefilter for the 2nd QDir retrieve | 405 | // let's update the mimetypes. Use the current mimefilter for the 2nd QDir retrieve |
389 | // insert QListViewItems with the right options | 406 | // insert QListViewItems with the right options |
@@ -433,4 +450,5 @@ void OFileSelector::reparse() | |||
433 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) ); | 450 | m_mimeCheck->setCurrentItem( indexByString( m_mimeCheck, currMime ) ); |
434 | }; | 451 | }; |
452 | |||
435 | QDir dir( m_currentDir ); | 453 | QDir dir( m_currentDir ); |
436 | //dir.setFilter(-1 ); | 454 | //dir.setFilter(-1 ); |
@@ -498,16 +516,21 @@ void OFileSelector::reparse() | |||
498 | m_View->sort(); | 516 | m_View->sort(); |
499 | } | 517 | } |
518 | |||
500 | QString OFileSelector::directory()const | 519 | QString OFileSelector::directory()const |
501 | { | 520 | { |
502 | return m_currentDir; | 521 | QDir d( m_currentDir); |
522 | return d.absPath(); | ||
503 | } | 523 | } |
524 | |||
504 | int OFileSelector::fileCount() | 525 | int OFileSelector::fileCount() |
505 | { | 526 | { |
506 | return 0; | 527 | return 0; |
507 | } | 528 | } |
529 | |||
508 | void OFileSelector::slotOk( ) | 530 | void OFileSelector::slotOk( ) |
509 | { | 531 | { |
510 | emit ok(); | 532 | emit ok(); |
511 | } | 533 | } |
534 | |||
512 | void OFileSelector::slotCancel( ) | 535 | void OFileSelector::slotCancel( ) |
513 | { | 536 | { |
@@ -527,4 +550,5 @@ void OFileSelector::initializeName() | |||
527 | m_lay->addLayout(m_boxName); | 550 | m_lay->addLayout(m_boxName); |
528 | } | 551 | } |
552 | |||
529 | void OFileSelector::initializeYes() | 553 | void OFileSelector::initializeYes() |
530 | { | 554 | { |
@@ -542,4 +566,5 @@ void OFileSelector::initializeYes() | |||
542 | 566 | ||
543 | } | 567 | } |
568 | |||
544 | void OFileSelector::initializeChooser() | 569 | void OFileSelector::initializeChooser() |
545 | { | 570 | { |
@@ -571,4 +596,5 @@ void OFileSelector::initializeChooser() | |||
571 | this, SLOT(slotMimeCheck(const QString & ) ) ); | 596 | this, SLOT(slotMimeCheck(const QString & ) ) ); |
572 | } | 597 | } |
598 | |||
573 | void OFileSelector::slotMimeCheck(const QString &view ){ | 599 | void OFileSelector::slotMimeCheck(const QString &view ){ |
574 | if(m_selector == NORMAL ){ | 600 | if(m_selector == NORMAL ){ |
@@ -646,5 +672,5 @@ void OFileSelector::slotViewCheck(const QString &view ){ | |||
646 | reparse(); | 672 | reparse(); |
647 | }; | 673 | }; |
648 | }; | 674 | } |
649 | 675 | ||
650 | 676 | ||
@@ -666,5 +692,6 @@ void OFileSelector::updateMimes() // lets check which mode is active | |||
666 | ; | 692 | ; |
667 | } | 693 | } |
668 | }; | 694 | } |
695 | |||
669 | void OFileSelector::initializeListView() | 696 | void OFileSelector::initializeListView() |
670 | { | 697 | { |
@@ -694,4 +721,5 @@ void OFileSelector::initializeListView() | |||
694 | m_boxToolbar->setAutoAdd( true ); | 721 | m_boxToolbar->setAutoAdd( true ); |
695 | m_location = new QComboBox(m_pseudo ); | 722 | m_location = new QComboBox(m_pseudo ); |
723 | connect( m_location, SIGNAL(activated(const QString &) ), this, SLOT( locationComboActivated(const QString & ) ) ); | ||
696 | 724 | ||
697 | m_up = new QPushButton(Resource::loadIconSet("up"),"", m_pseudo,"cdUpButton"); | 725 | m_up = new QPushButton(Resource::loadIconSet("up"),"", m_pseudo,"cdUpButton"); |
@@ -806,4 +834,5 @@ void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink ) | |||
806 | dir, locked ); | 834 | dir, locked ); |
807 | } | 835 | } |
836 | |||
808 | void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink ) | 837 | void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink ) |
809 | { | 838 | { |
@@ -843,4 +872,5 @@ void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink ) | |||
843 | } | 872 | } |
844 | } | 873 | } |
874 | |||
845 | void OFileSelector::setShowDirs(bool dir ) | 875 | void OFileSelector::setShowDirs(bool dir ) |
846 | { | 876 | { |
@@ -857,4 +887,5 @@ void OFileSelector::slotFileSelected(const QString &string ) | |||
857 | // do AppLnk stuff | 887 | // do AppLnk stuff |
858 | } | 888 | } |
889 | |||
859 | void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) | 890 | void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) |
860 | { | 891 | { |
@@ -862,4 +893,5 @@ void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) | |||
862 | emit fileSelected( lnk ); | 893 | emit fileSelected( lnk ); |
863 | } | 894 | } |
895 | |||
864 | void OFileSelector::slotSelectionChanged() // get the current items | 896 | void OFileSelector::slotSelectionChanged() // get the current items |
865 | // fixme | 897 | // fixme |
@@ -867,4 +899,5 @@ void OFileSelector::slotSelectionChanged() // get the current items | |||
867 | qWarning("selection changed" ); | 899 | qWarning("selection changed" ); |
868 | } | 900 | } |
901 | |||
869 | void OFileSelector::slotCurrentChanged(QListViewItem *item ) | 902 | void OFileSelector::slotCurrentChanged(QListViewItem *item ) |
870 | { | 903 | { |
@@ -886,4 +919,5 @@ void OFileSelector::slotCurrentChanged(QListViewItem *item ) | |||
886 | } | 919 | } |
887 | } | 920 | } |
921 | |||
888 | // either select or change dir | 922 | // either select or change dir |
889 | void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &point, int ) | 923 | void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &point, int ) |
@@ -902,17 +936,18 @@ void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint & | |||
902 | QStringList str = QStringList::split("->", sel->text(1) ); | 936 | QStringList str = QStringList::split("->", sel->text(1) ); |
903 | if(sel->isDir() ){ | 937 | if(sel->isDir() ){ |
904 | cd( sel->directory() + "/" + str[0] ); | 938 | cd( sel->directory() + "/" + str[0] ); |
905 | }else{ | 939 | } else { |
906 | qWarning("file" ); | 940 | qWarning("file" ); |
907 | if(m_shLne ) | 941 | if(m_shLne ) |
908 | m_edit->setText(str[0] ); | 942 | m_edit->setText(str[0] ); |
909 | emit fileSelected(str[0] ); | 943 | emit fileSelected(str[0] ); |
910 | // emit DocLnk need to do it | 944 | // emit DocLnk need to do it |
911 | } | 945 | } |
912 | }else{ | 946 | } else { |
913 | qWarning( "locked" ); | 947 | qWarning( "locked" ); |
914 | } | 948 | } |
915 | }; | 949 | }; |
916 | } | 950 | } |
951 | |||
917 | void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int ) | 952 | void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int ) |
918 | { | 953 | { |
@@ -925,4 +960,5 @@ void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoin | |||
925 | slotContextMenu(item); | 960 | slotContextMenu(item); |
926 | } | 961 | } |
962 | |||
927 | void OFileSelector::slotContextMenu(QListViewItem *item) | 963 | void OFileSelector::slotContextMenu(QListViewItem *item) |
928 | { | 964 | { |
@@ -976,4 +1012,5 @@ void OFileSelector::slotContextMenu(QListViewItem *item) | |||
976 | } | 1012 | } |
977 | } | 1013 | } |
1014 | |||
978 | bool OFileSelector::cd(const QString &str ) | 1015 | bool OFileSelector::cd(const QString &str ) |
979 | { | 1016 | { |
@@ -981,9 +1018,9 @@ bool OFileSelector::cd(const QString &str ) | |||
981 | QDir dir( str); | 1018 | QDir dir( str); |
982 | if(dir.exists() ){ | 1019 | if(dir.exists() ){ |
983 | m_currentDir = str; | 1020 | m_currentDir = dir.absPath(); |
984 | reparse(); | 1021 | reparse(); |
985 | if(m_shTool ){ | 1022 | if(m_shTool ){ |
986 | int count = m_location->count(); | 1023 | int count = m_location->count(); |
987 | m_location->insertItem(str ); | 1024 | insertLocationPath( str ,count ); |
988 | m_location->setCurrentItem( count ); | 1025 | m_location->setCurrentItem( count ); |
989 | } | 1026 | } |
@@ -993,4 +1030,19 @@ bool OFileSelector::cd(const QString &str ) | |||
993 | } | 1030 | } |
994 | 1031 | ||
1032 | void OFileSelector::insertLocationPath(const QString ¤tPath, int count) { | ||
1033 | QStringList pathList; | ||
1034 | for(int i=0;i<count;i++) { | ||
1035 | pathList << m_location->text(i); | ||
1036 | } | ||
1037 | if( pathList.grep( currentPath,TRUE).isEmpty() ) { | ||
1038 | m_location->clear(); | ||
1039 | if( currentPath.left(2)=="//") | ||
1040 | pathList.append( currentPath.right(currentPath.length()-1) ); | ||
1041 | else | ||
1042 | pathList.append( currentPath ); | ||
1043 | m_location->insertStringList( pathList,-1); | ||
1044 | } | ||
1045 | } | ||
1046 | |||
995 | void OFileSelector::slotChangedDir() | 1047 | void OFileSelector::slotChangedDir() |
996 | { | 1048 | { |
@@ -999,6 +1051,8 @@ void OFileSelector::slotChangedDir() | |||
999 | QStringList str = QStringList::split("->", sel->text(1) ); | 1051 | QStringList str = QStringList::split("->", sel->text(1) ); |
1000 | cd( sel->directory() + "/" + str[0] ); | 1052 | cd( sel->directory() + "/" + str[0] ); |
1053 | |||
1001 | } | 1054 | } |
1002 | } | 1055 | } |
1056 | |||
1003 | void OFileSelector::slotOpen() | 1057 | void OFileSelector::slotOpen() |
1004 | { | 1058 | { |
@@ -1009,12 +1063,15 @@ void OFileSelector::slotOpen() | |||
1009 | } | 1063 | } |
1010 | } | 1064 | } |
1065 | |||
1011 | void OFileSelector::slotRescan() | 1066 | void OFileSelector::slotRescan() |
1012 | { | 1067 | { |
1013 | reparse(); | 1068 | reparse(); |
1014 | } | 1069 | } |
1070 | |||
1015 | void OFileSelector::slotRename() | 1071 | void OFileSelector::slotRename() |
1016 | { | 1072 | { |
1017 | // rename inline | 1073 | // rename inline |
1018 | } | 1074 | } |
1075 | |||
1019 | void OFileSelector::slotDelete() | 1076 | void OFileSelector::slotDelete() |
1020 | { | 1077 | { |
@@ -1023,7 +1080,12 @@ void OFileSelector::slotDelete() | |||
1023 | QStringList list = QStringList::split("->", sel->text(1) ); | 1080 | QStringList list = QStringList::split("->", sel->text(1) ); |
1024 | if( sel->isDir() ){ | 1081 | if( sel->isDir() ){ |
1025 | QString str = QString::fromLatin1("rm -rf ") + list[0]; | 1082 | QString str = QString::fromLatin1("rm -rf ") + list[0]; //better safe than sorry |
1026 | ::system(str.utf8().data() ); | 1083 | switch ( QMessageBox::warning(this,tr("Delete"),tr("Do you really want to delete\n")+list[0], |
1027 | }else{ | 1084 | tr("Yes"),tr("No"),0,1,1) ) { |
1085 | case 0: | ||
1086 | ::system(str.utf8().data() ); | ||
1087 | break; | ||
1088 | } | ||
1089 | } else { | ||
1028 | QFile::remove( list[0] ); | 1090 | QFile::remove( list[0] ); |
1029 | } | 1091 | } |
@@ -1040,18 +1102,37 @@ void OFileSelector::cdUP() | |||
1040 | reparse(); | 1102 | reparse(); |
1041 | int count = m_location->count(); | 1103 | int count = m_location->count(); |
1042 | m_location->insertItem(m_currentDir ); | 1104 | insertLocationPath( m_currentDir,count ); |
1043 | m_location->setCurrentItem( count ); | 1105 | m_location->setCurrentItem( indexFromString(m_currentDir )); |
1106 | //this wont work in all instances | ||
1107 | // FIXME | ||
1044 | } | 1108 | } |
1045 | } | 1109 | } |
1110 | |||
1111 | int OFileSelector::indexFromString(const QString &str) { | ||
1112 | |||
1113 | for(int i=0;i< m_location->count();i++) { | ||
1114 | if(str == m_location->text(i)) | ||
1115 | return i; | ||
1116 | } | ||
1117 | return 0; | ||
1118 | } | ||
1119 | |||
1046 | void OFileSelector::slotHome() | 1120 | void OFileSelector::slotHome() |
1047 | { | 1121 | { |
1048 | cd(QDir::homeDirPath() ); | 1122 | cd(QDir::homeDirPath() ); |
1049 | } | 1123 | } |
1124 | |||
1050 | void OFileSelector::slotDoc() | 1125 | void OFileSelector::slotDoc() |
1051 | { | 1126 | { |
1052 | cd(QDir::homeDirPath() + "/Documents" ); | 1127 | cd(QDir::homeDirPath() + "/Documents" ); |
1053 | } | 1128 | } |
1129 | |||
1054 | void OFileSelector::slotNavigate() | 1130 | void OFileSelector::slotNavigate() |
1055 | { | 1131 | { |
1056 | 1132 | ||
1057 | } | 1133 | } |
1134 | |||
1135 | void OFileSelector::locationComboActivated(const QString & file ) { | ||
1136 | cd(file.left(file.find("<-",0,TRUE))); | ||
1137 | reparse(); | ||
1138 | } | ||
diff --git a/libopie/ofileselector.h b/libopie/ofileselector.h index 5e98a1e..81a9e63 100644 --- a/libopie/ofileselector.h +++ b/libopie/ofileselector.h | |||
@@ -68,6 +68,6 @@ class OFileSelectorItem : public QListViewItem { | |||
68 | public: | 68 | public: |
69 | OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, | 69 | OFileSelectorItem(QListView *view, const QPixmap &pixmap, const QString &path, |
70 | const QString &date, const QString &size, const QString &mDir, | 70 | const QString &date, const QString &size, const QString &mDir, |
71 | bool isLocked=false, bool isDir=false ): QListViewItem(view) { | 71 | bool isLocked=false, bool isDir=false ): QListViewItem(view) { |
72 | setPixmap(0, pixmap ); | 72 | setPixmap(0, pixmap ); |
73 | setText(1, path ); | 73 | setText(1, path ); |
@@ -95,9 +95,9 @@ class OFileSelectorItem : public QListViewItem { | |||
95 | if( id == 0 || id == 1 ){ // name | 95 | if( id == 0 || id == 1 ){ // name |
96 | if( dir ){ | 96 | if( dir ){ |
97 | ke.append("0" ); | 97 | ke.append("0" ); |
98 | ke.append( text(1) ); | 98 | ke.append( text(1) ); |
99 | }else{ | 99 | }else{ |
100 | ke.append("1" ); | 100 | ke.append("1" ); |
101 | ke.append( text(1) ); | 101 | ke.append( text(1) ); |
102 | } | 102 | } |
103 | }else if( id == 2 ){ // size | 103 | }else if( id == 2 ){ // size |
@@ -191,4 +191,7 @@ class OFileSelector : public QWidget { | |||
191 | void slotViewCheck(const QString & ); | 191 | void slotViewCheck(const QString & ); |
192 | void slotMimeCheck(const QString & ); | 192 | void slotMimeCheck(const QString & ); |
193 | void locationComboActivated(const QString & ); | ||
194 | void insertLocationPath(const QString &, int); | ||
195 | int indexFromString(const QString &); | ||
193 | protected: | 196 | protected: |
194 | void init(); | 197 | void init(); |