Diffstat (limited to 'libopie/ofileselector/ofileselector.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie/ofileselector/ofileselector.cpp | 261 |
1 files changed, 25 insertions, 236 deletions
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 | |||
@@ -33,3 +33,3 @@ | |||
33 | #include "ofileselector.h" | 33 | #include "ofileselector.h" |
34 | 34 | #include "olister.h" | |
35 | 35 | ||
@@ -38,2 +38,3 @@ QMap<QString,QPixmap> *OFileSelector::m_pixmaps = 0; | |||
38 | namespace { | 38 | namespace { |
39 | /* let's find the index for a specified string */ | ||
39 | int indexByString( const QComboBox *box, const QString &str ){ | 40 | int indexByString( const QComboBox *box, const QString &str ){ |
@@ -41,2 +42,3 @@ namespace { | |||
41 | for(int i= 0; i < box->count(); i++ ){ | 42 | for(int i= 0; i < box->count(); i++ ){ |
43 | /* found */ | ||
42 | if( str == box->text(i ) ){ | 44 | if( str == box->text(i ) ){ |
@@ -48,3 +50,2 @@ namespace { | |||
48 | } | 50 | } |
49 | |||
50 | } | 51 | } |
@@ -60,3 +61,5 @@ OFileSelector::OFileSelector( QWidget *wid, int mode, int selector, | |||
60 | m_name = fileName; | 61 | m_name = fileName; |
62 | |||
61 | initVars(); | 63 | initVars(); |
64 | |||
62 | m_mode = mode; | 65 | m_mode = mode; |
@@ -65,3 +68,2 @@ OFileSelector::OFileSelector( QWidget *wid, int mode, int selector, | |||
65 | init(); | 68 | init(); |
66 | //QTimer::singleShot(6*1000, this, SLOT( slotTest() ) ); | ||
67 | } | 69 | } |
@@ -73,2 +75,3 @@ OFileSelector::OFileSelector(const QString &mimeFilter, QWidget *parent, | |||
73 | { | 75 | { |
76 | /* update the mimefilter */ | ||
74 | if (!mimeFilter.isEmpty() ) { | 77 | if (!mimeFilter.isEmpty() ) { |
@@ -156,2 +159,3 @@ void OFileSelector::setToolbarVisible( bool 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 ){ |
@@ -634,22 +638,2 @@ void OFileSelector::initVars() | |||
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() |
@@ -731,2 +715,3 @@ void OFileSelector::initializeChooser() | |||
731 | m_viewCheck->insertItem( tr("All Files") ); | 715 | m_viewCheck->insertItem( tr("All Files") ); |
716 | /* update to custom views */ | ||
732 | updateMimeCheck(); | 717 | updateMimeCheck(); |
@@ -816,28 +801,4 @@ void OFileSelector::initializeListView() | |||
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 ); |
@@ -851,3 +812,2 @@ void OFileSelector::initializePerm() | |||
851 | m_lay->addWidget( m_checkPerm ); | 812 | m_lay->addWidget( m_checkPerm ); |
852 | |||
853 | } | 813 | } |
@@ -859,2 +819,3 @@ void OFileSelector::initPics() | |||
859 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 819 | QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
820 | |||
860 | QPainter painter( &pm ); | 821 | QPainter painter( &pm ); |
@@ -918,6 +879,2 @@ bool OFileSelector::compliesMime( const QString& mime ) { | |||
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 | ||
@@ -947,107 +904,4 @@ void OFileSelector::slotFileBridgeSelected( const DocLnk &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 | 905 | ||
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 | 906 | ||
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 | |||
1048 | } | ||
1049 | void OFileSelector::slotRename() | ||
1050 | { | ||
1051 | reparse(); | ||
1052 | } | ||
1053 | void OFileSelector::slotDelete() | 907 | void OFileSelector::slotDelete() |
@@ -1103,6 +957,5 @@ void OFileSelector::reparse() | |||
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) |
@@ -1111,2 +964,3 @@ void OFileSelector::reparse() | |||
1111 | QString currentMimeType; | 964 | QString currentMimeType; |
965 | |||
1112 | // let's update the mimetype | 966 | // let's update the mimetype |
@@ -1120,21 +974,4 @@ void OFileSelector::reparse() | |||
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 ); | ||
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 | 976 | ||
1138 | ++it; | ||
1139 | } | ||
1140 | // add them to the chooser | 977 | // add them to the chooser |
@@ -1147,6 +984,5 @@ void OFileSelector::reparse() | |||
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 | } |
@@ -1154,58 +990,7 @@ void OFileSelector::reparse() | |||
1154 | 990 | ||
1155 | QDir dir( m_currentDir ); | 991 | currentLister()->reparse( m_currentDir ); |
992 | /* we're done with adding let's sort */ | ||
993 | currentView()->sort(); | ||
1156 | 994 | ||
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 | 995 | ||
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 ){ |
@@ -1254,2 +1039,3 @@ void OFileSelector::internChangedDir( const QString& s) { | |||
1254 | emit dirSelected( s ); | 1039 | emit dirSelected( s ); |
1040 | cd(s ); | ||
1255 | } | 1041 | } |
@@ -1262 +1048,4 @@ QPixmap OFileSelector::pixmap( const QString& s ) { | |||
1262 | } | 1048 | } |
1049 | OLister* OFileSelector::currentLister()const { | ||
1050 | return 0l; | ||
1051 | } | ||