summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-04-24 03:22:24 (UTC)
committer llornkcor <llornkcor>2002-04-24 03:22:24 (UTC)
commit219994e9d1de70b44c994ccee57060741f22d428 (patch) (unidiff)
tree2acfcae2a6bfc432266ee1d0cb76285a95fe683f
parentc9159a3d5192799f5b2911d13337f04f50b1ac5a (diff)
downloadopie-219994e9d1de70b44c994ccee57060741f22d428.zip
opie-219994e9d1de70b44c994ccee57060741f22d428.tar.gz
opie-219994e9d1de70b44c994ccee57060741f22d428.tar.bz2
fixed location combo showing redundant directories and multiple seperators
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/ofileselector.cc123
-rw-r--r--libopie/ofileselector.h15
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
@@ -44,2 +44,4 @@
44#include <qcursor.h> 44#include <qcursor.h>
45#include <qstringlist.h>
46#include <qmessagebox.h>
45 47
@@ -136,2 +138,3 @@ OFileSelector::OFileSelector(QWidget *wid, int mode, int selector, const QString
136} 138}
139
137void OFileSelector::initPics() 140void OFileSelector::initPics()
@@ -153,3 +156,4 @@ void OFileSelector::initPics()
153 156
154}; 157}
158
155// let's initialize the gui 159// let's initialize the gui
@@ -181,2 +185,3 @@ void OFileSelector::delItems()
181} 185}
186
182void OFileSelector::init() 187void OFileSelector::init()
@@ -218,3 +223,3 @@ void OFileSelector::init()
218 223
219}; 224}
220 225
@@ -263,2 +268,3 @@ void OFileSelector::setPermissionBarVisible( bool show )
263} 268}
269
264void OFileSelector::setLineEditVisible( bool show ) 270void OFileSelector::setLineEditVisible( bool show )
@@ -278,2 +284,3 @@ void OFileSelector::setLineEditVisible( bool show )
278} 284}
285
279void OFileSelector::setChooserVisible( bool show ) 286void OFileSelector::setChooserVisible( bool show )
@@ -291,2 +298,3 @@ void OFileSelector::setChooserVisible( bool show )
291} 298}
299
292QCheckBox* OFileSelector::permissionCheckbox( ) 300QCheckBox* OFileSelector::permissionCheckbox( )
@@ -295,2 +303,3 @@ QCheckBox* OFileSelector::permissionCheckbox( )
295} 303}
304
296void OFileSelector::setCaseSensetive( bool caSe ) 305void OFileSelector::setCaseSensetive( bool caSe )
@@ -300,2 +309,3 @@ void OFileSelector::setCaseSensetive( bool caSe )
300} 309}
310
301void OFileSelector::setShowFiles(bool files ){ 311void OFileSelector::setShowFiles(bool files ){
@@ -304,2 +314,3 @@ void OFileSelector::setShowFiles(bool files ){
304} 314}
315
305void OFileSelector::setPopupMenu(QPopupMenu *pop ) 316void OFileSelector::setPopupMenu(QPopupMenu *pop )
@@ -309,2 +320,3 @@ void OFileSelector::setPopupMenu(QPopupMenu *pop )
309} 320}
321
310bool OFileSelector::setPermission( ) const 322bool OFileSelector::setPermission( ) const
@@ -316,2 +328,3 @@ bool OFileSelector::setPermission( ) const
316} 328}
329
317void OFileSelector::setPermissionChecked( bool check ) 330void OFileSelector::setPermissionChecked( bool check )
@@ -322,2 +335,3 @@ void OFileSelector::setPermissionChecked( bool check )
322} 335}
336
323QString OFileSelector::selectedName( )const 337QString OFileSelector::selectedName( )const
@@ -336,2 +350,3 @@ QString OFileSelector::selectedName( )const
336} 350}
351
337QStringList OFileSelector::selectedNames()const 352QStringList OFileSelector::selectedNames()const
@@ -341,2 +356,3 @@ QStringList OFileSelector::selectedNames()const
341} 356}
357
342DocLnk OFileSelector::selectedDocument( )const 358DocLnk OFileSelector::selectedDocument( )const
@@ -387,2 +403,3 @@ void OFileSelector::updateLay()
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
@@ -434,2 +451,3 @@ void OFileSelector::reparse()
434 }; 451 };
452
435 QDir dir( m_currentDir ); 453 QDir dir( m_currentDir );
@@ -499,6 +517,9 @@ void OFileSelector::reparse()
499} 517}
518
500QString OFileSelector::directory()const 519QString OFileSelector::directory()const
501{ 520{
502 return m_currentDir; 521 QDir d( m_currentDir);
522 return d.absPath();
503} 523}
524
504int OFileSelector::fileCount() 525int OFileSelector::fileCount()
@@ -507,2 +528,3 @@ int OFileSelector::fileCount()
507} 528}
529
508void OFileSelector::slotOk( ) 530void OFileSelector::slotOk( )
@@ -511,2 +533,3 @@ void OFileSelector::slotOk( )
511} 533}
534
512void OFileSelector::slotCancel( ) 535void OFileSelector::slotCancel( )
@@ -528,2 +551,3 @@ void OFileSelector::initializeName()
528} 551}
552
529void OFileSelector::initializeYes() 553void OFileSelector::initializeYes()
@@ -543,2 +567,3 @@ void OFileSelector::initializeYes()
543} 567}
568
544void OFileSelector::initializeChooser() 569void OFileSelector::initializeChooser()
@@ -572,2 +597,3 @@ void OFileSelector::initializeChooser()
572} 597}
598
573void OFileSelector::slotMimeCheck(const QString &view ){ 599void OFileSelector::slotMimeCheck(const QString &view ){
@@ -647,3 +673,3 @@ void OFileSelector::slotViewCheck(const QString &view ){
647 }; 673 };
648}; 674}
649 675
@@ -667,3 +693,4 @@ void OFileSelector::updateMimes() // lets check which mode is active
667 } 693 }
668}; 694}
695
669void OFileSelector::initializeListView() 696void OFileSelector::initializeListView()
@@ -695,2 +722,3 @@ void OFileSelector::initializeListView()
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
@@ -807,2 +835,3 @@ void OFileSelector::addFile(const QString &mime, QFileInfo *info, bool symlink )
807} 835}
836
808void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink ) 837void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink )
@@ -844,2 +873,3 @@ void OFileSelector::addDir(const QString &mime, QFileInfo *info, bool symlink )
844} 873}
874
845void OFileSelector::setShowDirs(bool dir ) 875void OFileSelector::setShowDirs(bool dir )
@@ -858,2 +888,3 @@ void OFileSelector::slotFileSelected(const QString &string )
858} 888}
889
859void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk ) 890void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk )
@@ -863,2 +894,3 @@ void OFileSelector::slotFileBridgeSelected( const DocLnk &lnk )
863} 894}
895
864void OFileSelector::slotSelectionChanged() // get the current items 896void OFileSelector::slotSelectionChanged() // get the current items
@@ -868,2 +900,3 @@ void OFileSelector::slotSelectionChanged() // get the current items
868} 900}
901
869void OFileSelector::slotCurrentChanged(QListViewItem *item ) 902void OFileSelector::slotCurrentChanged(QListViewItem *item )
@@ -887,2 +920,3 @@ void OFileSelector::slotCurrentChanged(QListViewItem *item )
887} 920}
921
888// either select or change dir 922// either select or change dir
@@ -903,11 +937,11 @@ void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &
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" );
@@ -916,2 +950,3 @@ void OFileSelector::slotClicked( int button, QListViewItem *item, const QPoint &
916} 950}
951
917void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int ) 952void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoint &, int )
@@ -926,2 +961,3 @@ void OFileSelector::slotRightButton(int button, QListViewItem *item, const QPoin
926} 961}
962
927void OFileSelector::slotContextMenu(QListViewItem *item) 963void OFileSelector::slotContextMenu(QListViewItem *item)
@@ -977,2 +1013,3 @@ void OFileSelector::slotContextMenu(QListViewItem *item)
977} 1013}
1014
978bool OFileSelector::cd(const QString &str ) 1015bool OFileSelector::cd(const QString &str )
@@ -982,7 +1019,7 @@ bool OFileSelector::cd(const QString &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 );
@@ -994,2 +1031,17 @@ bool OFileSelector::cd(const QString &str )
994 1031
1032void OFileSelector::insertLocationPath(const QString &currentPath, 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
995void OFileSelector::slotChangedDir() 1047void OFileSelector::slotChangedDir()
@@ -1000,4 +1052,6 @@ void OFileSelector::slotChangedDir()
1000 cd( sel->directory() + "/" + str[0] ); 1052 cd( sel->directory() + "/" + str[0] );
1053
1001 } 1054 }
1002} 1055}
1056
1003void OFileSelector::slotOpen() 1057void OFileSelector::slotOpen()
@@ -1010,2 +1064,3 @@ void OFileSelector::slotOpen()
1010} 1064}
1065
1011void OFileSelector::slotRescan() 1066void OFileSelector::slotRescan()
@@ -1014,2 +1069,3 @@ void OFileSelector::slotRescan()
1014} 1069}
1070
1015void OFileSelector::slotRename() 1071void OFileSelector::slotRename()
@@ -1018,2 +1074,3 @@ void OFileSelector::slotRename()
1018} 1074}
1075
1019void OFileSelector::slotDelete() 1076void OFileSelector::slotDelete()
@@ -1024,5 +1081,10 @@ void OFileSelector::slotDelete()
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] );
@@ -1041,6 +1103,18 @@ void OFileSelector::cdUP()
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
1111int 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
1046void OFileSelector::slotHome() 1120void OFileSelector::slotHome()
@@ -1049,2 +1123,3 @@ void OFileSelector::slotHome()
1049} 1123}
1124
1050void OFileSelector::slotDoc() 1125void OFileSelector::slotDoc()
@@ -1053,2 +1128,3 @@ void OFileSelector::slotDoc()
1053} 1128}
1129
1054void OFileSelector::slotNavigate() 1130void OFileSelector::slotNavigate()
@@ -1057 +1133,6 @@ void OFileSelector::slotNavigate()
1057} 1133}
1134
1135void 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
@@ -69,4 +69,4 @@ class OFileSelectorItem : public QListViewItem {
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 );
@@ -96,7 +96,7 @@ class OFileSelectorItem : public QListViewItem {
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 }
@@ -192,2 +192,5 @@ class OFileSelector : public QWidget {
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: