]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphintabwidget.cpp
Cleanup unused colors. Use const. Use KColorScheme danger.
[dolphin.git] / src / dolphintabwidget.cpp
index 9fd6005673f405d3f743004f711543c61df2c83b..5ef39dac658ce3793ac9083d2f10a64a300dca38 100644 (file)
@@ -1,21 +1,8 @@
-/***************************************************************************
- * Copyright (C) 2014 by Emmanuel Pescosta <emmanuelpescosta099@gmail.com> *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
+/*
+ * SPDX-FileCopyrightText: 2014 Emmanuel Pescosta <emmanuelpescosta099@gmail.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
 
 #include "dolphintabwidget.h"
 
@@ -229,7 +216,7 @@ void DolphinTabWidget::openFiles(const QList<QUrl>& files, bool splitView)
     // for each directory. If the "split view" option is enabled, two
     // directories are shown inside one tab (see openDirectories()).
     QList<QUrl> dirs;
-    foreach (const QUrl& url, files) {
+    for (const QUrl& url : files) {
         const QUrl dir(url.adjusted(QUrl::RemoveFilename));
         if (!dirs.contains(dir)) {
             dirs.append(dir);
@@ -271,7 +258,7 @@ void DolphinTabWidget::closeTab(const int index)
     }
 
     DolphinTabPage* tabPage = tabPageAt(index);
-    emit rememberClosedTab(tabPage->activeViewContainer()->url(), tabPage->saveState());
+    Q_EMIT rememberClosedTab(tabPage->activeViewContainer()->url(), tabPage->saveState());
 
     removeTab(index);
     tabPage->deleteLater();
@@ -330,10 +317,10 @@ void DolphinTabWidget::copyToInactiveSplitView()
 
     if (tabPage->primaryViewActive()) {
         // copy from left panel to right
-        activeViewContainer->view()->copySelectedItemsToInactiveSplitView(activeViewContainer->view()->selectedItems(), tabPage->secondaryViewContainer()->url());
+        activeViewContainer->view()->copySelectedItems(activeViewContainer->view()->selectedItems(), tabPage->secondaryViewContainer()->url());
     } else {
         // copy from right panel to left
-        activeViewContainer->view()->copySelectedItemsToInactiveSplitView(activeViewContainer->view()->selectedItems(), tabPage->primaryViewContainer()->url());
+        activeViewContainer->view()->copySelectedItems(activeViewContainer->view()->selectedItems(), tabPage->primaryViewContainer()->url());
     }
 }
 
@@ -347,10 +334,10 @@ void DolphinTabWidget::moveToInactiveSplitView()
 
     if (tabPage->primaryViewActive()) {
         // move from left panel to right
-        activeViewContainer->view()->moveSelectedItemsToInactiveSplitView(activeViewContainer->view()->selectedItems(), tabPage->secondaryViewContainer()->url());
+        activeViewContainer->view()->moveSelectedItems(activeViewContainer->view()->selectedItems(), tabPage->secondaryViewContainer()->url());
     } else {
         // move from right panel to left
-        activeViewContainer->view()->moveSelectedItemsToInactiveSplitView(activeViewContainer->view()->selectedItems(), tabPage->primaryViewContainer()->url());
+        activeViewContainer->view()->moveSelectedItems(activeViewContainer->view()->selectedItems(), tabPage->primaryViewContainer()->url());
     }
 }
 
@@ -395,6 +382,7 @@ void DolphinTabWidget::tabUrlChanged(const QUrl& url)
     const int index = indexOf(qobject_cast<QWidget*>(sender()));
     if (index >= 0) {
         tabBar()->setTabText(index, tabName(tabPageAt(index)));
+        tabBar()->setTabToolTip(index, url.toDisplayString(QUrl::PreferLocalFile));
         if (tabBar()->isVisible()) {
             tabBar()->setTabIcon(index, QIcon::fromTheme(KIO::iconNameForUrl(url)));
         } else {
@@ -404,7 +392,7 @@ void DolphinTabWidget::tabUrlChanged(const QUrl& url)
 
         // Emit the currentUrlChanged signal if the url of the current tab has been changed.
         if (index == currentIndex()) {
-            emit currentUrlChanged(url);
+            Q_EMIT currentUrlChanged(url);
         }
     }
 }
@@ -417,8 +405,8 @@ void DolphinTabWidget::currentTabChanged(int index)
     }
     DolphinTabPage* tabPage = tabPageAt(index);
     DolphinViewContainer* viewContainer = tabPage->activeViewContainer();
-    emit activeViewChanged(viewContainer);
-    emit currentUrlChanged(viewContainer->url());
+    Q_EMIT activeViewChanged(viewContainer);
+    Q_EMIT currentUrlChanged(viewContainer->url());
     tabPage->setActive(true);
     m_lastViewedTab = index;
 }
@@ -430,15 +418,19 @@ void DolphinTabWidget::tabInserted(int index)
     if (count() > 1) {
         // Resolve all pending tab icons
         for (int i = 0; i < count(); ++i) {
+            const QUrl url = tabPageAt(i)->activeViewContainer()->url();
             if (tabBar()->tabIcon(i).isNull()) {
-                tabBar()->setTabIcon(i, QIcon::fromTheme(KIO::iconNameForUrl(tabPageAt(i)->activeViewContainer()->url())));
+                tabBar()->setTabIcon(i, QIcon::fromTheme(KIO::iconNameForUrl(url)));
+            }
+            if (tabBar()->tabToolTip(i).isEmpty()) {
+                tabBar()->setTabToolTip(index, url.toDisplayString(QUrl::PreferLocalFile));
             }
         }
 
         tabBar()->show();
     }
 
-    emit tabCountChanged(count());
+    Q_EMIT tabCountChanged(count());
 }
 
 void DolphinTabWidget::tabRemoved(int index)
@@ -451,7 +443,7 @@ void DolphinTabWidget::tabRemoved(int index)
         tabBar()->hide();
     }
 
-    emit tabCountChanged(count());
+    Q_EMIT tabCountChanged(count());
 }
 
 QString DolphinTabWidget::tabName(DolphinTabPage* tabPage) const