[X2Go-Commits] [x2goclient] 01/01: Support for sessions folders in sessionmanagedialog.
git-admin at x2go.org
git-admin at x2go.org
Thu Aug 14 13:14:58 CEST 2014
This is an automated email from the git hooks/post-receive script.
x2go pushed a commit to branch master
in repository x2goclient.
commit 9c05de1eefc87ff767d96d2ea1064d1a3a203a08
Author: Oleksandr Shneyder <o.shneyder at phoca-gmbh.de>
Date: Thu Aug 14 13:14:49 2014 +0200
Support for sessions folders in sessionmanagedialog.
---
debian/changelog | 1 +
editconnectiondialog.cpp | 4 +-
editconnectiondialog.h | 34 +++++++--------
onmainwindow.cpp | 2 +-
sessionbutton.h | 4 ++
sessionexplorer.cpp | 4 +-
sessionexplorer.h | 10 +++++
sessionmanagedialog.cpp | 107 +++++++++++++++++++++++++++++++++-------------
sessionmanagedialog.h | 46 +++++++++++---------
sessionwidget.cpp | 7 ++-
sessionwidget.h | 3 +-
11 files changed, 147 insertions(+), 75 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 8534eec..744fa33 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -30,6 +30,7 @@ x2goclient (4.0.3.0-0x2go1) UNRELEASED; urgency=low
- Add Makefile for x2gohelper.
- Add support for sessions folders.
- Add folder explorer - GUI to management of sessions folders.
+ - Support for sessions folders in sessionmanagedialog.
[ Mike DePaulo ]
* New upstream release (4.0.3.0):
diff --git a/editconnectiondialog.cpp b/editconnectiondialog.cpp
index 0769e3b..5cd0d3d 100644
--- a/editconnectiondialog.cpp
+++ b/editconnectiondialog.cpp
@@ -28,7 +28,7 @@
#include "connectionwidget.h"
#include "settingswidget.h"
-EditConnectionDialog::EditConnectionDialog ( QString id, QWidget * par,
+EditConnectionDialog::EditConnectionDialog ( bool newSession, QString id, QWidget * par,
int ind,Qt::WFlags f )
: QDialog ( par,f )
{
@@ -49,7 +49,7 @@ EditConnectionDialog::EditConnectionDialog ( QString id, QWidget * par,
#endif
setFont ( fnt );
- sessSet=new SessionWidget ( id,parent );
+ sessSet=new SessionWidget ( newSession, id,parent );
conSet=new ConnectionWidget ( id,parent );
otherSet=new SettingsWidget ( id,parent );
exportDir=new ShareWidget ( id,parent );
diff --git a/editconnectiondialog.h b/editconnectiondialog.h
index a7bfee9..32b36dd 100644
--- a/editconnectiondialog.h
+++ b/editconnectiondialog.h
@@ -45,25 +45,25 @@ class ShareWidget;
class EditConnectionDialog : public QDialog
{
- Q_OBJECT
- public:
- EditConnectionDialog ( QString id, QWidget * par, int ind=0,
- Qt::WFlags f = 0 );
- ~EditConnectionDialog();
- private:
- QTabWidget *fr;
- SessionWidget* sessSet;
- ConnectionWidget* conSet;
- SettingsWidget* otherSet;
- ShareWidget* exportDir;
+ Q_OBJECT
+public:
+ EditConnectionDialog ( bool newSession, QString id, QWidget * par, int ind=0,
+ Qt::WFlags f = 0 );
+ ~EditConnectionDialog();
+private:
+ QTabWidget *fr;
+ SessionWidget* sessSet;
+ ConnectionWidget* conSet;
+ SettingsWidget* otherSet;
+ ShareWidget* exportDir;
- private slots:
- void slot_changeCaption ( const QString& newName );
- void slot_accepted();
- void slot_default();
-#ifdef Q_OS_LINUX
- void slot_directRDP(bool direct);
+private slots:
+ void slot_changeCaption ( const QString& newName );
+ void slot_accepted();
+ void slot_default();
+#ifdef Q_OS_LINUX
+ void slot_directRDP(bool direct);
#endif
};
diff --git a/onmainwindow.cpp b/onmainwindow.cpp
index 4f4bceb..69be30f 100644
--- a/onmainwindow.cpp
+++ b/onmainwindow.cpp
@@ -2193,7 +2193,7 @@ void ONMainWindow::slotNewSession()
{
QString id=QDateTime::currentDateTime().
toString ( "yyyyMMddhhmmsszzz" );
- EditConnectionDialog dlg ( id, this );
+ EditConnectionDialog dlg (true, id, this );
if ( dlg.exec() ==QDialog::Accepted )
{
SessionButton* bt=sessionExplorer->createBut ( id );
diff --git a/sessionbutton.h b/sessionbutton.h
index 6a39648..e153438 100644
--- a/sessionbutton.h
+++ b/sessionbutton.h
@@ -48,6 +48,10 @@ public:
{
return path;
}
+ QString getName()
+ {
+ return sessName->text();
+ }
void setPath(QString path)
{
this->path=path;
diff --git a/sessionexplorer.cpp b/sessionexplorer.cpp
index 06694f7..cd16ed3 100644
--- a/sessionexplorer.cpp
+++ b/sessionexplorer.cpp
@@ -86,7 +86,7 @@ void SessionExplorer::cleanSessions()
void SessionExplorer::exportsEdit ( SessionButton* bt )
{
- EditConnectionDialog dlg ( bt->id(),parent,3 );
+ EditConnectionDialog dlg (false, bt->id(),parent,3 );
if ( dlg.exec() ==QDialog::Accepted )
{
bt->redraw();
@@ -119,7 +119,7 @@ void SessionExplorer::getFoldersFromConfig()
void SessionExplorer::slotEdit ( SessionButton* bt )
{
- EditConnectionDialog dlg ( bt->id(),parent );
+ EditConnectionDialog dlg (false, bt->id(),parent );
if ( dlg.exec() ==QDialog::Accepted )
{
bt->redraw();
diff --git a/sessionexplorer.h b/sessionexplorer.h
index beaa471..67bd171 100644
--- a/sessionexplorer.h
+++ b/sessionexplorer.h
@@ -64,6 +64,16 @@ public:
void renameFolder(QString oldPath, QString currentPath);
void deleteFolder(QString path);
+ QString getCurrentPath()
+ {
+ return currentPath;
+ }
+
+ void setCurrrentPath(QString path)
+ {
+ currentPath=path;
+ }
+
//vars
private:
diff --git a/sessionmanagedialog.cpp b/sessionmanagedialog.cpp
index ca11f31..f88245b 100644
--- a/sessionmanagedialog.cpp
+++ b/sessionmanagedialog.cpp
@@ -23,13 +23,15 @@
#include <QDir>
#include <QFrame>
#include <QBoxLayout>
-#include <QListView>
+#include <QTreeWidget>
#include <QStringListModel>
#include <QShortcut>
#include "sessionbutton.h"
+#include "folderbutton.h"
#include "sessionexplorer.h"
-
+#define SESSIONROLE Qt::UserRole+1
+#define SESSIONIDROLE Qt::UserRole+2
SessionManageDialog::SessionManageDialog ( QWidget * parent,
bool onlyCreateIcon, Qt::WFlags f )
@@ -39,10 +41,12 @@ SessionManageDialog::SessionManageDialog ( QWidget * parent,
QFrame *fr=new QFrame ( this );
QHBoxLayout* frLay=new QHBoxLayout ( fr );
+ currentPath="";
+
QPushButton* ok=new QPushButton ( tr ( "E&xit" ),this );
QHBoxLayout* bLay=new QHBoxLayout();
- sessions=new QListView ( fr );
+ sessions=new QTreeWidget ( fr );
frLay->addWidget ( sessions );
QPushButton* newSession=new QPushButton ( tr ( "&New session" ),fr );
@@ -115,10 +119,10 @@ SessionManageDialog::SessionManageDialog ( QWidget * parent,
setWindowTitle ( tr ( "Session management" ) );
loadSessions();
- connect ( sessions,SIGNAL ( clicked ( const QModelIndex& ) ),
- this,SLOT ( slot_activated ( const QModelIndex& ) ) );
- connect ( sessions,SIGNAL ( doubleClicked ( const QModelIndex& ) ),
- this,SLOT ( slot_dclicked ( const QModelIndex& ) ) );
+ connect ( sessions, SIGNAL(itemActivated(QTreeWidgetItem*,int)),
+ this,SLOT(slot_activated(QTreeWidgetItem*,int)) );
+ connect ( sessions,SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),
+ this,SLOT(slot_dclicked(QTreeWidgetItem*,int)) );
}
@@ -128,47 +132,90 @@ SessionManageDialog::~SessionManageDialog()
void SessionManageDialog::loadSessions()
{
- QStringListModel *model= ( QStringListModel* ) sessions->model();
- if ( !model )
- model=new QStringListModel();
- sessions->setModel ( model );
- QStringList lst;
- model->setStringList ( lst );
+ sessions->clear();
const QList<SessionButton*> *sess=par->getSessionExplorer()->getSessionsList();
+ const QList<FolderButton*> *folders=par->getSessionExplorer()->getFoldersList();
- for ( int i=0; i<sess->size(); ++i )
- lst<<sess->at ( i )->name();
-
- model->setStringList ( lst );
removeSession->setEnabled ( false );
editSession->setEnabled ( false );
#if (!defined Q_WS_HILDON) && (!defined Q_OS_DARWIN)
if ( !ONMainWindow::getPortable() )
createSessionIcon->setEnabled ( false );
#endif
- sessions->setEditTriggers ( QAbstractItemView::NoEditTriggers );
+
+ QTreeWidgetItem* root;
+
+ root=new QTreeWidgetItem(sessions);
+ root->setText(0,"/");
+ root->setIcon(0,QIcon(":icons/128x128/folder.png"));
+ initFolders(root, "");
+ root->setExpanded(true);
+ root->setData(0, SESSIONROLE , false);
+
+ sessions->setRootIsDecorated(false);
+ sessions->setHeaderHidden(true);
}
+void SessionManageDialog::initFolders(QTreeWidgetItem* parent, QString path)
+{
+ FolderButton* b;
+ foreach(b, *(par->getSessionExplorer()->getFoldersList()))
+ {
+ if(b->getPath()==path)
+ {
+ QTreeWidgetItem* it=new QTreeWidgetItem(parent);
+ it->setText(0,b->getName());
+ it->setIcon(0, QIcon(*(b->folderIcon())));
+ QString normPath=(b->getPath()+"/"+b->getName()).split("/",QString::SkipEmptyParts).join("/");
+ it->setData(0,Qt::UserRole, normPath+"/");
+ it->setData(0, SESSIONROLE , false);
+ initFolders(it, normPath);
+ }
+ }
+ for(int i=0; i< par->getSessionExplorer()->getSessionsList()->count(); ++i)
+ {
+ SessionButton* s=par->getSessionExplorer()->getSessionsList()->at(i);
+ if(s->getPath()==path)
+ {
+ QTreeWidgetItem* it=new QTreeWidgetItem(parent);
+ it->setText(0,s->getName());
+ it->setIcon(0, QIcon(*(s->sessIcon())));
+ QString normPath=(s->getPath()+"/"+s->getName()).split("/",QString::SkipEmptyParts).join("/");
+ it->setData(0,Qt::UserRole, normPath+"/");
+ it->setData(0, SESSIONROLE, true);
+ it->setData(0, SESSIONIDROLE, i);
+ initFolders(it, normPath);
+ }
+ }
+}
-void SessionManageDialog::slot_activated ( const QModelIndex& )
+
+void SessionManageDialog::slot_activated ( QTreeWidgetItem* item, int )
{
- removeSession->setEnabled ( true );
- editSession->setEnabled ( true );
+ bool isSess=item->data(0, SESSIONROLE).toBool();
+ if(!isSess)
+ {
+ currentPath=item->data(0,Qt::UserRole).toString().split("/",QString::SkipEmptyParts).join("/");
+ }
+ removeSession->setEnabled ( isSess );
+ editSession->setEnabled ( isSess );
#if (!defined Q_WS_HILDON) && (!defined Q_OS_DARWIN)
if ( !ONMainWindow::getPortable() )
- createSessionIcon->setEnabled ( true );
+ createSessionIcon->setEnabled ( isSess );
#endif
}
-void SessionManageDialog::slot_dclicked ( const QModelIndex& )
+void SessionManageDialog::slot_dclicked ( QTreeWidgetItem* item, int )
{
- slot_edit();
+ if(item->data(0, SESSIONROLE).toBool())
+ slot_edit();
}
void SessionManageDialog::slotNew()
{
+ par->getSessionExplorer()->setCurrrentPath(currentPath);
par->slotNewSession();
loadSessions();
}
@@ -176,27 +223,27 @@ void SessionManageDialog::slotNew()
void SessionManageDialog::slot_edit()
{
- int ind=sessions->currentIndex().row();
- if ( ind<0 )
+ if((! sessions->currentItem()) || (! sessions->currentItem()->data(0, SESSIONROLE).toBool()))
return;
+ int ind=sessions->currentItem()->data(0, SESSIONIDROLE).toInt();
par->getSessionExplorer()->slotEdit ( par->getSessionExplorer()->getSessionsList()->at ( ind ) );
loadSessions();
}
void SessionManageDialog::slot_createSessionIcon()
{
- int ind=sessions->currentIndex().row();
- if ( ind<0 )
+ if((! sessions->currentItem()) || (! sessions->currentItem()->data(0, SESSIONROLE).toBool()))
return;
+ int ind=sessions->currentItem()->data(0, SESSIONIDROLE).toInt();
par->getSessionExplorer()->slotCreateDesktopIcon ( par->getSessionExplorer()->getSessionsList()->at ( ind ) );
}
void SessionManageDialog::slot_delete()
{
- int ind=sessions->currentIndex().row();
- if ( ind<0 )
+ if((! sessions->currentItem()) || (! sessions->currentItem()->data(0, SESSIONROLE).toBool()))
return;
+ int ind=sessions->currentItem()->data(0, SESSIONIDROLE).toInt();
par->getSessionExplorer()->slotDeleteButton ( par->getSessionExplorer()->getSessionsList()->at ( ind ) );
loadSessions();
}
diff --git a/sessionmanagedialog.h b/sessionmanagedialog.h
index 825d6db..1f9c18f 100644
--- a/sessionmanagedialog.h
+++ b/sessionmanagedialog.h
@@ -20,7 +20,8 @@
#include "x2goclientconfig.h"
#include <QDialog>
-class QListView;
+class QTreeWidget;
+class QTreeWidgetItem;
class QPushButton;
class QModelIndex;
class ONMainWindow;
@@ -30,26 +31,29 @@ class ONMainWindow;
class SessionManageDialog : public QDialog
{
- Q_OBJECT
- public:
- SessionManageDialog ( QWidget * parent,
- bool onlyCreateIcon=false,
- Qt::WFlags f=0 );
- ~SessionManageDialog();
- void loadSessions();
- private:
- QListView* sessions;
- QPushButton* editSession;
- QPushButton* removeSession;
- QPushButton* createSessionIcon;
- ONMainWindow* par;
- private slots:
- void slot_activated ( const QModelIndex& index );
- void slotNew();
- void slot_edit();
- void slot_createSessionIcon();
- void slot_delete();
- void slot_dclicked ( const QModelIndex& index );
+ Q_OBJECT
+public:
+ SessionManageDialog ( QWidget * parent,
+ bool onlyCreateIcon=false,
+ Qt::WFlags f=0 );
+ ~SessionManageDialog();
+ void loadSessions();
+private:
+ void initFolders(QTreeWidgetItem* parent, QString path);
+private:
+ QTreeWidget* sessions;
+ QPushButton* editSession;
+ QPushButton* removeSession;
+ QPushButton* createSessionIcon;
+ ONMainWindow* par;
+ QString currentPath;
+private slots:
+ void slot_activated ( QTreeWidgetItem * item, int);
+ void slotNew();
+ void slot_edit();
+ void slot_createSessionIcon();
+ void slot_delete();
+ void slot_dclicked ( QTreeWidgetItem * item, int );
};
#endif
diff --git a/sessionwidget.cpp b/sessionwidget.cpp
index 874c26f..668676c 100644
--- a/sessionwidget.cpp
+++ b/sessionwidget.cpp
@@ -36,8 +36,9 @@
#include <QButtonGroup>
#include <QRadioButton>
#include "folderexplorer.h"
+#include "sessionexplorer.h"
-SessionWidget::SessionWidget ( QString id, ONMainWindow * mw,
+SessionWidget::SessionWidget ( bool newSession, QString id, ONMainWindow * mw,
QWidget * parent, Qt::WindowFlags f )
: ConfigWidget ( id,mw,parent,f )
{
@@ -46,6 +47,8 @@ SessionWidget::SessionWidget ( QString id, ONMainWindow * mw,
sessLay->setMargin ( 2 );
#endif
this->parent=mw;
+ this->newSession=newSession;
+
sessName=new QLineEdit ( this );
icon=new QPushButton ( QString::null,this );
if ( !miniMode )
@@ -533,6 +536,8 @@ void SessionWidget::readConfig()
path=tails.join("/")+"/";
}
lPath->setText(path);
+ if(newSession)
+ lPath->setText(parent->getSessionExplorer()->getCurrentPath()+"/");
sessName->setText (name);
diff --git a/sessionwidget.h b/sessionwidget.h
index 4d07e6a..94ef4e3 100644
--- a/sessionwidget.h
+++ b/sessionwidget.h
@@ -35,7 +35,7 @@ class SessionWidget : public ConfigWidget
{
Q_OBJECT
public:
- SessionWidget ( QString id, ONMainWindow * mv,
+ SessionWidget ( bool newSession, QString id, ONMainWindow * mv,
QWidget * parent = 0, Qt::WindowFlags f = 0 );
~SessionWidget();
void setDefaults();
@@ -65,6 +65,7 @@ private:
QLineEdit* server;
QSpinBox* sshPort;
ONMainWindow* parent;
+ bool newSession;
#ifdef Q_OS_LINUX
QSpinBox* rdpPort;
#endif
--
Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git
More information about the x2go-commits
mailing list