Commit 602212df authored by Urs Wolfer's avatar Urs Wolfer

The remote desktops model is now able to show the current bookmarks (and...

The remote desktops model is now able to show the current bookmarks (and groups). Also show some icons and make the dock widget a bit more usable: on double click check if the remote desktop has already been opened and in case switch to that tab instead of opening it again.
Still work in progress.

svn path=/trunk/KDE/kdenetwork/krdc/; revision=789190
parent 5d52a8ed
......@@ -103,6 +103,7 @@ MainWindow::MainWindow(QWidget *parent)
QTreeView *remoteDesktopsTreeView = new QTreeView(remoteDesktopsDockWidget);
remoteDesktopsTreeView->setModel(new RemoteDesktopsModel(this));
connect(remoteDesktopsTreeView, SIGNAL(doubleClicked(const QModelIndex &)),
SLOT(openFromDockWidget(const QModelIndex &)));
......@@ -348,10 +349,22 @@ void MainWindow::newConnection(const KUrl &newUrl, bool switchFullscreenWhenConn
void MainWindow::openFromDockWidget(const QModelIndex &index)
KUrl url(;
kDebug(5010) << url;
if (url.isValid())
if ( {
KUrl url(;
// first check if url has already been opened; in case show the tab
for (int i = 0; i < m_remoteViewList.count(); i++) {
if (>url() == url) {
int numNonRemoteView = 0;
if (m_showStartPage)
if (m_zeroconfPage)
m_tabWidget->setCurrentIndex(i + numNonRemoteView);
void MainWindow::resizeTabWidget(int w, int h)
......@@ -26,6 +26,7 @@
#include "remotedesktopsitem.h"
#include <KBookmarkManager>
#include <KIcon>
#include <KStandardDirs>
#include <KDebug>
......@@ -42,12 +43,7 @@ RemoteDesktopsModel::RemoteDesktopsModel(QObject *parent)
KBookmarkGroup root = m_manager->root();
KBookmark bm = root.first();
while (!bm.isNull()) {
rootItem->appendChild(new RemoteDesktopsItem(QList<QVariant>() << bm.text(), rootItem));
bm =;
buildModelFromBookmarkGroup(m_manager->root(), rootItem);
RemoteDesktopsItem *localNetwork = new RemoteDesktopsItem(QList<QVariant>() << "Local Network", rootItem);
......@@ -72,12 +68,25 @@ QVariant RemoteDesktopsModel::data(const QModelIndex &index, int role) const
if (!index.isValid())
return QVariant();
if (role != Qt::DisplayRole)
return QVariant();
RemoteDesktopsItem *item = static_cast<RemoteDesktopsItem*>(index.internalPointer());
return item->data(index.column());
switch (role) {
case Qt::DisplayRole:
return item->data(index.column());
case Qt::DecorationRole:
if (item->data(index.column()).toString().contains("://")) //TODO: clean impl
return KIcon("krdc");
else if (item->data(index.column()).toString() == "Local Network") //TODO: clean impl
return KIcon("network-workgroup");
else if (item->data(index.column()).toString() == "...") //TODO: clean impl
return KIcon("view-history");
return KIcon("folder-bookmarks");
case Qt::UserRole: // tell if it is an address
return QVariant(item->data(index.column()).toString().contains("://"));
return QVariant();
Qt::ItemFlags RemoteDesktopsModel::flags(const QModelIndex &index) const
......@@ -144,4 +153,16 @@ int RemoteDesktopsModel::rowCount(const QModelIndex &parent) const
return parentItem->childCount();
void RemoteDesktopsModel::buildModelFromBookmarkGroup(const KBookmarkGroup &group, RemoteDesktopsItem *item)
KBookmark bm = group.first();
while (!bm.isNull()) {
RemoteDesktopsItem *newItem = new RemoteDesktopsItem(QList<QVariant>() << bm.text(), item);
if (bm.isGroup())
buildModelFromBookmarkGroup(bm.toGroup(), newItem); //recursive
bm =;
#include "remotedesktopsmodel.moc"
......@@ -26,6 +26,7 @@
#include <QAbstractItemModel>
class KBookmarkGroup;
class KBookmarkManager;
class RemoteDesktopsItem;
......@@ -48,6 +49,8 @@ public:
int columnCount(const QModelIndex &parent = QModelIndex()) const;
void buildModelFromBookmarkGroup(const KBookmarkGroup &group, RemoteDesktopsItem *item);
KBookmarkManager *m_manager;
RemoteDesktopsItem *rootItem;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment