]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Merge branch 'Applications/18.12'
authorElvis Angelaccio <elvis.angelaccio@kde.org>
Tue, 4 Dec 2018 21:04:41 +0000 (22:04 +0100)
committerElvis Angelaccio <elvis.angelaccio@kde.org>
Tue, 4 Dec 2018 21:04:41 +0000 (22:04 +0100)
21 files changed:
CMakeLists.txt
src/CMakeLists.txt
src/dolphincontextmenu.cpp
src/kitemviews/kfileitemmodel.cpp
src/kitemviews/kfileitemmodel.h
src/kitemviews/kitemlistcontroller.cpp
src/kitemviews/kitemlistcontroller.h
src/kitemviews/kitemmodelbase.cpp
src/kitemviews/kitemmodelbase.h
src/kitemviews/private/kitemlistheaderwidget.cpp
src/org.kde.dolphin.appdata.xml
src/panels/information/informationpanel.cpp
src/panels/information/pixmapviewer.cpp
src/panels/places/placesitem.cpp
src/panels/places/placesitem.h
src/panels/places/placesitemeditdialog.cpp [deleted file]
src/panels/places/placesitemeditdialog.h [deleted file]
src/panels/places/placesitemmodel.cpp
src/panels/places/placesitemmodel.h
src/panels/places/placespanel.cpp
src/views/versioncontrol/versioncontrolobserver.cpp

index 126a365369bd0454e9538cd624077e34b4135d19..e551fcc66ba6a2de618ecc76b0e72bc9d1c0b2c0 100644 (file)
@@ -1,14 +1,14 @@
 cmake_minimum_required(VERSION 3.0)
 
 # KDE Application Version, managed by release script
-set (KDE_APPLICATIONS_VERSION_MAJOR "18")
-set (KDE_APPLICATIONS_VERSION_MINOR "11")
-set (KDE_APPLICATIONS_VERSION_MICRO "90")
+set (KDE_APPLICATIONS_VERSION_MAJOR "19")
+set (KDE_APPLICATIONS_VERSION_MINOR "03")
+set (KDE_APPLICATIONS_VERSION_MICRO "70")
 set (KDE_APPLICATIONS_VERSION "${KDE_APPLICATIONS_VERSION_MAJOR}.${KDE_APPLICATIONS_VERSION_MINOR}.${KDE_APPLICATIONS_VERSION_MICRO}")
 project(Dolphin VERSION ${KDE_APPLICATIONS_VERSION})
 
 set(QT_MIN_VERSION "5.8.0")
-set(KF5_MIN_VERSION "5.43.0")
+set(KF5_MIN_VERSION "5.53.0")
 
 # ECM setup
 find_package(ECM ${KF5_MIN_VERSION} CONFIG REQUIRED)
index d5206beb37eb19b2ffaf578863c3cf89529f2eec..7222dcde1d8d8e270916934b098431412270133d 100644 (file)
@@ -201,7 +201,6 @@ set(dolphinstatic_SRCS
     filterbar/filterbar.cpp
     panels/places/placespanel.cpp
     panels/places/placesitem.cpp
-    panels/places/placesitemeditdialog.cpp
     panels/places/placesitemlistgroupheader.cpp
     panels/places/placesitemlistwidget.cpp
     panels/places/placesitemmodel.cpp
index a521551e59a050e8015f9a40dd74dd9e7b59e864..9d7972b9fd18886f22206cf3bbbbf2ccc5071556 100644 (file)
@@ -421,26 +421,24 @@ void DolphinContextMenu::insertDefaultItemActions(const KFileItemListProperties&
     addAction(collection->action(KStandardAction::name(KStandardAction::RenameFile)));
 
     // Insert 'Move to Trash' and/or 'Delete'
-    if (properties.supportsDeleting()) {
-        const bool showDeleteAction = (KSharedConfig::openConfig()->group("KDE").readEntry("ShowDeleteCommand", false) ||
-                                       !properties.isLocal());
-        const bool showMoveToTrashAction = (properties.isLocal() &&
-                                            properties.supportsMoving());
-
-        if (showDeleteAction && showMoveToTrashAction) {
-            delete m_removeAction;
-            m_removeAction = nullptr;
-            addAction(m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::MoveToTrash)));
-            addAction(m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile)));
-        } else if (showDeleteAction && !showMoveToTrashAction) {
-            addAction(m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile)));
-        } else {
-            if (!m_removeAction) {
-                m_removeAction = new DolphinRemoveAction(this, m_mainWindow->actionCollection());
-            }
-            addAction(m_removeAction);
-            m_removeAction->update();
+    const bool showDeleteAction = (KSharedConfig::openConfig()->group("KDE").readEntry("ShowDeleteCommand", false) ||
+                                    !properties.isLocal());
+    const bool showMoveToTrashAction = (properties.isLocal() &&
+                                        properties.supportsMoving());
+
+    if (showDeleteAction && showMoveToTrashAction) {
+        delete m_removeAction;
+        m_removeAction = nullptr;
+        addAction(m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::MoveToTrash)));
+        addAction(m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile)));
+    } else if (showDeleteAction && !showMoveToTrashAction) {
+        addAction(m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile)));
+    } else {
+        if (!m_removeAction) {
+            m_removeAction = new DolphinRemoveAction(this, m_mainWindow->actionCollection());
         }
+        addAction(m_removeAction);
+        m_removeAction->update();
     }
 }
 
index fd0a88fb61a034b9001e6ace59cbf9819fa8126e..7c7abe9a7221758df4b6de41b7ca29f45147ad12 100644 (file)
@@ -304,6 +304,9 @@ QString KFileItemModel::roleDescription(const QByteArray& role) const
         int count = 0;
         const RoleInfoMap* map = rolesInfoMap(count);
         for (int i = 0; i < count; ++i) {
+           if (!map[i].roleTranslation) {
+                   continue;
+           }
             description.insert(map[i].role, i18nc(map[i].roleTranslationContext, map[i].roleTranslation));
         }
     }
@@ -786,7 +789,7 @@ void KFileItemModel::onGroupedSortingChanged(bool current)
     m_groups.clear();
 }
 
-void KFileItemModel::onSortRoleChanged(const QByteArray& current, const QByteArray& previous)
+void KFileItemModel::onSortRoleChanged(const QByteArray& current, const QByteArray& previous, bool resortItems)
 {
     Q_UNUSED(previous);
     m_sortRole = typeForRole(current);
@@ -797,7 +800,9 @@ void KFileItemModel::onSortRoleChanged(const QByteArray& current, const QByteArr
         setRoles(newRoles);
     }
 
-    resortAllItems();
+    if (resortItems) {
+        resortAllItems();
+    }
 }
 
 void KFileItemModel::onSortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous)
index a931a28cc35d5b07954f72931d7fb50e93e42767..3266a49f9246c92bf87201f7421654d715eb41a9 100644 (file)
@@ -260,7 +260,7 @@ signals:
 
 protected:
     void onGroupedSortingChanged(bool current) override;
-    void onSortRoleChanged(const QByteArray& current, const QByteArray& previous) override;
+    void onSortRoleChanged(const QByteArray& current, const QByteArray& previous, bool resortItems = true) override;
     void onSortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous) override;
 
 private slots:
index bde2bb26c14b1985faf5d015398ec2258240a191..d3dbeb35ccdd369b36abd3488728c64f8df006c3 100644 (file)
@@ -210,18 +210,6 @@ bool KItemListController::singleClickActivationEnforced() const
     return m_singleClickActivationEnforced;
 }
 
