-rw-r--r-- | noncore/apps/advancedfm/advancedfm.cpp | 201 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfm.h | 4 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 114 |
3 files changed, 186 insertions, 133 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.cpp b/noncore/apps/advancedfm/advancedfm.cpp index 2fc4b49..ecf471d 100644 --- a/noncore/apps/advancedfm/advancedfm.cpp +++ b/noncore/apps/advancedfm/advancedfm.cpp | |||
@@ -97,122 +97,125 @@ void AdvancedFm::tabChanged(QWidget *) { | |||
97 | 97 | ||
98 | setCaption(tr("AdvancedFm :: ")+fs+" :: " | 98 | setCaption(tr("AdvancedFm :: ")+fs+" :: " |
99 | +checkDiskSpace( (const QString &) path )+ tr(" kB free") ); | 99 | +checkDiskSpace( (const QString &) path )+ tr(" kB free") ); |
100 | chdir( path.latin1()); | 100 | chdir( path.latin1()); |
101 | } | 101 | } |
102 | 102 | ||
103 | 103 | ||
104 | void AdvancedFm::populateView() { | 104 | void AdvancedFm::populateView() { |
105 | QPixmap pm; | ||
106 | QListView *thisView = CurrentView(); | ||
107 | QDir *thisDir = CurrentDir(); | ||
108 | QString path = thisDir->canonicalPath(); | ||
109 | // qWarning("path is "+path); | ||
110 | thisView->clear(); | ||
111 | thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | ||
112 | thisDir->setMatchAllDirs(TRUE); | ||
113 | thisDir->setNameFilter(filterStr); | ||
114 | QString fileL, fileS, fileDate; | ||
115 | QString fs= getFileSystemType((const QString &) path); | ||
116 | setCaption(tr("AdvancedFm :: ")+fs+" :: " | ||
117 | +checkDiskSpace((const QString &) path)+ tr(" kB free") ); | ||
118 | bool isDir=FALSE; | ||
119 | const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | ||
120 | QFileInfoListIterator it(*list); | ||
121 | QFileInfo *fi; | ||
122 | while ( (fi=it.current()) ) { | ||
123 | if (fi->isSymLink() ) { | ||
124 | QString symLink=fi->readLink(); | ||
125 | QFileInfo sym( symLink); | ||
126 | fileS.sprintf( "%10i", sym.size() ); | ||
127 | fileL = fi->fileName() +" -> " + sym.filePath().data(); | ||
128 | fileDate = sym.lastModified().toString(); | ||
129 | } else { | ||
130 | fileS.sprintf( "%10i", fi->size() ); | ||
131 | fileL = fi->fileName(); | ||
132 | fileDate= fi->lastModified().toString(); | ||
133 | if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { | ||
134 | // if(fileL == "..") | ||
135 | fileL += "/"; | ||
136 | isDir=TRUE; | ||
137 | } | ||
138 | } | ||
139 | QFileInfo fileInfo( path + "/" + fileL); | ||
140 | 105 | ||
141 | if(fileL !="./" && fi->exists()) { | 106 | qWarning("PopulateView"); |
142 | item = new QListViewItem( thisView, fileL, fileS , fileDate); | 107 | QPixmap pm; |
143 | 108 | QListView *thisView = CurrentView(); | |
144 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 109 | QDir *thisDir = CurrentDir(); |
145 | 110 | QString path = thisDir->canonicalPath(); | |
146 | if( !QDir( fi->filePath() ).isReadable()) //is directory | 111 | |
147 | pm = Resource::loadPixmap( "lockedfolder" ); | 112 | qWarning("path is "+path); |
148 | else | 113 | thisView->clear(); |
149 | pm= Resource::loadPixmap( "folder" ); | 114 | thisDir->setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
150 | } | 115 | thisDir->setMatchAllDirs(TRUE); |
151 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 116 | thisDir->setNameFilter(filterStr); |
152 | pm = Resource::loadPixmap( "exec"); | 117 | QString fileL, fileS, fileDate; |
153 | } | 118 | QString fs= getFileSystemType((const QString &) path); |
154 | else if( (fileInfo.permission( QFileInfo::ExeUser) | 119 | setCaption(tr("AdvancedFm :: ")+fs+" :: " |
155 | | fileInfo.permission( QFileInfo::ExeGroup) | 120 | +checkDiskSpace((const QString &) path)+ tr(" kB free") ); |
156 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { | 121 | bool isDir=FALSE; |
157 | pm = Resource::loadPixmap( "exec"); | 122 | const QFileInfoList *list = thisDir->entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
158 | } | 123 | QFileInfoListIterator it(*list); |
159 | else if( !fi->isReadable() ) { | 124 | QFileInfo *fi; |
160 | pm = Resource::loadPixmap( "locked" ); | 125 | while ( (fi=it.current()) ) { |
161 | } | 126 | if (fi->isSymLink() ) { |
162 | else { //everything else goes by mimetype | 127 | QString symLink=fi->readLink(); |
163 | MimeType mt(fi->filePath()); | 128 | QFileInfo sym( symLink); |
164 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | 129 | fileS.sprintf( "%10i", sym.size() ); |
165 | if(pm.isNull()) { | 130 | fileL = fi->fileName() +" -> " + sym.filePath().data(); |
166 | pm = unknownXpm; | 131 | fileDate = sym.lastModified().toString(); |
167 | } | 132 | } else { |
168 | } | 133 | fileS.sprintf( "%10i", fi->size() ); |
169 | if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { | 134 | fileL = fi->fileName(); |
170 | // qDebug(" overlay link image"); | 135 | fileDate= fi->lastModified().toString(); |
171 | pm= Resource::loadPixmap( "advancedfm/symlink" ); | 136 | if( QDir(QDir::cleanDirPath( path +"/"+fileL)).exists() ) { |
172 | // pm= Resource::loadPixmap( "folder" ); | 137 | // if(fileL == "..") |
138 | fileL += "/"; | ||
139 | isDir=TRUE; | ||
140 | } | ||
141 | } | ||
142 | QFileInfo fileInfo( path + "/" + fileL); | ||
143 | |||
144 | if(fileL !="./" && fi->exists()) { | ||
145 | item = new QListViewItem( thisView, fileL, fileS , fileDate); | ||
146 | |||
147 | if(isDir || fileL.find("/",0,TRUE) != -1) { | ||
148 | |||
149 | if( !QDir( fi->filePath() ).isReadable()) //is directory | ||
150 | pm = Resource::loadPixmap( "lockedfolder" ); | ||
151 | else | ||
152 | pm= Resource::loadPixmap( "folder" ); | ||
153 | } | ||
154 | else if ( fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | ||
155 | pm = Resource::loadPixmap( "exec"); | ||
156 | } | ||
157 | else if( (fileInfo.permission( QFileInfo::ExeUser) | ||
158 | | fileInfo.permission( QFileInfo::ExeGroup) | ||
159 | | fileInfo.permission( QFileInfo::ExeOther)) && fs != "vfat" ) { | ||
160 | pm = Resource::loadPixmap( "exec"); | ||
161 | } | ||
162 | else if( !fi->isReadable() ) { | ||
163 | pm = Resource::loadPixmap( "locked" ); | ||
164 | } | ||
165 | else { //everything else goes by mimetype | ||
166 | MimeType mt(fi->filePath()); | ||
167 | pm=mt.pixmap(); //sets the correct pixmap for mimetype | ||
168 | if(pm.isNull()) { | ||
169 | pm = unknownXpm; | ||
170 | } | ||
171 | } | ||
172 | if( fi->isSymLink() || fileL.find("->",0,TRUE) != -1) { | ||
173 | // qDebug(" overlay link image"); | ||
174 | pm= Resource::loadPixmap( "advancedfm/symlink" ); | ||
175 | // pm= Resource::loadPixmap( "folder" ); | ||
173 | // QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); | 176 | // QPixmap lnk = Resource::loadPixmap( "opie/symlink" ); |
174 | // QPainter painter( &pm ); | 177 | // QPainter painter( &pm ); |
175 | // painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | 178 | // painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
176 | // pm.setMask( pm.createHeuristicMask( FALSE ) ); | 179 | // pm.setMask( pm.createHeuristicMask( FALSE ) ); |
177 | } | 180 | } |
178 | item->setPixmap( 0,pm); | 181 | item->setPixmap( 0,pm); |
179 | 182 | ||
180 | } | 183 | } |
181 | isDir=FALSE; | 184 | isDir=FALSE; |
182 | ++it; | 185 | ++it; |
183 | } | 186 | } |
184 | 187 | ||
185 | if( path.find("dev",0,TRUE) != -1) { | 188 | if( path.find("dev",0,TRUE) != -1) { |
186 | struct stat buf; | 189 | struct stat buf; |
187 | dev_t devT; | 190 | dev_t devT; |
188 | DIR *dir; | 191 | DIR *dir; |
189 | struct dirent *mydirent; | 192 | struct dirent *mydirent; |
190 | 193 | ||
191 | if((dir = opendir( path.latin1())) != NULL) | 194 | if((dir = opendir( path.latin1())) != NULL) |
192 | while ((mydirent = readdir(dir)) != NULL) { | 195 | while ((mydirent = readdir(dir)) != NULL) { |
193 | lstat( mydirent->d_name, &buf); | 196 | lstat( mydirent->d_name, &buf); |
194 | // qDebug(mydirent->d_name); | 197 | // qDebug(mydirent->d_name); |
195 | fileL.sprintf("%s", mydirent->d_name); | 198 | fileL.sprintf("%s", mydirent->d_name); |
196 | devT = buf.st_dev; | 199 | devT = buf.st_dev; |
197 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); | 200 | fileS.sprintf("%d, %d", (int) ( devT >>8) &0xFF, (int)devT &0xFF); |
198 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); | 201 | fileDate.sprintf("%s", ctime( &buf.st_mtime)); |
199 | if( fileL.find(".") == -1 ) { | 202 | if( fileL.find(".") == -1 ) { |
200 | item= new QListViewItem( thisView, fileL, fileS, fileDate); | 203 | item= new QListViewItem( thisView, fileL, fileS, fileDate); |
201 | pm = unknownXpm; | 204 | pm = unknownXpm; |
202 | item->setPixmap( 0,pm); | 205 | item->setPixmap( 0,pm); |
203 | } | 206 | } |
204 | } | 207 | } |
205 | 208 | ||
206 | closedir(dir); | 209 | closedir(dir); |
207 | } | 210 | } |
208 | 211 | ||
209 | thisView->setSorting( 3,FALSE); | 212 | thisView->setSorting( 3,FALSE); |
210 | fillCombo( (const QString &) path ); | 213 | fillCombo( (const QString &) path ); |
211 | } | 214 | } |
212 | 215 | ||
213 | void AdvancedFm::rePopulate() { | 216 | void AdvancedFm::rePopulate() { |
214 | populateView(); | 217 | populateView(); |
215 | setOtherTabCurrent(); | 218 | setOtherTabCurrent(); |
216 | populateView(); | 219 | populateView(); |
217 | 220 | ||
218 | // int tmpTab = whichTab; | 221 | // int tmpTab = whichTab; |
@@ -804,17 +807,17 @@ QListView * AdvancedFm::CurrentView() { | |||
804 | QListView * AdvancedFm::OtherView() { | 807 | QListView * AdvancedFm::OtherView() { |
805 | if ( whichTab == 1) | 808 | if ( whichTab == 1) |
806 | return Remote_View; | 809 | return Remote_View; |
807 | else | 810 | else |
808 | return Local_View; | 811 | return Local_View; |
809 | } | 812 | } |
810 | 813 | ||
811 | void AdvancedFm::setOtherTabCurrent() { | 814 | void AdvancedFm::setOtherTabCurrent() { |
812 | // qWarning("setOtherTabCurrent()"); | 815 | qWarning("setOtherTabCurrent() %d", whichTab); |
813 | if ( whichTab == 1) { | 816 | if ( whichTab == 1) { |
814 | TabWidget->setCurrentWidget(1); | 817 | TabWidget->setCurrentWidget(1); |
815 | } else { | 818 | } else { |
816 | TabWidget->setCurrentWidget(0); | 819 | TabWidget->setCurrentWidget(0); |
817 | } | 820 | } |
818 | OtherView()->setFocus(); | 821 | OtherView()->setFocus(); |
819 | OtherView()->setSelected( CurrentView()->firstChild(), true); | 822 | OtherView()->setSelected( CurrentView()->firstChild(), true); |
820 | } | 823 | } |
diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h index 5f6eabb..be574c4 100644 --- a/noncore/apps/advancedfm/advancedfm.h +++ b/noncore/apps/advancedfm/advancedfm.h | |||
@@ -149,17 +149,19 @@ protected slots: | |||
149 | void currentPathComboActivated(const QString &); | 149 | void currentPathComboActivated(const QString &); |
150 | void fillCombo(const QString &); | 150 | void fillCombo(const QString &); |
151 | bool copyFile( const QString & , const QString & ); | 151 | bool copyFile( const QString & , const QString & ); |
152 | void move(); | 152 | void move(); |
153 | void fileStatus(); | 153 | void fileStatus(); |
154 | void doAbout(); | 154 | void doAbout(); |
155 | void doBeam(); | 155 | void doBeam(); |
156 | void fileBeamFinished( Ir *); | 156 | void fileBeamFinished( Ir *); |
157 | 157 | bool copyDirectory( const QString & , const QString & ); | |
158 | // void navigateToSelected(); | ||
159 | bool moveDirectory( const QString & , const QString & ); | ||
158 | // void slotSwitchtoLocal(int); | 160 | // void slotSwitchtoLocal(int); |
159 | 161 | ||
160 | private: | 162 | private: |
161 | MenuButton *menuButton; | 163 | MenuButton *menuButton; |
162 | QString oldName; | 164 | QString oldName; |
163 | QTimer menuTimer; | 165 | QTimer menuTimer; |
164 | void startProcess(const QString &); | 166 | void startProcess(const QString &); |
165 | bool eventFilter( QObject * , QEvent * ); | 167 | bool eventFilter( QObject * , QEvent * ); |
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index c0be948..90c887f 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -63,29 +63,29 @@ void AdvancedFm::showMenuHidden() { | |||
63 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 63 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
64 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 64 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
65 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 65 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
66 | } else { | 66 | } else { |
67 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 67 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
68 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 68 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
69 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 69 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
70 | } | 70 | } |
71 | rePopulate(); | ||
72 | b = !b; | 71 | b = !b; |
72 | populateView(); | ||
73 | } | 73 | } |
74 | 74 | ||
75 | void AdvancedFm::showHidden() { | 75 | void AdvancedFm::showHidden() { |
76 | if (b) { | 76 | if (b) { |
77 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 77 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
78 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 78 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
79 | } else { | 79 | } else { |
80 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 80 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
81 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 81 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
82 | } | 82 | } |
83 | rePopulate(); | 83 | populateView(); |
84 | } | 84 | } |
85 | 85 | ||
86 | QString AdvancedFm::dealWithSymName(const QString &fileName) { | 86 | QString AdvancedFm::dealWithSymName(const QString &fileName) { |
87 | QString strItem = fileName; | 87 | QString strItem = fileName; |
88 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 88 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
89 | } | 89 | } |
90 | 90 | ||
91 | void AdvancedFm::runThis() { | 91 | void AdvancedFm::runThis() { |
@@ -141,17 +141,17 @@ void AdvancedFm::makeDir() { | |||
141 | InputDialog *fileDlg; | 141 | InputDialog *fileDlg; |
142 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 142 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
143 | fileDlg->exec(); | 143 | fileDlg->exec(); |
144 | if( fileDlg->result() == 1 ) { | 144 | if( fileDlg->result() == 1 ) { |
145 | QDir *thisDir = CurrentDir(); | 145 | QDir *thisDir = CurrentDir(); |
146 | QString filename = fileDlg->LineEdit1->text(); | 146 | QString filename = fileDlg->LineEdit1->text(); |
147 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); | 147 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); |
148 | } | 148 | } |
149 | populateView(); | 149 | populateView(); |
150 | } | 150 | } |
151 | 151 | ||
152 | void AdvancedFm::doDelete() { | 152 | void AdvancedFm::doDelete() { |
153 | QStringList curFileList = getPath(); | 153 | QStringList curFileList = getPath(); |
154 | bool doMsg=true; | 154 | bool doMsg=true; |
155 | int count = curFileList.count(); | 155 | int count = curFileList.count(); |
156 | if( count > 0) { | 156 | if( count > 0) { |
157 | if(count > 1 ) { | 157 | if(count > 1 ) { |
@@ -186,17 +186,17 @@ void AdvancedFm::doDelete() { | |||
186 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), | 186 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), |
187 | tr("Really delete %1\nand all it's contents ?" ).arg( f ) , | 187 | tr("Really delete %1\nand all it's contents ?" ).arg( f ) , |
188 | tr("Yes"), tr("No"), 0, 0, 1) ) { | 188 | tr("Yes"), tr("No"), 0, 0, 1) ) { |
189 | case 0: | 189 | case 0: |
190 | { | 190 | { |
191 | f=f.left(f.length()-1); | 191 | f=f.left(f.length()-1); |
192 | QString cmd="rm -rf "+f; | 192 | QString cmd="rm -rf "+f; |
193 | startProcess( (const QString)cmd.latin1() ); | 193 | startProcess( (const QString)cmd.latin1() ); |
194 | populateView(); | 194 | populateView(); |
195 | } | 195 | } |
196 | break; | 196 | break; |
197 | case 1: | 197 | case 1: |
198 | // exit | 198 | // exit |
199 | break; | 199 | break; |
200 | }; | 200 | }; |
201 | 201 | ||
202 | } else { | 202 | } else { |
@@ -223,34 +223,34 @@ void AdvancedFm::doDelete() { | |||
223 | if(lnk->isValid()) | 223 | if(lnk->isValid()) |
224 | lnk->removeLinkFile(); | 224 | lnk->removeLinkFile(); |
225 | // delete lnk; | 225 | // delete lnk; |
226 | file.remove(); | 226 | file.remove(); |
227 | } | 227 | } |
228 | } | 228 | } |
229 | } | 229 | } |
230 | } | 230 | } |
231 | populateView(); | 231 | populateView(); |
232 | } | 232 | } |
233 | 233 | ||
234 | void AdvancedFm::filePerms() { | 234 | void AdvancedFm::filePerms() { |
235 | QStringList curFileList = getPath(); | 235 | QStringList curFileList = getPath(); |
236 | QString filePath; | 236 | QString filePath; |
237 | 237 | ||
238 | filePath = CurrentDir()->canonicalPath()+"/"; | 238 | filePath = CurrentDir()->canonicalPath()+"/"; |
239 | 239 | ||
240 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 240 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
241 | filePermissions *filePerm; | 241 | filePermissions *filePerm; |
242 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | 242 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); |
243 | filePerm->showMaximized(); | 243 | filePerm->showMaximized(); |
244 | filePerm->exec(); | 244 | filePerm->exec(); |
245 | if( filePerm) | 245 | if( filePerm) |
246 | delete filePerm; | 246 | delete filePerm; |
247 | } | 247 | } |
248 | populateView(); | 248 | populateView(); |
249 | } | 249 | } |
250 | 250 | ||
251 | void AdvancedFm::doProperties() { | 251 | void AdvancedFm::doProperties() { |
252 | #if defined(QT_QWS_OPIE) | 252 | #if defined(QT_QWS_OPIE) |
253 | 253 | ||
254 | QStringList curFileList = getPath(); | 254 | QStringList curFileList = getPath(); |
255 | 255 | ||
256 | QString filePath; | 256 | QString filePath; |
@@ -273,17 +273,17 @@ void AdvancedFm::upDir() { | |||
273 | QDir *thisDir = CurrentDir(); | 273 | QDir *thisDir = CurrentDir(); |
274 | QString current = thisDir->canonicalPath(); | 274 | QString current = thisDir->canonicalPath(); |
275 | QDir dir(current); | 275 | QDir dir(current); |
276 | dir.cdUp(); | 276 | dir.cdUp(); |
277 | current = dir.canonicalPath(); | 277 | current = dir.canonicalPath(); |
278 | chdir( current.latin1() ); | 278 | chdir( current.latin1() ); |
279 | thisDir->cd( current, TRUE); | 279 | thisDir->cd( current, TRUE); |
280 | 280 | ||
281 | populateView(); | 281 | populateView(); |
282 | update(); | 282 | update(); |
283 | } | 283 | } |
284 | 284 | ||
285 | void AdvancedFm::copy() { | 285 | void AdvancedFm::copy() { |
286 | qApp->processEvents(); | 286 | qApp->processEvents(); |
287 | QStringList curFileList = getPath(); | 287 | QStringList curFileList = getPath(); |
288 | 288 | ||
289 | QDir *thisDir = CurrentDir(); | 289 | QDir *thisDir = CurrentDir(); |
@@ -334,18 +334,18 @@ void AdvancedFm::copy() { | |||
334 | } | 334 | } |
335 | 335 | ||
336 | if( !copyFile( curFile, destFile) ) { | 336 | if( !copyFile( curFile, destFile) ) { |
337 | QMessageBox::message("AdvancedFm", | 337 | QMessageBox::message("AdvancedFm", |
338 | tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); | 338 | tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); |
339 | return; | 339 | return; |
340 | } | 340 | } |
341 | } | 341 | } |
342 | rePopulate(); | 342 | setOtherTabCurrent(); |
343 | setOtherTabCurrent(); | 343 | rePopulate(); |
344 | } | 344 | } |
345 | } | 345 | } |
346 | 346 | ||
347 | void AdvancedFm::copyAs() { | 347 | void AdvancedFm::copyAs() { |
348 | qApp->processEvents(); | 348 | qApp->processEvents(); |
349 | 349 | ||
350 | QStringList curFileList = getPath(); | 350 | QStringList curFileList = getPath(); |
351 | QString curFile, item; | 351 | QString curFile, item; |
@@ -384,18 +384,18 @@ void AdvancedFm::copyAs() { | |||
384 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 384 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
385 | +curFile +tr("to\n")+destFile); | 385 | +curFile +tr("to\n")+destFile); |
386 | return; | 386 | return; |
387 | } | 387 | } |
388 | } | 388 | } |
389 | delete fileDlg; | 389 | delete fileDlg; |
390 | 390 | ||
391 | } | 391 | } |
392 | rePopulate(); | 392 | rePopulate(); |
393 | setOtherTabCurrent(); | 393 | setOtherTabCurrent(); |
394 | } | 394 | } |
395 | 395 | ||
396 | void AdvancedFm::copySameDir() { | 396 | void AdvancedFm::copySameDir() { |
397 | qApp->processEvents(); | 397 | qApp->processEvents(); |
398 | QStringList curFileList = getPath(); | 398 | QStringList curFileList = getPath(); |
399 | QString curFile, item, destFile; | 399 | QString curFile, item, destFile; |
400 | InputDialog *fileDlg; | 400 | InputDialog *fileDlg; |
401 | 401 | ||
@@ -433,17 +433,17 @@ void AdvancedFm::copySameDir() { | |||
433 | +curFile +tr("to\n")+destFile); | 433 | +curFile +tr("to\n")+destFile); |
434 | return; | 434 | return; |
435 | } | 435 | } |
436 | 436 | ||
437 | // qDebug("copy "+curFile+" as "+destFile); | 437 | // qDebug("copy "+curFile+" as "+destFile); |
438 | } | 438 | } |
439 | delete fileDlg; | 439 | delete fileDlg; |
440 | } | 440 | } |
441 | populateView(); | 441 | rePopulate(); |
442 | } | 442 | } |
443 | 443 | ||
444 | void AdvancedFm::move() { | 444 | void AdvancedFm::move() { |
445 | qApp->processEvents(); | 445 | qApp->processEvents(); |
446 | 446 | ||
447 | QStringList curFileList = getPath(); | 447 | QStringList curFileList = getPath(); |
448 | if( curFileList.count() > 0) { | 448 | if( curFileList.count() > 0) { |
449 | QString curFile, destFile, item; | 449 | QString curFile, destFile, item; |
@@ -456,42 +456,90 @@ void AdvancedFm::move() { | |||
456 | 456 | ||
457 | if(destFile.right(1).find("/",0,TRUE) == -1) | 457 | if(destFile.right(1).find("/",0,TRUE) == -1) |
458 | destFile+="/"; | 458 | destFile+="/"; |
459 | destFile += item; | 459 | destFile += item; |
460 | // qDebug("Destination file is "+destFile); | 460 | // qDebug("Destination file is "+destFile); |
461 | 461 | ||
462 | curFile = thisDir->canonicalPath(); | 462 | curFile = thisDir->canonicalPath(); |
463 | if(curFile.right(1).find("/",0,TRUE) == -1) | 463 | if(curFile.right(1).find("/",0,TRUE) == -1) |
464 | curFile +="/"; | 464 | curFile +="/"; |
465 | curFile+= item; | 465 | curFile+= item; |
466 | // qDebug("CurrentFile file is " + curFile); | 466 | // qDebug("CurrentFile file is " + curFile); |
467 | 467 | ||
468 | QFile f( curFile); | 468 | if(QFileInfo(curFile).isDir()) { |
469 | moveDirectory( curFile, destFile ); | ||
470 | rePopulate(); | ||
471 | return; | ||
472 | } | ||
473 | |||
474 | QFile f( curFile); | ||
469 | if( f.exists()) { | 475 | if( f.exists()) { |
470 | if( !copyFile( curFile, destFile) ) { | 476 | if( !copyFile( curFile, destFile) ) { |
471 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); | 477 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); |
472 | return; | 478 | return; |
473 | } else | 479 | } else |
474 | QFile::remove(curFile); | 480 | QFile::remove(curFile); |
475 | } | 481 | } |
476 | } | 482 | } |
477 | 483 | ||
478 | } | 484 | } |
479 | rePopulate(); | 485 | rePopulate(); |
480 | setOtherTabCurrent(); | 486 | setOtherTabCurrent(); |
487 | } | ||
488 | |||
489 | bool AdvancedFm::moveDirectory( const QString & src, const QString & dest ) { | ||
490 | int err = 0; | ||
491 | if( copyDirectory( src, dest ) ) { QString cmd = "rm -rf " + src; | ||
492 | err = system((const char*)cmd); | ||
493 | } else | ||
494 | err = -1; | ||
495 | |||
496 | if(err!=0) { | ||
497 | QMessageBox::message(tr("Note"),tr("Could not move\n") + src); | ||
498 | return false; | ||
499 | } | ||
500 | return true; | ||
481 | } | 501 | } |
482 | 502 | ||
503 | bool AdvancedFm::copyDirectory( const QString & src, const QString & dest ) { | ||
504 | |||
505 | QStringcmd = "/bin/cp -fpR " + src + " " + dest; | ||
506 | qWarning(cmd); | ||
507 | interr = system( (const char *) cmd ); | ||
508 | if ( err != 0 ) { | ||
509 | QMessageBox::message("AdvancedFm", | ||
510 | tr( "Could not copy \n%1 \nto \n%2").arg( src ).arg( dest ) ); | ||
511 | return false; | ||
512 | } | ||
513 | |||
514 | return true; | ||
515 | } | ||
516 | |||
517 | |||
483 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { | 518 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { |
484 | bool success = true; | 519 | |
485 | struct stat status; | 520 | |
486 | QFile srcFile(src); | 521 | if(QFileInfo(src).isDir()) { |
487 | QFile destFile(dest); | 522 | if( copyDirectory( src, dest )) { |
488 | int err=0; | 523 | setOtherTabCurrent(); |
489 | int read_fd=0; | 524 | populateView(); |
525 | return true; | ||
526 | } | ||
527 | else | ||
528 | return false; | ||
529 | } | ||
530 | |||
531 | |||
532 | bool success = true; | ||
533 | struct stat status; | ||
534 | QFile srcFile(src); | ||
535 | QFile destFile(dest); | ||
536 | int err=0; | ||
537 | int read_fd=0; | ||
490 | int write_fd=0; | 538 | int write_fd=0; |
491 | struct stat stat_buf; | 539 | struct stat stat_buf; |
492 | off_t offset = 0; | 540 | off_t offset = 0; |
493 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { | 541 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { |
494 | // qWarning("open failed"); | 542 | // qWarning("open failed"); |
495 | return success = false; | 543 | return success = false; |
496 | } | 544 | } |
497 | read_fd = srcFile.handle(); | 545 | read_fd = srcFile.handle(); |
@@ -628,19 +676,19 @@ void AdvancedFm::mkSym() { | |||
628 | if( curFile.right(1) == "/") { | 676 | if( curFile.right(1) == "/") { |
629 | curFile = curFile.left( curFile.length() -1); | 677 | curFile = curFile.left( curFile.length() -1); |
630 | } | 678 | } |
631 | 679 | ||
632 | cmd = "ln -s "+curFile+" "+destName; | 680 | cmd = "ln -s "+curFile+" "+destName; |
633 | // qDebug(cmd); | 681 | // qDebug(cmd); |
634 | startProcess( (const QString)cmd ); | 682 | startProcess( (const QString)cmd ); |
635 | } | 683 | } |
636 | rePopulate(); | 684 | rePopulate(); |
637 | setOtherTabCurrent(); | 685 | setOtherTabCurrent(); |
638 | } | 686 | } |
639 | } | 687 | } |
640 | 688 | ||
641 | void AdvancedFm::doBeam() { | 689 | void AdvancedFm::doBeam() { |
642 | Ir ir; | 690 | Ir ir; |
643 | if(!ir.supported()) { | 691 | if(!ir.supported()) { |
644 | } else { | 692 | } else { |
645 | QStringList curFileList = getPath(); | 693 | QStringList curFileList = getPath(); |
646 | if( curFileList.count() > 0) { | 694 | if( curFileList.count() > 0) { |
@@ -682,17 +730,17 @@ void AdvancedFm::startProcess(const QString & cmd) { | |||
682 | command << "-c"; | 730 | command << "-c"; |
683 | command << cmd.latin1(); | 731 | command << cmd.latin1(); |
684 | *process << command; | 732 | *process << command; |
685 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) | 733 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) |
686 | qDebug("could not start process"); | 734 | qDebug("could not start process"); |
687 | } | 735 | } |
688 | 736 | ||
689 | void AdvancedFm::processEnded(OProcess *) { | 737 | void AdvancedFm::processEnded(OProcess *) { |
690 | populateView(); | 738 | rePopulate(); |
691 | } | 739 | } |
692 | 740 | ||
693 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { | 741 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { |
694 | // qWarning("received stderrt %d bytes", buflen); | 742 | // qWarning("received stderrt %d bytes", buflen); |
695 | 743 | ||
696 | QString lineStr = buffer; | 744 | QString lineStr = buffer; |
697 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); | 745 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); |
698 | } | 746 | } |
@@ -770,17 +818,17 @@ void AdvancedFm::doRename(QListView * view) { | |||
770 | } | 818 | } |
771 | 819 | ||
772 | 820 | ||
773 | void AdvancedFm::renameIt() { | 821 | void AdvancedFm::renameIt() { |
774 | if( !CurrentView()->currentItem()) return; | 822 | if( !CurrentView()->currentItem()) return; |
775 | QListView *thisView = CurrentView(); | 823 | QListView *thisView = CurrentView(); |
776 | oldName = thisView->currentItem()->text(0); | 824 | oldName = thisView->currentItem()->text(0); |
777 | doRename( thisView ); | 825 | doRename( thisView ); |
778 | populateView(); | 826 | rePopulate(); |
779 | } | 827 | } |
780 | 828 | ||
781 | void AdvancedFm::okRename() { | 829 | void AdvancedFm::okRename() { |
782 | if( !CurrentView()->currentItem()) return; | 830 | if( !CurrentView()->currentItem()) return; |
783 | QString newName = renameBox->text(); | 831 | QString newName = renameBox->text(); |
784 | cancelRename(); | 832 | cancelRename(); |
785 | QListView * view = CurrentView(); | 833 | QListView * view = CurrentView(); |
786 | QString path = CurrentDir()->canonicalPath() + "/"; | 834 | QString path = CurrentDir()->canonicalPath() + "/"; |
@@ -789,14 +837,14 @@ void AdvancedFm::okRename() { | |||
789 | 837 | ||
790 | if( rename( oldName.latin1(), newName.latin1())== -1) | 838 | if( rename( oldName.latin1(), newName.latin1())== -1) |
791 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 839 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
792 | else | 840 | else |
793 | oldName = ""; | 841 | oldName = ""; |
794 | 842 | ||
795 | view->takeItem( view->currentItem() ); | 843 | view->takeItem( view->currentItem() ); |
796 | delete view->currentItem(); | 844 | delete view->currentItem(); |
797 | populateView(); | 845 | rePopulate(); |
798 | } | 846 | } |
799 | 847 | ||
800 | void AdvancedFm::openSearch() { | 848 | void AdvancedFm::openSearch() { |
801 | QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); | 849 | QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); |
802 | } | 850 | } |