summaryrefslogtreecommitdiff
Unidiff
Diffstat (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
@@ -81,154 +81,157 @@ void AdvancedFm::cleanUp() {
81} 81}
82 82
83void AdvancedFm::tabChanged(QWidget *) { 83void AdvancedFm::tabChanged(QWidget *) {
84// qWarning("tab changed"); 84// qWarning("tab changed");
85 QString path = CurrentDir()->canonicalPath(); 85 QString path = CurrentDir()->canonicalPath();
86 currentPathCombo->lineEdit()->setText( path ); 86 currentPathCombo->lineEdit()->setText( path );
87 87
88 if(whichTab == 1) { 88 if(whichTab == 1) {
89 viewMenu->setItemChecked(viewMenu->idAt(0), true); 89 viewMenu->setItemChecked(viewMenu->idAt(0), true);
90 viewMenu->setItemChecked(viewMenu->idAt(1), false); 90 viewMenu->setItemChecked(viewMenu->idAt(1), false);
91 } else { 91 } else {
92 viewMenu->setItemChecked(viewMenu->idAt(0), false); 92 viewMenu->setItemChecked(viewMenu->idAt(0), false);
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);
223// populateView(); 226// populateView();
224// } 227// }
225// TabWidget->setCurrentWidget( tmpTab - 1); 228// TabWidget->setCurrentWidget( tmpTab - 1);
226} 229}
227 230
228void AdvancedFm::ListClicked(QListViewItem *selectedItem) { 231void AdvancedFm::ListClicked(QListViewItem *selectedItem) {
229//qWarning("listclicked"); 232//qWarning("listclicked");
230 if(selectedItem) { 233 if(selectedItem) {
231 QString strItem=selectedItem->text(0); 234 QString strItem=selectedItem->text(0);
232// qWarning(strItem); 235// qWarning(strItem);
233 QString strSize=selectedItem->text(1); 236 QString strSize=selectedItem->text(1);
234 strSize=strSize.stripWhiteSpace(); 237 strSize=strSize.stripWhiteSpace();
@@ -788,49 +791,49 @@ QDir *AdvancedFm::OtherDir() {
788 return &currentRemoteDir; 791 return &currentRemoteDir;
789 } else { 792 } else {
790 return &currentDir; 793 return &currentDir;
791 } 794 }
792} 795}
793 796
794QListView * AdvancedFm::CurrentView() { 797QListView * AdvancedFm::CurrentView() {
795 if ( whichTab == 1) { 798 if ( whichTab == 1) {
796// qWarning("CurrentView Tab 1"); 799// qWarning("CurrentView Tab 1");
797 return Local_View; 800 return Local_View;
798 } else { 801 } else {
799// qWarning("CurrentView Tab 2"); 802// qWarning("CurrentView Tab 2");
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 );
825 if ( msg == "openDirectory(QString)" ) { 828 if ( msg == "openDirectory(QString)" ) {
826// qDebug("received"); 829// qDebug("received");
827 QString file; 830 QString file;
828 stream >> file; 831 stream >> file;
829 gotoDirectory( (const QString &) file); 832 gotoDirectory( (const QString &) file);
830 } 833 }
831} 834}
832 835
833void AdvancedFm::setDocument(const QString &file) { 836void AdvancedFm::setDocument(const QString &file) {
834 gotoDirectory( file); 837 gotoDirectory( file);
835 838
836} 839}
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
@@ -133,49 +133,51 @@ protected:
133 133
134protected slots: 134protected slots:
135 void openSearch(); 135 void openSearch();
136 void dirMenuSelected(int); 136 void dirMenuSelected(int);
137 void showFileMenu(); 137 void showFileMenu();
138 void cancelMenuTimer(); 138 void cancelMenuTimer();
139 void homeButtonPushed(); 139 void homeButtonPushed();
140 void docButtonPushed(); 140 void docButtonPushed();
141 void SDButtonPushed(); 141 void SDButtonPushed();
142 void CFButtonPushed(); 142 void CFButtonPushed();
143 void QPEButtonPushed(); 143 void QPEButtonPushed();
144 void upDir(); 144 void upDir();
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();
170 void addCustomDir(); 172 void addCustomDir();
171 void removeCustomDir(); 173 void removeCustomDir();
172 void gotoDirectory(const QString &); 174 void gotoDirectory(const QString &);
173 void navigateToSelected(); 175 void navigateToSelected();
174 void findFile(const QString &); 176 void findFile(const QString &);
175 177
176private slots: 178private slots:
177 void processEnded(OProcess *); 179 void processEnded(OProcess *);
178 void oprocessStderr(OProcess *, char *, int); 180 void oprocessStderr(OProcess *, char *, int);
179 void gotoCustomDir(const QString &); 181 void gotoCustomDir(const QString &);
180 void qcopReceive(const QCString&, const QByteArray&); 182 void qcopReceive(const QCString&, const QByteArray&);
181 void setDocument(const QString &); 183 void setDocument(const QString &);
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
@@ -47,61 +47,61 @@
47 47
48 48
49void AdvancedFm::doDirChange() { 49void AdvancedFm::doDirChange() {
50 QString pathItem = CurrentView()->currentItem()->text(0); 50 QString pathItem = CurrentView()->currentItem()->text(0);
51 if( pathItem == "../") { 51 if( pathItem == "../") {
52 ListClicked( CurrentView()->currentItem()); 52 ListClicked( CurrentView()->currentItem());
53 } else { 53 } else {
54 if( pathItem.find(" -> ",0,TRUE) != -1) 54 if( pathItem.find(" -> ",0,TRUE) != -1)
55 pathItem = dealWithSymName((const QString&)pathItem)+"/"; 55 pathItem = dealWithSymName((const QString&)pathItem)+"/";
56// qWarning(pathItem); 56// qWarning(pathItem);
57 gotoDirectory( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) ); 57 gotoDirectory( CurrentDir()->path()+"/"+pathItem.left( pathItem.length() - 1) );
58 } 58 }
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
96 QString curFile = CurrentView()->currentItem()->text(0); 96 QString curFile = CurrentView()->currentItem()->text(0);
97 QString path = thisDir->canonicalPath(); 97 QString path = thisDir->canonicalPath();
98 98
99 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink 99 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
100 100
101 curFile = dealWithSymName((const QString&)curFile); 101 curFile = dealWithSymName((const QString&)curFile);
102 102
103 if(curFile != "../") { 103 if(curFile != "../") {
104 104
105 fs = getFileSystemType((const QString &) path); 105 fs = getFileSystemType((const QString &) path);
106 QFileInfo fileInfo( path + "/" + curFile); 106 QFileInfo fileInfo( path + "/" + curFile);
107// qDebug( fileInfo.owner()); 107// qDebug( fileInfo.owner());
@@ -125,181 +125,181 @@ void AdvancedFm::runThis() {
125 } 125 }
126} 126}
127 127
128void AdvancedFm::runText() { 128void AdvancedFm::runText() {
129 if( !CurrentView()->currentItem()) return; 129 if( !CurrentView()->currentItem()) return;
130 QString curFile = CurrentView()->currentItem()->text(0); 130 QString curFile = CurrentView()->currentItem()->text(0);
131 if(curFile != "../") { 131 if(curFile != "../") {
132 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink 132 if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink
133 curFile = dealWithSymName((const QString&)curFile); 133 curFile = dealWithSymName((const QString&)curFile);
134 curFile = CurrentDir()->canonicalPath()+"/"+curFile; 134 curFile = CurrentDir()->canonicalPath()+"/"+curFile;
135 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); 135 QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
136 e << curFile; 136 e << curFile;
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) )
162 { 162 {
163 case 0: 163 case 0:
164 doMsg=false; 164 doMsg=false;
165 break; 165 break;
166 case 1: 166 case 1:
167 return; 167 return;
168 break; 168 break;
169 }; 169 };
170 } 170 }
171 171
172 QString myFile; 172 QString myFile;
173 173
174 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 174 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
175 myFile = (*it); 175 myFile = (*it);
176 if( myFile.find(" -> ",0,TRUE) != -1) 176 if( myFile.find(" -> ",0,TRUE) != -1)
177 myFile = myFile.left( myFile.find(" -> ",0,TRUE)); 177 myFile = myFile.left( myFile.find(" -> ",0,TRUE));
178 178
179 QString f = CurrentDir()->canonicalPath(); 179 QString f = CurrentDir()->canonicalPath();
180 if(f.right(1).find("/",0,TRUE) == -1) 180 if(f.right(1).find("/",0,TRUE) == -1)
181 f += "/"; 181 f += "/";
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) ) {
207 case 1: 207 case 1:
208 return; 208 return;
209 break; 209 break;
210 }; 210 };
211 } 211 }
212 212
213 QString cmd="rm "+f; 213 QString cmd="rm "+f;
214 QFile file(f); 214 QFile file(f);
215 QFileInfo fi(myFile); 215 QFileInfo fi(myFile);
216 if( fi.fileName().find("../",0,TRUE)==-1) { 216 if( fi.fileName().find("../",0,TRUE)==-1) {
217// qDebug("remove link files "+myFile); 217// qDebug("remove link files "+myFile);
218 218
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
261 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 261 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
262// qDebug((filePath+*it)); 262// qDebug((filePath+*it));
263 DocLnk lnk( (filePath+*it)); 263 DocLnk lnk( (filePath+*it));
264 LnkProperties prop( &lnk ); 264 LnkProperties prop( &lnk );
265 prop.showMaximized(); 265 prop.showMaximized();
266 prop.exec(); 266 prop.exec();
267 } 267 }
268#endif 268#endif
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();
294 if( count > 0) { 294 if( count > 0) {
295 if(count > 1 ){ 295 if(count > 1 ){
296 QString msg; 296 QString msg;
297 msg=tr("Really copy\n%1 files?").arg(count); 297 msg=tr("Really copy\n%1 files?").arg(count);
298 switch ( QMessageBox::warning(this,tr("Copy"),msg 298 switch ( QMessageBox::warning(this,tr("Copy"),msg
299 ,tr("Yes"),tr("No"),0,0,1) ) 299 ,tr("Yes"),tr("No"),0,0,1) )
300 { 300 {
301 case 0: 301 case 0:
302 doMsg=false; 302 doMsg=false;
303 break; 303 break;
304 case 1: 304 case 1:
305 return; 305 return;
@@ -318,196 +318,244 @@ void AdvancedFm::copy() {
318 318
319// qDebug("Destination file is "+destFile); 319// qDebug("Destination file is "+destFile);
320// qDebug("CurrentFile file is " + curFile); 320// qDebug("CurrentFile file is " + curFile);
321 321
322 QFile f(destFile); 322 QFile f(destFile);
323 if( f.exists()) { 323 if( f.exists()) {
324 if(doMsg) { 324 if(doMsg) {
325 switch ( QMessageBox::warning(this,tr("File Exists!"), 325 switch ( QMessageBox::warning(this,tr("File Exists!"),
326 tr("%1 exists. Ok to overwrite?").arg( item ), 326 tr("%1 exists. Ok to overwrite?").arg( item ),
327 tr("Yes"),tr("No"),0,0,1) ) { 327 tr("Yes"),tr("No"),0,0,1) ) {
328 case 1: 328 case 1:
329 return; 329 return;
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();
356 356
357 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 357 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
358 QString destFile; 358 QString destFile;
359 item=(*it); 359 item=(*it);
360 curFile = thisDir->canonicalPath()+"/"+(*it); 360 curFile = thisDir->canonicalPath()+"/"+(*it);
361 fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0); 361 fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0);
362 362
363 fileDlg->setInputText((const QString &) destFile ); 363 fileDlg->setInputText((const QString &) destFile );
364 fileDlg->exec(); 364 fileDlg->exec();
365 365
366 if( fileDlg->result() == 1 ) { 366 if( fileDlg->result() == 1 ) {
367 QString filename = fileDlg->LineEdit1->text(); 367 QString filename = fileDlg->LineEdit1->text();
368 destFile = thatDir->canonicalPath()+"/"+filename; 368 destFile = thatDir->canonicalPath()+"/"+filename;
369 369
370 QFile f( destFile); 370 QFile f( destFile);
371 if( f.exists()) { 371 if( f.exists()) {
372 switch (QMessageBox::warning(this,tr("File Exists!"), 372 switch (QMessageBox::warning(this,tr("File Exists!"),
373 item+tr("\nexists. Ok to overwrite?"), 373 item+tr("\nexists. Ok to overwrite?"),
374 tr("Yes"),tr("No"),0,0,1) ) { 374 tr("Yes"),tr("No"),0,0,1) ) {
375 case 0: 375 case 0:
376 f.remove(); 376 f.remove();
377 break; 377 break;
378 case 1: 378 case 1:
379 return; 379 return;
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);
406 curFile = thisDir->canonicalPath()+"/"+ item; 406 curFile = thisDir->canonicalPath()+"/"+ item;
407 407
408 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); 408 fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
409 fileDlg->setInputText((const QString &) destFile ); 409 fileDlg->setInputText((const QString &) destFile );
410 fileDlg->exec(); 410 fileDlg->exec();
411 411
412 if( fileDlg->result() == 1 ) { 412 if( fileDlg->result() == 1 ) {
413 413
414 QString filename = fileDlg->LineEdit1->text(); 414 QString filename = fileDlg->LineEdit1->text();
415 destFile = thisDir->canonicalPath()+"/"+filename; 415 destFile = thisDir->canonicalPath()+"/"+filename;
416 416
417 QFile f(destFile); 417 QFile f(destFile);
418 if( f.exists()) { 418 if( f.exists()) {
419 switch (QMessageBox::warning(this,tr("Delete"), 419 switch (QMessageBox::warning(this,tr("Delete"),
420 destFile+tr(" already exists.\nDo you really want to delete it?"), 420 destFile+tr(" already exists.\nDo you really want to delete it?"),
421 tr("Yes"),tr("No"),0,0,1) ) { 421 tr("Yes"),tr("No"),0,0,1) ) {
422 case 0: 422 case 0:
423 423
424 f.remove(); 424 f.remove();
425 break; 425 break;
426 case 1: 426 case 1:
427 return; 427 return;
428 break; 428 break;
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");
502 return success = false; 550 return success = false;
503 } 551 }
504 write_fd = destFile.handle(); 552 write_fd = destFile.handle();
505 if(write_fd != -1) { 553 if(write_fd != -1) {
506 err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size); 554 err = sendfile(write_fd, read_fd, &offset, stat_buf.st_size);
507 if( err == -1) { 555 if( err == -1) {
508 QString msg; 556 QString msg;
509 switch(err) { 557 switch(err) {
510 case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; 558 case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. ";
511 case EINVAL: msg = "Descriptor is not valid or locked. "; 559 case EINVAL: msg = "Descriptor is not valid or locked. ";
512 case ENOMEM: msg = "Insufficient memory to read from in_fd."; 560 case ENOMEM: msg = "Insufficient memory to read from in_fd.";
513 case EIO: msg = "Unspecified error while reading from in_fd."; 561 case EIO: msg = "Unspecified error while reading from in_fd.";
@@ -612,51 +660,51 @@ void AdvancedFm::del() {
612void AdvancedFm::mkSym() { 660void AdvancedFm::mkSym() {
613 QString cmd; 661 QString cmd;
614 QStringList curFileList = getPath(); 662 QStringList curFileList = getPath();
615 if( curFileList.count() > 0) { 663 if( curFileList.count() > 0) {
616 QDir *thisDir = CurrentDir(); 664 QDir *thisDir = CurrentDir();
617 QDir * thatDir = OtherDir(); 665 QDir * thatDir = OtherDir();
618 666
619 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { 667 for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
620 668
621 QString destName = thatDir->canonicalPath()+"/"+(*it); 669 QString destName = thatDir->canonicalPath()+"/"+(*it);
622 if(destName.right(1) == "/") { 670 if(destName.right(1) == "/") {
623 destName = destName.left( destName.length() -1); 671 destName = destName.left( destName.length() -1);
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) == "/") {
651 curFilePath = curFilePath.left( curFilePath.length() -1); 699 curFilePath = curFilePath.left( curFilePath.length() -1);
652 } 700 }
653 Ir *file = new Ir(this, "IR"); 701 Ir *file = new Ir(this, "IR");
654 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); 702 connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
655 file->send( curFilePath, curFile ); 703 file->send( curFilePath, curFile );
656 } 704 }
657 } 705 }
658 } 706 }
659} 707}
660 708
661void AdvancedFm::fileBeamFinished( Ir *) { 709void AdvancedFm::fileBeamFinished( Ir *) {
662 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); 710 QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") );
@@ -666,49 +714,49 @@ void AdvancedFm::selectAll() {
666 QListView *thisView = CurrentView(); 714 QListView *thisView = CurrentView();
667 thisView->selectAll(true); 715 thisView->selectAll(true);
668 thisView->setSelected( thisView->firstChild(),false); 716 thisView->setSelected( thisView->firstChild(),false);
669} 717}
670 718
671void AdvancedFm::startProcess(const QString & cmd) { 719void AdvancedFm::startProcess(const QString & cmd) {
672 QStringList command; 720 QStringList command;
673 OProcess *process; 721 OProcess *process;
674 process = new OProcess(); 722 process = new OProcess();
675 connect(process, SIGNAL(processExited(OProcess *)), 723 connect(process, SIGNAL(processExited(OProcess *)),
676 this, SLOT( processEnded(OProcess *))); 724 this, SLOT( processEnded(OProcess *)));
677 725
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 ) {
703 QKeyEvent *ke = (QKeyEvent*)e; 751 QKeyEvent *ke = (QKeyEvent*)e;
704 if ( ke->key() == Key_Return || 752 if ( ke->key() == Key_Return ||
705 ke->key() == Key_Enter ) { 753 ke->key() == Key_Enter ) {
706 okRename(); 754 okRename();
707 return true; 755 return true;
708 } 756 }
709 else if ( ke->key() == Key_Escape ) { 757 else if ( ke->key() == Key_Escape ) {
710 cancelRename(); 758 cancelRename();
711 return true; 759 return true;
712 } 760 }
713 } 761 }
714 else if ( e->type() == QEvent::FocusOut ) { 762 else if ( e->type() == QEvent::FocusOut ) {
@@ -754,49 +802,49 @@ void AdvancedFm::doRename(QListView * view) {
754 r.setX( view->contentsX() ); 802 r.setX( view->contentsX() );
755 if ( r.width() > view->visibleWidth() ) 803 if ( r.width() > view->visibleWidth() )
756 r.setWidth( view->visibleWidth() ); 804 r.setWidth( view->visibleWidth() );
757 805
758 renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); 806 renameBox = new QLineEdit( view->viewport(), "qt_renamebox" );
759 renameBox->setFrame(true); 807 renameBox->setFrame(true);
760 808
761 renameBox->setText( view->currentItem()->text(0) ); 809 renameBox->setText( view->currentItem()->text(0) );
762 810
763 renameBox->selectAll(); 811 renameBox->selectAll();
764 renameBox->installEventFilter( this ); 812 renameBox->installEventFilter( this );
765 view->addChild( renameBox, r.x(), r.y() ); 813 view->addChild( renameBox, r.x(), r.y() );
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}