-bool KItemListController::showEvent(QShowEvent* event)
-{
-    Q_UNUSED(event);
-    return false;
-}
-
-bool KItemListController::hideEvent(QHideEvent* event)
-{
-    Q_UNUSED(event);
-    return false;
-}
-
 bool KItemListController::keyPressEvent(QKeyEvent* event)
 {
     int index = m_selectionManager->currentItem();
index 2f84a6c2c3f2580ffb9acd0d6e9d255453ce74af..b21e50735c59ab19ed6ee39f58cb7c5eacaeef74 100644 (file)
@@ -40,10 +40,8 @@ class QGraphicsSceneDragDropEvent;
 class QGraphicsSceneMouseEvent;
 class QGraphicsSceneResizeEvent;
 class QGraphicsSceneWheelEvent;
-class QHideEvent;
 class QInputMethodEvent;
 class QKeyEvent;
-class QShowEvent;
 class QTransform;
 
 /**
@@ -136,24 +134,7 @@ public:
     void setSingleClickActivationEnforced(bool singleClick);
     bool singleClickActivationEnforced() const;
 
-    virtual bool showEvent(QShowEvent* event);
-    virtual bool hideEvent(QHideEvent* event);
-    virtual bool keyPressEvent(QKeyEvent* event);
-    virtual bool inputMethodEvent(QInputMethodEvent* event);
-    virtual bool mousePressEvent(QGraphicsSceneMouseEvent* event, const QTransform& transform);
-    virtual bool mouseMoveEvent(QGraphicsSceneMouseEvent* event, const QTransform& transform);
-    virtual bool mouseReleaseEvent(QGraphicsSceneMouseEvent* event, const QTransform& transform);
-    virtual bool mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event, const QTransform& transform);
-    virtual bool dragEnterEvent(QGraphicsSceneDragDropEvent* event, const QTransform& transform);
-    virtual bool dragLeaveEvent(QGraphicsSceneDragDropEvent* event, const QTransform& transform);
-    virtual bool dragMoveEvent(QGraphicsSceneDragDropEvent* event, const QTransform& transform);
-    virtual bool dropEvent(QGraphicsSceneDragDropEvent* event, const QTransform& transform);
-    virtual bool hoverEnterEvent(QGraphicsSceneHoverEvent* event, const QTransform& transform);
-    virtual bool hoverMoveEvent(QGraphicsSceneHoverEvent* event, const QTransform& transform);
-    virtual bool hoverLeaveEvent(QGraphicsSceneHoverEvent* event, const QTransform& transform);
-    virtual bool wheelEvent(QGraphicsSceneWheelEvent* event, const QTransform& transform);
-    virtual bool resizeEvent(QGraphicsSceneResizeEvent* event, const QTransform& transform);
-    virtual bool processEvent(QEvent* event, const QTransform& transform);
+    bool processEvent(QEvent* event, const QTransform& transform);
 
 signals:
     /**
@@ -307,6 +288,22 @@ private:
      */
     void updateExtendedSelectionRegion();
 
+    bool keyPressEvent(QKeyEvent* event);
+    bool inputMethodEvent(QInputMethodEvent* event);
+    bool mousePressEvent(QGraphicsSceneMouseEvent* event, const QTransform& transform);
+    bool mouseMoveEvent(QGraphicsSceneMouseEvent* event, const QTransform& transform);
+    bool mouseReleaseEvent(QGraphicsSceneMouseEvent* event, const QTransform& transform);
+    bool mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event, const QTransform& transform);
+    bool dragEnterEvent(QGraphicsSceneDragDropEvent* event, const QTransform& transform);
+    bool dragLeaveEvent(QGraphicsSceneDragDropEvent* event, const QTransform& transform);
+    bool dragMoveEvent(QGraphicsSceneDragDropEvent* event, const QTransform& transform);
+    bool dropEvent(QGraphicsSceneDragDropEvent* event, const QTransform& transform);
+    bool hoverEnterEvent(QGraphicsSceneHoverEvent* event, const QTransform& transform);
+    bool hoverMoveEvent(QGraphicsSceneHoverEvent* event, const QTransform& transform);
+    bool hoverLeaveEvent(QGraphicsSceneHoverEvent* event, const QTransform& transform);
+    bool wheelEvent(QGraphicsSceneWheelEvent* event, const QTransform& transform);
+    bool resizeEvent(QGraphicsSceneResizeEvent* event, const QTransform& transform);
+
 private:
     bool m_singleClickActivationEnforced;
     bool m_selectionTogglePressed;
index 47db1f86d1d4286d719a09f0704c15666c311cbd..7f7877555d46a5a13d52bcacb666276f95b41bae 100644 (file)
@@ -63,12 +63,12 @@ bool KItemModelBase::groupedSorting() const
     return m_groupedSorting;
 }
 
-void KItemModelBase::setSortRole(const QByteArray& role)
+void KItemModelBase::setSortRole(const QByteArray& role, bool resortItems)
 {
     if (role != m_sortRole) {
         const QByteArray previous = m_sortRole;
         m_sortRole = role;
-        onSortRoleChanged(role, previous);
+        onSortRoleChanged(role, previous, resortItems);
         emit sortRoleChanged(role, previous);
     }
 }
@@ -152,10 +152,11 @@ void KItemModelBase::onGroupedSortingChanged(bool current)
     Q_UNUSED(current);
 }
 
