summaryrefslogtreecommitdiff
path: root/noncore/settings/tabmanager/tabmanager.cpp
Unidiff
Diffstat (limited to 'noncore/settings/tabmanager/tabmanager.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/tabmanager/tabmanager.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/noncore/settings/tabmanager/tabmanager.cpp b/noncore/settings/tabmanager/tabmanager.cpp
index 5f0899c..c9d7aed 100644
--- a/noncore/settings/tabmanager/tabmanager.cpp
+++ b/noncore/settings/tabmanager/tabmanager.cpp
@@ -196,192 +196,195 @@ void TabManager::removeItem(){
196 196
197 // Remove directory 197 // Remove directory
198 if(item->parent() == NULL){ 198 if(item->parent() == NULL){
199 // Remove .directory file string 199 // Remove .directory file string
200 location = location.mid(0,location.length()-10); 200 location = location.mid(0,location.length()-10);
201 QDir dir; 201 QDir dir;
202 if(!dir.rmdir(location)) 202 if(!dir.rmdir(location))
203 removeSuccessfull = false; 203 removeSuccessfull = false;
204 else 204 else
205 removeSuccessfull = true; 205 removeSuccessfull = true;
206 } 206 }
207 207
208 // If removing failed. 208 // If removing failed.
209 if(!removeSuccessfull){ 209 if(!removeSuccessfull){
210 qDebug((QString("removeItem: ") + location).latin1()); 210 qDebug((QString("removeItem: ") + location).latin1());
211 QMessageBox::critical(this, tr("Message"), tr("Can't remove."), tr("Ok") ); 211 QMessageBox::critical(this, tr("Message"), tr("Can't remove."), tr("Ok") );
212 return; 212 return;
213 } 213 }
214 214
215 // Remove from the installer so it wont fail. 215 // Remove from the installer so it wont fail.
216 // Don't need to do this sense the current install uses rm -f so no error 216 // Don't need to do this sense the current install uses rm -f so no error
217 217
218 // Remove from the gui list. 218 // Remove from the gui list.
219 itemList.remove(item); 219 itemList.remove(item);
220 if(item->parent()) 220 if(item->parent())
221 item->parent()->takeItem(item); 221 item->parent()->takeItem(item);
222 delete item; 222 delete item;
223 223
224 // We have changed something. 224 // We have changed something.
225 changed = true; 225 changed = true;
226} 226}
227 227
228/** 228/**
229 * Helper function. Edits the current item. 229 * Helper function. Edits the current item.
230 * calls editItem with the currently selected item. 230 * calls editItem with the currently selected item.
231 */ 231 */
232void TabManager::editCurrentItem(){ 232void TabManager::editCurrentItem(){
233 editItem(tabList->currentItem()); 233 editItem(tabList->currentItem());
234} 234}
235 235
236/** 236/**
237 * Edit the item that is passed in. 237 * Edit the item that is passed in.
238 * Show application dialog and if anything changed 238 * Show application dialog and if anything changed
239 * @param item the item to edit. 239 * @param item the item to edit.
240 */ 240 */
241void TabManager::editItem( QListViewItem * item){ 241void TabManager::editItem( QListViewItem * item){
242 if(!item) 242 if(!item)
243 return; 243 return;
244 244
245 TabAppLnk app(itemList[item]); 245 TabAppLnk app(itemList[item]);
246 if(!app.isValid()){ 246 if(!app.isValid()){
247 qDebug(QString("editItem: Not a valid applnk file: ") + itemList[item].latin1()); 247 qDebug(QString("editItem: Not a valid applnk file: ") + itemList[item].latin1());
248 return; 248 return;
249 } 249 }
250 250
251 // Fill with all of the icons 251 // Fill with all of the icons
252 if(!application){ 252 if(!application){
253 Wait waitDialog(this, "Wait dialog"); 253 Wait waitDialog(this, "Wait dialog");
254 waitDialog.waitLabel->setText(tr("Gathering icons...")); 254 waitDialog.waitLabel->setText(tr("Gathering icons..."));
255 waitDialog.show(); 255 waitDialog.show();
256 qApp->processEvents(); 256 qApp->processEvents();
257 application = new AppEdit(this, "Application edit", true); 257 application = new AppEdit(this, "Application edit", true);
258 258
259 QDir d(QPEApplication::qpeDir() + "/pics/"); 259 QDir d(QPEApplication::qpeDir() + "/pics/");
260 d.setFilter( QDir::Files); 260 d.setFilter( QDir::Files);
261 261
262 const QFileInfoList *list = d.entryInfoList(); 262 const QFileInfoList *list = d.entryInfoList();
263 QFileInfoListIterator it( *list ); // create list iterator 263 QFileInfoListIterator it( *list ); // create list iterator
264 QFileInfo *fi; // pointer for traversing 264 QFileInfo *fi; // pointer for traversing
265 265
266 while ( (fi=it.current()) ) { // for each file... 266 while ( (fi=it.current()) ) { // for each file...
267 QString fileName = fi->fileName(); 267 QString fileName = fi->fileName();
268 if(fileName.right(4) == ".png"){ 268 if(fileName.right(4) == ".png"){
269 fileName = fileName.mid(0,fileName.length()-4); 269 fileName = fileName.mid(0,fileName.length()-4);
270 QPixmap imageOfFile(Resource::loadPixmap(fileName)); 270 QPixmap imageOfFile(Resource::loadPixmap(fileName));
271 QImage foo = imageOfFile.convertToImage(); 271 QImage foo = imageOfFile.convertToImage();
272 foo = foo.smoothScale(16,16); 272 foo = foo.smoothScale(16,16);
273 imageOfFile.convertFromImage(foo); 273 imageOfFile.convertFromImage(foo);
274 application->iconLineEdit->insertItem(imageOfFile,fileName); 274 application->iconLineEdit->insertItem(imageOfFile,fileName);
275 } 275 }
276 //qDebug(fi->fileName().latin1()); 276 //qDebug(fi->fileName().latin1());
277 ++it; 277 ++it;
278 } 278 }
279 waitDialog.hide(); 279 waitDialog.hide();
280 } 280 }
281 int pixmap = -1; 281 int pixmap = -1;
282 QString pixmapText = app.pixmapString(); 282 QString pixmapText = app.pixmapString();
283 QComboBox *f = application->iconLineEdit; 283 QComboBox *f = application->iconLineEdit;
284 for(int i = 0; i < application->iconLineEdit->count(); i++){ 284 for(int i = 0; i < application->iconLineEdit->count(); i++){
285 if(f->text(i) == pixmapText){ 285 if(f->text(i) == pixmapText){
286 pixmap = i; 286 pixmap = i;
287 break; 287 break;
288 } 288 }
289 } 289 }
290 if(pixmap != -1) 290 if(pixmap != -1)
291 application->iconLineEdit->setCurrentItem(pixmap); 291 application->iconLineEdit->setCurrentItem(pixmap);
292 else if(pixmapText.isEmpty()){
293 application->iconLineEdit->setCurrentItem(0);
294 }
292 else{ 295 else{
293 QPixmap imageOfFile(Resource::loadPixmap(pixmapText)); 296 QPixmap imageOfFile(Resource::loadPixmap(pixmapText));
294 QImage foo = imageOfFile.convertToImage(); 297 QImage foo = imageOfFile.convertToImage();
295 foo = foo.smoothScale(16,16); 298 foo = foo.smoothScale(16,16);
296 imageOfFile.convertFromImage(foo); 299 imageOfFile.convertFromImage(foo);
297 application->iconLineEdit->insertItem(imageOfFile,pixmapText,0); 300 application->iconLineEdit->insertItem(imageOfFile,pixmapText,0);
298 application->iconLineEdit->setCurrentItem(0); 301 application->iconLineEdit->setCurrentItem(0);
299 } 302 }
300 303
301 application->nameLineEdit->setText(app.name()); 304 application->nameLineEdit->setText(app.name());
302 application->execLineEdit->setText(app.exec()); 305 application->execLineEdit->setText(app.exec());
303 application->commentLineEdit->setText(app.comment()); 306 application->commentLineEdit->setText(app.comment());
304 307
305 if(item->parent() == NULL){ 308 if(item->parent() == NULL){
306 application->execLineEdit->setEnabled(false); 309 application->execLineEdit->setEnabled(false);
307 application->TextLabel3->setEnabled(false); 310 application->TextLabel3->setEnabled(false);
308 application->setCaption(tr("Tab")); 311 application->setCaption(tr("Tab"));
309 } 312 }
310 else{ 313 else{
311 application->execLineEdit->setEnabled(true); 314 application->execLineEdit->setEnabled(true);
312 application->TextLabel3->setEnabled(true); 315 application->TextLabel3->setEnabled(true);
313 application->setCaption(tr("Application")); 316 application->setCaption(tr("Application"));
314 } 317 }
315 318
316 // Only do somthing if they hit OK 319 // Only do somthing if they hit OK
317 application->showMaximized(); 320 application->showMaximized();
318 if(application->exec() == 0) 321 if(application->exec() == 0)
319 return; 322 return;
320 323
321 // If nothing has changed exit (hmmm why did they hit ok?) 324 // If nothing has changed exit (hmmm why did they hit ok?)
322 if(app.name() == application->nameLineEdit->text() && 325 if(app.name() == application->nameLineEdit->text() &&
323 app.pixmapString() == application->iconLineEdit->currentText() && 326 app.pixmapString() == application->iconLineEdit->currentText() &&
324 app.comment() == application->commentLineEdit->text() && 327 app.comment() == application->commentLineEdit->text() &&
325 app.exec() == application->execLineEdit->text()) 328 app.exec() == application->execLineEdit->text())
326 return; 329 return;
327 330
328 // Change the applnk file 331 // Change the applnk file
329 QString oldName = app.name(); 332 QString oldName = app.name();
330 app.setName(application->nameLineEdit->text()); 333 app.setName(application->nameLineEdit->text());
331 app.setIcon(application->iconLineEdit->currentText()); 334 app.setIcon(application->iconLineEdit->currentText());
332 app.setComment(application->commentLineEdit->text()); 335 app.setComment(application->commentLineEdit->text());
333 app.setExec(application->execLineEdit->text()); 336 app.setExec(application->execLineEdit->text());
334 if(!app.writeLink()){ 337 if(!app.writeLink()){
335 QMessageBox::critical(this, tr("Message"), "Can't save.", tr("Ok") ); 338 QMessageBox::critical(this, tr("Message"), "Can't save.", tr("Ok") );
336 return; 339 return;
337 } 340 }
338 341
339 // Update the gui icon and name 342 // Update the gui icon and name
340 item->setText(0,app.name()); 343 item->setText(0,app.name());
341 item->setPixmap(0,app.pixmap()); 344 item->setPixmap(0,app.pixmap());
342 345
343 // We have changed something. 346 // We have changed something.
344 changed = true; 347 changed = true;
345 348
346 // If we were dealing with a new folder or new application change 349 // If we were dealing with a new folder or new application change
347 // the file names. Also change the item location in itemList 350 // the file names. Also change the item location in itemList
348 if(oldName == NEW_FOLDER){ 351 if(oldName == NEW_FOLDER){
349 QDir r; 352 QDir r;
350 QString oldName = itemList[item]; 353 QString oldName = itemList[item];
351 oldName = oldName.mid(0,oldName.length()-11); 354 oldName = oldName.mid(0,oldName.length()-11);
352 QString newName = oldName.mid(0,oldName.length()-9); 355 QString newName = oldName.mid(0,oldName.length()-9);
353 newName = newName + "/" + app.name(); 356 newName = newName + "/" + app.name();
354 r.rename(oldName, newName); 357 r.rename(oldName, newName);
355 itemList.remove(item); 358 itemList.remove(item);
356 itemList.insert(item, newName + "/.directory" ); 359 itemList.insert(item, newName + "/.directory" );
357 } 360 }
358 else if(oldName == NEW_APPLICATION){ 361 else if(oldName == NEW_APPLICATION){
359 if(!item->parent()) 362 if(!item->parent())
360 return; 363 return;
361 QString parentDir = itemList[item->parent()]; 364 QString parentDir = itemList[item->parent()];
362 QDir r; 365 QDir r;
363 QString oldName = itemList[item]; 366 QString oldName = itemList[item];
364 QString newName = oldName.mid(0, parentDir.length()-10); 367 QString newName = oldName.mid(0, parentDir.length()-10);
365 newName = newName + app.name() + APPLICATION_EXTENSION; 368 newName = newName + app.name() + APPLICATION_EXTENSION;
366 r.rename(oldName, newName); 369 r.rename(oldName, newName);
367 itemList.remove(item); 370 itemList.remove(item);
368 itemList.insert(item, newName); 371 itemList.insert(item, newName);
369 } 372 }
370} 373}
371 374
372/** 375/**
373 * Move an application from one directory to another. 376 * Move an application from one directory to another.
374 * Move in the gui, move in the applnk file, move in the installer. 377 * Move in the gui, move in the applnk file, move in the installer.
375 * @param item the application to move 378 * @param item the application to move
376 * @pearam newGroup the new parent of this application 379 * @pearam newGroup the new parent of this application
377 */ 380 */
378void TabManager::moveApplication(QListViewItem *item, QListViewItem *newGroup){ 381void TabManager::moveApplication(QListViewItem *item, QListViewItem *newGroup){
379 // Can we even move it? 382 // Can we even move it?
380 if(!item || !item->parent() || newGroup->parent()) 383 if(!item || !item->parent() || newGroup->parent())
381 return; 384 return;
382 if(item->parent() == newGroup) 385 if(item->parent() == newGroup)
383 return; 386 return;
384 387
385 // Get the new folder, new file name, 388 // Get the new folder, new file name,
386 QString newFolder = itemList[newGroup]; 389 QString newFolder = itemList[newGroup];
387 newFolder = newFolder.mid(0,newFolder.length()-11); 390 newFolder = newFolder.mid(0,newFolder.length()-11);