summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/tabmanager/tabmanager.cpp122
-rw-r--r--noncore/settings/tabmanager/tabmanager.pro2
2 files changed, 63 insertions, 61 deletions
diff --git a/noncore/settings/tabmanager/tabmanager.cpp b/noncore/settings/tabmanager/tabmanager.cpp
index 4274203..3eae424 100644
--- a/noncore/settings/tabmanager/tabmanager.cpp
+++ b/noncore/settings/tabmanager/tabmanager.cpp
@@ -3,6 +3,8 @@
#include "wait.h"
#include "tabapplnk.h"
+#include <opie2/odebug.h>
+
#include <qpe/applnk.h>
#include <qdir.h>
#include <qfile.h>
@@ -63,8 +65,8 @@ TabManager::~TabManager(){
* NULL then the item is a tab and should be placed as a child of the window.
*/
void TabManager::rescanFolder(QString directory, QListViewItem* parent){
- //odebug << QString("rescanFolder: ") + directory.latin1() << oendl;
-
+ //odebug << QString("rescanFolder: ") + directory.latin1() << oendl;
+
QDir d;
d.setPath(directory);
// Show hidden files for .directories
@@ -89,7 +91,7 @@ void TabManager::rescanFolder(QString directory, QListViewItem* parent){
}
else{
// it is a file, if not a .directory add to parent.
-
+
// Change parents name and icon to reflect icon.
if(fi->fileName() == ".directory"){
AppLnk app(directory + "/" + fi->fileName());
@@ -129,11 +131,11 @@ void TabManager::newFolder(){
r.mkdir(QString(HOME_APP_DIR) + "/" + NEW_FOLDER);
system((QString("echo [Desktop Entry] | cat >> ") + HOME_APP_DIR + "/" + NEW_FOLDER "/.directory").latin1());
system((QString("echo Name=" NEW_FOLDER " | cat >> ") + HOME_APP_DIR + "/" + NEW_FOLDER "/.directory").latin1());
-
+
QString homeLocation = QString(HOME_APP_DIR) + "/" + NEW_FOLDER + "/.directory";
QListViewItem *newItem = new QListViewItem(tabList, NEW_FOLDER);
itemList.insert(newItem, homeLocation );
-
+
// We have changed something.
changed = true;
}
@@ -148,20 +150,20 @@ void TabManager::newApplication(){
QListViewItem *item = tabList->currentItem();
if(!item || item->parent())
return;
-
- QString parentDir = itemList[item].mid(0,itemList[item].length()-11);
+
+ QString parentDir = itemList[item].mid(0,itemList[item].length()-11);
QString homeLocation = parentDir + "/" NEW_APPLICATION APPLICATION_EXTENSION;
system((QString("echo [Desktop Entry] | cat >> ") + homeLocation).latin1());
system((QString("echo Name=" NEW_APPLICATION " | cat >> ") + homeLocation).latin1());
int slash = parentDir.findRev('/', -1);
QString folderName = parentDir.mid(slash+1, parentDir.length());
-
+
system((QString("echo Type=") + folderName + " | cat >> " + homeLocation).latin1());
-
+
// Insert into the tree
QListViewItem *newItem = new QListViewItem(item, NEW_APPLICATION);
itemList.insert(newItem, homeLocation );
-
+
// We have changed something.
changed = true;
}
@@ -172,7 +174,7 @@ void TabManager::newApplication(){
* Prompt user
* Delete physical file (Dir, remove .dir, then dir. File, remove file)
* Remove from installer if need too.
- */
+ */
void TabManager::removeItem(){
// Make sure we can delete
QListViewItem *item = tabList->currentItem();
@@ -180,20 +182,20 @@ void TabManager::removeItem(){
return;
if(item->childCount() > 0){
QMessageBox::critical(this, tr("Message"), tr("Can't remove with applications\nstill in the group."), tr("Ok") );
- return;
+ return;
}
-
+
// Prompt.
int answer = QMessageBox::warning(this, tr("Message"), tr("Are you sure you want to delete?"), tr("Yes"), tr("Cancel"), 0, 1 );
if (answer)
return;
-
+
bool removeSuccessful = true;
QString location = itemList[item];
// Remove file (.directory in a Directory case)
if(!QFile::remove(location))
removeSuccessful = false;
-
+
// Remove directory
if(item->parent() == NULL){
// Remove .directory file string
@@ -204,23 +206,23 @@ void TabManager::removeItem(){
else
removeSuccessful = true;
}
-
- // If removing failed.
+
+ // If removing failed.
if(!removeSuccessful){
- odebug << (QString("removeItem: ") + location).latin1() << oendl;
+ odebug << (QString("removeItem: ") + location).latin1() << oendl;
QMessageBox::critical(this, tr("Message"), tr("Can't remove."), tr("Ok") );
return;
}
-
+
// Remove from the installer so it wont fail.
// Don't need to do this sense the current install uses rm -f so no error
-
+
// Remove from the gui list.
itemList.remove(item);
if(item->parent())
item->parent()->takeItem(item);
delete item;
-
+
// We have changed something.
changed = true;
}
@@ -235,19 +237,19 @@ void TabManager::editCurrentItem(){
/**
* Edit the item that is passed in.
- * Show application dialog and if anything changed
+ * Show application dialog and if anything changed
* @param item the item to edit.
- */
+ */
void TabManager::editItem( QListViewItem * item){
if(!item)
return;
-
+
TabAppLnk app(itemList[item]);
if(!app.isValid()){
- odebug << QString("editItem: Not a valid applnk file: ") + itemList[item].latin1() << oendl;
- return;
- }
-
+ odebug << QString("editItem: Not a valid applnk file: ") + itemList[item].latin1() << oendl;
+ return;
+ }
+
// Fill with all of the icons
if(!application){
Wait waitDialog(this, "Wait dialog");
@@ -255,7 +257,7 @@ void TabManager::editItem( QListViewItem * item){
waitDialog.show();
qApp->processEvents();
application = new AppEdit(this, "Application edit", true);
-
+
QDir d(QPEApplication::qpeDir() + "/pics/");
d.setFilter( QDir::Files);
@@ -271,9 +273,9 @@ void TabManager::editItem( QListViewItem * item){
QImage foo = imageOfFile.convertToImage();
foo = foo.smoothScale(16,16);
imageOfFile.convertFromImage(foo);
- application->iconLineEdit->insertItem(imageOfFile,fileName);
+ application->iconLineEdit->insertItem(imageOfFile,fileName);
}
- //odebug << fi->fileName().latin1() << oendl;
+ //odebug << fi->fileName().latin1() << oendl;
++it;
}
waitDialog.hide();
@@ -297,14 +299,14 @@ void TabManager::editItem( QListViewItem * item){
QImage foo = imageOfFile.convertToImage();
foo = foo.smoothScale(16,16);
imageOfFile.convertFromImage(foo);
- application->iconLineEdit->insertItem(imageOfFile,pixmapText,0);
+ application->iconLineEdit->insertItem(imageOfFile,pixmapText,0);
application->iconLineEdit->setCurrentItem(0);
}
-
+
application->nameLineEdit->setText(app.name());
application->execLineEdit->setText(app.exec());
application->commentLineEdit->setText(app.comment());
-
+
if(item->parent() == NULL){
application->execLineEdit->setEnabled(false);
application->TextLabel3->setEnabled(false);
@@ -315,7 +317,7 @@ void TabManager::editItem( QListViewItem * item){
application->TextLabel3->setEnabled(true);
application->setCaption(tr("Application"));
}
-
+
// Only do somthing if they hit OK
application->showMaximized();
if(application->exec() == 0)
@@ -338,14 +340,14 @@ void TabManager::editItem( QListViewItem * item){
QMessageBox::critical(this, tr("Message"), "Can't save.", tr("Ok") );
return;
}
-
+
// Update the gui icon and name
item->setText(0,app.name());
item->setPixmap(0,app.pixmap());
-
+
// We have changed something.
changed = true;
-
+
// If we were dealing with a new folder or new application change
// the file names. Also change the item location in itemList
if(oldName == NEW_FOLDER){
@@ -371,26 +373,26 @@ void TabManager::editItem( QListViewItem * item){
itemList.insert(item, newName);
}
}
-
+
/**
* Move an application from one directory to another.
* Move in the gui, move in the applnk file, move in the installer.
* @param item the application to move
* @pearam newGroup the new parent of this application
- */
+ */
void TabManager::moveApplication(QListViewItem *item, QListViewItem *newGroup){
// Can we even move it?
if(!item || !item->parent() || newGroup->parent())
- return;
+ return;
if(item->parent() == newGroup)
return;
- // Get the new folder, new file name,
+ // Get the new folder, new file name,
QString newFolder = itemList[newGroup];
newFolder = newFolder.mid(0,newFolder.length()-11);
int slash = newFolder.findRev('/', -1);
QString folderName = newFolder.mid(slash+1, newFolder.length());
-
+
QString desktopFile = itemList[item];
slash = desktopFile.findRev('/', -1);
desktopFile = desktopFile.mid(slash, desktopFile.length());
@@ -400,32 +402,32 @@ void TabManager::moveApplication(QListViewItem *item, QListViewItem *newGroup){
QDir r;
if(!r.rename(itemList[item], newFolder)){
QMessageBox::critical(this, tr("Message"), "Can't move application.", tr("Ok") );
- return;
+ return;
}
- //odebug << (QString("moveApplication: ") + itemList[item]).latin1() << oendl;
- //odebug << (QString("moveApplication: ") + newFolder).latin1() << oendl;
-
+ //odebug << (QString("moveApplication: ") + itemList[item]).latin1() << oendl;
+ //odebug << (QString("moveApplication: ") + newFolder).latin1() << oendl;
+
// Move in the gui
item->parent()->takeItem(item);
newGroup->insertItem(item);
newGroup->setOpen(true);
-
+
// Move file in the installer
QString installedAppFile;
if(findInstalledApplication(desktopFile, installedAppFile))
swapInstalledLocation(installedAppFile, desktopFile, newFolder);
else
- odebug << "moveApplication: No installed app found for dekstop file" << oendl;
-
- // Move application type
+ odebug << "moveApplication: No installed app found for dekstop file" << oendl;
+
+ // Move application type
AppLnk app(newFolder);
app.setType(folderName);
app.writeLink();
-
+
// Move in our internal list
itemList.remove(item);
itemList.insert(item, newFolder);
-
+
// We have changed something.
changed = true;
}
@@ -437,9 +439,9 @@ void TabManager::moveApplication(QListViewItem *item, QListViewItem *newGroup){
* @param desktopFile - the .desktop file to search for [foo.desktop]
* @param installedAppFile - location of the app install list
* @return true if successful, false if file not found.
- */
+ */
bool TabManager::findInstalledApplication(QString desktopFile, QString &installedAppFile){
-
+
QDir d;
d.setPath(HOME_APP_INSTALL_DIR);
d.setFilter( QDir::Files );
@@ -464,7 +466,7 @@ bool TabManager::findInstalledApplication(QString desktopFile, QString &installe
file.close();
}
else
- odebug << (QString("findInstalledApplication: Can't open file") + HOME_APP_INSTALL_DIR + "/" + fi->fileName()).latin1() << oendl;
+ odebug << (QString("findInstalledApplication: Can't open file") + HOME_APP_INSTALL_DIR + "/" + fi->fileName()).latin1() << oendl;
++it; // goto next list element
}
return false;
@@ -473,16 +475,16 @@ bool TabManager::findInstalledApplication(QString desktopFile, QString &installe
/**
* Open a file and replace a file containing the old desktop file with the new.
* @param installedAppFile application installed list
- * @param desktopFile old .desktop file
+ * @param desktopFile old .desktop file
* @param newLocation new .desktop file
*/
void TabManager::swapInstalledLocation( QString installedAppFile, QString desktopFile, QString newLocation ){
QFile file(installedAppFile);
if ( !file.open(IO_ReadOnly) ){
- odebug << QString("swapInstalledLocation: Can't edit file: %1").arg(installedAppFile).latin1() << oendl;
+ odebug << QString("swapInstalledLocation: Can't edit file: %1").arg(installedAppFile).latin1() << oendl;
return;
}
-
+
QTextStream stream( &file ); // use a text stream
QString allLines;
while ( !stream.eof() ) { // until end of file...
@@ -496,7 +498,7 @@ void TabManager::swapInstalledLocation( QString installedAppFile, QString deskto
file.close();
if ( !file.open(IO_ReadWrite) ){
- odebug << QString("swapInstalledLocation: Can't edit file: %1").arg(installedAppFile).latin1() << oendl;
+ odebug << QString("swapInstalledLocation: Can't edit file: %1").arg(installedAppFile).latin1() << oendl;
return;
}
QTextStream streamOut( &file );
diff --git a/noncore/settings/tabmanager/tabmanager.pro b/noncore/settings/tabmanager/tabmanager.pro
index dbc81a3..d4aac43 100644
--- a/noncore/settings/tabmanager/tabmanager.pro
+++ b/noncore/settings/tabmanager/tabmanager.pro
@@ -4,7 +4,7 @@ HEADERS = tabmanager.h tabmainwindow.h tablistview.h tabmanagerbase.h tabapplnk
SOURCES = main.cpp tabmanager.cpp tabmanagerbase.cpp
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
-LIBS += -lqpe
+LIBS += -lqpe -lopiecore2
INTERFACES = app.ui wait.ui
TARGET = tabmanager
DESTDIR = $(OPIEDIR)/bin