-void KItemModelBase::onSortRoleChanged(const QByteArray& current, const QByteArray& previous)
+void KItemModelBase::onSortRoleChanged(const QByteArray& current, const QByteArray& previous, bool resortItems)
 {
     Q_UNUSED(current);
     Q_UNUSED(previous);
+    Q_UNUSED(resortItems);
 }
 
 void KItemModelBase::onSortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous)
index 257872f9ca91f1058299030e9116f0c683ab9e45..f1945de06c1df6cf47ee5eee47be80e6d5a95cc2 100644 (file)
@@ -85,8 +85,9 @@ public:
      * Sets the sort-role to \a role. The method KItemModelBase::onSortRoleChanged() will be
      * called so that model-implementations can react on the sort-role change. Afterwards the
      * signal sortRoleChanged() will be emitted.
+     * The implementation should resort only if \a resortItems is true.
      */
-    void setSortRole(const QByteArray& role);
+    void setSortRole(const QByteArray& role, bool resortItems = true);
     QByteArray sortRole() const;
 
     /**
@@ -266,8 +267,9 @@ protected:
      * Usually the most efficient way is to emit a
      * itemsRemoved() signal for all items, reorder the items internally and to emit a
      * itemsInserted() signal afterwards.
+     * The implementation should resort only if \a resortItems is true.
      */
-    virtual void onSortRoleChanged(const QByteArray& current, const QByteArray& previous);
+    virtual void onSortRoleChanged(const QByteArray& current, const QByteArray& previous, bool resortItems = true);
 
     /**
      * Is invoked if the sort order has been changed by KItemModelBase::setSortOrder(). Allows
index a994f69c8358267885a897929b9bca7605e4466e..a3f3f521fa4063beb9504a5fbd06893889e72d69 100644 (file)
@@ -220,10 +220,11 @@ void KItemListHeaderWidget::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
             // Change the sort role and reset to the ascending order
             const QByteArray previous = m_model->sortRole();
             const QByteArray current = m_columns[m_pressedRoleIndex];
-            m_model->setSortRole(current);
+            const bool resetSortOrder = m_model->sortOrder() == Qt::DescendingOrder;
+            m_model->setSortRole(current, !resetSortOrder);
             emit sortRoleChanged(current, previous);
 
-            if (m_model->sortOrder() == Qt::DescendingOrder) {
+            if (resetSortOrder) {
                 m_model->setSortOrder(Qt::AscendingOrder);
                 emit sortOrderChanged(Qt::AscendingOrder, Qt::DescendingOrder);
             }
index 6797c6e1bf4d9aba03e0e77d7e3e2b1e6f06f4a6..b3b029632a64b46701fe5d7b635956bbc7876921 100644 (file)
       <caption xml:lang="ca">Gestió de fitxers al Dolphin</caption>
       <caption xml:lang="ca-valencia">Gestió de fitxers al Dolphin</caption>
       <caption xml:lang="de">Dateiverwaltung mit Dolphin</caption>
+      <caption xml:lang="el">Διαχείριση αρχείων στο Dolphin</caption>
       <caption xml:lang="en-GB">File management in Dolphin</caption>
       <caption xml:lang="es">Gestión de archivos en Dolphin</caption>
       <caption xml:lang="fi">Tiedostonhallinta Dolphinissa</caption>
       <caption xml:lang="pt">Gestão de ficheiros no Dolphin</caption>
       <caption xml:lang="pt-BR">Gerenciamento de arquivos no Dolphin</caption>
       <caption xml:lang="ru">Управление файлами</caption>
+      <caption xml:lang="sk">Správa súborov v Dolphin</caption>
       <caption xml:lang="sv">Filhantering i Dolphin</caption>
       <caption xml:lang="uk">Керування файлами у Dolphin</caption>
       <caption xml:lang="x-test">xxFile management in Dolphinxx</caption>
+      <caption xml:lang="zh-CN">在 Dolphin 中管理文件</caption>
       <caption xml:lang="zh-TW">在 Dolphin 管理檔案</caption>
       <image>https://kde.org/images/screenshots/dolphin.png</image>
     </screenshot>
index 042849b2511baa90dae257cdea8e782cc830ab61..1ec2696e31a2d44761b588c4f396d6ed8a660dac 100644 (file)
@@ -91,7 +91,7 @@ void InformationPanel::requestDelayedItemInfo(const KFileItem& item)
     if (item.isNull()) {
         // The cursor is above the viewport. If files are selected,
         // show information regarding the selection.
-        if (m_selection.size() > 0) {
+        if (!m_selection.isEmpty()) {
             m_fileItem = KFileItem();
             m_infoTimer->start();
         }
index 24a6295696610a886e56339fee5f43538e5efe10..5828a37ddb44261145e600dba8f14f9757d7394c 100644 (file)
@@ -112,7 +112,7 @@ void PixmapViewer::paintEvent(QPaintEvent* event)
 
 void PixmapViewer::checkPendingPixmaps()
 {
-    if (m_pendingPixmaps.count() > 0) {
+    if (!m_pendingPixmaps.isEmpty()) {
         QPixmap pixmap = m_pendingPixmaps.dequeue();
         m_oldPixmap = m_pixmap.isNull() ? pixmap : m_pixmap;
         m_pixmap = pixmap;
index 9f9041bfa72236134c661b24ebf80085dd15cce7..3d3645ea2fa706732c301a63d9f77d16b70f43e8 100644 (file)
@@ -1,5 +1,6 @@
 /***************************************************************************
  *   Copyright (C) 2012 by Peter Penz <peter.penz19@gmail.com>             *
+ *   Copyright (C) 2018 by Elvis Angelaccio <elvis.angelaccio@kde.org>     *
  *                                                                         *
  *   Based on KFilePlacesItem from kdelibs:                                *
  *   Copyright (C) 2007 Kevin Ottens <ervin@kde.org>                       *
@@ -80,6 +81,16 @@ QString PlacesItem::udi() const
     return dataValue("udi").toString();
 }
 
+void PlacesItem::setApplicationName(const QString &applicationName)
+{
+    setDataValue("applicationName", applicationName);
+}
+
+QString PlacesItem::applicationName() const
+{
+    return dataValue("applicationName").toString();
+}
+
 void PlacesItem::setHidden(bool hidden)
 {
     setDataValue("isHidden", hidden);
@@ -247,6 +258,8 @@ void PlacesItem::updateBookmarkForRole(const QByteArray& role)
         m_bookmark.setUrl(url());
     } else if (role == "udi") {
         m_bookmark.setMetaDataItem(QStringLiteral("UDI"), udi());
+    } else if (role == "applicationName") {
+        m_bookmark.setMetaDataItem(QStringLiteral("OnlyInApp"), applicationName());
     } else if (role == "isSystemItem") {
         m_bookmark.setMetaDataItem(QStringLiteral("isSystemItem"), isSystemItem() ? QStringLiteral("true") : QStringLiteral("false"));
     } else if (role == "isHidden") {
index 1677cca19a487a35f7745c8aeb941c24a553b82a..eccd297fa4bc6e2fbe5595471291e747a3cca215 100644 (file)
@@ -52,6 +52,9 @@ public:
     void setUdi(const QString& udi);
     QString udi() const;
 
+    void setApplicationName(const QString& applicationName);
+    QString applicationName() const;
+
     void setHidden(bool hidden);
     bool isHidden() const;
 
diff --git a/src/panels/places/placesitemeditdialog.cpp b/src/panels/places/placesitemeditdialog.cpp
deleted file mode 100644 (file)
index dfb5dda..0000000
+++ /dev/null
@@ -1,174 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2012 by Peter Penz <peter.penz19@gmail.com>             *
- *                                                                         *
- *   Based on KFilePlaceEditDialog from kdelibs:                           *
- *   Copyright (C) 2001,2002,2003 Carsten Pfeiffer <pfeiffer@kde.org>      *
- *   Copyright (C) 2007 Kevin Ottens <ervin@kde.org>                       *                                                                         *
- *                                                                         *
- *   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            *
- ***************************************************************************/
-
-#include "placesitemeditdialog.h"
-
-#include "dolphindebug.h"
-
-#include <KAboutData>
-#include <KFile>
-#include <KIconButton>
-#include <KLocalizedString>
-#include <KUrlRequester>
-
-#include <QCheckBox>
-#include <QDialogButtonBox>
-#include <QEvent>
-#include <QFormLayout>
-#include <QLineEdit>
-#include <QMimeDatabase>
-
-PlacesItemEditDialog::PlacesItemEditDialog(QWidget* parent) :
-    QDialog(parent),
-    m_icon(),
-    m_text(),
-    m_url(),
-    m_allowGlobal(false),
-    m_urlEdit(nullptr),
-    m_textEdit(nullptr),
-    m_iconButton(nullptr),
-    m_appLocal(nullptr),
-    m_buttonBox(nullptr)
-{
-}
-
-void PlacesItemEditDialog::setIcon(const QString& icon)
-{
-    m_icon = icon;
-}
-
-QString PlacesItemEditDialog::icon() const
-{
-    return m_iconButton ? m_iconButton->icon() : m_icon;
-}
-
-void PlacesItemEditDialog::setText(const QString& text)
-{
-    m_text = text;
-}
-
-QString PlacesItemEditDialog::text() const
-{
-    QString text = m_textEdit->text();
-    if (text.isEmpty()) {
-        const QUrl url = m_urlEdit->url();
-        text = url.fileName().isEmpty() ? url.toDisplayString(QUrl::PreferLocalFile) : url.fileName();
-    }
-    return text;
-}
-
-void PlacesItemEditDialog::setUrl(const QUrl& url)
-{
-    m_url = url;
-}
-
-QUrl PlacesItemEditDialog::url() const
-{
-    return m_urlEdit->url();
-}
-
-void PlacesItemEditDialog::setAllowGlobal(bool allow)
-{
-    m_allowGlobal = allow;
-}
-
-bool PlacesItemEditDialog::allowGlobal() const
-{
-    return m_allowGlobal;
-}
-
-bool PlacesItemEditDialog::event(QEvent* event)
-{
-    if (event->type() == QEvent::Polish) {
-        initialize();
-    }
-    return QWidget::event(event);
-}
-
-void PlacesItemEditDialog::slotUrlChanged(const QString& text)
-{
-    m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!text.isEmpty());
-}
-
-PlacesItemEditDialog::~PlacesItemEditDialog()
-{
-}
-
-void PlacesItemEditDialog::initialize()
-{
-    m_buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel, this);
-    connect(m_buttonBox, &QDialogButtonBox::accepted, this, &PlacesItemEditDialog::accept);
-    connect(m_buttonBox, &QDialogButtonBox::rejected, this, &PlacesItemEditDialog::reject);
-    setModal(true);
-
-    QVBoxLayout *mainLayout = new QVBoxLayout;
-    setLayout(mainLayout);
-    QWidget* mainWidget = new QWidget(this);
-    mainLayout->addWidget(mainWidget);
-    mainLayout->addWidget(m_buttonBox);
-
-    QVBoxLayout* vBox = new QVBoxLayout(mainWidget);
-
-    QFormLayout* formLayout = new QFormLayout();
-    vBox->addLayout( formLayout );
-
-    m_textEdit = new QLineEdit(mainWidget);
-    formLayout->addRow(i18nc("@label", "Label:"), m_textEdit);
-    m_textEdit->setText(m_text);
-    m_textEdit->setPlaceholderText(i18n("Enter descriptive label here"));
-
-    m_urlEdit = new KUrlRequester(m_url, mainWidget);
-    m_urlEdit->setMode(KFile::Directory);
-    formLayout->addRow(i18nc("@label", "Location:"), m_urlEdit);
-    // Provide room for at least 40 chars (average char width is half of height)
-    m_urlEdit->setMinimumWidth(m_urlEdit->fontMetrics().height() * (40 / 2));
-    connect(m_urlEdit, &KUrlRequester::textChanged, this, &PlacesItemEditDialog::slotUrlChanged);
-
-    if (m_url.scheme() != QLatin1String("trash")) {
-        m_iconButton = new KIconButton(mainWidget);
-        formLayout->addRow(i18nc("@label", "Choose an icon:"), m_iconButton);
-        m_iconButton->setIconSize(IconSize(KIconLoader::Desktop));
-        m_iconButton->setIconType(KIconLoader::NoGroup, KIconLoader::Place);
-        if (m_icon.isEmpty()) {
-            QMimeDatabase db;
-            m_iconButton->setIcon(db.mimeTypeForUrl(m_url).iconName());
-        } else {
-            m_iconButton->setIcon(m_icon);
-        }
-    }
-
-    if (m_allowGlobal) {
-        const QString appName = KAboutData::applicationData().displayName();
-        m_appLocal = new QCheckBox( i18n("&Only show when using this application (%1)",  appName ), mainWidget );
-        m_appLocal->setChecked(false);
-        vBox->addWidget(m_appLocal);
-    }
-
-    if (m_text.isEmpty()) {
-        m_urlEdit->setFocus();
-    } else {
-        m_textEdit->setFocus();
-    }
-
-}
-
diff --git a/src/panels/places/placesitemeditdialog.h b/src/panels/places/placesitemeditdialog.h
deleted file mode 100644 (file)
index 73104a1..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2012 by Peter Penz <peter.penz19@gmail.com>             *
- *                                                                         *
- *   Based on KFilePlaceEditDialog from kdelibs:                           *
- *   Copyright (C) 2001,2002,2003 Carsten Pfeiffer <pfeiffer@kde.org>      *
- *   Copyright (C) 2007 Kevin Ottens <ervin@kde.org>                       *                                                                         *
- *                                                                         *
- *   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            *
- ***************************************************************************/
-
-#ifndef PLACESITEMEDITDIALOG_H
-#define PLACESITEMEDITDIALOG_H
-
-#include <QDialog>
-#include <QUrl>
-
-class KIconButton;
-class KUrlRequester;
-class QLineEdit;
-class QCheckBox;
-class QDialogButtonBox;
-
-class PlacesItemEditDialog: public QDialog
-{
-    Q_OBJECT
-
-public:
-    explicit PlacesItemEditDialog(QWidget* parent = nullptr);
-    ~PlacesItemEditDialog() override;
-
-    void setIcon(const QString& icon);
-    QString icon() const;
-
-    void setText(const QString& text);
-    QString text() const;
-
-    void setUrl(const QUrl& url);
-    QUrl url() const;
-
-    void setAllowGlobal(bool allow);
-    bool allowGlobal() const;
-
-protected:
-    bool event(QEvent* event) override;
-
-private slots:
-    void slotUrlChanged(const QString& text);
-
-private:
-    void initialize();
-
-private:
-    QString m_icon;
-    QString m_text;
-    QUrl m_url;
-    bool m_allowGlobal;
-
-    KUrlRequester* m_urlEdit;
-    QLineEdit* m_textEdit;
-    KIconButton* m_iconButton;
-    QCheckBox* m_appLocal;
-    QDialogButtonBox *m_buttonBox;
-};
-
-#endif
index 66bdbd57aa881f592bf75c2e1dd5138b44b00277..7513a25d522309db65de2a823f7777a3f386012a 100644 (file)
@@ -78,12 +78,14 @@ PlacesItemModel::~PlacesItemModel()
 {
 }
 
-void PlacesItemModel::createPlacesItem(const QString& text,
-                                       const QUrl& url,
-                                       const QString& iconName,
-                                       int after)
+void PlacesItemModel::createPlacesItem(const QString &text, const QUrl &url, const QString &iconName, const QString &appName)
 {
-    m_sourceModel->addPlace(text, url, iconName, {}, mapToSource(after));
+    createPlacesItem(text, url, iconName, appName, -1);
+}
+
+void PlacesItemModel::createPlacesItem(const QString &text, const QUrl &url, const QString &iconName, const QString &appName, int after)
+{
+    m_sourceModel->addPlace(text, url, iconName, appName, mapToSource(after));
 }
 
 PlacesItem* PlacesItemModel::placesItem(int index) const
@@ -369,7 +371,7 @@ void PlacesItemModel::dropMimeDataBefore(int index, const QMimeData* mimeData)
                 continue;
             }
 
-            createPlacesItem(text, url, KIO::iconNameForUrl(url), qMax(0, index - 1));
+            createPlacesItem(text, url, KIO::iconNameForUrl(url), {}, qMax(0, index - 1));
         }
     }
     // will save bookmark alteration and fix sort if that is broken by the drag/drop operation
index 58d0d55b2b6dab9ab47b3798e233fc75d43a5292..dde3f3d7b5239154a67aa2bcc3a1291824449f06 100644 (file)
@@ -52,10 +52,8 @@ public:
      * @brief Create a new place entry in the bookmark file
      * and add it to the model
      */
