summaryrefslogtreecommitdiff
path: root/noncore
authorllornkcor <llornkcor>2003-11-07 12:37:57 (UTC)
committer llornkcor <llornkcor>2003-11-07 12:37:57 (UTC)
commitfa1e47631442d509e9c1603684bdc9e9590cf866 (patch) (unidiff)
tree5411adf72ccde8c46b13b0487a2602609b081d9e /noncore
parent82fdb639058354177d27b432f97e8750ac846ee6 (diff)
downloadopie-fa1e47631442d509e9c1603684bdc9e9590cf866.zip
opie-fa1e47631442d509e9c1603684bdc9e9590cf866.tar.gz
opie-fa1e47631442d509e9c1603684bdc9e9590cf866.tar.bz2
from 1.0, needs fix
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.cpp201
-rw-r--r--noncore/apps/advancedfm/advancedfm.h4
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp114
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
@@ -93,130 +93,133 @@ void AdvancedFm::tabChanged(QWidget *) {
93 viewMenu->setItemChecked(viewMenu->idAt(1), true); 93 viewMenu->setItemChecked(viewMenu->idAt(1), true);
94 } 94 }
95 95
96 QString fs= getFileSystemType( (const QString &) path); 96 QString fs= getFileSystemType( (const QString &) path);
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
104void AdvancedFm::populateView() { 104void 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()) { 106qWarning("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" ); 112qWarning("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
213void AdvancedFm::rePopulate() { 216void AdvancedFm::rePopulate() {
214 populateView(); 217 populateView();
215 setOtherTabCurrent(); 218 setOtherTabCurrent();
216 populateView(); 219 populateView();
217 220
218// int tmpTab = whichTab; 221// int tmpTab = whichTab;
219// // qDebug("%d", tmpTab); 222// // qDebug("%d", tmpTab);
220 223
221// for(int i =1; i < 3; i++) { 224// for(int i =1; i < 3; i++) {
222// TabWidget->setCurrentWidget(i - 1); 225// TabWidget->setCurrentWidget(i - 1);
@@ -800,25 +803,25 @@ QListView * AdvancedFm::CurrentView() {
800 return Remote_View; 803 return Remote_View;
801 } 804 }
802} 805}
803 806
804QListView * AdvancedFm::OtherView() { 807QListView * 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
811void AdvancedFm::setOtherTabCurrent() { 814void 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}
821 824
822void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) { 825void AdvancedFm::qcopReceive(const QCString &msg, const QByteArray &data) {
823// qDebug("qcop message "+msg ); 826// qDebug("qcop message "+msg );
824 QDataStream stream ( data, IO_ReadOnly ); 827 QDataStream stream ( data, IO_ReadOnly );
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
@@ -145,25 +145,27 @@ protected slots:
145 void currentPathComboChanged(); 145 void currentPathComboChanged();
146 void copy(); 146 void copy();
147 void copyAs(); 147 void copyAs();
148 void copySameDir(); 148 void copySameDir();
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
160private: 162private:
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 * );
166 void cancelRename(); 168 void cancelRename();
167 void doRename(QListView *); 169 void doRename(QListView *);
168 void okRename(); 170 void okRename();
169 void customDirsToMenu(); 171 void customDirsToMenu();
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
@@ -59,37 +59,37 @@ void AdvancedFm::doDirChange() {
59} 59}
60 60
61void AdvancedFm::showMenuHidden() { 61void AdvancedFm::showMenuHidden() {
62 if (b) { 62 if (b) {
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
75void AdvancedFm::showHidden() { 75void 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
86QString AdvancedFm::dealWithSymName(const QString &fileName) { 86QString 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
91void AdvancedFm::runThis() { 91void AdvancedFm::runThis() {
92 if( !CurrentView()->currentItem()) return; 92 if( !CurrentView()->currentItem()) return;
93 QString fs; 93 QString fs;
94 QDir *thisDir = CurrentDir(); 94 QDir *thisDir = CurrentDir();
95 95
@@ -137,25 +137,25 @@ void AdvancedFm::runText() {
137 } 137 }
138} 138}
139 139
140void AdvancedFm::makeDir() { 140void 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
152void AdvancedFm::doDelete() { 152void 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 ) {
158 QString msg; 158 QString msg;
159 msg=tr("Really delete\n%1 files?").arg(count); 159 msg=tr("Really delete\n%1 files?").arg(count);
160 switch ( QMessageBox::warning(this,tr("Delete"),msg 160 switch ( QMessageBox::warning(this,tr("Delete"),msg
161 ,tr("Yes"),tr("No"),0,0,1) ) 161 ,tr("Yes"),tr("No"),0,0,1) )
@@ -182,25 +182,25 @@ void AdvancedFm::doDelete() {
182 f += myFile; 182 f += myFile;
183 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { 183 if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
184 //if file is a directory 184 //if file is a directory
185 185
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 {
203 if(doMsg) { 203 if(doMsg) {
204 switch ( QMessageBox::warning(this,tr("Delete"), 204 switch ( QMessageBox::warning(this,tr("Delete"),
205 tr("Really delete\n%1?").arg( myFile ), 205 tr("Really delete\n%1?").arg( myFile ),
206 tr("Yes"), tr("No"), 0, 0, 1) ) { 206 tr("Yes"), tr("No"), 0, 0, 1) ) {
@@ -219,42 +219,42 @@ void AdvancedFm::doDelete() {
219// DocLnk lnk(f); 219// DocLnk lnk(f);
220 DocLnk *lnk; 220 DocLnk *lnk;
221 lnk = new DocLnk(f); 221 lnk = new DocLnk(f);
222// qDebug("Deleting doclnk " + lnk->linkFile()); 222// qDebug("Deleting doclnk " + lnk->linkFile());
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
234void AdvancedFm::filePerms() { 234void 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
251void AdvancedFm::doProperties() { 251void 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;
257 filePath = CurrentDir()->canonicalPath()+"/"; 257 filePath = CurrentDir()->canonicalPath()+"/";
258 258
259// qDebug("%d",curFileList.count()); 259// qDebug("%d",curFileList.count());
260 260
@@ -269,25 +269,25 @@ void AdvancedFm::doProperties() {
269 269
270} 270}
271 271
272void AdvancedFm::upDir() { 272void 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
285void AdvancedFm::copy() { 285void 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();
290 QDir *thatDir = OtherDir(); 290 QDir *thatDir = OtherDir();
291 291
292 bool doMsg=true; 292 bool doMsg=true;
293 int count=curFileList.count(); 293 int count=curFileList.count();
@@ -330,26 +330,26 @@ void AdvancedFm::copy() {
330 break; 330 break;
331 }; 331 };
332 } 332 }
333 f.remove(); 333 f.remove();
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
347void AdvancedFm::copyAs() { 347void 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;
352 InputDialog *fileDlg; 352 InputDialog *fileDlg;
353 353
354 QDir *thisDir = CurrentDir(); 354 QDir *thisDir = CurrentDir();
355 QDir *thatDir = OtherDir(); 355 QDir *thatDir = OtherDir();
@@ -380,26 +380,26 @@ void AdvancedFm::copyAs() {
380 break; 380 break;
381 }; 381 };
382 } 382 }
383 if( !copyFile( curFile, destFile) ) { 383 if( !copyFile( curFile, destFile) ) {
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
396void AdvancedFm::copySameDir() { 396void 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
402 QDir *thisDir = CurrentDir(); 402 QDir *thisDir = CurrentDir();
403 403
404 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 404 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
405 item=(*it); 405 item=(*it);
@@ -429,73 +429,121 @@ void AdvancedFm::copySameDir() {
429 }; 429 };
430 } 430 }
431 if(!copyFile( curFile,destFile) ) { 431 if(!copyFile( curFile,destFile) ) {
432 QMessageBox::message("AdvancedFm",tr("Could not copy\n") 432 QMessageBox::message("AdvancedFm",tr("Could not copy\n")
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
444void AdvancedFm::move() { 444void 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;
450 450
451 QDir *thisDir = CurrentDir(); 451 QDir *thisDir = CurrentDir();
452 QDir *thatDir = OtherDir(); 452 QDir *thatDir = OtherDir();
453 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 453 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
454 item=(*it); 454 item=(*it);
455 QString destFile = thatDir->canonicalPath(); 455 QString destFile = thatDir->canonicalPath();
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
489bool 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
503bool 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
483bool AdvancedFm::copyFile( const QString & src, const QString & dest ) { 518bool 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();
498 if(read_fd != -1) { 546 if(read_fd != -1) {
499 fstat (read_fd, &stat_buf); 547 fstat (read_fd, &stat_buf);
500 if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { 548 if( !destFile.open( IO_WriteOnly|IO_Raw ) ) {
501// qWarning("destfile open failed"); 549// qWarning("destfile open failed");
@@ -624,27 +672,27 @@ void AdvancedFm::mkSym() {
624 } 672 }
625 673
626 QString curFile = thisDir->canonicalPath()+"/"+(*it); 674 QString curFile = thisDir->canonicalPath()+"/"+(*it);
627 675
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
641void AdvancedFm::doBeam() { 689void 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) {
647 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 695 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
648 QString curFile = (*it); 696 QString curFile = (*it);
649 QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; 697 QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile;
650 if( curFilePath.right(1) == "/") { 698 if( curFilePath.right(1) == "/") {
@@ -678,25 +726,25 @@ void AdvancedFm::startProcess(const QString & cmd) {
678 connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)), 726 connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)),
679 this, SLOT( oprocessStderr(OProcess *, char *, int))); 727 this, SLOT( oprocessStderr(OProcess *, char *, int)));
680 728
681 command << "/bin/sh"; 729 command << "/bin/sh";
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
689void AdvancedFm::processEnded(OProcess *) { 737void AdvancedFm::processEnded(OProcess *) {
690 populateView(); 738 rePopulate();
691} 739}
692 740
693void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int ) { 741void 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}
699 747
700bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) { 748bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) {
701 if ( o->inherits( "QLineEdit" ) ) { 749 if ( o->inherits( "QLineEdit" ) ) {
702 if ( e->type() == QEvent::KeyPress ) { 750 if ( e->type() == QEvent::KeyPress ) {
@@ -766,37 +814,37 @@ void AdvancedFm::doRename(QListView * view) {
766 renameBox->resize( r.size() ); 814 renameBox->resize( r.size() );
767 view->viewport()->setFocusProxy( renameBox ); 815 view->viewport()->setFocusProxy( renameBox );
768 renameBox->setFocus(); 816 renameBox->setFocus();
769 renameBox->show(); 817 renameBox->show();
770} 818}
771 819
772 820
773void AdvancedFm::renameIt() { 821void 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
781void AdvancedFm::okRename() { 829void 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() + "/";
787 oldName = path + oldName; 835 oldName = path + oldName;
788 newName = path + newName; 836 newName = path + newName;
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
800void AdvancedFm::openSearch() { 848void AdvancedFm::openSearch() {
801 QMessageBox::message(tr("Note"),tr("Not Yet Implemented")); 849 QMessageBox::message(tr("Note"),tr("Not Yet Implemented"));
802} 850}