Blame SOURCES/kdenetwork-4.10.5-krdc-bz#1008890.patch

a0c1b7
--- kdenetwork-4.10.5/krdc/mainwindow.cpp.orig  2013-06-28 20:08:57.392483928 +0200
a0c1b7
+++ kdenetwork-4.10.5/krdc/mainwindow.cpp       2013-10-29 09:41:07.000000000 +0100
a0c1b7
@@ -340,8 +340,6 @@ void MainWindow::newConnection(const KUr
a0c1b7
     connect(view, SIGNAL(statusChanged(RemoteView::RemoteStatus)), this, SLOT(statusChanged(RemoteView::RemoteStatus)));
a0c1b7
     connect(view, SIGNAL(disconnected()), this, SLOT(disconnectHost()));
a0c1b7
 
a0c1b7
-    m_remoteViewList.append(view);
a0c1b7
-
a0c1b7
     QScrollArea *scrollArea = createScrollArea(m_tabWidget, view);
a0c1b7
 
a0c1b7
     const int indexOfNewConnectionWidget = m_tabWidget->indexOf(m_newConnectionWidget);
a0c1b7
@@ -350,6 +348,7 @@ void MainWindow::newConnection(const KUr
a0c1b7
 
a0c1b7
     const int newIndex = m_tabWidget->addTab(scrollArea, KIcon("krdc"), tabName.isEmpty() ? url.prettyUrl(KUrl::RemoveTrailingSlash) : tabName);
a0c1b7
     m_tabWidget->setCurrentIndex(newIndex);
a0c1b7
+    m_remoteViewMap.insert(m_tabWidget->widget(newIndex), view);
a0c1b7
     tabChanged(newIndex); // force to update m_currentRemoteView (tabChanged is not emitted when start page has been disabled)
a0c1b7
 
a0c1b7
     view->start();
a0c1b7
@@ -362,12 +361,13 @@ void MainWindow::openFromRemoteDesktopsM
a0c1b7
     if (!urlString.isEmpty()) {
a0c1b7
         const KUrl url(urlString);
a0c1b7
         // first check if url has already been opened; in case show the tab
a0c1b7
-        for (int i = 0; i < m_remoteViewList.count(); ++i) {
a0c1b7
-            if (m_remoteViewList.at(i)->url() == url) {
a0c1b7
-                m_tabWidget->setCurrentIndex(i);
a0c1b7
+        foreach (QWidget *widget, m_remoteViewMap.keys()) {
a0c1b7
+            if (m_remoteViewMap.value(widget)->url() == url) {
a0c1b7
+                m_tabWidget->setCurrentWidget(widget);
a0c1b7
                 return;
a0c1b7
             }
a0c1b7
         }
a0c1b7
+
a0c1b7
         newConnection(url, false, nameString);
a0c1b7
     }
a0c1b7
 }
a0c1b7
@@ -469,7 +469,7 @@ void MainWindow::statusChanged(RemoteVie
a0c1b7
 
a0c1b7
 void MainWindow::takeScreenshot()
a0c1b7
 {
a0c1b7
-    const QPixmap snapshot = m_remoteViewList.at(m_currentRemoteView)->takeScreenshot();
a0c1b7
+    const QPixmap snapshot = currentRemoteView()->takeScreenshot();
a0c1b7
 
a0c1b7
     QApplication::clipboard()->setPixmap(snapshot);
a0c1b7
 }
a0c1b7
@@ -491,8 +491,8 @@ void MainWindow::switchFullscreen()
a0c1b7
         restoreGeometry(m_mainWindowGeometry);
a0c1b7
         if (m_systemTrayIcon) m_systemTrayIcon->setAssociatedWidget(this);
a0c1b7
 
a0c1b7
-        foreach(RemoteView *currentView, m_remoteViewList) {
a0c1b7
-            currentView->enableScaling(currentView->hostPreferences()->windowedScale());
a0c1b7
+        foreach (RemoteView * view, m_remoteViewMap.values()) {
a0c1b7
+            view->enableScaling(view->hostPreferences()->windowedScale());
a0c1b7
         }
a0c1b7
 
a0c1b7
         if (m_toolBar) {
a0c1b7
@@ -518,7 +518,7 @@ void MainWindow::switchFullscreen()
a0c1b7
         m_tabWidget->setTabBarHidden(true);
a0c1b7
         m_tabWidget->setDocumentMode(true);
a0c1b7
 
a0c1b7
-        foreach(RemoteView *currentView, m_remoteViewList) {
a0c1b7
+        foreach(RemoteView *currentView, m_remoteViewMap) {
a0c1b7
             currentView->enableScaling(currentView->hostPreferences()->fullscreenScale());
a0c1b7
         }
a0c1b7
 
a0c1b7
@@ -572,10 +572,11 @@ void MainWindow::disconnectHost()
a0c1b7
     QWidget *widgetToDelete;
a0c1b7
     if (view) {
a0c1b7
         widgetToDelete = (QWidget*) view->parent()->parent();
a0c1b7
-        m_remoteViewList.removeOne(view);
a0c1b7
+        m_remoteViewMap.remove(m_remoteViewMap.key(view));
a0c1b7
     } else {
a0c1b7
         widgetToDelete = m_tabWidget->currentWidget();
a0c1b7
-        view = m_remoteViewList.takeAt(m_currentRemoteView);
a0c1b7
+        view = currentRemoteView();
a0c1b7
+        m_remoteViewMap.remove(m_remoteViewMap.key(view));
a0c1b7
     }
a0c1b7
 
a0c1b7
     saveHostPrefs(view);
a0c1b7
@@ -600,12 +601,10 @@ void MainWindow::disconnectHost()
a0c1b7
 void MainWindow::closeTab(QWidget *widget)
a0c1b7
 {
a0c1b7
     bool isNewConnectionPage = widget == m_newConnectionWidget;
a0c1b7
-    const int index = m_tabWidget->indexOf(widget);
a0c1b7
-
a0c1b7
-    kDebug(5010) << index;
a0c1b7
 
a0c1b7
     if (!isNewConnectionPage) {
a0c1b7
-        RemoteView *view = m_remoteViewList.takeAt(index);
a0c1b7
+        RemoteView *view = m_remoteViewMap.value(widget);
a0c1b7
+        m_remoteViewMap.remove(m_remoteViewMap.key(view));
a0c1b7
         view->startQuitting();
a0c1b7
 #ifdef TELEPATHY_SUPPORT
a0c1b7
         m_tubesManager->closeTube(view->url());
a0c1b7
@@ -746,7 +745,7 @@ void MainWindow::showLocalCursor(bool sh
a0c1b7
 {
a0c1b7
     kDebug(5010) << showLocalCursor;
a0c1b7
 
a0c1b7
-    RemoteView* view = m_remoteViewList.at(m_currentRemoteView);
a0c1b7
+    RemoteView* view = currentRemoteView();
a0c1b7
     view->showDotCursor(showLocalCursor ? RemoteView::CursorOn : RemoteView::CursorOff);
a0c1b7
     view->hostPreferences()->setShowLocalCursor(showLocalCursor);
a0c1b7
     saveHostPrefs(view);
a0c1b7
@@ -756,7 +755,7 @@ void MainWindow::viewOnly(bool viewOnly)
a0c1b7
 {
a0c1b7
     kDebug(5010) << viewOnly;
a0c1b7
 
a0c1b7
-    RemoteView* view = m_remoteViewList.at(m_currentRemoteView);
a0c1b7
+    RemoteView* view = currentRemoteView();
a0c1b7
     view->setViewOnly(viewOnly);
a0c1b7
     view->hostPreferences()->setViewOnly(viewOnly);
a0c1b7
     saveHostPrefs(view);
a0c1b7
@@ -766,7 +765,7 @@ void MainWindow::grabAllKeys(bool grabAl
a0c1b7
 {
a0c1b7
     kDebug(5010);
a0c1b7
 
a0c1b7
-    RemoteView* view = m_remoteViewList.at(m_currentRemoteView);
a0c1b7
+    RemoteView* view = currentRemoteView();
a0c1b7
     view->setGrabAllKeys(grabAllKeys);
a0c1b7
     view->hostPreferences()->setGrabAllKeys(grabAllKeys);
a0c1b7
     saveHostPrefs(view);
a0c1b7
@@ -776,7 +775,7 @@ void MainWindow::scale(bool scale)
a0c1b7
 {
a0c1b7
     kDebug(5010);
a0c1b7
 
a0c1b7
-    RemoteView* view = m_remoteViewList.at(m_currentRemoteView);
a0c1b7
+    RemoteView* view = currentRemoteView();
a0c1b7
     view->enableScaling(scale);
a0c1b7
     if (m_fullscreenWindow)
a0c1b7
         view->hostPreferences()->setFullscreenScale(scale);
a0c1b7
@@ -854,7 +853,7 @@ void MainWindow::updateActionStatus()
a0c1b7
     if (m_tabWidget->currentWidget() == m_newConnectionWidget)
a0c1b7
         enabled = false;
a0c1b7
 
a0c1b7
-    RemoteView* view = (m_currentRemoteView >= 0 && enabled) ? m_remoteViewList.at(m_currentRemoteView) : 0;
a0c1b7
+    RemoteView* view = (m_currentRemoteView >= 0 && enabled) ? currentRemoteView() : 0;
a0c1b7
 
a0c1b7
     actionCollection()->action("take_screenshot")->setEnabled(enabled);
a0c1b7
     actionCollection()->action("disconnect")->setEnabled(enabled);
a0c1b7
@@ -934,15 +933,15 @@ void MainWindow::updateConfiguration()
a0c1b7
     }
a0c1b7
 
a0c1b7
     // Send update configuration message to all views
a0c1b7
-    for (int i = 0; i < m_remoteViewList.count(); ++i) {
a0c1b7
-        m_remoteViewList.at(i)->updateConfiguration();
a0c1b7
+    foreach (RemoteView *view, m_remoteViewMap.values()) {
a0c1b7
+        view->updateConfiguration();
a0c1b7
     }
a0c1b7
 
a0c1b7
 }
a0c1b7
 
a0c1b7
 void MainWindow::quit(bool systemEvent)
a0c1b7
 {
a0c1b7
-    const bool haveRemoteConnections = !m_remoteViewList.isEmpty();
a0c1b7
+    const bool haveRemoteConnections = !m_remoteViewMap.isEmpty();
a0c1b7
     if (systemEvent || !haveRemoteConnections || KMessageBox::warningContinueCancel(this,
a0c1b7
             i18n("Are you sure you want to quit the KDE Remote Desktop Client?"),
a0c1b7
             i18n("Confirm Quit"),
a0c1b7
@@ -951,17 +950,17 @@ void MainWindow::quit(bool systemEvent)
a0c1b7
 
a0c1b7
         if (Settings::rememberSessions()) { // remember open remote views for next startup
a0c1b7
             QStringList list;
a0c1b7
-            for (int i = 0; i < m_remoteViewList.count(); ++i) {
a0c1b7
-                kDebug(5010) << m_remoteViewList.at(i)->url();
a0c1b7
-                list.append(m_remoteViewList.at(i)->url().prettyUrl(KUrl::RemoveTrailingSlash));
a0c1b7
+            foreach (RemoteView *view, m_remoteViewMap.values()) {
a0c1b7
+                kDebug(5010) << view->url();
a0c1b7
+                list.append(view->url().prettyUrl(KUrl::RemoveTrailingSlash));
a0c1b7
             }
a0c1b7
             Settings::setOpenSessions(list);
a0c1b7
         }
a0c1b7
 
a0c1b7
         saveHostPrefs();
a0c1b7
 
a0c1b7
-        for (int i = 0; i < m_remoteViewList.count(); ++i) {
a0c1b7
-            m_remoteViewList.at(i)->startQuitting();
a0c1b7
+        foreach (RemoteView *view, m_remoteViewMap.values()) {
a0c1b7
+            view->startQuitting();
a0c1b7
         }
a0c1b7
 
a0c1b7
         Settings::self()->writeConfig();
a0c1b7
@@ -1029,9 +1028,9 @@ void MainWindow::saveProperties(KConfigG
a0c1b7
 
a0c1b7
 void MainWindow::saveHostPrefs()
a0c1b7
 {
a0c1b7
-    for (int i = 0; i < m_remoteViewList.count(); ++i) {
a0c1b7
-        saveHostPrefs(m_remoteViewList.at(i));
a0c1b7
-        m_remoteViewList.at(i)->startQuitting();
a0c1b7
+    foreach (RemoteView *view, m_remoteViewMap.values()) {
a0c1b7
+        saveHostPrefs(view);
a0c1b7
+        view->startQuitting();
a0c1b7
     }
a0c1b7
 }
a0c1b7
 
a0c1b7
@@ -1172,9 +1171,9 @@ void MainWindow::newConnectionPage(bool
a0c1b7
     m_addressInput->setFocus();
a0c1b7
 }
a0c1b7
 
a0c1b7
-QList<RemoteView *> MainWindow::remoteViewList() const
a0c1b7
+QMap<QWidget *, RemoteView *> MainWindow::remoteViewList() const
a0c1b7
 {
a0c1b7
-    return m_remoteViewList;
a0c1b7
+    return m_remoteViewMap;
a0c1b7
 }
a0c1b7
 
a0c1b7
 QList<RemoteViewFactory *> MainWindow::remoteViewFactoriesList() const
a0c1b7
@@ -1182,9 +1181,13 @@ QList<RemoteViewFactory *> MainWindow::r
a0c1b7
     return m_remoteViewFactories.values();
a0c1b7
 }
a0c1b7
 
a0c1b7
-int MainWindow::currentRemoteView() const
a0c1b7
+RemoteView* MainWindow::currentRemoteView() const
a0c1b7
 {
a0c1b7
-    return m_currentRemoteView;
a0c1b7
+    if (m_currentRemoteView >= 0) {
a0c1b7
+        return m_remoteViewMap.value(m_tabWidget->widget(m_currentRemoteView));
a0c1b7
+    } else {
a0c1b7
+        return 0;
a0c1b7
+    }
a0c1b7
 }
a0c1b7
 
a0c1b7
 void MainWindow::createDockWidget()
a0c1b7
--- kdenetwork-4.10.5/krdc/mainwindow.h.orig    2013-06-28 20:08:57.392483928 +0200
a0c1b7
+++ kdenetwork-4.10.5/krdc/mainwindow.h 2013-10-29 09:41:07.000000000 +0100
a0c1b7
@@ -60,9 +60,9 @@ public:
a0c1b7
     MainWindow(QWidget *parent = 0);
a0c1b7
     ~MainWindow();
a0c1b7
 
a0c1b7
-    QList<RemoteView *> remoteViewList() const;
a0c1b7
+    QMap<QWidget *, RemoteView *> remoteViewList() const;
a0c1b7
     QList<RemoteViewFactory *> remoteViewFactoriesList() const;
a0c1b7
-    int currentRemoteView() const;
a0c1b7
+    RemoteView* currentRemoteView() const;
a0c1b7
 
a0c1b7
 public slots:
a0c1b7
     void newConnection(const KUrl &newUrl = KUrl(), bool switchFullscreenWhenConnected = false, const QString &tabName = QString());
a0c1b7
@@ -125,7 +125,7 @@ private:
a0c1b7
 
a0c1b7
     BookmarkManager *m_bookmarkManager;
a0c1b7
 
a0c1b7
-    QList<RemoteView *> m_remoteViewList;
a0c1b7
+    QMap<QWidget *, RemoteView *> m_remoteViewMap;
a0c1b7
     QMap<int, RemoteViewFactory *> m_remoteViewFactories;
a0c1b7
 
a0c1b7
     int m_currentRemoteView;
a0c1b7
--- kdenetwork-4.10.5/krdc/bookmarkmanager.cpp.orig     2013-06-28 20:08:57.370483046 +0200
a0c1b7
+++ kdenetwork-4.10.5/krdc/bookmarkmanager.cpp  2013-10-29 09:41:07.000000000 +0100
a0c1b7
@@ -114,8 +114,9 @@ bool BookmarkManager::editBookmarkEntry(
a0c1b7
 
a0c1b7
 QString BookmarkManager::currentUrl() const
a0c1b7
 {
a0c1b7
-    if (m_mainWindow->currentRemoteView() >= 0)
a0c1b7
-        return urlForView(m_mainWindow->remoteViewList().at(m_mainWindow->currentRemoteView()));
a0c1b7
+    RemoteView *view = m_mainWindow->currentRemoteView();
a0c1b7
+    if (view)
a0c1b7
+        return urlForView(view);
a0c1b7
     else
a0c1b7
         return QString();
a0c1b7
 }
a0c1b7
@@ -146,10 +147,10 @@ QList<QPair<QString, QString> > Bookmark
a0c1b7
 {
a0c1b7
     QList<QPair<QString, QString> > list;
a0c1b7
 
a0c1b7
-    QListIterator<RemoteView *> iter(m_mainWindow->remoteViewList());
a0c1b7
+    QMapIterator<QWidget *, RemoteView *> iter(m_mainWindow->remoteViewList());
a0c1b7
 
a0c1b7
     while (iter.hasNext()) {
a0c1b7
-        RemoteView *next = iter.next();
a0c1b7
+        RemoteView *next = iter.next().value();
a0c1b7
         const QString url = next->url().prettyUrl(KUrl::RemoveTrailingSlash);
a0c1b7
         list << QPair<QString, QString>(url, url);
a0c1b7
     }