-    void createPlacesItem(const QString& text,
-                          const QUrl& url,
-                          const QString& iconName = QString(),
-                          int after = -1);
+    void createPlacesItem(const QString& text, const QUrl& url, const QString& iconName = {}, const QString& appName = {});
+    void createPlacesItem(const QString& text, const QUrl& url, const QString& iconName, const QString& appName, int after);
 
     PlacesItem* placesItem(int index) const;
 
index 1a8b0ecd48f286ee74a8f384b09b0a471ea61f8d..93fba716870312ca8049c3cec615d004ff2bd2b8 100644 (file)
@@ -30,7 +30,6 @@
 #include "kitemviews/kitemlistselectionmanager.h"
 #include "kitemviews/kstandarditem.h"
 #include "placesitem.h"
-#include "placesitemeditdialog.h"
 #include "placesitemlistgroupheader.h"
 #include "placesitemlistwidget.h"
 #include "placesitemmodel.h"
@@ -38,6 +37,7 @@
 #include "trash/dolphintrash.h"
 #include "views/draganddrophelper.h"
 
+#include <KFilePlaceEditDialog>
 #include <KFilePlacesModel>
 #include <KIO/DropJob>
 #include <KIO/EmptyTrashJob>
@@ -474,13 +474,12 @@ void PlacesPanel::addEntry()
 {
     const int index = m_controller->selectionManager()->currentItem();
     const QUrl url = m_model->data(index).value("url").toUrl();
+    const QString text = url.fileName().isEmpty() ? url.toDisplayString(QUrl::PreferLocalFile) : url.fileName();
 
-    QPointer<PlacesItemEditDialog> dialog = new PlacesItemEditDialog(this);
-    dialog->setWindowTitle(i18nc("@title:window", "Add Places Entry"));
-    dialog->setAllowGlobal(true);
-    dialog->setUrl(url);
+    QPointer<KFilePlaceEditDialog> dialog = new KFilePlaceEditDialog(true, url, text, QString(), true, false, KIconLoader::SizeMedium, this);
     if (dialog->exec() == QDialog::Accepted) {
-        m_model->createPlacesItem(dialog->text(), dialog->url(), dialog->icon());
+        const QString appName = dialog->applicationLocal() ? QCoreApplication::applicationName() : QString();
+        m_model->createPlacesItem(dialog->label(), dialog->url(), dialog->icon(), appName);
     }
 
     delete dialog;
@@ -489,17 +488,17 @@ void PlacesPanel::addEntry()
 void PlacesPanel::editEntry(int index)
 {
     QHash<QByteArray, QVariant> data = m_model->data(index);
+    const QUrl url = data.value("url").toUrl();
+    const QString text = data.value("text").toString();
+    const bool applicationLocal = !data.value("applicationName").toString().isEmpty();
 
-    QPointer<PlacesItemEditDialog> dialog = new PlacesItemEditDialog(this);
-    dialog->setWindowTitle(i18nc("@title:window", "Edit Places Entry"));
-    dialog->setIcon(data.value("iconName").toString());
-    dialog->setText(data.value("text").toString());
-    dialog->setUrl(data.value("url").toUrl());
-    dialog->setAllowGlobal(true);
+    QPointer<KFilePlaceEditDialog> dialog = new KFilePlaceEditDialog(true, url, text, QString(), true, applicationLocal, KIconLoader::SizeMedium, this);
     if (dialog->exec() == QDialog::Accepted) {
         PlacesItem* oldItem = m_model->placesItem(index);
         if (oldItem) {
-            oldItem->setText(dialog->text());
+            const QString appName = dialog->applicationLocal() ? QCoreApplication::applicationName() : QString();
+            oldItem->setApplicationName(appName);
+            oldItem->setText(dialog->label());
             oldItem->setUrl(dialog->url());
             oldItem->setIcon(dialog->icon());
             m_model->refresh();
index 7295a245ae02bf6b8c07040c7a0aef876207a6d5..62f4cfd167b4268b1367fd93e80c767b81917398 100644 (file)
@@ -248,7 +248,7 @@ int VersionControlObserver::createItemStatesList(QMap<QString, QVector<ItemState
         }
     }
 
-    if (items.count() > 0) {
+    if (!items.isEmpty()) {
         const QUrl& url = items.first().first.url();
         itemStates.insert(url.adjusted(QUrl::RemoveFilename).path(), items);
     }