[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [konversation/1.6] src/viewer: Renable tab dragging.
From:       Eike Hein <hein () kde ! org>
Date:       2015-03-31 23:26:32
Message-ID: E1Yd5YG-0006Cx-RB () scm ! kde ! org
[Download RAW message or body]

Git commit dfc90609c1f96766b4deb3e016d72ad255b00a70 by Eike Hein.
Committed on 31/03/2015 at 23:24.
Pushed by hein into branch '1.6'.

Renable tab dragging.

Switching from the tab bar to the tree list will resort tabs
into tree topology again.

Just leaves DND for the tree now ...

CCBUG:341405

M  +138  -60   src/viewer/viewcontainer.cpp
M  +2    -0    src/viewer/viewcontainer.h

http://commits.kde.org/konversation/dfc90609c1f96766b4deb3e016d72ad255b00a70

diff --git a/src/viewer/viewcontainer.cpp b/src/viewer/viewcontainer.cpp
index 6bccd54..5c94073 100644
--- a/src/viewer/viewcontainer.cpp
+++ b/src/viewer/viewcontainer.cpp
@@ -218,7 +218,7 @@ void ViewContainer::setupTabWidget()
     vboxLayout->addWidget(m_queueTuner);
     m_queueTuner->hide();
 
-    m_tabWidget->setMovable(false); // FIXME KF5 Port: Tab DND is currently disabled \
because it doesn't implement nesting constraints. +    m_tabWidget->setMovable(true);
     m_tabWidget->tabBar()->setSelectionBehaviorOnRemove(QTabBar::SelectPreviousTab);
 
     m_vbox->hide();
@@ -239,6 +239,8 @@ void ViewContainer::setupTabWidget()
 
 void ViewContainer::setupViewTree()
 {
+    unclutterTabs();
+
     m_viewTree = new ViewTree(m_viewTreeSplitter);
     m_viewTree->setModel(this);
     m_viewTreeSplitter->insertWidget(0, m_viewTree);
@@ -1237,9 +1239,7 @@ void ViewContainer::toggleConnectOnStartup()
 
 void ViewContainer::addView(ChatWindow* view, const QString& label, bool \
weinitiated)  {
-    ChatWindow *tmp_ChatWindow;
-    int placement = m_tabWidget->count();
-    ChatWindow::WindowType wtype;
+    int placement = insertIndex(view);
     QIcon iconSet;
 
     if (Preferences::self()->closeButtons() && m_viewTree)
@@ -1250,6 +1250,108 @@ void ViewContainer::addView(ChatWindow* view, const QString& \
                label, bool weiniti
     connect(view, SIGNAL(clearStatusBarTempText()), this, \
                SIGNAL(clearStatusBarTempText()));
     connect(view, SIGNAL(closing(ChatWindow*)), this, \
SLOT(cleanupAfterClose(ChatWindow*)));  
+    switch (view->getType())
+    {
+        case ChatWindow::Channel:
+            if (Preferences::self()->tabNotificationsLeds())
+                iconSet = images->getMsgsLed(false);
+
+            break;
+
+        case ChatWindow::RawLog:
+            if (Preferences::self()->tabNotificationsLeds())
+                iconSet = images->getSystemLed(false);
+
+            break;
+
+        case ChatWindow::Query:
+            if (Preferences::self()->tabNotificationsLeds())
+                iconSet = images->getPrivateLed(false);
+
+            break;
+
+        case ChatWindow::DccChat:
+            if (Preferences::self()->tabNotificationsLeds())
+                iconSet = images->getMsgsLed(false);
+
+            break;
+
+        case ChatWindow::Status:
+            if (Preferences::self()->tabNotificationsLeds())
+                iconSet = images->getServerLed(false);
+
+            break;
+
+        case ChatWindow::ChannelList:
+            if (Preferences::self()->tabNotificationsLeds())
+                iconSet = images->getSystemLed(false);
+
+            break;
+
+        default:
+            if (Preferences::self()->tabNotificationsLeds())
+                iconSet = images->getSystemLed(false);
+            break;
+    }
+
+    if (view->isTopLevelView()) {
+        int diff = 0;
+
+        for (int i = 0; i < placement; ++i) {
+            if (!static_cast<ChatWindow*>(m_tabWidget->widget(i))->isTopLevelView()) \
{ +                ++diff;
+            }
+        }
+
+        beginInsertRows(QModelIndex(), placement - diff, placement - diff);
+    } else {
+        int statusViewIndex = \
m_tabWidget->indexOf(view->getServer()->getStatusView()); +        const QModelIndex \
idx = indexForView(view->getServer()->getStatusView()); +
+        if (m_viewTree) {
+            m_viewTree->setExpanded(idx, true);
+        }
+
+        beginInsertRows(idx, placement - statusViewIndex - 1, placement - \
statusViewIndex - 1); +    }
+
+    m_tabWidget->insertTab(placement, view, iconSet, QString(label).replace('&', \
"&&")); +
+    endInsertRows();
+
+    m_vbox->show();
+
+    // Check, if user was typing in old input line
+    bool doBringToFront=false;
+
+    if (Preferences::self()->focusNewQueries() && view->getType()==ChatWindow::Query \
&& !weinitiated) +        doBringToFront = true;
+
+    if (Preferences::self()->bringToFront() && view->getType()!=ChatWindow::RawLog)
+        doBringToFront = true;
+
+    // make sure that bring to front only works when the user wasn't typing \
something +    if (m_frontView && view->getType() != ChatWindow::UrlCatcher && \
view->getType() != ChatWindow::Konsole) +    {
+        if (!m_frontView->getTextInLine().isEmpty())
+            doBringToFront = false;
+    }
+
+    if (doBringToFront) showView(view);
+
+    updateViewActions(m_tabWidget->currentIndex());
+
+    if (m_viewTree && m_tabWidget->count() == 1) {
+        setViewTreeShown(true);
+    }
+}
+
+int ViewContainer::insertIndex(ChatWindow* view)
+{
+    int placement = m_tabWidget->count();
+    ChatWindow::WindowType wtype;
+    ChatWindow *tmp_ChatWindow;
+
     // Please be careful about changing any of the grouping behavior in here,
     // because it needs to match up with the sorting behavior of the tree list,
     // otherwise they may become out of sync, wreaking havoc with the move
@@ -1258,9 +1360,6 @@ void ViewContainer::addView(ChatWindow* view, const QString& \
label, bool weiniti  switch (view->getType())
     {
         case ChatWindow::Channel:
-            if (Preferences::self()->tabNotificationsLeds())
-                iconSet = images->getMsgsLed(false);
-
             for (int sindex = 0; sindex < m_tabWidget->count(); sindex++)
             {
                 tmp_ChatWindow = static_cast<ChatWindow \
*>(m_tabWidget->widget(sindex)); @@ -1286,9 +1385,6 @@ void \
ViewContainer::addView(ChatWindow* view, const QString& label, bool weiniti  break;
 
         case ChatWindow::RawLog:
-            if (Preferences::self()->tabNotificationsLeds())
-                iconSet = images->getSystemLed(false);
-
             for (int sindex = 0; sindex < m_tabWidget->count(); sindex++)
             {
                 tmp_ChatWindow = static_cast<ChatWindow \
*>(m_tabWidget->widget(sindex)); @@ -1303,9 +1399,6 @@ void \
ViewContainer::addView(ChatWindow* view, const QString& label, bool weiniti  break;
 
         case ChatWindow::Query:
-            if (Preferences::self()->tabNotificationsLeds())
-                iconSet = images->getPrivateLed(false);
-
             for (int sindex = 0; sindex < m_tabWidget->count(); sindex++)
             {
                 tmp_ChatWindow = static_cast<ChatWindow \
*>(m_tabWidget->widget(sindex)); @@ -1331,9 +1424,6 @@ void \
ViewContainer::addView(ChatWindow* view, const QString& label, bool weiniti  break;
 
         case ChatWindow::DccChat:
-            if (Preferences::self()->tabNotificationsLeds())
-                iconSet = images->getMsgsLed(false);
-
             for (int sindex = 0; sindex < m_tabWidget->count(); sindex++)
             {
                 tmp_ChatWindow = \
static_cast<ChatWindow*>(m_tabWidget->widget(sindex)); @@ -1350,9 +1440,6 @@ void \
ViewContainer::addView(ChatWindow* view, const QString& label, bool weiniti  break;
 
         case ChatWindow::Status:
-            if (Preferences::self()->tabNotificationsLeds())
-                iconSet = images->getServerLed(false);
-
             if (m_viewTree)
             {
                 for (int sindex = 0; sindex < m_tabWidget->count(); sindex++)
@@ -1373,9 +1460,6 @@ void ViewContainer::addView(ChatWindow* view, const QString& \
label, bool weiniti  break;
 
         case ChatWindow::ChannelList:
-            if (Preferences::self()->tabNotificationsLeds())
-                iconSet = images->getSystemLed(false);
-
             for (int sindex = 0; sindex < m_tabWidget->count(); sindex++)
             {
                 tmp_ChatWindow = static_cast<ChatWindow \
*>(m_tabWidget->widget(sindex)); @@ -1387,61 +1471,55 @@ void \
ViewContainer::addView(ChatWindow* view, const QString& label, bool weiniti  break;
 
         default:
-            if (Preferences::self()->tabNotificationsLeds())
-                iconSet = images->getSystemLed(false);
             break;
     }
 
-    if (view->isTopLevelView()) {
-        int diff = 0;
-
-        for (int i = 0; i < placement; ++i) {
-            if (!static_cast<ChatWindow*>(m_tabWidget->widget(i))->isTopLevelView()) \
                {
-                ++diff;
-            }
-        }
+    return placement;
+}
 
-        beginInsertRows(QModelIndex(), placement - diff, placement - diff);
-    } else {
-        int statusViewIndex = \
                m_tabWidget->indexOf(view->getServer()->getStatusView());
-        const QModelIndex idx = indexForView(view->getServer()->getStatusView());
+void ViewContainer::unclutterTabs()
+{
+    if (!m_tabWidget || !m_tabWidget->count()) {
+        return;
+    }
 
-        if (m_viewTree) {
-            m_viewTree->setExpanded(idx, true);
-        }
+    emit beginResetModel();
 
-        beginInsertRows(idx, placement - statusViewIndex - 1, placement - \
                statusViewIndex - 1);
-    }
+    m_tabWidget->blockSignals(true);
 
-    m_tabWidget->insertTab(placement, view, iconSet, QString(label).replace('&', \
"&&")); +    QWidget* currentView = m_tabWidget->currentWidget();
 
-    endInsertRows();
+    QList<ChatWindow *> views;
 
-    m_vbox->show();
+    while (m_tabWidget->count()) {
+        views << static_cast<ChatWindow* >(m_tabWidget->widget(0));
+        m_tabWidget->removeTab(0);
+    }
 
-    // Check, if user was typing in old input line
-    bool doBringToFront=false;
+    foreach(ChatWindow *view, views) {
+        if (view->isTopLevelView()) {
+            m_tabWidget->insertTab(insertIndex(view), view, QIcon(), \
view->getName().replace('&', "&&")); +            views.removeAll(view);
+        }
+    }
 
-    if (Preferences::self()->focusNewQueries() && view->getType()==ChatWindow::Query \
                && !weinitiated)
-        doBringToFront = true;
+    foreach(ChatWindow *view, views) {
+        if (!view->isTopLevelView()) {
+            m_tabWidget->insertTab(insertIndex(view), view, QIcon(), \
view->getName().replace('&', "&&")); +        }
+    }
 
-    if (Preferences::self()->bringToFront() && view->getType()!=ChatWindow::RawLog)
-        doBringToFront = true;
+    updateViews();
 
-    // make sure that bring to front only works when the user wasn't typing \
                something
-    if (m_frontView && view->getType() != ChatWindow::UrlCatcher && view->getType() \
                != ChatWindow::Konsole)
-    {
-        if (!m_frontView->getTextInLine().isEmpty())
-            doBringToFront = false;
+    if (currentView) {
+        m_tabWidget->setCurrentWidget(currentView);
     }
 
-    if (doBringToFront) showView(view);
+    m_tabWidget->blockSignals(false);
 
-    updateViewActions(m_tabWidget->currentIndex());
+    emit endResetModel();
 
-    if (m_viewTree && m_tabWidget->count() == 1) {
-        setViewTreeShown(true);
-    }
+    emit viewSwitched(m_tabWidget->currentIndex());
 }
 
 void ViewContainer::viewSwitched(int newIndex)
diff --git a/src/viewer/viewcontainer.h b/src/viewer/viewcontainer.h
index 6e23686..c044f04 100644
--- a/src/viewer/viewcontainer.h
+++ b/src/viewer/viewcontainer.h
@@ -235,6 +235,8 @@ class ViewContainer : public QAbstractItemModel
         void updateTabWidgetAppearance();
 
         void addView(ChatWindow* view, const QString& label, bool weinitiated=true);
+        int insertIndex(ChatWindow* view);
+        void unclutterTabs();
 
         void updateViewActions(int index);
         void updateFrontView();


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic