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) (side-by-side diff)
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 @@
+*.moc
+Makefile*
+app.cpp
+app.h
+moc_*
+wait.cpp
+wait.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 @@
+<!DOCTYPE UI><UI>
+<class>AppEdit</class>
+<widget>
+ <class>QDialog</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>AppEdit</cstring>
+ </property>
+ <property stdset="1">
+ <name>geometry</name>
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>212</width>
+ <height>136</height>
+ </rect>
+ </property>
+ <property stdset="1">
+ <name>caption</name>
+ <string>Application</string>
+ </property>
+ <grid>
+ <property stdset="1">
+ <name>margin</name>
+ <number>4</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>4</number>
+ </property>
+ <widget row="0" column="1" >
+ <class>QLineEdit</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>nameLineEdit</cstring>
+ </property>
+ </widget>
+ <widget row="3" column="1" >
+ <class>QLineEdit</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>commentLineEdit</cstring>
+ </property>
+ </widget>
+ <widget row="0" column="0" >
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TextLabel1</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Name:</string>
+ </property>
+ </widget>
+ <widget row="1" column="0" >
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TextLabel2</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Icon:</string>
+ </property>
+ </widget>
+ <widget row="2" column="0" >
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TextLabel3</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Exec:</string>
+ </property>
+ </widget>
+ <widget row="3" column="0" >
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TextLabel4</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Comment:</string>
+ </property>
+ </widget>
+ <spacer row="4" column="1" >
+ <property>
+ <name>name</name>
+ <cstring>Spacer1</cstring>
+ </property>
+ <property stdset="1">
+ <name>orientation</name>
+ <enum>Vertical</enum>
+ </property>
+ <property stdset="1">
+ <name>sizeType</name>
+ <enum>Expanding</enum>
+ </property>
+ <property>
+ <name>sizeHint</name>
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ </spacer>
+ <widget row="2" column="1" >
+ <class>QLineEdit</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>execLineEdit</cstring>
+ </property>
+ </widget>
+ <widget row="1" column="1" >
+ <class>QComboBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>iconLineEdit</cstring>
+ </property>
+ <property stdset="1">
+ <name>duplicatesEnabled</name>
+ <bool>false</bool>
+ </property>
+ </widget>
+ </grid>
+</widget>
+</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 @@
+ config TABMANAGER
+ boolean "opie-tabmanager (menu editor for the Opie taskbar)"
+ default "y"
+ 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 @@
+#include "tabmainwindow.h"
+#include <opie2/oapplicationfactory.h>
+
+OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<TabMainWindow> )
+
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 @@
+Package: opie-tabmanager
+Files: plugins/application/libtabmanager.so* bin/tabmanager apps/Settings/tabmanager.desktop pics/tabmanager/tabmanager.png
+Priority: optional
+Section: opie/settings
+Depends: task-opie-minimal
+Architecture: arm
+Maintainer: Benjamin Meyer <meyerb@sharpsec.com>
+Description: Tab Manager
+ Create new tabs, remove old tabs. Edit tab's name, comment and icon.
+ Edit applications name, exec, comment and icon. Add/remove applications.
+Version: $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 @@
+#ifndef TABAPPLNK_H
+#define TABAPPLNK_H
+
+#include <qpe/applnk.h>
+
+class TabAppLnk : public AppLnk {
+
+public:
+ TabAppLnk( const QString & file) :AppLnk(file){ };
+
+ QString pixmapString() { return mIconFile; };
+
+};
+
+#endif
+
+// tabapplnk.h
+
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 @@
+#ifndef TABLISTVIEW_H
+#define TABLISTVIEW_H
+
+/* OPIE */
+#include <opie2/odebug.h>
+
+/* QT */
+#include <qlistview.h>
+#include <qcursor.h>
+#include <qapplication.h>
+
+class TabListView : public QListView {
+ Q_OBJECT
+
+signals:
+ void moveItem(QListViewItem *item, QListViewItem *newFolder);
+
+public:
+ TabListView( QWidget* parent = 0, const char* name = 0) : QListView(parent, name){ currentSelectedItem = NULL;
+ connect(this, SIGNAL(pressed ( QListViewItem *)), this, SLOT(itemPressed(QListViewItem *)));
+ internalCursor.setShape(0);
+ };
+
+protected:
+ void contentsMouseReleaseEvent(QMouseEvent* ){
+ QListViewItem *newGroup = this->currentItem();
+ // Make sure they are both real.
+ if (currentSelectedItem == NULL || newGroup == NULL)
+ return;
+ // Make sure they are not the same
+ if(this->isSelected(currentSelectedItem) == true)
+ return;
+
+ // Ok we have two valid items.
+ if(newGroup->parent())
+ newGroup = newGroup->parent();
+
+ // Just in case the parent was null
+ if(newGroup == NULL)
+ return;
+
+ // If the new folder and buddies current parent are the same don't do anything.
+ if (newGroup != currentSelectedItem->parent())
+ moveItem(currentSelectedItem, newGroup);
+ currentSelectedItem = NULL;
+ qApp->restoreOverrideCursor();
+};
+
+private slots:
+ void itemPressed(QListViewItem *item){
+ if(item == NULL || !item->parent()){
+ if(item == NULL)
+ odebug << "Item is NULL" << oendl;
+ return;
+ }
+
+ currentSelectedItem = item;
+ internalCursor.setShape(13);
+ qApp->setOverrideCursor(internalCursor);
+};
+
+
+private:
+ QListViewItem *currentSelectedItem;
+ QCursor internalCursor;
+};
+
+#endif
+
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 @@
+#ifndef TABMAINWINDOW_H
+#define TABMAINWINDOW_H
+
+#include "tabmanager.h"
+#include <qmainwindow.h>
+#include <qtoolbar.h>
+#include <qtoolbutton.h>
+#include <qpe/resource.h>
+
+class TabMainWindow : public QMainWindow {
+
+public:
+ static QString appName() { return QString::fromLatin1( QUICKAPP_NAME ); }
+
+ TabMainWindow( QWidget* parent = 0, const char* name = 0, WFlags fl = 0) : QMainWindow(parent, name, fl){
+ tabManager = new TabManager(this, "TabManger");
+ setCaption("Tab Manager");
+ setToolBarsMovable(false);
+ this->setCentralWidget(tabManager);
+ QToolBar *newToolBar = new QToolBar("toolbar", this);
+ QToolBar *emptyToolBar = new QToolBar("empty", this);
+ emptyToolBar->setHorizontalStretchable(true);
+
+ // Insert all of the buttons.
+ QToolButton *newFolder = new QToolButton(Resource::loadPixmap("fileopen"), "New Folder", 0, tabManager, SLOT(newFolder()), newToolBar);
+ QToolButton *newFile = new QToolButton(Resource::loadPixmap("new"), "New Application", 0, tabManager, SLOT(newApplication()), newToolBar);
+ QToolButton *editItem = new QToolButton(Resource::loadPixmap("edit"), "Edit", 0, tabManager, SLOT(editCurrentItem()), newToolBar);
+ QToolButton *deleteItem = new QToolButton(Resource::loadPixmap("trash"), "Delete", 0, tabManager, SLOT(removeItem()), newToolBar);
+
+ };
+
+protected:
+ TabManager *tabManager;
+
+};
+
+#endif
+
+// tabmainwindow.h
+
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 @@
+#include "tabmanager.h"
+#include "app.h"
+#include "wait.h"
+#include "tabapplnk.h"
+
+#include <opie2/odebug.h>
+
+#include <qpe/applnk.h>
+#include <qdir.h>
+#include <qfile.h>
+#include <qtextstream.h>
+#include <qlistview.h>
+#include <qheader.h>
+#include <qcombobox.h>
+#include <qlineedit.h>
+#include <qlabel.h>
+#include <qmessagebox.h>
+#include <stdlib.h>
+#include <qpe/qcopenvelope_qws.h>
+#include <qpe/qpeapplication.h>
+#include <qpe/resource.h>
+
+
+#define HOME_APP_DIR QPEApplication::qpeDir()+"apps"
+#define HOME_APP_INSTALL_DIR "/usr/lib/ipkg/info"
+#define NEW_FOLDER "EmptyTab"
+#define NEW_APPLICATION "NewApp"
+#define APPLICATION_EXTENSION ".desktop"
+#define APPLICATION_EXTENSION_LENGTH 8
+
+/**
+ * Constructor. Sets up signals. Performs initial scan of applications
+ * and tabs
+ */
+TabManager::TabManager( QWidget* parent, const char* name):TabManagerBase(parent, name), changed(false), application(NULL){
+ rescanFolder(HOME_APP_DIR);
+
+ // Connect the signals and slots
+ connect(tabList, SIGNAL(doubleClicked(QListViewItem*)), this, SLOT(editItem(QListViewItem*)));
+ (tabList->header())->hide();
+ connect(tabList, SIGNAL(moveItem(QListViewItem*,QListViewItem*)), this, SLOT(moveApplication(QListViewItem*,QListViewItem*)));
+}
+
+/**
+ * If anything in the tab's have been changed then update the system or alert
+ * the user.
+ */
+TabManager::~TabManager(){
+ if(changed){
+ // Prompt.
+ //int answer = QMessageBox::warning(this, "Message", "Should your desktop be","Yes", "Cancel", 0, 1 );
+ //if (answer)
+ // return;
+ QCopEnvelope e("QPE/System", "linkChanged(QString)");
+ QString link; //we'll just send an empty string
+ e << link;
+ }
+}
+
+/**
+ * Scans root directory for any tabs or applications. Will recursivly go down,
+ * but will not follow symlinks.
+ * @param directory - the directory to look in.
+ * @param parent - the parent to place any new tabs or apps into. If parent is
+ * NULL then the item is a tab and should be placed as a child of the window.
+ */
+void TabManager::rescanFolder(QString directory, QListViewItem* parent){
+ //odebug << QString("rescanFolder: ") + directory.latin1() << oendl;
+
+ QDir d;
+ d.setPath(directory);
+ // Show hidden files for .directories
+ d.setFilter( QDir::Files | QDir::Hidden | QDir::Dirs);
+
+ const QFileInfoList *list = d.entryInfoList();
+ QFileInfoListIterator it( *list ); // create list iterator
+ QFileInfo *fi; // pointer for traversing
+
+ while ( (fi=it.current()) ) { // for each file...
+ // If it is a dir and not .. or . then add it as a tab and go down.
+ if(fi->isDir()){
+ if(fi->fileName() != ".." && fi->fileName() != ".") {
+ QListViewItem* newItem;
+ if(!parent)
+ newItem = new QListViewItem(tabList, fi->fileName());
+ else
+ newItem = new QListViewItem(parent, fi->fileName());
+ itemList.insert(newItem, directory + "/" + fi->fileName() + "/.directory" );
+ rescanFolder(directory + "/" + fi->fileName(), newItem);
+ }
+ }
+ else{
+ // it is a file, if not a .directory add to parent.
+
+ // Change parents name and icon to reflect icon.
+ if(fi->fileName() == ".directory"){
+ AppLnk app(directory + "/" + fi->fileName());
+ if(parent){
+ parent->setPixmap(0,app.pixmap());
+ parent->setText(0, app.name());
+ }
+ }
+ else{
+ // Add any desktop files found.
+ QListViewItem* newItem;
+ if(directory != HOME_APP_DIR){
+ if(!parent)
+ newItem = new QListViewItem(tabList, fi->fileName());
+ else
+ newItem = new QListViewItem(parent, fi->fileName());
+ if(fi->fileName().right(APPLICATION_EXTENSION_LENGTH) == APPLICATION_EXTENSION){
+ AppLnk app(directory + "/" + fi->fileName());
+ newItem->setPixmap(0,app.pixmap());
+ newItem->setText(0, app.name());
+ itemList.insert(newItem, directory + "/" + fi->fileName());
+ }
+ }
+ }
+ }
+ ++it; // goto next list element
+ }
+}
+
+/**
+ * Create a new blank Tab.
+ * Create a physical folder with .directory file
+ * Create a item on the list
+ */
+void TabManager::newFolder(){
+ QDir r;
+ r.mkdir(QString(HOME_APP_DIR) + "/" + NEW_FOLDER);
+ system((QString("echo [Desktop Entry] | cat >> ") + HOME_APP_DIR + "/" + NEW_FOLDER "/.directory").latin1());
+ system((QString("echo Name=" NEW_FOLDER " | cat >> ") + HOME_APP_DIR + "/" + NEW_FOLDER "/.directory").latin1());
+
+ QString homeLocation = QString(HOME_APP_DIR) + "/" + NEW_FOLDER + "/.directory";
+ QListViewItem *newItem = new QListViewItem(tabList, NEW_FOLDER);
+ itemList.insert(newItem, homeLocation );
+
+ // We have changed something.
+ changed = true;
+}
+
+/**
+ * Create a new blank application
+ * Make sure a tab is selected
+ * create physical file
+ * fill file with default information (entry, name, type).
+ */
+void TabManager::newApplication(){
+ QListViewItem *item = tabList->currentItem();
+ if(!item || item->parent())
+ return;
+
+ QString parentDir = itemList[item].mid(0,itemList[item].length()-11);
+ QString homeLocation = parentDir + "/" NEW_APPLICATION APPLICATION_EXTENSION;
+ system((QString("echo [Desktop Entry] | cat >> ") + homeLocation).latin1());
+ system((QString("echo Name=" NEW_APPLICATION " | cat >> ") + homeLocation).latin1());
+ int slash = parentDir.findRev('/', -1);
+ QString folderName = parentDir.mid(slash+1, parentDir.length());
+
+ system((QString("echo Type=") + folderName + " | cat >> " + homeLocation).latin1());
+
+ // Insert into the tree
+ QListViewItem *newItem = new QListViewItem(item, NEW_APPLICATION);
+ itemList.insert(newItem, homeLocation );
+
+ // We have changed something.
+ changed = true;
+}
+
+/**
+ * Remove the item.
+ * Check if we can
+ * Prompt user
+ * Delete physical file (Dir, remove .dir, then dir. File, remove file)
+ * Remove from installer if need too.
+ */
+void TabManager::removeItem(){
+ // Make sure we can delete
+ QListViewItem *item = tabList->currentItem();
+ if(!item)
+ return;
+ if(item->childCount() > 0){
+ QMessageBox::critical(this, tr("Message"), tr("Can't remove with applications\nstill in the group."), tr("Ok") );
+ return;
+ }
+
+ // Prompt.
+ int answer = QMessageBox::warning(this, tr("Message"), tr("Are you sure you want to delete?"), tr("Yes"), tr("Cancel"), 0, 1 );
+ if (answer)
+ return;
+
+ bool removeSuccessful = true;
+ QString location = itemList[item];
+ // Remove file (.directory in a Directory case)
+ if(!QFile::remove(location))
+ removeSuccessful = false;
+
+ // Remove directory
+ if(item->parent() == NULL){
+ // Remove .directory file string
+ location = location.mid(0,location.length()-10);
+ QDir dir;
+ if(!dir.rmdir(location))
+ removeSuccessful = false;
+ else
+ removeSuccessful = true;
+ }
+
+ // If removing failed.
+ if(!removeSuccessful){
+ odebug << (QString("removeItem: ") + location).latin1() << oendl;
+ QMessageBox::critical(this, tr("Message"), tr("Can't remove."), tr("Ok") );
+ return;
+ }
+
+ // Remove from the installer so it wont fail.
+ // Don't need to do this sense the current install uses rm -f so no error
+
+ // Remove from the gui list.
+ itemList.remove(item);
+ if(item->parent())
+ item->parent()->takeItem(item);
+ delete item;
+
+ // We have changed something.
+ changed = true;
+}
+
+/**
+ * Helper function. Edits the current item.
+ * calls editItem with the currently selected item.
+ */
+void TabManager::editCurrentItem(){
+ editItem(tabList->currentItem());
+}
+
+/**
+ * Edit the item that is passed in.
+ * Show application dialog and if anything changed
+ * @param item the item to edit.
+ */
+void TabManager::editItem( QListViewItem * item){
+ if(!item)
+ return;
+
+ TabAppLnk app(itemList[item]);
+ if(!app.isValid()){
+ odebug << QString("editItem: Not a valid applnk file: ") + itemList[item].latin1() << oendl;
+ return;
+ }
+
+ // Fill with all of the icons
+ if(!application){
+ Wait waitDialog(this, "Wait dialog");
+ waitDialog.waitLabel->setText(tr("Gathering icons..."));
+ waitDialog.show();
+ qApp->processEvents();
+ application = new AppEdit(this, "Application edit", true);
+
+ QDir d(QPEApplication::qpeDir() + "pics/");
+ d.setFilter( QDir::Files);
+
+ const QFileInfoList *list = d.entryInfoList();
+ QFileInfoListIterator it( *list ); // create list iterator
+ QFileInfo *fi; // pointer for traversing
+
+ while ( (fi=it.current()) ) { // for each file...
+ QString fileName = fi->fileName();
+ if(fileName.right(4) == ".png"){
+ fileName = fileName.mid(0,fileName.length()-4);
+ QPixmap imageOfFile(Resource::loadPixmap(fileName));
+ QImage foo = imageOfFile.convertToImage();
+ foo = foo.smoothScale(16,16);
+ imageOfFile.convertFromImage(foo);
+ application->iconLineEdit->insertItem(imageOfFile,fileName);
+ }
+ //odebug << fi->fileName().latin1() << oendl;
+ ++it;
+ }
+ waitDialog.hide();
+ }
+ int pixmap = -1;
+ QString pixmapText = app.pixmapString();
+ QComboBox *f = application->iconLineEdit;
+ for(int i = 0; i < application->iconLineEdit->count(); i++){
+ if(f->text(i) == pixmapText){
+ pixmap = i;
+ break;
+ }
+ }
+ if(pixmap != -1)
+ application->iconLineEdit->setCurrentItem(pixmap);
+ else if(pixmapText.isEmpty()){
+ application->iconLineEdit->setCurrentItem(0);
+ }
+ else{
+ QPixmap imageOfFile(Resource::loadPixmap(pixmapText));
+ QImage foo = imageOfFile.convertToImage();
+ foo = foo.smoothScale(16,16);
+ imageOfFile.convertFromImage(foo);
+ application->iconLineEdit->insertItem(imageOfFile,pixmapText,0);
+ application->iconLineEdit->setCurrentItem(0);
+ }
+
+ application->nameLineEdit->setText(app.name());
+ application->execLineEdit->setText(app.exec());
+ application->commentLineEdit->setText(app.comment());
+
+ if(item->parent() == NULL){
+ application->execLineEdit->setEnabled(false);
+ application->TextLabel3->setEnabled(false);
+ application->setCaption(tr("Tab"));
+ }
+ else{
+ application->execLineEdit->setEnabled(true);
+ application->TextLabel3->setEnabled(true);
+ application->setCaption(tr("Application"));
+ }
+
+ // Only do somthing if they hit OK
+ application->showMaximized();
+ if(application->exec() == 0)
+ return;
+
+ // If nothing has changed exit (hmmm why did they hit ok?)
+ if(app.name() == application->nameLineEdit->text() &&
+ app.pixmapString() == application->iconLineEdit->currentText() &&
+ app.comment() == application->commentLineEdit->text() &&
+ app.exec() == application->execLineEdit->text())
+ return;
+
+ // Change the applnk file
+ QString oldName = app.name();
+ app.setName(application->nameLineEdit->text());
+ app.setIcon(application->iconLineEdit->currentText());
+ app.setComment(application->commentLineEdit->text());
+ app.setExec(application->execLineEdit->text());
+ if(!app.writeLink()){
+ QMessageBox::critical(this, tr("Message"), "Can't save.", tr("Ok") );
+ return;
+ }
+
+ // Update the gui icon and name
+ item->setText(0,app.name());
+ item->setPixmap(0,app.pixmap());
+
+ // We have changed something.
+ changed = true;
+
+ // If we were dealing with a new folder or new application change
+ // the file names. Also change the item location in itemList
+ if(oldName == NEW_FOLDER){
+ QDir r;
+ QString oldName = itemList[item];
+ oldName = oldName.mid(0,oldName.length()-11);
+ QString newName = oldName.mid(0,oldName.length()-9);
+ newName = newName + "/" + app.name();
+ r.rename(oldName, newName);
+ itemList.remove(item);
+ itemList.insert(item, newName + "/.directory" );
+ }
+ else if(oldName == NEW_APPLICATION){
+ if(!item->parent())
+ return;
+ QString parentDir = itemList[item->parent()];
+ QDir r;
+ QString oldName = itemList[item];
+ QString newName = oldName.mid(0, parentDir.length()-10);
+ newName = newName + app.name() + APPLICATION_EXTENSION;
+ r.rename(oldName, newName);
+ itemList.remove(item);
+ itemList.insert(item, newName);
+ }
+}
+
+/**
+ * Move an application from one directory to another.
+ * Move in the gui, move in the applnk file, move in the installer.
+ * @param item the application to move
+ * @pearam newGroup the new parent of this application
+ */
+void TabManager::moveApplication(QListViewItem *item, QListViewItem *newGroup){
+ // Can we even move it?
+ if(!item || !item->parent() || newGroup->parent())
+ return;
+ if(item->parent() == newGroup)
+ return;
+
+ // Get the new folder, new file name,
+ QString newFolder = itemList[newGroup];
+ newFolder = newFolder.mid(0,newFolder.length()-11);
+ int slash = newFolder.findRev('/', -1);
+ QString folderName = newFolder.mid(slash+1, newFolder.length());
+
+ QString desktopFile = itemList[item];
+ slash = desktopFile.findRev('/', -1);
+ desktopFile = desktopFile.mid(slash, desktopFile.length());
+ newFolder = newFolder + desktopFile;
+
+ // Move file
+ QDir r;
+ if(!r.rename(itemList[item], newFolder)){
+ QMessageBox::critical(this, tr("Message"), "Can't move application.", tr("Ok") );
+ return;
+ }
+ //odebug << (QString("moveApplication: ") + itemList[item]).latin1() << oendl;
+ //odebug << (QString("moveApplication: ") + newFolder).latin1() << oendl;
+
+ // Move in the gui
+ item->parent()->takeItem(item);
+ newGroup->insertItem(item);
+ newGroup->setOpen(true);
+
+ // Move file in the installer
+ QString installedAppFile;
+ if(findInstalledApplication(desktopFile, installedAppFile))
+ swapInstalledLocation(installedAppFile, desktopFile, newFolder);
+ else
+ odebug << "moveApplication: No installed app found for dekstop file" << oendl;
+
+ // Move application type
+ AppLnk app(newFolder);
+ app.setType(folderName);
+ app.writeLink();
+
+ // Move in our internal list
+ itemList.remove(item);
+ itemList.insert(item, newFolder);
+
+ // We have changed something.
+ changed = true;
+}
+
+/**
+ * File the installed application that has this desktop file.
+ * Go through each file in HOME_APP_INSTALL_DIR and see if it contains desktop
+ * file
+ * @param desktopFile - the .desktop file to search for [foo.desktop]
+ * @param installedAppFile - location of the app install list
+ * @return true if successful, false if file not found.
+ */
+bool TabManager::findInstalledApplication(QString desktopFile, QString &installedAppFile){
+
+ QDir d;
+ d.setPath(HOME_APP_INSTALL_DIR);
+ d.setFilter( QDir::Files );
+
+ const QFileInfoList *list = d.entryInfoList();
+ QFileInfoListIterator it( *list ); // create list iterator
+ QFileInfo *fi; // pointer for traversing
+
+ while ( (fi=it.current()) ) { // for each file...
+ QFile file(QString(HOME_APP_INSTALL_DIR) + "/" + fi->fileName());
+ if ( file.open(IO_ReadOnly) ) { // file opened successfully
+ QTextStream stream( &file ); // use a text stream
+ QString line;
+ while ( !stream.eof() ) { // until end of file...
+ line = stream.readLine(); // line of text excluding '\n'
+ if(line.contains(desktopFile)){
+ installedAppFile = QString(HOME_APP_INSTALL_DIR) + "/" + fi->fileName();
+ file.close();
+ return true;
+ }
+ }
+ file.close();
+ }
+ else
+ odebug << (QString("findInstalledApplication: Can't open file") + HOME_APP_INSTALL_DIR + "/" + fi->fileName()).latin1() << oendl;
+ ++it; // goto next list element
+ }
+ return false;
+}
+
+/**
+ * Open a file and replace a file containing the old desktop file with the new.
+ * @param installedAppFile application installed list
+ * @param desktopFile old .desktop file
+ * @param newLocation new .desktop file
+ */
+void TabManager::swapInstalledLocation( QString installedAppFile, QString desktopFile, QString newLocation ){
+ QFile file(installedAppFile);
+ if ( !file.open(IO_ReadOnly) ){
+ odebug << QString("swapInstalledLocation: Can't edit file: %1").arg(installedAppFile).latin1() << oendl;
+ return;
+ }
+
+ QTextStream stream( &file ); // use a text stream
+ QString allLines;
+ while ( !stream.eof() ) { // until end of file...
+ QString line = stream.readLine(); // line of text excluding '\n'
+ if(line.contains(desktopFile))
+ allLines += newLocation;
+ else
+ allLines += line;
+ allLines += '\n';
+ }
+ file.close();
+
+ if ( !file.open(IO_ReadWrite) ){
+ odebug << QString("swapInstalledLocation: Can't edit file: %1").arg(installedAppFile).latin1() << oendl;
+ return;
+ }
+ QTextStream streamOut( &file );
+ streamOut << allLines;
+ file.close();
+}
+
+// tabmanager.cpp
+
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 @@
+#ifndef TABMANAGER_H
+#define TABMANAGER_H
+
+#include "tabmanagerbase.h"
+#include <qmap.h>
+#include <qevent.h>
+
+class QListViewItem;
+class AppEdit;
+
+class TabManager : public TabManagerBase {
+ Q_OBJECT
+
+public:
+ TabManager( QWidget* parent = 0, const char* name = 0);
+ ~TabManager();
+ bool changed;
+
+public slots:
+ void newFolder();
+ void newApplication();
+ void removeItem();
+ void editCurrentItem();
+
+private slots:
+ void moveApplication(QListViewItem *, QListViewItem *);
+ void editItem(QListViewItem * item);
+
+protected:
+ void rescanFolder(QString directory, QListViewItem* parent=NULL);
+ QMap<QListViewItem *, QString> itemList;
+ bool findInstalledApplication(QString desktopFile, QString &installedAppFile);
+ void swapInstalledLocation( QString installedAppFile, QString desktopFile, QString newLocation );
+
+private:
+ AppEdit *application;
+
+};
+
+#endif
+
+// tabmanager.h
+
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 @@
+CONFIG = qt quick-app
+HEADERS = tabmanager.h tabmainwindow.h tablistview.h tabmanagerbase.h tabapplnk.h
+SOURCES = main.cpp tabmanager.cpp tabmanagerbase.cpp
+INCLUDEPATH += $(OPIEDIR)/include
+DEPENDPATH += $(OPIEDIR)/include
+LIBS += -lqpe -lopiecore2
+INTERFACES = app.ui wait.ui
+TARGET = tabmanager
+
+include( $(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 @@
+/****************************************************************************
+** Form implementation generated from reading ui file 'tabmanagerbase.ui'
+**
+** Created: Fri May 3 14:38:14 2002
+** by: The User Interface Compiler (uic)
+**
+** WARNING! All changes made in this file will be lost!
+****************************************************************************/
+#include "tabmanagerbase.h"
+
+#include <qheader.h>
+#include <qlistview.h>
+#include <qpushbutton.h>
+#include <qlayout.h>
+#include <qvariant.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+
+/*
+ * Constructs a TabManagerBase which is a child of 'parent', with the
+ * name 'name' and widget flags set to 'f'
+ */
+TabManagerBase::TabManagerBase( QWidget* parent, const char* name, WFlags fl )
+ : QWidget( parent, name, fl )
+{
+ if ( !name )
+ setName( "TabManagerBase" );
+ resize( 289, 228 );
+ setCaption( tr( "Tab Manager" ) );
+ TabManagerBaseLayout = new QVBoxLayout( this );
+ TabManagerBaseLayout->setSpacing( 4 );
+ TabManagerBaseLayout->setMargin( 4 );
+
+ tabList = new TabListView( this, "tabList" );
+ tabList->addColumn( tr( "Hierarchy" ) );
+ tabList->setRootIsDecorated( TRUE );
+ TabManagerBaseLayout->addWidget( tabList );
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+TabManagerBase::~TabManagerBase()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
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 @@
+/****************************************************************************
+** Form interface generated from reading ui file 'tabmanagerbase.ui'
+**
+** Created: Fri May 3 14:38:09 2002
+** by: The User Interface Compiler (uic)
+**
+** WARNING! All changes made in this file will be lost!
+****************************************************************************/
+#ifndef TABMANAGERBASE_H
+#define TABMANAGERBASE_H
+
+#include <qvariant.h>
+#include <qwidget.h>
+#include "tablistview.h"
+class QVBoxLayout;
+class QHBoxLayout;
+class QGridLayout;
+class QListView;
+class QListViewItem;
+
+class TabManagerBase : public QWidget
+{
+ Q_OBJECT
+
+public:
+ TabManagerBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
+ ~TabManagerBase();
+
+ TabListView* tabList;
+
+protected:
+ QVBoxLayout* TabManagerBaseLayout;
+};
+
+#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 @@
+<!DOCTYPE UI><UI>
+<class>TabManagerBase</class>
+<widget>
+ <class>QWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TabManagerBase</cstring>
+ </property>
+ <property stdset="1">
+ <name>geometry</name>
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>289</width>
+ <height>228</height>
+ </rect>
+ </property>
+ <property stdset="1">
+ <name>caption</name>
+ <string>Tab Manager</string>
+ </property>
+ <property>
+ <name>layoutMargin</name>
+ </property>
+ <vbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>4</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>4</number>
+ </property>
+ <widget>
+ <class>QListView</class>
+ <column>
+ <property>
+ <name>text</name>
+ <string>Hierarchy</string>
+ </property>
+ <property>
+ <name>clickable</name>
+ <bool>true</bool>
+ </property>
+ <property>
+ <name>resizeable</name>
+ <bool>true</bool>
+ </property>
+ </column>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>tabList</cstring>
+ </property>
+ <property stdset="1">
+ <name>rootIsDecorated</name>
+ <bool>true</bool>
+ </property>
+ </widget>
+ </vbox>
+</widget>
+</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 @@
+<!DOCTYPE UI><UI>
+<class>Wait</class>
+<widget>
+ <class>QDialog</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Wait</cstring>
+ </property>
+ <property stdset="1">
+ <name>geometry</name>
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>124</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property stdset="1">
+ <name>caption</name>
+ <string>Please Wait...</string>
+ </property>
+ <property>
+ <name>layoutMargin</name>
+ </property>
+ <grid>
+ <property stdset="1">
+ <name>margin</name>
+ <number>4</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>4</number>
+ </property>
+ <widget row="0" column="0" >
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>waitLabel</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Please Wait...</string>
+ </property>
+ <property stdset="1">
+ <name>alignment</name>
+ <set>AlignCenter</set>
+ </property>
+ <property>
+ <name>hAlign</name>
+ </property>
+ </widget>
+ </grid>
+</widget>
+</UI>