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