-rw-r--r-- | core/apps/textedit/fileBrowser.cpp | 117 | ||||
-rw-r--r-- | core/apps/textedit/fileBrowser.h | 2 | ||||
-rw-r--r-- | core/apps/textedit/fileSaver.cpp | 45 |
3 files changed, 104 insertions, 60 deletions
diff --git a/core/apps/textedit/fileBrowser.cpp b/core/apps/textedit/fileBrowser.cpp index 8c942a1..8ea8067 100644 --- a/core/apps/textedit/fileBrowser.cpp +++ b/core/apps/textedit/fileBrowser.cpp | |||
@@ -92,245 +92,248 @@ fileBrowser::fileBrowser( QWidget* parent, const char* name, bool modal, WFlags | |||
92 | docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); | 92 | docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); |
93 | docButton->setMinimumSize( QSize( 20, 20 ) ); | 93 | docButton->setMinimumSize( QSize( 20, 20 ) ); |
94 | docButton->setMaximumSize( QSize( 20, 20 ) ); | 94 | docButton->setMaximumSize( QSize( 20, 20 ) ); |
95 | connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); | 95 | connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); |
96 | docButton->setFlat(TRUE); | 96 | docButton->setFlat(TRUE); |
97 | layout->addMultiCellWidget( docButton, 0, 0, 6, 6 ); | 97 | layout->addMultiCellWidget( docButton, 0, 0, 6, 6 ); |
98 | 98 | ||
99 | homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); | 99 | homeButton = new QPushButton( Resource::loadIconSet("home"),"",this,"homeButton"); |
100 | homeButton->setMinimumSize( QSize( 20, 20 ) ); | 100 | homeButton->setMinimumSize( QSize( 20, 20 ) ); |
101 | homeButton->setMaximumSize( QSize( 20, 20 ) ); | 101 | homeButton->setMaximumSize( QSize( 20, 20 ) ); |
102 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); | 102 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); |
103 | homeButton->setFlat(TRUE); | 103 | homeButton->setFlat(TRUE); |
104 | layout->addMultiCellWidget( homeButton, 0, 0, 7, 7 ); | 104 | layout->addMultiCellWidget( homeButton, 0, 0, 7, 7 ); |
105 | 105 | ||
106 | FileStack = new QWidgetStack( this ); | 106 | FileStack = new QWidgetStack( this ); |
107 | 107 | ||
108 | ListView = new QListView( this, "ListView" ); | 108 | ListView = new QListView( this, "ListView" ); |
109 | // ListView->setMinimumSize( QSize( 100, 25 ) ); | 109 | // ListView->setMinimumSize( QSize( 100, 25 ) ); |
110 | ListView->addColumn( tr( "Name" ) ); | 110 | ListView->addColumn( tr( "Name" ) ); |
111 | ListView->setColumnWidth(0,120); | 111 | ListView->setColumnWidth(0,120); |
112 | ListView->setSorting( 2, FALSE); | 112 | ListView->setSorting( 2, FALSE); |
113 | ListView->addColumn( tr( "Size" ) ); | 113 | ListView->addColumn( tr( "Size" ) ); |
114 | ListView->setColumnWidth(1,-1); | 114 | ListView->setColumnWidth(1,-1); |
115 | ListView->addColumn( "Date",-1); | 115 | ListView->addColumn( "Date",-1); |
116 | 116 | ||
117 | ListView->setColumnWidthMode(0,QListView::Manual); | 117 | ListView->setColumnWidthMode(0,QListView::Manual); |
118 | ListView->setColumnAlignment(1,QListView::AlignRight); | 118 | ListView->setColumnAlignment(1,QListView::AlignRight); |
119 | ListView->setColumnAlignment(2,QListView::AlignRight); | 119 | ListView->setColumnAlignment(2,QListView::AlignRight); |
120 | ListView->setAllColumnsShowFocus( TRUE ); | 120 | ListView->setAllColumnsShowFocus( TRUE ); |
121 | 121 | ||
122 | QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold); | 122 | QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold); |
123 | connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), | 123 | connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), |
124 | this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); | 124 | this, SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); |
125 | 125 | ||
126 | connect( ListView, SIGNAL( clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); | 126 | connect( ListView, SIGNAL( clicked( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); |
127 | 127 | ||
128 | FileStack->addWidget( ListView, get_unique_id() ); | 128 | FileStack->addWidget( ListView, get_unique_id() ); |
129 | 129 | ||
130 | fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy | 130 | fileSelector = new FileSelector( mimeType, FileStack, "fileselector" , FALSE, FALSE); //buggy |
131 | // connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); | 131 | // connect( fileSelector, SIGNAL( closeMe() ), this, SLOT( showEditTools() ) ); |
132 | // connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); | 132 | // connect( fileSelector, SIGNAL( newSelected( const DocLnk &) ), this, SLOT( newFile( const DocLnk & ) ) ); |
133 | connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); | 133 | connect( fileSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( docOpen( const DocLnk & ) ) ); |
134 | layout->addMultiCellWidget( FileStack, 1, 1, 0, 7 ); | 134 | layout->addMultiCellWidget( FileStack, 1, 1, 0, 7 ); |
135 | 135 | ||
136 | SelectionCombo = new QComboBox( FALSE, this, "SelectionCombo" ); | 136 | SelectionCombo = new QComboBox( FALSE, this, "SelectionCombo" ); |
137 | SelectionCombo->insertItem( tr( "Documents" ) ); | 137 | SelectionCombo->insertItem( tr( "Documents" ) ); |
138 | SelectionCombo->insertItem( tr( "All files" ) ); | 138 | SelectionCombo->insertItem( tr( "All files" ) ); |
139 | SelectionCombo->insertItem( tr( "Hidden files" ) ); | 139 | SelectionCombo->insertItem( tr( "Hidden files" ) ); |
140 | // SelectionCombo->setMaximumWidth(120); | 140 | // SelectionCombo->setMaximumWidth(120); |
141 | layout->addMultiCellWidget( SelectionCombo, 2, 2, 0, 3 ); | 141 | layout->addMultiCellWidget( SelectionCombo, 2, 2, 0, 3 ); |
142 | 142 | ||
143 | connect( SelectionCombo, SIGNAL( activated( const QString & ) ), | 143 | connect( SelectionCombo, SIGNAL( activated( const QString & ) ), |
144 | this, SLOT( selectionChanged( const QString & ) ) ); | 144 | this, SLOT( selectionChanged( const QString & ) ) ); |
145 | 145 | ||
146 | typemb = new MenuButton(this); | 146 | typemb = new MenuButton(this); |
147 | typemb->setLabel(tr("Type: %1")); | 147 | typemb->setLabel(tr("Type: %1")); |
148 | typemb->setMinimumWidth(110); | 148 | typemb->setMinimumWidth(110); |
149 | typemb->setFixedHeight(22); | 149 | typemb->setFixedHeight(22); |
150 | layout->addMultiCellWidget( typemb, 2, 2, 4, 7 ); | 150 | layout->addMultiCellWidget( typemb, 2, 2, 4, 7 ); |
151 | updateMimeTypeMenu() ; | 151 | updateMimeTypeMenu() ; |
152 | 152 | ||
153 | currentDir.setPath(QDir::currentDirPath()); | 153 | currentDir.setPath(QDir::currentDirPath()); |
154 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All); | 154 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All); |
155 | currentDir.setNameFilter(filterStr); | 155 | currentDir.setNameFilter(filterStr); |
156 | 156 | ||
157 | populateList(); | 157 | populateList(); |
158 | move(0,15); | 158 | move(0,15); |
159 | } | 159 | } |
160 | 160 | ||
161 | fileBrowser::~fileBrowser() | 161 | fileBrowser::~fileBrowser() |
162 | { | 162 | { |
163 | } | 163 | } |
164 | 164 | ||
165 | void fileBrowser::setFileView( int selection ) | 165 | void fileBrowser::setFileView( int selection ) |
166 | { | 166 | { |
167 | SelectionCombo->setCurrentItem( selection ); | 167 | SelectionCombo->setCurrentItem( selection ); |
168 | selectionChanged( SelectionCombo->currentText() ); | 168 | selectionChanged( SelectionCombo->currentText() ); |
169 | } | 169 | } |
170 | 170 | ||
171 | void fileBrowser::populateList() | 171 | void fileBrowser::populateList() |
172 | { | 172 | { |
173 | ListView->clear(); | 173 | ListView->clear(); |
174 | QListViewItem * item; | ||
174 | bool isDir=FALSE; | 175 | bool isDir=FALSE; |
175 | //qDebug(currentDir.canonicalPath()); | 176 | //qDebug(currentDir.canonicalPath()); |
176 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 177 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
177 | currentDir.setMatchAllDirs(TRUE); | 178 | currentDir.setMatchAllDirs(TRUE); |
178 | 179 | ||
179 | // currentDir.setNameFilter("*.txt;*.etx"); | 180 | // currentDir.setNameFilter("*.txt;*.etx"); |
180 | QString fileL, fileS, fileDate; | 181 | QString fileL, fileS, fileDate; |
181 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 182 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
182 | QFileInfoListIterator it(*list); | 183 | QFileInfoListIterator it(*list); |
183 | QFileInfo *fi; | 184 | QFileInfo *fi; |
184 | while ( (fi=it.current()) ) { | 185 | while ( (fi=it.current()) ) { |
185 | 186 | if (fi->isSymLink() ){ | |
186 | if (fi->isSymLink() ){ | 187 | QString symLink=fi->readLink(); |
187 | QString symLink=fi->readLink(); | ||
188 | // qDebug("Symlink detected "+symLink); | 188 | // qDebug("Symlink detected "+symLink); |
189 | QFileInfo sym( symLink); | 189 | QFileInfo sym( symLink); |
190 | fileS.sprintf( "%10li", sym.size() ); | 190 | fileS.sprintf( "%10li", sym.size() ); |
191 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); | 191 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); |
192 | fileDate = sym.lastModified().toString(); | 192 | fileDate = sym.lastModified().toString(); |
193 | } else { | 193 | } else { |
194 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 194 | // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
195 | fileS.sprintf( "%10li", fi->size() ); | 195 | fileS.sprintf( "%10li", fi->size() ); |
196 | fileL.sprintf( "%s",fi->fileName().data() ); | 196 | fileL.sprintf( "%s",fi->fileName().data() ); |
197 | fileDate= fi->lastModified().toString(); | 197 | fileDate= fi->lastModified().toString(); |
198 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 198 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
199 | fileL+="/"; | 199 | fileL+="/"; |
200 | isDir=TRUE; | 200 | isDir=TRUE; |
201 | // qDebug( fileL); | 201 | // qDebug( fileL); |
202 | } | ||
202 | } | 203 | } |
203 | } | 204 | if(fileL !="./" && fi->exists()) { |
204 | if(fileL !="./") { | 205 | item= new QListViewItem( ListView,fileL,fileS , fileDate); |
205 | item= new QListViewItem( ListView,fileL,fileS , fileDate); | 206 | QPixmap pm; |
206 | QPixmap pm; | ||
207 | 207 | ||
208 | if(isDir || fileL.find("/",0,TRUE) != -1) { | 208 | if(isDir || fileL.find("/",0,TRUE) != -1) { |
209 | if( !QDir( fi->filePath() ).isReadable()) | 209 | if( !QDir( fi->filePath() ).isReadable()) |
210 | pm = Resource::loadPixmap( "lockedfolder" ); | 210 | pm = Resource::loadPixmap( "lockedfolder" ); |
211 | else | 211 | else |
212 | pm= Resource::loadPixmap( "folder" ); | ||
213 | item->setPixmap( 0,pm ); | ||
214 | } else { | ||
215 | if( !fi->isReadable() ) | ||
216 | pm = Resource::loadPixmap( "locked" ); | ||
217 | else { | ||
218 | MimeType mt(fi->filePath()); | ||
219 | pm=mt.pixmap(); | ||
220 | if(pm.isNull()) | ||
221 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | ||
222 | item->setPixmap( 0,pm); | ||
223 | } | ||
224 | } | ||
225 | if( fileL.find("->",0,TRUE) != -1) { | ||
226 | // overlay link image | ||
212 | pm= Resource::loadPixmap( "folder" ); | 227 | pm= Resource::loadPixmap( "folder" ); |
213 | item->setPixmap( 0,pm ); | 228 | QPixmap lnk = Resource::loadPixmap( "symlink" ); |
214 | } else { | 229 | QPainter painter( &pm ); |
215 | if( !fi->isReadable() ) | 230 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); |
216 | pm = Resource::loadPixmap( "locked" ); | 231 | pm.setMask( pm.createHeuristicMask( FALSE ) ); |
217 | else { | 232 | item->setPixmap( 0, pm); |
218 | MimeType mt(fi->filePath()); | ||
219 | pm=mt.pixmap(); | ||
220 | if(pm.isNull()) | ||
221 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | ||
222 | item->setPixmap( 0,pm); | ||
223 | } | 233 | } |
224 | } | 234 | } |
225 | if( fileL.find("->",0,TRUE) != -1) { | 235 | isDir=FALSE; |
226 | // overlay link image | 236 | ++it; |
227 | pm= Resource::loadPixmap( "folder" ); | 237 | // } |
228 | QPixmap lnk = Resource::loadPixmap( "symlink" ); | ||
229 | QPainter painter( &pm ); | ||
230 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | ||
231 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | ||
232 | item->setPixmap( 0, pm); | ||
233 | } | ||
234 | } | ||
235 | isDir=FALSE; | ||
236 | ++it; | ||
237 | } | 238 | } |
238 | ListView->setSorting( 3, FALSE); | 239 | ListView->setSorting( 3, FALSE); |
239 | QString currentPath = currentDir.canonicalPath(); | 240 | QString currentPath = currentDir.canonicalPath(); |
240 | 241 | ||
241 | fillCombo( (const QString &)currentPath); | 242 | fillCombo( (const QString &)currentPath); |
242 | // dirPathCombo->lineEdit()->setText(currentPath); | 243 | // dirPathCombo->lineEdit()->setText(currentPath); |
243 | 244 | ||
244 | // if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) { | 245 | // if( dirPathStringList.grep(currentPath,TRUE).isEmpty() ) { |
245 | // dirPathCombo->clear(); | 246 | // dirPathCombo->clear(); |
246 | // dirPathStringList.prepend(currentPath ); | 247 | // dirPathStringList.prepend(currentPath ); |
247 | // dirPathCombo->insertStringList( dirPathStringList,-1); | 248 | // dirPathCombo->insertStringList( dirPathStringList,-1); |
248 | // } | 249 | // } |
249 | } | 250 | } |
250 | 251 | ||
251 | void fileBrowser::upDir() | 252 | void fileBrowser::upDir() |
252 | { | 253 | { |
253 | QString current = currentDir.canonicalPath(); | 254 | QString current = currentDir.canonicalPath(); |
254 | QDir dir(current); | 255 | QDir dir(current); |
255 | dir.cdUp(); | 256 | dir.cdUp(); |
256 | current = dir.canonicalPath(); | 257 | current = dir.canonicalPath(); |
257 | chdir( current.latin1() ); | 258 | chdir( current.latin1() ); |
258 | currentDir.cd( current, TRUE); | 259 | currentDir.cd( current, TRUE); |
259 | populateList(); | 260 | populateList(); |
260 | update(); | 261 | update(); |
261 | } | 262 | } |
262 | 263 | ||
263 | // you may want to switch these 2 functions. I like single clicks | 264 | // you may want to switch these 2 functions. I like single clicks |
264 | void fileBrowser::listClicked(QListViewItem *selectedItem) | 265 | void fileBrowser::listClicked(QListViewItem *selectedItem) |
265 | { | 266 | { |
267 | if(selectedItem) { | ||
266 | QString strItem=selectedItem->text(0); | 268 | QString strItem=selectedItem->text(0); |
267 | QString strSize=selectedItem->text(1); | 269 | QString strSize=selectedItem->text(1); |
268 | // qDebug("strItem is "+strItem); | 270 | // qDebug("strItem is "+strItem); |
269 | strSize.stripWhiteSpace(); | 271 | strSize.stripWhiteSpace(); |
270 | // qDebug(strSize); | 272 | // qDebug(strSize); |
271 | 273 | ||
272 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 274 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
273 | // is symlink | 275 | // is symlink |
274 | QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); | 276 | QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); |
275 | // qDebug("strItem symlink is "+strItem2); | 277 | // qDebug("strItem symlink is "+strItem2); |
276 | if(QDir(strItem2).exists() ) { | 278 | if(QDir(strItem2).exists() ) { |
277 | currentDir.cd(strItem2, TRUE); | 279 | currentDir.cd(strItem2, TRUE); |
278 | populateList(); | 280 | populateList(); |
279 | } | 281 | } |
280 | } else { // not a symlink | 282 | } else { // not a symlink |
281 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { | 283 | if(strItem.find(". .",0,TRUE) && strItem.find("/",0,TRUE)!=-1 ) { |
282 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { | 284 | if(QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem)).exists() ) { |
283 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 285 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
284 | currentDir.cd(strItem,FALSE); | 286 | currentDir.cd(strItem,FALSE); |
285 | // qDebug("Path is "+strItem); | 287 | // qDebug("Path is "+strItem); |
286 | populateList(); | 288 | populateList(); |
287 | } else { | 289 | } else { |
288 | currentDir.cdUp(); | 290 | currentDir.cdUp(); |
289 | populateList(); | 291 | populateList(); |
290 | } | 292 | } |
291 | if(QDir(strItem).exists()){ | 293 | if(QDir(strItem).exists()){ |
292 | currentDir.cd(strItem, TRUE); | 294 | currentDir.cd(strItem, TRUE); |
293 | populateList(); | 295 | populateList(); |
294 | } | 296 | } |
295 | } else { | 297 | } else { |
296 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); | 298 | strItem=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+strItem); |
297 | if( QFile::exists(strItem ) ) { | 299 | if( QFile::exists(strItem ) ) { |
298 | //currentDir.canonicalPath() | 300 | //currentDir.canonicalPath() |
299 | qDebug("We found our files!!"+strItem); | 301 | qDebug("We found our files!!"+strItem); |
300 | OnOK(); | 302 | OnOK(); |
301 | } | 303 | } |
302 | } //end not symlink | 304 | } //end not symlink |
303 | chdir(strItem.latin1()); | 305 | chdir(strItem.latin1()); |
304 | } | 306 | } |
307 | } | ||
305 | } | 308 | } |
306 | 309 | ||
307 | void fileBrowser::OnOK() | 310 | void fileBrowser::OnOK() |
308 | { | 311 | { |
309 | QListViewItemIterator it1( ListView); | 312 | QListViewItemIterator it1( ListView); |
310 | for ( ; it1.current(); ++it1 ) { | 313 | for ( ; it1.current(); ++it1 ) { |
311 | if ( it1.current()->isSelected() ) { | 314 | if ( it1.current()->isSelected() ) { |
312 | selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0)); | 315 | selectedFileName=QDir::cleanDirPath(currentDir.canonicalPath()+"/"+it1.current()->text(0)); |
313 | qDebug("selected filename is "+selectedFileName); | 316 | qDebug("selected filename is "+selectedFileName); |
314 | fileList.append( selectedFileName ); | 317 | fileList.append( selectedFileName ); |
315 | } | 318 | } |
316 | } | 319 | } |
317 | accept(); | 320 | accept(); |
318 | } | 321 | } |
319 | 322 | ||
320 | void fileBrowser::homeButtonPushed() { | 323 | void fileBrowser::homeButtonPushed() { |
321 | QString current = QDir::homeDirPath(); | 324 | QString current = QDir::homeDirPath(); |
322 | chdir( current.latin1() ); | 325 | chdir( current.latin1() ); |
323 | currentDir.cd( current, TRUE); | 326 | currentDir.cd( current, TRUE); |
324 | populateList(); | 327 | populateList(); |
325 | update(); | 328 | update(); |
326 | } | 329 | } |
327 | 330 | ||
328 | void fileBrowser::docButtonPushed() { | 331 | void fileBrowser::docButtonPushed() { |
329 | QString current = QPEApplication::documentDir(); | 332 | QString current = QPEApplication::documentDir(); |
330 | chdir( current.latin1() ); | 333 | chdir( current.latin1() ); |
331 | currentDir.cd( current, TRUE); | 334 | currentDir.cd( current, TRUE); |
332 | populateList(); | 335 | populateList(); |
333 | update(); | 336 | update(); |
334 | 337 | ||
335 | } | 338 | } |
336 | 339 | ||
@@ -349,123 +352,127 @@ void fileBrowser::selectionChanged( const QString &select ) | |||
349 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); | 352 | currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All); |
350 | 353 | ||
351 | populateList(); | 354 | populateList(); |
352 | update(); | 355 | update(); |
353 | dirPathCombo->show(); | 356 | dirPathCombo->show(); |
354 | cdUpButton->show(); | 357 | cdUpButton->show(); |
355 | docButton->show(); | 358 | docButton->show(); |
356 | homeButton->show(); | 359 | homeButton->show(); |
357 | FileStack->raiseWidget( ListView ); | 360 | FileStack->raiseWidget( ListView ); |
358 | } | 361 | } |
359 | } | 362 | } |
360 | 363 | ||
361 | void fileBrowser::docOpen( const DocLnk &doc ) | 364 | void fileBrowser::docOpen( const DocLnk &doc ) |
362 | { | 365 | { |
363 | fileList.append( doc.file().latin1() ); | 366 | fileList.append( doc.file().latin1() ); |
364 | accept(); | 367 | accept(); |
365 | } | 368 | } |
366 | 369 | ||
367 | void fileBrowser::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) | 370 | void fileBrowser::ListPressed( int mouse, QListViewItem *item, const QPoint &point, int i) |
368 | { | 371 | { |
369 | switch (mouse) { | 372 | switch (mouse) { |
370 | case 1: | 373 | case 1: |
371 | break; | 374 | break; |
372 | case 2: | 375 | case 2: |
373 | showListMenu(item); | 376 | showListMenu(item); |
374 | break; | 377 | break; |
375 | }; | 378 | }; |
376 | } | 379 | } |
377 | 380 | ||
378 | void fileBrowser::showListMenu(QListViewItem *item) { | 381 | void fileBrowser::showListMenu(QListViewItem *item) { |
379 | 382 | ||
380 | QPopupMenu m;// = new QPopupMenu( Local_View ); | 383 | QPopupMenu m;// = new QPopupMenu( Local_View ); |
381 | if( item->text(0).find("/",0,TRUE)) | 384 | if(item) { |
382 | m.insertItem( tr( "Change Directory" ), this, SLOT( doCd() )); | 385 | if( item->text(0).find("/",0,TRUE)) |
383 | else | 386 | m.insertItem( tr( "Change Directory" ), this, SLOT( doCd() )); |
384 | m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() )); | 387 | m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() )); |
385 | m.insertItem( tr( "Rescan" ), this, SLOT( populateList() )); | 388 | m.insertItem( tr( "Rescan" ), this, SLOT( populateList() )); |
386 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); | 389 | m.insertItem( tr( "Rename" ), this, SLOT( localRename() )); |
387 | m.insertSeparator(); | 390 | m.insertSeparator(); |
388 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); | 391 | m.insertItem( tr( "Delete" ), this, SLOT( localDelete() )); |
392 | } else { | ||
393 | m.insertItem( tr( "Make Directory" ), this, SLOT( makDir() )); | ||
394 | m.insertItem( tr( "Rescan" ), this, SLOT( populateList() )); | ||
395 | |||
396 | } | ||
389 | m.exec( QCursor::pos() ); | 397 | m.exec( QCursor::pos() ); |
390 | |||
391 | } | 398 | } |
392 | 399 | ||
393 | void fileBrowser::doCd() { | 400 | void fileBrowser::doCd() { |
394 | listClicked( ListView->currentItem()); | 401 | listClicked( ListView->currentItem()); |
395 | } | 402 | } |
396 | 403 | ||
397 | void fileBrowser::makDir() { | 404 | void fileBrowser::makDir() { |
398 | InputDialog *fileDlg; | 405 | InputDialog *fileDlg; |
399 | fileDlg = new InputDialog(this,"Make Directory",TRUE, 0); | 406 | fileDlg = new InputDialog(this,"Make Directory",TRUE, 0); |
400 | fileDlg->exec(); | 407 | fileDlg->exec(); |
401 | if( fileDlg->result() == 1 ) { | 408 | if( fileDlg->result() == 1 ) { |
402 | QString filename = fileDlg->LineEdit1->text(); | 409 | QString filename = fileDlg->LineEdit1->text(); |
410 | qDebug("Make dir"); | ||
403 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); | 411 | currentDir.mkdir( currentDir.canonicalPath()+"/"+filename); |
404 | } | 412 | } |
405 | populateList(); | 413 | populateList(); |
406 | } | 414 | } |
407 | 415 | ||
408 | void fileBrowser::localRename() { | 416 | void fileBrowser::localRename() { |
409 | QString curFile = ListView->currentItem()->text(0); | 417 | QString curFile = ListView->currentItem()->text(0); |
410 | InputDialog *fileDlg; | 418 | InputDialog *fileDlg; |
411 | fileDlg = new InputDialog(this,"Rename",TRUE, 0); | 419 | fileDlg = new InputDialog(this,"Rename",TRUE, 0); |
412 | fileDlg->inputText = curFile; | 420 | fileDlg->inputText = curFile; |
413 | fileDlg->exec(); | 421 | fileDlg->exec(); |
414 | if( fileDlg->result() == 1 ) { | 422 | if( fileDlg->result() == 1 ) { |
415 | QString oldname = currentDir.canonicalPath() + "/" + curFile; | 423 | QString oldname = currentDir.canonicalPath() + "/" + curFile; |
416 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; | 424 | QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();//+".playlist"; |
417 | if( rename(oldname.latin1(), newName.latin1())== -1) | 425 | if( rename(oldname.latin1(), newName.latin1())== -1) |
418 | QMessageBox::message("Note","Could not rename"); | 426 | QMessageBox::message("Note","Could not rename"); |
419 | } | 427 | } |
420 | populateList(); | 428 | populateList(); |
421 | } | 429 | } |
422 | 430 | ||
423 | void fileBrowser::localDelete() { | 431 | void fileBrowser::localDelete() { |
424 | QString f = ListView->currentItem()->text(0); | 432 | QString f = ListView->currentItem()->text(0); |
425 | if(QDir(f).exists() ) { | 433 | if(QDir(f).exists() ) { |
426 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+ | 434 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f+ |
427 | " ?\nIt must be empty","Yes","No",0,0,1) ) { | 435 | " ?\nIt must be empty","Yes","No",0,0,1) ) { |
428 | case 0: { | 436 | case 0: { |
429 | f=currentDir.canonicalPath()+"/"+f; | 437 | f=currentDir.canonicalPath()+"/"+f; |
430 | QString cmd="rmdir "+f; | 438 | QString cmd="rmdir "+f; |
431 | system( cmd.latin1()); | 439 | system( cmd.latin1()); |
432 | populateList(); | 440 | populateList(); |
433 | } | 441 | } |
434 | break; | 442 | break; |
435 | case 1: | 443 | case 1: |
436 | // exit | 444 | // exit |
437 | break; | 445 | break; |
438 | }; | 446 | }; |
439 | |||
440 | } else { | 447 | } else { |
441 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f | 448 | switch ( QMessageBox::warning(this,"Delete","Do you really want to delete\n"+f |
442 | +" ?","Yes","No",0,0,1) ) { | 449 | +" ?","Yes","No",0,0,1) ) { |
443 | case 0: { | 450 | case 0: { |
444 | f=currentDir.canonicalPath()+"/"+f; | 451 | f=currentDir.canonicalPath()+"/"+f; |
445 | QString cmd="rm "+f; | 452 | QString cmd="rm "+f; |
446 | system( cmd.latin1()); | 453 | system( cmd.latin1()); |
447 | populateList(); | 454 | populateList(); |
448 | } | 455 | } |
449 | break; | 456 | break; |
450 | case 1: | 457 | case 1: |
451 | // exit | 458 | // exit |
452 | break; | 459 | break; |
453 | }; | 460 | }; |
454 | } | 461 | } |
455 | } | 462 | } |
456 | 463 | ||
457 | void fileBrowser::updateMimeTypeMenu() { | 464 | void fileBrowser::updateMimeTypeMenu() { |
458 | 465 | ||
459 | disconnect( typemb, SIGNAL(selected(const QString&)), | 466 | disconnect( typemb, SIGNAL(selected(const QString&)), |
460 | this, SLOT(showType(const QString&)) ); | 467 | this, SLOT(showType(const QString&)) ); |
461 | 468 | ||
462 | QString prev; | 469 | QString prev; |
463 | 470 | ||
464 | // Type filter | 471 | // Type filter |
465 | QStringList types; | 472 | QStringList types; |
466 | types << tr("All"); | 473 | types << tr("All"); |
467 | types << "--"; | 474 | types << "--"; |
468 | types += getMimeTypes(); | 475 | types += getMimeTypes(); |
469 | prev = typemb->currentText(); | 476 | prev = typemb->currentText(); |
470 | typemb->clear(); | 477 | typemb->clear(); |
471 | typemb->insertItems(types); | 478 | typemb->insertItems(types); |
diff --git a/core/apps/textedit/fileBrowser.h b/core/apps/textedit/fileBrowser.h index 339483f..e76c7df 100644 --- a/core/apps/textedit/fileBrowser.h +++ b/core/apps/textedit/fileBrowser.h | |||
@@ -38,65 +38,65 @@ class QListViewItem; | |||
38 | class QPushButton; | 38 | class QPushButton; |
39 | class QComboBox; | 39 | class QComboBox; |
40 | class QWidgetStack; | 40 | class QWidgetStack; |
41 | class FileSelector; | 41 | class FileSelector; |
42 | class QPoint; | 42 | class QPoint; |
43 | class MenuButton; | 43 | class MenuButton; |
44 | class QRegExp; | 44 | class QRegExp; |
45 | 45 | ||
46 | 46 | ||
47 | class fileBrowser : public QDialog | 47 | class fileBrowser : public QDialog |
48 | { | 48 | { |
49 | Q_OBJECT | 49 | Q_OBJECT |
50 | 50 | ||
51 | public: | 51 | public: |
52 | fileBrowser( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0); | 52 | fileBrowser( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ,const QString filter=0); |
53 | ~fileBrowser(); | 53 | ~fileBrowser(); |
54 | 54 | ||
55 | QString selectedFileName; | 55 | QString selectedFileName; |
56 | QFile file; | 56 | QFile file; |
57 | QStringList fileList; | 57 | QStringList fileList; |
58 | QComboBox *SelectionCombo; | 58 | QComboBox *SelectionCombo; |
59 | public slots: | 59 | public slots: |
60 | void setFileView( int ); | 60 | void setFileView( int ); |
61 | 61 | ||
62 | private: | 62 | private: |
63 | // QDict<void> mimes; | 63 | // QDict<void> mimes; |
64 | QPushButton *buttonOk, *buttonCancel, *homeButton, *docButton, *hideButton, *cdUpButton; | 64 | QPushButton *buttonOk, *buttonCancel, *homeButton, *docButton, *hideButton, *cdUpButton; |
65 | QListView* ListView; | 65 | QListView* ListView; |
66 | QLabel *dirLabel; | 66 | QLabel *dirLabel; |
67 | QString filterStr, mimeType; | 67 | QString filterStr, mimeType; |
68 | QDir currentDir; | 68 | QDir currentDir; |
69 | QStringList dirPathStringList, mimetypes; | 69 | QStringList dirPathStringList, mimetypes; |
70 | QListViewItem * item; | 70 | /* QListViewItem * item; */ |
71 | QComboBox *dirPathCombo; | 71 | QComboBox *dirPathCombo; |
72 | MenuButton *typemb; | 72 | MenuButton *typemb; |
73 | QWidgetStack *FileStack; | 73 | QWidgetStack *FileStack; |
74 | FileSelector *fileSelector; | 74 | FileSelector *fileSelector; |
75 | QRegExp tf; | 75 | QRegExp tf; |
76 | QStringList getMimeTypes(); | 76 | QStringList getMimeTypes(); |
77 | void fillCombo( const QString&); | 77 | void fillCombo( const QString&); |
78 | 78 | ||
79 | private slots: | 79 | private slots: |
80 | void populateList(); | 80 | void populateList(); |
81 | void homeButtonPushed(); | 81 | void homeButtonPushed(); |
82 | void docButtonPushed(); | 82 | void docButtonPushed(); |
83 | void ListPressed( int, QListViewItem *, const QPoint&, int); | 83 | void ListPressed( int, QListViewItem *, const QPoint&, int); |
84 | void showListMenu(QListViewItem*); | 84 | void showListMenu(QListViewItem*); |
85 | void doCd(); | 85 | void doCd(); |
86 | void makDir(); | 86 | void makDir(); |
87 | void localRename(); | 87 | void localRename(); |
88 | void localDelete(); | 88 | void localDelete(); |
89 | void receive( const QCString &msg, const QByteArray &data ); | 89 | void receive( const QCString &msg, const QByteArray &data ); |
90 | void dirPathComboActivated( const QString & ); | 90 | void dirPathComboActivated( const QString & ); |
91 | void upDir(); | 91 | void upDir(); |
92 | void listClicked( QListViewItem * ); | 92 | void listClicked( QListViewItem * ); |
93 | void selectionChanged( const QString & ); | 93 | void selectionChanged( const QString & ); |
94 | void OnOK(); | 94 | void OnOK(); |
95 | void docOpen( const DocLnk & ); | 95 | void docOpen( const DocLnk & ); |
96 | void updateMimeTypeMenu(); | 96 | void updateMimeTypeMenu(); |
97 | void showType(const QString &); | 97 | void showType(const QString &); |
98 | void dirPathEditPressed(); | 98 | void dirPathEditPressed(); |
99 | 99 | ||
100 | protected slots: | 100 | protected slots: |
101 | 101 | ||
102 | protected: | 102 | protected: |
diff --git a/core/apps/textedit/fileSaver.cpp b/core/apps/textedit/fileSaver.cpp index 07fb5ba..f2a5355 100644 --- a/core/apps/textedit/fileSaver.cpp +++ b/core/apps/textedit/fileSaver.cpp | |||
@@ -1,158 +1,195 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** copyright 2001 ljp ljp@llornkcor.com | 2 | ** copyright 2001 ljp ljp@llornkcor.com |
3 | ** Created: Fri Dec 14 08:16:46 2001 fileSaver.cpp | 3 | ** Created: Fri Dec 14 08:16:46 2001 fileSaver.cpp |
4 | ** | 4 | ** |
5 | ** This file may be distributed and/or modified under the terms of the | 5 | ** This file may be distributed and/or modified under the terms of the |
6 | ** GNU General Public License version 2 as published by the Free Software | 6 | ** GNU General Public License version 2 as published by the Free Software |
7 | ** Foundation and appearing in the file LICENSE.GPL included in the | 7 | ** Foundation and appearing in the file LICENSE.GPL included in the |
8 | ** packaging of this file. | 8 | ** packaging of this file. |
9 | ** | 9 | ** |
10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 10 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 11 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
12 | ** | 12 | ** |
13 | ****************************************************************************/ | 13 | ****************************************************************************/ |
14 | #include "fileSaver.h" | 14 | #include "fileSaver.h" |
15 | #include <qpe/config.h> | 15 | #include <qpe/config.h> |
16 | #include <qpe/resource.h> | 16 | #include <qpe/resource.h> |
17 | #include <qpe/mimetype.h> | ||
17 | 18 | ||
18 | #include <qpe/qpeapplication.h> | 19 | #include <qpe/qpeapplication.h> |
19 | #include <qlistview.h> | 20 | #include <qlistview.h> |
20 | #include <qpushbutton.h> | 21 | #include <qpushbutton.h> |
21 | #include <qfile.h> | 22 | #include <qfile.h> |
22 | #include <qmessagebox.h> | 23 | #include <qmessagebox.h> |
23 | #include <qlineedit.h> | 24 | #include <qlineedit.h> |
24 | #include <qcheckbox.h> | 25 | #include <qcheckbox.h> |
25 | 26 | ||
26 | #include <unistd.h> | 27 | #include <unistd.h> |
27 | 28 | ||
28 | fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl , const QString currentFileName ) | 29 | fileSaver::fileSaver( QWidget* parent, const char* name, bool modal, WFlags fl , const QString currentFileName ) |
29 | : QDialog( parent, name, modal, fl ) | 30 | : QDialog( parent, name, modal, fl ) |
30 | { | 31 | { |
31 | if ( !name ) | 32 | if ( !name ) |
32 | setName( "fileSaver" ); | 33 | setName( "fileSaver" ); |
33 | resize( 240, 280 ); | 34 | resize( 240, 280 ); |
34 | setCaption(tr( name ) ); | 35 | setCaption(tr( name ) ); |
35 | QFileInfo fi(currentFileName); | 36 | QFileInfo fi(currentFileName); |
36 | QString tmpFileName=fi.fileName(); | 37 | QString tmpFileName=fi.fileName(); |
37 | // qDebug( tmpFileName); | 38 | // qDebug( tmpFileName); |
38 | dirLabel = new QLabel(this, "DirLabel"); | 39 | dirLabel = new QLabel(this, "DirLabel"); |
39 | dirLabel->setText(currentDir.canonicalPath()); | 40 | dirLabel->setText(currentDir.canonicalPath()); |
40 | dirLabel->setGeometry(10,20,230,15); | 41 | dirLabel->setGeometry(10,20,230,15); |
41 | 42 | ||
42 | homeButton = new QPushButton(Resource::loadIconSet("home"),"",this,"homeButton"); | 43 | homeButton = new QPushButton(Resource::loadIconSet("home"),"",this,"homeButton"); |
43 | homeButton->setGeometry(200,4,25,25); | 44 | homeButton->setGeometry(200,4,25,25); |
44 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); | 45 | connect(homeButton,SIGNAL(released()),this,SLOT(homeButtonPushed()) ); |
45 | homeButton->setFlat(TRUE); | 46 | homeButton->setFlat(TRUE); |
46 | 47 | ||
47 | docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); | 48 | docButton = new QPushButton(Resource::loadIconSet("DocsIcon"),"",this,"docsButton"); |
48 | docButton->setGeometry(170,4,25,25); | 49 | docButton->setGeometry(170,4,25,25); |
49 | connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); | 50 | connect( docButton,SIGNAL(released()),this,SLOT( docButtonPushed()) ); |
51 | |||
50 | docButton->setFlat(TRUE); | 52 | docButton->setFlat(TRUE); |
51 | 53 | ||
52 | hideButton = new QPushButton( Resource::loadIconSet("textedit/s_hidden"),"",this,"hideButton"); | 54 | hideButton = new QPushButton( Resource::loadIconSet("textedit/s_hidden"),"",this,"hideButton"); |
53 | hideButton->setGeometry(140,4,25,25); | 55 | hideButton->setGeometry(140,4,25,25); |
54 | connect( hideButton,SIGNAL(toggled(bool)),this,SLOT( hideButtonPushed(bool)) ); | 56 | connect( hideButton,SIGNAL(toggled(bool)),this,SLOT( hideButtonPushed(bool)) ); |
55 | hideButton->setToggleButton(TRUE); | 57 | hideButton->setToggleButton(TRUE); |
56 | hideButton->setFlat(TRUE); | 58 | hideButton->setFlat(TRUE); |
57 | 59 | ||
58 | ListView = new QListView( this, "ListView" ); | 60 | ListView = new QListView( this, "ListView" ); |
59 | ListView->addColumn( tr( "Name" ) ); | 61 | ListView->addColumn( tr( "Name" ) ); |
60 | ListView->setColumnWidth(0,140); | 62 | ListView->setColumnWidth(0,120); |
61 | ListView->setSorting( 2, FALSE); | 63 | ListView->setSorting( 2, FALSE); |
62 | ListView->addColumn( tr( "Size" ) ); | 64 | ListView->addColumn( tr( "Size" ) ); |
63 | ListView->setColumnWidth(1,59); | 65 | ListView->setColumnWidth(1,-1); |
66 | ListView->addColumn( "Date",-1); | ||
67 | |||
64 | ListView->setColumnWidthMode(0,QListView::Manual); | 68 | ListView->setColumnWidthMode(0,QListView::Manual); |
65 | ListView->setColumnAlignment(1,QListView::AlignRight); | 69 | ListView->setColumnAlignment(1,QListView::AlignRight); |
66 | // ListView->setMultiSelection(true); | 70 | // ListView->setMultiSelection(true); |
67 | // ListView->setSelectionMode(QListView::Extended); | 71 | // ListView->setSelectionMode(QListView::Extended); |
68 | 72 | ||
69 | ListView->setAllColumnsShowFocus( TRUE ); | 73 | ListView->setAllColumnsShowFocus( TRUE ); |
70 | ListView->setGeometry( QRect( 10,35,220,125)); | 74 | ListView->setGeometry( QRect( 10,35,220,125)); |
71 | 75 | ||
72 | fileEdit= new QLineEdit(this); | 76 | fileEdit= new QLineEdit(this); |
73 | fileEdit->setGeometry( QRect( 10, 162, 205, 17)); | 77 | fileEdit->setGeometry( QRect( 10, 162, 205, 17)); |
74 | 78 | ||
75 | fileEdit->setText( tmpFileName); | 79 | fileEdit->setText( tmpFileName); |
76 | 80 | ||
77 | filePermCheck = new QCheckBox( this, "SetFilePerms" ); | 81 | filePermCheck = new QCheckBox( this, "SetFilePerms" ); |
78 | filePermCheck->setText("set file permissions"); | 82 | filePermCheck->setText("set file permissions"); |
79 | filePermCheck->setGeometry(10, 178, 150,17); | 83 | filePermCheck->setGeometry(10, 178, 150,17); |
80 | // signals and slots connections | 84 | // signals and slots connections |
81 | connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); | 85 | connect( ListView, SIGNAL(doubleClicked( QListViewItem*)), SLOT(listDoubleClicked(QListViewItem *)) ); |
82 | connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); | 86 | connect( ListView, SIGNAL(pressed( QListViewItem*)), SLOT(listClicked(QListViewItem *)) ); |
83 | 87 | ||
84 | // tmpFileName=fi.FilePath(); | 88 | // tmpFileName=fi.FilePath(); |
85 | // qDebug( tmpFileName); | 89 | // qDebug( tmpFileName); |
86 | currentDir.setPath( QDir::currentDirPath() ); | 90 | currentDir.setPath( QDir::currentDirPath() ); |
87 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All); | 91 | currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden */| QDir::All); |
88 | populateList(); | 92 | populateList(); |
89 | move(0,15); | 93 | move(0,15); |
90 | fileEdit->setFocus(); | 94 | fileEdit->setFocus(); |
91 | } | 95 | } |
92 | 96 | ||
93 | fileSaver::~fileSaver() | 97 | fileSaver::~fileSaver() |
94 | { | 98 | { |
95 | } | 99 | } |
96 | 100 | ||
97 | void fileSaver::populateList() | 101 | void fileSaver::populateList() |
98 | { | 102 | { |
99 | ListView->clear(); | 103 | ListView->clear(); |
104 | bool isDir=FALSE; | ||
100 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); | 105 | currentDir.setSorting(/* QDir::Size*/ /*| QDir::Reversed | */QDir::DirsFirst); |
101 | currentDir.setMatchAllDirs(TRUE); | 106 | currentDir.setMatchAllDirs(TRUE); |
102 | 107 | ||
103 | currentDir.setNameFilter("*"); | 108 | currentDir.setNameFilter("*"); |
104 | QString fileL, fileS; | 109 | QString fileL, fileS, fileDate; |
105 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); | 110 | const QFileInfoList *list = currentDir.entryInfoList( /*QDir::All*/ /*, QDir::SortByMask*/); |
106 | QFileInfoListIterator it(*list); | 111 | QFileInfoListIterator it(*list); |
107 | QFileInfo *fi; | 112 | QFileInfo *fi; |
108 | while ( (fi=it.current()) ) { | 113 | while ( (fi=it.current()) ) { |
109 | 114 | ||
110 | if (fi->isSymLink() ){ | 115 | if (fi->isSymLink() ){ |
111 | QString symLink=fi->readLink(); | 116 | QString symLink=fi->readLink(); |
112 | // qDebug("Symlink detected "+symLink); | 117 | // qDebug("Symlink detected "+symLink); |
113 | QFileInfo sym( symLink); | 118 | QFileInfo sym( symLink); |
114 | fileS.sprintf( "%10li", sym.size() ); | 119 | fileS.sprintf( "%10li", sym.size() ); |
115 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); | 120 | fileL.sprintf( "%s -> %s", sym.fileName().data(),sym.absFilePath().data() ); |
116 | 121 | ||
117 | } else { | 122 | } else { |
118 | // // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); | 123 | // // qDebug("Not a dir: "+currentDir.canonicalPath()+fileL); |
119 | fileS.sprintf( "%10li", fi->size() ); | 124 | fileS.sprintf( "%10li", fi->size() ); |
120 | fileL.sprintf( "%s",fi->fileName().data() ); | 125 | fileL.sprintf( "%s",fi->fileName().data() ); |
121 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { | 126 | if( QDir(QDir::cleanDirPath(currentDir.canonicalPath()+"/"+fileL)).exists() ) { |
122 | fileL+="/"; | 127 | fileL+="/"; |
128 | isDir=TRUE; | ||
123 | // qDebug(currentDir.canonicalPath()+fileL); | 129 | // qDebug(currentDir.canonicalPath()+fileL); |
124 | } | 130 | } |
125 | } | 131 | } |
126 | item= new QListViewItem( ListView,fileL,fileS ); | 132 | if(fileL !="./") { |
133 | item= new QListViewItem( ListView,fileL,fileS , fileDate); | ||
134 | QPixmap pm; | ||
135 | |||
136 | if(isDir || fileL.find("/",0,TRUE) != -1) { | ||
137 | if( !QDir( fi->filePath() ).isReadable()) | ||
138 | pm = Resource::loadPixmap( "lockedfolder" ); | ||
139 | else | ||
140 | pm= Resource::loadPixmap( "folder" ); | ||
141 | item->setPixmap( 0,pm ); | ||
142 | } else { | ||
143 | if( !fi->isReadable() ) | ||
144 | pm = Resource::loadPixmap( "locked" ); | ||
145 | else { | ||
146 | MimeType mt(fi->filePath()); | ||
147 | pm=mt.pixmap(); | ||
148 | if(pm.isNull()) | ||
149 | pm = Resource::loadPixmap( "UnknownDocument-14" ); | ||
150 | item->setPixmap( 0,pm); | ||
151 | } | ||
152 | } | ||
153 | if( fileL.find("->",0,TRUE) != -1) { | ||
154 | // overlay link image | ||
155 | pm= Resource::loadPixmap( "folder" ); | ||
156 | QPixmap lnk = Resource::loadPixmap( "symlink" ); | ||
157 | QPainter painter( &pm ); | ||
158 | painter.drawPixmap( pm.width()-lnk.width(), pm.height()-lnk.height(), lnk ); | ||
159 | pm.setMask( pm.createHeuristicMask( FALSE ) ); | ||
160 | item->setPixmap( 0, pm); | ||
161 | } | ||
162 | } | ||
163 | isDir=FALSE; | ||
127 | ++it; | 164 | ++it; |
128 | } | 165 | } |
129 | ListView->setSorting( 2, FALSE); | 166 | ListView->setSorting( 2, FALSE); |
130 | dirLabel->setText(currentDir.canonicalPath()); | 167 | dirLabel->setText(currentDir.canonicalPath()); |
131 | 168 | ||
132 | 169 | ||
133 | } | 170 | } |
134 | 171 | ||
135 | void fileSaver::upDir() | 172 | void fileSaver::upDir() |
136 | { | 173 | { |
137 | // qDebug(currentDir.canonicalPath()); | 174 | // qDebug(currentDir.canonicalPath()); |
138 | } | 175 | } |
139 | 176 | ||
140 | void fileSaver::listDoubleClicked(QListViewItem *selectedItem) | 177 | void fileSaver::listDoubleClicked(QListViewItem *selectedItem) |
141 | { | 178 | { |
142 | } | 179 | } |
143 | 180 | ||
144 | void fileSaver::listClicked(QListViewItem *selectedItem) | 181 | void fileSaver::listClicked(QListViewItem *selectedItem) |
145 | { | 182 | { |
146 | QString strItem=selectedItem->text(0); | 183 | QString strItem=selectedItem->text(0); |
147 | QString strSize=selectedItem->text(1); | 184 | QString strSize=selectedItem->text(1); |
148 | // qDebug("strItem is "+strItem); | 185 | // qDebug("strItem is "+strItem); |
149 | strSize.stripWhiteSpace(); | 186 | strSize.stripWhiteSpace(); |
150 | // qDebug(strSize); | 187 | // qDebug(strSize); |
151 | 188 | ||
152 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink | 189 | if(strItem.find("@",0,TRUE) !=-1 || strItem.find("->",0,TRUE) !=-1 ) { //if symlink |
153 | QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); | 190 | QString strItem2=strItem.right( (strItem.length()-strItem.find("->",0,TRUE)) -4); |
154 | // qDebug("strItem symlink is "+strItem2); | 191 | // qDebug("strItem symlink is "+strItem2); |
155 | if(QDir(strItem2).exists() ) { | 192 | if(QDir(strItem2).exists() ) { |
156 | currentDir.cd(strItem2, TRUE); | 193 | currentDir.cd(strItem2, TRUE); |
157 | populateList(); | 194 | populateList(); |
158 | } | 195 | } |