author | leseb <leseb> | 2002-07-08 14:58:34 (UTC) |
---|---|---|
committer | leseb <leseb> | 2002-07-08 14:58:34 (UTC) |
commit | 8b6a15ef84bc6b1c9c1a82689788c6e281780495 (patch) (unidiff) | |
tree | 1d2c2f416aab46103d244a0b9d5b1c764c9f5452 | |
parent | c92049007eaf6615a059425073b03a827d11831e (diff) | |
download | opie-8b6a15ef84bc6b1c9c1a82689788c6e281780495.zip opie-8b6a15ef84bc6b1c9c1a82689788c6e281780495.tar.gz opie-8b6a15ef84bc6b1c9c1a82689788c6e281780495.tar.bz2 |
Sync with 1.2 version + some bug fixes
-rw-r--r-- | noncore/settings/tabmanager/app.cpp | 83 | ||||
-rw-r--r-- | noncore/settings/tabmanager/app.h | 41 | ||||
-rw-r--r-- | noncore/settings/tabmanager/opie-tabmanager.control | 8 | ||||
-rw-r--r-- | noncore/settings/tabmanager/tabapplnk.h | 4 | ||||
-rw-r--r-- | noncore/settings/tabmanager/tablistview.h | 18 | ||||
-rw-r--r-- | noncore/settings/tabmanager/tabmainwindow.h | 17 | ||||
-rw-r--r-- | noncore/settings/tabmanager/tabmanager.cpp | 247 | ||||
-rw-r--r-- | noncore/settings/tabmanager/tabmanager.h | 12 | ||||
-rw-r--r-- | noncore/settings/tabmanager/tabmanager.pro | 37 | ||||
-rw-r--r-- | noncore/settings/tabmanager/tabmanagerbase.cpp | 9 | ||||
-rw-r--r-- | noncore/settings/tabmanager/tabmanagerbase.ui | 22 |
11 files changed, 209 insertions, 289 deletions
diff --git a/noncore/settings/tabmanager/app.cpp b/noncore/settings/tabmanager/app.cpp deleted file mode 100644 index 30ba9a5..0000000 --- a/noncore/settings/tabmanager/app.cpp +++ b/dev/null | |||
@@ -1,83 +0,0 @@ | |||
1 | /**************************************************************************** | ||
2 | ** Form implementation generated from reading ui file 'app.ui' | ||
3 | ** | ||
4 | ** Created: Fri May 3 14:38:15 2002 | ||
5 | ** by: The User Interface Compiler (uic) | ||
6 | ** | ||
7 | ** WARNING! All changes made in this file will be lost! | ||
8 | ****************************************************************************/ | ||
9 | #include "app.h" | ||
10 | |||
11 | #include <qlabel.h> | ||
12 | #include <qlineedit.h> | ||
13 | #include <qpushbutton.h> | ||
14 | #include <qlayout.h> | ||
15 | #include <qvariant.h> | ||
16 | #include <qtooltip.h> | ||
17 | #include <qwhatsthis.h> | ||
18 | |||
19 | /* | ||
20 | * Constructs a AppEdit which is a child of 'parent', with the | ||
21 | * name 'name' and widget flags set to 'f' | ||
22 | * | ||
23 | * The dialog will by default be modeless, unless you set 'modal' to | ||
24 | * TRUE to construct a modal dialog. | ||
25 | */ | ||
26 | AppEdit::AppEdit( QWidget* parent, const char* name, bool modal, WFlags fl ) | ||
27 | : QDialog( parent, name, modal, fl ) | ||
28 | { | ||
29 | if ( !name ) | ||
30 | setName( "AppEdit" ); | ||
31 | resize( 211, 241 ); | ||
32 | setCaption( tr( "Application" ) ); | ||
33 | AppEditLayout = new QGridLayout( this ); | ||
34 | AppEditLayout->setSpacing( 6 ); | ||
35 | AppEditLayout->setMargin( 11 ); | ||
36 | |||
37 | TextLabel3 = new QLabel( this, "TextLabel3" ); | ||
38 | TextLabel3->setText( tr( "Exec" ) ); | ||
39 | |||
40 | AppEditLayout->addWidget( TextLabel3, 2, 0 ); | ||
41 | |||
42 | TextLabel4 = new QLabel( this, "TextLabel4" ); | ||
43 | TextLabel4->setText( tr( "Comment" ) ); | ||
44 | |||
45 | AppEditLayout->addWidget( TextLabel4, 3, 0 ); | ||
46 | |||
47 | TextLabel2 = new QLabel( this, "TextLabel2" ); | ||
48 | TextLabel2->setText( tr( "Icon" ) ); | ||
49 | |||
50 | AppEditLayout->addWidget( TextLabel2, 1, 0 ); | ||
51 | |||
52 | TextLabel1 = new QLabel( this, "TextLabel1" ); | ||
53 | TextLabel1->setText( tr( "Name" ) ); | ||
54 | |||
55 | AppEditLayout->addWidget( TextLabel1, 0, 0 ); | ||
56 | |||
57 | iconLineEdit = new QLineEdit( this, "iconLineEdit" ); | ||
58 | |||
59 | AppEditLayout->addWidget( iconLineEdit, 1, 1 ); | ||
60 | |||
61 | nameLineEdit = new QLineEdit( this, "nameLineEdit" ); | ||
62 | |||
63 | AppEditLayout->addWidget( nameLineEdit, 0, 1 ); | ||
64 | |||
65 | commentLineEdit = new QLineEdit( this, "commentLineEdit" ); | ||
66 | |||
67 | AppEditLayout->addWidget( commentLineEdit, 3, 1 ); | ||
68 | |||
69 | execLineEdit = new QLineEdit( this, "execLineEdit" ); | ||
70 | |||
71 | AppEditLayout->addWidget( execLineEdit, 2, 1 ); | ||
72 | QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); | ||
73 | AppEditLayout->addItem( spacer, 4, 1 ); | ||
74 | } | ||
75 | |||
76 | /* | ||
77 | * Destroys the object and frees any allocated resources | ||
78 | */ | ||
79 | AppEdit::~AppEdit() | ||
80 | { | ||
81 | // no need to delete child widgets, Qt does it all for us | ||
82 | } | ||
83 | |||
diff --git a/noncore/settings/tabmanager/app.h b/noncore/settings/tabmanager/app.h deleted file mode 100644 index ffa6222..0000000 --- a/noncore/settings/tabmanager/app.h +++ b/dev/null | |||
@@ -1,41 +0,0 @@ | |||
1 | /**************************************************************************** | ||
2 | ** Form interface generated from reading ui file 'app.ui' | ||
3 | ** | ||
4 | ** Created: Fri May 3 14:38:09 2002 | ||
5 | ** by: The User Interface Compiler (uic) | ||
6 | ** | ||
7 | ** WARNING! All changes made in this file will be lost! | ||
8 | ****************************************************************************/ | ||
9 | #ifndef APPEDIT_H | ||
10 | #define APPEDIT_H | ||
11 | |||
12 | #include <qvariant.h> | ||
13 | #include <qdialog.h> | ||
14 | class QVBoxLayout; | ||
15 | class QHBoxLayout; | ||
16 | class QGridLayout; | ||
17 | class QLabel; | ||
18 | class QLineEdit; | ||
19 | |||
20 | class AppEdit : public QDialog | ||
21 | { | ||
22 | Q_OBJECT | ||
23 | |||
24 | public: | ||
25 | AppEdit( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); | ||
26 | ~AppEdit(); | ||
27 | |||
28 | QLabel* TextLabel3; | ||
29 | QLabel* TextLabel4; | ||
30 | QLabel* TextLabel2; | ||
31 | QLabel* TextLabel1; | ||
32 | QLineEdit* iconLineEdit; | ||
33 | QLineEdit* nameLineEdit; | ||
34 | QLineEdit* commentLineEdit; | ||
35 | QLineEdit* execLineEdit; | ||
36 | |||
37 | protected: | ||
38 | QGridLayout* AppEditLayout; | ||
39 | }; | ||
40 | |||
41 | #endif // APPEDIT_H | ||
diff --git a/noncore/settings/tabmanager/opie-tabmanager.control b/noncore/settings/tabmanager/opie-tabmanager.control index 0d5c1e7..610a281 100644 --- a/noncore/settings/tabmanager/opie-tabmanager.control +++ b/noncore/settings/tabmanager/opie-tabmanager.control | |||
@@ -1,9 +1,11 @@ | |||
1 | Package: opie-tabmanager | 1 | Package: opie-tabmanager |
2 | Files: bin/tabmanager apps/Settings/tabmanager.desktop pics/tabmanager/tabmanager.png | 2 | Files: bin/tabmanager apps/Settings/tabmanager.desktop pics/tabmanager/tabmanager.png |
3 | Priority: optional | 3 | Priority: optional |
4 | Version: 1.0 | 4 | Section: opie/settings |
5 | Version: $QPE_VERSION-$SUB_VERSION-1.0 | ||
6 | Depends: opie-base ($QPE_VERSION) | ||
5 | Architecture: arm | 7 | Architecture: arm |
6 | Maintainer: Benjamin Meyer <meyerb@sharpsec.com> | 8 | Maintainer: Benjamin Meyer <meyerb@sharpsec.com> |
7 | Section: Settings | ||
8 | Description: Tab Manager | 9 | Description: Tab Manager |
9 | Helps to manage the Applications tab | 10 | Create new tabs, remove old tabs. Edit tab's name, comment and icon. |
11 | Edit applications name, exec, comment and icon. Add/remove applications. | ||
diff --git a/noncore/settings/tabmanager/tabapplnk.h b/noncore/settings/tabmanager/tabapplnk.h index 9333e87..375d33b 100644 --- a/noncore/settings/tabmanager/tabapplnk.h +++ b/noncore/settings/tabmanager/tabapplnk.h | |||
@@ -1,18 +1,18 @@ | |||
1 | #ifndef TABAPPLNK_H | 1 | #ifndef TABAPPLNK_H |
2 | #define TABAPPLNK_H | 2 | #define TABAPPLNK_H |
3 | 3 | ||
4 | #include <qpe/applnk.h> | 4 | #include <qpe/applnk.h> |
5 | 5 | ||
6 | class TabAppLnk : public AppLnk { | 6 | class TabAppLnk : public AppLnk { |
7 | 7 | ||
8 | public: | 8 | public: |
9 | TabAppLnk( const QString & file) :AppLnk(file){ }; | 9 | TabAppLnk( const QString & file) :AppLnk(file){ }; |
10 | 10 | ||
11 | QString pixmapString() { return mIconFile; }; | 11 | QString pixmapString() { return mIconFile; }; |
12 | 12 | ||
13 | }; | 13 | }; |
14 | 14 | ||
15 | #endif | 15 | #endif |
16 | 16 | ||
17 | // tabapplnk.h | 17 | // tabapplnk.h |
18 | 18 | ||
diff --git a/noncore/settings/tabmanager/tablistview.h b/noncore/settings/tabmanager/tablistview.h index 97f9dec..dfd88f7 100644 --- a/noncore/settings/tabmanager/tablistview.h +++ b/noncore/settings/tabmanager/tablistview.h | |||
@@ -1,65 +1,65 @@ | |||
1 | #ifndef TABLISTVIEW_H | 1 | #ifndef TABLISTVIEW_H |
2 | #define TABLISTVIEW_H | 2 | #define TABLISTVIEW_H |
3 | 3 | ||
4 | #include <qlistview.h> | 4 | #include <qlistview.h> |
5 | #include <qcursor.h> | 5 | #include <qcursor.h> |
6 | #include <qapplication.h> | 6 | #include <qapplication.h> |
7 | 7 | ||
8 | class TabListView : public QListView { | 8 | class TabListView : public QListView { |
9 | Q_OBJECT | 9 | Q_OBJECT |
10 | 10 | ||
11 | signals: | 11 | signals: |
12 | void moveItem(QListViewItem *item, QListViewItem *newFolder); | 12 | void moveItem(QListViewItem *item, QListViewItem *newFolder); |
13 | 13 | ||
14 | public: | 14 | public: |
15 | TabListView( QWidget* parent = 0, const char* name = 0) : QListView(parent, name){ currentSelectedItem = NULL; | 15 | TabListView( QWidget* parent = 0, const char* name = 0) : QListView(parent, name){ currentSelectedItem = NULL; |
16 | connect(this, SIGNAL(pressed ( QListViewItem *)), this, SLOT(itemPressed(QListViewItem *))); | 16 | connect(this, SIGNAL(pressed ( QListViewItem *)), this, SLOT(itemPressed(QListViewItem *))); |
17 | internalCursor.setShape(0); | 17 | internalCursor.setShape(0); |
18 | }; | 18 | }; |
19 | 19 | ||
20 | protected: | 20 | protected: |
21 | void contentsMouseReleaseEvent(QMouseEvent* ){ | 21 | void contentsMouseReleaseEvent(QMouseEvent* ){ |
22 | QListViewItem *newGroup = this->currentItem(); | 22 | QListViewItem *newGroup = this->currentItem(); |
23 | // Make sure they are both real. | 23 | // Make sure they are both real. |
24 | if (currentSelectedItem == NULL || newGroup == NULL) | 24 | if (currentSelectedItem == NULL || newGroup == NULL) |
25 | return; | 25 | return; |
26 | // Make sure they are not the same | 26 | // Make sure they are not the same |
27 | if(this->isSelected(currentSelectedItem) == true) | 27 | if(this->isSelected(currentSelectedItem) == true) |
28 | return; | 28 | return; |
29 | 29 | ||
30 | // Ok we have two valid items. | 30 | // Ok we have two valid items. |
31 | if(newGroup->parent()) | 31 | if(newGroup->parent()) |
32 | newGroup = newGroup->parent(); | 32 | newGroup = newGroup->parent(); |
33 | 33 | ||
34 | // Just in case the parent was null | 34 | // Just in case the parent was null |
35 | if(newGroup == NULL) | 35 | if(newGroup == NULL) |
36 | return; | 36 | return; |
37 | 37 | ||
38 | // If the new folder and buddies current parent are the same don't do anything. | 38 | // If the new folder and buddies current parent are the same don't do anything. |
39 | if (newGroup != currentSelectedItem->parent()) | 39 | if (newGroup != currentSelectedItem->parent()) |
40 | moveItem(currentSelectedItem, newGroup); | 40 | moveItem(currentSelectedItem, newGroup); |
41 | currentSelectedItem = NULL; | 41 | currentSelectedItem = NULL; |
42 | qApp->restoreOverrideCursor(); | 42 | qApp->restoreOverrideCursor(); |
43 | }; | 43 | }; |
44 | 44 | ||
45 | private slots: | 45 | private slots: |
46 | void itemPressed(QListViewItem *item){ | 46 | void itemPressed(QListViewItem *item){ |
47 | if(item == NULL || !item->parent()){ | 47 | if(item == NULL || !item->parent()){ |
48 | if(item == NULL) | 48 | if(item == NULL) |
49 | qDebug("Item is NULL"); | 49 | qDebug("Item is NULL"); |
50 | return; | 50 | return; |
51 | } | 51 | } |
52 | 52 | ||
53 | currentSelectedItem = item; | 53 | currentSelectedItem = item; |
54 | internalCursor.setShape(13); | 54 | internalCursor.setShape(13); |
55 | qApp->setOverrideCursor(internalCursor); | 55 | qApp->setOverrideCursor(internalCursor); |
56 | }; | 56 | }; |
57 | 57 | ||
58 | 58 | ||
59 | private: | 59 | private: |
60 | QListViewItem *currentSelectedItem; | 60 | QListViewItem *currentSelectedItem; |
61 | QCursor internalCursor; | 61 | QCursor internalCursor; |
62 | }; | 62 | }; |
63 | 63 | ||
64 | #endif | 64 | #endif |
65 | 65 | ||
diff --git a/noncore/settings/tabmanager/tabmainwindow.h b/noncore/settings/tabmanager/tabmainwindow.h index c76ad9f..69fb15d 100644 --- a/noncore/settings/tabmanager/tabmainwindow.h +++ b/noncore/settings/tabmanager/tabmainwindow.h | |||
@@ -2,34 +2,37 @@ | |||
2 | #define TABMAINWINDOW_H | 2 | #define TABMAINWINDOW_H |
3 | 3 | ||
4 | #include "tabmanager.h" | 4 | #include "tabmanager.h" |
5 | #include <qmainwindow.h> | 5 | #include <qmainwindow.h> |
6 | #include <qtoolbar.h> | 6 | #include <qtoolbar.h> |
7 | #include <qtoolbutton.h> | 7 | #include <qtoolbutton.h> |
8 | #include <qpe/resource.h> | 8 | #include <qpe/resource.h> |
9 | 9 | ||
10 | class TabMainWindow : public QMainWindow { | 10 | class TabMainWindow : public QMainWindow { |
11 | 11 | ||
12 | public: | 12 | public: |
13 | TabMainWindow( QWidget* parent = 0, const char* name = 0) : QMainWindow(parent, name){ | 13 | TabMainWindow( QWidget* parent = 0, const char* name = 0) : QMainWindow(parent, name){ |
14 | tabManager = new TabManager(this, "TabManger"); | 14 | tabManager = new TabManager(this, "TabManger"); |
15 | setCaption("Tab Manager"); | 15 | setCaption("Tab Manager"); |
16 | setToolBarsMovable(false); | ||
16 | this->setCentralWidget(tabManager); | 17 | this->setCentralWidget(tabManager); |
17 | QToolBar *newToolBar = new QToolBar("toolbar", this); | 18 | QToolBar *newToolBar = new QToolBar("toolbar", this); |
18 | 19 | QToolBar *emptyToolBar = new QToolBar("empty", this); | |
19 | // Insert all of the buttons. | 20 | emptyToolBar->setHorizontalStretchable(true); |
21 | |||
22 | // Insert all of the buttons. | ||
20 | QToolButton *newFolder = new QToolButton(Resource::loadPixmap("fileopen"), "New Folder", 0, tabManager, SLOT(newFolder()), newToolBar); | 23 | QToolButton *newFolder = new QToolButton(Resource::loadPixmap("fileopen"), "New Folder", 0, tabManager, SLOT(newFolder()), newToolBar); |
21 | QToolButton *newFile = new QToolButton(Resource::loadPixmap("new"), "New Folder", 0, tabManager, SLOT(newApplication()), newToolBar); | 24 | QToolButton *newFile = new QToolButton(Resource::loadPixmap("new"), "New Application", 0, tabManager, SLOT(newApplication()), newToolBar); |
22 | QToolButton *editItem = new QToolButton(Resource::loadPixmap("edit"), "Edit", 0, tabManager, SLOT(editCurrentItem()), newToolBar); | 25 | QToolButton *editItem = new QToolButton(Resource::loadPixmap("edit"), "Edit", 0, tabManager, SLOT(editCurrentItem()), newToolBar); |
23 | QToolButton *deleteItem = new QToolButton(Resource::loadPixmap("reset"), "Deelete", 0, tabManager, SLOT(removeItem()), newToolBar); | 26 | QToolButton *deleteItem = new QToolButton(Resource::loadPixmap("trash"), "Delete", 0, tabManager, SLOT(removeItem()), newToolBar); |
24 | 27 | ||
25 | }; | 28 | }; |
26 | 29 | ||
27 | protected: | 30 | protected: |
28 | TabManager *tabManager; | 31 | TabManager *tabManager; |
29 | 32 | ||
30 | }; | 33 | }; |
31 | 34 | ||
32 | #endif | 35 | #endif |
33 | 36 | ||
34 | // tabmainwindow.h | 37 | // tabmainwindow.h |
35 | 38 | ||
diff --git a/noncore/settings/tabmanager/tabmanager.cpp b/noncore/settings/tabmanager/tabmanager.cpp index 13aae81..5f0899c 100644 --- a/noncore/settings/tabmanager/tabmanager.cpp +++ b/noncore/settings/tabmanager/tabmanager.cpp | |||
@@ -1,301 +1,353 @@ | |||
1 | #include "tabmanager.h" | 1 | #include "tabmanager.h" |
2 | #include "app.h" | 2 | #include "app.h" |
3 | #include "wait.h" | ||
3 | #include "tabapplnk.h" | 4 | #include "tabapplnk.h" |
4 | 5 | ||
5 | #include <qpe/applnk.h> | 6 | #include <qpe/applnk.h> |
6 | #include <qpe/qpeapplication.h> | ||
7 | #include <qdir.h> | 7 | #include <qdir.h> |
8 | #include <qfile.h> | 8 | #include <qfile.h> |
9 | #include <qtextstream.h> | 9 | #include <qtextstream.h> |
10 | #include <qlistview.h> | 10 | #include <qlistview.h> |
11 | #include <qheader.h> | 11 | #include <qheader.h> |
12 | #include <qcombobox.h> | ||
12 | #include <qlineedit.h> | 13 | #include <qlineedit.h> |
13 | #include <qlabel.h> | 14 | #include <qlabel.h> |
14 | #include <qmessagebox.h> | 15 | #include <qmessagebox.h> |
15 | #include <stdlib.h> | 16 | #include <stdlib.h> |
16 | #include <qpe/qcopenvelope_qws.h> | 17 | #include <qpe/qcopenvelope_qws.h> |
18 | #include <qpe/qpeapplication.h> | ||
19 | #include <qpe/resource.h> | ||
17 | 20 | ||
18 | #define HOME_APP_DIR QPEApplication::qpeDir()+"/apps" // <-- made this a little more flexible | 21 | |
22 | #define HOME_APP_DIR QPEApplication::qpeDir()+"/apps" | ||
19 | #define HOME_APP_INSTALL_DIR "/usr/lib/ipkg/info" | 23 | #define HOME_APP_INSTALL_DIR "/usr/lib/ipkg/info" |
20 | #define NEW_FOLDER "EmptyTab" | 24 | #define NEW_FOLDER "EmptyTab" |
21 | #define NEW_APPLICATION "NewApp" | 25 | #define NEW_APPLICATION "NewApp" |
22 | #define APPLICATION_EXTENSION ".desktop" | 26 | #define APPLICATION_EXTENSION ".desktop" |
23 | #define APPLICATION_EXTENSION_LENGTH 8 | 27 | #define APPLICATION_EXTENSION_LENGTH 8 |
24 | 28 | ||
25 | /** | 29 | /** |
26 | * Constructor. Sets up signals. Performs initial scan of applications | 30 | * Constructor. Sets up signals. Performs initial scan of applications |
27 | * and tabs | 31 | * and tabs |
28 | */ | 32 | */ |
29 | TabManager::TabManager( QWidget* parent, const char* name):TabManagerBase(parent, name), changed(false){ | 33 | TabManager::TabManager( QWidget* parent, const char* name):TabManagerBase(parent, name), changed(false), application(NULL){ |
30 | rescanFolder(HOME_APP_DIR); | 34 | rescanFolder(HOME_APP_DIR); |
31 | 35 | ||
32 | // Connect the signals and slots | 36 | // Connect the signals and slots |
33 | connect(tabList, SIGNAL(doubleClicked(QListViewItem *)), | 37 | connect(tabList, SIGNAL(doubleClicked(QListViewItem *)), this, SLOT(editItem(QListViewItem*))); |
34 | this, SLOT(editItem(QListViewItem*))); | ||
35 | (tabList->header())->hide(); | 38 | (tabList->header())->hide(); |
36 | connect(tabList, SIGNAL(moveItem(QListViewItem *, QListViewItem *)), | 39 | connect(tabList, SIGNAL(moveItem(QListViewItem *, QListViewItem *)), this, SLOT(moveApplication(QListViewItem *, QListViewItem *))); |
37 | this, SLOT(moveApplication(QListViewItem *, QListViewItem *))); | ||
38 | } | 40 | } |
39 | 41 | ||
40 | /** | 42 | /** |
41 | * If anything in the tab's have been changed then update the system or alert | 43 | * If anything in the tab's have been changed then update the system or alert |
42 | * the user. | 44 | * the user. |
43 | */ | 45 | */ |
44 | TabManager::~TabManager(){ | 46 | TabManager::~TabManager(){ |
45 | if(changed){ | 47 | if(changed){ |
46 | //QMessageBox::critical(this, tr("Message"), tr("Please restart Qtopia to see all new changes."),tr("Ok") ); | 48 | // Prompt. |
47 | //filename = fn; | 49 | //int answer = QMessageBox::warning(this, "Message", "Should your desktop be","Yes", "Cancel", 0, 1 ); |
50 | //if (answer) | ||
51 | // return; | ||
48 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 52 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
49 | //e << description << filename << mimetype; | ||
50 | QString link; //we'll just send an empty string | 53 | QString link; //we'll just send an empty string |
51 | e << link; | 54 | e << link; |
52 | } | 55 | } |
53 | } | 56 | } |
54 | 57 | ||
55 | /** | 58 | /** |
56 | * Scans root directory for any tabs or applications. Will recursivly go down, | 59 | * Scans root directory for any tabs or applications. Will recursivly go down, |
57 | * but will not follow symlinks. | 60 | * but will not follow symlinks. |
58 | * @param directory - the directory to look in. | 61 | * @param directory - the directory to look in. |
59 | * @param parent - the parent to place any new tabs or apps into. If parent is | 62 | * @param parent - the parent to place any new tabs or apps into. If parent is |
60 | * NULL then the item is a tab and should be placed as a child of the window. | 63 | * NULL then the item is a tab and should be placed as a child of the window. |
61 | */ | 64 | */ |
62 | void TabManager::rescanFolder(QString directory, QListViewItem* parent){ | 65 | void TabManager::rescanFolder(QString directory, QListViewItem* parent){ |
63 | //qDebug(QString("rescanFolder: ") + directory.latin1()); | 66 | //qDebug(QString("rescanFolder: ") + directory.latin1()); |
64 | 67 | ||
65 | QDir d; | 68 | QDir d; |
66 | d.setPath(directory); | 69 | d.setPath(directory); |
67 | // Show hidden files for .directories | 70 | // Show hidden files for .directories |
68 | d.setFilter( QDir::Files | QDir::Hidden | QDir::Dirs); | 71 | d.setFilter( QDir::Files | QDir::Hidden | QDir::Dirs); |
69 | 72 | ||
70 | const QFileInfoList *list = d.entryInfoList(); | 73 | const QFileInfoList *list = d.entryInfoList(); |
71 | QFileInfoListIterator it( *list ); // create list iterator | 74 | QFileInfoListIterator it( *list ); // create list iterator |
72 | QFileInfo *fi; // pointer for traversing | 75 | QFileInfo *fi; // pointer for traversing |
73 | 76 | ||
74 | while ( (fi=it.current()) ) { // for each file... | 77 | while ( (fi=it.current()) ) { // for each file... |
75 | // If it is a dir and not .. or . then add it as a tab and go down. | 78 | // If it is a dir and not .. or . then add it as a tab and go down. |
76 | if(fi->isDir()){ | 79 | if(fi->isDir()){ |
77 | if(fi->fileName() != ".." && fi->fileName() != ".") { | 80 | if(fi->fileName() != ".." && fi->fileName() != ".") { |
78 | QListViewItem* newItem; | 81 | QListViewItem* newItem; |
79 | if(!parent) | 82 | if(!parent) |
80 | newItem = new QListViewItem(tabList, fi->fileName()); | 83 | newItem = new QListViewItem(tabList, fi->fileName()); |
81 | else | 84 | else |
82 | newItem = new QListViewItem(parent, fi->fileName()); | 85 | newItem = new QListViewItem(parent, fi->fileName()); |
83 | itemList.insert(newItem, directory + "/" + fi->fileName() + "/.directory" ); | 86 | itemList.insert(newItem, directory + "/" + fi->fileName() + "/.directory" ); |
84 | rescanFolder(directory + "/" + fi->fileName(), newItem); | 87 | rescanFolder(directory + "/" + fi->fileName(), newItem); |
85 | } | 88 | } |
86 | } | 89 | } |
87 | else{ | 90 | else{ |
88 | // it is a file, if not a .directory add to parent. | 91 | // it is a file, if not a .directory add to parent. |
89 | 92 | ||
90 | // Change parents name and icon to reflect icon. | 93 | // Change parents name and icon to reflect icon. |
91 | if(fi->fileName() == ".directory"){ | 94 | if(fi->fileName() == ".directory"){ |
92 | AppLnk app(directory + "/" + fi->fileName()); | 95 | AppLnk app(directory + "/" + fi->fileName()); |
93 | if(parent){ | 96 | if(parent){ |
94 | parent->setPixmap(0,app.pixmap()); | 97 | parent->setPixmap(0,app.pixmap()); |
95 | parent->setText(0, app.name()); | 98 | parent->setText(0, app.name()); |
96 | } | 99 | } |
97 | } | 100 | } |
98 | else{ | 101 | else{ |
99 | // Add any desktop files found. | 102 | // Add any desktop files found. |
100 | QListViewItem* newItem; | 103 | QListViewItem* newItem; |
101 | if(directory != HOME_APP_DIR){ | 104 | if(directory != HOME_APP_DIR){ |
102 | if(!parent) | 105 | if(!parent) |
103 | newItem = new QListViewItem(tabList, fi->fileName()); | 106 | newItem = new QListViewItem(tabList, fi->fileName()); |
104 | else | 107 | else |
105 | newItem = new QListViewItem(parent, fi->fileName()); | 108 | newItem = new QListViewItem(parent, fi->fileName()); |
106 | if(fi->fileName().right(APPLICATION_EXTENSION_LENGTH) == APPLICATION_EXTENSION){ | 109 | if(fi->fileName().right(APPLICATION_EXTENSION_LENGTH) == APPLICATION_EXTENSION){ |
107 | AppLnk app(directory + "/" + fi->fileName()); | 110 | AppLnk app(directory + "/" + fi->fileName()); |
108 | newItem->setPixmap(0,app.pixmap()); | 111 | newItem->setPixmap(0,app.pixmap()); |
109 | newItem->setText(0, app.name()); | 112 | newItem->setText(0, app.name()); |
110 | itemList.insert(newItem, directory + "/" + fi->fileName()); | 113 | itemList.insert(newItem, directory + "/" + fi->fileName()); |
111 | } | 114 | } |
112 | } | 115 | } |
113 | } | 116 | } |
114 | } | 117 | } |
115 | ++it; // goto next list element | 118 | ++it; // goto next list element |
116 | } | 119 | } |
117 | } | 120 | } |
118 | 121 | ||
119 | /** | 122 | /** |
120 | * Create a new blank Tab. | 123 | * Create a new blank Tab. |
121 | * Create a physical folder with .directory file | 124 | * Create a physical folder with .directory file |
122 | * Create a item on the list | 125 | * Create a item on the list |
123 | */ | 126 | */ |
124 | void TabManager::newFolder(){ | 127 | void TabManager::newFolder(){ |
125 | QDir r; | 128 | QDir r; |
126 | r.mkdir(QString(HOME_APP_DIR) + "/" + NEW_FOLDER); | 129 | r.mkdir(QString(HOME_APP_DIR) + "/" + NEW_FOLDER); |
127 | system((QString("echo [Desktop Entry] | cat >> ") + HOME_APP_DIR + "/" + NEW_FOLDER "/.directory").latin1()); | 130 | system((QString("echo [Desktop Entry] | cat >> ") + HOME_APP_DIR + "/" + NEW_FOLDER "/.directory").latin1()); |
128 | system((QString("echo Name=" NEW_FOLDER " | cat >> ") + HOME_APP_DIR + "/" + NEW_FOLDER "/.directory").latin1()); | 131 | system((QString("echo Name=" NEW_FOLDER " | cat >> ") + HOME_APP_DIR + "/" + NEW_FOLDER "/.directory").latin1()); |
129 | 132 | ||
130 | QString homeLocation = QString(HOME_APP_DIR) + "/" + NEW_FOLDER + "/.directory"; | 133 | QString homeLocation = QString(HOME_APP_DIR) + "/" + NEW_FOLDER + "/.directory"; |
131 | QListViewItem *newItem = new QListViewItem(tabList, NEW_FOLDER); | 134 | QListViewItem *newItem = new QListViewItem(tabList, NEW_FOLDER); |
132 | itemList.insert(newItem, homeLocation ); | 135 | itemList.insert(newItem, homeLocation ); |
133 | 136 | ||
134 | // We have changed something. | 137 | // We have changed something. |
135 | changed = true; | 138 | changed = true; |
136 | } | 139 | } |
137 | 140 | ||
138 | /** | 141 | /** |
139 | * Create a new blank application | 142 | * Create a new blank application |
140 | * Make sure a tab is selected | 143 | * Make sure a tab is selected |
141 | * create physical file | 144 | * create physical file |
142 | * fill file with default information (entry, name, type). | 145 | * fill file with default information (entry, name, type). |
143 | */ | 146 | */ |
144 | void TabManager::newApplication(){ | 147 | void TabManager::newApplication(){ |
145 | QListViewItem *item = tabList->currentItem(); | 148 | QListViewItem *item = tabList->currentItem(); |
146 | if(!item || item->parent()) | 149 | if(!item || item->parent()) |
147 | return; | 150 | return; |
148 | 151 | ||
149 | QString parentDir = itemList[item].mid(0,itemList[item].length()-11); | 152 | QString parentDir = itemList[item].mid(0,itemList[item].length()-11); |
150 | QString homeLocation = parentDir + "/" NEW_APPLICATION APPLICATION_EXTENSION; | 153 | QString homeLocation = parentDir + "/" NEW_APPLICATION APPLICATION_EXTENSION; |
151 | system((QString("echo [Desktop Entry] | cat >> ") + homeLocation).latin1()); | 154 | system((QString("echo [Desktop Entry] | cat >> ") + homeLocation).latin1()); |
152 | system((QString("echo Name=" NEW_APPLICATION " | cat >> ") + homeLocation).latin1()); | 155 | system((QString("echo Name=" NEW_APPLICATION " | cat >> ") + homeLocation).latin1()); |
153 | int slash = parentDir.findRev('/', -1); | 156 | int slash = parentDir.findRev('/', -1); |
154 | QString folderName = parentDir.mid(slash+1, parentDir.length()); | 157 | QString folderName = parentDir.mid(slash+1, parentDir.length()); |
155 | 158 | ||
156 | system((QString("echo Type=") + folderName + " | cat >> " + homeLocation).latin1()); | 159 | system((QString("echo Type=") + folderName + " | cat >> " + homeLocation).latin1()); |
157 | 160 | ||
158 | // Insert into the tree | 161 | // Insert into the tree |
159 | QListViewItem *newItem = new QListViewItem(item, NEW_APPLICATION); | 162 | QListViewItem *newItem = new QListViewItem(item, NEW_APPLICATION); |
160 | itemList.insert(newItem, homeLocation ); | 163 | itemList.insert(newItem, homeLocation ); |
161 | 164 | ||
162 | // We have changed something. | 165 | // We have changed something. |
163 | changed = true; | 166 | changed = true; |
164 | } | 167 | } |
165 | 168 | ||
166 | /** | 169 | /** |
167 | * Remove the item. | 170 | * Remove the item. |
168 | * Check if we can | 171 | * Check if we can |
169 | * Prompt user | 172 | * Prompt user |
170 | * Delete physical file (Dir, remove .dir, then dir. File, remove file) | 173 | * Delete physical file (Dir, remove .dir, then dir. File, remove file) |
171 | * Remove from installer if need too. | 174 | * Remove from installer if need too. |
172 | */ | 175 | */ |
173 | void TabManager::removeItem(){ | 176 | void TabManager::removeItem(){ |
174 | // Make sure we can delete | 177 | // Make sure we can delete |
175 | QListViewItem *item = tabList->currentItem(); | 178 | QListViewItem *item = tabList->currentItem(); |
176 | if(!item) | 179 | if(!item) |
177 | return; | 180 | return; |
178 | if(item->childCount() > 0){ | 181 | if(item->childCount() > 0){ |
179 | QMessageBox::critical(this, tr("Message"), tr("Can't remove with applications\nstill in the group."), | 182 | QMessageBox::critical(this, tr("Message"), tr("Can't remove with applications\nstill in the group."), tr("Ok") ); |
180 | tr("Ok") ); | 183 | return; |
181 | return; | ||
182 | } | 184 | } |
183 | 185 | ||
184 | // Prompt. | 186 | // Prompt. |
185 | int answer = QMessageBox::warning(this, tr("Message"), tr("Are you sure you want to delete?"), | 187 | int answer = QMessageBox::warning(this, tr("Message"), tr("Are you sure you want to delete?"), tr("Yes"), tr("Cancel"), 0, 1 ); |
186 | tr("Yes"), tr("Cancel"), 0, 1 ); | ||
187 | if (answer) | 188 | if (answer) |
188 | return; | 189 | return; |
189 | 190 | ||
190 | bool removeSuccessfull = true; | 191 | bool removeSuccessfull = true; |
191 | QString location = itemList[item]; | 192 | QString location = itemList[item]; |
192 | // Remove file (.directory in a Directory case) | 193 | // Remove file (.directory in a Directory case) |
193 | if(!QFile::remove(location)) | 194 | if(!QFile::remove(location)) |
194 | removeSuccessfull = false; | 195 | removeSuccessfull = false; |
195 | 196 | ||
196 | // Remove directory | 197 | // Remove directory |
197 | if(item->parent() == NULL){ | 198 | if(item->parent() == NULL){ |
198 | // Remove .directory file string | 199 | // Remove .directory file string |
199 | location = location.mid(0,location.length()-10); | 200 | location = location.mid(0,location.length()-10); |
200 | QDir dir; | 201 | QDir dir; |
201 | if(!dir.rmdir(location)) | 202 | if(!dir.rmdir(location)) |
202 | removeSuccessfull = false; | 203 | removeSuccessfull = false; |
203 | else | 204 | else |
204 | removeSuccessfull = true; | 205 | removeSuccessfull = true; |
205 | |||
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."), | 211 | QMessageBox::critical(this, tr("Message"), tr("Can't remove."), tr("Ok") ); |
212 | tr("Ok") ); | ||
213 | return; | 212 | return; |
214 | } | 213 | } |
215 | 214 | ||
216 | // Remove from the installer so it wont fail. | 215 | // Remove from the installer so it wont fail. |
217 | // 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 |
218 | 217 | ||
219 | // Remove from the gui list. | 218 | // Remove from the gui list. |
220 | itemList.remove(item); | 219 | itemList.remove(item); |
221 | if(item->parent()) | 220 | if(item->parent()) |
222 | item->parent()->takeItem(item); | 221 | item->parent()->takeItem(item); |
223 | delete item; | 222 | delete item; |
224 | 223 | ||
225 | // We have changed something. | 224 | // We have changed something. |
226 | changed = true; | 225 | changed = true; |
227 | } | 226 | } |
228 | 227 | ||
229 | /** | 228 | /** |
230 | * Helper function. Edits the current item. | 229 | * Helper function. Edits the current item. |
231 | * calls editItem with the currently selected item. | 230 | * calls editItem with the currently selected item. |
232 | */ | 231 | */ |
233 | void TabManager::editCurrentItem(){ | 232 | void TabManager::editCurrentItem(){ |
234 | editItem(tabList->currentItem()); | 233 | editItem(tabList->currentItem()); |
235 | } | 234 | } |
236 | 235 | ||
237 | /** | 236 | /** |
238 | * Edit the item that is passed in. | 237 | * Edit the item that is passed in. |
239 | * Show application dialog and if anything changed | 238 | * Show application dialog and if anything changed |
240 | * @param item the item to edit. | 239 | * @param item the item to edit. |
241 | */ | 240 | */ |
242 | void TabManager::editItem( QListViewItem * item){ | 241 | void TabManager::editItem( QListViewItem * item){ |
243 | if(!item) | 242 | if(!item) |
244 | return; | 243 | return; |
245 | 244 | ||
246 | TabAppLnk app(itemList[item]); | 245 | TabAppLnk app(itemList[item]); |
247 | if(!app.isValid()){ | 246 | if(!app.isValid()){ |
248 | qDebug(QString("editItem: Not a valid applnk file: ") + itemList[item].latin1()); | 247 | qDebug(QString("editItem: Not a valid applnk file: ") + itemList[item].latin1()); |
249 | return; | 248 | return; |
249 | } | ||
250 | |||
251 | // Fill with all of the icons | ||
252 | if(!application){ | ||
253 | Wait waitDialog(this, "Wait dialog"); | ||
254 | waitDialog.waitLabel->setText(tr("Gathering icons...")); | ||
255 | waitDialog.show(); | ||
256 | qApp->processEvents(); | ||
257 | application = new AppEdit(this, "Application edit", true); | ||
258 | |||
259 | QDir d(QPEApplication::qpeDir() + "/pics/"); | ||
260 | d.setFilter( QDir::Files); | ||
261 | |||
262 | const QFileInfoList *list = d.entryInfoList(); | ||
263 | QFileInfoListIterator it( *list ); // create list iterator | ||
264 | QFileInfo *fi; // pointer for traversing | ||
265 | |||
266 | while ( (fi=it.current()) ) { // for each file... | ||
267 | QString fileName = fi->fileName(); | ||
268 | if(fileName.right(4) == ".png"){ | ||
269 | fileName = fileName.mid(0,fileName.length()-4); | ||
270 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); | ||
271 | QImage foo = imageOfFile.convertToImage(); | ||
272 | foo = foo.smoothScale(16,16); | ||
273 | imageOfFile.convertFromImage(foo); | ||
274 | application->iconLineEdit->insertItem(imageOfFile,fileName); | ||
275 | } | ||
276 | //qDebug(fi->fileName().latin1()); | ||
277 | ++it; | ||
278 | } | ||
279 | waitDialog.hide(); | ||
250 | } | 280 | } |
251 | 281 | int pixmap = -1; | |
252 | AppEdit application(this, tr("Application edit"), true); | 282 | QString pixmapText = app.pixmapString(); |
253 | application.nameLineEdit->setText(app.name()); | 283 | QComboBox *f = application->iconLineEdit; |
254 | application.iconLineEdit->setText(app.pixmapString()); | 284 | for(int i = 0; i < application->iconLineEdit->count(); i++){ |
255 | application.execLineEdit->setText(app.exec()); | 285 | if(f->text(i) == pixmapText){ |
256 | application.commentLineEdit->setText(app.comment()); | 286 | pixmap = i; |
257 | 287 | break; | |
288 | } | ||
289 | } | ||
290 | if(pixmap != -1) | ||
291 | application->iconLineEdit->setCurrentItem(pixmap); | ||
292 | else{ | ||
293 | QPixmap imageOfFile(Resource::loadPixmap(pixmapText)); | ||
294 | QImage foo = imageOfFile.convertToImage(); | ||
295 | foo = foo.smoothScale(16,16); | ||
296 | imageOfFile.convertFromImage(foo); | ||
297 | application->iconLineEdit->insertItem(imageOfFile,pixmapText,0); | ||
298 | application->iconLineEdit->setCurrentItem(0); | ||
299 | } | ||
300 | |||
301 | application->nameLineEdit->setText(app.name()); | ||
302 | application->execLineEdit->setText(app.exec()); | ||
303 | application->commentLineEdit->setText(app.comment()); | ||
304 | |||
258 | if(item->parent() == NULL){ | 305 | if(item->parent() == NULL){ |
259 | application.execLineEdit->setEnabled(false); | 306 | application->execLineEdit->setEnabled(false); |
260 | application.TextLabel3->setEnabled(false); | 307 | application->TextLabel3->setEnabled(false); |
261 | application.setCaption(tr("Tab")); | 308 | application->setCaption(tr("Tab")); |
262 | } | 309 | } |
263 | 310 | else{ | |
311 | application->execLineEdit->setEnabled(true); | ||
312 | application->TextLabel3->setEnabled(true); | ||
313 | application->setCaption(tr("Application")); | ||
314 | } | ||
315 | |||
264 | // Only do somthing if they hit OK | 316 | // Only do somthing if they hit OK |
265 | if(application.exec() == 0) | 317 | application->showMaximized(); |
318 | if(application->exec() == 0) | ||
266 | return; | 319 | return; |
267 | 320 | ||
268 | // If nothing has changed exit (hmmm why did they hit ok?) | 321 | // If nothing has changed exit (hmmm why did they hit ok?) |
269 | if(app.name() == application.nameLineEdit->text() && | 322 | if(app.name() == application->nameLineEdit->text() && |
270 | app.pixmapString() == application.iconLineEdit->text() && | 323 | app.pixmapString() == application->iconLineEdit->currentText() && |
271 | app.comment() == application.commentLineEdit->text() && | 324 | app.comment() == application->commentLineEdit->text() && |
272 | app.exec() == application.execLineEdit->text()) | 325 | app.exec() == application->execLineEdit->text()) |
273 | return; | 326 | return; |
274 | 327 | ||
275 | // Change the applnk file | 328 | // Change the applnk file |
276 | QString oldName = app.name(); | 329 | QString oldName = app.name(); |
277 | app.setName(application.nameLineEdit->text()); | 330 | app.setName(application->nameLineEdit->text()); |
278 | app.setIcon(application.iconLineEdit->text()); | 331 | app.setIcon(application->iconLineEdit->currentText()); |
279 | app.setComment(application.commentLineEdit->text()); | 332 | app.setComment(application->commentLineEdit->text()); |
280 | app.setExec(application.execLineEdit->text()); | 333 | app.setExec(application->execLineEdit->text()); |
281 | if(!app.writeLink()){ | 334 | if(!app.writeLink()){ |
282 | QMessageBox::critical(this, tr("Message"), tr("Can't save."), | 335 | QMessageBox::critical(this, tr("Message"), "Can't save.", tr("Ok") ); |
283 | tr("Ok") ); | ||
284 | return; | 336 | return; |
285 | } | 337 | } |
286 | 338 | ||
287 | // Update the gui icon and name | 339 | // Update the gui icon and name |
288 | item->setText(0,app.name()); | 340 | item->setText(0,app.name()); |
289 | item->setPixmap(0,app.pixmap()); | 341 | item->setPixmap(0,app.pixmap()); |
290 | 342 | ||
291 | // We have changed something. | 343 | // We have changed something. |
292 | changed = true; | 344 | changed = true; |
293 | 345 | ||
294 | // If we were dealing with a new folder or new application change | 346 | // If we were dealing with a new folder or new application change |
295 | // the file names. Also change the item location in itemList | 347 | // the file names. Also change the item location in itemList |
296 | if(oldName == NEW_FOLDER){ | 348 | if(oldName == NEW_FOLDER){ |
297 | QDir r; | 349 | QDir r; |
298 | QString oldName = itemList[item]; | 350 | QString oldName = itemList[item]; |
299 | oldName = oldName.mid(0,oldName.length()-11); | 351 | oldName = oldName.mid(0,oldName.length()-11); |
300 | QString newName = oldName.mid(0,oldName.length()-9); | 352 | QString newName = oldName.mid(0,oldName.length()-9); |
301 | newName = newName + "/" + app.name(); | 353 | newName = newName + "/" + app.name(); |
@@ -311,86 +363,85 @@ void TabManager::editItem( QListViewItem * item){ | |||
311 | QString oldName = itemList[item]; | 363 | QString oldName = itemList[item]; |
312 | QString newName = oldName.mid(0, parentDir.length()-10); | 364 | QString newName = oldName.mid(0, parentDir.length()-10); |
313 | newName = newName + app.name() + APPLICATION_EXTENSION; | 365 | newName = newName + app.name() + APPLICATION_EXTENSION; |
314 | r.rename(oldName, newName); | 366 | r.rename(oldName, newName); |
315 | itemList.remove(item); | 367 | itemList.remove(item); |
316 | itemList.insert(item, newName); | 368 | itemList.insert(item, newName); |
317 | } | 369 | } |
318 | } | 370 | } |
319 | 371 | ||
320 | /** | 372 | /** |
321 | * Move an application from one directory to another. | 373 | * Move an application from one directory to another. |
322 | * Move in the gui, move in the applnk file, move in the installer. | 374 | * Move in the gui, move in the applnk file, move in the installer. |
323 | * @param item the application to move | 375 | * @param item the application to move |
324 | * @pearam newGroup the new parent of this application | 376 | * @pearam newGroup the new parent of this application |
325 | */ | 377 | */ |
326 | void TabManager::moveApplication(QListViewItem *item, QListViewItem *newGroup){ | 378 | void TabManager::moveApplication(QListViewItem *item, QListViewItem *newGroup){ |
327 | // Can we even move it? | 379 | // Can we even move it? |
328 | if(!item || !item->parent() || newGroup->parent()) | 380 | if(!item || !item->parent() || newGroup->parent()) |
329 | return; | 381 | return; |
330 | if(item->parent() == newGroup) | 382 | if(item->parent() == newGroup) |
331 | return; | 383 | return; |
332 | 384 | ||
333 | // Get the new folder, new file name, | 385 | // Get the new folder, new file name, |
334 | QString newFolder = itemList[newGroup]; | 386 | QString newFolder = itemList[newGroup]; |
335 | newFolder = newFolder.mid(0,newFolder.length()-11); | 387 | newFolder = newFolder.mid(0,newFolder.length()-11); |
336 | int slash = newFolder.findRev('/', -1); | 388 | int slash = newFolder.findRev('/', -1); |
337 | QString folderName = newFolder.mid(slash+1, newFolder.length()); | 389 | QString folderName = newFolder.mid(slash+1, newFolder.length()); |
338 | 390 | ||
339 | QString desktopFile = itemList[item]; | 391 | QString desktopFile = itemList[item]; |
340 | slash = desktopFile.findRev('/', -1); | 392 | slash = desktopFile.findRev('/', -1); |
341 | desktopFile = desktopFile.mid(slash, desktopFile.length()); | 393 | desktopFile = desktopFile.mid(slash, desktopFile.length()); |
342 | newFolder = newFolder + desktopFile; | 394 | newFolder = newFolder + desktopFile; |
343 | 395 | ||
344 | // Move file | 396 | // Move file |
345 | QDir r; | 397 | QDir r; |
346 | if(!r.rename(itemList[item], newFolder)){ | 398 | if(!r.rename(itemList[item], newFolder)){ |
347 | QMessageBox::critical(this, tr("Message"), tr("Can't move application."), | 399 | QMessageBox::critical(this, tr("Message"), "Can't move application.", tr("Ok") ); |
348 | tr("Ok") ); | 400 | return; |
349 | return; | ||
350 | } | 401 | } |
351 | //qDebug((QString("moveApplication: ") + itemList[item]).latin1()); | 402 | //qDebug((QString("moveApplication: ") + itemList[item]).latin1()); |
352 | //qDebug((QString("moveApplication: ") + newFolder).latin1()); | 403 | //qDebug((QString("moveApplication: ") + newFolder).latin1()); |
353 | 404 | ||
354 | // Move in the gui | 405 | // Move in the gui |
355 | item->parent()->takeItem(item); | 406 | item->parent()->takeItem(item); |
356 | newGroup->insertItem(item); | 407 | newGroup->insertItem(item); |
357 | newGroup->setOpen(true); | 408 | newGroup->setOpen(true); |
358 | 409 | ||
359 | // Move file in the installer | 410 | // Move file in the installer |
360 | QString installedAppFile; | 411 | QString installedAppFile; |
361 | if(findInstalledApplication(desktopFile, installedAppFile)) | 412 | if(findInstalledApplication(desktopFile, installedAppFile)) |
362 | swapInstalledLocation(installedAppFile, desktopFile, newFolder); | 413 | swapInstalledLocation(installedAppFile, desktopFile, newFolder); |
363 | else | 414 | else |
364 | qDebug("moveApplication: No installed app found for dekstop file"); | 415 | qDebug("moveApplication: No installed app found for dekstop file"); |
365 | 416 | ||
366 | // Move application type | 417 | // Move application type |
367 | AppLnk app(newFolder); | 418 | AppLnk app(newFolder); |
368 | app.setType(folderName); | 419 | app.setType(folderName); |
369 | app.writeLink(); | 420 | app.writeLink(); |
370 | 421 | ||
371 | // Move in our internal list | 422 | // Move in our internal list |
372 | itemList.remove(item); | 423 | itemList.remove(item); |
373 | itemList.insert(item, newFolder); | 424 | itemList.insert(item, newFolder); |
374 | 425 | ||
375 | // We have changed something. | 426 | // We have changed something. |
376 | changed = true; | 427 | changed = true; |
377 | } | 428 | } |
378 | 429 | ||
379 | /** | 430 | /** |
380 | * File the installed application that has this desktop file. | 431 | * File the installed application that has this desktop file. |
381 | * Go through each file in HOME_APP_INSTALL_DIR and see if it contains desktop | 432 | * Go through each file in HOME_APP_INSTALL_DIR and see if it contains desktop |
382 | * file | 433 | * file |
383 | * @param desktopFile - the .desktop file to search for [foo.desktop] | 434 | * @param desktopFile - the .desktop file to search for [foo.desktop] |
384 | * @param installedAppFile - location of the app install list | 435 | * @param installedAppFile - location of the app install list |
385 | * @return true if successfull, false if file not found. | 436 | * @return true if successfull, false if file not found. |
386 | */ | 437 | */ |
387 | bool TabManager::findInstalledApplication(QString desktopFile, QString &installedAppFile){ | 438 | bool TabManager::findInstalledApplication(QString desktopFile, QString &installedAppFile){ |
388 | 439 | ||
389 | QDir d; | 440 | QDir d; |
390 | d.setPath(HOME_APP_INSTALL_DIR); | 441 | d.setPath(HOME_APP_INSTALL_DIR); |
391 | d.setFilter( QDir::Files ); | 442 | d.setFilter( QDir::Files ); |
392 | 443 | ||
393 | const QFileInfoList *list = d.entryInfoList(); | 444 | const QFileInfoList *list = d.entryInfoList(); |
394 | QFileInfoListIterator it( *list ); // create list iterator | 445 | QFileInfoListIterator it( *list ); // create list iterator |
395 | QFileInfo *fi; // pointer for traversing | 446 | QFileInfo *fi; // pointer for traversing |
396 | 447 | ||
@@ -414,26 +465,26 @@ bool TabManager::findInstalledApplication(QString desktopFile, QString &installe | |||
414 | ++it; // goto next list element | 465 | ++it; // goto next list element |
415 | } | 466 | } |
416 | return false; | 467 | return false; |
417 | } | 468 | } |
418 | 469 | ||
419 | /** | 470 | /** |
420 | * Open a file and replace a file containing the old desktop file with the new. | 471 | * Open a file and replace a file containing the old desktop file with the new. |
421 | * @param installedAppFile application installed list | 472 | * @param installedAppFile application installed list |
422 | * @param desktopFile old .desktop file | 473 | * @param desktopFile old .desktop file |
423 | * @param newLocation new .desktop file | 474 | * @param newLocation new .desktop file |
424 | */ | 475 | */ |
425 | void TabManager::swapInstalledLocation( QString installedAppFile, QString desktopFile, QString newLocation ){ | 476 | void TabManager::swapInstalledLocation( QString installedAppFile, QString desktopFile, QString newLocation ){ |
426 | QFile file(installedAppFile); | 477 | QFile file(installedAppFile); |
427 | if ( !file.open(IO_ReadOnly) ){ | 478 | if ( !file.open(IO_ReadOnly) ){ |
428 | qDebug(QString("swapInstalledLocation: Can't edit file: %1").arg(installedAppFile).latin1()); | 479 | qDebug(QString("swapInstalledLocation: Can't edit file: %1").arg(installedAppFile).latin1()); |
429 | return; | 480 | return; |
430 | } | 481 | } |
431 | 482 | ||
432 | QTextStream stream( &file ); // use a text stream | 483 | QTextStream stream( &file ); // use a text stream |
433 | QString allLines; | 484 | QString allLines; |
434 | while ( !stream.eof() ) { // until end of file... | 485 | while ( !stream.eof() ) { // until end of file... |
435 | QString line = stream.readLine(); // line of text excluding '\n' | 486 | QString line = stream.readLine(); // line of text excluding '\n' |
436 | if(line.contains(desktopFile)) | 487 | if(line.contains(desktopFile)) |
437 | allLines += newLocation; | 488 | allLines += newLocation; |
438 | else | 489 | else |
439 | allLines += line; | 490 | allLines += line; |
diff --git a/noncore/settings/tabmanager/tabmanager.h b/noncore/settings/tabmanager/tabmanager.h index 39865b0..7f8a65e 100644 --- a/noncore/settings/tabmanager/tabmanager.h +++ b/noncore/settings/tabmanager/tabmanager.h | |||
@@ -1,39 +1,43 @@ | |||
1 | #ifndef TABMANAGER_H | 1 | #ifndef TABMANAGER_H |
2 | #define TABMANAGER_H | 2 | #define TABMANAGER_H |
3 | 3 | ||
4 | #include "tabmanagerbase.h" | 4 | #include "tabmanagerbase.h" |
5 | #include <qmap.h> | 5 | #include <qmap.h> |
6 | #include <qevent.h> | 6 | #include <qevent.h> |
7 | 7 | ||
8 | class QListViewItem; | 8 | class QListViewItem; |
9 | class AppEdit; | ||
9 | 10 | ||
10 | class TabManager : public TabManagerBase { | 11 | class TabManager : public TabManagerBase { |
11 | Q_OBJECT | 12 | Q_OBJECT |
12 | 13 | ||
13 | public: | 14 | public: |
14 | TabManager( QWidget* parent = 0, const char* name = 0); | 15 | TabManager( QWidget* parent = 0, const char* name = 0); |
15 | ~TabManager(); | 16 | ~TabManager(); |
16 | bool changed; | 17 | bool changed; |
17 | 18 | ||
18 | public slots: | 19 | public slots: |
19 | void newFolder(); | 20 | void newFolder(); |
20 | void newApplication(); | 21 | void newApplication(); |
21 | void removeItem(); | 22 | void removeItem(); |
22 | void editCurrentItem(); | 23 | void editCurrentItem(); |
23 | 24 | ||
24 | private slots: | 25 | private slots: |
25 | void moveApplication(QListViewItem *, QListViewItem *); | 26 | void moveApplication(QListViewItem *, QListViewItem *); |
26 | void editItem(QListViewItem * item); | 27 | void editItem(QListViewItem * item); |
27 | 28 | ||
28 | protected: | 29 | protected: |
29 | void rescanFolder(QString directory, QListViewItem* parent=NULL); | 30 | void rescanFolder(QString directory, QListViewItem* parent=NULL); |
30 | QMap<QListViewItem *, QString> itemList; | 31 | QMap<QListViewItem *, QString> itemList; |
31 | bool findInstalledApplication(QString desktopFile, QString &installedAppFile); | 32 | bool findInstalledApplication(QString desktopFile, QString &installedAppFile); |
32 | void swapInstalledLocation( QString installedAppFile, QString desktopFile, QString newLocation ); | 33 | void swapInstalledLocation( QString installedAppFile, QString desktopFile, QString newLocation ); |
33 | 34 | ||
35 | private: | ||
36 | AppEdit *application; | ||
37 | |||
34 | }; | 38 | }; |
35 | 39 | ||
36 | #endif | 40 | #endif |
37 | 41 | ||
38 | // tabmanager.h | 42 | // tabmanager.h |
39 | 43 | ||
diff --git a/noncore/settings/tabmanager/tabmanager.pro b/noncore/settings/tabmanager/tabmanager.pro index 999c8b4..5c65a1d 100644 --- a/noncore/settings/tabmanager/tabmanager.pro +++ b/noncore/settings/tabmanager/tabmanager.pro | |||
@@ -1,26 +1,25 @@ | |||
1 | TEMPLATE= app | 1 | TEMPLATE= app |
2 | #CONFIG = qt warn_on debug | ||
3 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on release |
4 | HEADERS = tabmanager.h tabmainwindow.h app.h tablistview.h tabmanagerbase.h tabapplnk.h | 3 | HEADERS = tabmanager.h tabmainwindow.h tablistview.h tabmanagerbase.h tabapplnk.h |
5 | SOURCES = main.cpp tabmanager.cpp app.cpp tabmanagerbase.cpp | 4 | SOURCES = main.cpp tabmanager.cpp tabmanagerbase.cpp |
6 | INCLUDEPATH+= $(OPIEDIR)/include | 5 | INCLUDEPATH+= $(OPIEDIR)/include |
7 | DEPENDPATH+= $(OPIEDIR)/include | 6 | DEPENDPATH+= $(OPIEDIR)/include |
8 | LIBS += -lqpe | 7 | LIBS += -lqpe |
9 | #INTERFACES= tabmanagerbase.ui | 8 | INTERFACES= app.ui wait.ui |
10 | TARGET = tabmanager | 9 | TARGET = tabmanager |
11 | DESTDIR = $(OPIEDIR)/bin | 10 | DESTDIR = $(OPIEDIR)/bin |
12 | 11 | ||
13 | TRANSLATIONS = ../../../i18n/de/tabmanager.ts \ | 12 | TRANSLATIONS =../../../i18n/de/tabmanager.ts \ |
14 | ../../../i18n/en/tabmanager.ts \ | 13 | ../../../i18n/en/tabmanager.ts \ |
15 | ../../../i18n/es/tabmanager.ts \ | 14 | ../../../i18n/es/tabmanager.ts \ |
16 | ../../../i18n/fr/tabmanager.ts \ | 15 | ../../../i18n/fr/tabmanager.ts \ |
17 | ../../../i18n/hu/tabmanager.ts \ | 16 | ../../../i18n/hu/tabmanager.ts \ |
18 | ../../../i18n/ja/tabmanager.ts \ | 17 | ../../../i18n/ja/tabmanager.ts \ |
19 | ../../../i18n/ko/tabmanager.ts \ | 18 | ../../../i18n/ko/tabmanager.ts \ |
20 | ../../../i18n/no/tabmanager.ts \ | 19 | ../../../i18n/no/tabmanager.ts \ |
21 | ../../../i18n/pl/tabmanager.ts \ | 20 | ../../../i18n/pl/tabmanager.ts \ |
22 | ../../../i18n/pt/tabmanager.ts \ | 21 | ../../../i18n/pt/tabmanager.ts \ |
23 | ../../../i18n/pt_BR/tabmanager.ts \ | 22 | ../../../i18n/pt_BR/tabmanager.ts \ |
24 | ../../../i18n/sl/tabmanager.ts \ | 23 | ../../../i18n/sl/tabmanager.ts \ |
25 | ../../../i18n/zh_CN/tabmanager.ts \ | 24 | ../../../i18n/zh_CN/tabmanager.ts \ |
26 | ../../../i18n/zh_TW/tabmanager.ts | 25 | ../../../i18n/zh_TW/tabmanager.ts |
diff --git a/noncore/settings/tabmanager/tabmanagerbase.cpp b/noncore/settings/tabmanager/tabmanagerbase.cpp index a899529..29ec3a5 100644 --- a/noncore/settings/tabmanager/tabmanagerbase.cpp +++ b/noncore/settings/tabmanager/tabmanagerbase.cpp | |||
@@ -21,24 +21,23 @@ | |||
21 | * name 'name' and widget flags set to 'f' | 21 | * name 'name' and widget flags set to 'f' |
22 | */ | 22 | */ |
23 | TabManagerBase::TabManagerBase( QWidget* parent, const char* name, WFlags fl ) | 23 | TabManagerBase::TabManagerBase( QWidget* parent, const char* name, WFlags fl ) |
24 | : QWidget( parent, name, fl ) | 24 | : QWidget( parent, name, fl ) |
25 | { | 25 | { |
26 | if ( !name ) | 26 | if ( !name ) |
27 | setName( "TabManagerBase" ); | 27 | setName( "TabManagerBase" ); |
28 | resize( 289, 228 ); | 28 | resize( 289, 228 ); |
29 | setCaption( tr( "Tab Manger" ) ); | 29 | setCaption( tr( "Tab Manager" ) ); |
30 | TabManagerBaseLayout = new QVBoxLayout( this ); | 30 | TabManagerBaseLayout = new QVBoxLayout( this ); |
31 | TabManagerBaseLayout->setSpacing( 6 ); | 31 | TabManagerBaseLayout->setSpacing( 4 ); |
32 | TabManagerBaseLayout->setMargin( 0 ); | 32 | TabManagerBaseLayout->setMargin( 4 ); |
33 | 33 | ||
34 | tabList = new TabListView( this, "tabList" ); | 34 | tabList = new TabListView( this, "tabList" ); |
35 | tabList->addColumn( tr( "Groups" ) ); | 35 | tabList->addColumn( tr( "Hierarchy" ) ); |
36 | tabList->addColumn( tr( "Applications" ) ); | ||
37 | tabList->setRootIsDecorated( TRUE ); | 36 | tabList->setRootIsDecorated( TRUE ); |
38 | TabManagerBaseLayout->addWidget( tabList ); | 37 | TabManagerBaseLayout->addWidget( tabList ); |
39 | } | 38 | } |
40 | 39 | ||
41 | /* | 40 | /* |
42 | * Destroys the object and frees any allocated resources | 41 | * Destroys the object and frees any allocated resources |
43 | */ | 42 | */ |
44 | TabManagerBase::~TabManagerBase() | 43 | TabManagerBase::~TabManagerBase() |
diff --git a/noncore/settings/tabmanager/tabmanagerbase.ui b/noncore/settings/tabmanager/tabmanagerbase.ui index 2fd10dd..5ac0ff3 100644 --- a/noncore/settings/tabmanager/tabmanagerbase.ui +++ b/noncore/settings/tabmanager/tabmanagerbase.ui | |||
@@ -12,50 +12,36 @@ | |||
12 | <x>0</x> | 12 | <x>0</x> |
13 | <y>0</y> | 13 | <y>0</y> |
14 | <width>289</width> | 14 | <width>289</width> |
15 | <height>228</height> | 15 | <height>228</height> |
16 | </rect> | 16 | </rect> |
17 | </property> | 17 | </property> |
18 | <property stdset="1"> | 18 | <property stdset="1"> |
19 | <name>caption</name> | 19 | <name>caption</name> |
20 | <string>Tab Manger</string> | 20 | <string>Tab Manager</string> |
21 | </property> | 21 | </property> |
22 | <property> | 22 | <property> |
23 | <name>layoutMargin</name> | 23 | <name>layoutMargin</name> |
24 | </property> | 24 | </property> |
25 | <vbox> | 25 | <vbox> |
26 | <property stdset="1"> | 26 | <property stdset="1"> |
27 | <name>margin</name> | 27 | <name>margin</name> |
28 | <number>0</number> | 28 | <number>4</number> |
29 | </property> | 29 | </property> |
30 | <property stdset="1"> | 30 | <property stdset="1"> |
31 | <name>spacing</name> | 31 | <name>spacing</name> |
32 | <number>6</number> | 32 | <number>4</number> |
33 | </property> | 33 | </property> |
34 | <widget> | 34 | <widget> |
35 | <class>QListView</class> | 35 | <class>QListView</class> |
36 | <column> | 36 | <column> |
37 | <property> | 37 | <property> |
38 | <name>text</name> | 38 | <name>text</name> |
39 | <string>Groups</string> | 39 | <string>Hierarchy</string> |
40 | </property> | ||
41 | <property> | ||
42 | <name>clickable</name> | ||
43 | <bool>true</bool> | ||
44 | </property> | ||
45 | <property> | ||
46 | <name>resizeable</name> | ||
47 | <bool>true</bool> | ||
48 | </property> | ||
49 | </column> | ||
50 | <column> | ||
51 | <property> | ||
52 | <name>text</name> | ||
53 | <string>Applications</string> | ||
54 | </property> | 40 | </property> |
55 | <property> | 41 | <property> |
56 | <name>clickable</name> | 42 | <name>clickable</name> |
57 | <bool>true</bool> | 43 | <bool>true</bool> |
58 | </property> | 44 | </property> |
59 | <property> | 45 | <property> |
60 | <name>resizeable</name> | 46 | <name>resizeable</name> |
61 | <bool>true</bool> | 47 | <bool>true</bool> |