summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/tabmanager/app.cpp30
-rw-r--r--noncore/settings/tabmanager/app.h28
-rw-r--r--noncore/settings/tabmanager/main.cpp28
-rw-r--r--noncore/settings/tabmanager/tabapplnk.h28
-rw-r--r--noncore/settings/tabmanager/tablistview.h30
-rw-r--r--noncore/settings/tabmanager/tabmainwindow.h28
-rw-r--r--noncore/settings/tabmanager/tabmanager.cpp29
-rw-r--r--noncore/settings/tabmanager/tabmanager.h28
8 files changed, 2 insertions, 227 deletions
diff --git a/noncore/settings/tabmanager/app.cpp b/noncore/settings/tabmanager/app.cpp
index aa17bfe..30ba9a5 100644
--- a/noncore/settings/tabmanager/app.cpp
+++ b/noncore/settings/tabmanager/app.cpp
@@ -1,111 +1,83 @@
1/*
2
3               =. This file is part of the OPIE Project
4             .=l. Copyright (c) 2002 Benjamin Meyer <meyerb@sharpsec.com>
5           .>+-=
6 _;:,     .>    :=|. This library is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This library is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details.
20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
29/**************************************************************************** 1/****************************************************************************
30** Form implementation generated from reading ui file 'app.ui' 2** Form implementation generated from reading ui file 'app.ui'
31** 3**
32** Created: Fri May 3 14:38:15 2002 4** Created: Fri May 3 14:38:15 2002
33** by: The User Interface Compiler (uic) 5** by: The User Interface Compiler (uic)
34** 6**
35** WARNING! All changes made in this file will be lost! 7** WARNING! All changes made in this file will be lost!
36****************************************************************************/ 8****************************************************************************/
37#include "app.h" 9#include "app.h"
38 10
39#include <qlabel.h> 11#include <qlabel.h>
40#include <qlineedit.h> 12#include <qlineedit.h>
41#include <qpushbutton.h> 13#include <qpushbutton.h>
42#include <qlayout.h> 14#include <qlayout.h>
43#include <qvariant.h> 15#include <qvariant.h>
44#include <qtooltip.h> 16#include <qtooltip.h>
45#include <qwhatsthis.h> 17#include <qwhatsthis.h>
46 18
47/* 19/*
48 * Constructs a AppEdit which is a child of 'parent', with the 20 * Constructs a AppEdit which is a child of 'parent', with the
49 * name 'name' and widget flags set to 'f' 21 * name 'name' and widget flags set to 'f'
50 * 22 *
51 * The dialog will by default be modeless, unless you set 'modal' to 23 * The dialog will by default be modeless, unless you set 'modal' to
52 * TRUE to construct a modal dialog. 24 * TRUE to construct a modal dialog.
53 */ 25 */
54AppEdit::AppEdit( QWidget* parent, const char* name, bool modal, WFlags fl ) 26AppEdit::AppEdit( QWidget* parent, const char* name, bool modal, WFlags fl )
55 : QDialog( parent, name, modal, fl ) 27 : QDialog( parent, name, modal, fl )
56{ 28{
57 if ( !name ) 29 if ( !name )
58 setName( "AppEdit" ); 30 setName( "AppEdit" );
59 resize( 211, 241 ); 31 resize( 211, 241 );
60 setCaption( tr( "Application" ) ); 32 setCaption( tr( "Application" ) );
61 AppEditLayout = new QGridLayout( this ); 33 AppEditLayout = new QGridLayout( this );
62 AppEditLayout->setSpacing( 6 ); 34 AppEditLayout->setSpacing( 6 );
63 AppEditLayout->setMargin( 11 ); 35 AppEditLayout->setMargin( 11 );
64 36
65 TextLabel3 = new QLabel( this, "TextLabel3" ); 37 TextLabel3 = new QLabel( this, "TextLabel3" );
66 TextLabel3->setText( tr( "Exec" ) ); 38 TextLabel3->setText( tr( "Exec" ) );
67 39
68 AppEditLayout->addWidget( TextLabel3, 2, 0 ); 40 AppEditLayout->addWidget( TextLabel3, 2, 0 );
69 41
70 TextLabel4 = new QLabel( this, "TextLabel4" ); 42 TextLabel4 = new QLabel( this, "TextLabel4" );
71 TextLabel4->setText( tr( "Comment" ) ); 43 TextLabel4->setText( tr( "Comment" ) );
72 44
73 AppEditLayout->addWidget( TextLabel4, 3, 0 ); 45 AppEditLayout->addWidget( TextLabel4, 3, 0 );
74 46
75 TextLabel2 = new QLabel( this, "TextLabel2" ); 47 TextLabel2 = new QLabel( this, "TextLabel2" );
76 TextLabel2->setText( tr( "Icon" ) ); 48 TextLabel2->setText( tr( "Icon" ) );
77 49
78 AppEditLayout->addWidget( TextLabel2, 1, 0 ); 50 AppEditLayout->addWidget( TextLabel2, 1, 0 );
79 51
80 TextLabel1 = new QLabel( this, "TextLabel1" ); 52 TextLabel1 = new QLabel( this, "TextLabel1" );
81 TextLabel1->setText( tr( "Name" ) ); 53 TextLabel1->setText( tr( "Name" ) );
82 54
83 AppEditLayout->addWidget( TextLabel1, 0, 0 ); 55 AppEditLayout->addWidget( TextLabel1, 0, 0 );
84 56
85 iconLineEdit = new QLineEdit( this, "iconLineEdit" ); 57 iconLineEdit = new QLineEdit( this, "iconLineEdit" );
86 58
87 AppEditLayout->addWidget( iconLineEdit, 1, 1 ); 59 AppEditLayout->addWidget( iconLineEdit, 1, 1 );
88 60
89 nameLineEdit = new QLineEdit( this, "nameLineEdit" ); 61 nameLineEdit = new QLineEdit( this, "nameLineEdit" );
90 62
91 AppEditLayout->addWidget( nameLineEdit, 0, 1 ); 63 AppEditLayout->addWidget( nameLineEdit, 0, 1 );
92 64
93 commentLineEdit = new QLineEdit( this, "commentLineEdit" ); 65 commentLineEdit = new QLineEdit( this, "commentLineEdit" );
94 66
95 AppEditLayout->addWidget( commentLineEdit, 3, 1 ); 67 AppEditLayout->addWidget( commentLineEdit, 3, 1 );
96 68
97 execLineEdit = new QLineEdit( this, "execLineEdit" ); 69 execLineEdit = new QLineEdit( this, "execLineEdit" );
98 70
99 AppEditLayout->addWidget( execLineEdit, 2, 1 ); 71 AppEditLayout->addWidget( execLineEdit, 2, 1 );
100 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); 72 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
101 AppEditLayout->addItem( spacer, 4, 1 ); 73 AppEditLayout->addItem( spacer, 4, 1 );
102} 74}
103 75
104/* 76/*
105 * Destroys the object and frees any allocated resources 77 * Destroys the object and frees any allocated resources
106 */ 78 */
107AppEdit::~AppEdit() 79AppEdit::~AppEdit()
108{ 80{
109 // no need to delete child widgets, Qt does it all for us 81 // no need to delete child widgets, Qt does it all for us
110} 82}
111 83
diff --git a/noncore/settings/tabmanager/app.h b/noncore/settings/tabmanager/app.h
index 89afb28..ffa6222 100644
--- a/noncore/settings/tabmanager/app.h
+++ b/noncore/settings/tabmanager/app.h
@@ -1,69 +1,41 @@
1/*
2
3               =. This file is part of the OPIE Project
4             .=l. Copyright (c) 2002 Benjamin Meyer <meyerb@sharpsec.com>
5           .>+-=
6 _;:,     .>    :=|. This library is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This library is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details.
20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
29/**************************************************************************** 1/****************************************************************************
30** Form interface generated from reading ui file 'app.ui' 2** Form interface generated from reading ui file 'app.ui'
31** 3**
32** Created: Fri May 3 14:38:09 2002 4** Created: Fri May 3 14:38:09 2002
33** by: The User Interface Compiler (uic) 5** by: The User Interface Compiler (uic)
34** 6**
35** WARNING! All changes made in this file will be lost! 7** WARNING! All changes made in this file will be lost!
36****************************************************************************/ 8****************************************************************************/
37#ifndef APPEDIT_H 9#ifndef APPEDIT_H
38#define APPEDIT_H 10#define APPEDIT_H
39 11
40#include <qvariant.h> 12#include <qvariant.h>
41#include <qdialog.h> 13#include <qdialog.h>
42class QVBoxLayout; 14class QVBoxLayout;
43class QHBoxLayout; 15class QHBoxLayout;
44class QGridLayout; 16class QGridLayout;
45class QLabel; 17class QLabel;
46class QLineEdit; 18class QLineEdit;
47 19
48class AppEdit : public QDialog 20class AppEdit : public QDialog
49{ 21{
50 Q_OBJECT 22 Q_OBJECT
51 23
52public: 24public:
53 AppEdit( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); 25 AppEdit( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
54 ~AppEdit(); 26 ~AppEdit();
55 27
56 QLabel* TextLabel3; 28 QLabel* TextLabel3;
57 QLabel* TextLabel4; 29 QLabel* TextLabel4;
58 QLabel* TextLabel2; 30 QLabel* TextLabel2;
59 QLabel* TextLabel1; 31 QLabel* TextLabel1;
60 QLineEdit* iconLineEdit; 32 QLineEdit* iconLineEdit;
61 QLineEdit* nameLineEdit; 33 QLineEdit* nameLineEdit;
62 QLineEdit* commentLineEdit; 34 QLineEdit* commentLineEdit;
63 QLineEdit* execLineEdit; 35 QLineEdit* execLineEdit;
64 36
65protected: 37protected:
66 QGridLayout* AppEditLayout; 38 QGridLayout* AppEditLayout;
67}; 39};
68 40
69#endif // APPEDIT_H 41#endif // APPEDIT_H
diff --git a/noncore/settings/tabmanager/main.cpp b/noncore/settings/tabmanager/main.cpp
index a96d768..f737de5 100644
--- a/noncore/settings/tabmanager/main.cpp
+++ b/noncore/settings/tabmanager/main.cpp
@@ -1,40 +1,12 @@
1/*
2
3               =. This file is part of the OPIE Project
4             .=l. Copyright (c) 2002 Benjamin Meyer <meyerb@sharpsec.com>
5           .>+-=
6 _;:,     .>    :=|. This library is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This library is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details.
20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
29#include "tabmainwindow.h" 1#include "tabmainwindow.h"
30#include <qpe/qpeapplication.h> 2#include <qpe/qpeapplication.h>
31 3
32int main( int argc, char **argv ){ 4int main( int argc, char **argv ){
33 QPEApplication application( argc, argv ); 5 QPEApplication application( argc, argv );
34 TabMainWindow mainWindow; 6 TabMainWindow mainWindow;
35 application.showMainWidget(&mainWindow); 7 application.showMainWidget(&mainWindow);
36 return application.exec(); 8 return application.exec();
37} 9}
38 10
39//main.cpp 11//main.cpp
40 12
diff --git a/noncore/settings/tabmanager/tabapplnk.h b/noncore/settings/tabmanager/tabapplnk.h
index 6669144..9333e87 100644
--- a/noncore/settings/tabmanager/tabapplnk.h
+++ b/noncore/settings/tabmanager/tabapplnk.h
@@ -1,46 +1,18 @@
1/*
2
3               =. This file is part of the OPIE Project
4             .=l. Copyright (c) 2002 Benjamin Meyer <meyerb@sharpsec.com>
5           .>+-=
6 _;:,     .>    :=|. This library is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This library is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details.
20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
29#ifndef TABAPPLNK_H 1#ifndef TABAPPLNK_H
30#define TABAPPLNK_H 2#define TABAPPLNK_H
31 3
32#include <qpe/applnk.h> 4#include <qpe/applnk.h>
33 5
34class TabAppLnk : public AppLnk { 6class TabAppLnk : public AppLnk {
35 7
36public: 8public:
37 TabAppLnk( const QString & file) :AppLnk(file){ }; 9 TabAppLnk( const QString & file) :AppLnk(file){ };
38 10
39 QString pixmapString() { return mIconFile; }; 11 QString pixmapString() { return mIconFile; };
40 12
41}; 13};
42 14
43#endif 15#endif
44 16
45// tabapplnk.h 17// tabapplnk.h
46 18
diff --git a/noncore/settings/tabmanager/tablistview.h b/noncore/settings/tabmanager/tablistview.h
index 545ee38..97f9dec 100644
--- a/noncore/settings/tabmanager/tablistview.h
+++ b/noncore/settings/tabmanager/tablistview.h
@@ -1,93 +1,65 @@
1/*
2
3               =. This file is part of the OPIE Project
4             .=l. Copyright (c) 2002 Benjamin Meyer <meyerb@sharpsec.com>
5           .>+-=
6 _;:,     .>    :=|. This library is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This library is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details.
20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
29#ifndef TABLISTVIEW_H 1#ifndef TABLISTVIEW_H
30#define TABLISTVIEW_H 2#define TABLISTVIEW_H
31 3
32#include <qlistview.h> 4#include <qlistview.h>
33#include <qcursor.h> 5#include <qcursor.h>
34#include <qapplication.h> 6#include <qapplication.h>
35 7
36class TabListView : public QListView { 8class TabListView : public QListView {
37 Q_OBJECT 9 Q_OBJECT
38 10
39signals: 11signals:
40 void moveItem(QListViewItem *item, QListViewItem *newFolder); 12 void moveItem(QListViewItem *item, QListViewItem *newFolder);
41 13
42public: 14public:
43 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;
44 connect(this, SIGNAL(pressed ( QListViewItem *)), this, SLOT(itemPressed(QListViewItem *))); 16 connect(this, SIGNAL(pressed ( QListViewItem *)), this, SLOT(itemPressed(QListViewItem *)));
45 internalCursor.setShape(0); 17 internalCursor.setShape(0);
46 }; 18 };
47 19
48protected: 20protected:
49 void contentsMouseReleaseEvent(QMouseEvent* ){ 21 void contentsMouseReleaseEvent(QMouseEvent* ){
50 QListViewItem *newGroup = this->currentItem(); 22 QListViewItem *newGroup = this->currentItem();
51 // Make sure they are both real. 23 // Make sure they are both real.
52 if (currentSelectedItem == NULL || newGroup == NULL) 24 if (currentSelectedItem == NULL || newGroup == NULL)
53 return; 25 return;
54 // Make sure they are not the same 26 // Make sure they are not the same
55 if(this->isSelected(currentSelectedItem) == true) 27 if(this->isSelected(currentSelectedItem) == true)
56 return; 28 return;
57 29
58 // Ok we have two valid items. 30 // Ok we have two valid items.
59 if(newGroup->parent()) 31 if(newGroup->parent())
60 newGroup = newGroup->parent(); 32 newGroup = newGroup->parent();
61 33
62 // Just in case the parent was null 34 // Just in case the parent was null
63 if(newGroup == NULL) 35 if(newGroup == NULL)
64 return; 36 return;
65 37
66 // 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.
67 if (newGroup != currentSelectedItem->parent()) 39 if (newGroup != currentSelectedItem->parent())
68 moveItem(currentSelectedItem, newGroup); 40 moveItem(currentSelectedItem, newGroup);
69 currentSelectedItem = NULL; 41 currentSelectedItem = NULL;
70 qApp->restoreOverrideCursor(); 42 qApp->restoreOverrideCursor();
71}; 43};
72 44
73private slots: 45private slots:
74 void itemPressed(QListViewItem *item){ 46 void itemPressed(QListViewItem *item){
75 if(item == NULL || !item->parent()){ 47 if(item == NULL || !item->parent()){
76 if(item == NULL) 48 if(item == NULL)
77 qDebug("Item is NULL"); 49 qDebug("Item is NULL");
78 return; 50 return;
79 } 51 }
80 52
81 currentSelectedItem = item; 53 currentSelectedItem = item;
82 internalCursor.setShape(13); 54 internalCursor.setShape(13);
83 qApp->setOverrideCursor(internalCursor); 55 qApp->setOverrideCursor(internalCursor);
84}; 56};
85 57
86 58
87private: 59private:
88 QListViewItem *currentSelectedItem; 60 QListViewItem *currentSelectedItem;
89 QCursor internalCursor; 61 QCursor internalCursor;
90}; 62};
91 63
92#endif 64#endif
93 65
diff --git a/noncore/settings/tabmanager/tabmainwindow.h b/noncore/settings/tabmanager/tabmainwindow.h
index 2116f5a..c76ad9f 100644
--- a/noncore/settings/tabmanager/tabmainwindow.h
+++ b/noncore/settings/tabmanager/tabmainwindow.h
@@ -1,63 +1,35 @@
1/*
2
3               =. This file is part of the OPIE Project
4             .=l. Copyright (c) 2002 Benjamin Meyer <meyerb@sharpsec.com>
5           .>+-=
6 _;:,     .>    :=|. This library is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This library is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details.
20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
29#ifndef TABMAINWINDOW_H 1#ifndef TABMAINWINDOW_H
30#define TABMAINWINDOW_H 2#define TABMAINWINDOW_H
31 3
32#include "tabmanager.h" 4#include "tabmanager.h"
33#include <qmainwindow.h> 5#include <qmainwindow.h>
34#include <qtoolbar.h> 6#include <qtoolbar.h>
35#include <qtoolbutton.h> 7#include <qtoolbutton.h>
36#include <qpe/resource.h> 8#include <qpe/resource.h>
37 9
38class TabMainWindow : public QMainWindow { 10class TabMainWindow : public QMainWindow {
39 11
40public: 12public:
41 TabMainWindow( QWidget* parent = 0, const char* name = 0) : QMainWindow(parent, name){ 13 TabMainWindow( QWidget* parent = 0, const char* name = 0) : QMainWindow(parent, name){
42 tabManager = new TabManager(this, "TabManger"); 14 tabManager = new TabManager(this, "TabManger");
43 setCaption("Tab Manager"); 15 setCaption("Tab Manager");
44 this->setCentralWidget(tabManager); 16 this->setCentralWidget(tabManager);
45 QToolBar *newToolBar = new QToolBar("toolbar", this); 17 QToolBar *newToolBar = new QToolBar("toolbar", this);
46 18
47 // Insert all of the buttons. 19 // Insert all of the buttons.
48 QToolButton *newFolder = new QToolButton(Resource::loadPixmap("fileopen"), "New Folder", 0, tabManager, SLOT(newFolder()), newToolBar); 20 QToolButton *newFolder = new QToolButton(Resource::loadPixmap("fileopen"), "New Folder", 0, tabManager, SLOT(newFolder()), newToolBar);
49 QToolButton *newFile = new QToolButton(Resource::loadPixmap("new"), "New Folder", 0, tabManager, SLOT(newApplication()), newToolBar); 21 QToolButton *newFile = new QToolButton(Resource::loadPixmap("new"), "New Folder", 0, tabManager, SLOT(newApplication()), newToolBar);
50 QToolButton *editItem = new QToolButton(Resource::loadPixmap("edit"), "Edit", 0, tabManager, SLOT(editCurrentItem()), newToolBar); 22 QToolButton *editItem = new QToolButton(Resource::loadPixmap("edit"), "Edit", 0, tabManager, SLOT(editCurrentItem()), newToolBar);
51 QToolButton *deleteItem = new QToolButton(Resource::loadPixmap("reset"), "Deelete", 0, tabManager, SLOT(removeItem()), newToolBar); 23 QToolButton *deleteItem = new QToolButton(Resource::loadPixmap("reset"), "Deelete", 0, tabManager, SLOT(removeItem()), newToolBar);
52 24
53 }; 25 };
54 26
55protected: 27protected:
56 TabManager *tabManager; 28 TabManager *tabManager;
57 29
58}; 30};
59 31
60#endif 32#endif
61 33
62// tabmainwindow.h 34// tabmainwindow.h
63 35
diff --git a/noncore/settings/tabmanager/tabmanager.cpp b/noncore/settings/tabmanager/tabmanager.cpp
index f54c837..13aae81 100644
--- a/noncore/settings/tabmanager/tabmanager.cpp
+++ b/noncore/settings/tabmanager/tabmanager.cpp
@@ -1,483 +1,454 @@
1/*
2
3               =. This file is part of the OPIE Project
4             .=l. Copyright (c) 2002 Benjamin Meyer <meyerb@sharpsec.com>
5           .>+-=
6 _;:,     .>    :=|. This library is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This library is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details.
20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
29
30#include "tabmanager.h" 1#include "tabmanager.h"
31#include "app.h" 2#include "app.h"
32#include "tabapplnk.h" 3#include "tabapplnk.h"
33 4
34#include <qpe/applnk.h> 5#include <qpe/applnk.h>
35#include <qpe/qpeapplication.h> 6#include <qpe/qpeapplication.h>
36#include <qdir.h> 7#include <qdir.h>
37#include <qfile.h> 8#include <qfile.h>
38#include <qtextstream.h> 9#include <qtextstream.h>
39#include <qlistview.h> 10#include <qlistview.h>
40#include <qheader.h> 11#include <qheader.h>
41#include <qlineedit.h> 12#include <qlineedit.h>
42#include <qlabel.h> 13#include <qlabel.h>
43#include <qmessagebox.h> 14#include <qmessagebox.h>
44#include <stdlib.h> 15#include <stdlib.h>
45#include <qpe/qcopenvelope_qws.h> 16#include <qpe/qcopenvelope_qws.h>
46 17
47#define HOME_APP_DIR QPEApplication::qpeDir()+"/apps" // <-- made this a little more flexible 18#define HOME_APP_DIR QPEApplication::qpeDir()+"/apps" // <-- made this a little more flexible
48#define HOME_APP_INSTALL_DIR "/usr/lib/ipkg/info" 19#define HOME_APP_INSTALL_DIR "/usr/lib/ipkg/info"
49#define NEW_FOLDER "EmptyTab" 20#define NEW_FOLDER "EmptyTab"
50#define NEW_APPLICATION "NewApp" 21#define NEW_APPLICATION "NewApp"
51#define APPLICATION_EXTENSION ".desktop" 22#define APPLICATION_EXTENSION ".desktop"
52#define APPLICATION_EXTENSION_LENGTH 8 23#define APPLICATION_EXTENSION_LENGTH 8
53 24
54/** 25/**
55 * Constructor. Sets up signals. Performs initial scan of applications 26 * Constructor. Sets up signals. Performs initial scan of applications
56 * and tabs 27 * and tabs
57 */ 28 */
58TabManager::TabManager( QWidget* parent, const char* name):TabManagerBase(parent, name), changed(false){ 29TabManager::TabManager( QWidget* parent, const char* name):TabManagerBase(parent, name), changed(false){
59 rescanFolder(HOME_APP_DIR); 30 rescanFolder(HOME_APP_DIR);
60 31
61 // Connect the signals and slots 32 // Connect the signals and slots
62 connect(tabList, SIGNAL(doubleClicked(QListViewItem *)), 33 connect(tabList, SIGNAL(doubleClicked(QListViewItem *)),
63 this, SLOT(editItem(QListViewItem*))); 34 this, SLOT(editItem(QListViewItem*)));
64 (tabList->header())->hide(); 35 (tabList->header())->hide();
65 connect(tabList, SIGNAL(moveItem(QListViewItem *, QListViewItem *)), 36 connect(tabList, SIGNAL(moveItem(QListViewItem *, QListViewItem *)),
66 this, SLOT(moveApplication(QListViewItem *, QListViewItem *))); 37 this, SLOT(moveApplication(QListViewItem *, QListViewItem *)));
67} 38}
68 39
69/** 40/**
70 * If anything in the tab's have been changed then update the system or alert 41 * If anything in the tab's have been changed then update the system or alert
71 * the user. 42 * the user.
72 */ 43 */
73TabManager::~TabManager(){ 44TabManager::~TabManager(){
74 if(changed){ 45 if(changed){
75 //QMessageBox::critical(this, tr("Message"), tr("Please restart Qtopia to see all new changes."),tr("Ok") ); 46 //QMessageBox::critical(this, tr("Message"), tr("Please restart Qtopia to see all new changes."),tr("Ok") );
76 //filename = fn; 47 //filename = fn;
77 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 48 QCopEnvelope e("QPE/System", "linkChanged(QString)");
78 //e << description << filename << mimetype; 49 //e << description << filename << mimetype;
79 QString link; //we'll just send an empty string 50 QString link; //we'll just send an empty string
80 e << link; 51 e << link;
81 } 52 }
82} 53}
83 54
84/** 55/**
85 * Scans root directory for any tabs or applications. Will recursivly go down, 56 * Scans root directory for any tabs or applications. Will recursivly go down,
86 * but will not follow symlinks. 57 * but will not follow symlinks.
87 * @param directory - the directory to look in. 58 * @param directory - the directory to look in.
88 * @param parent - the parent to place any new tabs or apps into. If parent is 59 * @param parent - the parent to place any new tabs or apps into. If parent is
89 * NULL then the item is a tab and should be placed as a child of the window. 60 * NULL then the item is a tab and should be placed as a child of the window.
90 */ 61 */
91void TabManager::rescanFolder(QString directory, QListViewItem* parent){ 62void TabManager::rescanFolder(QString directory, QListViewItem* parent){
92 //qDebug(QString("rescanFolder: ") + directory.latin1()); 63 //qDebug(QString("rescanFolder: ") + directory.latin1());
93 64
94 QDir d; 65 QDir d;
95 d.setPath(directory); 66 d.setPath(directory);
96 // Show hidden files for .directories 67 // Show hidden files for .directories
97 d.setFilter( QDir::Files | QDir::Hidden | QDir::Dirs); 68 d.setFilter( QDir::Files | QDir::Hidden | QDir::Dirs);
98 69
99 const QFileInfoList *list = d.entryInfoList(); 70 const QFileInfoList *list = d.entryInfoList();
100 QFileInfoListIterator it( *list ); // create list iterator 71 QFileInfoListIterator it( *list ); // create list iterator
101 QFileInfo *fi; // pointer for traversing 72 QFileInfo *fi; // pointer for traversing
102 73
103 while ( (fi=it.current()) ) { // for each file... 74 while ( (fi=it.current()) ) { // for each file...
104 // If it is a dir and not .. or . then add it as a tab and go down. 75 // If it is a dir and not .. or . then add it as a tab and go down.
105 if(fi->isDir()){ 76 if(fi->isDir()){
106 if(fi->fileName() != ".." && fi->fileName() != ".") { 77 if(fi->fileName() != ".." && fi->fileName() != ".") {
107 QListViewItem* newItem; 78 QListViewItem* newItem;
108 if(!parent) 79 if(!parent)
109 newItem = new QListViewItem(tabList, fi->fileName()); 80 newItem = new QListViewItem(tabList, fi->fileName());
110 else 81 else
111 newItem = new QListViewItem(parent, fi->fileName()); 82 newItem = new QListViewItem(parent, fi->fileName());
112 itemList.insert(newItem, directory + "/" + fi->fileName() + "/.directory" ); 83 itemList.insert(newItem, directory + "/" + fi->fileName() + "/.directory" );
113 rescanFolder(directory + "/" + fi->fileName(), newItem); 84 rescanFolder(directory + "/" + fi->fileName(), newItem);
114 } 85 }
115 } 86 }
116 else{ 87 else{
117 // it is a file, if not a .directory add to parent. 88 // it is a file, if not a .directory add to parent.
118 89
119 // Change parents name and icon to reflect icon. 90 // Change parents name and icon to reflect icon.
120 if(fi->fileName() == ".directory"){ 91 if(fi->fileName() == ".directory"){
121 AppLnk app(directory + "/" + fi->fileName()); 92 AppLnk app(directory + "/" + fi->fileName());
122 if(parent){ 93 if(parent){
123 parent->setPixmap(0,app.pixmap()); 94 parent->setPixmap(0,app.pixmap());
124 parent->setText(0, app.name()); 95 parent->setText(0, app.name());
125 } 96 }
126 } 97 }
127 else{ 98 else{
128 // Add any desktop files found. 99 // Add any desktop files found.
129 QListViewItem* newItem; 100 QListViewItem* newItem;
130 if(directory != HOME_APP_DIR){ 101 if(directory != HOME_APP_DIR){
131 if(!parent) 102 if(!parent)
132 newItem = new QListViewItem(tabList, fi->fileName()); 103 newItem = new QListViewItem(tabList, fi->fileName());
133 else 104 else
134 newItem = new QListViewItem(parent, fi->fileName()); 105 newItem = new QListViewItem(parent, fi->fileName());
135 if(fi->fileName().right(APPLICATION_EXTENSION_LENGTH) == APPLICATION_EXTENSION){ 106 if(fi->fileName().right(APPLICATION_EXTENSION_LENGTH) == APPLICATION_EXTENSION){
136 AppLnk app(directory + "/" + fi->fileName()); 107 AppLnk app(directory + "/" + fi->fileName());
137 newItem->setPixmap(0,app.pixmap()); 108 newItem->setPixmap(0,app.pixmap());
138 newItem->setText(0, app.name()); 109 newItem->setText(0, app.name());
139 itemList.insert(newItem, directory + "/" + fi->fileName()); 110 itemList.insert(newItem, directory + "/" + fi->fileName());
140 } 111 }
141 } 112 }
142 } 113 }
143 } 114 }
144 ++it; // goto next list element 115 ++it; // goto next list element
145 } 116 }
146} 117}
147 118
148/** 119/**
149 * Create a new blank Tab. 120 * Create a new blank Tab.
150 * Create a physical folder with .directory file 121 * Create a physical folder with .directory file
151 * Create a item on the list 122 * Create a item on the list
152 */ 123 */
153void TabManager::newFolder(){ 124void TabManager::newFolder(){
154 QDir r; 125 QDir r;
155 r.mkdir(QString(HOME_APP_DIR) + "/" + NEW_FOLDER); 126 r.mkdir(QString(HOME_APP_DIR) + "/" + NEW_FOLDER);
156 system((QString("echo [Desktop Entry] | cat >> ") + HOME_APP_DIR + "/" + NEW_FOLDER "/.directory").latin1()); 127 system((QString("echo [Desktop Entry] | cat >> ") + HOME_APP_DIR + "/" + NEW_FOLDER "/.directory").latin1());
157 system((QString("echo Name=" NEW_FOLDER " | cat >> ") + HOME_APP_DIR + "/" + NEW_FOLDER "/.directory").latin1()); 128 system((QString("echo Name=" NEW_FOLDER " | cat >> ") + HOME_APP_DIR + "/" + NEW_FOLDER "/.directory").latin1());
158 129
159 QString homeLocation = QString(HOME_APP_DIR) + "/" + NEW_FOLDER + "/.directory"; 130 QString homeLocation = QString(HOME_APP_DIR) + "/" + NEW_FOLDER + "/.directory";
160 QListViewItem *newItem = new QListViewItem(tabList, NEW_FOLDER); 131 QListViewItem *newItem = new QListViewItem(tabList, NEW_FOLDER);
161 itemList.insert(newItem, homeLocation ); 132 itemList.insert(newItem, homeLocation );
162 133
163 // We have changed something. 134 // We have changed something.
164 changed = true; 135 changed = true;
165} 136}
166 137
167/** 138/**
168 * Create a new blank application 139 * Create a new blank application
169 * Make sure a tab is selected 140 * Make sure a tab is selected
170 * create physical file 141 * create physical file
171 * fill file with default information (entry, name, type). 142 * fill file with default information (entry, name, type).
172 */ 143 */
173void TabManager::newApplication(){ 144void TabManager::newApplication(){
174 QListViewItem *item = tabList->currentItem(); 145 QListViewItem *item = tabList->currentItem();
175 if(!item || item->parent()) 146 if(!item || item->parent())
176 return; 147 return;
177 148
178 QString parentDir = itemList[item].mid(0,itemList[item].length()-11); 149 QString parentDir = itemList[item].mid(0,itemList[item].length()-11);
179 QString homeLocation = parentDir + "/" NEW_APPLICATION APPLICATION_EXTENSION; 150 QString homeLocation = parentDir + "/" NEW_APPLICATION APPLICATION_EXTENSION;
180 system((QString("echo [Desktop Entry] | cat >> ") + homeLocation).latin1()); 151 system((QString("echo [Desktop Entry] | cat >> ") + homeLocation).latin1());
181 system((QString("echo Name=" NEW_APPLICATION " | cat >> ") + homeLocation).latin1()); 152 system((QString("echo Name=" NEW_APPLICATION " | cat >> ") + homeLocation).latin1());
182 int slash = parentDir.findRev('/', -1); 153 int slash = parentDir.findRev('/', -1);
183 QString folderName = parentDir.mid(slash+1, parentDir.length()); 154 QString folderName = parentDir.mid(slash+1, parentDir.length());
184 155
185 system((QString("echo Type=") + folderName + " | cat >> " + homeLocation).latin1()); 156 system((QString("echo Type=") + folderName + " | cat >> " + homeLocation).latin1());
186 157
187 // Insert into the tree 158 // Insert into the tree
188 QListViewItem *newItem = new QListViewItem(item, NEW_APPLICATION); 159 QListViewItem *newItem = new QListViewItem(item, NEW_APPLICATION);
189 itemList.insert(newItem, homeLocation ); 160 itemList.insert(newItem, homeLocation );
190 161
191 // We have changed something. 162 // We have changed something.
192 changed = true; 163 changed = true;
193} 164}
194 165
195/** 166/**
196 * Remove the item. 167 * Remove the item.
197 * Check if we can 168 * Check if we can
198 * Prompt user 169 * Prompt user
199 * Delete physical file (Dir, remove .dir, then dir. File, remove file) 170 * Delete physical file (Dir, remove .dir, then dir. File, remove file)
200 * Remove from installer if need too. 171 * Remove from installer if need too.
201 */ 172 */
202void TabManager::removeItem(){ 173void TabManager::removeItem(){
203 // Make sure we can delete 174 // Make sure we can delete
204 QListViewItem *item = tabList->currentItem(); 175 QListViewItem *item = tabList->currentItem();
205 if(!item) 176 if(!item)
206 return; 177 return;
207 if(item->childCount() > 0){ 178 if(item->childCount() > 0){
208 QMessageBox::critical(this, tr("Message"), tr("Can't remove with applications\nstill in the group."), 179 QMessageBox::critical(this, tr("Message"), tr("Can't remove with applications\nstill in the group."),
209 tr("Ok") ); 180 tr("Ok") );
210 return; 181 return;
211 } 182 }
212 183
213 // Prompt. 184 // Prompt.
214 int answer = QMessageBox::warning(this, tr("Message"), tr("Are you sure you want to delete?"), 185 int answer = QMessageBox::warning(this, tr("Message"), tr("Are you sure you want to delete?"),
215 tr("Yes"), tr("Cancel"), 0, 1 ); 186 tr("Yes"), tr("Cancel"), 0, 1 );
216 if (answer) 187 if (answer)
217 return; 188 return;
218 189
219 bool removeSuccessfull = true; 190 bool removeSuccessfull = true;
220 QString location = itemList[item]; 191 QString location = itemList[item];
221 // Remove file (.directory in a Directory case) 192 // Remove file (.directory in a Directory case)
222 if(!QFile::remove(location)) 193 if(!QFile::remove(location))
223 removeSuccessfull = false; 194 removeSuccessfull = false;
224 195
225 // Remove directory 196 // Remove directory
226 if(item->parent() == NULL){ 197 if(item->parent() == NULL){
227 // Remove .directory file string 198 // Remove .directory file string
228 location = location.mid(0,location.length()-10); 199 location = location.mid(0,location.length()-10);
229 QDir dir; 200 QDir dir;
230 if(!dir.rmdir(location)) 201 if(!dir.rmdir(location))
231 removeSuccessfull = false; 202 removeSuccessfull = false;
232 else 203 else
233 removeSuccessfull = true; 204 removeSuccessfull = true;
234 205
235 } 206 }
236 207
237 // If removing failed. 208 // If removing failed.
238 if(!removeSuccessfull){ 209 if(!removeSuccessfull){
239 qDebug((QString("removeItem: ") + location).latin1()); 210 qDebug((QString("removeItem: ") + location).latin1());
240 QMessageBox::critical(this, tr("Message"), tr("Can't remove."), 211 QMessageBox::critical(this, tr("Message"), tr("Can't remove."),
241 tr("Ok") ); 212 tr("Ok") );
242 return; 213 return;
243 } 214 }
244 215
245 // Remove from the installer so it wont fail. 216 // Remove from the installer so it wont fail.
246 // Don't need to do this sense the current install uses rm -f so no error 217 // Don't need to do this sense the current install uses rm -f so no error
247 218
248 // Remove from the gui list. 219 // Remove from the gui list.
249 itemList.remove(item); 220 itemList.remove(item);
250 if(item->parent()) 221 if(item->parent())
251 item->parent()->takeItem(item); 222 item->parent()->takeItem(item);
252 delete item; 223 delete item;
253 224
254 // We have changed something. 225 // We have changed something.
255 changed = true; 226 changed = true;
256} 227}
257 228
258/** 229/**
259 * Helper function. Edits the current item. 230 * Helper function. Edits the current item.
260 * calls editItem with the currently selected item. 231 * calls editItem with the currently selected item.
261 */ 232 */
262void TabManager::editCurrentItem(){ 233void TabManager::editCurrentItem(){
263 editItem(tabList->currentItem()); 234 editItem(tabList->currentItem());
264} 235}
265 236
266/** 237/**
267 * Edit the item that is passed in. 238 * Edit the item that is passed in.
268 * Show application dialog and if anything changed 239 * Show application dialog and if anything changed
269 * @param item the item to edit. 240 * @param item the item to edit.
270 */ 241 */
271void TabManager::editItem( QListViewItem * item){ 242void TabManager::editItem( QListViewItem * item){
272 if(!item) 243 if(!item)
273 return; 244 return;
274 245
275 TabAppLnk app(itemList[item]); 246 TabAppLnk app(itemList[item]);
276 if(!app.isValid()){ 247 if(!app.isValid()){
277 qDebug(QString("editItem: Not a valid applnk file: ") + itemList[item].latin1()); 248 qDebug(QString("editItem: Not a valid applnk file: ") + itemList[item].latin1());
278 return; 249 return;
279 } 250 }
280 251
281 AppEdit application(this, tr("Application edit"), true); 252 AppEdit application(this, tr("Application edit"), true);
282 application.nameLineEdit->setText(app.name()); 253 application.nameLineEdit->setText(app.name());
283 application.iconLineEdit->setText(app.pixmapString()); 254 application.iconLineEdit->setText(app.pixmapString());
284 application.execLineEdit->setText(app.exec()); 255 application.execLineEdit->setText(app.exec());
285 application.commentLineEdit->setText(app.comment()); 256 application.commentLineEdit->setText(app.comment());
286 257
287 if(item->parent() == NULL){ 258 if(item->parent() == NULL){
288 application.execLineEdit->setEnabled(false); 259 application.execLineEdit->setEnabled(false);
289 application.TextLabel3->setEnabled(false); 260 application.TextLabel3->setEnabled(false);
290 application.setCaption(tr("Tab")); 261 application.setCaption(tr("Tab"));
291 } 262 }
292 263
293 // Only do somthing if they hit OK 264 // Only do somthing if they hit OK
294 if(application.exec() == 0) 265 if(application.exec() == 0)
295 return; 266 return;
296 267
297 // If nothing has changed exit (hmmm why did they hit ok?) 268 // If nothing has changed exit (hmmm why did they hit ok?)
298 if(app.name() == application.nameLineEdit->text() && 269 if(app.name() == application.nameLineEdit->text() &&
299 app.pixmapString() == application.iconLineEdit->text() && 270 app.pixmapString() == application.iconLineEdit->text() &&
300 app.comment() == application.commentLineEdit->text() && 271 app.comment() == application.commentLineEdit->text() &&
301 app.exec() == application.execLineEdit->text()) 272 app.exec() == application.execLineEdit->text())
302 return; 273 return;
303 274
304 // Change the applnk file 275 // Change the applnk file
305 QString oldName = app.name(); 276 QString oldName = app.name();
306 app.setName(application.nameLineEdit->text()); 277 app.setName(application.nameLineEdit->text());
307 app.setIcon(application.iconLineEdit->text()); 278 app.setIcon(application.iconLineEdit->text());
308 app.setComment(application.commentLineEdit->text()); 279 app.setComment(application.commentLineEdit->text());
309 app.setExec(application.execLineEdit->text()); 280 app.setExec(application.execLineEdit->text());
310 if(!app.writeLink()){ 281 if(!app.writeLink()){
311 QMessageBox::critical(this, tr("Message"), tr("Can't save."), 282 QMessageBox::critical(this, tr("Message"), tr("Can't save."),
312 tr("Ok") ); 283 tr("Ok") );
313 return; 284 return;
314 } 285 }
315 286
316 // Update the gui icon and name 287 // Update the gui icon and name
317 item->setText(0,app.name()); 288 item->setText(0,app.name());
318 item->setPixmap(0,app.pixmap()); 289 item->setPixmap(0,app.pixmap());
319 290
320 // We have changed something. 291 // We have changed something.
321 changed = true; 292 changed = true;
322 293
323 // If we were dealing with a new folder or new application change 294 // If we were dealing with a new folder or new application change
324 // the file names. Also change the item location in itemList 295 // the file names. Also change the item location in itemList
325 if(oldName == NEW_FOLDER){ 296 if(oldName == NEW_FOLDER){
326 QDir r; 297 QDir r;
327 QString oldName = itemList[item]; 298 QString oldName = itemList[item];
328 oldName = oldName.mid(0,oldName.length()-11); 299 oldName = oldName.mid(0,oldName.length()-11);
329 QString newName = oldName.mid(0,oldName.length()-9); 300 QString newName = oldName.mid(0,oldName.length()-9);
330 newName = newName + "/" + app.name(); 301 newName = newName + "/" + app.name();
331 r.rename(oldName, newName); 302 r.rename(oldName, newName);
332 itemList.remove(item); 303 itemList.remove(item);
333 itemList.insert(item, newName + "/.directory" ); 304 itemList.insert(item, newName + "/.directory" );
334 } 305 }
335 else if(oldName == NEW_APPLICATION){ 306 else if(oldName == NEW_APPLICATION){
336 if(!item->parent()) 307 if(!item->parent())
337 return; 308 return;
338 QString parentDir = itemList[item->parent()]; 309 QString parentDir = itemList[item->parent()];
339 QDir r; 310 QDir r;
340 QString oldName = itemList[item]; 311 QString oldName = itemList[item];
341 QString newName = oldName.mid(0, parentDir.length()-10); 312 QString newName = oldName.mid(0, parentDir.length()-10);
342 newName = newName + app.name() + APPLICATION_EXTENSION; 313 newName = newName + app.name() + APPLICATION_EXTENSION;
343 r.rename(oldName, newName); 314 r.rename(oldName, newName);
344 itemList.remove(item); 315 itemList.remove(item);
345 itemList.insert(item, newName); 316 itemList.insert(item, newName);
346 } 317 }
347} 318}
348 319
349/** 320/**
350 * Move an application from one directory to another. 321 * Move an application from one directory to another.
351 * Move in the gui, move in the applnk file, move in the installer. 322 * Move in the gui, move in the applnk file, move in the installer.
352 * @param item the application to move 323 * @param item the application to move
353 * @pearam newGroup the new parent of this application 324 * @pearam newGroup the new parent of this application
354 */ 325 */
355void TabManager::moveApplication(QListViewItem *item, QListViewItem *newGroup){ 326void TabManager::moveApplication(QListViewItem *item, QListViewItem *newGroup){
356 // Can we even move it? 327 // Can we even move it?
357 if(!item || !item->parent() || newGroup->parent()) 328 if(!item || !item->parent() || newGroup->parent())
358 return; 329 return;
359 if(item->parent() == newGroup) 330 if(item->parent() == newGroup)
360 return; 331 return;
361 332
362 // Get the new folder, new file name, 333 // Get the new folder, new file name,
363 QString newFolder = itemList[newGroup]; 334 QString newFolder = itemList[newGroup];
364 newFolder = newFolder.mid(0,newFolder.length()-11); 335 newFolder = newFolder.mid(0,newFolder.length()-11);
365 int slash = newFolder.findRev('/', -1); 336 int slash = newFolder.findRev('/', -1);
366 QString folderName = newFolder.mid(slash+1, newFolder.length()); 337 QString folderName = newFolder.mid(slash+1, newFolder.length());
367 338
368 QString desktopFile = itemList[item]; 339 QString desktopFile = itemList[item];
369 slash = desktopFile.findRev('/', -1); 340 slash = desktopFile.findRev('/', -1);
370 desktopFile = desktopFile.mid(slash, desktopFile.length()); 341 desktopFile = desktopFile.mid(slash, desktopFile.length());
371 newFolder = newFolder + desktopFile; 342 newFolder = newFolder + desktopFile;
372 343
373 // Move file 344 // Move file
374 QDir r; 345 QDir r;
375 if(!r.rename(itemList[item], newFolder)){ 346 if(!r.rename(itemList[item], newFolder)){
376 QMessageBox::critical(this, tr("Message"), tr("Can't move application."), 347 QMessageBox::critical(this, tr("Message"), tr("Can't move application."),
377 tr("Ok") ); 348 tr("Ok") );
378 return; 349 return;
379 } 350 }
380 //qDebug((QString("moveApplication: ") + itemList[item]).latin1()); 351 //qDebug((QString("moveApplication: ") + itemList[item]).latin1());
381 //qDebug((QString("moveApplication: ") + newFolder).latin1()); 352 //qDebug((QString("moveApplication: ") + newFolder).latin1());
382 353
383 // Move in the gui 354 // Move in the gui
384 item->parent()->takeItem(item); 355 item->parent()->takeItem(item);
385 newGroup->insertItem(item); 356 newGroup->insertItem(item);
386 newGroup->setOpen(true); 357 newGroup->setOpen(true);
387 358
388 // Move file in the installer 359 // Move file in the installer
389 QString installedAppFile; 360 QString installedAppFile;
390 if(findInstalledApplication(desktopFile, installedAppFile)) 361 if(findInstalledApplication(desktopFile, installedAppFile))
391 swapInstalledLocation(installedAppFile, desktopFile, newFolder); 362 swapInstalledLocation(installedAppFile, desktopFile, newFolder);
392 else 363 else
393 qDebug("moveApplication: No installed app found for dekstop file"); 364 qDebug("moveApplication: No installed app found for dekstop file");
394 365
395 // Move application type 366 // Move application type
396 AppLnk app(newFolder); 367 AppLnk app(newFolder);
397 app.setType(folderName); 368 app.setType(folderName);
398 app.writeLink(); 369 app.writeLink();
399 370
400 // Move in our internal list 371 // Move in our internal list
401 itemList.remove(item); 372 itemList.remove(item);
402 itemList.insert(item, newFolder); 373 itemList.insert(item, newFolder);
403 374
404 // We have changed something. 375 // We have changed something.
405 changed = true; 376 changed = true;
406} 377}
407 378
408/** 379/**
409 * File the installed application that has this desktop file. 380 * File the installed application that has this desktop file.
410 * Go through each file in HOME_APP_INSTALL_DIR and see if it contains desktop 381 * Go through each file in HOME_APP_INSTALL_DIR and see if it contains desktop
411 * file 382 * file
412 * @param desktopFile - the .desktop file to search for [foo.desktop] 383 * @param desktopFile - the .desktop file to search for [foo.desktop]
413 * @param installedAppFile - location of the app install list 384 * @param installedAppFile - location of the app install list
414 * @return true if successfull, false if file not found. 385 * @return true if successfull, false if file not found.
415 */ 386 */
416bool TabManager::findInstalledApplication(QString desktopFile, QString &installedAppFile){ 387bool TabManager::findInstalledApplication(QString desktopFile, QString &installedAppFile){
417 388
418 QDir d; 389 QDir d;
419 d.setPath(HOME_APP_INSTALL_DIR); 390 d.setPath(HOME_APP_INSTALL_DIR);
420 d.setFilter( QDir::Files ); 391 d.setFilter( QDir::Files );
421 392
422 const QFileInfoList *list = d.entryInfoList(); 393 const QFileInfoList *list = d.entryInfoList();
423 QFileInfoListIterator it( *list ); // create list iterator 394 QFileInfoListIterator it( *list ); // create list iterator
424 QFileInfo *fi; // pointer for traversing 395 QFileInfo *fi; // pointer for traversing
425 396
426 while ( (fi=it.current()) ) { // for each file... 397 while ( (fi=it.current()) ) { // for each file...
427 QFile file(QString(HOME_APP_INSTALL_DIR) + "/" + fi->fileName()); 398 QFile file(QString(HOME_APP_INSTALL_DIR) + "/" + fi->fileName());
428 if ( file.open(IO_ReadOnly) ) { // file opened successfully 399 if ( file.open(IO_ReadOnly) ) { // file opened successfully
429 QTextStream stream( &file ); // use a text stream 400 QTextStream stream( &file ); // use a text stream
430 QString line; 401 QString line;
431 while ( !stream.eof() ) { // until end of file... 402 while ( !stream.eof() ) { // until end of file...
432 line = stream.readLine(); // line of text excluding '\n' 403 line = stream.readLine(); // line of text excluding '\n'
433 if(line.contains(desktopFile)){ 404 if(line.contains(desktopFile)){
434 installedAppFile = QString(HOME_APP_INSTALL_DIR) + "/" + fi->fileName(); 405 installedAppFile = QString(HOME_APP_INSTALL_DIR) + "/" + fi->fileName();
435 file.close(); 406 file.close();
436 return true; 407 return true;
437 } 408 }
438 } 409 }
439 file.close(); 410 file.close();
440 } 411 }
441 else 412 else
442 qDebug((QString("findInstalledApplication: Can't open file") + HOME_APP_INSTALL_DIR + "/" + fi->fileName()).latin1()); 413 qDebug((QString("findInstalledApplication: Can't open file") + HOME_APP_INSTALL_DIR + "/" + fi->fileName()).latin1());
443 ++it; // goto next list element 414 ++it; // goto next list element
444 } 415 }
445 return false; 416 return false;
446} 417}
447 418
448/** 419/**
449 * Open a file and replace a file containing the old desktop file with the new. 420 * Open a file and replace a file containing the old desktop file with the new.
450 * @param installedAppFile application installed list 421 * @param installedAppFile application installed list
451 * @param desktopFile old .desktop file 422 * @param desktopFile old .desktop file
452 * @param newLocation new .desktop file 423 * @param newLocation new .desktop file
453 */ 424 */
454void TabManager::swapInstalledLocation( QString installedAppFile, QString desktopFile, QString newLocation ){ 425void TabManager::swapInstalledLocation( QString installedAppFile, QString desktopFile, QString newLocation ){
455 QFile file(installedAppFile); 426 QFile file(installedAppFile);
456 if ( !file.open(IO_ReadOnly) ){ 427 if ( !file.open(IO_ReadOnly) ){
457 qDebug(QString("swapInstalledLocation: Can't edit file: %1").arg(installedAppFile).latin1()); 428 qDebug(QString("swapInstalledLocation: Can't edit file: %1").arg(installedAppFile).latin1());
458 return; 429 return;
459 } 430 }
460 431
461 QTextStream stream( &file ); // use a text stream 432 QTextStream stream( &file ); // use a text stream
462 QString allLines; 433 QString allLines;
463 while ( !stream.eof() ) { // until end of file... 434 while ( !stream.eof() ) { // until end of file...
464 QString line = stream.readLine(); // line of text excluding '\n' 435 QString line = stream.readLine(); // line of text excluding '\n'
465 if(line.contains(desktopFile)) 436 if(line.contains(desktopFile))
466 allLines += newLocation; 437 allLines += newLocation;
467 else 438 else
468 allLines += line; 439 allLines += line;
469 allLines += '\n'; 440 allLines += '\n';
470 } 441 }
471 file.close(); 442 file.close();
472 443
473 if ( !file.open(IO_ReadWrite) ){ 444 if ( !file.open(IO_ReadWrite) ){
474 qDebug(QString("swapInstalledLocation: Can't edit file: %1").arg(installedAppFile).latin1()); 445 qDebug(QString("swapInstalledLocation: Can't edit file: %1").arg(installedAppFile).latin1());
475 return; 446 return;
476 } 447 }
477 QTextStream streamOut( &file ); 448 QTextStream streamOut( &file );
478 streamOut << allLines; 449 streamOut << allLines;
479 file.close(); 450 file.close();
480} 451}
481 452
482// tabmanager.cpp 453// tabmanager.cpp
483 454
diff --git a/noncore/settings/tabmanager/tabmanager.h b/noncore/settings/tabmanager/tabmanager.h
index 2700fe7..39865b0 100644
--- a/noncore/settings/tabmanager/tabmanager.h
+++ b/noncore/settings/tabmanager/tabmanager.h
@@ -1,67 +1,39 @@
1/*
2
3               =. This file is part of the OPIE Project
4             .=l. Copyright (c) 2002 Benjamin Meyer <meyerb@sharpsec.com>
5           .>+-=
6 _;:,     .>    :=|. This library is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This library is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details.
20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
29#ifndef TABMANAGER_H 1#ifndef TABMANAGER_H
30#define TABMANAGER_H 2#define TABMANAGER_H
31 3
32#include "tabmanagerbase.h" 4#include "tabmanagerbase.h"
33#include <qmap.h> 5#include <qmap.h>
34#include <qevent.h> 6#include <qevent.h>
35 7
36class QListViewItem; 8class QListViewItem;
37 9
38class TabManager : public TabManagerBase { 10class TabManager : public TabManagerBase {
39 Q_OBJECT 11 Q_OBJECT
40 12
41public: 13public:
42 TabManager( QWidget* parent = 0, const char* name = 0); 14 TabManager( QWidget* parent = 0, const char* name = 0);
43 ~TabManager(); 15 ~TabManager();
44 bool changed; 16 bool changed;
45 17
46public slots: 18public slots:
47 void newFolder(); 19 void newFolder();
48 void newApplication(); 20 void newApplication();
49 void removeItem(); 21 void removeItem();
50 void editCurrentItem(); 22 void editCurrentItem();
51 23
52private slots: 24private slots:
53 void moveApplication(QListViewItem *, QListViewItem *); 25 void moveApplication(QListViewItem *, QListViewItem *);
54 void editItem(QListViewItem * item); 26 void editItem(QListViewItem * item);
55 27
56protected: 28protected:
57 void rescanFolder(QString directory, QListViewItem* parent=NULL); 29 void rescanFolder(QString directory, QListViewItem* parent=NULL);
58 QMap<QListViewItem *, QString> itemList; 30 QMap<QListViewItem *, QString> itemList;
59 bool findInstalledApplication(QString desktopFile, QString &installedAppFile); 31 bool findInstalledApplication(QString desktopFile, QString &installedAppFile);
60 void swapInstalledLocation( QString installedAppFile, QString desktopFile, QString newLocation ); 32 void swapInstalledLocation( QString installedAppFile, QString desktopFile, QString newLocation );
61 33
62}; 34};
63 35
64#endif 36#endif
65 37
66// tabmanager.h 38// tabmanager.h
67 39