author | llornkcor <llornkcor> | 2003-07-17 19:51:45 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-07-17 19:51:45 (UTC) |
commit | cf3921fe77f87e94ff821df65bb80b02487a9f9b (patch) (unidiff) | |
tree | f7109c1df836035b73226ac64837c76e467f19a3 | |
parent | 6140e0d6a131ac127ebfc583990cb6ceefdd30ad (diff) | |
download | opie-cf3921fe77f87e94ff821df65bb80b02487a9f9b.zip opie-cf3921fe77f87e94ff821df65bb80b02487a9f9b.tar.gz opie-cf3921fe77f87e94ff821df65bb80b02487a9f9b.tar.bz2 |
show no hidden default. fix for nonfresh after move, via patch. thanks
-rw-r--r-- | noncore/apps/advancedfm/advancedfmData.cpp | 3 | ||||
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 9 |
2 files changed, 6 insertions, 6 deletions
diff --git a/noncore/apps/advancedfm/advancedfmData.cpp b/noncore/apps/advancedfm/advancedfmData.cpp index a120f35..45dc0c4 100644 --- a/noncore/apps/advancedfm/advancedfmData.cpp +++ b/noncore/apps/advancedfm/advancedfmData.cpp | |||
@@ -1,284 +1,285 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | advancedfmData.cpp | 2 | advancedfmData.cpp |
3 | ------------------- | 3 | ------------------- |
4 | ** Created: Mon 09-23-2002 13:24:11 | 4 | ** Created: Mon 09-23-2002 13:24:11 |
5 | copyright : (C) 2002 by ljp | 5 | copyright : (C) 2002 by ljp |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | #include "advancedfm.h" | 12 | #include "advancedfm.h" |
13 | 13 | ||
14 | #include <opie/otabwidget.h> | 14 | #include <opie/otabwidget.h> |
15 | #include <qpe/storage.h> | 15 | #include <qpe/storage.h> |
16 | 16 | ||
17 | #include <qpe/qpeapplication.h> | 17 | #include <qpe/qpeapplication.h> |
18 | #include <qpe/resource.h> | 18 | #include <qpe/resource.h> |
19 | #include <qpe/menubutton.h> | 19 | #include <qpe/menubutton.h> |
20 | 20 | ||
21 | #include <qlayout.h> | 21 | #include <qlayout.h> |
22 | #include <qhbox.h> | 22 | #include <qhbox.h> |
23 | #include <qmenubar.h> | 23 | #include <qmenubar.h> |
24 | #include <qcombobox.h> | 24 | #include <qcombobox.h> |
25 | #include <qtoolbutton.h> | 25 | #include <qtoolbutton.h> |
26 | #include <qlineedit.h> | 26 | #include <qlineedit.h> |
27 | #include <qlistview.h> | 27 | #include <qlistview.h> |
28 | 28 | ||
29 | #include <sys/utsname.h> | 29 | #include <sys/utsname.h> |
30 | 30 | ||
31 | 31 | ||
32 | void AdvancedFm::init() { | 32 | void AdvancedFm::init() { |
33 | #if defined(QT_QWS_OPIE) | 33 | #if defined(QT_QWS_OPIE) |
34 | qDebug("<<<<<<<<<<<<<<<<<<<<<<<< OPIE!!!"); | 34 | qDebug("<<<<<<<<<<<<<<<<<<<<<<<< OPIE!!!"); |
35 | #endif | 35 | #endif |
36 | setCaption( tr( "AdvancedFm" ) ); | 36 | setCaption( tr( "AdvancedFm" ) ); |
37 | 37 | ||
38 | QVBoxLayout *layout = new QVBoxLayout( this ); | 38 | QVBoxLayout *layout = new QVBoxLayout( this ); |
39 | layout->setSpacing( 2); | 39 | layout->setSpacing( 2); |
40 | layout->setMargin( 2); | 40 | layout->setMargin( 2); |
41 | 41 | ||
42 | QMenuBar *menuBar = new QMenuBar(this); | 42 | QMenuBar *menuBar = new QMenuBar(this); |
43 | fileMenu = new QPopupMenu( this ); | 43 | fileMenu = new QPopupMenu( this ); |
44 | viewMenu = new QPopupMenu( this ); | 44 | viewMenu = new QPopupMenu( this ); |
45 | // customDirMenu = new QPopupMenu( this ); | 45 | // customDirMenu = new QPopupMenu( this ); |
46 | 46 | ||
47 | layout->addWidget( menuBar ); | 47 | layout->addWidget( menuBar ); |
48 | 48 | ||
49 | menuBar->insertItem( tr( "File" ), fileMenu); | 49 | menuBar->insertItem( tr( "File" ), fileMenu); |
50 | menuBar->insertItem( tr( "View" ), viewMenu); | 50 | menuBar->insertItem( tr( "View" ), viewMenu); |
51 | 51 | ||
52 | cdUpButton = new QToolButton( 0,"cdUpButton"); | 52 | cdUpButton = new QToolButton( 0,"cdUpButton"); |
53 | cdUpButton->setPixmap(Resource::loadPixmap("up")); | 53 | cdUpButton->setPixmap(Resource::loadPixmap("up")); |
54 | cdUpButton->setAutoRaise( true ); | 54 | cdUpButton->setAutoRaise( true ); |
55 | menuBar->insertItem( cdUpButton ); | 55 | menuBar->insertItem( cdUpButton ); |
56 | 56 | ||
57 | 57 | ||
58 | QHBox *lineBox = new QHBox( this ); | 58 | QHBox *lineBox = new QHBox( this ); |
59 | 59 | ||
60 | qpeDirButton= new QToolButton( 0,"QPEButton"); | 60 | qpeDirButton= new QToolButton( 0,"QPEButton"); |
61 | qpeDirButton->setPixmap( Resource::loadPixmap("launcher/opielogo16x16"));//,"",this,"QPEButton"); | 61 | qpeDirButton->setPixmap( Resource::loadPixmap("launcher/opielogo16x16"));//,"",this,"QPEButton"); |
62 | qpeDirButton->setAutoRaise( true ); | 62 | qpeDirButton->setAutoRaise( true ); |
63 | menuBar->insertItem( qpeDirButton ); | 63 | menuBar->insertItem( qpeDirButton ); |
64 | 64 | ||
65 | cfButton = new QToolButton( 0, "CFButton"); | 65 | cfButton = new QToolButton( 0, "CFButton"); |
66 | cfButton->setPixmap(Resource::loadPixmap("cardmon/pcmcia")); | 66 | cfButton->setPixmap(Resource::loadPixmap("cardmon/pcmcia")); |
67 | cfButton->setAutoRaise( true ); | 67 | cfButton->setAutoRaise( true ); |
68 | menuBar->insertItem( cfButton ); | 68 | menuBar->insertItem( cfButton ); |
69 | 69 | ||
70 | sdButton = new QToolButton( 0, "SDButton"); | 70 | sdButton = new QToolButton( 0, "SDButton"); |
71 | sdButton->setPixmap(Resource::loadPixmap("advancedfm/sdcard")); | 71 | sdButton->setPixmap(Resource::loadPixmap("advancedfm/sdcard")); |
72 | sdButton->setAutoRaise( true ); | 72 | sdButton->setAutoRaise( true ); |
73 | menuBar->insertItem( sdButton ); | 73 | menuBar->insertItem( sdButton ); |
74 | 74 | ||
75 | docButton = new QToolButton( 0,"docsButton"); | 75 | docButton = new QToolButton( 0,"docsButton"); |
76 | docButton->setPixmap(Resource::loadPixmap("DocsIcon")); | 76 | docButton->setPixmap(Resource::loadPixmap("DocsIcon")); |
77 | docButton->setAutoRaise( true ); | 77 | docButton->setAutoRaise( true ); |
78 | menuBar->insertItem( docButton ); | 78 | menuBar->insertItem( docButton ); |
79 | 79 | ||
80 | homeButton = new QToolButton( 0, "homeButton"); | 80 | homeButton = new QToolButton( 0, "homeButton"); |
81 | homeButton->setPixmap(Resource::loadPixmap("home")); | 81 | homeButton->setPixmap(Resource::loadPixmap("home")); |
82 | homeButton->setAutoRaise( true ); | 82 | homeButton->setAutoRaise( true ); |
83 | menuBar->insertItem( homeButton ); | 83 | menuBar->insertItem( homeButton ); |
84 | 84 | ||
85 | fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showMenuHidden() )); | 85 | fileMenu->insertItem( tr( "Show Hidden Files" ), this, SLOT( showMenuHidden() )); |
86 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 86 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
87 | fileMenu->insertSeparator(); | 87 | fileMenu->insertSeparator(); |
88 | fileMenu->insertItem( tr( "File Search" ), this, SLOT( openSearch() )); | 88 | fileMenu->insertItem( tr( "File Search" ), this, SLOT( openSearch() )); |
89 | fileMenu->insertSeparator(); | 89 | fileMenu->insertSeparator(); |
90 | fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() )); | 90 | fileMenu->insertItem( tr( "Make Directory" ), this, SLOT( mkDir() )); |
91 | fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() )); | 91 | fileMenu->insertItem( tr( "Rename" ), this, SLOT( rn() )); |
92 | fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() )); | 92 | fileMenu->insertItem( tr( "Run Command" ), this, SLOT( runCommandStd() )); |
93 | fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() )); | 93 | fileMenu->insertItem( tr( "Run Command with Output" ), this, SLOT( runCommand() )); |
94 | fileMenu->insertSeparator(); | 94 | fileMenu->insertSeparator(); |
95 | fileMenu->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); | 95 | fileMenu->insertItem( tr( "Make Symlink" ), this, SLOT( mkSym() )); |
96 | fileMenu->insertItem( tr( "Select All" ), this, SLOT( selectAll() )); | 96 | fileMenu->insertItem( tr( "Select All" ), this, SLOT( selectAll() )); |
97 | fileMenu->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); | 97 | fileMenu->insertItem( tr( "Add To Documents" ), this, SLOT( addToDocs() )); |
98 | fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() )); | 98 | fileMenu->insertItem( tr( "Delete" ), this, SLOT( del() )); |
99 | fileMenu->setCheckable(TRUE); | 99 | fileMenu->setCheckable(TRUE); |
100 | 100 | ||
101 | viewMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); | 101 | viewMenu->insertItem( tr( "Switch to Local" ), this, SLOT( switchToLocalTab() )); |
102 | viewMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); | 102 | viewMenu->insertItem( tr( "Switch to Remote" ), this, SLOT( switchToRemoteTab() )); |
103 | // viewMenu->insertSeparator(); | 103 | // viewMenu->insertSeparator(); |
104 | // viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); | 104 | // viewMenu->insertItem( tr( "About" ), this, SLOT( doAbout() )); |
105 | viewMenu->setCheckable(TRUE); | 105 | viewMenu->setCheckable(TRUE); |
106 | 106 | ||
107 | s_addBookmark = tr("Bookmark Directory"); | 107 | s_addBookmark = tr("Bookmark Directory"); |
108 | s_removeBookmark = tr("Remove Current Directory from Bookmarks"); | 108 | s_removeBookmark = tr("Remove Current Directory from Bookmarks"); |
109 | 109 | ||
110 | // menuButton->insertItem(""); | 110 | // menuButton->insertItem(""); |
111 | 111 | ||
112 | // customDirMenu->insertItem(tr("Add This Directory")); | 112 | // customDirMenu->insertItem(tr("Add This Directory")); |
113 | // customDirMenu->insertItem(tr("Remove This Directory")); | 113 | // customDirMenu->insertItem(tr("Remove This Directory")); |
114 | // customDirMenu->insertSeparator(); | 114 | // customDirMenu->insertSeparator(); |
115 | 115 | ||
116 | menuButton = new MenuButton( lineBox ); | 116 | menuButton = new MenuButton( lineBox ); |
117 | 117 | ||
118 | menuButton->setUseLabel(false); | 118 | menuButton->setUseLabel(false); |
119 | menuButton->setMaximumWidth( 20 ); | 119 | menuButton->setMaximumWidth( 20 ); |
120 | menuButton->insertItem( s_addBookmark); | 120 | menuButton->insertItem( s_addBookmark); |
121 | menuButton->insertItem( s_removeBookmark); | 121 | menuButton->insertItem( s_removeBookmark); |
122 | menuButton->insertSeparator(); | 122 | menuButton->insertSeparator(); |
123 | 123 | ||
124 | customDirsToMenu(); | 124 | customDirsToMenu(); |
125 | 125 | ||
126 | currentPathCombo = new QComboBox( FALSE, lineBox, "currentPathCombo" ); | 126 | currentPathCombo = new QComboBox( FALSE, lineBox, "currentPathCombo" ); |
127 | currentPathCombo->setEditable(TRUE); | 127 | currentPathCombo->setEditable(TRUE); |
128 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); | 128 | currentPathCombo->lineEdit()->setText( currentDir.canonicalPath()); |
129 | 129 | ||
130 | layout->addWidget( lineBox ); | 130 | layout->addWidget( lineBox ); |
131 | 131 | ||
132 | 132 | ||
133 | TabWidget = new OTabWidget( this, "TabWidget",/* OTabWidget::Global | */OTabWidget::IconTab); | 133 | TabWidget = new OTabWidget( this, "TabWidget",/* OTabWidget::Global | */OTabWidget::IconTab); |
134 | // TabWidget = new QTabWidget( this, "TabWidget" ); | 134 | // TabWidget = new QTabWidget( this, "TabWidget" ); |
135 | layout->addWidget( TabWidget, 4 ); | 135 | layout->addWidget( TabWidget, 4 ); |
136 | 136 | ||
137 | tab = new QWidget( TabWidget, "tab" ); | 137 | tab = new QWidget( TabWidget, "tab" ); |
138 | tabLayout = new QGridLayout( tab ); | 138 | tabLayout = new QGridLayout( tab ); |
139 | tabLayout->setSpacing( 2); | 139 | tabLayout->setSpacing( 2); |
140 | tabLayout->setMargin( 2); | 140 | tabLayout->setMargin( 2); |
141 | 141 | ||
142 | Local_View = new QListView( tab, "Local_View" ); | 142 | Local_View = new QListView( tab, "Local_View" ); |
143 | Local_View->addColumn( tr("File"),130); | 143 | Local_View->addColumn( tr("File"),130); |
144 | Local_View->addColumn( tr("Size"),-1); | 144 | Local_View->addColumn( tr("Size"),-1); |
145 | Local_View->setColumnAlignment(1,QListView::AlignRight); | 145 | Local_View->setColumnAlignment(1,QListView::AlignRight); |
146 | Local_View->addColumn( tr("Date"),-1); | 146 | Local_View->addColumn( tr("Date"),-1); |
147 | Local_View->setColumnAlignment(2,QListView::AlignRight); | 147 | Local_View->setColumnAlignment(2,QListView::AlignRight); |
148 | Local_View->setAllColumnsShowFocus(TRUE); | 148 | Local_View->setAllColumnsShowFocus(TRUE); |
149 | Local_View->setMultiSelection( TRUE ); | 149 | Local_View->setMultiSelection( TRUE ); |
150 | Local_View->setSelectionMode(QListView::Extended); | 150 | Local_View->setSelectionMode(QListView::Extended); |
151 | 151 | ||
152 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); | 152 | QPEApplication::setStylusOperation( Local_View->viewport(),QPEApplication::RightOnHold); |
153 | 153 | ||
154 | tabLayout->addWidget( Local_View, 0, 0 ); | 154 | tabLayout->addWidget( Local_View, 0, 0 ); |
155 | 155 | ||
156 | TabWidget->addTab( tab,"advancedfm/smFileBrowser.png", tr("1")); | 156 | TabWidget->addTab( tab,"advancedfm/smFileBrowser.png", tr("1")); |
157 | // TabWidget->insertTab( tab, tr("1")); | 157 | // TabWidget->insertTab( tab, tr("1")); |
158 | 158 | ||
159 | tab_2 = new QWidget( TabWidget, "tab_2" ); | 159 | tab_2 = new QWidget( TabWidget, "tab_2" ); |
160 | tabLayout_2 = new QGridLayout( tab_2 ); | 160 | tabLayout_2 = new QGridLayout( tab_2 ); |
161 | tabLayout_2->setSpacing( 2); | 161 | tabLayout_2->setSpacing( 2); |
162 | tabLayout_2->setMargin( 2); | 162 | tabLayout_2->setMargin( 2); |
163 | 163 | ||
164 | Remote_View = new QListView( tab_2, "Remote_View" ); | 164 | Remote_View = new QListView( tab_2, "Remote_View" ); |
165 | Remote_View->addColumn( tr("File"),130); | 165 | Remote_View->addColumn( tr("File"),130); |
166 | Remote_View->addColumn( tr("Size"),-1); | 166 | Remote_View->addColumn( tr("Size"),-1); |
167 | Remote_View->setColumnAlignment(1,QListView::AlignRight); | 167 | Remote_View->setColumnAlignment(1,QListView::AlignRight); |
168 | Remote_View->addColumn( tr("Date"),-1); | 168 | Remote_View->addColumn( tr("Date"),-1); |
169 | Remote_View->setColumnAlignment(2,QListView::AlignRight); | 169 | Remote_View->setColumnAlignment(2,QListView::AlignRight); |
170 | Remote_View->setAllColumnsShowFocus(TRUE); | 170 | Remote_View->setAllColumnsShowFocus(TRUE); |
171 | Remote_View->setMultiSelection( TRUE ); | 171 | Remote_View->setMultiSelection( TRUE ); |
172 | Remote_View->setSelectionMode(QListView::Extended); | 172 | Remote_View->setSelectionMode(QListView::Extended); |
173 | 173 | ||
174 | 174 | ||
175 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); | 175 | QPEApplication::setStylusOperation( Remote_View->viewport(),QPEApplication::RightOnHold); |
176 | 176 | ||
177 | tabLayout_2->addWidget( Remote_View, 0, 0 ); | 177 | tabLayout_2->addWidget( Remote_View, 0, 0 ); |
178 | 178 | ||
179 | TabWidget->addTab( tab_2, "advancedfm/smFileBrowser.png",tr( "2")); | 179 | TabWidget->addTab( tab_2, "advancedfm/smFileBrowser.png",tr( "2")); |
180 | // TabWidget->insertTab( tab_2, tr( "2")); | 180 | // TabWidget->insertTab( tab_2, tr( "2")); |
181 | 181 | ||
182 | /* tab_3 = new QWidget( TabWidget, "tab_3" ); | 182 | /* tab_3 = new QWidget( TabWidget, "tab_3" ); |
183 | tabLayout_3 = new QGridLayout( tab_3 ); | 183 | tabLayout_3 = new QGridLayout( tab_3 ); |
184 | tabLayout_3->setSpacing( 2); | 184 | tabLayout_3->setSpacing( 2); |
185 | tabLayout_3->setMargin( 2); | 185 | tabLayout_3->setMargin( 2); |
186 | 186 | ||
187 | 187 | ||
188 | // OFileDialog fileDialog; | 188 | // OFileDialog fileDialog; |
189 | // fileDialog; | 189 | // fileDialog; |
190 | // fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy | 190 | // fileSelector = new FileSelector( "*",tab_3, "fileselector" , FALSE, FALSE); //buggy |
191 | // fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow"); | 191 | // fileDialog = new OFileDialog("bangalow", tab_3, 4, 2, "Bungalow"); |
192 | // OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/"); | 192 | // OFileSelector fileDialog = new OFileSelector( tab_3, 4, 2,"/"); |
193 | 193 | ||
194 | QListView *fileTree; | 194 | QListView *fileTree; |
195 | fileTree = new QListView( tab_3, "tree" ); | 195 | fileTree = new QListView( tab_3, "tree" ); |
196 | 196 | ||
197 | 197 | ||
198 | tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 ); | 198 | tabLayout_3->addMultiCellWidget( fileTree, 0, 0, 0, 3 ); |
199 | 199 | ||
200 | TabWidget->insertTab( tab_3, tr( "Remote" ) ); | 200 | TabWidget->insertTab( tab_3, tr( "Remote" ) ); |
201 | */ | 201 | */ |
202 | 202 | ||
203 | /////////////// | 203 | /////////////// |
204 | 204 | ||
205 | 205 | ||
206 | struct utsname name; /* check for embedix kernel running on the zaurus*/ | 206 | struct utsname name; /* check for embedix kernel running on the zaurus*/ |
207 | if (uname(&name) != -1) { | 207 | if (uname(&name) != -1) { |
208 | QString release=name.release; | 208 | QString release=name.release; |
209 | if(release.find("embedix",0,TRUE) !=-1) { | 209 | if(release.find("embedix",0,TRUE) !=-1) { |
210 | zaurusDevice=TRUE; | 210 | zaurusDevice=TRUE; |
211 | } else { | 211 | } else { |
212 | zaurusDevice=FALSE; | 212 | zaurusDevice=FALSE; |
213 | } | 213 | } |
214 | } | 214 | } |
215 | 215 | ||
216 | if( !StorageInfo::hasSd() || !StorageInfo::hasMmc()) { | 216 | if( !StorageInfo::hasSd() || !StorageInfo::hasMmc()) { |
217 | qDebug("not have sd"); | 217 | qDebug("not have sd"); |
218 | sdButton->hide(); | 218 | sdButton->hide(); |
219 | } | 219 | } |
220 | if( !StorageInfo::hasCf() ) { | 220 | if( !StorageInfo::hasCf() ) { |
221 | qDebug("not have cf"); | 221 | qDebug("not have cf"); |
222 | cfButton->hide(); | 222 | cfButton->hide(); |
223 | } | 223 | } |
224 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 224 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
225 | currentDir.setPath( QDir::currentDirPath()); | 225 | currentDir.setPath( QDir::currentDirPath()); |
226 | 226 | ||
227 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 227 | currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
228 | currentRemoteDir.setPath( QDir::currentDirPath()); | 228 | currentRemoteDir.setPath( QDir::currentDirPath()); |
229 | 229 | ||
230 | b = TRUE; | 230 | // b = TRUE; |
231 | 231 | ||
232 | filterStr="*"; | 232 | filterStr="*"; |
233 | b=FALSE; | 233 | b=FALSE; |
234 | showMenuHidden(); | ||
234 | TabWidget->setCurrentTab(0); | 235 | TabWidget->setCurrentTab(0); |
235 | 236 | ||
236 | } | 237 | } |
237 | 238 | ||
238 | void AdvancedFm::initConnections() | 239 | void AdvancedFm::initConnections() |
239 | { | 240 | { |
240 | 241 | ||
241 | connect( qApp,SIGNAL( aboutToQuit()), | 242 | connect( qApp,SIGNAL( aboutToQuit()), |
242 | this, SLOT( cleanUp()) ); | 243 | this, SLOT( cleanUp()) ); |
243 | connect( qpeDirButton ,SIGNAL(released()), | 244 | connect( qpeDirButton ,SIGNAL(released()), |
244 | this,SLOT( QPEButtonPushed()) ); | 245 | this,SLOT( QPEButtonPushed()) ); |
245 | connect( cfButton ,SIGNAL(released()), | 246 | connect( cfButton ,SIGNAL(released()), |
246 | this,SLOT( CFButtonPushed()) ); | 247 | this,SLOT( CFButtonPushed()) ); |
247 | connect( sdButton ,SIGNAL(released()), | 248 | connect( sdButton ,SIGNAL(released()), |
248 | this,SLOT( SDButtonPushed()) ); | 249 | this,SLOT( SDButtonPushed()) ); |
249 | connect( cdUpButton ,SIGNAL(released()), | 250 | connect( cdUpButton ,SIGNAL(released()), |
250 | this,SLOT( upDir()) ); | 251 | this,SLOT( upDir()) ); |
251 | connect( docButton,SIGNAL(released()), | 252 | connect( docButton,SIGNAL(released()), |
252 | this,SLOT( docButtonPushed()) ); | 253 | this,SLOT( docButtonPushed()) ); |
253 | connect( homeButton,SIGNAL(released()), | 254 | connect( homeButton,SIGNAL(released()), |
254 | this,SLOT( homeButtonPushed()) ); | 255 | this,SLOT( homeButtonPushed()) ); |
255 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), | 256 | connect( currentPathCombo, SIGNAL( activated( const QString & ) ), |
256 | this, SLOT( currentPathComboActivated( const QString & ) ) ); | 257 | this, SLOT( currentPathComboActivated( const QString & ) ) ); |
257 | 258 | ||
258 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), | 259 | connect( currentPathCombo->lineEdit(),SIGNAL(returnPressed()), |
259 | this,SLOT(currentPathComboChanged())); | 260 | this,SLOT(currentPathComboChanged())); |
260 | 261 | ||
261 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), | 262 | connect( Local_View, SIGNAL( clicked( QListViewItem*)), |
262 | this,SLOT( ListClicked(QListViewItem *)) ); | 263 | this,SLOT( ListClicked(QListViewItem *)) ); |
263 | 264 | ||
264 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 265 | connect( Local_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
265 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); | 266 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); |
266 | 267 | ||
267 | connect( Local_View, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) ); | 268 | connect( Local_View, SIGNAL( selectionChanged() ), SLOT( cancelMenuTimer() ) ); |
268 | 269 | ||
269 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), | 270 | connect( Remote_View, SIGNAL( clicked( QListViewItem*)), |
270 | this,SLOT( ListClicked(QListViewItem *)) ); | 271 | this,SLOT( ListClicked(QListViewItem *)) ); |
271 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 272 | connect( Remote_View, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
272 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); | 273 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); |
273 | 274 | ||
274 | connect( TabWidget,SIGNAL(currentChanged(QWidget *)), | 275 | connect( TabWidget,SIGNAL(currentChanged(QWidget *)), |
275 | this,SLOT(tabChanged(QWidget*))); | 276 | this,SLOT(tabChanged(QWidget*))); |
276 | 277 | ||
277 | connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) ); | 278 | connect( &menuTimer, SIGNAL( timeout() ), SLOT( showFileMenu() ) ); |
278 | 279 | ||
279 | connect( menuButton, SIGNAL( selected(const QString &)), SLOT(gotoCustomDir(const QString&))); | 280 | connect( menuButton, SIGNAL( selected(const QString &)), SLOT(gotoCustomDir(const QString&))); |
280 | // connect( menuButton, SIGNAL( selected( int)), SLOT( dirMenuSelected(int))); | 281 | // connect( menuButton, SIGNAL( selected( int)), SLOT( dirMenuSelected(int))); |
281 | 282 | ||
282 | // connect( customDirMenu, SIGNAL( activated(int)), this, SLOT( dirMenuSelected(int))); | 283 | // connect( customDirMenu, SIGNAL( activated(int)), this, SLOT( dirMenuSelected(int))); |
283 | 284 | ||
284 | } | 285 | } |
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index 00d0e07..544350c 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -1,882 +1,881 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | AdvancedFm.cpp | 2 | AdvancedFm.cpp |
3 | ------------------- | 3 | ------------------- |
4 | ** Created: Sat Mar 9 23:33:09 2002 | 4 | ** Created: Sat Mar 9 23:33:09 2002 |
5 | copyright : (C) 2002 by ljp | 5 | copyright : (C) 2002 by ljp |
6 | email : ljp@llornkcor.com | 6 | email : ljp@llornkcor.com |
7 | * This program is free software; you can redistribute it and/or modify * | 7 | * This program is free software; you can redistribute it and/or modify * |
8 | * it under the terms of the GNU General Public License as published by * | 8 | * it under the terms of the GNU General Public License as published by * |
9 | * the Free Software Foundation; either version 2 of the License, or * | 9 | * the Free Software Foundation; either version 2 of the License, or * |
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | #include "advancedfm.h" | 12 | #include "advancedfm.h" |
13 | #include "output.h" | 13 | #include "output.h" |
14 | #include "filePermissions.h" | 14 | #include "filePermissions.h" |
15 | 15 | ||
16 | #include <opie/otabwidget.h> | 16 | #include <opie/otabwidget.h> |
17 | #include <opie/oprocess.h> | 17 | #include <opie/oprocess.h> |
18 | 18 | ||
19 | #include <qpe/lnkproperties.h> | 19 | #include <qpe/lnkproperties.h> |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
21 | #include <qpe/resource.h> | 21 | #include <qpe/resource.h> |
22 | #include <qpe/qcopenvelope_qws.h> | 22 | #include <qpe/qcopenvelope_qws.h> |
23 | #include <qpe/applnk.h> | 23 | #include <qpe/applnk.h> |
24 | #include <qpe/ir.h> | 24 | #include <qpe/ir.h> |
25 | 25 | ||
26 | #include <qmessagebox.h> | 26 | #include <qmessagebox.h> |
27 | #include <qmultilineedit.h> | 27 | #include <qmultilineedit.h> |
28 | 28 | ||
29 | #include <qstring.h> | 29 | #include <qstring.h> |
30 | 30 | ||
31 | #include <qlayout.h> | 31 | #include <qlayout.h> |
32 | #include <qpixmap.h> | 32 | #include <qpixmap.h> |
33 | #include <qcombobox.h> | 33 | #include <qcombobox.h> |
34 | #include <qpopupmenu.h> | 34 | #include <qpopupmenu.h> |
35 | #include <qtabwidget.h> | 35 | #include <qtabwidget.h> |
36 | #include <qtoolbutton.h> | 36 | #include <qtoolbutton.h> |
37 | #include <qtabwidget.h> | ||
38 | #include <qlineedit.h> | 37 | #include <qlineedit.h> |
39 | #include <qlistview.h> | 38 | #include <qlistview.h> |
40 | 39 | ||
41 | #include <errno.h> | 40 | #include <errno.h> |
42 | #include <stdlib.h> | 41 | #include <stdlib.h> |
43 | #include <unistd.h> | 42 | #include <unistd.h> |
44 | #include <sys/stat.h> | 43 | #include <sys/stat.h> |
45 | #include <dirent.h> | 44 | #include <dirent.h> |
46 | #include <sys/sendfile.h> | 45 | #include <sys/sendfile.h> |
47 | #include <fcntl.h> | 46 | #include <fcntl.h> |
48 | 47 | ||
49 | 48 | ||
50 | void AdvancedFm::doDirChange() | 49 | void AdvancedFm::doDirChange() |
51 | { | 50 | { |
52 | ListClicked( CurrentView()->currentItem()); | 51 | ListClicked( CurrentView()->currentItem()); |
53 | } | 52 | } |
54 | 53 | ||
55 | void AdvancedFm::showMenuHidden() | 54 | void AdvancedFm::showMenuHidden() |
56 | { | 55 | { |
57 | if (b) | 56 | if (b) |
58 | { | 57 | { |
59 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 58 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
60 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 59 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
61 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 60 | fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
62 | // b=FALSE; | 61 | // b=FALSE; |
63 | 62 | ||
64 | } | 63 | } |
65 | else | 64 | else |
66 | { | 65 | { |
67 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 66 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
68 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 67 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
69 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 68 | fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
70 | // b=TRUE; | 69 | // b=TRUE; |
71 | } | 70 | } |
72 | rePopulate(); | 71 | rePopulate(); |
73 | // if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true"); | 72 | // if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true"); |
74 | if(b) b = false; else b = true; | 73 | b = !b; |
75 | } | 74 | } |
76 | 75 | ||
77 | void AdvancedFm::showHidden() | 76 | void AdvancedFm::showHidden() |
78 | { | 77 | { |
79 | if (b) | 78 | if (b) |
80 | { | 79 | { |
81 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 80 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
82 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 81 | OtherDir()->setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
83 | // fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); | 82 | // fileMenu->setItemChecked( fileMenu->idAt(0),TRUE); |
84 | // b=FALSE; | 83 | // b=FALSE; |
85 | 84 | ||
86 | } | 85 | } |
87 | else | 86 | else |
88 | { | 87 | { |
89 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 88 | CurrentDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
90 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); | 89 | OtherDir()->setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All); |
91 | // fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); | 90 | // fileMenu->setItemChecked( fileMenu->idAt(0),FALSE); |
92 | // b=TRUE; | 91 | // b=TRUE; |
93 | } | 92 | } |
94 | rePopulate(); | 93 | rePopulate(); |
95 | } | 94 | } |
96 | 95 | ||
97 | QString AdvancedFm::dealWithSymName(const QString &fileName) | 96 | QString AdvancedFm::dealWithSymName(const QString &fileName) |
98 | { | 97 | { |
99 | QString strItem = fileName; | 98 | QString strItem = fileName; |
100 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); | 99 | return strItem.right( (strItem.length() - strItem.find("->",0,TRUE)) - 4); |
101 | } | 100 | } |
102 | 101 | ||
103 | void AdvancedFm::runThis() | 102 | void AdvancedFm::runThis() |
104 | { | 103 | { |
105 | QString fs; | 104 | QString fs; |
106 | QDir *thisDir = CurrentDir(); | 105 | QDir *thisDir = CurrentDir(); |
107 | 106 | ||
108 | QString curFile = CurrentView()->currentItem()->text(0); | 107 | QString curFile = CurrentView()->currentItem()->text(0); |
109 | QString path = thisDir->canonicalPath(); | 108 | QString path = thisDir->canonicalPath(); |
110 | 109 | ||
111 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 110 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
112 | 111 | ||
113 | curFile = dealWithSymName((const QString&)curFile); | 112 | curFile = dealWithSymName((const QString&)curFile); |
114 | 113 | ||
115 | if(curFile != "../") | 114 | if(curFile != "../") |
116 | { | 115 | { |
117 | 116 | ||
118 | fs = getFileSystemType((const QString &) path); | 117 | fs = getFileSystemType((const QString &) path); |
119 | QFileInfo fileInfo( path + "/" + curFile); | 118 | QFileInfo fileInfo( path + "/" + curFile); |
120 | qDebug( fileInfo.owner()); | 119 | qDebug( fileInfo.owner()); |
121 | 120 | ||
122 | if( (fileInfo.permission( QFileInfo::ExeUser) | 121 | if( (fileInfo.permission( QFileInfo::ExeUser) |
123 | | fileInfo.permission( QFileInfo::ExeGroup) | 122 | | fileInfo.permission( QFileInfo::ExeGroup) |
124 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { | 123 | | fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) { |
125 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { | 124 | | fs == "vfat" && fileInfo.filePath().contains("/bin") ) { |
126 | QCopEnvelope e("QPE/System", "execute(QString)" ); | 125 | QCopEnvelope e("QPE/System", "execute(QString)" ); |
127 | e << curFile; | 126 | e << curFile; |
128 | } | 127 | } |
129 | else | 128 | else |
130 | { | 129 | { |
131 | curFile = path + "/" + curFile; | 130 | curFile = path + "/" + curFile; |
132 | DocLnk nf(curFile); | 131 | DocLnk nf(curFile); |
133 | QString execStr = nf.exec(); | 132 | QString execStr = nf.exec(); |
134 | qDebug( execStr); | 133 | qDebug( execStr); |
135 | if( execStr.isEmpty() ) | 134 | if( execStr.isEmpty() ) |
136 | { | 135 | { |
137 | } | 136 | } |
138 | else | 137 | else |
139 | { | 138 | { |
140 | nf.execute(); | 139 | nf.execute(); |
141 | } | 140 | } |
142 | } | 141 | } |
143 | } | 142 | } |
144 | } | 143 | } |
145 | 144 | ||
146 | void AdvancedFm::runText() | 145 | void AdvancedFm::runText() |
147 | { | 146 | { |
148 | QString curFile = CurrentView()->currentItem()->text(0); | 147 | QString curFile = CurrentView()->currentItem()->text(0); |
149 | if(curFile != "../") | 148 | if(curFile != "../") |
150 | { | 149 | { |
151 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink | 150 | if( curFile.find("@",0,TRUE) !=-1 || curFile.find("->",0,TRUE) !=-1 ) //if symlink |
152 | curFile = dealWithSymName((const QString&)curFile); | 151 | curFile = dealWithSymName((const QString&)curFile); |
153 | curFile = CurrentDir()->canonicalPath()+"/"+curFile; | 152 | curFile = CurrentDir()->canonicalPath()+"/"+curFile; |
154 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); | 153 | QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" ); |
155 | e << curFile; | 154 | e << curFile; |
156 | } | 155 | } |
157 | } | 156 | } |
158 | 157 | ||
159 | void AdvancedFm::makeDir() | 158 | void AdvancedFm::makeDir() |
160 | { | 159 | { |
161 | InputDialog *fileDlg; | 160 | InputDialog *fileDlg; |
162 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); | 161 | fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0); |
163 | fileDlg->exec(); | 162 | fileDlg->exec(); |
164 | if( fileDlg->result() == 1 ) | 163 | if( fileDlg->result() == 1 ) |
165 | { | 164 | { |
166 | QDir *thisDir = CurrentDir(); | 165 | QDir *thisDir = CurrentDir(); |
167 | QString filename = fileDlg->LineEdit1->text(); | 166 | QString filename = fileDlg->LineEdit1->text(); |
168 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); | 167 | thisDir->mkdir( thisDir->canonicalPath()+"/"+filename); |
169 | } | 168 | } |
170 | populateView(); | 169 | populateView(); |
171 | } | 170 | } |
172 | 171 | ||
173 | void AdvancedFm::doDelete() | 172 | void AdvancedFm::doDelete() |
174 | { | 173 | { |
175 | QStringList curFileList = getPath(); | 174 | QStringList curFileList = getPath(); |
176 | bool doMsg=true; | 175 | bool doMsg=true; |
177 | int count = curFileList.count(); | 176 | int count = curFileList.count(); |
178 | if( count > 0) { | 177 | if( count > 0) { |
179 | if(count > 1 ) { | 178 | if(count > 1 ) { |
180 | QString msg; | 179 | QString msg; |
181 | msg=tr("Really delete\n%1 files?").arg(count); | 180 | msg=tr("Really delete\n%1 files?").arg(count); |
182 | switch ( QMessageBox::warning(this,tr("Delete"),msg | 181 | switch ( QMessageBox::warning(this,tr("Delete"),msg |
183 | ,tr("Yes"),tr("No"),0,0,1) ) | 182 | ,tr("Yes"),tr("No"),0,0,1) ) |
184 | { | 183 | { |
185 | case 0: | 184 | case 0: |
186 | doMsg=false; | 185 | doMsg=false; |
187 | break; | 186 | break; |
188 | case 1: | 187 | case 1: |
189 | return; | 188 | return; |
190 | break; | 189 | break; |
191 | }; | 190 | }; |
192 | } | 191 | } |
193 | 192 | ||
194 | QString myFile; | 193 | QString myFile; |
195 | 194 | ||
196 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 195 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
197 | myFile = (*it); | 196 | myFile = (*it); |
198 | if( myFile.find(" -> ",0,TRUE) != -1) | 197 | if( myFile.find(" -> ",0,TRUE) != -1) |
199 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); | 198 | myFile = myFile.left( myFile.find(" -> ",0,TRUE)); |
200 | 199 | ||
201 | QString f = CurrentDir()->canonicalPath(); | 200 | QString f = CurrentDir()->canonicalPath(); |
202 | if(f.right(1).find("/",0,TRUE) == -1) | 201 | if(f.right(1).find("/",0,TRUE) == -1) |
203 | f += "/"; | 202 | f += "/"; |
204 | f += myFile; | 203 | f += myFile; |
205 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { | 204 | if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) { |
206 | //if file is a directory | 205 | //if file is a directory |
207 | 206 | ||
208 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), | 207 | switch ( QMessageBox::warning( this, tr("Delete Directory?"), |
209 | tr("Really delete %1\nand all it's contents ?" ).arg( f ) , | 208 | tr("Really delete %1\nand all it's contents ?" ).arg( f ) , |
210 | tr("Yes"), tr("No"), 0, 0, 1) ) { | 209 | tr("Yes"), tr("No"), 0, 0, 1) ) { |
211 | case 0: | 210 | case 0: |
212 | { | 211 | { |
213 | f=f.left(f.length()-1); | 212 | f=f.left(f.length()-1); |
214 | QString cmd="rm -rf "+f; | 213 | QString cmd="rm -rf "+f; |
215 | startProcess( (const QString)cmd.latin1() ); | 214 | startProcess( (const QString)cmd.latin1() ); |
216 | populateView(); | 215 | populateView(); |
217 | } | 216 | } |
218 | break; | 217 | break; |
219 | case 1: | 218 | case 1: |
220 | // exit | 219 | // exit |
221 | break; | 220 | break; |
222 | }; | 221 | }; |
223 | 222 | ||
224 | } else { | 223 | } else { |
225 | if(doMsg) { | 224 | if(doMsg) { |
226 | switch ( QMessageBox::warning(this,tr("Delete"), | 225 | switch ( QMessageBox::warning(this,tr("Delete"), |
227 | tr("Really delete\n%1?").arg( myFile ), | 226 | tr("Really delete\n%1?").arg( myFile ), |
228 | tr("Yes"), tr("No"), 0, 0, 1) ) { | 227 | tr("Yes"), tr("No"), 0, 0, 1) ) { |
229 | case 1: | 228 | case 1: |
230 | return; | 229 | return; |
231 | break; | 230 | break; |
232 | }; | 231 | }; |
233 | } | 232 | } |
234 | 233 | ||
235 | QString cmd="rm "+f; | 234 | QString cmd="rm "+f; |
236 | QFile file(f); | 235 | QFile file(f); |
237 | QFileInfo fi(myFile); | 236 | QFileInfo fi(myFile); |
238 | if( fi.fileName().find("../",0,TRUE)==-1) { | 237 | if( fi.fileName().find("../",0,TRUE)==-1) { |
239 | qDebug("remove link files "+myFile); | 238 | qDebug("remove link files "+myFile); |
240 | 239 | ||
241 | // DocLnk lnk(f); | 240 | // DocLnk lnk(f); |
242 | DocLnk *lnk; | 241 | DocLnk *lnk; |
243 | lnk = new DocLnk(f); | 242 | lnk = new DocLnk(f); |
244 | qDebug("Deleting doclnk " + lnk->linkFile()); | 243 | qDebug("Deleting doclnk " + lnk->linkFile()); |
245 | if(lnk->isValid()) | 244 | if(lnk->isValid()) |
246 | lnk->removeLinkFile(); | 245 | lnk->removeLinkFile(); |
247 | // delete lnk; | 246 | // delete lnk; |
248 | file.remove(); | 247 | file.remove(); |
249 | } | 248 | } |
250 | } | 249 | } |
251 | } | 250 | } |
252 | } | 251 | } |
253 | populateView(); | 252 | populateView(); |
254 | } | 253 | } |
255 | 254 | ||
256 | void AdvancedFm::filePerms() | 255 | void AdvancedFm::filePerms() |
257 | { | 256 | { |
258 | QStringList curFileList = getPath(); | 257 | QStringList curFileList = getPath(); |
259 | QString filePath; | 258 | QString filePath; |
260 | 259 | ||
261 | filePath = CurrentDir()->canonicalPath()+"/"; | 260 | filePath = CurrentDir()->canonicalPath()+"/"; |
262 | 261 | ||
263 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 262 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
264 | { | 263 | { |
265 | filePermissions *filePerm; | 264 | filePermissions *filePerm; |
266 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); | 265 | filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it)); |
267 | filePerm->showMaximized(); | 266 | filePerm->showMaximized(); |
268 | filePerm->exec(); | 267 | filePerm->exec(); |
269 | if( filePerm) | 268 | if( filePerm) |
270 | delete filePerm; | 269 | delete filePerm; |
271 | } | 270 | } |
272 | populateView(); | 271 | populateView(); |
273 | } | 272 | } |
274 | 273 | ||
275 | void AdvancedFm::doProperties() | 274 | void AdvancedFm::doProperties() |
276 | { | 275 | { |
277 | #if defined(QT_QWS_OPIE) | 276 | #if defined(QT_QWS_OPIE) |
278 | 277 | ||
279 | QStringList curFileList = getPath(); | 278 | QStringList curFileList = getPath(); |
280 | 279 | ||
281 | QString filePath; | 280 | QString filePath; |
282 | filePath = CurrentDir()->canonicalPath()+"/"; | 281 | filePath = CurrentDir()->canonicalPath()+"/"; |
283 | 282 | ||
284 | qDebug("%d",curFileList.count()); | 283 | qDebug("%d",curFileList.count()); |
285 | 284 | ||
286 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 285 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
287 | { | 286 | { |
288 | qDebug((filePath+*it)); | 287 | qDebug((filePath+*it)); |
289 | DocLnk lnk( (filePath+*it)); | 288 | DocLnk lnk( (filePath+*it)); |
290 | LnkProperties prop( &lnk ); | 289 | LnkProperties prop( &lnk ); |
291 | prop.showMaximized(); | 290 | prop.showMaximized(); |
292 | prop.exec(); | 291 | prop.exec(); |
293 | } | 292 | } |
294 | #endif | 293 | #endif |
295 | 294 | ||
296 | } | 295 | } |
297 | 296 | ||
298 | void AdvancedFm::upDir() | 297 | void AdvancedFm::upDir() |
299 | { | 298 | { |
300 | QDir *thisDir = CurrentDir(); | 299 | QDir *thisDir = CurrentDir(); |
301 | QString current = thisDir->canonicalPath(); | 300 | QString current = thisDir->canonicalPath(); |
302 | QDir dir(current); | 301 | QDir dir(current); |
303 | dir.cdUp(); | 302 | dir.cdUp(); |
304 | current = dir.canonicalPath(); | 303 | current = dir.canonicalPath(); |
305 | chdir( current.latin1() ); | 304 | chdir( current.latin1() ); |
306 | thisDir->cd( current, TRUE); | 305 | thisDir->cd( current, TRUE); |
307 | 306 | ||
308 | populateView(); | 307 | populateView(); |
309 | update(); | 308 | update(); |
310 | } | 309 | } |
311 | 310 | ||
312 | void AdvancedFm::copy() | 311 | void AdvancedFm::copy() |
313 | { | 312 | { |
314 | qApp->processEvents(); | 313 | qApp->processEvents(); |
315 | QStringList curFileList = getPath(); | 314 | QStringList curFileList = getPath(); |
316 | 315 | ||
317 | QDir *thisDir = CurrentDir(); | 316 | QDir *thisDir = CurrentDir(); |
318 | QDir *thatDir = OtherDir(); | 317 | QDir *thatDir = OtherDir(); |
319 | 318 | ||
320 | bool doMsg=true; | 319 | bool doMsg=true; |
321 | int count=curFileList.count(); | 320 | int count=curFileList.count(); |
322 | if( count > 0) { | 321 | if( count > 0) { |
323 | if(count > 1 ){ | 322 | if(count > 1 ){ |
324 | QString msg; | 323 | QString msg; |
325 | msg=tr("Really copy\n%1 files?").arg(count); | 324 | msg=tr("Really copy\n%1 files?").arg(count); |
326 | switch ( QMessageBox::warning(this,tr("Copy"),msg | 325 | switch ( QMessageBox::warning(this,tr("Copy"),msg |
327 | ,tr("Yes"),tr("No"),0,0,1) ) | 326 | ,tr("Yes"),tr("No"),0,0,1) ) |
328 | { | 327 | { |
329 | case 0: | 328 | case 0: |
330 | doMsg=false; | 329 | doMsg=false; |
331 | break; | 330 | break; |
332 | case 1: | 331 | case 1: |
333 | return; | 332 | return; |
334 | break; | 333 | break; |
335 | }; | 334 | }; |
336 | } | 335 | } |
337 | 336 | ||
338 | QString curFile, item, destFile; | 337 | QString curFile, item, destFile; |
339 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 338 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
340 | { | 339 | { |
341 | item=(*it); | 340 | item=(*it); |
342 | if(item.find("->",0,TRUE)) //symlink | 341 | if(item.find("->",0,TRUE)) //symlink |
343 | item = item.left(item.find("->",0,TRUE)); | 342 | item = item.left(item.find("->",0,TRUE)); |
344 | 343 | ||
345 | curFile = thisDir->canonicalPath()+"/"+ item; | 344 | curFile = thisDir->canonicalPath()+"/"+ item; |
346 | destFile = thatDir->canonicalPath()+"/"+ item; | 345 | destFile = thatDir->canonicalPath()+"/"+ item; |
347 | 346 | ||
348 | qDebug("Destination file is "+destFile); | 347 | qDebug("Destination file is "+destFile); |
349 | qDebug("CurrentFile file is " + curFile); | 348 | qDebug("CurrentFile file is " + curFile); |
350 | 349 | ||
351 | QFile f(destFile); | 350 | QFile f(destFile); |
352 | if( f.exists()) | 351 | if( f.exists()) |
353 | { | 352 | { |
354 | if(doMsg) | 353 | if(doMsg) |
355 | { | 354 | { |
356 | switch ( QMessageBox::warning(this,tr("File Exists!"), | 355 | switch ( QMessageBox::warning(this,tr("File Exists!"), |
357 | tr("%1 exists. Ok to overwrite?").arg( item ), | 356 | tr("%1 exists. Ok to overwrite?").arg( item ), |
358 | tr("Yes"),tr("No"),0,0,1) ) | 357 | tr("Yes"),tr("No"),0,0,1) ) |
359 | { | 358 | { |
360 | case 1: | 359 | case 1: |
361 | return; | 360 | return; |
362 | break; | 361 | break; |
363 | }; | 362 | }; |
364 | } | 363 | } |
365 | f.remove(); | 364 | f.remove(); |
366 | } | 365 | } |
367 | 366 | ||
368 | if( !copyFile( curFile, destFile) ) { | 367 | if( !copyFile( curFile, destFile) ) { |
369 | QMessageBox::message("AdvancedFm", | 368 | QMessageBox::message("AdvancedFm", |
370 | tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); | 369 | tr( "Could not copy %1 to %2").arg( curFile ).arg( destFile ) ); |
371 | return; | 370 | return; |
372 | } | 371 | } |
373 | } | 372 | } |
374 | setOtherTabCurrent(); | 373 | setOtherTabCurrent(); |
375 | populateView(); | 374 | populateView(); |
376 | } | 375 | } |
377 | } | 376 | } |
378 | 377 | ||
379 | void AdvancedFm::copyAs() | 378 | void AdvancedFm::copyAs() |
380 | { | 379 | { |
381 | qApp->processEvents(); | 380 | qApp->processEvents(); |
382 | 381 | ||
383 | QStringList curFileList = getPath(); | 382 | QStringList curFileList = getPath(); |
384 | QString curFile, item; | 383 | QString curFile, item; |
385 | InputDialog *fileDlg; | 384 | InputDialog *fileDlg; |
386 | 385 | ||
387 | QDir *thisDir = CurrentDir(); | 386 | QDir *thisDir = CurrentDir(); |
388 | QDir *thatDir = OtherDir(); | 387 | QDir *thatDir = OtherDir(); |
389 | 388 | ||
390 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 389 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
391 | { | 390 | { |
392 | QString destFile; | 391 | QString destFile; |
393 | item=(*it); | 392 | item=(*it); |
394 | curFile = thisDir->canonicalPath()+"/"+(*it); | 393 | curFile = thisDir->canonicalPath()+"/"+(*it); |
395 | fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0); | 394 | fileDlg = new InputDialog( this, tr("Copy "+curFile+" As"), TRUE, 0); |
396 | 395 | ||
397 | fileDlg->setInputText((const QString &) destFile ); | 396 | fileDlg->setInputText((const QString &) destFile ); |
398 | fileDlg->exec(); | 397 | fileDlg->exec(); |
399 | 398 | ||
400 | if( fileDlg->result() == 1 ) | 399 | if( fileDlg->result() == 1 ) |
401 | { | 400 | { |
402 | QString filename = fileDlg->LineEdit1->text(); | 401 | QString filename = fileDlg->LineEdit1->text(); |
403 | destFile = thatDir->canonicalPath()+"/"+filename; | 402 | destFile = thatDir->canonicalPath()+"/"+filename; |
404 | 403 | ||
405 | QFile f( destFile); | 404 | QFile f( destFile); |
406 | if( f.exists()) | 405 | if( f.exists()) |
407 | { | 406 | { |
408 | switch (QMessageBox::warning(this,tr("File Exists!"), | 407 | switch (QMessageBox::warning(this,tr("File Exists!"), |
409 | item+tr("\nexists. Ok to overwrite?"), | 408 | item+tr("\nexists. Ok to overwrite?"), |
410 | tr("Yes"),tr("No"),0,0,1) ) | 409 | tr("Yes"),tr("No"),0,0,1) ) |
411 | { | 410 | { |
412 | case 0: | 411 | case 0: |
413 | f.remove(); | 412 | f.remove(); |
414 | break; | 413 | break; |
415 | case 1: | 414 | case 1: |
416 | return; | 415 | return; |
417 | break; | 416 | break; |
418 | }; | 417 | }; |
419 | } | 418 | } |
420 | if( !copyFile( curFile, destFile) ) { | 419 | if( !copyFile( curFile, destFile) ) { |
421 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 420 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
422 | +curFile +tr("to\n")+destFile); | 421 | +curFile +tr("to\n")+destFile); |
423 | return; | 422 | return; |
424 | } | 423 | } |
425 | } | 424 | } |
426 | delete fileDlg; | 425 | delete fileDlg; |
427 | 426 | ||
428 | } | 427 | } |
429 | setOtherTabCurrent(); | 428 | setOtherTabCurrent(); |
430 | populateView(); | 429 | populateView(); |
431 | } | 430 | } |
432 | 431 | ||
433 | void AdvancedFm::copySameDir() | 432 | void AdvancedFm::copySameDir() |
434 | { | 433 | { |
435 | qApp->processEvents(); | 434 | qApp->processEvents(); |
436 | QStringList curFileList = getPath(); | 435 | QStringList curFileList = getPath(); |
437 | QString curFile, item, destFile; | 436 | QString curFile, item, destFile; |
438 | InputDialog *fileDlg; | 437 | InputDialog *fileDlg; |
439 | 438 | ||
440 | QDir *thisDir = CurrentDir(); | 439 | QDir *thisDir = CurrentDir(); |
441 | 440 | ||
442 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 441 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
443 | { | 442 | { |
444 | item=(*it); | 443 | item=(*it); |
445 | curFile = thisDir->canonicalPath()+"/"+ item; | 444 | curFile = thisDir->canonicalPath()+"/"+ item; |
446 | 445 | ||
447 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); | 446 | fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0); |
448 | fileDlg->setInputText((const QString &) destFile ); | 447 | fileDlg->setInputText((const QString &) destFile ); |
449 | fileDlg->exec(); | 448 | fileDlg->exec(); |
450 | 449 | ||
451 | if( fileDlg->result() == 1 ) | 450 | if( fileDlg->result() == 1 ) |
452 | { | 451 | { |
453 | 452 | ||
454 | QString filename = fileDlg->LineEdit1->text(); | 453 | QString filename = fileDlg->LineEdit1->text(); |
455 | destFile = thisDir->canonicalPath()+"/"+filename; | 454 | destFile = thisDir->canonicalPath()+"/"+filename; |
456 | 455 | ||
457 | QFile f(destFile); | 456 | QFile f(destFile); |
458 | if( f.exists()) | 457 | if( f.exists()) |
459 | { | 458 | { |
460 | switch (QMessageBox::warning(this,tr("Delete"), | 459 | switch (QMessageBox::warning(this,tr("Delete"), |
461 | destFile+tr(" already exists.\nDo you really want to delete it?"), | 460 | destFile+tr(" already exists.\nDo you really want to delete it?"), |
462 | tr("Yes"),tr("No"),0,0,1) ) { | 461 | tr("Yes"),tr("No"),0,0,1) ) { |
463 | case 0: | 462 | case 0: |
464 | 463 | ||
465 | f.remove(); | 464 | f.remove(); |
466 | break; | 465 | break; |
467 | case 1: | 466 | case 1: |
468 | return; | 467 | return; |
469 | break; | 468 | break; |
470 | }; | 469 | }; |
471 | } | 470 | } |
472 | if(!copyFile( curFile,destFile) ) { | 471 | if(!copyFile( curFile,destFile) ) { |
473 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") | 472 | QMessageBox::message("AdvancedFm",tr("Could not copy\n") |
474 | +curFile +tr("to\n")+destFile); | 473 | +curFile +tr("to\n")+destFile); |
475 | return; | 474 | return; |
476 | } | 475 | } |
477 | 476 | ||
478 | qDebug("copy "+curFile+" as "+destFile); | 477 | qDebug("copy "+curFile+" as "+destFile); |
479 | } | 478 | } |
480 | delete fileDlg; | 479 | delete fileDlg; |
481 | } | 480 | } |
482 | populateView(); | 481 | populateView(); |
483 | } | 482 | } |
484 | 483 | ||
485 | void AdvancedFm::move() | 484 | void AdvancedFm::move() |
486 | { | 485 | { |
487 | qApp->processEvents(); | 486 | qApp->processEvents(); |
488 | 487 | ||
489 | QStringList curFileList = getPath(); | 488 | QStringList curFileList = getPath(); |
490 | if( curFileList.count() > 0) | 489 | if( curFileList.count() > 0) |
491 | { | 490 | { |
492 | QString curFile, destFile, item; | 491 | QString curFile, destFile, item; |
493 | 492 | ||
494 | QDir *thisDir = CurrentDir(); | 493 | QDir *thisDir = CurrentDir(); |
495 | QDir *thatDir = OtherDir(); | 494 | QDir *thatDir = OtherDir(); |
496 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 495 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
497 | { | 496 | { |
498 | item=(*it); | 497 | item=(*it); |
499 | QString destFile = thatDir->canonicalPath(); | 498 | QString destFile = thatDir->canonicalPath(); |
500 | 499 | ||
501 | if(destFile.right(1).find("/",0,TRUE) == -1) | 500 | if(destFile.right(1).find("/",0,TRUE) == -1) |
502 | destFile+="/"; | 501 | destFile+="/"; |
503 | destFile += item; | 502 | destFile += item; |
504 | qDebug("Destination file is "+destFile); | 503 | qDebug("Destination file is "+destFile); |
505 | 504 | ||
506 | curFile = thisDir->canonicalPath(); | 505 | curFile = thisDir->canonicalPath(); |
507 | if(curFile.right(1).find("/",0,TRUE) == -1) | 506 | if(curFile.right(1).find("/",0,TRUE) == -1) |
508 | curFile +="/"; | 507 | curFile +="/"; |
509 | curFile+= item; | 508 | curFile+= item; |
510 | qDebug("CurrentFile file is " + curFile); | 509 | qDebug("CurrentFile file is " + curFile); |
511 | 510 | ||
512 | QFile f( curFile); | 511 | QFile f( curFile); |
513 | if( f.exists()) { | 512 | if( f.exists()) { |
514 | if( !copyFile( curFile, destFile) ) { | 513 | if( !copyFile( curFile, destFile) ) { |
515 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); | 514 | QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile); |
516 | return; | 515 | return; |
517 | } else | 516 | } else |
518 | QFile::remove(curFile); | 517 | QFile::remove(curFile); |
519 | } | 518 | } |
520 | } | 519 | } |
521 | 520 | ||
522 | } | 521 | } |
523 | setOtherTabCurrent(); | 522 | populateView(); |
524 | populateView(); | 523 | setOtherTabCurrent(); |
525 | // populateLocalView(); | 524 | populateView(); |
526 | } | 525 | } |
527 | 526 | ||
528 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) | 527 | bool AdvancedFm::copyFile( const QString & src, const QString & dest ) |
529 | { | 528 | { |
530 | bool success = true; | 529 | bool success = true; |
531 | struct stat status; | 530 | struct stat status; |
532 | QFile srcFile(src); | 531 | QFile srcFile(src); |
533 | QFile destFile(dest); | 532 | QFile destFile(dest); |
534 | int err=0; | 533 | int err=0; |
535 | int read_fd=0; | 534 | int read_fd=0; |
536 | int write_fd=0; | 535 | int write_fd=0; |
537 | struct stat stat_buf; | 536 | struct stat stat_buf; |
538 | off_t offset = 0; | 537 | off_t offset = 0; |
539 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { | 538 | if(!srcFile.open( IO_ReadOnly|IO_Raw)) { |
540 | qWarning("open failed"); | 539 | qWarning("open failed"); |
541 | return success = false; | 540 | return success = false; |
542 | } | 541 | } |
543 | read_fd = srcFile.handle(); | 542 | read_fd = srcFile.handle(); |
544 | if(read_fd != -1) { | 543 | if(read_fd != -1) { |
545 | fstat (read_fd, &stat_buf); | 544 | fstat (read_fd, &stat_buf); |
546 | if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { | 545 | if( !destFile.open( IO_WriteOnly|IO_Raw ) ) { |
547 | qWarning("destfile open failed"); | 546 | qWarning("destfile open failed"); |
548 | return success = false; | 547 | return success = false; |
549 | } | 548 | } |
550 | write_fd = destFile.handle(); | 549 | write_fd = destFile.handle(); |
551 | if(write_fd != -1) { | 550 | if(write_fd != -1) { |
552 | err =sendfile(write_fd, read_fd, &offset, stat_buf.st_size); | 551 | err =sendfile(write_fd, read_fd, &offset, stat_buf.st_size); |
553 | if( err == -1) { | 552 | if( err == -1) { |
554 | QString msg; | 553 | QString msg; |
555 | switch(err) { | 554 | switch(err) { |
556 | case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; | 555 | case EBADF : msg = "The input file was not opened for reading or the output file was not opened for writing. "; |
557 | case EINVAL: msg = "Descriptor is not valid or locked. "; | 556 | case EINVAL: msg = "Descriptor is not valid or locked. "; |
558 | case ENOMEM: msg = "Insufficient memory to read from in_fd."; | 557 | case ENOMEM: msg = "Insufficient memory to read from in_fd."; |
559 | case EIO: msg = "Unspecified error while reading from in_fd."; | 558 | case EIO: msg = "Unspecified error while reading from in_fd."; |
560 | }; | 559 | }; |
561 | success = false; | 560 | success = false; |
562 | qWarning(msg); | 561 | qWarning(msg); |
563 | } | 562 | } |
564 | } else { | 563 | } else { |
565 | success = false; | 564 | success = false; |
566 | } | 565 | } |
567 | } else { | 566 | } else { |
568 | success = false; | 567 | success = false; |
569 | } | 568 | } |
570 | srcFile.close(); | 569 | srcFile.close(); |
571 | destFile.close(); | 570 | destFile.close(); |
572 | // Set file permissions | 571 | // Set file permissions |
573 | if( stat( (const char *) src, &status ) == 0 ) { | 572 | if( stat( (const char *) src, &status ) == 0 ) { |
574 | chmod( (const char *) dest, status.st_mode ); | 573 | chmod( (const char *) dest, status.st_mode ); |
575 | } | 574 | } |
576 | 575 | ||
577 | return success; | 576 | return success; |
578 | } | 577 | } |
579 | 578 | ||
580 | void AdvancedFm::runCommand() | 579 | void AdvancedFm::runCommand() |
581 | { | 580 | { |
582 | QDir *thisDir = CurrentDir(); | 581 | QDir *thisDir = CurrentDir(); |
583 | 582 | ||
584 | QString curFile; | 583 | QString curFile; |
585 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); | 584 | curFile = thisDir->canonicalPath() +"/"+ CurrentView()->currentItem()->text(0); |
586 | 585 | ||
587 | InputDialog *fileDlg; | 586 | InputDialog *fileDlg; |
588 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 587 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
589 | fileDlg->setInputText(curFile); | 588 | fileDlg->setInputText(curFile); |
590 | fileDlg->exec(); | 589 | fileDlg->exec(); |
591 | //QString command; | 590 | //QString command; |
592 | 591 | ||
593 | if( fileDlg->result() == 1 ) | 592 | if( fileDlg->result() == 1 ) |
594 | { | 593 | { |
595 | qDebug(fileDlg->LineEdit1->text()); | 594 | qDebug(fileDlg->LineEdit1->text()); |
596 | QStringList command; | 595 | QStringList command; |
597 | 596 | ||
598 | command << "/bin/sh"; | 597 | command << "/bin/sh"; |
599 | command << "-c"; | 598 | command << "-c"; |
600 | command << fileDlg->LineEdit1->text(); | 599 | command << fileDlg->LineEdit1->text(); |
601 | Output *outDlg; | 600 | Output *outDlg; |
602 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 601 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
603 | outDlg->showMaximized(); | 602 | outDlg->showMaximized(); |
604 | outDlg->exec(); | 603 | outDlg->exec(); |
605 | qApp->processEvents(); | 604 | qApp->processEvents(); |
606 | 605 | ||
607 | } | 606 | } |
608 | } | 607 | } |
609 | 608 | ||
610 | void AdvancedFm::runCommandStd() | 609 | void AdvancedFm::runCommandStd() |
611 | { | 610 | { |
612 | QString curFile; | 611 | QString curFile; |
613 | QDir *thisDir = CurrentDir(); | 612 | QDir *thisDir = CurrentDir(); |
614 | QListView *thisView = CurrentView(); | 613 | QListView *thisView = CurrentView(); |
615 | if( thisView->currentItem()) | 614 | if( thisView->currentItem()) |
616 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); | 615 | curFile = thisDir->canonicalPath() +"/"+ thisView->currentItem()->text(0); |
617 | 616 | ||
618 | InputDialog *fileDlg; | 617 | InputDialog *fileDlg; |
619 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 618 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
620 | fileDlg->setInputText(curFile); | 619 | fileDlg->setInputText(curFile); |
621 | fileDlg->exec(); | 620 | fileDlg->exec(); |
622 | 621 | ||
623 | if( fileDlg->result() == 1 ) | 622 | if( fileDlg->result() == 1 ) |
624 | { | 623 | { |
625 | qApp->processEvents(); | 624 | qApp->processEvents(); |
626 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); | 625 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); |
627 | } | 626 | } |
628 | } | 627 | } |
629 | 628 | ||
630 | void AdvancedFm::fileStatus() | 629 | void AdvancedFm::fileStatus() |
631 | { | 630 | { |
632 | QString curFile; | 631 | QString curFile; |
633 | curFile = CurrentView()->currentItem()->text(0); | 632 | curFile = CurrentView()->currentItem()->text(0); |
634 | 633 | ||
635 | QStringList command; | 634 | QStringList command; |
636 | command << "/bin/sh"; | 635 | command << "/bin/sh"; |
637 | command << "-c"; | 636 | command << "-c"; |
638 | command << "stat -l "+ curFile; | 637 | command << "stat -l "+ curFile; |
639 | 638 | ||
640 | Output *outDlg; | 639 | Output *outDlg; |
641 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); | 640 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
642 | outDlg->showMaximized(); | 641 | outDlg->showMaximized(); |
643 | outDlg->exec(); | 642 | outDlg->exec(); |
644 | qApp->processEvents(); | 643 | qApp->processEvents(); |
645 | } | 644 | } |
646 | 645 | ||
647 | 646 | ||
648 | void AdvancedFm::mkDir() | 647 | void AdvancedFm::mkDir() |
649 | { | 648 | { |
650 | makeDir(); | 649 | makeDir(); |
651 | } | 650 | } |
652 | 651 | ||
653 | void AdvancedFm::rn() | 652 | void AdvancedFm::rn() |
654 | { | 653 | { |
655 | renameIt(); | 654 | renameIt(); |
656 | } | 655 | } |
657 | 656 | ||
658 | void AdvancedFm::del() | 657 | void AdvancedFm::del() |
659 | { | 658 | { |
660 | doDelete(); | 659 | doDelete(); |
661 | } | 660 | } |
662 | 661 | ||
663 | void AdvancedFm::mkSym() | 662 | void AdvancedFm::mkSym() |
664 | { | 663 | { |
665 | QString cmd; | 664 | QString cmd; |
666 | QStringList curFileList = getPath(); | 665 | QStringList curFileList = getPath(); |
667 | if( curFileList.count() > 0) | 666 | if( curFileList.count() > 0) |
668 | { | 667 | { |
669 | QDir *thisDir = CurrentDir(); | 668 | QDir *thisDir = CurrentDir(); |
670 | QDir * thatDir = OtherDir(); | 669 | QDir * thatDir = OtherDir(); |
671 | 670 | ||
672 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) | 671 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) |
673 | { | 672 | { |
674 | 673 | ||
675 | QString destName = thatDir->canonicalPath()+"/"+(*it); | 674 | QString destName = thatDir->canonicalPath()+"/"+(*it); |
676 | if(destName.right(1) == "/") | 675 | if(destName.right(1) == "/") |
677 | { | 676 | { |
678 | destName = destName.left( destName.length() -1); | 677 | destName = destName.left( destName.length() -1); |
679 | } | 678 | } |
680 | 679 | ||
681 | QString curFile = thisDir->canonicalPath()+"/"+(*it); | 680 | QString curFile = thisDir->canonicalPath()+"/"+(*it); |
682 | 681 | ||
683 | if( curFile.right(1) == "/") | 682 | if( curFile.right(1) == "/") |
684 | { | 683 | { |
685 | curFile = curFile.left( curFile.length() -1); | 684 | curFile = curFile.left( curFile.length() -1); |
686 | } | 685 | } |
687 | 686 | ||
688 | cmd = "ln -s "+curFile+" "+destName; | 687 | cmd = "ln -s "+curFile+" "+destName; |
689 | qDebug(cmd); | 688 | qDebug(cmd); |
690 | startProcess( (const QString)cmd ); | 689 | startProcess( (const QString)cmd ); |
691 | } | 690 | } |
692 | setOtherTabCurrent(); | 691 | setOtherTabCurrent(); |
693 | populateView(); | 692 | populateView(); |
694 | } | 693 | } |
695 | } | 694 | } |
696 | 695 | ||
697 | void AdvancedFm::doBeam() | 696 | void AdvancedFm::doBeam() |
698 | { | 697 | { |
699 | Ir ir; | 698 | Ir ir; |
700 | if(!ir.supported()) { | 699 | if(!ir.supported()) { |
701 | } else { | 700 | } else { |
702 | QStringList curFileList = getPath(); | 701 | QStringList curFileList = getPath(); |
703 | if( curFileList.count() > 0) { | 702 | if( curFileList.count() > 0) { |
704 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { | 703 | for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) { |
705 | QString curFile = (*it); | 704 | QString curFile = (*it); |
706 | QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; | 705 | QString curFilePath = CurrentDir()->canonicalPath()+"/"+curFile; |
707 | if( curFilePath.right(1) == "/") { | 706 | if( curFilePath.right(1) == "/") { |
708 | curFilePath = curFilePath.left( curFilePath.length() -1); | 707 | curFilePath = curFilePath.left( curFilePath.length() -1); |
709 | } | 708 | } |
710 | Ir *file = new Ir(this, "IR"); | 709 | Ir *file = new Ir(this, "IR"); |
711 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); | 710 | connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * ))); |
712 | file->send( curFilePath, curFile ); | 711 | file->send( curFilePath, curFile ); |
713 | } | 712 | } |
714 | } | 713 | } |
715 | } | 714 | } |
716 | } | 715 | } |
717 | 716 | ||
718 | void AdvancedFm::fileBeamFinished( Ir *) | 717 | void AdvancedFm::fileBeamFinished( Ir *) |
719 | { | 718 | { |
720 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); | 719 | QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") ); |
721 | } | 720 | } |
722 | 721 | ||
723 | void AdvancedFm::selectAll() | 722 | void AdvancedFm::selectAll() |
724 | { | 723 | { |
725 | // if (TabWidget->currentTab() == 0) { | 724 | // if (TabWidget->currentTab() == 0) { |
726 | QListView *thisView = CurrentView(); | 725 | QListView *thisView = CurrentView(); |
727 | thisView->selectAll(true); | 726 | thisView->selectAll(true); |
728 | thisView->setSelected( thisView->firstChild(),false); | 727 | thisView->setSelected( thisView->firstChild(),false); |
729 | // } else { | 728 | // } else { |
730 | // Remote_View->selectAll(true); | 729 | // Remote_View->selectAll(true); |
731 | // Remote_View->setSelected( Remote_View->firstChild(),false); | 730 | // Remote_View->setSelected( Remote_View->firstChild(),false); |
732 | // } | 731 | // } |
733 | } | 732 | } |
734 | 733 | ||
735 | void AdvancedFm::startProcess(const QString & cmd) | 734 | void AdvancedFm::startProcess(const QString & cmd) |
736 | { | 735 | { |
737 | QStringList command; | 736 | QStringList command; |
738 | OProcess *process; | 737 | OProcess *process; |
739 | process = new OProcess(); | 738 | process = new OProcess(); |
740 | connect(process, SIGNAL(processExited(OProcess *)), | 739 | connect(process, SIGNAL(processExited(OProcess *)), |
741 | this, SLOT( processEnded(OProcess *))); | 740 | this, SLOT( processEnded(OProcess *))); |
742 | 741 | ||
743 | connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)), | 742 | connect(process, SIGNAL( receivedStderr(OProcess *, char *, int)), |
744 | this, SLOT( oprocessStderr(OProcess *, char *, int))); | 743 | this, SLOT( oprocessStderr(OProcess *, char *, int))); |
745 | 744 | ||
746 | command << "/bin/sh"; | 745 | command << "/bin/sh"; |
747 | command << "-c"; | 746 | command << "-c"; |
748 | command << cmd.latin1(); | 747 | command << cmd.latin1(); |
749 | *process << command; | 748 | *process << command; |
750 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) | 749 | if(!process->start(OProcess::NotifyOnExit, OProcess::All) ) |
751 | qDebug("could not start process"); | 750 | qDebug("could not start process"); |
752 | } | 751 | } |
753 | 752 | ||
754 | void AdvancedFm::processEnded(OProcess *) | 753 | void AdvancedFm::processEnded(OProcess *) |
755 | { | 754 | { |
756 | // populateLocalView(); | 755 | // populateLocalView(); |
757 | populateView(); | 756 | populateView(); |
758 | } | 757 | } |
759 | 758 | ||
760 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int buflen) { | 759 | void AdvancedFm::oprocessStderr(OProcess*, char *buffer, int buflen) { |
761 | qWarning("received stderrt %d bytes", buflen); | 760 | qWarning("received stderrt %d bytes", buflen); |
762 | 761 | ||
763 | QString lineStr = buffer; | 762 | QString lineStr = buffer; |
764 | // lineStr=lineStr.left(lineStr.length()-1); | 763 | // lineStr=lineStr.left(lineStr.length()-1); |
765 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); | 764 | QMessageBox::warning( this, tr("Error"), lineStr ,tr("Ok") ); |
766 | 765 | ||
767 | // OutputEdit->append(lineStr); | 766 | // OutputEdit->append(lineStr); |
768 | // OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); | 767 | // OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE); |
769 | } | 768 | } |
770 | 769 | ||
771 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) | 770 | bool AdvancedFm::eventFilter( QObject * o, QEvent * e ) |
772 | { | 771 | { |
773 | if ( o->inherits( "QLineEdit" ) ) | 772 | if ( o->inherits( "QLineEdit" ) ) |
774 | { | 773 | { |
775 | if ( e->type() == QEvent::KeyPress ) | 774 | if ( e->type() == QEvent::KeyPress ) |
776 | { | 775 | { |
777 | QKeyEvent *ke = (QKeyEvent*)e; | 776 | QKeyEvent *ke = (QKeyEvent*)e; |
778 | if ( ke->key() == Key_Return || | 777 | if ( ke->key() == Key_Return || |
779 | ke->key() == Key_Enter ) | 778 | ke->key() == Key_Enter ) |
780 | { | 779 | { |
781 | okRename(); | 780 | okRename(); |
782 | return true; | 781 | return true; |
783 | } | 782 | } |
784 | else if ( ke->key() == Key_Escape ) | 783 | else if ( ke->key() == Key_Escape ) |
785 | { | 784 | { |
786 | cancelRename(); | 785 | cancelRename(); |
787 | return true; | 786 | return true; |
788 | } | 787 | } |
789 | } | 788 | } |
790 | else if ( e->type() == QEvent::FocusOut ) | 789 | else if ( e->type() == QEvent::FocusOut ) |
791 | { | 790 | { |
792 | cancelRename(); | 791 | cancelRename(); |
793 | return true; | 792 | return true; |
794 | } | 793 | } |
795 | } | 794 | } |
796 | if ( o->inherits( "QListView" ) ) | 795 | if ( o->inherits( "QListView" ) ) |
797 | { | 796 | { |
798 | if ( e->type() == QEvent::FocusOut ) | 797 | if ( e->type() == QEvent::FocusOut ) |
799 | { | 798 | { |
800 | printf("focusIn\n"); | 799 | printf("focusIn\n"); |
801 | 800 | ||
802 | } | 801 | } |
803 | } | 802 | } |
804 | 803 | ||
805 | return QWidget::eventFilter( o, e ); | 804 | return QWidget::eventFilter( o, e ); |
806 | } | 805 | } |
807 | 806 | ||
808 | 807 | ||
809 | void AdvancedFm::cancelRename() | 808 | void AdvancedFm::cancelRename() |
810 | { | 809 | { |
811 | qDebug("cancel rename"); | 810 | qDebug("cancel rename"); |
812 | QListView * view; | 811 | QListView * view; |
813 | view = CurrentView(); | 812 | view = CurrentView(); |
814 | 813 | ||
815 | bool resetFocus = view->viewport()->focusProxy() == renameBox; | 814 | bool resetFocus = view->viewport()->focusProxy() == renameBox; |
816 | delete renameBox; | 815 | delete renameBox; |
817 | renameBox = 0; | 816 | renameBox = 0; |
818 | if ( resetFocus ) | 817 | if ( resetFocus ) |
819 | { | 818 | { |
820 | view->viewport()->setFocusProxy( view); | 819 | view->viewport()->setFocusProxy( view); |
821 | view->setFocus(); | 820 | view->setFocus(); |
822 | } | 821 | } |
823 | } | 822 | } |
824 | 823 | ||
825 | void AdvancedFm::doRename(QListView * view) | 824 | void AdvancedFm::doRename(QListView * view) |
826 | { | 825 | { |
827 | 826 | ||
828 | QRect r = view->itemRect( view->currentItem( )); | 827 | QRect r = view->itemRect( view->currentItem( )); |
829 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); | 828 | r = QRect( view->viewportToContents( r.topLeft() ), r.size() ); |
830 | r.setX( view->contentsX() ); | 829 | r.setX( view->contentsX() ); |
831 | if ( r.width() > view->visibleWidth() ) | 830 | if ( r.width() > view->visibleWidth() ) |
832 | r.setWidth( view->visibleWidth() ); | 831 | r.setWidth( view->visibleWidth() ); |
833 | 832 | ||
834 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); | 833 | renameBox = new QLineEdit( view->viewport(), "qt_renamebox" ); |
835 | renameBox->setFrame(true); | 834 | renameBox->setFrame(true); |
836 | 835 | ||
837 | renameBox->setText( view->currentItem()->text(0) ); | 836 | renameBox->setText( view->currentItem()->text(0) ); |
838 | 837 | ||
839 | renameBox->selectAll(); | 838 | renameBox->selectAll(); |
840 | renameBox->installEventFilter( this ); | 839 | renameBox->installEventFilter( this ); |
841 | view->addChild( renameBox, r.x(), r.y() ); | 840 | view->addChild( renameBox, r.x(), r.y() ); |
842 | renameBox->resize( r.size() ); | 841 | renameBox->resize( r.size() ); |
843 | view->viewport()->setFocusProxy( renameBox ); | 842 | view->viewport()->setFocusProxy( renameBox ); |
844 | renameBox->setFocus(); | 843 | renameBox->setFocus(); |
845 | renameBox->show(); | 844 | renameBox->show(); |
846 | 845 | ||
847 | } | 846 | } |
848 | 847 | ||
849 | 848 | ||
850 | void AdvancedFm::renameIt() | 849 | void AdvancedFm::renameIt() |
851 | { | 850 | { |
852 | QListView *thisView = CurrentView(); | 851 | QListView *thisView = CurrentView(); |
853 | oldName = thisView->currentItem()->text(0); | 852 | oldName = thisView->currentItem()->text(0); |
854 | doRename( thisView ); | 853 | doRename( thisView ); |
855 | populateView(); | 854 | populateView(); |
856 | } | 855 | } |
857 | 856 | ||
858 | void AdvancedFm::okRename() | 857 | void AdvancedFm::okRename() |
859 | { | 858 | { |
860 | QString newName = renameBox->text(); | 859 | QString newName = renameBox->text(); |
861 | cancelRename(); | 860 | cancelRename(); |
862 | // int tabs=0; | 861 | // int tabs=0; |
863 | QListView * view = CurrentView(); | 862 | QListView * view = CurrentView(); |
864 | QString path = CurrentDir()->canonicalPath() + "/"; | 863 | QString path = CurrentDir()->canonicalPath() + "/"; |
865 | oldName = path + oldName; | 864 | oldName = path + oldName; |
866 | newName = path + newName; | 865 | newName = path + newName; |
867 | 866 | ||
868 | if( view->currentItem() == NULL) | 867 | if( view->currentItem() == NULL) |
869 | return; | 868 | return; |
870 | if( rename( oldName.latin1(), newName.latin1())== -1) | 869 | if( rename( oldName.latin1(), newName.latin1())== -1) |
871 | QMessageBox::message(tr("Note"),tr("Could not rename")); | 870 | QMessageBox::message(tr("Note"),tr("Could not rename")); |
872 | else | 871 | else |
873 | oldName = ""; | 872 | oldName = ""; |
874 | 873 | ||
875 | view->takeItem( view->currentItem() ); | 874 | view->takeItem( view->currentItem() ); |
876 | delete view->currentItem(); | 875 | delete view->currentItem(); |
877 | populateView(); | 876 | populateView(); |
878 | } | 877 | } |
879 | 878 | ||
880 | void AdvancedFm::openSearch() { | 879 | void AdvancedFm::openSearch() { |
881 | 880 | ||
882 | } | 881 | } |