]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Merge branch 'Applications/17.12'
authorNathaniel Graham <pointedstick@zoho.com>
Wed, 31 Jan 2018 00:06:43 +0000 (17:06 -0700)
committerNathaniel Graham <pointedstick@zoho.com>
Wed, 31 Jan 2018 00:06:43 +0000 (17:06 -0700)
190 files changed:
.reviewboardrc [deleted file]
CMakeLists.txt
src/dolphincontextmenu.cpp
src/dolphincontextmenu.h
src/dolphindockwidget.cpp
src/dolphindockwidget.h
src/dolphinmainwindow.cpp
src/dolphinmainwindow.h
src/dolphinnewfilemenu.h
src/dolphinpart.cpp
src/dolphinpart.desktop
src/dolphinpart.h
src/dolphinpart_ext.h
src/dolphinrecenttabsmenu.cpp
src/dolphintabbar.h
src/dolphintabpage.h
src/dolphintabwidget.h
src/dolphinviewcontainer.cpp
src/dolphinviewcontainer.h
src/filterbar/filterbar.h
src/kitemviews/kfileitemlistview.cpp
src/kitemviews/kfileitemlistview.h
src/kitemviews/kfileitemlistwidget.cpp
src/kitemviews/kfileitemlistwidget.h
src/kitemviews/kfileitemmodel.cpp
src/kitemviews/kfileitemmodel.h
src/kitemviews/kfileitemmodelrolesupdater.cpp
src/kitemviews/kfileitemmodelrolesupdater.h
src/kitemviews/kitemlistcontainer.cpp
src/kitemviews/kitemlistcontainer.h
src/kitemviews/kitemlistcontroller.cpp
src/kitemviews/kitemlistcontroller.h
src/kitemviews/kitemlistgroupheader.cpp
src/kitemviews/kitemlistgroupheader.h
src/kitemviews/kitemlistheader.h
src/kitemviews/kitemlistselectionmanager.cpp
src/kitemviews/kitemlistselectionmanager.h
src/kitemviews/kitemlistview.cpp
src/kitemviews/kitemlistview.h
src/kitemviews/kitemlistviewaccessible.cpp
src/kitemviews/kitemlistviewaccessible.h
src/kitemviews/kitemlistwidget.cpp
src/kitemviews/kitemlistwidget.h
src/kitemviews/kitemmodelbase.cpp
src/kitemviews/kitemmodelbase.h
src/kitemviews/kstandarditem.cpp
src/kitemviews/kstandarditem.h
src/kitemviews/kstandarditemlistgroupheader.h
src/kitemviews/kstandarditemlistview.h
src/kitemviews/kstandarditemlistwidget.cpp
src/kitemviews/kstandarditemlistwidget.h
src/kitemviews/kstandarditemmodel.cpp
src/kitemviews/kstandarditemmodel.h
src/kitemviews/private/kbaloorolesprovider.cpp
src/kitemviews/private/kdirectorycontentscounter.cpp
src/kitemviews/private/kdirectorycontentscounter.h
src/kitemviews/private/kdirectorycontentscounterworker.cpp
src/kitemviews/private/kdirectorycontentscounterworker.h
src/kitemviews/private/kfileitemclipboard.cpp
src/kitemviews/private/kfileitemclipboard.h
src/kitemviews/private/kfileitemmodeldirlister.cpp
src/kitemviews/private/kfileitemmodeldirlister.h
src/kitemviews/private/kfileitemmodelfilter.cpp
src/kitemviews/private/kitemlistheaderwidget.cpp
src/kitemviews/private/kitemlistheaderwidget.h
src/kitemviews/private/kitemlistkeyboardsearchmanager.h
src/kitemviews/private/kitemlistroleeditor.h
src/kitemviews/private/kitemlistrubberband.h
src/kitemviews/private/kitemlistselectiontoggle.cpp
src/kitemviews/private/kitemlistselectiontoggle.h
src/kitemviews/private/kitemlistsizehintresolver.cpp
src/kitemviews/private/kitemlistsizehintresolver.h
src/kitemviews/private/kitemlistsmoothscroller.cpp
src/kitemviews/private/kitemlistsmoothscroller.h
src/kitemviews/private/kitemlistviewanimation.cpp
src/kitemviews/private/kitemlistviewanimation.h
src/kitemviews/private/kitemlistviewlayouter.cpp
src/kitemviews/private/kitemlistviewlayouter.h
src/panels/folders/foldersitemlistwidget.h
src/panels/folders/folderspanel.h
src/panels/folders/treeviewcontextmenu.h
src/panels/information/filemetadataconfigurationdialog.h
src/panels/information/informationpanel.cpp
src/panels/information/informationpanel.h
src/panels/information/informationpanelcontent.cpp
src/panels/information/informationpanelcontent.h
src/panels/information/phononwidget.cpp
src/panels/information/phononwidget.h
src/panels/information/pixmapviewer.h
src/panels/panel.h
src/panels/places/placesitem.cpp
src/panels/places/placesitem.h
src/panels/places/placesitemeditdialog.cpp
src/panels/places/placesitemeditdialog.h
src/panels/places/placesitemlistgroupheader.h
src/panels/places/placesitemlistwidget.cpp
src/panels/places/placesitemlistwidget.h
src/panels/places/placesitemmodel.cpp
src/panels/places/placesitemmodel.h
src/panels/places/placesitemsignalhandler.h
src/panels/places/placespanel.cpp
src/panels/places/placespanel.h
src/panels/terminal/terminalpanel.cpp
src/panels/terminal/terminalpanel.h
src/search/dolphinfacetswidget.h
src/search/dolphinsearchbox.cpp
src/search/dolphinsearchbox.h
src/settings/additionalinfodialog.cpp
src/settings/additionalinfodialog.h
src/settings/applyviewpropsjob.cpp
src/settings/applyviewpropsjob.h
src/settings/dolphin_directoryviewpropertysettings.kcfg
src/settings/dolphinsettingsdialog.h
src/settings/general/behaviorsettingspage.h
src/settings/general/configurepreviewplugindialog.h
src/settings/general/confirmationssettingspage.cpp
src/settings/general/confirmationssettingspage.h
src/settings/general/generalsettingspage.cpp
src/settings/general/generalsettingspage.h
src/settings/general/previewssettingspage.cpp
src/settings/general/previewssettingspage.h
src/settings/general/statusbarsettingspage.h
src/settings/kcm/kcmdolphingeneral.cpp
src/settings/kcm/kcmdolphingeneral.h
src/settings/kcm/kcmdolphinnavigation.cpp
src/settings/kcm/kcmdolphinnavigation.h
src/settings/kcm/kcmdolphinservices.cpp
src/settings/kcm/kcmdolphinservices.h
src/settings/kcm/kcmdolphinviewmodes.cpp
src/settings/kcm/kcmdolphinviewmodes.h
src/settings/navigation/navigationsettingspage.cpp
src/settings/navigation/navigationsettingspage.h
src/settings/serviceitemdelegate.h
src/settings/servicemodel.h
src/settings/services/servicessettingspage.cpp
src/settings/services/servicessettingspage.h
src/settings/settingspagebase.h
src/settings/startup/startupsettingspage.h
src/settings/trash/trashsettingspage.h
src/settings/viewmodes/dolphinfontrequester.cpp
src/settings/viewmodes/dolphinfontrequester.h
src/settings/viewmodes/viewsettingspage.cpp
src/settings/viewmodes/viewsettingspage.h
src/settings/viewmodes/viewsettingstab.cpp
src/settings/viewmodes/viewsettingstab.h
src/settings/viewpropertiesdialog.cpp
src/settings/viewpropertiesdialog.h
src/settings/viewpropsprogressinfo.cpp
src/settings/viewpropsprogressinfo.h
src/statusbar/dolphinstatusbar.cpp
src/statusbar/dolphinstatusbar.h
src/statusbar/mountpointobserver.h
src/statusbar/mountpointobservercache.cpp
src/statusbar/mountpointobservercache.h
src/statusbar/spaceinfoobserver.cpp
src/statusbar/spaceinfoobserver.h
src/statusbar/statusbarspaceinfo.cpp
src/statusbar/statusbarspaceinfo.h
src/tests/CMakeLists.txt
src/tests/data/fakecomputer.xml [new file with mode: 0644]
src/tests/kfileitemlistviewtest.cpp
src/tests/kfileitemmodeltest.cpp
src/tests/kitemlistcontrollertest.cpp
src/tests/kitemlistselectionmanagertest.cpp
src/tests/kstandarditemmodeltest.cpp
src/tests/placesitemmodeltest.cpp [new file with mode: 0644]
src/tests/viewpropertiestest.cpp
src/views/dolphinfileitemlistwidget.h
src/views/dolphinitemlistview.cpp
src/views/dolphinitemlistview.h
src/views/dolphinnewfilemenuobserver.cpp
src/views/dolphinnewfilemenuobserver.h
src/views/dolphinremoteencoding.h
src/views/dolphinview.cpp
src/views/dolphinview.h
src/views/dolphinviewactionhandler.cpp
src/views/draganddrophelper.cpp
src/views/renamedialog.cpp
src/views/renamedialog.h
src/views/tooltips/dolphinfilemetadatawidget.cpp
src/views/tooltips/dolphinfilemetadatawidget.h
src/views/tooltips/tooltipmanager.cpp
src/views/tooltips/tooltipmanager.h
src/views/versioncontrol/kversioncontrolplugin.h
src/views/versioncontrol/updateitemstatesthread.cpp
src/views/versioncontrol/updateitemstatesthread.h
src/views/versioncontrol/versioncontrolobserver.cpp
src/views/versioncontrol/versioncontrolobserver.h
src/views/viewmodecontroller.h
src/views/viewproperties.cpp

diff --git a/.reviewboardrc b/.reviewboardrc
deleted file mode 100644 (file)
index 1442486..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-# the whole file must be valid python code 
-# for detail documentation, see http://www.reviewboard.org/docs/manual/dev/users/tools/post-review/
-
-REVIEWBOARD_URL = "https://git.reviewboard.kde.org"
-TARGET_GROUPS = "dolphin"
-REPOSITORY = "dolphin"
-
-GUESS_FIELDS = True
-OPEN_BROWSER = True
index d45626ee699f8711465a4ad576aa65bda9adb887..a1dd08c50cd6774e97e417d59c056b695e6ed4e0 100644 (file)
@@ -1,14 +1,14 @@
 cmake_minimum_required(VERSION 3.0)
 
 # KDE Application Version, managed by release script
-set (KDE_APPLICATIONS_VERSION_MAJOR "17")
-set (KDE_APPLICATIONS_VERSION_MINOR "12")
-set (KDE_APPLICATIONS_VERSION_MICRO "1")
+set (KDE_APPLICATIONS_VERSION_MAJOR "18")
+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.5.0")
-set(KF5_MIN_VERSION "5.37.0")
+set(KF5_MIN_VERSION "5.43.0")
 set(ECM_MIN_VERSION "1.6.0")
 
 # ECM setup
index d4cf196b7cd05e3d7d5a5ff7919d534a6dec14b6..de40d7eaa0356df55495d295774ffc818ea548f5 100644 (file)
@@ -66,14 +66,14 @@ DolphinContextMenu::DolphinContextMenu(DolphinMainWindow* parent,
     m_mainWindow(parent),
     m_fileInfo(fileInfo),
     m_baseUrl(baseUrl),
-    m_baseFileItem(0),
+    m_baseFileItem(nullptr),
     m_selectedItems(),
     m_selectedItemsProperties(nullptr),
     m_context(NoContext),
     m_copyToMenu(parent),
     m_customActions(),
     m_command(None),
-    m_removeAction(0)
+    m_removeAction(nullptr)
 {
     // The context menu either accesses the URLs of the selected items
     // or the items itself. To increase the performance both lists are cached.
@@ -306,9 +306,7 @@ void DolphinContextMenu::openItemContextMenu()
             if (selectedUrl.isValid()) {
                 PlacesItemModel model;
                 const QString text = selectedUrl.fileName();
-                PlacesItem* item = model.createPlacesItem(text, selectedUrl, KIO::iconNameForUrl(selectedUrl));
-                model.appendItemToGroup(item);
-                model.saveBookmarks();
+                model.createPlacesItem(text, selectedUrl, KIO::iconNameForUrl(selectedUrl));
             }
         } else if (activatedAction == openParentAction) {
             m_command = OpenParentFolder;
@@ -337,7 +335,7 @@ void DolphinContextMenu::openViewportContextMenu()
     addAction(m_mainWindow->actionCollection()->action(QStringLiteral("new_tab")));
 
     // Insert 'Add to Places' entry if exactly one item is selected
-    QAction* addToPlacesAction = 0;
+    QAction* addToPlacesAction = nullptr;
     if (!placeExists(m_mainWindow->activeViewContainer()->url())) {
         addToPlacesAction = addAction(QIcon::fromTheme(QStringLiteral("bookmark-new")),
                                              i18nc("@action:inmenu Add current folder to places", "Add to Places"));
@@ -378,9 +376,7 @@ void DolphinContextMenu::openViewportContextMenu()
             } else {
                 icon = KIO::iconNameForUrl(url);
             }
-            PlacesItem* item = model.createPlacesItem(container->placesText(), url, icon);
-            model.appendItemToGroup(item);
-            model.saveBookmarks();
+            model.createPlacesItem(container->placesText(), url, icon);
         }
     }
 }
@@ -408,7 +404,7 @@ void DolphinContextMenu::insertDefaultItemActions(const KFileItemListProperties&
 
         if (showDeleteAction && showMoveToTrashAction) {
             delete m_removeAction;
-            m_removeAction = 0;
+            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) {
@@ -445,7 +441,7 @@ bool DolphinContextMenu::placeExists(const QUrl& url) const
 
 QAction* DolphinContextMenu::createPasteAction()
 {
-    QAction* action = 0;
+    QAction* action = nullptr;
     const bool isDir = !m_fileInfo.isNull() && m_fileInfo.isDir();
     if (isDir && (m_selectedItems.count() == 1)) {
         const QMimeData *mimeData = QApplication::clipboard()->mimeData();
index ea68244e1a7e978dca9edbaa569a33238d1ae685..558115fb045587fb0ffcc5f158d25f11812c4512 100644 (file)
@@ -74,7 +74,7 @@ public:
                        const KFileItem& fileInfo,
                        const QUrl& baseUrl);
 
-    virtual ~DolphinContextMenu();
+    ~DolphinContextMenu() override;
 
     void setCustomActions(const QList<QAction*>& actions);
 
@@ -89,8 +89,8 @@ public:
     Command open();
 
 protected:
-    virtual void keyPressEvent(QKeyEvent *ev) Q_DECL_OVERRIDE;
-    virtual void keyReleaseEvent(QKeyEvent *ev) Q_DECL_OVERRIDE;
+    void keyPressEvent(QKeyEvent *ev) override;
+    void keyReleaseEvent(QKeyEvent *ev) override;
 
 private:
     void openTrashContextMenu();
index c7beb1689b8c6ec8c1c86ba4aedf7f2a81ff6424..726338377daae192dd0f6bd70e47fd3344eefdaf 100644 (file)
@@ -36,15 +36,15 @@ class DolphinDockTitleBar : public QWidget
 
 public:
     explicit DolphinDockTitleBar(QWidget* parent = nullptr) : QWidget(parent) {}
-    virtual ~DolphinDockTitleBar() {}
+    ~DolphinDockTitleBar() override {}
 
-    QSize minimumSizeHint() const Q_DECL_OVERRIDE
+    QSize minimumSizeHint() const override
     {
         const int border = style()->pixelMetric(QStyle::PM_DockWidgetTitleBarButtonMargin);
         return QSize(border, border);
     }
 
-    QSize sizeHint() const Q_DECL_OVERRIDE
+    QSize sizeHint() const override
     {
         return minimumSizeHint();
     }
index 8f491295d1600986aff9f3bf79b7de6e1e0267d8..c4fcbf753b042a52ae915a89f2210e7a788b339d 100644 (file)
@@ -30,9 +30,9 @@ class DolphinDockWidget : public QDockWidget
     Q_OBJECT
 
 public:
-    explicit DolphinDockWidget(const QString& title, QWidget* parent = 0, Qt::WindowFlags flags = 0);
-    explicit DolphinDockWidget(QWidget* parent = 0, Qt::WindowFlags flags = 0);
-    virtual ~DolphinDockWidget();
+    explicit DolphinDockWidget(const QString& title, QWidget* parent = nullptr, Qt::WindowFlags flags = nullptr);
+    explicit DolphinDockWidget(QWidget* parent = nullptr, Qt::WindowFlags flags = nullptr);
+    ~DolphinDockWidget() override;
 
     /**
      * @param lock If \a lock is true, the title bar of the dock-widget will get hidden so
index 070d56aeb21ee1960234968432f553745de40f43..95b05785fbf2e5aa49b22c73cae64e498b28c6d2 100644 (file)
@@ -90,20 +90,20 @@ namespace {
 }
 
 DolphinMainWindow::DolphinMainWindow() :
-    KXmlGuiWindow(0),
-    m_newFileMenu(0),
-    m_tabWidget(0),
-    m_activeViewContainer(0),
-    m_actionHandler(0),
-    m_remoteEncoding(0),
+    KXmlGuiWindow(nullptr),
+    m_newFileMenu(nullptr),
+    m_tabWidget(nullptr),
+    m_activeViewContainer(nullptr),
+    m_actionHandler(nullptr),
+    m_remoteEncoding(nullptr),
     m_settingsDialog(),
-    m_controlButton(0),
-    m_updateToolBarTimer(0),
-    m_lastHandleUrlStatJob(0),
+    m_controlButton(nullptr),
+    m_updateToolBarTimer(nullptr),
+    m_lastHandleUrlStatJob(nullptr),
 #ifndef Q_OS_WIN
-    m_terminalPanel(0),
+    m_terminalPanel(nullptr),
 #endif
-    m_placesPanel(0),
+    m_placesPanel(nullptr),
     m_tearDownFromPlacesRequested(false)
 {
     Q_INIT_RESOURCE(dolphin);
@@ -629,6 +629,15 @@ void DolphinMainWindow::togglePanelLockState()
     GeneralSettings::setLockPanels(newLockState);
 }
 
+void DolphinMainWindow::slotTerminalPanelVisibilityChanged()
+{
+#ifndef Q_OS_WIN
+    if (m_terminalPanel->isHiddenInVisibleWindow()) {
+        m_activeViewContainer->view()->setFocus();
+    }
+#endif
+}
+
 void DolphinMainWindow::goBack()
 {
     KUrlNavigator* urlNavigator = m_activeViewContainer->urlNavigator();
@@ -751,7 +760,7 @@ void DolphinMainWindow::editSettings()
 void DolphinMainWindow::handleUrl(const QUrl& url)
 {
     delete m_lastHandleUrlStatJob;
-    m_lastHandleUrlStatJob = 0;
+    m_lastHandleUrlStatJob = nullptr;
 
     if (url.isLocalFile() && QFileInfo(url.toLocalFile()).isDir()) {
         activeViewContainer()->setUrl(url);
@@ -771,7 +780,7 @@ void DolphinMainWindow::handleUrl(const QUrl& url)
 
 void DolphinMainWindow::slotHandleUrlStatFinished(KJob* job)
 {
-    m_lastHandleUrlStatJob = 0;
+    m_lastHandleUrlStatJob = nullptr;
     const KIO::UDSEntry entry = static_cast<KIO::StatJob*>(job)->statResult();
     const QUrl url = static_cast<KIO::StatJob*>(job)->url();
     if (entry.isDir()) {
@@ -912,7 +921,7 @@ void DolphinMainWindow::updateToolBar()
 
 void DolphinMainWindow::slotControlButtonDeleted()
 {
-    m_controlButton = 0;
+    m_controlButton = nullptr;
     m_updateToolBarTimer->start();
 }
 
@@ -1001,6 +1010,16 @@ void DolphinMainWindow::setUrlAsCaption(const QUrl& url)
         fileName = '/';
     }
 
+    if (m_activeViewContainer->isSearchModeEnabled()) {
+        if(m_activeViewContainer->currentSearchText().isEmpty()){
+            setWindowTitle(i18n("Search"));
+        } else {
+            const auto searchText = i18n("Search for %1", m_activeViewContainer->currentSearchText());
+            setWindowTitle(searchText);
+        }
+        return;
+    }
+
     setWindowTitle(schemePrefix + fileName);
 }
 
@@ -1165,6 +1184,7 @@ void DolphinMainWindow::setupActions()
     compareFiles->setEnabled(false);
     connect(compareFiles, &QAction::triggered, this, &DolphinMainWindow::compareFiles);
 
+#ifndef Q_OS_WIN
     if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
         QAction* openTerminal = actionCollection()->addAction(QStringLiteral("open_terminal"));
         openTerminal->setText(i18nc("@action:inmenu Tools", "Open Terminal"));
@@ -1172,9 +1192,10 @@ void DolphinMainWindow::setupActions()
         actionCollection()->setDefaultShortcut(openTerminal, Qt::SHIFT | Qt::Key_F4);
         connect(openTerminal, &QAction::triggered, this, &DolphinMainWindow::openTerminal);
     }
+#endif
 
     // setup 'Settings' menu
-    KToggleAction* showMenuBar = KStandardAction::showMenubar(0, 0, actionCollection());
+    KToggleAction* showMenuBar = KStandardAction::showMenubar(nullptr, nullptr, actionCollection());
     connect(showMenuBar, &KToggleAction::triggered,                   // Fixes #286822
             this, &DolphinMainWindow::toggleShowMenuBar, Qt::QueuedConnection);
     KStandardAction::preferences(this, SLOT(editSettings()), actionCollection());
@@ -1286,6 +1307,8 @@ void DolphinMainWindow::setupDockWidgets()
         connect(m_terminalPanel, &TerminalPanel::changeUrl, this, &DolphinMainWindow::slotTerminalDirectoryChanged);
         connect(terminalDock, &DolphinDockWidget::visibilityChanged,
                 m_terminalPanel, &TerminalPanel::dockVisibilityChanged);
+        connect(terminalDock, &DolphinDockWidget::visibilityChanged,
+                this, &DolphinMainWindow::slotTerminalPanelVisibilityChanged);
 
         QAction* terminalAction = terminalDock->toggleViewAction();
         createPanelAction(QIcon::fromTheme(QStringLiteral("utilities-terminal")), Qt::Key_F4, terminalAction, QStringLiteral("show_terminal_panel"));
@@ -1435,10 +1458,10 @@ void DolphinMainWindow::createControlButton()
 void DolphinMainWindow::deleteControlButton()
 {
     delete m_controlButton;
-    m_controlButton = 0;
+    m_controlButton = nullptr;
 
     delete m_updateToolBarTimer;
-    m_updateToolBarTimer = 0;
+    m_updateToolBarTimer = nullptr;
 }
 
 bool DolphinMainWindow::addActionToMenu(QAction* action, QMenu* menu)
index c05fc34ad404ee2f37edb8cbdd0ead8305958ba7..01746169bd16de848e6e161fd48eff17e2fc19db 100644 (file)
@@ -64,7 +64,7 @@ class DolphinMainWindow: public KXmlGuiWindow
 
 public:
     DolphinMainWindow();
-    virtual ~DolphinMainWindow();
+    ~DolphinMainWindow() override;
 
     /**
      * Returns the currently active view.
@@ -152,16 +152,16 @@ signals:
 
 protected:
     /** @see QWidget::showEvent() */
-    virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
+    void showEvent(QShowEvent* event) override;
 
     /** @see QMainWindow::closeEvent() */
-    virtual void closeEvent(QCloseEvent* event) Q_DECL_OVERRIDE;
+    void closeEvent(QCloseEvent* event) override;
 
     /** @see KMainWindow::saveProperties() */
-    virtual void saveProperties(KConfigGroup& group) Q_DECL_OVERRIDE;
+    void saveProperties(KConfigGroup& group) override;
 
     /** @see KMainWindow::readProperties() */
-    virtual void readProperties(const KConfigGroup& group) Q_DECL_OVERRIDE;
+    void readProperties(const KConfigGroup& group) override;
 
 private slots:
     /**
@@ -261,6 +261,12 @@ private slots:
      */
     void togglePanelLockState();
 
+    /**
+     * Is invoked if the Terminal panel got visible/invisible and takes care
+     * that the active view has the focus if the Terminal panel is invisible.
+     */
+    void slotTerminalPanelVisibilityChanged();
+
     /** Goes back one step of the URL history. */
     void goBack();
 
@@ -499,8 +505,8 @@ private:
     {
     public:
         UndoUiInterface();
-        virtual ~UndoUiInterface();
-        virtual void jobError(KIO::Job* job) Q_DECL_OVERRIDE;
+        ~UndoUiInterface() override;
+        void jobError(KIO::Job* job) override;
     };
 
     KNewFileMenu* m_newFileMenu;
index 9f1cb55991f780058ed5add533161e35c3287f97..3505017e13ae86929c3d81ccc90ddf00293e9be5 100644 (file)
@@ -41,14 +41,14 @@ class DOLPHIN_EXPORT DolphinNewFileMenu : public KNewFileMenu
 
 public:
     DolphinNewFileMenu(KActionCollection* collection, QObject* parent);
-    virtual ~DolphinNewFileMenu();
+    ~DolphinNewFileMenu() override;
 
 signals:
     void errorMessage(const QString& error);
 
 protected slots:
     /** @see KNewFileMenu::slotResult() */
-    virtual void slotResult(KJob* job) Q_DECL_OVERRIDE;
+    void slotResult(KJob* job) override;
 };
 
 #endif
index b3b47304e1b211e32bca7424331e27575870f63b..6f8e20489ace4d37372706c35ac1022e5c77c4bc 100644 (file)
@@ -60,8 +60,8 @@ K_PLUGIN_FACTORY(DolphinPartFactory, registerPlugin<DolphinPart>();)
 
 DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantList& args)
     : KParts::ReadOnlyPart(parent)
-      ,m_openTerminalAction(0)
-      ,m_removeAction(0)
+      ,m_openTerminalAction(nullptr)
+      ,m_removeAction(nullptr)
 {
     Q_UNUSED(args)
     setComponentData(*createAboutData(), false);
@@ -223,6 +223,7 @@ void DolphinPart::createActions()
     m_findFileAction->setIcon(QIcon::fromTheme(QStringLiteral("edit-find")));
     connect(m_findFileAction, &QAction::triggered, this, &DolphinPart::slotFindFile);
 
+#ifndef Q_OS_WIN
     if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
         m_openTerminalAction = actionCollection()->addAction(QStringLiteral("open_terminal"));
         m_openTerminalAction->setIcon(QIcon::fromTheme(QStringLiteral("utilities-terminal")));
@@ -230,6 +231,7 @@ void DolphinPart::createActions()
         connect(m_openTerminalAction, &QAction::triggered, this, &DolphinPart::slotOpenTerminal);
         actionCollection()->setDefaultShortcut(m_openTerminalAction, Qt::Key_F4);
     }
+#endif
 }
 
 void DolphinPart::createGoAction(const char* name, const char* iconName,
@@ -316,7 +318,7 @@ bool DolphinPart::openUrl(const QUrl &url)
     QString prettyUrl = visibleUrl.toDisplayString(QUrl::PreferLocalFile);
     emit setWindowCaption(prettyUrl);
     emit m_extension->setLocationBarUrl(prettyUrl);
-    emit started(0); // get the wheel to spin
+    emit started(nullptr); // get the wheel to spin
     m_view->setNameFilter(m_nameFilter);
     m_view->setUrl(url);
     updatePasteAction();
@@ -431,7 +433,7 @@ void DolphinPart::slotOpenContextMenu(const QPoint& pos,
 
             if (showDeleteAction && showMoveToTrashAction) {
                 delete m_removeAction;
-                m_removeAction = 0;
+                m_removeAction = nullptr;
                 editActions.append(actionCollection()->action(KStandardAction::name(KStandardAction::MoveToTrash)));
                 editActions.append(actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile)));
             } else if (showDeleteAction && !showMoveToTrashAction) {
index 9bf9f95cf216deae0229826de386302d23510446..fb257221ca496d27d1f42d84862da8faac37373f 100644 (file)
@@ -130,7 +130,7 @@ Name[lt]=KompaktiÅ¡kas
 Name[nb]=Kompakt
 Name[nl]=Compact
 Name[nn]=Kompakt
-Name[pa]=ਸੰà¨\96ਿਪਤ
+Name[pa]=ਸੰà¨\96à©\87ਪ
 Name[pl]=Kompaktowy
 Name[pt]=Compacta
 Name[pt_BR]=Compacto
index 48aff5602901a0303e3ec4303a6d9b1117ccc16b..845d843651aa6b1d9e7c548646abf1f800b4b001 100644 (file)
@@ -54,7 +54,7 @@ class DolphinPart : public KParts::ReadOnlyPart
 
 public:
     explicit DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantList& args);
-    ~DolphinPart();
+    ~DolphinPart() override;
 
     static KAboutData* createAboutData();
 
@@ -62,7 +62,7 @@ public:
      * Standard KParts::ReadOnlyPart openUrl method.
      * Called by Konqueror to view a directory in DolphinPart.
      */
-    virtual bool openUrl(const QUrl& url) Q_DECL_OVERRIDE;
+    bool openUrl(const QUrl& url) override;
 
     /// see the supportsUndo property
     bool supportsUndo() const { return true; }
@@ -98,7 +98,7 @@ protected:
     /**
      * We reimplement openUrl so no need to implement openFile.
      */
-    virtual bool openFile() override { return true; }
+    bool openFile() override { return true; }
 
 Q_SIGNALS:
     /**
@@ -223,7 +223,7 @@ private Q_SLOTS:
     void setFilesToSelect(const QList<QUrl> &files);
     QList<QUrl> filesToSelect() const { return QList<QUrl>(); } // silence moc
 
-    virtual bool eventFilter(QObject*, QEvent*) Q_DECL_OVERRIDE;
+    bool eventFilter(QObject*, QEvent*) override;
 
 private:
     void createActions();
index 0b7018dbb2d3025a2a40c1cc7be05885a44391c3..590fc169cdd0a3cb1f282326af2829b89bd0a12b 100644 (file)
@@ -33,8 +33,8 @@ class DolphinPartBrowserExtension : public KParts::BrowserExtension
     Q_OBJECT
 public:
     DolphinPartBrowserExtension( DolphinPart* part );
-    virtual void restoreState(QDataStream &stream) Q_DECL_OVERRIDE;
-    virtual void saveState(QDataStream &stream) Q_DECL_OVERRIDE;
+    void restoreState(QDataStream &stream) override;
+    void saveState(QDataStream &stream) override;
 
 public Q_SLOTS:
     void cut();
@@ -54,10 +54,10 @@ class DolphinPartFileInfoExtension : public KParts::FileInfoExtension
 public:
     DolphinPartFileInfoExtension(DolphinPart* part);
 
-    virtual QueryModes supportedQueryModes() const Q_DECL_OVERRIDE;
-    virtual bool hasSelection() const Q_DECL_OVERRIDE;
+    QueryModes supportedQueryModes() const override;
+    bool hasSelection() const override;
 
-    virtual KFileItemList queryFor(QueryMode mode) const Q_DECL_OVERRIDE;
+    KFileItemList queryFor(QueryMode mode) const override;
 
 private:
     DolphinPart* m_part;
@@ -69,10 +69,10 @@ class DolphinPartListingFilterExtension : public KParts::ListingFilterExtension
 
 public:
     DolphinPartListingFilterExtension(DolphinPart* part);
-    virtual FilterModes supportedFilterModes() const Q_DECL_OVERRIDE;
-    virtual bool supportsMultipleFilters(FilterMode mode) const Q_DECL_OVERRIDE;
-    virtual QVariant filter(FilterMode mode) const Q_DECL_OVERRIDE;
-    virtual void setFilter(FilterMode mode, const QVariant& filter) Q_DECL_OVERRIDE;
+    FilterModes supportedFilterModes() const override;
+    bool supportsMultipleFilters(FilterMode mode) const override;
+    QVariant filter(FilterMode mode) const override;
+    void setFilter(FilterMode mode, const QVariant& filter) override;
 
 private:
     DolphinPart* m_part;
@@ -84,7 +84,7 @@ class DolphinPartListingNotificationExtension : public KParts::ListingNotificati
 
 public:
     DolphinPartListingNotificationExtension(DolphinPart* part);
-    virtual NotificationEventTypes supportedNotificationEventTypes() const Q_DECL_OVERRIDE;
+    NotificationEventTypes supportedNotificationEventTypes() const override;
 
 public Q_SLOTS:
     void slotNewItems(const KFileItemList&);
index c155632c6707c8f68593466bcc3606a1166f1552..f425df21805cf218d89500c99145a8da721a3c99 100644 (file)
@@ -86,7 +86,7 @@ void DolphinRecentTabsMenu::handleAction(QAction* action)
         const QByteArray state = action->data().toByteArray();
         removeAction(action);
         delete action;
-        action = 0;
+        action = nullptr;
         emit restoreClosedTab(state);
         emit closedTabsCountChanged(menu()->actions().size() - 2);
     }
index 0c08031a9714e4fbb584785ae74cf1434e1dbd5b..02270d0fce9ff4061f005ca0ced4d058d3f162d2 100644 (file)
@@ -35,18 +35,18 @@ signals:
     void tabDetachRequested(int index);
 
 protected:
-    virtual void dragEnterEvent(QDragEnterEvent* event) Q_DECL_OVERRIDE;
-    virtual void dragLeaveEvent(QDragLeaveEvent* event) Q_DECL_OVERRIDE;
-    virtual void dragMoveEvent(QDragMoveEvent* event) Q_DECL_OVERRIDE;
-    virtual void dropEvent(QDropEvent* event) Q_DECL_OVERRIDE;
-    virtual void mousePressEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
-    virtual void mouseReleaseEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
-    virtual void mouseDoubleClickEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
+    void dragEnterEvent(QDragEnterEvent* event) override;
+    void dragLeaveEvent(QDragLeaveEvent* event) override;
+    void dragMoveEvent(QDragMoveEvent* event) override;
+    void dropEvent(QDropEvent* event) override;
+    void mousePressEvent(QMouseEvent* event) override;
+    void mouseReleaseEvent(QMouseEvent* event) override;
+    void mouseDoubleClickEvent(QMouseEvent* event) override;
 
     /**
      * Opens a context menu for the tab on the \a event position.
      */
-    virtual void contextMenuEvent(QContextMenuEvent* event) Q_DECL_OVERRIDE;
+    void contextMenuEvent(QContextMenuEvent* event) override;
 
 private slots:
     void slotAutoActivationTimeout();
index b8772602d15cf50b110494c23c0b2b585c698f34..ba4c144d91acf85b4bcf3574c4a24788c8792b61 100644 (file)
@@ -33,7 +33,7 @@ class DolphinTabPage : public QWidget
     Q_OBJECT
 
 public:
-    explicit DolphinTabPage(const QUrl& primaryUrl, const QUrl& secondaryUrl = QUrl(), QWidget* parent = 0);
+    explicit DolphinTabPage(const QUrl& primaryUrl, const QUrl& secondaryUrl = QUrl(), QWidget* parent = nullptr);
 
     /**
      * @return True if primary view is the active view in this tab.
index 50ebd602ab85342d405cf8540b0dbd0d701a6e9b..ba2fd4867ab109dad2db80a300abb9f4d5be97c9 100644 (file)
@@ -174,8 +174,8 @@ private slots:
     void currentTabChanged(int index);
 
 protected:
-    virtual void tabInserted(int index) Q_DECL_OVERRIDE;
-    virtual void tabRemoved(int index) Q_DECL_OVERRIDE;
+    void tabInserted(int index) override;
+    void tabRemoved(int index) override;
 
 private:
     /**
index e92ec6022f8297e4805bea8ef83add447409c317..83b9f4343778235f303f6893324e4d288c28a5c2 100644 (file)
 
 DolphinViewContainer::DolphinViewContainer(const QUrl& url, QWidget* parent) :
     QWidget(parent),
-    m_topLayout(0),
-    m_urlNavigator(0),
-    m_searchBox(0),
-    m_messageWidget(0),
-    m_view(0),
-    m_filterBar(0),
-    m_statusBar(0),
-    m_statusBarTimer(0),
+    m_topLayout(nullptr),
+    m_urlNavigator(nullptr),
+    m_searchBox(nullptr),
+    m_messageWidget(nullptr),
+    m_view(nullptr),
+    m_filterBar(nullptr),
+    m_statusBar(nullptr),
+    m_statusBarTimer(nullptr),
     m_statusBarTimestamp(),
     m_autoGrabFocus(true)
 #ifdef KActivities_FOUND
@@ -245,6 +245,11 @@ bool DolphinViewContainer::autoGrabFocus() const
     return m_autoGrabFocus;
 }
 
+QString DolphinViewContainer::currentSearchText() const
+{
+     return m_searchBox->text();
+}
+
 const DolphinStatusBar* DolphinViewContainer::statusBar() const
 {
     return m_statusBar;
index 41c8f0b04b400353e4533f47aaf94a530e3428a7..837b168d704c4fe1a939d068023274d59115e688 100644 (file)
@@ -70,7 +70,7 @@ public:
     };
 
     DolphinViewContainer(const QUrl& url, QWidget* parent);
-    virtual ~DolphinViewContainer();
+    ~DolphinViewContainer() override;
 
     /**
      * Returns the current active URL, where all actions are applied.
@@ -93,6 +93,8 @@ public:
     void setAutoGrabFocus(bool grab);
     bool autoGrabFocus() const;
 
+    QString currentSearchText() const;
+
     const DolphinStatusBar* statusBar() const;
     DolphinStatusBar* statusBar();
 
index a275d1ea4cf114c96216ef9e40d2bc9aa76dd4b9..0c7dcb6cd0d16bbfc68a4b3e3d29a574812333af 100644 (file)
@@ -37,8 +37,8 @@ class FilterBar : public QWidget
     Q_OBJECT
 
 public:
-    explicit FilterBar(QWidget* parent = 0);
-    virtual ~FilterBar();
+    explicit FilterBar(QWidget* parent = nullptr);
+    ~FilterBar() override;
 
     /** Called by view container to hide this **/
     void closeFilterBar();
@@ -74,8 +74,8 @@ signals:
     void focusViewRequest();
 
 protected:
-    virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
-    virtual void keyReleaseEvent(QKeyEvent* event) Q_DECL_OVERRIDE;
+    void showEvent(QShowEvent* event) override;
+    void keyReleaseEvent(QKeyEvent* event) override;
 
 private:
     QLineEdit* m_filterInput;
index c17d543676dc78f3ebd54e156d32624df422e276..41f8aeade0d60010e233ea9314ce67b58296a749 100644 (file)
@@ -49,9 +49,9 @@ namespace {
 
 KFileItemListView::KFileItemListView(QGraphicsWidget* parent) :
     KStandardItemListView(parent),
-    m_modelRolesUpdater(0),
-    m_updateVisibleIndexRangeTimer(0),
-    m_updateIconSizeTimer(0)
+    m_modelRolesUpdater(nullptr),
+    m_updateVisibleIndexRangeTimer(nullptr),
+    m_updateIconSizeTimer(nullptr)
 {
     setAcceptDrops(true);
 
@@ -229,7 +229,7 @@ void KFileItemListView::onModelChanged(KItemModelBase* current, KItemModelBase*
     KStandardItemListView::onModelChanged(current, previous);
 
     delete m_modelRolesUpdater;
-    m_modelRolesUpdater = 0;
+    m_modelRolesUpdater = nullptr;
 
     if (current) {
         m_modelRolesUpdater = new KFileItemModelRolesUpdater(static_cast<KFileItemModel*>(current), this);
index 84aa17d89baec0ed1a2148d7c1e5c62f20e86278..95ad9ba6862a222c598a9acc8cf28dbf42bdaee5 100644 (file)
@@ -41,8 +41,8 @@ class DOLPHIN_EXPORT KFileItemListView : public KStandardItemListView
     Q_OBJECT
 
 public:
-    KFileItemListView(QGraphicsWidget* parent = 0);
-    virtual ~KFileItemListView();
+    KFileItemListView(QGraphicsWidget* parent = nullptr);
+    ~KFileItemListView() override;
 
     void setPreviewsShown(bool show);
     bool previewsShown() const;
@@ -72,27 +72,27 @@ public:
      */
     QStringList enabledPlugins() const;
 
-    virtual QPixmap createDragPixmap(const KItemSet& indexes) const Q_DECL_OVERRIDE;
+    QPixmap createDragPixmap(const KItemSet& indexes) const override;
 
 protected:
-    virtual KItemListWidgetCreatorBase* defaultWidgetCreator() const Q_DECL_OVERRIDE;
-    virtual void initializeItemListWidget(KItemListWidget* item) Q_DECL_OVERRIDE;
+    KItemListWidgetCreatorBase* defaultWidgetCreator() const override;
+    void initializeItemListWidget(KItemListWidget* item) override;
     virtual void onPreviewsShownChanged(bool shown);
-    virtual void onItemLayoutChanged(ItemLayout current, ItemLayout previous) Q_DECL_OVERRIDE;
-    virtual void onModelChanged(KItemModelBase* current, KItemModelBase* previous) Q_DECL_OVERRIDE;
-    virtual void onScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous) Q_DECL_OVERRIDE;
-    virtual void onItemSizeChanged(const QSizeF& current, const QSizeF& previous) Q_DECL_OVERRIDE;
-    virtual void onScrollOffsetChanged(qreal current, qreal previous) Q_DECL_OVERRIDE;
-    virtual void onVisibleRolesChanged(const QList<QByteArray>& current, const QList<QByteArray>& previous) Q_DECL_OVERRIDE;
-    virtual void onStyleOptionChanged(const KItemListStyleOption& current, const KItemListStyleOption& previous) Q_DECL_OVERRIDE;
-    virtual void onSupportsItemExpandingChanged(bool supportsExpanding) Q_DECL_OVERRIDE;
-    virtual void onTransactionBegin() Q_DECL_OVERRIDE;
-    virtual void onTransactionEnd() Q_DECL_OVERRIDE;
-    virtual void resizeEvent(QGraphicsSceneResizeEvent* event) Q_DECL_OVERRIDE;
+    void onItemLayoutChanged(ItemLayout current, ItemLayout previous) override;
+    void onModelChanged(KItemModelBase* current, KItemModelBase* previous) override;
+    void onScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous) override;
+    void onItemSizeChanged(const QSizeF& current, const QSizeF& previous) override;
+    void onScrollOffsetChanged(qreal current, qreal previous) override;
+    void onVisibleRolesChanged(const QList<QByteArray>& current, const QList<QByteArray>& previous) override;
+    void onStyleOptionChanged(const KItemListStyleOption& current, const KItemListStyleOption& previous) override;
+    void onSupportsItemExpandingChanged(bool supportsExpanding) override;
+    void onTransactionBegin() override;
+    void onTransactionEnd() override;
+    void resizeEvent(QGraphicsSceneResizeEvent* event) override;
 
 protected slots:
-    virtual void slotItemsRemoved(const KItemRangeList& itemRanges) Q_DECL_OVERRIDE;
-    virtual void slotSortRoleChanged(const QByteArray& current, const QByteArray& previous) Q_DECL_OVERRIDE;
+    void slotItemsRemoved(const KItemRangeList& itemRanges) override;
+    void slotSortRoleChanged(const QByteArray& current, const QByteArray& previous) override;
 
 private slots:
     void triggerVisibleIndexRangeUpdate();
index fa98093b55bf85e91ee9242b11b2e7eb3c3f56be..5fa3e548c5989dd5df6ce56e867850a8bc3b6184 100644 (file)
@@ -80,7 +80,7 @@ QString KFileItemListWidgetInformant::roleText(const QByteArray& role,
             const KIO::filesize_t size = roleValue.value<KIO::filesize_t>();
             text = KFormat().formatByteSize(size);
         }
-    } else if (role == "modificationtime" || role == "accesstime" || role == "deletiontime") {
+    } else if (role == "modificationtime" || role == "accesstime" || role == "deletiontime" || role == "imageDateTime") {
         const QDateTime dateTime = roleValue.toDateTime();
         text = QLocale().toString(dateTime, QLocale::ShortFormat);
     } else {
index 07ca59b44455bf1fd0559518742480d80378d642..fbb0300f81e587b42be460e2bfe0c17b0561d409 100644 (file)
@@ -28,13 +28,13 @@ class DOLPHIN_EXPORT KFileItemListWidgetInformant : public KStandardItemListWidg
 {
 public:
     KFileItemListWidgetInformant();
-    virtual ~KFileItemListWidgetInformant();
+    ~KFileItemListWidgetInformant() override;
 
 protected:
-    virtual QString itemText(int index, const KItemListView* view) const Q_DECL_OVERRIDE;
-    virtual bool itemIsLink(int index, const KItemListView* view) const Q_DECL_OVERRIDE;
-    virtual QString roleText(const QByteArray& role, const QHash<QByteArray, QVariant>& values) const Q_DECL_OVERRIDE;
-    virtual QFont customizedFontForLinks(const QFont& baseFont) const Q_DECL_OVERRIDE;
+    QString itemText(int index, const KItemListView* view) const override;
+    bool itemIsLink(int index, const KItemListView* view) const override;
+    QString roleText(const QByteArray& role, const QHash<QByteArray, QVariant>& values) const override;
+    QFont customizedFontForLinks(const QFont& baseFont) const override;
 };
 
 class DOLPHIN_EXPORT KFileItemListWidget : public KStandardItemListWidget
@@ -43,19 +43,19 @@ class DOLPHIN_EXPORT KFileItemListWidget : public KStandardItemListWidget
 
 public:
     KFileItemListWidget(KItemListWidgetInformant* informant, QGraphicsItem* parent);
-    virtual ~KFileItemListWidget();
+    ~KFileItemListWidget() override;
 
     static KItemListWidgetInformant* createInformant();
 
 protected:
-    virtual bool isRoleRightAligned(const QByteArray& role) const Q_DECL_OVERRIDE;
-    virtual bool isHidden() const Q_DECL_OVERRIDE;
-    virtual QFont customizedFont(const QFont& baseFont) const Q_DECL_OVERRIDE;
+    bool isRoleRightAligned(const QByteArray& role) const override;
+    bool isHidden() const override;
+    QFont customizedFont(const QFont& baseFont) const override;
 
     /**
      * @return Selection length without MIME-type extension
      */
-    virtual int selectionLength(const QString& text) const Q_DECL_OVERRIDE;
+    int selectionLength(const QString& text) const override;
 };
 
 #endif
index 5919e64274db5ebe65843afd7990f3334fca0aac..a5422a7bf5280f703002e5979c2cf58ef99c12f8 100644 (file)
@@ -42,7 +42,7 @@
 
 KFileItemModel::KFileItemModel(QObject* parent) :
     KItemModelBase("text", parent),
-    m_dirLister(0),
+    m_dirLister(nullptr),
     m_sortDirsFirst(true),
     m_sortRole(NameRole),
     m_sortingProgressPercent(-1),
@@ -52,8 +52,8 @@ KFileItemModel::KFileItemModel(QObject* parent) :
     m_filter(),
     m_filteredItems(),
     m_requestRole(),
-    m_maximumUpdateIntervalTimer(0),
-    m_resortAllItemsTimer(0),
+    m_maximumUpdateIntervalTimer(nullptr),
+    m_resortAllItemsTimer(nullptr),
     m_pendingItemsToInsert(),
     m_groups(),
     m_expandedDirs(),
@@ -251,7 +251,7 @@ QMimeData* KFileItemModel::createMimeData(const KItemSet& indexes) const
     QList<QUrl> urls;
     QList<QUrl> mostLocalUrls;
     bool canUseMostLocalUrls = true;
-    const ItemData* lastAddedItem = 0;
+    const ItemData* lastAddedItem = nullptr;
 
     for (int index : indexes) {
         const ItemData* itemData = m_itemData.at(index);
@@ -2299,19 +2299,20 @@ const KFileItemModel::RoleInfoMap* KFileItemModel::rolesInfoMap(int& count)
 {
     static const RoleInfoMap rolesInfoMap[] = {
     //  | role         | roleType       | role translation                                | group translation           | requires Baloo   | requires indexer
-        { 0,             NoRole,          0, 0,                                             0, 0,                                     false, false },
-        { "text",        NameRole,        I18N_NOOP2_NOSTRIP("@label", "Name"),             0, 0,                                     false, false },
-        { "size",        SizeRole,        I18N_NOOP2_NOSTRIP("@label", "Size"),             0, 0,                                     false, false },
-        { "modificationtime",        ModificationTimeRole,        I18N_NOOP2_NOSTRIP("@label", "Modified"),             0, 0,                                     false, false },
-        { "creationtime",        CreationTimeRole,        I18N_NOOP2_NOSTRIP("@label", "Created"),             0, 0,                                     false, false },
-        { "accesstime",        AccessTimeRole,        I18N_NOOP2_NOSTRIP("@label", "Accessed"),             0, 0,                                     false, false },
-        { "type",        TypeRole,        I18N_NOOP2_NOSTRIP("@label", "Type"),             0, 0,                                     false, false },
-        { "rating",      RatingRole,      I18N_NOOP2_NOSTRIP("@label", "Rating"),           0, 0,                                     true,  false },
-        { "tags",        TagsRole,        I18N_NOOP2_NOSTRIP("@label", "Tags"),             0, 0,                                     true,  false },
-        { "comment",     CommentRole,     I18N_NOOP2_NOSTRIP("@label", "Comment"),          0, 0,                                     true,  false },
+        { nullptr,             NoRole,          nullptr, nullptr,                                             nullptr, nullptr,                                     false, false },
+        { "text",        NameRole,        I18N_NOOP2_NOSTRIP("@label", "Name"),             nullptr, nullptr,                                     false, false },
+        { "size",        SizeRole,        I18N_NOOP2_NOSTRIP("@label", "Size"),             nullptr, nullptr,                                     false, false },
+        { "modificationtime",        ModificationTimeRole,        I18N_NOOP2_NOSTRIP("@label", "Modified"),             nullptr, nullptr,                                     false, false },
+        { "creationtime",        CreationTimeRole,        I18N_NOOP2_NOSTRIP("@label", "Created"),             nullptr, nullptr,                                     false, false },
+        { "accesstime",        AccessTimeRole,        I18N_NOOP2_NOSTRIP("@label", "Accessed"),             nullptr, nullptr,                                     false, false },
+        { "type",        TypeRole,        I18N_NOOP2_NOSTRIP("@label", "Type"),             nullptr, nullptr,                                     false, false },
+        { "rating",      RatingRole,      I18N_NOOP2_NOSTRIP("@label", "Rating"),           nullptr, nullptr,                                     true,  false },
+        { "tags",        TagsRole,        I18N_NOOP2_NOSTRIP("@label", "Tags"),             nullptr, nullptr,                                     true,  false },
+        { "comment",     CommentRole,     I18N_NOOP2_NOSTRIP("@label", "Comment"),          nullptr, nullptr,                                     true,  false },
         { "title",       TitleRole,       I18N_NOOP2_NOSTRIP("@label", "Title"),            I18N_NOOP2_NOSTRIP("@label", "Document"), true,  true  },
         { "wordCount",   WordCountRole,   I18N_NOOP2_NOSTRIP("@label", "Word Count"),       I18N_NOOP2_NOSTRIP("@label", "Document"), true,  true  },
         { "lineCount",   LineCountRole,   I18N_NOOP2_NOSTRIP("@label", "Line Count"),       I18N_NOOP2_NOSTRIP("@label", "Document"), true,  true  },
+        { "imageDateTime",   ImageDateTimeRole,   I18N_NOOP2_NOSTRIP("@label", "Date Photographed"),       I18N_NOOP2_NOSTRIP("@label", "Image"),    true,  true  },
         { "imageSize",   ImageSizeRole,   I18N_NOOP2_NOSTRIP("@label", "Image Size"),       I18N_NOOP2_NOSTRIP("@label", "Image"),    true,  true  },
         { "orientation", OrientationRole, I18N_NOOP2_NOSTRIP("@label", "Orientation"),      I18N_NOOP2_NOSTRIP("@label", "Image"),    true,  true  },
         { "artist",      ArtistRole,      I18N_NOOP2_NOSTRIP("@label", "Artist"),           I18N_NOOP2_NOSTRIP("@label", "Audio"),    true,  true  },
@@ -2377,7 +2378,7 @@ bool KFileItemModel::isConsistent() const
         return false;
     }
 
-    for (int i = 0; i < count(); ++i) {
+    for (int i = 0, iMax = count(); i < iMax; ++i) {
         // Check if m_items and m_itemData are consistent.
         const KFileItem item = fileItem(i);
         if (item.isNull()) {
index 0ca748d7ab8803363ab6e00c583289b7de83b84f..4589b542241e8b65181bd8dffc09a764cf996796 100644 (file)
@@ -50,8 +50,8 @@ class DOLPHIN_EXPORT KFileItemModel : public KItemModelBase
     Q_OBJECT
 
 public:
-    explicit KFileItemModel(QObject* parent = 0);
-    virtual ~KFileItemModel();
+    explicit KFileItemModel(QObject* parent = nullptr);
+    ~KFileItemModel() override;
 
     /**
      * Loads the directory specified by \a url. The signals
@@ -73,7 +73,7 @@ public:
      *         the root-parent of all items.
      * @see rootItem()
      */
-    QUrl directory() const Q_DECL_OVERRIDE;
+    QUrl directory() const override;
 
     /**
      * Cancels the loading of a directory which has been started by either
@@ -81,9 +81,9 @@ public:
      */
     void cancelDirectoryLoading();
 
-    virtual int count() const Q_DECL_OVERRIDE;
-    virtual QHash<QByteArray, QVariant> data(int index) const Q_DECL_OVERRIDE;
-    virtual bool setData(int index, const QHash<QByteArray, QVariant>& values) Q_DECL_OVERRIDE;
+    int count() const override;
+    QHash<QByteArray, QVariant> data(int index) const override;
+    bool setData(int index, const QHash<QByteArray, QVariant>& values) override;
 
     /**
      * Sets a separate sorting with directories first (true) or a mixed
@@ -102,15 +102,15 @@ public:
     void setShowDirectoriesOnly(bool enabled);
     bool showDirectoriesOnly() const;
 
-    virtual QMimeData* createMimeData(const KItemSet& indexes) const Q_DECL_OVERRIDE;
+    QMimeData* createMimeData(const KItemSet& indexes) const override;
 
-    virtual int indexForKeyboardSearch(const QString& text, int startFromIndex = 0) const Q_DECL_OVERRIDE;
+    int indexForKeyboardSearch(const QString& text, int startFromIndex = 0) const override;
 
-    virtual bool supportsDropping(int index) const Q_DECL_OVERRIDE;
+    bool supportsDropping(int index) const override;
 
-    virtual QString roleDescription(const QByteArray& role) const Q_DECL_OVERRIDE;
+    QString roleDescription(const QByteArray& role) const override;
 
-    virtual QList<QPair<int, QVariant> > groups() const Q_DECL_OVERRIDE;
+    QList<QPair<int, QVariant> > groups() const override;
 
     /**
      * @return The file-item for the index \a index. If the index is in a valid
@@ -156,10 +156,10 @@ public:
     void setRoles(const QSet<QByteArray>& roles);
     QSet<QByteArray> roles() const;
 
-    virtual bool setExpanded(int index, bool expanded) Q_DECL_OVERRIDE;
-    virtual bool isExpanded(int index) const Q_DECL_OVERRIDE;
-    virtual bool isExpandable(int index) const Q_DECL_OVERRIDE;
-    virtual int expandedParentsCount(int index) const Q_DECL_OVERRIDE;
+    bool setExpanded(int index, bool expanded) override;
+    bool isExpanded(int index) const override;
+    bool isExpandable(int index) const override;
+    int expandedParentsCount(int index) const override;
 
     QSet<QUrl> expandedDirectories() const;
 
@@ -258,9 +258,9 @@ signals:
     void urlIsFileError(const QUrl& url);
 
 protected:
-    virtual void onGroupedSortingChanged(bool current) Q_DECL_OVERRIDE;
-    virtual void onSortRoleChanged(const QByteArray& current, const QByteArray& previous) Q_DECL_OVERRIDE;
-    virtual void onSortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous) Q_DECL_OVERRIDE;
+    void onGroupedSortingChanged(bool current) override;
+    void onSortRoleChanged(const QByteArray& current, const QByteArray& previous) override;
+    void onSortOrderChanged(Qt::SortOrder current, Qt::SortOrder previous) override;
 
 private slots:
     /**
@@ -285,7 +285,7 @@ private:
         NoRole, NameRole, SizeRole, ModificationTimeRole, CreationTimeRole, AccessTimeRole, PermissionsRole, OwnerRole,
         GroupRole, TypeRole, DestinationRole, PathRole, DeletionTimeRole,
         // User visible roles available with Baloo:
-        CommentRole, TagsRole, RatingRole, ImageSizeRole, OrientationRole,
+        CommentRole, TagsRole, RatingRole, ImageSizeRole, ImageDateTimeRole, OrientationRole,
         WordCountRole, TitleRole, LineCountRole, ArtistRole, GenreRole, AlbumRole, DurationRole, TrackRole, ReleaseYearRole,
         BitrateRole, OriginUrlRole,
         // Non-visible roles:
index 0d7f983113896758eb928ab258cbe846e4581932..a08f1ae150d4424299a040580995b136358125cc 100644 (file)
@@ -88,21 +88,18 @@ KFileItemModelRolesUpdater::KFileItemModelRolesUpdater(KFileItemModel* model, QO
     m_pendingIndexes(),
     m_pendingPreviewItems(),
     m_previewJob(),
-    m_recentlyChangedItemsTimer(0),
+    m_recentlyChangedItemsTimer(nullptr),
     m_recentlyChangedItems(),
     m_changedItems(),
-    m_directoryContentsCounter(0)
+    m_directoryContentsCounter(nullptr)
   #ifdef HAVE_BALOO
-  , m_balooFileMonitor(0)
+  , m_balooFileMonitor(nullptr)
   #endif
 {
     Q_ASSERT(model);
 
     const KConfigGroup globalConfig(KSharedConfig::openConfig(), "PreviewSettings");
-    m_enabledPlugins = globalConfig.readEntry("Plugins", QStringList()
-                                                         << QStringLiteral("directorythumbnail")
-                                                         << QStringLiteral("imagethumbnail")
-                                                         << QStringLiteral("jpegthumbnail"));
+    m_enabledPlugins = globalConfig.readEntry("Plugins", KIO::PreviewJob::defaultPlugins());
 
     connect(m_model, &KFileItemModel::itemsInserted,
             this,    &KFileItemModelRolesUpdater::slotItemsInserted);
@@ -299,7 +296,7 @@ void KFileItemModelRolesUpdater::setRoles(const QSet<QByteArray>& roles)
                     this, &KFileItemModelRolesUpdater::applyChangedBalooRoles);
         } else if (!hasBalooRole && m_balooFileMonitor) {
             delete m_balooFileMonitor;
-            m_balooFileMonitor = 0;
+            m_balooFileMonitor = nullptr;
         }
 #endif
 
@@ -597,7 +594,7 @@ void KFileItemModelRolesUpdater::slotPreviewFailed(const KFileItem& item)
 
 void KFileItemModelRolesUpdater::slotPreviewJobFinished()
 {
-    m_previewJob = 0;
+    m_previewJob = nullptr;
 
     if (m_state != PreviewJobRunning) {
         return;
@@ -1141,7 +1138,7 @@ void KFileItemModelRolesUpdater::killPreviewJob()
         disconnect(m_previewJob,  &KIO::PreviewJob::finished,
                    this, &KFileItemModelRolesUpdater::slotPreviewJobFinished);
         m_previewJob->kill();
-        m_previewJob = 0;
+        m_previewJob = nullptr;
         m_pendingPreviewItems.clear();
     }
 }
index cd86fce1eeed3de3b26b6c7645c9524ac7db3fb5..d971a7c17164b16300b2b374922768abec48584d 100644 (file)
@@ -94,8 +94,8 @@ class DOLPHIN_EXPORT KFileItemModelRolesUpdater : public QObject
     Q_OBJECT
 
 public:
-    explicit KFileItemModelRolesUpdater(KFileItemModel* model, QObject* parent = 0);
-    virtual ~KFileItemModelRolesUpdater();
+    explicit KFileItemModelRolesUpdater(KFileItemModel* model, QObject* parent = nullptr);
+    ~KFileItemModelRolesUpdater() override;
 
     void setIconSize(const QSize& size);
     QSize iconSize() const;
index b4ea62fac354249d66e4977d94807c6d05f515a0..c1eae53bd6a8c628cefe917c5859be572d7bd939 100644 (file)
@@ -35,7 +35,6 @@
 #include <QStyle>
 #include <QStyleOption>
 
-
 /**
  * Replaces the default viewport of KItemListContainer by a
  * non-scrollable viewport. The scrolling is done in an optimized
@@ -48,7 +47,7 @@ class KItemListContainerViewport : public QGraphicsView
 public:
     KItemListContainerViewport(QGraphicsScene* scene, QWidget* parent);
 protected:
-    void wheelEvent(QWheelEvent* event) Q_DECL_OVERRIDE;
+    void wheelEvent(QWheelEvent* event) override;
 };
 
 KItemListContainerViewport::KItemListContainerViewport(QGraphicsScene* scene, QWidget* parent) :
@@ -70,8 +69,8 @@ void KItemListContainerViewport::wheelEvent(QWheelEvent* event)
 KItemListContainer::KItemListContainer(KItemListController* controller, QWidget* parent) :
     QAbstractScrollArea(parent),
     m_controller(controller),
-    m_horizontalSmoothScroller(0),
-    m_verticalSmoothScroller(0)
+    m_horizontalSmoothScroller(nullptr),
+    m_verticalSmoothScroller(nullptr)
 {
     Q_ASSERT(controller);
     controller->setParent(this);
@@ -83,10 +82,10 @@ KItemListContainer::KItemListContainer(KItemListController* controller, QWidget*
     m_verticalSmoothScroller = new KItemListSmoothScroller(verticalScrollBar(), this);
 
     if (controller->model()) {
-        slotModelChanged(controller->model(), 0);
+        slotModelChanged(controller->model(), nullptr);
     }
     if (controller->view()) {
-        slotViewChanged(controller->view(), 0);
+        slotViewChanged(controller->view(), nullptr);
     }
 
     connect(controller, &KItemListController::modelChanged,
@@ -100,7 +99,7 @@ KItemListContainer::~KItemListContainer()
     // Don't rely on the QObject-order to delete the controller, otherwise
     // the QGraphicsScene might get deleted before the view.
     delete m_controller;
-    m_controller = 0;
+    m_controller = nullptr;
 }
 
 KItemListController* KItemListContainer::controller() const
@@ -216,8 +215,8 @@ void KItemListContainer::slotViewChanged(KItemListView* current, KItemListView*
         disconnect(previous, &KItemListView::maximumItemOffsetChanged,
                    this, &KItemListContainer::updateItemOffsetScrollBar);
         disconnect(previous, &KItemListView::scrollTo, this, &KItemListContainer::scrollTo);
-        m_horizontalSmoothScroller->setTargetObject(0);
-        m_verticalSmoothScroller->setTargetObject(0);
+        m_horizontalSmoothScroller->setTargetObject(nullptr);
+        m_verticalSmoothScroller->setTargetObject(nullptr);
     }
     if (current) {
         scene->addItem(current);
@@ -257,8 +256,8 @@ void KItemListContainer::updateScrollOffsetScrollBar()
         return;
     }
 
-    KItemListSmoothScroller* smoothScroller = 0;
-    QScrollBar* scrollOffsetScrollBar = 0;
+    KItemListSmoothScroller* smoothScroller = nullptr;
+    QScrollBar* scrollOffsetScrollBar = nullptr;
     int singleStep = 0;
     int pageStep = 0;
     int maximum = 0;
@@ -308,8 +307,8 @@ void KItemListContainer::updateItemOffsetScrollBar()
         return;
     }
 
-    KItemListSmoothScroller* smoothScroller = 0;
-    QScrollBar* itemOffsetScrollBar = 0;
+    KItemListSmoothScroller* smoothScroller = nullptr;
+    QScrollBar* itemOffsetScrollBar = nullptr;
     int singleStep = 0;
     int pageStep = 0;
     if (view->scrollOrientation() == Qt::Vertical) {
index 9fc3d4957ee0e2df38525990f6df925d6ab69ee0..c5ef855634f8eb0424f1eead19c580265b905b73 100644 (file)
@@ -50,19 +50,19 @@ public:
      *                   (the parent will be set to the KItemListContainer).
      * @param parent     Optional parent widget.
      */
-    explicit KItemListContainer(KItemListController* controller, QWidget* parent = 0);
-    virtual ~KItemListContainer();
+    explicit KItemListContainer(KItemListController* controller, QWidget* parent = nullptr);
+    ~KItemListContainer() override;
     KItemListController* controller() const;
 
     void setEnabledFrame(bool enable);
     bool enabledFrame() const;
 
 protected:
-    virtual void keyPressEvent(QKeyEvent* event) Q_DECL_OVERRIDE;
-    virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
-    virtual void resizeEvent(QResizeEvent* event) Q_DECL_OVERRIDE;
-    virtual void scrollContentsBy(int dx, int dy) Q_DECL_OVERRIDE;
-    virtual void wheelEvent(QWheelEvent* event) Q_DECL_OVERRIDE;
+    void keyPressEvent(QKeyEvent* event) override;
+    void showEvent(QShowEvent* event) override;
+    void resizeEvent(QResizeEvent* event) override;
+    void scrollContentsBy(int dx, int dy) override;
+    void wheelEvent(QWheelEvent* event) override;
 
 private slots:
     void slotScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous);
index 008b6c4c6cdb21a3a463a1d65709b37cb7214f2a..1309364884ee5fa708492c50c7e15fc26b5a0850 100644 (file)
@@ -49,13 +49,13 @@ KItemListController::KItemListController(KItemModelBase* model, KItemListView* v
     m_selectionBehavior(NoSelection),
     m_autoActivationBehavior(ActivationAndExpansion),
     m_mouseDoubleClickAction(ActivateItemOnly),
-    m_model(0),
-    m_view(0),
+    m_model(nullptr),
+    m_view(nullptr),
     m_selectionManager(new KItemListSelectionManager(this)),
     m_keyboardManager(new KItemListKeyboardSearchManager(this)),
     m_pressedIndex(-1),
     m_pressedMousePos(),
-    m_autoActivationTimer(0),
+    m_autoActivationTimer(nullptr),
     m_oldSelection(),
     m_keyboardAnchorIndex(-1),
     m_keyboardAnchorPos(0)
@@ -76,10 +76,10 @@ KItemListController::KItemListController(KItemModelBase* model, KItemListView* v
 
 KItemListController::~KItemListController()
 {
-    setView(0);
+    setView(nullptr);
     Q_ASSERT(!m_view);
 
-    setModel(0);
+    setModel(nullptr);
     Q_ASSERT(!m_model);
 }
 
@@ -179,6 +179,20 @@ KItemListController::MouseDoubleClickAction KItemListController::mouseDoubleClic
     return m_mouseDoubleClickAction;
 }
 
+int KItemListController::indexCloseToMousePressedPosition() const
+{
+    QHashIterator<KItemListWidget*, KItemListGroupHeader*> it(m_view->m_visibleGroups);
+    while (it.hasNext()) {
+        it.next();
+        KItemListGroupHeader *groupHeader = it.value();
+        const QPointF mappedToGroup = groupHeader->mapFromItem(nullptr, m_pressedMousePos);
+        if (groupHeader->contains(mappedToGroup)) {
+            return it.key()->index();
+        }
+    }
+    return -1;
+}
+
 void KItemListController::setAutoActivationDelay(int delay)
 {
     m_autoActivationTimer->setInterval(delay);
@@ -1216,7 +1230,7 @@ KItemListWidget* KItemListController::hoveredWidget() const
         }
     }
 
-    return 0;
+    return nullptr;
 }
 
 KItemListWidget* KItemListController::widgetForPos(const QPointF& pos) const
@@ -1233,7 +1247,7 @@ KItemListWidget* KItemListController::widgetForPos(const QPointF& pos) const
         }
     }
 
-    return 0;
+    return nullptr;
 }
 
 void KItemListController::updateKeyboardAnchor()
index f293774434ef3e6bf24966e70cc6599702fedc70..3de5edece9e79913abad5a18e4b85f09557ad65a 100644 (file)
@@ -88,8 +88,8 @@ public:
      * @param view   View of the controller. The ownership is passed to the controller.
      * @param parent Optional parent object.
      */
-    KItemListController(KItemModelBase* model, KItemListView* view, QObject* parent = 0);
-    virtual ~KItemListController();
+    KItemListController(KItemModelBase* model, KItemListView* view, QObject* parent = nullptr);
+    ~KItemListController() override;
 
     void setModel(KItemModelBase* model);
     KItemModelBase* model() const;
@@ -108,6 +108,8 @@ public:
     void setMouseDoubleClickAction(MouseDoubleClickAction action);
     MouseDoubleClickAction mouseDoubleClickAction() const;
 
+    int indexCloseToMousePressedPosition() const;
+
     /**
      * Sets the delay in milliseconds when dragging an object above an item
      * until the item gets activated automatically. A value of -1 indicates
index f8576b08cfcd5da7157c0e9c0b9e99e9ef6469eb..fb92989894243f1ef5c6103ee391c3831a698d7e 100644 (file)
@@ -29,7 +29,7 @@
 #include <QStyleOptionGraphicsItem>
 
 KItemListGroupHeader::KItemListGroupHeader(QGraphicsWidget* parent) :
-    QGraphicsWidget(parent, 0),
+    QGraphicsWidget(parent, nullptr),
     m_dirtyCache(true),
     m_role(),
     m_data(),
index 4612bc4da839fba143f626536e631c5eb1262de8..6a8bd76e86a9ddf17a3d32edc0e5e23d8237b732 100644 (file)
@@ -42,8 +42,8 @@ class DOLPHIN_EXPORT KItemListGroupHeader : public QGraphicsWidget
     Q_OBJECT
 
 public:
-    KItemListGroupHeader(QGraphicsWidget* parent = 0);
-    virtual ~KItemListGroupHeader();
+    KItemListGroupHeader(QGraphicsWidget* parent = nullptr);
+    ~KItemListGroupHeader() override;
 
     void setRole(const QByteArray& role);
     QByteArray role() const;
@@ -65,7 +65,7 @@ public:
     void setItemIndex(int index);
     int itemIndex() const;
 
-    virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0) Q_DECL_OVERRIDE;
+    void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = nullptr) override;
 
 protected:
     virtual void paintRole(QPainter* painter, const QRectF& roleBounds, const QColor& color) = 0;
@@ -101,7 +101,7 @@ protected:
      */
     virtual void itemIndexChanged(int current, int previous);
 
-    virtual void resizeEvent(QGraphicsSceneResizeEvent* event) Q_DECL_OVERRIDE;
+    void resizeEvent(QGraphicsSceneResizeEvent* event) override;
 
     virtual QPalette::ColorRole normalTextColorRole() const;
     virtual QPalette::ColorRole normalBaseColorRole() const;
index 76c4205590161628fad1933b1da617a133eb541b..4d9d9a5b0837206742c85f8c63301963b81f7664 100644 (file)
@@ -38,7 +38,7 @@ class DOLPHIN_EXPORT KItemListHeader : public QObject
     Q_OBJECT
 
 public:
-    virtual ~KItemListHeader();
+    ~KItemListHeader() override;
 
     /**
      * If set to true, KItemListView will automatically adjust the
index 46ffe7c139f036b840659ca49a3fb4ece3955664..5d7b08eeb08b9df754dcba26596a42c5a3cc970d 100644 (file)
@@ -31,7 +31,7 @@ KItemListSelectionManager::KItemListSelectionManager(QObject* parent) :
     m_anchorItem(-1),
     m_selectedItems(),
     m_isAnchoredSelectionActive(false),
-    m_model(0)
+    m_model(nullptr)
 {
 }
 
index 16761428bb632608234a285a4667ac60f99ba6ec..54c2cc06299a32136a0e9e981e9de31189ceda1d 100644 (file)
@@ -51,8 +51,8 @@ public:
         Toggle
     };
 
-    KItemListSelectionManager(QObject* parent = 0);
-    virtual ~KItemListSelectionManager();
+    KItemListSelectionManager(QObject* parent = nullptr);
+    ~KItemListSelectionManager() override;
 
     void setCurrentItem(int current);
     int currentItem() const;
index d26809797954fa8362812a4cbe09016f8c7866c0..dbeb571a40d7732fc16733642deb04738ffd74d4 100644 (file)
@@ -67,7 +67,7 @@ QAccessibleInterface* accessibleInterfaceFactory(const QString& key, QObject* ob
         return new KItemListViewAccessible(view);
     }
 
-    return 0;
+    return nullptr;
 }
 #endif
 
@@ -80,30 +80,30 @@ KItemListView::KItemListView(QGraphicsWidget* parent) :
     m_activeTransactions(0),
     m_endTransactionAnimationHint(Animation),
     m_itemSize(),
-    m_controller(0),
-    m_model(0),
+    m_controller(nullptr),
+    m_model(nullptr),
     m_visibleRoles(),
-    m_widgetCreator(0),
-    m_groupHeaderCreator(0),
+    m_widgetCreator(nullptr),
+    m_groupHeaderCreator(nullptr),
     m_styleOption(),
     m_visibleItems(),
     m_visibleGroups(),
     m_visibleCells(),
-    m_sizeHintResolver(0),
-    m_layouter(0),
-    m_animation(0),
-    m_layoutTimer(0),
+    m_sizeHintResolver(nullptr),
+    m_layouter(nullptr),
+    m_animation(nullptr),
+    m_layoutTimer(nullptr),
     m_oldScrollOffset(0),
     m_oldMaximumScrollOffset(0),
     m_oldItemOffset(0),
     m_oldMaximumItemOffset(0),
     m_skipAutoScrollForRubberBand(false),
-    m_rubberBand(0),
+    m_rubberBand(nullptr),
     m_mousePos(),
     m_autoScrollIncrement(0),
-    m_autoScrollTimer(0),
-    m_header(0),
-    m_headerWidget(0),
+    m_autoScrollTimer(nullptr),
+    m_header(nullptr),
+    m_headerWidget(nullptr),
     m_dropIndicator()
 {
     setAcceptHoverEvents(true);
@@ -141,13 +141,13 @@ KItemListView::~KItemListView()
     // widgetCreator(). So it is mandatory to delete the group headers
     // first.
     delete m_groupHeaderCreator;
-    m_groupHeaderCreator = 0;
+    m_groupHeaderCreator = nullptr;
 
     delete m_widgetCreator;
-    m_widgetCreator = 0;
+    m_widgetCreator = nullptr;
 
     delete m_sizeHintResolver;
-    m_sizeHintResolver = 0;
+    m_sizeHintResolver = nullptr;
 }
 
 void KItemListView::setScrollOffset(qreal offset)
@@ -270,13 +270,13 @@ void KItemListView::setAutoScroll(bool enabled)
         m_autoScrollTimer->start(InitialAutoScrollDelay);
     } else if (!enabled && m_autoScrollTimer) {
         delete m_autoScrollTimer;
-        m_autoScrollTimer = 0;
+        m_autoScrollTimer = nullptr;
     }
 }
 
 bool KItemListView::autoScroll() const
 {
-    return m_autoScrollTimer != 0;
+    return m_autoScrollTimer != nullptr;
 }
 
 void KItemListView::setEnabledSelectionToggles(bool enabled)
@@ -342,7 +342,7 @@ QSizeF KItemListView::itemSize() const
 
 QSizeF KItemListView::itemSizeHint() const
 {
-    return m_sizeHintResolver->maxSizeHint();
+    return m_sizeHintResolver->minSizeHint();
 }
 
 const KItemListStyleOption& KItemListView::styleOption() const
@@ -629,7 +629,7 @@ QPixmap KItemListView::createDragPixmap(const KItemSet& indexes) const
         KItemListWidget* item = m_visibleItems.value(indexes.first());
         QGraphicsView* graphicsView = scene()->views()[0];
         if (item && graphicsView) {
-            pixmap = item->createDragPixmap(0, graphicsView);
+            pixmap = item->createDragPixmap(nullptr, graphicsView);
         }
     } else {
         // TODO: Not implemented yet. Probably extend the interface
@@ -834,12 +834,12 @@ Qt::Orientation KItemListView::scrollOrientation() const
 
 KItemListWidgetCreatorBase* KItemListView::defaultWidgetCreator() const
 {
-    return 0;
+    return nullptr;
 }
 
 KItemListGroupHeaderCreatorBase* KItemListView::defaultGroupHeaderCreator() const
 {
-    return 0;
+    return nullptr;
 }
 
 void KItemListView::initializeItemListWidget(KItemListWidget* item)
@@ -2090,7 +2090,7 @@ void KItemListView::recycleGroupHeaderForWidget(KItemListWidget* widget)
 {
     KItemListGroupHeader* header = m_visibleGroups.value(widget);
     if (header) {
-        header->setParentItem(0);
+        header->setParentItem(nullptr);
         groupHeaderCreator()->recycle(header);
         m_visibleGroups.remove(widget);
         disconnect(widget, &KItemListWidget::geometryChanged, this, &KItemListView::slotGeometryOfGroupHeaderParentChanged);
@@ -2551,7 +2551,7 @@ void KItemListView::updateSiblingsInformation(int firstIndex, int lastIndex)
             const int parents = m_model->expandedParentsCount(lastIndex + 1);
             for (int i = lastIndex; i >= firstIndex; --i) {
                 if (m_model->expandedParentsCount(i) != parents) {
-                    widget = 0;
+                    widget = nullptr;
                     break;
                 }
             }
@@ -2714,7 +2714,7 @@ void KItemListCreatorBase::pushRecycleableWidget(QGraphicsWidget* widget)
 QGraphicsWidget* KItemListCreatorBase::popRecycleableWidget()
 {
     if (m_recycleableWidgets.isEmpty()) {
-        return 0;
+        return nullptr;
     }
 
     QGraphicsWidget* widget = m_recycleableWidgets.takeLast();
@@ -2728,7 +2728,7 @@ KItemListWidgetCreatorBase::~KItemListWidgetCreatorBase()
 
 void KItemListWidgetCreatorBase::recycle(KItemListWidget* widget)
 {
-    widget->setParentItem(0);
+    widget->setParentItem(nullptr);
     widget->setOpacity(1.0);
     pushRecycleableWidget(widget);
 }
index e64ac7e31ad760303e0439cbf0fc2d6625e32b1a..e3793e10ef55a513757c52b9000e34a4884451d6 100644 (file)
@@ -67,8 +67,8 @@ class DOLPHIN_EXPORT KItemListView : public QGraphicsWidget
     Q_PROPERTY(qreal itemOffset READ itemOffset WRITE setItemOffset)
 
 public:
-    KItemListView(QGraphicsWidget* parent = 0);
-    virtual ~KItemListView();
+    KItemListView(QGraphicsWidget* parent = nullptr);
+    ~KItemListView() override;
 
     /**
      * Offset of the scrollbar that represents the scroll-orientation
@@ -165,7 +165,7 @@ public:
 
     const KItemListStyleOption& styleOption() const;
 
-    virtual void setGeometry(const QRectF& rect) Q_DECL_OVERRIDE;
+    void setGeometry(const QRectF& rect) override;
 
     /**
      * @return The page step which should be used by the vertical scroll bar.
@@ -285,7 +285,7 @@ public:
      */
     void editRole(int index, const QByteArray& role);
 
-    virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0) Q_DECL_OVERRIDE;
+    void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = nullptr) override;
 
 signals:
     void scrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous);
@@ -325,7 +325,7 @@ signals:
     void roleEditingFinished(int index, const QByteArray& role, const QVariant& value);
 
 protected:
-    virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) Q_DECL_OVERRIDE;
+    QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
     void setItemSize(const QSizeF& size);
     void setStyleOption(const KItemListStyleOption& option);
 
@@ -382,13 +382,13 @@ protected:
     virtual void onTransactionBegin();
     virtual void onTransactionEnd();
 
-    virtual bool event(QEvent* event) Q_DECL_OVERRIDE;
-    virtual void mousePressEvent(QGraphicsSceneMouseEvent* event) Q_DECL_OVERRIDE;
-    virtual void mouseMoveEvent(QGraphicsSceneMouseEvent* event) Q_DECL_OVERRIDE;
-    virtual void dragEnterEvent(QGraphicsSceneDragDropEvent* event) Q_DECL_OVERRIDE;
-    virtual void dragMoveEvent(QGraphicsSceneDragDropEvent* event) Q_DECL_OVERRIDE;
-    virtual void dragLeaveEvent(QGraphicsSceneDragDropEvent* event) Q_DECL_OVERRIDE;
-    virtual void dropEvent(QGraphicsSceneDragDropEvent* event) Q_DECL_OVERRIDE;
+    bool event(QEvent* event) override;
+    void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
+    void mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
+    void dragEnterEvent(QGraphicsSceneDragDropEvent* event) override;
+    void dragMoveEvent(QGraphicsSceneDragDropEvent* event) override;
+    void dragLeaveEvent(QGraphicsSceneDragDropEvent* event) override;
+    void dropEvent(QGraphicsSceneDragDropEvent* event) override;
 
     QList<KItemListWidget*> visibleItemListWidgets() const;
 
@@ -803,7 +803,7 @@ private:
 class DOLPHIN_EXPORT KItemListWidgetCreatorBase : public KItemListCreatorBase
 {
 public:
-    virtual ~KItemListWidgetCreatorBase();
+    ~KItemListWidgetCreatorBase() override;
 
     virtual KItemListWidget* create(KItemListView* view) = 0;
 
@@ -824,15 +824,15 @@ class KItemListWidgetCreator : public KItemListWidgetCreatorBase
 {
 public:
     KItemListWidgetCreator();
-    virtual ~KItemListWidgetCreator();
+    ~KItemListWidgetCreator() override;
 
-    virtual KItemListWidget* create(KItemListView* view) Q_DECL_OVERRIDE;
+    KItemListWidget* create(KItemListView* view) override;
 
-    virtual void calculateItemSizeHints(QVector<qreal>& logicalHeightHints, qreal& logicalWidthHint, const KItemListView* view) const Q_DECL_OVERRIDE;
+    void calculateItemSizeHints(QVector<qreal>& logicalHeightHints, qreal& logicalWidthHint, const KItemListView* view) const override;
 
-    virtual qreal preferredRoleColumnWidth(const QByteArray& role,
+    qreal preferredRoleColumnWidth(const QByteArray& role,
                                            int index,
-                                           const KItemListView* view) const Q_DECL_OVERRIDE;
+                                           const KItemListView* view) const override;
 private:
     KItemListWidgetInformant* m_informant;
 };
@@ -885,7 +885,7 @@ qreal KItemListWidgetCreator<T>::preferredRoleColumnWidth(const QByteArray& role
 class DOLPHIN_EXPORT KItemListGroupHeaderCreatorBase : public KItemListCreatorBase
 {
 public:
-    virtual ~KItemListGroupHeaderCreatorBase();
+    ~KItemListGroupHeaderCreatorBase() override;
     virtual KItemListGroupHeader* create(KItemListView* view) = 0;
     virtual void recycle(KItemListGroupHeader* header);
 };
@@ -894,8 +894,8 @@ template <class T>
 class KItemListGroupHeaderCreator : public KItemListGroupHeaderCreatorBase
 {
 public:
-    virtual ~KItemListGroupHeaderCreator();
-    virtual KItemListGroupHeader* create(KItemListView* view) Q_DECL_OVERRIDE;
+    ~KItemListGroupHeaderCreator() override;
+    KItemListGroupHeader* create(KItemListView* view) override;
 };
 
 template <class T>
index 6f06e243e3ef0ac77360f806bcb57c763e6f9a07..c593dad82c4d6b738611813fd47dd12a4cbc82c7 100644 (file)
@@ -60,7 +60,7 @@ void* KItemListViewAccessible::interface_cast(QAccessible::InterfaceType type)
     if (type == QAccessible::TableInterface) {
         return static_cast<QAccessibleTableInterface*>(this);
     }
-    return Q_NULLPTR;
+    return nullptr;
 }
 
 void KItemListViewAccessible::modelReset()
@@ -70,7 +70,7 @@ void KItemListViewAccessible::modelReset()
 QAccessibleInterface* KItemListViewAccessible::cell(int index) const
 {
     if (index < 0 || index >= view()->model()->count()) {
-        return 0;
+        return nullptr;
     }
 
     if (m_cells.size() <= index) {
@@ -93,7 +93,7 @@ QAccessibleInterface* KItemListViewAccessible::cellAt(int row, int column) const
 
 QAccessibleInterface* KItemListViewAccessible::caption() const
 {
-    return 0;
+    return nullptr;
 }
 
 QString KItemListViewAccessible::columnDescription(int) const
@@ -168,7 +168,7 @@ QList<int> KItemListViewAccessible::selectedRows() const
 
 QAccessibleInterface* KItemListViewAccessible::summary() const
 {
-    return 0;
+    return nullptr;
 }
 
 bool KItemListViewAccessible::isColumnSelected(int) const
@@ -225,7 +225,7 @@ QAccessibleInterface* KItemListViewAccessible::childAt(int x, int y) const
 QAccessibleInterface* KItemListViewAccessible::parent() const
 {
     // FIXME: return KItemListContainerAccessible here
-    return Q_NULLPTR;
+    return nullptr;
 }
 
 int KItemListViewAccessible::childCount() const
@@ -265,7 +265,7 @@ QAccessibleInterface* KItemListViewAccessible::child(int index) const
     if (index >= 0 && index < childCount()) {
         return cell(index);
     }
-    return Q_NULLPTR;
+    return nullptr;
 }
 
 // Table Cell
@@ -282,7 +282,7 @@ void* KItemListAccessibleCell::interface_cast(QAccessible::InterfaceType type)
     if (type == QAccessible::TableCellInterface) {
         return static_cast<QAccessibleTableCellInterface*>(this);
     }
-    return Q_NULLPTR;
+    return nullptr;
 }
 
 int KItemListAccessibleCell::columnExtent() const
@@ -398,7 +398,7 @@ void KItemListAccessibleCell::setText(QAccessible::Text, const QString&)
 
 QAccessibleInterface* KItemListAccessibleCell::child(int) const
 {
-    return Q_NULLPTR;
+    return nullptr;
 }
 
 bool KItemListAccessibleCell::isValid() const
@@ -408,7 +408,7 @@ bool KItemListAccessibleCell::isValid() const
 
 QAccessibleInterface* KItemListAccessibleCell::childAt(int, int) const
 {
-    return Q_NULLPTR;
+    return nullptr;
 }
 
 int KItemListAccessibleCell::childCount() const
@@ -434,7 +434,7 @@ int KItemListAccessibleCell::index() const
 
 QObject* KItemListAccessibleCell::object() const
 {
-    return 0;
+    return nullptr;
 }
 
 // Container Interface
@@ -465,7 +465,7 @@ QAccessibleInterface* KItemListContainerAccessible::child(int index) const
     if (index == 0) {
         return QAccessible::queryAccessibleInterface(container()->controller()->view());
     }
-    return Q_NULLPTR;
+    return nullptr;
 }
 
 const KItemListContainer* KItemListContainerAccessible::container() const
index afef2d5fe9488cc11ae9b4d98106724e6533633c..674d98ee631ef7f889fa307c31ab29eb7fa8dc9f 100644 (file)
@@ -36,44 +36,44 @@ class DOLPHIN_EXPORT KItemListViewAccessible: public QAccessibleObject, public Q
 {
 public:
     explicit KItemListViewAccessible(KItemListView* view);
-    ~KItemListViewAccessible();
+    ~KItemListViewAccessible() override;
 
-    void* interface_cast(QAccessible::InterfaceType type) Q_DECL_OVERRIDE;
+    void* interface_cast(QAccessible::InterfaceType type) override;
 
-    QAccessible::Role role() const Q_DECL_OVERRIDE;
-    QAccessible::State state() const Q_DECL_OVERRIDE;
-    QString text(QAccessible::Text t) const Q_DECL_OVERRIDE;
-    QRect rect() const Q_DECL_OVERRIDE;
+    QAccessible::Role role() const override;
+    QAccessible::State state() const override;
+    QString text(QAccessible::Text t) const override;
+    QRect rect() const override;
 
-    QAccessibleInterface* child(int index) const Q_DECL_OVERRIDE;
-    int childCount() const Q_DECL_OVERRIDE;
-    int indexOfChild(const QAccessibleInterface*) const Q_DECL_OVERRIDE;
-    QAccessibleInterface* childAt(int x, int y) const Q_DECL_OVERRIDE;
-    QAccessibleInterface* parent() const Q_DECL_OVERRIDE;
+    QAccessibleInterface* child(int index) const override;
+    int childCount() const override;
+    int indexOfChild(const QAccessibleInterface*) const override;
+    QAccessibleInterface* childAt(int x, int y) const override;
+    QAccessibleInterface* parent() const override;
 
     // Table interface
-    virtual QAccessibleInterface* cellAt(int row, int column) const Q_DECL_OVERRIDE;
-    virtual QAccessibleInterface* caption() const Q_DECL_OVERRIDE;
-    virtual QAccessibleInterface* summary() const Q_DECL_OVERRIDE;
-    virtual QString columnDescription(int column) const Q_DECL_OVERRIDE;
-    virtual QString rowDescription(int row) const Q_DECL_OVERRIDE;
-    virtual int columnCount() const Q_DECL_OVERRIDE;
-    virtual int rowCount() const Q_DECL_OVERRIDE;
+    QAccessibleInterface* cellAt(int row, int column) const override;
+    QAccessibleInterface* caption() const override;
+    QAccessibleInterface* summary() const override;
+    QString columnDescription(int column) const override;
+    QString rowDescription(int row) const override;
+    int columnCount() const override;
+    int rowCount() const override;
 
     // Selection
-    virtual int selectedCellCount() const Q_DECL_OVERRIDE;
-    virtual int selectedColumnCount() const Q_DECL_OVERRIDE;
-    virtual int selectedRowCount() const Q_DECL_OVERRIDE;
-    virtual QList<QAccessibleInterface*> selectedCells() const Q_DECL_OVERRIDE;
-    virtual QList<int> selectedColumns() const Q_DECL_OVERRIDE;
-    virtual QList<int> selectedRows() const Q_DECL_OVERRIDE;
-    virtual bool isColumnSelected(int column) const Q_DECL_OVERRIDE;
-    virtual bool isRowSelected(int row) const Q_DECL_OVERRIDE;
-    virtual bool selectRow(int row) Q_DECL_OVERRIDE;
-    virtual bool selectColumn(int column) Q_DECL_OVERRIDE;
-    virtual bool unselectRow(int row) Q_DECL_OVERRIDE;
-    virtual bool unselectColumn(int column) Q_DECL_OVERRIDE;
-    virtual void modelChange(QAccessibleTableModelChangeEvent*) Q_DECL_OVERRIDE;
+    int selectedCellCount() const override;
+    int selectedColumnCount() const override;
+    int selectedRowCount() const override;
+    QList<QAccessibleInterface*> selectedCells() const override;
+    QList<int> selectedColumns() const override;
+    QList<int> selectedRows() const override;
+    bool isColumnSelected(int column) const override;
+    bool isRowSelected(int row) const override;
+    bool selectRow(int row) override;
+    bool selectColumn(int column) override;
+    bool unselectRow(int row) override;
+    bool unselectColumn(int column) override;
+    void modelChange(QAccessibleTableModelChangeEvent*) override;
 
     KItemListView* view() const;
 
@@ -94,32 +94,32 @@ class DOLPHIN_EXPORT KItemListAccessibleCell: public QAccessibleInterface, publi
 public:
     KItemListAccessibleCell(KItemListView* view, int m_index);
 
-    void* interface_cast(QAccessible::InterfaceType type) Q_DECL_OVERRIDE;
-    QObject* object() const Q_DECL_OVERRIDE;
-    bool isValid() const Q_DECL_OVERRIDE;
-    QAccessible::Role role() const Q_DECL_OVERRIDE;
-    QAccessible::State state() const Q_DECL_OVERRIDE;
-    QRect rect() const Q_DECL_OVERRIDE;
-    QString text(QAccessible::Text t) const Q_DECL_OVERRIDE;
-    void setText(QAccessible::Text t, const QString& text) Q_DECL_OVERRIDE;
-
-    QAccessibleInterface* child(int index) const Q_DECL_OVERRIDE;
-    int childCount() const Q_DECL_OVERRIDE;
-    QAccessibleInterface* childAt(int x, int y) const Q_DECL_OVERRIDE;
-    int indexOfChild(const QAccessibleInterface*) const Q_DECL_OVERRIDE;
-
-    QAccessibleInterface* parent() const Q_DECL_OVERRIDE;
+    void* interface_cast(QAccessible::InterfaceType type) override;
+    QObject* object() const override;
+    bool isValid() const override;
+    QAccessible::Role role() const override;
+    QAccessible::State state() const override;
+    QRect rect() const override;
+    QString text(QAccessible::Text t) const override;
+    void setText(QAccessible::Text t, const QString& text) override;
+
+    QAccessibleInterface* child(int index) const override;
+    int childCount() const override;
+    QAccessibleInterface* childAt(int x, int y) const override;
+    int indexOfChild(const QAccessibleInterface*) const override;
+
+    QAccessibleInterface* parent() const override;
     bool isExpandable() const;
 
     // Cell Interface
-    virtual int columnExtent() const Q_DECL_OVERRIDE;
-    virtual QList<QAccessibleInterface*> columnHeaderCells() const Q_DECL_OVERRIDE;
-    virtual int columnIndex() const Q_DECL_OVERRIDE;
-    virtual int rowExtent() const Q_DECL_OVERRIDE;
-    virtual QList<QAccessibleInterface*> rowHeaderCells() const Q_DECL_OVERRIDE;
-    virtual int rowIndex() const Q_DECL_OVERRIDE;
-    virtual bool isSelected() const Q_DECL_OVERRIDE;
-    virtual QAccessibleInterface* table() const Q_DECL_OVERRIDE;
+    int columnExtent() const override;
+    QList<QAccessibleInterface*> columnHeaderCells() const override;
+    int columnIndex() const override;
+    int rowExtent() const override;
+    QList<QAccessibleInterface*> rowHeaderCells() const override;
+    int rowIndex() const override;
+    bool isSelected() const override;
+    QAccessibleInterface* table() const override;
 
     inline int index() const;
 
@@ -132,11 +132,11 @@ class DOLPHIN_EXPORT KItemListContainerAccessible : public QAccessibleWidget
 {
 public:
     explicit KItemListContainerAccessible(KItemListContainer* container);
-    virtual ~KItemListContainerAccessible();
+    ~KItemListContainerAccessible() override;
 
-    QAccessibleInterface* child(int index) const Q_DECL_OVERRIDE;
-    int childCount() const Q_DECL_OVERRIDE;
-    int indexOfChild(const QAccessibleInterface* child) const Q_DECL_OVERRIDE;
+    QAccessibleInterface* child(int index) const override;
+    int childCount() const override;
+    int indexOfChild(const QAccessibleInterface* child) const override;
 
 private:
     const KItemListContainer* container() const;
index 65fc911bd9b60f3ddd9628327da1ca423407e339..579d8b7a2c4c0913cfdc67cd321f6c822b13e2ba 100644 (file)
@@ -42,7 +42,7 @@ KItemListWidgetInformant::~KItemListWidgetInformant()
 }
 
 KItemListWidget::KItemListWidget(KItemListWidgetInformant* informant, QGraphicsItem* parent) :
-    QGraphicsWidget(parent, 0),
+    QGraphicsWidget(parent, nullptr),
     m_informant(informant),
     m_index(-1),
     m_selected(false),
@@ -56,9 +56,9 @@ KItemListWidget::KItemListWidget(KItemListWidgetInformant* informant, QGraphicsI
     m_styleOption(),
     m_siblingsInfo(),
     m_hoverOpacity(0),
-    m_hoverCache(0),
-    m_hoverAnimation(0),
-    m_selectionToggle(0),
+    m_hoverCache(nullptr),
+    m_hoverAnimation(nullptr),
+    m_selectionToggle(nullptr),
     m_editedRole()
 {
 }
@@ -72,7 +72,7 @@ void KItemListWidget::setIndex(int index)
 {
     if (m_index != index) {
         delete m_selectionToggle;
-        m_selectionToggle = 0;
+        m_selectionToggle = nullptr;
 
         if (m_hoverAnimation) {
             m_hoverAnimation->stop();
@@ -474,7 +474,7 @@ void KItemListWidget::slotHoverAnimationFinished()
 {
     if (!m_hovered && m_selectionToggle) {
         m_selectionToggle->deleteLater();
-        m_selectionToggle = 0;
+        m_selectionToggle = nullptr;
     }
 }
 
@@ -502,7 +502,7 @@ void KItemListWidget::setHoverOpacity(qreal opacity)
 
     if (m_hoverOpacity <= 0.0) {
         delete m_hoverCache;
-        m_hoverCache = 0;
+        m_hoverCache = nullptr;
     }
 
     update();
@@ -511,7 +511,7 @@ void KItemListWidget::setHoverOpacity(qreal opacity)
 void KItemListWidget::clearHoverCache()
 {
     delete m_hoverCache;
-    m_hoverCache = 0;
+    m_hoverCache = nullptr;
 }
 
 void KItemListWidget::drawItemStyleOption(QPainter* painter, QWidget* widget, QStyle::State styleState)
index d1ea7c9da4db056b5da689a1e2b09b003a62f810..06fea0e39120b1afadfe55f6230ce8a104ad4411 100644 (file)
@@ -69,7 +69,7 @@ class DOLPHIN_EXPORT KItemListWidget : public QGraphicsWidget
 
 public:
     KItemListWidget(KItemListWidgetInformant* informant, QGraphicsItem* parent);
-    virtual ~KItemListWidget();
+    ~KItemListWidget() override;
 
     void setIndex(int index);
     int index() const;
@@ -82,7 +82,7 @@ public:
      * to show the data of the custom model provided by KItemListWidget::data().
      * @reimp
      */
-    virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0) Q_DECL_OVERRIDE;
+    void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = nullptr) override;
 
     void setVisibleRoles(const QList<QByteArray>& roles);
     QList<QByteArray> visibleRoles() const;
@@ -142,7 +142,7 @@ public:
      *         or KItemListWidget::expansionToggleRect().
      * @reimp
      */
-    virtual bool contains(const QPointF& point) const override;
+    bool contains(const QPointF& point) const override;
 
     /**
      * @return Rectangle for the area that shows the icon.
@@ -186,7 +186,7 @@ public:
      * @return Pixmap that is used when dragging an item. Per default the current state of the
      *         widget is returned as pixmap.
      */
-    virtual QPixmap createDragPixmap(const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
+    virtual QPixmap createDragPixmap(const QStyleOptionGraphicsItem* option, QWidget* widget = nullptr);
 
 signals:
     void roleEditingCanceled(int index, const QByteArray& role, const QVariant& value);
@@ -203,7 +203,7 @@ protected:
     virtual void alternateBackgroundChanged(bool enabled);
     virtual void siblingsInformationChanged(const QBitArray& current, const QBitArray& previous);
     virtual void editedRoleChanged(const QByteArray& current, const QByteArray& previous);
-    virtual void resizeEvent(QGraphicsSceneResizeEvent* event) Q_DECL_OVERRIDE;
+    void resizeEvent(QGraphicsSceneResizeEvent* event) override;
 
     /**
      * @return The current opacity of the hover-animation. When implementing a custom painting-code for a hover-state
index d73468336b6dde6071b578fe703ee78a8a5d15d8..983b46960855622009ffd8f59afaf480c5731bd3 100644 (file)
@@ -126,7 +126,7 @@ int KItemModelBase::expandedParentsCount(int index) const
 QMimeData* KItemModelBase::createMimeData(const KItemSet& indexes) const
 {
     Q_UNUSED(indexes);
-    return 0;
+    return nullptr;
 }
 
 int KItemModelBase::indexForKeyboardSearch(const QString& text, int startFromIndex) const
index a7773ee3b36163e996939c7dd78f0dda3c760d2c..0aa6d187f4e28191b512483d10ae6bc01aba69bd 100644 (file)
@@ -55,9 +55,9 @@ class DOLPHIN_EXPORT KItemModelBase : public QObject
     Q_OBJECT
 
 public:
-    KItemModelBase(QObject* parent = 0);
-    explicit KItemModelBase(const QByteArray& sortRole, QObject* parent = 0);
-    virtual ~KItemModelBase();
+    KItemModelBase(QObject* parent = nullptr);
+    explicit KItemModelBase(const QByteArray& sortRole, QObject* parent = nullptr);
+    ~KItemModelBase() override;
 
     /** @return The number of items. */
     virtual int count() const = 0;
index f3fd258f93a5616578ebcfac8484fdbe5e4b06aa..d4d1fa2f91efd3da9cbd9eb9ac4f543356c21bfc 100644 (file)
@@ -25,7 +25,7 @@
 KStandardItem::KStandardItem(KStandardItem* parent) :
     m_parent(parent),
     m_children(),
-    m_model(0),
+    m_model(nullptr),
     m_data()
 {
 }
@@ -33,7 +33,7 @@ KStandardItem::KStandardItem(KStandardItem* parent) :
 KStandardItem::KStandardItem(const QString& text, KStandardItem* parent) :
     m_parent(parent),
     m_children(),
-    m_model(0),
+    m_model(nullptr),
     m_data()
 {
     setText(text);
@@ -42,7 +42,7 @@ KStandardItem::KStandardItem(const QString& text, KStandardItem* parent) :
 KStandardItem::KStandardItem(const QString& icon, const QString& text, KStandardItem* parent) :
     m_parent(parent),
     m_children(),
-    m_model(0),
+    m_model(nullptr),
     m_data()
 {
     setIcon(icon);
index 5bb2bb36f7bb5826c3d879e75531641ec6dac1b8..fec197c06ff34dbadbbf5a8b9d6f7da9ae33ed38 100644 (file)
@@ -40,9 +40,9 @@ class DOLPHIN_EXPORT KStandardItem
 {
 
 public:
-    explicit KStandardItem(KStandardItem* parent = 0);
-    explicit KStandardItem(const QString& text, KStandardItem* parent = 0);
-    KStandardItem(const QString& icon, const QString& text, KStandardItem* parent = 0);
+    explicit KStandardItem(KStandardItem* parent = nullptr);
+    explicit KStandardItem(const QString& text, KStandardItem* parent = nullptr);
+    KStandardItem(const QString& icon, const QString& text, KStandardItem* parent = nullptr);
     KStandardItem(const KStandardItem& item);
     virtual ~KStandardItem();
 
index f0eacfd49ab604d35013459b18a6c5f6b7ef4b86..36ab7772218aa7853f44441923805a0afd00b95e 100644 (file)
@@ -32,17 +32,17 @@ class DOLPHIN_EXPORT KStandardItemListGroupHeader : public KItemListGroupHeader
     Q_OBJECT
 
 public:
-    KStandardItemListGroupHeader(QGraphicsWidget* parent = 0);
-    virtual ~KStandardItemListGroupHeader();
+    KStandardItemListGroupHeader(QGraphicsWidget* parent = nullptr);
+    ~KStandardItemListGroupHeader() override;
 
-    virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0) Q_DECL_OVERRIDE;
+    void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = nullptr) override;
 
 protected:
-    virtual void paintRole(QPainter* painter, const QRectF& roleBounds, const QColor& color) Q_DECL_OVERRIDE;
-    virtual void paintSeparator(QPainter* painter, const QColor& color) Q_DECL_OVERRIDE;
-    virtual void roleChanged(const QByteArray &current, const QByteArray &previous) Q_DECL_OVERRIDE;
-    virtual void dataChanged(const QVariant& current, const QVariant& previous) Q_DECL_OVERRIDE;
-    virtual void resizeEvent(QGraphicsSceneResizeEvent* event) Q_DECL_OVERRIDE;
+    void paintRole(QPainter* painter, const QRectF& roleBounds, const QColor& color) override;
+    void paintSeparator(QPainter* painter, const QColor& color) override;
+    void roleChanged(const QByteArray &current, const QByteArray &previous) override;
+    void dataChanged(const QVariant& current, const QVariant& previous) override;
+    void resizeEvent(QGraphicsSceneResizeEvent* event) override;
 
 private:
     void updateCache();
index 2e4c7a0a0a05ab3cc0a112bad25b779e60414a79..6321a1d2e69611f8cfc602e7dc3f51eaa9779565 100644 (file)
@@ -52,22 +52,22 @@ public:
         DetailsLayout
     };
 
-    KStandardItemListView(QGraphicsWidget* parent = 0);
-    virtual ~KStandardItemListView();
+    KStandardItemListView(QGraphicsWidget* parent = nullptr);
+    ~KStandardItemListView() override;
 
     void setItemLayout(ItemLayout layout);
     ItemLayout itemLayout() const;
 
 protected:
-    virtual KItemListWidgetCreatorBase* defaultWidgetCreator() const Q_DECL_OVERRIDE;
-    virtual KItemListGroupHeaderCreatorBase* defaultGroupHeaderCreator() const Q_DECL_OVERRIDE;
-    virtual void initializeItemListWidget(KItemListWidget* item) Q_DECL_OVERRIDE;
-    virtual bool itemSizeHintUpdateRequired(const QSet<QByteArray>& changedRoles) const Q_DECL_OVERRIDE;
+    KItemListWidgetCreatorBase* defaultWidgetCreator() const override;
+    KItemListGroupHeaderCreatorBase* defaultGroupHeaderCreator() const override;
+    void initializeItemListWidget(KItemListWidget* item) override;
+    bool itemSizeHintUpdateRequired(const QSet<QByteArray>& changedRoles) const override;
     virtual bool itemLayoutSupportsItemExpanding(ItemLayout layout) const;
     virtual void onItemLayoutChanged(ItemLayout current, ItemLayout previous);
-    virtual void onScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous) Q_DECL_OVERRIDE;
-    virtual void onSupportsItemExpandingChanged(bool supportsExpanding) Q_DECL_OVERRIDE;
-    virtual void polishEvent() Q_DECL_OVERRIDE;
+    void onScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous) override;
+    void onSupportsItemExpandingChanged(bool supportsExpanding) override;
+    void polishEvent() override;
 
 private:
     void applyDefaultStyleOption(int iconSize, int padding, int horizontalMargin, int verticalMargin);
index 7d94a59f511c1bf3432c22730b63d20d58ae5229..82753761266fe54d45ec55e294ff6987a38f9ae2 100644 (file)
@@ -273,8 +273,8 @@ KStandardItemListWidget::KStandardItemListWidget(KItemListWidgetInformant* infor
     m_additionalInfoTextColor(),
     m_overlay(),
     m_rating(),
-    m_roleEditor(0),
-    m_oldRoleEditor(0)
+    m_roleEditor(nullptr),
+    m_oldRoleEditor(nullptr)
 {
 }
 
@@ -770,7 +770,7 @@ void KStandardItemListWidget::editedRoleChanged(const QByteArray& current, const
             }
             m_oldRoleEditor = m_roleEditor;
             m_roleEditor->hide();
-            m_roleEditor = 0;
+            m_roleEditor = nullptr;
         }
         return;
     }
@@ -998,7 +998,7 @@ void KStandardItemListWidget::updatePixmapCache()
 
     if (!m_overlay.isNull()) {
         QPainter painter(&m_pixmap);
-        painter.drawPixmap(0, m_pixmap.height() - m_overlay.height(), m_overlay);
+        painter.drawPixmap(0, (m_pixmap.height() - m_overlay.height()) / m_pixmap.devicePixelRatio(), m_overlay);
     }
 
     int scaledIconSize = 0;
@@ -1452,7 +1452,7 @@ void KStandardItemListWidget::closeRoleEditor()
     }
     m_oldRoleEditor = m_roleEditor;
     m_roleEditor->hide();
-    m_roleEditor = 0;
+    m_roleEditor = nullptr;
 }
 
 QPixmap KStandardItemListWidget::pixmapForIcon(const QString& name, const QStringList& overlays, int size, QIcon::Mode mode)
index cb7364795237daf1245d499161a62f6536a69270..b13c303bc173f43b151e1757c080eb6102f960ab 100644 (file)
@@ -36,13 +36,13 @@ class DOLPHIN_EXPORT KStandardItemListWidgetInformant : public KItemListWidgetIn
 {
 public:
     KStandardItemListWidgetInformant();
-    virtual ~KStandardItemListWidgetInformant();
+    ~KStandardItemListWidgetInformant() override;
 
-    virtual void calculateItemSizeHints(QVector<qreal>& logicalHeightHints, qreal& logicalWidthHint, const KItemListView* view) const Q_DECL_OVERRIDE;
+    void calculateItemSizeHints(QVector<qreal>& logicalHeightHints, qreal& logicalWidthHint, const KItemListView* view) const override;
 
-    virtual qreal preferredRoleColumnWidth(const QByteArray& role,
+    qreal preferredRoleColumnWidth(const QByteArray& role,
                                            int index,
-                                           const KItemListView* view) const Q_DECL_OVERRIDE;
+                                           const KItemListView* view) const override;
 protected:
     /**
      * @return The value of the "text" role. The default implementation returns
@@ -96,7 +96,7 @@ public:
     };
 
     KStandardItemListWidget(KItemListWidgetInformant* informant, QGraphicsItem* parent);
-    virtual ~KStandardItemListWidget();
+    ~KStandardItemListWidget() override;
 
     void setLayout(Layout layout);
     Layout layout() const;
@@ -104,15 +104,15 @@ public:
     void setSupportsItemExpanding(bool supportsItemExpanding);
     bool supportsItemExpanding() const;
 
-    virtual void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0) override;
+    void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = nullptr) override;
 
-    virtual QRectF iconRect() const Q_DECL_OVERRIDE;
-    virtual QRectF textRect() const Q_DECL_OVERRIDE;
-    virtual QRectF textFocusRect() const Q_DECL_OVERRIDE;
-    virtual QRectF selectionRect() const Q_DECL_OVERRIDE;
-    virtual QRectF expansionToggleRect() const Q_DECL_OVERRIDE;
-    virtual QRectF selectionToggleRect() const Q_DECL_OVERRIDE;
-    virtual QPixmap createDragPixmap(const QStyleOptionGraphicsItem* option, QWidget* widget = 0) Q_DECL_OVERRIDE;
+    QRectF iconRect() const override;
+    QRectF textRect() const override;
+    QRectF textFocusRect() const override;
+    QRectF selectionRect() const override;
+    QRectF expansionToggleRect() const override;
+    QRectF selectionToggleRect() const override;
+    QPixmap createDragPixmap(const QStyleOptionGraphicsItem* option, QWidget* widget = nullptr) override;
 
     static KItemListWidgetInformant* createInformant();
 
@@ -172,18 +172,18 @@ protected:
      */
     virtual int selectionLength(const QString& text) const;
 
-    virtual void dataChanged(const QHash<QByteArray, QVariant>& current, const QSet<QByteArray>& roles = QSet<QByteArray>()) Q_DECL_OVERRIDE;
-    virtual void visibleRolesChanged(const QList<QByteArray>& current, const QList<QByteArray>& previous) Q_DECL_OVERRIDE;
-    virtual void columnWidthChanged(const QByteArray& role, qreal current, qreal previous) Q_DECL_OVERRIDE;
-    virtual void styleOptionChanged(const KItemListStyleOption& current, const KItemListStyleOption& previous) Q_DECL_OVERRIDE;
-    virtual void hoveredChanged(bool hovered) Q_DECL_OVERRIDE;
-    virtual void selectedChanged(bool selected) Q_DECL_OVERRIDE;
-    virtual void siblingsInformationChanged(const QBitArray& current, const QBitArray& previous) Q_DECL_OVERRIDE;
-    virtual void editedRoleChanged(const QByteArray& current, const QByteArray& previous) Q_DECL_OVERRIDE;
-    virtual void resizeEvent(QGraphicsSceneResizeEvent* event) Q_DECL_OVERRIDE;
-    virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
-    virtual void hideEvent(QHideEvent* event) Q_DECL_OVERRIDE;
-    bool event(QEvent *event) Q_DECL_OVERRIDE;
+    void dataChanged(const QHash<QByteArray, QVariant>& current, const QSet<QByteArray>& roles = QSet<QByteArray>()) override;
+    void visibleRolesChanged(const QList<QByteArray>& current, const QList<QByteArray>& previous) override;
+    void columnWidthChanged(const QByteArray& role, qreal current, qreal previous) override;
+    void styleOptionChanged(const KItemListStyleOption& current, const KItemListStyleOption& previous) override;
+    void hoveredChanged(bool hovered) override;
+    void selectedChanged(bool selected) override;
+    void siblingsInformationChanged(const QBitArray& current, const QBitArray& previous) override;
+    void editedRoleChanged(const QByteArray& current, const QByteArray& previous) override;
+    void resizeEvent(QGraphicsSceneResizeEvent* event) override;
+    void showEvent(QShowEvent* event) override;
+    void hideEvent(QHideEvent* event) override;
+    bool event(QEvent *event) override;
 
 public slots:
     void finishRoleEditing();
index 25288e50f1de2b0d41e0f4859c23a37d276dbb58..0779614c3eddd109c928d7112a03c41ddd9af4dc 100644 (file)
@@ -89,7 +89,7 @@ void KStandardItemModel::changeItem(int index, KStandardItem* item)
 
     m_indexesForItems.remove(oldItem);
     delete oldItem;
-    oldItem = 0;
+    oldItem = nullptr;
 
     m_items[index] = item;
     m_indexesForItems.insert(item, index);
@@ -114,7 +114,7 @@ void KStandardItemModel::removeItem(int index)
         onItemRemoved(index, item);
 
         delete item;
-        item = 0;
+        item = nullptr;
 
         emit itemsRemoved(KItemRangeList() << KItemRange(index, 1));
 
@@ -134,7 +134,7 @@ void KStandardItemModel::clear()
 KStandardItem* KStandardItemModel::item(int index) const
 {
     if (index < 0 || index >= m_items.count()) {
-        return 0;
+        return nullptr;
     }
     return m_items[index];
 }
@@ -178,7 +178,7 @@ bool KStandardItemModel::setData(int index, const QHash<QByteArray, QVariant>& v
 QMimeData* KStandardItemModel::createMimeData(const KItemSet& indexes) const
 {
     Q_UNUSED(indexes);
-    return 0;
+    return nullptr;
 }
 
 int KStandardItemModel::indexForKeyboardSearch(const QString& text, int startFromIndex) const
index 58c5a5d88dafcc932d00f790a478668542795eea..288b5b84f7097ec42216c897c88289bf25cdf1d0 100644 (file)
@@ -40,8 +40,8 @@ class DOLPHIN_EXPORT KStandardItemModel : public KItemModelBase
     Q_OBJECT
 
 public:
-    explicit KStandardItemModel(QObject* parent = 0);
-    virtual ~KStandardItemModel();
+    explicit KStandardItemModel(QObject* parent = nullptr);
+    ~KStandardItemModel() override;
 
     /**
      * Inserts the item \a item at the index \a index. If the index
@@ -69,14 +69,14 @@ public:
      */
     void appendItem(KStandardItem* item);
 
-    virtual int count() const Q_DECL_OVERRIDE;
-    virtual QHash<QByteArray, QVariant> data(int index) const Q_DECL_OVERRIDE;
-    virtual bool setData(int index, const QHash<QByteArray, QVariant>& values) Q_DECL_OVERRIDE;
-    virtual QMimeData* createMimeData(const KItemSet& indexes) const Q_DECL_OVERRIDE;
-    virtual int indexForKeyboardSearch(const QString& text, int startFromIndex = 0) const Q_DECL_OVERRIDE;
-    virtual bool supportsDropping(int index) const Q_DECL_OVERRIDE;
-    virtual QString roleDescription(const QByteArray& role) const Q_DECL_OVERRIDE;
-    virtual QList<QPair<int, QVariant> > groups() const Q_DECL_OVERRIDE;
+    int count() const override;
+    QHash<QByteArray, QVariant> data(int index) const override;
+    bool setData(int index, const QHash<QByteArray, QVariant>& values) override;
+    QMimeData* createMimeData(const KItemSet& indexes) const override;
+    int indexForKeyboardSearch(const QString& text, int startFromIndex = 0) const override;
+    bool supportsDropping(int index) const override;
+    QString roleDescription(const QByteArray& role) const override;
+    QList<QPair<int, QVariant> > groups() const override;
 
     virtual void clear();
 protected:
index 314c2f06bcd23c48a050466063fb7d812073aefc..53fc0b3b9cac1d95540756cdeb4ed706ede102ee 100644 (file)
@@ -148,6 +148,7 @@ KBalooRolesProvider::KBalooRolesProvider() :
         { "lineCount",     "lineCount" },
         { "width",         "imageSize" },
         { "height",        "imageSize" },
+        { "imageDateTime",   "imageDateTime"},
         { "nexif.orientation", "orientation", },
         { "artist",     "artist" },
         { "genre",     "genre"  },
index af7312ad270089999bc29164d3837aab9716a85c..90716173c5d1852fff097b61f00140d4d5088aec 100644 (file)
@@ -30,9 +30,9 @@ KDirectoryContentsCounter::KDirectoryContentsCounter(KFileItemModel* model, QObj
     QObject(parent),
     m_model(model),
     m_queue(),
-    m_worker(0),
+    m_worker(nullptr),
     m_workerIsBusy(false),
-    m_dirWatcher(0),
+    m_dirWatcher(nullptr),
     m_watchedDirs()
 {
     connect(m_model, &KFileItemModel::itemsRemoved,
@@ -70,7 +70,7 @@ KDirectoryContentsCounter::~KDirectoryContentsCounter()
         m_workerThread->quit();
         m_workerThread->wait();
         delete m_workerThread;
-        m_workerThread = 0;
+        m_workerThread = nullptr;
 
         // The worker thread has finished running now, so it's safe to delete
         // m_worker. deleteLater() would not work at all because the event loop
@@ -180,5 +180,5 @@ void KDirectoryContentsCounter::startWorker(const QString& path)
     }
 }
 
-QThread* KDirectoryContentsCounter::m_workerThread = 0;
+QThread* KDirectoryContentsCounter::m_workerThread = nullptr;
 int KDirectoryContentsCounter::m_workersCount = 0;
index 988208e02788746a8d222068d25de64d587ac9d6..977765ab72f1b37c7c2a72410155e43aaa7fee06 100644 (file)
@@ -35,8 +35,8 @@ class KDirectoryContentsCounter : public QObject
     Q_OBJECT
 
 public:
-    explicit KDirectoryContentsCounter(KFileItemModel* model, QObject* parent = 0);
-    ~KDirectoryContentsCounter();
+    explicit KDirectoryContentsCounter(KFileItemModel* model, QObject* parent = nullptr);
+    ~KDirectoryContentsCounter() override;
 
     /**
      * Requests the number of items inside the directory \a path. The actual
index 47fbb5dd51e7916e87400d2ba2b4dbee797dad94..79e134724b0298ea6e5693336078cefd0dabd3e2 100644 (file)
@@ -59,7 +59,7 @@ int KDirectoryContentsCounterWorker::subItemsCount(const QString& path, Options
     DIR* dir = ::opendir(QFile::encodeName(path));
     if (dir) {  // krazy:exclude=syscalls
         count = 0;
-        struct dirent *dirEntry = 0;
+        struct dirent *dirEntry = nullptr;
         while ((dirEntry = ::readdir(dir))) {
             if (dirEntry->d_name[0] == '.') {
                 if (dirEntry->d_name[1] == '\0' || !countHiddenFiles) {
index b2e31ef0f838f74a8bd979f77fca6b3c31ac4dff..2460a0e1ff132d28300494b37c56cbb9f6f8e6d4 100644 (file)
@@ -37,7 +37,7 @@ public:
     };
     Q_DECLARE_FLAGS(Options, Option)
 
-    explicit KDirectoryContentsCounterWorker(QObject* parent = 0);
+    explicit KDirectoryContentsCounterWorker(QObject* parent = nullptr);
 
     /**
      * Counts the items inside the directory \a path using the options
index d27869dffd31a64c75a6b69353db379944eeab8e..31e6c6198693e958e6e26503d9880626e2515fb8 100644 (file)
@@ -74,7 +74,7 @@ void KFileItemClipboard::updateCutItems()
 }
 
 KFileItemClipboard::KFileItemClipboard() :
-    QObject(0),
+    QObject(nullptr),
     m_cutItems()
 {
     updateCutItems();
index 3ee50d6610d3ee2acd9d152c641c182827bc1135..5b5ab1eec609eca4e1aee07c7a567dfa13e8a22d 100644 (file)
@@ -46,7 +46,7 @@ signals:
     void cutItemsChanged();
 
 protected:
-    virtual ~KFileItemClipboard();
+    ~KFileItemClipboard() override;
 
 private slots:
     void updateCutItems();
index 778625573a1053d230b1fa8f20ffba7d641ea3e4..eeeba11b2683db5c41f6fa90dee332e1c5739d3d 100644 (file)
@@ -24,7 +24,7 @@
 KFileItemModelDirLister::KFileItemModelDirLister(QObject* parent) :
     KDirLister(parent)
 {
-    setAutoErrorHandlingEnabled(false, 0);
+    setAutoErrorHandlingEnabled(false, nullptr);
 }
 
 KFileItemModelDirLister::~KFileItemModelDirLister()
index 5aa2b63031cc7ae12d78a74725097ad5674ec87b..c8b670f713a8f17fcf32e5afc36d8e8a1d9c5361 100644 (file)
@@ -34,8 +34,8 @@ class DOLPHIN_EXPORT KFileItemModelDirLister : public KDirLister
     Q_OBJECT
 
 public:
-    KFileItemModelDirLister(QObject* parent = 0);
-    virtual ~KFileItemModelDirLister();
+    KFileItemModelDirLister(QObject* parent = nullptr);
+    ~KFileItemModelDirLister() override;
 
 signals:
     /** Is emitted whenever an error has occurred. */
@@ -48,7 +48,7 @@ signals:
     void urlIsFileError(const QUrl& url);
 
 protected:
-    void handleError(KIO::Job* job) Q_DECL_OVERRIDE;
+    void handleError(KIO::Job* job) override;
 };
 
 #endif
index 6c6f94ffab016fa6f0816e17a3143ec26e6f4da6..a388a242c80d64aa2ff5598caadaa9670df14f7c 100644 (file)
@@ -26,7 +26,7 @@
 
 KFileItemModelFilter::KFileItemModelFilter() :
     m_useRegExp(false),
-    m_regExp(0),
+    m_regExp(nullptr),
     m_lowerCasePattern(),
     m_pattern()
 {
@@ -35,7 +35,7 @@ KFileItemModelFilter::KFileItemModelFilter() :
 KFileItemModelFilter::~KFileItemModelFilter()
 {
     delete m_regExp;
-    m_regExp = 0;
+    m_regExp = nullptr;
 }
 
 void KFileItemModelFilter::setPattern(const QString& filter)
index cc11e19da3ddb384f1c97296566bbae03d8efbbc..4092ec523ecd349c9059250f69b7d924d1d5bd1a 100644 (file)
@@ -30,7 +30,7 @@
 KItemListHeaderWidget::KItemListHeaderWidget(QGraphicsWidget* parent) :
     QGraphicsWidget(parent),
     m_automaticColumnResizing(true),
-    m_model(0),
+    m_model(nullptr),
     m_offset(0),
     m_columns(),
     m_columnWidths(),
index 2342b4907fcc4f08c354dfe82f4a3ae9ef9ae8a5..6d0974f9798f782e3a766f4005c17e1d4e331b32 100644 (file)
@@ -38,8 +38,8 @@ class DOLPHIN_EXPORT KItemListHeaderWidget : public QGraphicsWidget
     Q_OBJECT
 
 public:
-    KItemListHeaderWidget(QGraphicsWidget* parent = 0);
-    virtual ~KItemListHeaderWidget();
+    KItemListHeaderWidget(QGraphicsWidget* parent = nullptr);
+    ~KItemListHeaderWidget() override;
 
     void setModel(KItemModelBase* model);
     KItemModelBase* model() const;
@@ -64,7 +64,7 @@ public:
 
     qreal minimumColumnWidth() const;
 
-    void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0) Q_DECL_OVERRIDE;
+    void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = nullptr) override;
 
 signals:
     /**
@@ -104,13 +104,13 @@ signals:
     void sortRoleChanged(const QByteArray& current, const QByteArray& previous);
 
 protected:
-    void mousePressEvent(QGraphicsSceneMouseEvent* event) Q_DECL_OVERRIDE;
-    void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) Q_DECL_OVERRIDE;
-    void mouseMoveEvent(QGraphicsSceneMouseEvent* event) Q_DECL_OVERRIDE;
-    void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) Q_DECL_OVERRIDE;
-    void hoverEnterEvent(QGraphicsSceneHoverEvent* event) Q_DECL_OVERRIDE;
-    void hoverLeaveEvent(QGraphicsSceneHoverEvent* event) Q_DECL_OVERRIDE;
-    void hoverMoveEvent(QGraphicsSceneHoverEvent* event) Q_DECL_OVERRIDE;
+    void mousePressEvent(QGraphicsSceneMouseEvent* event) override;
+    void mouseReleaseEvent(QGraphicsSceneMouseEvent* event) override;
+    void mouseMoveEvent(QGraphicsSceneMouseEvent* event) override;
+    void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) override;
+    void hoverEnterEvent(QGraphicsSceneHoverEvent* event) override;
+    void hoverLeaveEvent(QGraphicsSceneHoverEvent* event) override;
+    void hoverMoveEvent(QGraphicsSceneHoverEvent* event) override;
 
 private slots:
     void slotSortRoleChanged(const QByteArray& current, const QByteArray& previous);
@@ -121,7 +121,7 @@ private:
                    const QByteArray& role,
                    const QRectF& rect,
                    int orderIndex,
-                   QWidget* widget = 0) const;
+                   QWidget* widget = nullptr) const;
 
     void updatePressedRoleIndex(const QPointF& pos);
     void updateHoveredRoleIndex(const QPointF& pos);
index 2a14ca470456fffc48e6537671f12f1514d7afea..02dedefca0a31d84ab221b6cc5563a94e8763d1d 100644 (file)
@@ -41,8 +41,8 @@ class DOLPHIN_EXPORT KItemListKeyboardSearchManager : public QObject
 
 public:
 
-    KItemListKeyboardSearchManager(QObject* parent = 0);
-    virtual ~KItemListKeyboardSearchManager();
+    KItemListKeyboardSearchManager(QObject* parent = nullptr);
+    ~KItemListKeyboardSearchManager() override;
 
     /**
      * Add \a keys to the text buffer used for searching.
index f889ea4f4ff601275636be1f0a658d02166eaf22..7285d62f7788e8767d772e2860dd1fdd936767d3 100644 (file)
@@ -39,20 +39,20 @@ class DOLPHIN_EXPORT KItemListRoleEditor : public KTextEdit
 
 public:
     explicit KItemListRoleEditor(QWidget* parent);
-    virtual ~KItemListRoleEditor();
+    ~KItemListRoleEditor() override;
 
     void setRole(const QByteArray& role);
     QByteArray role() const;
 
-    bool eventFilter(QObject* watched, QEvent* event) Q_DECL_OVERRIDE;
+    bool eventFilter(QObject* watched, QEvent* event) override;
 
 signals:
     void roleEditingFinished(const QByteArray& role, const QVariant& value);
     void roleEditingCanceled(const QByteArray& role, const QVariant& value);
 
 protected:
-    bool event(QEvent* event) Q_DECL_OVERRIDE;
-    void keyPressEvent(QKeyEvent* event) Q_DECL_OVERRIDE;
+    bool event(QEvent* event) override;
+    void keyPressEvent(QKeyEvent* event) override;
 
 private slots:
     /**
index b47c30c1fab00bb856b80710319a11986629c282..eaef5917334fb5971bfe9eb6477c5c898abdcd53 100644 (file)
@@ -32,8 +32,8 @@ class DOLPHIN_EXPORT KItemListRubberBand : public QObject
     Q_OBJECT
 
 public:
-    explicit KItemListRubberBand(QObject* parent = 0);
-    virtual ~KItemListRubberBand();
+    explicit KItemListRubberBand(QObject* parent = nullptr);
+    ~KItemListRubberBand() override;
 
     void setStartPosition(const QPointF& pos);
     QPointF startPosition() const;
index 9031c870f8c6a8032b74b81b6420c25add5fa716..25f97ee0201ada1ab9c017f70de9e3cad4cd6a47 100644 (file)
@@ -24,7 +24,7 @@
 
 
 KItemListSelectionToggle::KItemListSelectionToggle(QGraphicsItem* parent) :
-    QGraphicsWidget(parent, 0),
+    QGraphicsWidget(parent, nullptr),
     m_checked(false),
     m_hovered(false)
 {
index e3f5bb63c87a06fd6e5bca20a3605885570d5e5b..a10995372ea06fa37d0c503f36df646735cf5961 100644 (file)
@@ -35,17 +35,17 @@ class DOLPHIN_EXPORT KItemListSelectionToggle : public QGraphicsWidget
 
 public:
     KItemListSelectionToggle(QGraphicsItem* parent);
-    virtual ~KItemListSelectionToggle();
+    ~KItemListSelectionToggle() override;
 
     void setChecked(bool checked);
     bool isChecked() const;
 
     void setHovered(bool hovered);
 
-    void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0) Q_DECL_OVERRIDE;
+    void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = nullptr) override;
 
 protected:
-    void resizeEvent(QGraphicsSceneResizeEvent* event) Q_DECL_OVERRIDE;
+    void resizeEvent(QGraphicsSceneResizeEvent* event) override;
 
 private:
     void updatePixmap();
index 02f1865b349c80caa7fd5a2f32b8301f32794b8d..5c121c6670d8fbba2981d3a6c9e504acbecbda70 100644 (file)
@@ -26,6 +26,7 @@ KItemListSizeHintResolver::KItemListSizeHintResolver(const KItemListView* itemLi
     m_logicalHeightHintCache(),
     m_logicalWidthHint(0.0),
     m_logicalHeightHint(0.0),
+    m_minHeightHint(0.0),
     m_needsResolving(false)
 {
 }
@@ -40,6 +41,12 @@ QSizeF KItemListSizeHintResolver::maxSizeHint()
     return QSizeF(m_logicalWidthHint, m_logicalHeightHint);
 }
 
+QSizeF KItemListSizeHintResolver::minSizeHint()
+{
+    updateCache();
+    return QSizeF(m_logicalWidthHint, m_minHeightHint);
+}
+
 QSizeF KItemListSizeHintResolver::sizeHint(int index)
 {
     updateCache();
@@ -161,6 +168,7 @@ void KItemListSizeHintResolver::updateCache()
             m_logicalHeightHint = 0.0;
         } else {
             m_logicalHeightHint = *std::max_element(m_logicalHeightHintCache.begin(), m_logicalHeightHintCache.end());
+            m_minHeightHint = *std::min_element(m_logicalHeightHintCache.begin(), m_logicalHeightHintCache.end());
         }
         m_needsResolving = false;
     }
index 841e9ca1001adcee51c1e825c62df6dbb0755cf4..fa92b8682221bb53962a192de1c90275b5d3eadf 100644 (file)
@@ -37,6 +37,7 @@ public:
     KItemListSizeHintResolver(const KItemListView* itemListView);
     virtual ~KItemListSizeHintResolver();
     QSizeF maxSizeHint();
+    QSizeF minSizeHint();
     QSizeF sizeHint(int index);
 
     void itemsInserted(const KItemRangeList& itemRanges);
@@ -52,6 +53,7 @@ private:
     mutable QVector<qreal> m_logicalHeightHintCache;
     mutable qreal m_logicalWidthHint;
     mutable qreal m_logicalHeightHint;
+    mutable qreal m_minHeightHint;
     bool m_needsResolving;
 };
 
index 6bfdba4c9ae5fbd911716e96c136685e7a5ee22e..77a842838f3350f3d79e98b636b8d11eb7001f43 100644 (file)
@@ -32,11 +32,17 @@ KItemListSmoothScroller::KItemListSmoothScroller(QScrollBar* scrollBar,
     m_scrollBarPressed(false),
     m_smoothScrolling(true),
     m_scrollBar(scrollBar),
-    m_animation(0)
+    m_animation(nullptr)
 {
     m_animation = new QPropertyAnimation(this);
-    const int duration = m_scrollBar->style()->styleHint(QStyle::SH_Widget_Animate, nullptr, m_scrollBar) ? 100 : 1;
-    m_animation->setDuration(duration);
+#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
+    const int animationDuration = m_scrollBar->style()->styleHint(QStyle::SH_Widget_Animation_Duration, nullptr, m_scrollBar);
+    const bool animationEnabled = (animationDuration > 0);
+ #else
+    const int animationDuration = 100;
+    const bool animationEnabled = m_scrollBar->style()->styleHint(QStyle::SH_Widget_Animate, nullptr, m_scrollBar);
+#endif
+    m_animation->setDuration(animationEnabled ? animationDuration : 1);
     connect(m_animation, &QPropertyAnimation::stateChanged,
             this, &KItemListSmoothScroller::slotAnimationStateChanged);
 
index 7d01a6b62ce269253cb4df0b2e61375c78c8950a..a5aca82e625ce51b4195b4eef5ea0f3ee975d82b 100644 (file)
@@ -39,8 +39,8 @@ class DOLPHIN_EXPORT KItemListSmoothScroller : public QObject
 
 public:
     explicit KItemListSmoothScroller(QScrollBar* scrollBar,
-                                     QObject* parent = 0);
-    virtual ~KItemListSmoothScroller();
+                                     QObject* parent = nullptr);
+    ~KItemListSmoothScroller() override;
 
     void setScrollBar(QScrollBar* scrollBar);
     QScrollBar* scrollBar() const;
@@ -83,7 +83,7 @@ public:
     void handleWheelEvent(QWheelEvent* event);
 
 protected:
-    bool eventFilter(QObject* obj, QEvent* event) Q_DECL_OVERRIDE;
+    bool eventFilter(QObject* obj, QEvent* event) override;
 
 private slots:
     void slotAnimationStateChanged(QAbstractAnimation::State newState,
index 67ad192c6ecdadd689749d7a13d7694968f1bf7a..89b3452108259adb759b756c728a24e9cd1fff60 100644 (file)
@@ -116,7 +116,7 @@ void KItemListViewAnimation::start(QGraphicsWidget* widget, AnimationType type,
 {
     stop(widget, type);
 
-    QPropertyAnimation* propertyAnim = 0;
+    QPropertyAnimation* propertyAnim = nullptr;
     const int animationDuration = widget->style()->styleHint(QStyle::SH_Widget_Animate) ? 200 : 1;
 
     switch (type) {
index 06c81c9b873d7d3f1bf9fa88bb9de87070371733..ba3a33dc923493c257b0ce16d46343c7ca10dfab 100644 (file)
@@ -48,8 +48,8 @@ public:
         ResizeAnimation
     };
 
-    KItemListViewAnimation(QObject* parent = 0);
-    virtual ~KItemListViewAnimation();
+    KItemListViewAnimation(QObject* parent = nullptr);
+    ~KItemListViewAnimation() override;
 
     void setScrollOrientation(Qt::Orientation orientation);
     Qt::Orientation scrollOrientation() const;
index d54457908543be3cef192367d0d3b69baa5df1da..ca39426446a390e7cf0f8c9f08dbf55cd6ad1226 100644 (file)
@@ -35,7 +35,7 @@ KItemListViewLayouter::KItemListViewLayouter(KItemListSizeHintResolver* sizeHint
     m_itemSize(128, 128),
     m_itemMargin(),
     m_headerHeight(0),
-    m_model(0),
+    m_model(nullptr),
     m_sizeHintResolver(sizeHintResolver),
     m_scrollOffset(0),
     m_maximumScrollOffset(0),
index 3f1cf68d45d7436101403133f66bfaecf97789d0..2116f8405c5b5ad8570565ad314a1bbd62ff4d66 100644 (file)
@@ -50,8 +50,8 @@ class DOLPHIN_EXPORT KItemListViewLayouter : public QObject
     Q_OBJECT
 
 public:
-    KItemListViewLayouter(KItemListSizeHintResolver* sizeHintResolver, QObject* parent = 0);
-    virtual ~KItemListViewLayouter();
+    KItemListViewLayouter(KItemListSizeHintResolver* sizeHintResolver, QObject* parent = nullptr);
+    ~KItemListViewLayouter() override;
 
     void setScrollOrientation(Qt::Orientation orientation);
     Qt::Orientation scrollOrientation() const;
index 2278762e342be97eb2c62f80b0c955be72df7a9e..5a4595c4a96ba4010db7785c04673bc299b5a64d 100644 (file)
@@ -31,10 +31,10 @@ class FoldersItemListWidget : public KFileItemListWidget
 
 public:
     FoldersItemListWidget(KItemListWidgetInformant* informant, QGraphicsItem* parent);
-    virtual ~FoldersItemListWidget();
+    ~FoldersItemListWidget() override;
 
 protected:
-    virtual QPalette::ColorRole normalTextColorRole() const Q_DECL_OVERRIDE;
+    QPalette::ColorRole normalTextColorRole() const override;
 };
 
 #endif
index 3b27dd3dda490c0a9cacf4548877a41b57f71cf9..f67c19cbba3c020f8637a7b5138af0801f6f4bd3 100644 (file)
@@ -40,7 +40,7 @@ class FoldersPanel : public Panel
 
 public:
     explicit FoldersPanel(QWidget* parent = nullptr);
-    virtual ~FoldersPanel();
+    ~FoldersPanel() override;
 
     void setShowHiddenFiles(bool show);
     void setLimitFoldersPanelToHome(bool enable);
@@ -59,13 +59,13 @@ signals:
 
 protected:
     /** @see Panel::urlChanged() */
-    virtual bool urlChanged() Q_DECL_OVERRIDE;
+    bool urlChanged() override;
 
     /** @see QWidget::showEvent() */
-    virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
+    void showEvent(QShowEvent* event) override;
 
     /** @see QWidget::keyPressEvent() */
-    virtual void keyPressEvent(QKeyEvent* event) Q_DECL_OVERRIDE;
+    void keyPressEvent(QKeyEvent* event) override;
 
 private slots:
     void slotItemActivated(int index);
index 93ddd7aef9cfd95379d174576c9b0c717aa9040f..3e61c494126f873324ab41ed935688f3fca01cf1 100644 (file)
@@ -45,7 +45,7 @@ public:
     TreeViewContextMenu(FoldersPanel* parent,
                         const KFileItem& fileInfo);
 
-    virtual ~TreeViewContextMenu();
+    ~TreeViewContextMenu() override;
 
     /** Opens the context menu modal. */
     void open();
index 13562ef5ceb78a95c56b93fcdc00cc3eeb5fe165..8ca9ef6febf50033f4eafd0de85df6589ee97760 100644 (file)
@@ -43,8 +43,8 @@ class FileMetaDataConfigurationDialog : public QDialog
     Q_OBJECT
 
 public:
-    explicit FileMetaDataConfigurationDialog(QWidget* parent = 0);
-    virtual ~FileMetaDataConfigurationDialog();
+    explicit FileMetaDataConfigurationDialog(QWidget* parent = nullptr);
+    ~FileMetaDataConfigurationDialog() override;
 
     /**
      * Sets the items, for which the visibility of the meta data should
index 850d94d92234ace1a7b1b8fe4f758d1647a2b2ac..ac987c9b4426a77cb791833ecc02240bb0cae825 100644 (file)
@@ -198,7 +198,7 @@ void InformationPanel::showItemInfo()
 
 void InformationPanel::slotFolderStatFinished(KJob* job)
 {
-    m_folderStatJob = 0;
+    m_folderStatJob = nullptr;
     const KIO::UDSEntry entry = static_cast<KIO::StatJob*>(job)->statResult();
     m_content->showItem(KFileItem(entry, m_shownUrl));
 }
@@ -296,7 +296,7 @@ void InformationPanel::slotLeftDirectory(const QString& directory)
 void InformationPanel::cancelRequest()
 {
     delete m_folderStatJob;
-    m_folderStatJob = 0;
+    m_folderStatJob = nullptr;
 
     m_infoTimer->stop();
     m_resetUrlTimer->stop();
index a698e544fbb51c9f5cec03012dbd39fe8fb74de9..89a1bc3d24099911fbea12606c2b35346dd5fc97 100644 (file)
@@ -37,7 +37,7 @@ class InformationPanel : public Panel
 
 public:
     explicit InformationPanel(QWidget* parent = nullptr);
-    virtual ~InformationPanel();
+    ~InformationPanel() override;
 
 signals:
     void urlActivated(const QUrl& url);
@@ -59,16 +59,16 @@ public slots:
 
 protected:
     /** @see Panel::urlChanged() */
-    virtual bool urlChanged() Q_DECL_OVERRIDE;
+    bool urlChanged() override;
 
     /** @see QWidget::showEvent() */
-    virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
+    void showEvent(QShowEvent* event) override;
 
     /** @see QWidget::resizeEvent() */
-    virtual void resizeEvent(QResizeEvent* event) Q_DECL_OVERRIDE;
+    void resizeEvent(QResizeEvent* event) override;
 
     /** @see QWidget::contextMenuEvent() */
-    virtual void contextMenuEvent(QContextMenuEvent* event) Q_DECL_OVERRIDE;
+    void contextMenuEvent(QContextMenuEvent* event) override;
 
 private slots:
     /**
index 3c48a2296be4fee51b8a529679ff346c2e225567..2e279dc620ed2c9df82642c3307632463da6de5e 100644 (file)
 InformationPanelContent::InformationPanelContent(QWidget* parent) :
     QWidget(parent),
     m_item(),
-    m_previewJob(0),
-    m_outdatedPreviewTimer(0),
-    m_preview(0),
-    m_phononWidget(0),
-    m_nameLabel(0),
-    m_metaDataWidget(0),
-    m_metaDataArea(0),
-    m_placesItemModel(0)
+    m_previewJob(nullptr),
+    m_outdatedPreviewTimer(nullptr),
+    m_preview(nullptr),
+    m_phononWidget(nullptr),
+    m_nameLabel(nullptr),
+    m_metaDataWidget(nullptr),
+    m_metaDataArea(nullptr),
+    m_placesItemModel(nullptr)
 {
     parent->installEventFilter(this);
 
index 533e9de3b559628cc036c6ea05b6bcdb4be44bf2..8b143af1d6f72c903f9b7b1da0e71ab31ef8b5c9 100644 (file)
@@ -57,8 +57,8 @@ class InformationPanelContent : public QWidget
     Q_OBJECT
 
 public:
-    explicit InformationPanelContent(QWidget* parent = 0);
-    virtual ~InformationPanelContent();
+    explicit InformationPanelContent(QWidget* parent = nullptr);
+    ~InformationPanelContent() override;
 
     /**
      * Shows the meta information for the item \p item.
@@ -85,7 +85,7 @@ signals:
 
 protected:
     /** @see QObject::eventFilter() */
-    virtual bool eventFilter(QObject* obj, QEvent* event) Q_DECL_OVERRIDE;
+    bool eventFilter(QObject* obj, QEvent* event) override;
 
 private slots:
     /**
index 3a3268cb3da3726332e66f5ff644019da466139d..a71a77897f592cf540f432607637c65fde0edd0d 100644 (file)
@@ -52,7 +52,7 @@ class EmbeddedVideoPlayer : public Phonon::VideoWidget
             updateGeometry();
         }
 
-        QSize sizeHint() const Q_DECL_OVERRIDE
+        QSize sizeHint() const override
         {
             return m_sizeHint.isValid() ? m_sizeHint : Phonon::VideoWidget::sizeHint();
         }
index 837a66888150234f8ec3c3f08b9a75b5612b2521..947f0cdac2c7588cc5030f22d1612663358638eb 100644 (file)
@@ -43,7 +43,7 @@ class PhononWidget : public QWidget
 {
     Q_OBJECT
     public:
-        PhononWidget(QWidget *parent = 0);
+        PhononWidget(QWidget *parent = nullptr);
 
         void setUrl(const QUrl &url);
         QUrl url() const;
@@ -63,8 +63,8 @@ class PhononWidget : public QWidget
         void hasVideoChanged(bool hasVideo);
 
     protected:
-        virtual void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
-        virtual void hideEvent(QHideEvent *event) Q_DECL_OVERRIDE;
+        void showEvent(QShowEvent *event) override;
+        void hideEvent(QHideEvent *event) override;
 
     private slots:
         void stateChanged(Phonon::State);
index ddc183351e4d330b2b79282d7b7840d956d7da6e..f6b456ee6272dfcc57e41b2c2c7c5fdf8ca059e7 100644 (file)
@@ -62,7 +62,7 @@ public:
     explicit PixmapViewer(QWidget* parent,
                           Transition transition = DefaultTransition);
 
-    virtual ~PixmapViewer();
+    ~PixmapViewer() override;
     void setPixmap(const QPixmap& pixmap);
     QPixmap pixmap() const;
 
@@ -71,10 +71,10 @@ public:
      * of the parent widget. Per default no size hint is given.
      */
     void setSizeHint(const QSize& size);
-    virtual QSize sizeHint() const Q_DECL_OVERRIDE;
+    QSize sizeHint() const override;
 
 protected:
-    virtual void paintEvent(QPaintEvent* event) Q_DECL_OVERRIDE;
+    void paintEvent(QPaintEvent* event) override;
 
 private Q_SLOTS:
     void checkPendingPixmaps();
index d3460bf130d1351cb208ccf160b7d1a8c09ce647..84d73e74c0087d625d1569b686ab7768351b8c35 100644 (file)
@@ -35,8 +35,8 @@ class Panel : public QWidget
     Q_OBJECT
 
 public:
-    explicit Panel(QWidget* parent = 0);
-    virtual ~Panel();
+    explicit Panel(QWidget* parent = nullptr);
+    ~Panel() override;
 
     /** Returns the current set URL of the active Dolphin view. */
     QUrl url() const;
@@ -49,7 +49,7 @@ public:
     void setCustomContextMenuActions(const QList<QAction*>& actions);
     QList<QAction*> customContextMenuActions() const;
 
-    virtual QSize sizeHint() const Q_DECL_OVERRIDE;
+    QSize sizeHint() const override;
 
 public slots:
     /**
index 93cc4d5c3d9be14c02c22f06dcff86e7af6c28d4..3c6023ba80797ecd24a5b4318dacab03c3a545e1 100644 (file)
@@ -66,7 +66,7 @@ void PlacesItem::setUrl(const QUrl &url)
             // watches for changes if the number of items has been changed.
             // The update of the icon is handled in onTrashDirListerCompleted().
             m_trashDirLister = new KDirLister();
-            m_trashDirLister->setAutoErrorHandlingEnabled(false, 0);
+            m_trashDirLister->setAutoErrorHandlingEnabled(false, nullptr);
             m_trashDirLister->setDelayedMimeTypes(true);
             QObject::connect(m_trashDirLister.data(), static_cast<void(KDirLister::*)()>(&KDirLister::completed),
                              m_signalHandler.data(), &PlacesItemSignalHandler::onTrashDirListerCompleted);
@@ -102,6 +102,16 @@ bool PlacesItem::isHidden() const
     return dataValue("isHidden").toBool();
 }
 
+bool PlacesItem::isGroupHidden() const
+{
+    return dataValue("isGroupHidden").toBool();
+}
+
+void PlacesItem::setGroupHidden(bool hidden)
+{
+    setDataValue("isGroupHidden", hidden);
+}
+
 void PlacesItem::setSystemItem(bool isSystemItem)
 {
     setDataValue("isSystemItem", isSystemItem);
@@ -119,46 +129,30 @@ Solid::Device PlacesItem::device() const
 
 void PlacesItem::setBookmark(const KBookmark& bookmark)
 {
-    if (bookmark == m_bookmark) {
-        return;
-    }
+    const bool bookmarkDataChanged = !(bookmark == m_bookmark);
 
+    // bookmark object must be updated to keep in sync with source model
     m_bookmark = bookmark;
 
+    if (!bookmarkDataChanged) {
+        return;
+    }
+
     delete m_access;
     delete m_volume;
     delete m_disc;
     delete m_mtp;
 
-
     const QString udi = bookmark.metaDataItem(QStringLiteral("UDI"));
     if (udi.isEmpty()) {
         setIcon(bookmark.icon());
         setText(i18nc("KFile System Bookmarks", bookmark.text().toUtf8().constData()));
         setUrl(bookmark.url());
+        setSystemItem(bookmark.metaDataItem(QStringLiteral("isSystemItem")) == QLatin1String("true"));
     } else {
         initializeDevice(udi);
     }
 
-    const GroupType type = groupType();
-    if (icon().isEmpty()) {
-        switch (type) {
-        case RecentlySavedType: setIcon(QStringLiteral("chronometer")); break;
-        case SearchForType:     setIcon(QStringLiteral("system-search")); break;
-        case PlacesType:
-        default:                setIcon(QStringLiteral("folder"));
-        }
-
-    }
-
-    switch (type) {
-    case PlacesType:        setGroup(i18nc("@item", "Places")); break;
-    case RecentlySavedType: setGroup(i18nc("@item", "Recently Saved")); break;
-    case SearchForType:     setGroup(i18nc("@item", "Search For")); break;
-    case DevicesType:       setGroup(i18nc("@item", "Devices")); break;
-    default:                Q_ASSERT(false); break;
-    }
-
     setHidden(bookmark.metaDataItem(QStringLiteral("IsHidden")) == QLatin1String("true"));
 }
 
@@ -167,62 +161,15 @@ KBookmark PlacesItem::bookmark() const
     return m_bookmark;
 }
 
-PlacesItem::GroupType PlacesItem::groupType() const
-{
-    if (udi().isEmpty()) {
-        const QString protocol = url().scheme();
-        if (protocol == QLatin1String("timeline")) {
-            return RecentlySavedType;
-        }
-
-        if (protocol.contains(QLatin1String("search"))) {
-            return SearchForType;
-        }
-
-        if (protocol == QLatin1String("bluetooth") || protocol == QLatin1String("obexftp") || protocol == QLatin1String("kdeconnect")) {
-            return DevicesType;
-        }
-
-        return PlacesType;
-    }
-
-    return DevicesType;
-}
-
 bool PlacesItem::storageSetupNeeded() const
 {
     return m_access ? !m_access->isAccessible() : false;
 }
 
-KBookmark PlacesItem::createBookmark(KBookmarkManager* manager,
-                                     const QString& text,
-                                     const QUrl& url,
-                                     const QString& iconName)
+bool PlacesItem::isSearchOrTimelineUrl() const
 {
-    KBookmarkGroup root = manager->root();
-    if (root.isNull()) {
-        return KBookmark();
-    }
-
-    KBookmark bookmark = root.addBookmark(text, url, iconName);
-    bookmark.setFullText(text);
-    bookmark.setMetaDataItem(QStringLiteral("ID"), generateNewId());
-
-    return bookmark;
-}
-
-KBookmark PlacesItem::createDeviceBookmark(KBookmarkManager* manager,
-                                           const QString& udi)
-{
-    KBookmarkGroup root = manager->root();
-    if (root.isNull()) {
-        return KBookmark();
-    }
-
-    KBookmark bookmark = root.createNewSeparator();
-    bookmark.setMetaDataItem(QStringLiteral("UDI"), udi);
-    bookmark.setMetaDataItem(QStringLiteral("isSystemItem"), QStringLiteral("true"));
-    return bookmark;
+    const QString urlScheme = url().scheme();
+    return (urlScheme.contains("search") || urlScheme.contains("timeline"));
 }
 
 void PlacesItem::onDataValueChanged(const QByteArray& role,
index d1b5b5d96e343c84d97f23b1215298727a084bdb..733265d468c8ade9bfbe912af6da694b3dd30e86 100644 (file)
@@ -40,16 +40,8 @@ class PlacesItem : public KStandardItem
 {
 
 public:
-    enum GroupType
-    {
-        PlacesType,
-        SearchForType,
-        RecentlySavedType,
-        DevicesType
-    };
-
-    explicit PlacesItem(const KBookmark& bookmark, PlacesItem* parent = 0);
-    virtual ~PlacesItem();
+    explicit PlacesItem(const KBookmark& bookmark, PlacesItem* parent = nullptr);
+    ~PlacesItem() override;
 
     void setUrl(const QUrl& url);
     QUrl url() const;
@@ -60,6 +52,9 @@ public:
     void setHidden(bool hidden);
     bool isHidden() const;
 
+    void setGroupHidden(bool hidden);
+    bool isGroupHidden() const;
+
     void setSystemItem(bool isSystemItem);
     bool isSystemItem() const;
 
@@ -68,26 +63,19 @@ public:
     void setBookmark(const KBookmark& bookmark);
     KBookmark bookmark() const;
 
-    GroupType groupType() const;
-
     bool storageSetupNeeded() const;
 
-    static KBookmark createBookmark(KBookmarkManager* manager,
-                                    const QString& text,
-                                    const QUrl& url,
-                                    const QString& iconName);
-    static KBookmark createDeviceBookmark(KBookmarkManager* manager,
-                                          const QString& udi);
+    bool isSearchOrTimelineUrl() const;
 
     PlacesItemSignalHandler* signalHandler() const;
 
 protected:
-    virtual void onDataValueChanged(const QByteArray& role,
+    void onDataValueChanged(const QByteArray& role,
                                     const QVariant& current,
-                                    const QVariant& previous) Q_DECL_OVERRIDE;
+                                    const QVariant& previous) override;
 
-    virtual void onDataChanged(const QHash<QByteArray, QVariant>& current,
-                               const QHash<QByteArray, QVariant>& previous) Q_DECL_OVERRIDE;
+    void onDataChanged(const QHash<QByteArray, QVariant>& current,
+                               const QHash<QByteArray, QVariant>& previous) override;
 
 private:
     PlacesItem(const PlacesItem& item);
index ffcac4c8f73f2b0df64a6ab8e8ab28e7d28375aa..4a56ce908594e7523cac7a01906261cef88e8815 100644 (file)
@@ -44,10 +44,10 @@ PlacesItemEditDialog::PlacesItemEditDialog(QWidget* parent) :
     m_text(),
     m_url(),
     m_allowGlobal(false),
-    m_urlEdit(0),
-    m_textEdit(0),
-    m_iconButton(0),
-    m_appLocal(0),
+    m_urlEdit(nullptr),
+    m_textEdit(nullptr),
+    m_iconButton(nullptr),
+    m_appLocal(nullptr),
     m_buttonBox(nullptr)
 {
 }
index f2d69781a592d901485cef3c4cc3123f9651f2f4..73104a1b6cf59231b1e4cf80b1fa2fc9e572f238 100644 (file)
@@ -38,8 +38,8 @@ class PlacesItemEditDialog: public QDialog
     Q_OBJECT
 
 public:
-    explicit PlacesItemEditDialog(QWidget* parent = 0);
-    virtual ~PlacesItemEditDialog();
+    explicit PlacesItemEditDialog(QWidget* parent = nullptr);
+    ~PlacesItemEditDialog() override;
 
     void setIcon(const QString& icon);
     QString icon() const;
@@ -54,7 +54,7 @@ public:
     bool allowGlobal() const;
 
 protected:
-    virtual bool event(QEvent* event) Q_DECL_OVERRIDE;
+    bool event(QEvent* event) override;
 
 private slots:
     void slotUrlChanged(const QString& text);
index ec845e0ae8fadae778099e3042586f90d67d4129..4408aa9ef848f26c225c7cd7dbe2272d8f43cb87 100644 (file)
@@ -27,13 +27,13 @@ class PlacesItemListGroupHeader : public KStandardItemListGroupHeader
     Q_OBJECT
 
 public:
-    PlacesItemListGroupHeader(QGraphicsWidget* parent = 0);
-    virtual ~PlacesItemListGroupHeader();
+    PlacesItemListGroupHeader(QGraphicsWidget* parent = nullptr);
+    ~PlacesItemListGroupHeader() override;
 
 protected:
-    virtual void paintSeparator(QPainter* painter, const QColor& color) Q_DECL_OVERRIDE;
+    void paintSeparator(QPainter* painter, const QColor& color) override;
 
-    virtual QPalette::ColorRole normalTextColorRole() const Q_DECL_OVERRIDE;
+    QPalette::ColorRole normalTextColorRole() const override;
 };
 #endif
 
index 18e5618640cc6e29d94d19772afbf37d5ba158eb..b0b3fb2aa288bd2858cb8b598b3fc7af38fe83bb 100644 (file)
@@ -30,7 +30,8 @@ PlacesItemListWidget::~PlacesItemListWidget()
 
 bool PlacesItemListWidget::isHidden() const
 {
-    return data().value("isHidden").toBool();
+    return data().value("isHidden").toBool() ||
+           data().value("isGroupHidden").toBool();
 }
 
 QPalette::ColorRole PlacesItemListWidget::normalTextColorRole() const
index e9e6a07678de8532d68c0e4e6e30b1b13d0e784c..3be5dde7cf2076ce5e9f66538801461bcf2d7a62 100644 (file)
@@ -32,11 +32,11 @@ class PlacesItemListWidget : public KStandardItemListWidget
 
 public:
     PlacesItemListWidget(KItemListWidgetInformant* informant, QGraphicsItem* parent);
-    virtual ~PlacesItemListWidget();
+    ~PlacesItemListWidget() override;
 
 protected:
-    virtual bool isHidden() const Q_DECL_OVERRIDE;
-    virtual QPalette::ColorRole normalTextColorRole() const Q_DECL_OVERRIDE;
+    bool isHidden() const override;
+    QPalette::ColorRole normalTextColorRole() const override;
 };
 
 #endif
index abdd4c20b65bf1b8933fa7207930b0f3367954e7..077c9044c24930e3c2b37224a2569dc089065175 100644 (file)
@@ -40,6 +40,7 @@
 #include <QMimeData>
 #include <QTimer>
 #include <KUrlMimeData>
+#include <KFilePlacesModel>
 
 #include <Solid/Device>
 #include <Solid/DeviceNotifier>
 #include <views/dolphinview.h>
 #include <views/viewproperties.h>
 
-#ifdef HAVE_BALOO
-    #include <Baloo/Query>
-    #include <Baloo/IndexerConfig>
-#endif
-
 namespace {
-    // As long as KFilePlacesView from kdelibs is available in parallel, the
-    // system-bookmarks for "Recently Saved" and "Search For" should be
-    // shown only inside the Places Panel. This is necessary as the stored
-    // URLs needs to get translated to a Baloo-search-URL on-the-fly to
-    // be independent from changes in the Baloo-search-URL-syntax.
-    // Hence a prefix to the application-name of the stored bookmarks is
+    // A suffix to the application-name of the stored bookmarks is
     // added, which is only read by PlacesItemModel.
-    const char AppNamePrefix[] = "-places-panel";
-
+    const QString AppNameSuffix = QStringLiteral("-places-panel");
     static QList<QUrl> balooURLs = {
         QUrl(QStringLiteral("timeline:/today")),
         QUrl(QStringLiteral("timeline:/yesterday")),
@@ -80,53 +70,33 @@ namespace {
 
 PlacesItemModel::PlacesItemModel(QObject* parent) :
     KStandardItemModel(parent),
-    m_fileIndexingEnabled(false),
     m_hiddenItemsShown(false),
-    m_availableDevices(),
-    m_predicate(),
-    m_bookmarkManager(0),
-    m_systemBookmarks(),
-    m_systemBookmarksIndexes(),
-    m_bookmarkedItems(),
-    m_hiddenItemToRemove(-1),
-    m_deviceToTearDown(0),
-    m_updateBookmarksTimer(0),
-    m_storageSetupInProgress()
+    m_deviceToTearDown(nullptr),
+    m_storageSetupInProgress(),
+    m_sourceModel(new KFilePlacesModel(KAboutData::applicationData().componentName() + AppNameSuffix, this))
 {
-#ifdef HAVE_BALOO
-    Baloo::IndexerConfig config;
-    m_fileIndexingEnabled = config.fileIndexingEnabled();
-#endif
-    const QString file = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/user-places.xbel";
-    m_bookmarkManager = KBookmarkManager::managerForExternalFile(file);
-
-    createSystemBookmarks();
-    initializeAvailableDevices();
+    cleanupBookmarks();
     loadBookmarks();
+    initializeDefaultViewProperties();
 
-    const int syncBookmarksTimeout = 100;
-
-    m_updateBookmarksTimer = new QTimer(this);
-    m_updateBookmarksTimer->setInterval(syncBookmarksTimeout);
-    m_updateBookmarksTimer->setSingleShot(true);
-    connect(m_updateBookmarksTimer, &QTimer::timeout, this, &PlacesItemModel::updateBookmarks);
-
-    connect(m_bookmarkManager, &KBookmarkManager::changed,
-            m_updateBookmarksTimer, static_cast<void(QTimer::*)()>(&QTimer::start));
+    connect(m_sourceModel.data(), &KFilePlacesModel::rowsInserted, this, &PlacesItemModel::onSourceModelRowsInserted);
+    connect(m_sourceModel.data(), &KFilePlacesModel::rowsAboutToBeRemoved, this, &PlacesItemModel::onSourceModelRowsAboutToBeRemoved);
+    connect(m_sourceModel.data(), &KFilePlacesModel::dataChanged, this, &PlacesItemModel::onSourceModelDataChanged);
+    connect(m_sourceModel.data(), &KFilePlacesModel::rowsAboutToBeMoved, this, &PlacesItemModel::onSourceModelRowsAboutToBeMoved);
+    connect(m_sourceModel.data(), &KFilePlacesModel::rowsMoved, this, &PlacesItemModel::onSourceModelRowsMoved);
+    connect(m_sourceModel.data(), &KFilePlacesModel::groupHiddenChanged, this, &PlacesItemModel::onSourceModelGroupHiddenChanged);
 }
 
 PlacesItemModel::~PlacesItemModel()
 {
-    qDeleteAll(m_bookmarkedItems);
-    m_bookmarkedItems.clear();
 }
 
-PlacesItem* PlacesItemModel::createPlacesItem(const QString& text,
-                                              const QUrl& url,
-                                              const QString& iconName)
+void PlacesItemModel::createPlacesItem(const QString& text,
+                                       const QUrl& url,
+                                       const QString& iconName,
+                                       int after)
 {
-    const KBookmark bookmark = PlacesItem::createBookmark(m_bookmarkManager, text, url, iconName);
-    return new PlacesItem(bookmark);
+    m_sourceModel->addPlace(text, url, iconName, {}, mapToSource(after));
 }
 
 PlacesItem* PlacesItemModel::placesItem(int index) const
@@ -136,20 +106,7 @@ PlacesItem* PlacesItemModel::placesItem(int index) const
 
 int PlacesItemModel::hiddenCount() const
 {
-    int modelIndex = 0;
-    int hiddenItemCount = 0;
-    foreach (const PlacesItem* item, m_bookmarkedItems) {
-        if (item) {
-            ++hiddenItemCount;
-        } else {
-            if (placesItem(modelIndex)->isHidden()) {
-                ++hiddenItemCount;
-            }
-            ++modelIndex;
-        }
-    }
-
-    return hiddenItemCount;
+    return m_sourceModel->hiddenCount();
 }
 
 void PlacesItemModel::setHiddenItemsShown(bool show)
@@ -161,38 +118,18 @@ void PlacesItemModel::setHiddenItemsShown(bool show)
     m_hiddenItemsShown = show;
 
     if (show) {
-        // Move all items that are part of m_bookmarkedItems to the model.
-        QList<PlacesItem*> itemsToInsert;
-        QList<int> insertPos;
-        int modelIndex = 0;
-        for (int i = 0; i < m_bookmarkedItems.count(); ++i) {
-            if (m_bookmarkedItems[i]) {
-                itemsToInsert.append(m_bookmarkedItems[i]);
-                m_bookmarkedItems[i] = 0;
-                insertPos.append(modelIndex);
+        for (int r = 0, rMax = m_sourceModel->rowCount(); r < rMax; r++) {
+            const QModelIndex index = m_sourceModel->index(r, 0);
+            if (!m_sourceModel->isHidden(index)) {
+                continue;
             }
-            ++modelIndex;
-        }
-
-        // Inserting the items will automatically insert an item
-        // to m_bookmarkedItems in PlacesItemModel::onItemsInserted().
-        // The items are temporary saved in itemsToInsert, so
-        // m_bookmarkedItems can be shrinked now.
-        m_bookmarkedItems.erase(m_bookmarkedItems.begin(),
-                                m_bookmarkedItems.begin() + itemsToInsert.count());
-
-        for (int i = 0; i < itemsToInsert.count(); ++i) {
-            insertItem(insertPos[i], itemsToInsert[i]);
+            addItemFromSourceModel(index);
         }
-
-        Q_ASSERT(m_bookmarkedItems.count() == count());
     } else {
-        // Move all items of the model, where the "isHidden" property is true, to
-        // m_bookmarkedItems.
-        Q_ASSERT(m_bookmarkedItems.count() == count());
-        for (int i = count() - 1; i >= 0; --i) {
-            if (placesItem(i)->isHidden()) {
-                hideItem(i);
+        for (int r = 0, rMax = m_sourceModel->rowCount(); r < rMax; r++) {
+            const QModelIndex index = m_sourceModel->index(r, 0);
+            if (m_sourceModel->isHidden(index)) {
+                removeItemByIndex(index);
             }
         }
     }
@@ -210,75 +147,99 @@ bool PlacesItemModel::hiddenItemsShown() const
 
 int PlacesItemModel::closestItem(const QUrl& url) const
 {
-    int foundIndex = -1;
-    int maxLength = 0;
-
-    for (int i = 0; i < count(); ++i) {
-        const QUrl itemUrl = placesItem(i)->url();
-        if (url == itemUrl) {
-            // We can't find a closer one, so stop here.
-            foundIndex = i;
-            break;
-        } else if (itemUrl.isParentOf(url)) {
-            const int length = itemUrl.path().length();
-            if (length > maxLength) {
-                foundIndex = i;
-                maxLength = length;
-            }
-        }
-    }
-
-    return foundIndex;
+    return mapFromSource(m_sourceModel->closestItem(url));
 }
 
-void PlacesItemModel::appendItemToGroup(PlacesItem* item)
+// look for the correct position for the item based on source model
+void PlacesItemModel::insertSortedItem(PlacesItem* item)
 {
     if (!item) {
         return;
     }
 
-    int i = 0;
-    while (i < count() && placesItem(i)->group() != item->group()) {
-        ++i;
-    }
+    const KBookmark iBookmark = item->bookmark();
+    const QString iBookmarkId = bookmarkId(iBookmark);
+    QModelIndex sourceIndex;
+    int pos = 0;
+
+    for(int r = 0, rMax = m_sourceModel->rowCount(); r < rMax; r++) {
+        sourceIndex = m_sourceModel->index(r, 0);
+        const KBookmark sourceBookmark = m_sourceModel->bookmarkForIndex(sourceIndex);
 
-    bool inserted = false;
-    while (!inserted && i < count()) {
-        if (placesItem(i)->group() != item->group()) {
-            insertItem(i, item);
-            inserted = true;
+        if (bookmarkId(sourceBookmark) == iBookmarkId) {
+            break;
         }
-        ++i;
-    }
 
-    if (!inserted) {
-        appendItem(item);
+        if (m_hiddenItemsShown || !m_sourceModel->isHidden(sourceIndex)) {
+            pos++;
+        }
     }
+
+    m_indexMap.insert(pos, sourceIndex);
+    insertItem(pos, item);
+}
+
+void PlacesItemModel::onItemInserted(int index)
+{
+    KStandardItemModel::onItemInserted(index);
+#ifdef PLACESITEMMODEL_DEBUG
+    qCDebug(DolphinDebug) << "Inserted item" << index;
+    showModelState();
+#endif
+}
+
+void PlacesItemModel::onItemRemoved(int index, KStandardItem* removedItem)
+{
+    m_indexMap.removeAt(index);
+
+    KStandardItemModel::onItemRemoved(index, removedItem);
+#ifdef PLACESITEMMODEL_DEBUG
+    qCDebug(DolphinDebug) << "Removed item" << index;
+    showModelState();
+#endif
 }
 
+void PlacesItemModel::onItemChanged(int index, const QSet<QByteArray>& changedRoles)
+{
+    const QModelIndex sourceIndex = mapToSource(index);
+    const PlacesItem *changedItem = placesItem(mapFromSource(sourceIndex));
+
+    if (!changedItem || !sourceIndex.isValid()) {
+        qWarning() << "invalid item changed signal";
+        return;
+    }
+    if (changedRoles.contains("isHidden")) {
+        if (m_sourceModel->isHidden(sourceIndex) != changedItem->isHidden()) {
+            m_sourceModel->setPlaceHidden(sourceIndex, changedItem->isHidden());
+        } else {
+            m_sourceModel->refresh();
+        }
+    }
+    KStandardItemModel::onItemChanged(index, changedRoles);
+}
 
 QAction* PlacesItemModel::ejectAction(int index) const
 {
     const PlacesItem* item = placesItem(index);
     if (item && item->device().is<Solid::OpticalDisc>()) {
-        return new QAction(QIcon::fromTheme(QStringLiteral("media-eject")), i18nc("@item", "Eject"), 0);
+        return new QAction(QIcon::fromTheme(QStringLiteral("media-eject")), i18nc("@item", "Eject"), nullptr);
     }
 
-    return 0;
+    return nullptr;
 }
 
 QAction* PlacesItemModel::teardownAction(int index) const
 {
     const PlacesItem* item = placesItem(index);
     if (!item) {
-        return 0;
+        return nullptr;
     }
 
     Solid::Device device = item->device();
     const bool providesTearDown = device.is<Solid::StorageAccess>() &&
                                   device.as<Solid::StorageAccess>()->isAccessible();
     if (!providesTearDown) {
-        return 0;
+        return nullptr;
     }
 
     Solid::StorageDrive* drive = device.as<Solid::StorageDrive>();
@@ -306,10 +267,10 @@ QAction* PlacesItemModel::teardownAction(int index) const
     }
 
     if (iconName.isEmpty()) {
-        return new QAction(text, 0);
+        return new QAction(text, nullptr);
     }
 
-    return new QAction(QIcon::fromTheme(iconName), text, 0);
+    return new QAction(QIcon::fromTheme(iconName), text, nullptr);
 }
 
 void PlacesItemModel::requestEject(int index)
@@ -415,25 +376,8 @@ void PlacesItemModel::dropMimeDataBefore(int index, const QMimeData* mimeData)
         QDataStream stream(&itemData, QIODevice::ReadOnly);
         int oldIndex;
         stream >> oldIndex;
-        if (oldIndex == index || oldIndex == index - 1) {
-            // No moving has been done
-            return;
-        }
 
-        PlacesItem* oldItem = placesItem(oldIndex);
-        if (!oldItem) {
-            return;
-        }
-
-        PlacesItem* newItem = new PlacesItem(oldItem->bookmark());
-        removeItem(oldIndex);
-
-        if (oldIndex < index) {
-            --index;
-        }
-
-        const int dropIndex = groupedDropIndex(index, newItem);
-        insertItem(dropIndex, newItem);
+        m_sourceModel->movePlace(oldIndex, index);
     } else if (mimeData->hasFormat(QStringLiteral("text/uri-list"))) {
         // One or more items must be added to the model
         const QList<QUrl> urls = KUrlMimeData::urlsFromMimeData(mimeData);
@@ -451,150 +395,104 @@ void PlacesItemModel::dropMimeDataBefore(int index, const QMimeData* mimeData)
                 continue;
             }
 
-            PlacesItem* newItem = createPlacesItem(text, url);
-            const int dropIndex = groupedDropIndex(index, newItem);
-            insertItem(dropIndex, newItem);
+            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
+    refresh();
 }
 
-QUrl PlacesItemModel::convertedUrl(const QUrl& url)
+void PlacesItemModel::addItemFromSourceModel(const QModelIndex &index)
 {
-    QUrl newUrl = url;
-    if (url.scheme() == QLatin1String("timeline")) {
-        newUrl = createTimelineUrl(url);
-    } else if (url.scheme() == QLatin1String("search")) {
-        newUrl = createSearchUrl(url);
+    if (!m_hiddenItemsShown && m_sourceModel->isHidden(index)) {
+        return;
     }
 
-    return newUrl;
-}
-
-void PlacesItemModel::onItemInserted(int index)
-{
-    const PlacesItem* insertedItem = placesItem(index);
-    if (insertedItem) {
-        // Take care to apply the PlacesItemModel-order of the inserted item
-        // also to the bookmark-manager.
-        const KBookmark insertedBookmark = insertedItem->bookmark();
-
-        const PlacesItem* previousItem = placesItem(index - 1);
-        KBookmark previousBookmark;
-        if (previousItem) {
-            previousBookmark = previousItem->bookmark();
-        }
-
-        m_bookmarkManager->root().moveBookmark(insertedBookmark, previousBookmark);
+    const KBookmark bookmark = m_sourceModel->bookmarkForIndex(index);
+    Q_ASSERT(!bookmark.isNull());
+    PlacesItem *item = itemFromBookmark(bookmark);
+    if (!item) {
+        item = new PlacesItem(bookmark);
     }
+    updateItem(item, index);
+    insertSortedItem(item);
 
-    if (index == count() - 1) {
-        // The item has been appended as last item to the list. In this
-        // case assure that it is also appended after the hidden items and
-        // not before (like done otherwise).
-        m_bookmarkedItems.append(0);
-    } else {
-
-        int modelIndex = -1;
-        int bookmarkIndex = 0;
-        while (bookmarkIndex < m_bookmarkedItems.count()) {
-            if (!m_bookmarkedItems[bookmarkIndex]) {
-                ++modelIndex;
-                if (modelIndex + 1 == index) {
-                    break;
-                }
-            }
-            ++bookmarkIndex;
-        }
-        m_bookmarkedItems.insert(bookmarkIndex, 0);
+    if (m_sourceModel->isDevice(index)) {
+        connect(item->signalHandler(), &PlacesItemSignalHandler::tearDownExternallyRequested,
+                this, &PlacesItemModel::storageTearDownExternallyRequested);
     }
-
-#ifdef PLACESITEMMODEL_DEBUG
-    qCDebug(DolphinDebug) << "Inserted item" << index;
-    showModelState();
-#endif
 }
 
-void PlacesItemModel::onItemRemoved(int index, KStandardItem* removedItem)
+void PlacesItemModel::removeItemByIndex(const QModelIndex &sourceIndex)
 {
-    PlacesItem* placesItem = dynamic_cast<PlacesItem*>(removedItem);
-    if (placesItem) {
-        const KBookmark bookmark = placesItem->bookmark();
-        m_bookmarkManager->root().deleteBookmark(bookmark);
-    }
-
-    const int boomarkIndex = bookmarkIndex(index);
-    Q_ASSERT(!m_bookmarkedItems[boomarkIndex]);
-    m_bookmarkedItems.removeAt(boomarkIndex);
-
-#ifdef PLACESITEMMODEL_DEBUG
-    qCDebug(DolphinDebug) << "Removed item" << index;
-    showModelState();
-#endif
-}
+    QString id = bookmarkId(m_sourceModel->bookmarkForIndex(sourceIndex));
 
-void PlacesItemModel::onItemChanged(int index, const QSet<QByteArray>& changedRoles)
-{
-    const PlacesItem* changedItem = placesItem(index);
-    if (changedItem) {
-        // Take care to apply the PlacesItemModel-order of the changed item
-        // also to the bookmark-manager.
-        const KBookmark insertedBookmark = changedItem->bookmark();
-
-        const PlacesItem* previousItem = placesItem(index - 1);
-        KBookmark previousBookmark;
-        if (previousItem) {
-            previousBookmark = previousItem->bookmark();
+    for (int i = 0, iMax = count(); i < iMax; ++i) {
+        if (bookmarkId(placesItem(i)->bookmark()) == id) {
+            removeItem(i);
+            return;
         }
-
-        m_bookmarkManager->root().moveBookmark(insertedBookmark, previousBookmark);
     }
+}
 
-    if (changedRoles.contains("isHidden")) {
-        if (!m_hiddenItemsShown && changedItem->isHidden()) {
-            m_hiddenItemToRemove = index;
-            QTimer::singleShot(0, this, static_cast<void (PlacesItemModel::*)()>(&PlacesItemModel::hideItem));
+QString PlacesItemModel::bookmarkId(const KBookmark &bookmark) const
+{
+    QString id = bookmark.metaDataItem(QStringLiteral("UDI"));
+    if (id.isEmpty()) {
+        id = bookmark.metaDataItem(QStringLiteral("ID"));
+    }
+    return id;
+}
+
+void PlacesItemModel::initializeDefaultViewProperties() const
+{
+    for(int i = 0, iMax = m_sourceModel->rowCount(); i < iMax; i++) {
+        const QModelIndex index = m_sourceModel->index(i, 0);
+        const PlacesItem *item = placesItem(mapFromSource(index));
+        if (!item) {
+            continue;
+        }
+
+        // Create default view-properties for all "Search For" and "Recently Saved" bookmarks
+        // in case the user has not already created custom view-properties for a corresponding
+        // query yet.
+        const bool createDefaultViewProperties = item->isSearchOrTimelineUrl() && !GeneralSettings::self()->globalViewProps();
+        if (createDefaultViewProperties) {
+            const QUrl itemUrl = item->url();
+            ViewProperties props(KFilePlacesModel::convertedUrl(itemUrl));
+            if (!props.exist()) {
+                const QString path = itemUrl.path();
+                if (path == QLatin1String("/documents")) {
+                    props.setViewMode(DolphinView::DetailsView);
+                    props.setPreviewsShown(false);
+                    props.setVisibleRoles({"text", "path"});
+                } else if (path == QLatin1String("/images")) {
+                    props.setViewMode(DolphinView::IconsView);
+                    props.setPreviewsShown(true);
+                    props.setVisibleRoles({"text", "imageSize"});
+                } else if (path == QLatin1String("/audio")) {
+                    props.setViewMode(DolphinView::DetailsView);
+                    props.setPreviewsShown(false);
+                    props.setVisibleRoles({"text", "artist", "album"});
+                } else if (path == QLatin1String("/videos")) {
+                    props.setViewMode(DolphinView::IconsView);
+                    props.setPreviewsShown(true);
+                    props.setVisibleRoles({"text"});
+                } else if (itemUrl.scheme() == QLatin1String("timeline")) {
+                    props.setViewMode(DolphinView::DetailsView);
+                    props.setVisibleRoles({"text", "modificationtime"});
+                }
+                props.save();
+            }
         }
     }
 }
 
-void PlacesItemModel::slotDeviceAdded(const QString& udi)
+void PlacesItemModel::updateItem(PlacesItem *item, const QModelIndex &index)
 {
-    const Solid::Device device(udi);
-
-    if (!m_predicate.matches(device)) {
-        return;
-    }
-
-    m_availableDevices << udi;
-    const KBookmark bookmark = PlacesItem::createDeviceBookmark(m_bookmarkManager, udi);
-
-    PlacesItem *item = new PlacesItem(bookmark);
-    appendItem(item);
-    connect(item->signalHandler(), &PlacesItemSignalHandler::tearDownExternallyRequested,
-            this, &PlacesItemModel::storageTearDownExternallyRequested);
-}
-
-void PlacesItemModel::slotDeviceRemoved(const QString& udi)
-{
-    if (!m_availableDevices.contains(udi)) {
-        return;
-    }
-
-    for (int i = 0; i < m_bookmarkedItems.count(); ++i) {
-        PlacesItem* item = m_bookmarkedItems[i];
-        if (item && item->udi() == udi) {
-            m_bookmarkedItems.removeAt(i);
-            delete item;
-            return;
-        }
-    }
-
-    for (int i = 0; i < count(); ++i) {
-        if (placesItem(i)->udi() == udi) {
-            removeItem(i);
-            return;
-        }
-    }
+    item->setGroup(index.data(KFilePlacesModel::GroupRole).toString());
+    item->setIcon(index.data(KFilePlacesModel::IconNameRole).toString());
+    item->setGroupHidden(index.data(KFilePlacesModel::GroupHiddenRole).toBool());
 }
 
 void PlacesItemModel::slotStorageTearDownDone(Solid::ErrorType error, const QVariant& errorData)
@@ -633,342 +531,133 @@ void PlacesItemModel::slotStorageSetupDone(Solid::ErrorType error,
     }
 }
 
-void PlacesItemModel::hideItem()
+void PlacesItemModel::onSourceModelRowsInserted(const QModelIndex &parent, int first, int last)
 {
-    hideItem(m_hiddenItemToRemove);
-    m_hiddenItemToRemove = -1;
+    for (int i = first; i <= last; i++) {
+        const QModelIndex index = m_sourceModel->index(i, 0, parent);
+        addItemFromSourceModel(index);
+    }
 }
 
-void PlacesItemModel::updateBookmarks()
+void PlacesItemModel::onSourceModelRowsAboutToBeRemoved(const QModelIndex &parent, int first, int last)
 {
-    // Verify whether new bookmarks have been added or existing
-    // bookmarks have been changed.
-    KBookmarkGroup root = m_bookmarkManager->root();
-    KBookmark newBookmark = root.first();
-    while (!newBookmark.isNull()) {
-        if (acceptBookmark(newBookmark, m_availableDevices)) {
-            bool found = false;
-            int modelIndex = 0;
-            for (int i = 0; i < m_bookmarkedItems.count(); ++i) {
-                PlacesItem* item = m_bookmarkedItems[i];
-                if (!item) {
-                    item = placesItem(modelIndex);
-                    ++modelIndex;
-                }
-
-                const KBookmark oldBookmark = item->bookmark();
-                if (equalBookmarkIdentifiers(newBookmark, oldBookmark)) {
-                    // The bookmark has been found in the model or as
-                    // a hidden item. The content of the bookmark might
-                    // have been changed, so an update is done.
-                    found = true;
-                    if (newBookmark.metaDataItem(QStringLiteral("UDI")).isEmpty()) {
-                        item->setBookmark(newBookmark);
-                        item->setText(i18nc("KFile System Bookmarks", newBookmark.text().toUtf8().constData()));
-                    }
-                    break;
-                }
-            }
-
-            if (!found) {
-                const QString udi = newBookmark.metaDataItem(QStringLiteral("UDI"));
-
-                /*
-                 * See Bug 304878
-                 * Only add a new places item, if the item text is not empty
-                 * and if the device is available. Fixes the strange behaviour -
-                 * add a places item without text in the Places section - when you
-                 * remove a device (e.g. a usb stick) without unmounting.
-                 */
-                if (udi.isEmpty() || Solid::Device(udi).isValid()) {
-                    PlacesItem* item = new PlacesItem(newBookmark);
-                    if (item->isHidden() && !m_hiddenItemsShown) {
-                        m_bookmarkedItems.append(item);
-                    } else {
-                        appendItemToGroup(item);
-                    }
-                }
-            }
+    for(int r = first; r <= last; r++) {
+        const QModelIndex index = m_sourceModel->index(r, 0, parent);
+        int oldIndex = mapFromSource(index);
+        if (oldIndex != -1) {
+            removeItem(oldIndex);
         }
-
-        newBookmark = root.next(newBookmark);
     }
+}
 
-    // Remove items that are not part of the bookmark-manager anymore
-    int modelIndex = 0;
-    for (int i = m_bookmarkedItems.count() - 1; i >= 0; --i) {
-        PlacesItem* item = m_bookmarkedItems[i];
-        const bool itemIsPartOfModel = (item == 0);
-        if (itemIsPartOfModel) {
-            item = placesItem(modelIndex);
-        }
-
-        bool hasBeenRemoved = true;
-        const KBookmark oldBookmark = item->bookmark();
-        KBookmark newBookmark = root.first();
-        while (!newBookmark.isNull()) {
-            if (equalBookmarkIdentifiers(newBookmark, oldBookmark)) {
-                hasBeenRemoved = false;
-                break;
-            }
-            newBookmark = root.next(newBookmark);
-        }
-
-        if (hasBeenRemoved) {
-            if (m_bookmarkedItems[i]) {
-                delete m_bookmarkedItems[i];
-                m_bookmarkedItems.removeAt(i);
-            } else {
-                removeItem(modelIndex);
-                --modelIndex;
-            }
-        }
+void PlacesItemModel::onSourceModelRowsAboutToBeMoved(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row)
+{
+    Q_UNUSED(destination);
+    Q_UNUSED(row);
 
-        if (itemIsPartOfModel) {
-            ++modelIndex;
-        }
+    for(int r = start; r <= end; r++) {
+        const QModelIndex sourceIndex = m_sourceModel->index(r, 0, parent);
+        // remove moved item
+        removeItem(mapFromSource(sourceIndex));
     }
 }
 
-void PlacesItemModel::saveBookmarks()
+void PlacesItemModel::onSourceModelRowsMoved(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row)
 {
-    m_bookmarkManager->emitChanged(m_bookmarkManager->root());
-}
+    Q_UNUSED(destination);
+    Q_UNUSED(parent);
 
-void PlacesItemModel::loadBookmarks()
-{
-    KBookmarkGroup root = m_bookmarkManager->root();
-    KBookmark bookmark = root.first();
-    QSet<QString> devices = m_availableDevices;
+    const int blockSize = (end - start) + 1;
 
-    QSet<QUrl> missingSystemBookmarks;
-    foreach (const SystemBookmarkData& data, m_systemBookmarks) {
-        missingSystemBookmarks.insert(data.url);
+    for (int r = start; r <= end; r++) {
+        // insert the moved item in the new position
+        const int targetRow = row + (start - r) - (r < row ? blockSize : 0);
+        const QModelIndex targetIndex = m_sourceModel->index(targetRow, 0, destination);
+
+        addItemFromSourceModel(targetIndex);
     }
+}
 
-    // The bookmarks might have a mixed order of places, devices and search-groups due
-    // to the compatibility with the KFilePlacesPanel. In Dolphin's places panel the
-    // items should always be collected in one group so the items are collected first
-    // in separate lists before inserting them.
-    QList<PlacesItem*> placesItems;
-    QList<PlacesItem*> recentlySavedItems;
-    QList<PlacesItem*> searchForItems;
-    QList<PlacesItem*> devicesItems;
+void PlacesItemModel::onSourceModelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles)
+{
+    Q_UNUSED(roles);
 
-    while (!bookmark.isNull()) {
-        if (acceptBookmark(bookmark, devices)) {
-            PlacesItem* item = new PlacesItem(bookmark);
-            if (item->groupType() == PlacesItem::DevicesType) {
-                devices.remove(item->udi());
-                devicesItems.append(item);
-            } else {
-                const QUrl url = bookmark.url();
-                if (missingSystemBookmarks.contains(url)) {
-                    missingSystemBookmarks.remove(url);
-
-                    // Try to retranslate the text of system bookmarks to have translated
-                    // items when changing the language. In case if the user has applied a custom
-                    // text, the retranslation will fail and the users custom text is still used.
-                    // It is important to use "KFile System Bookmarks" as context (see
-                    // createSystemBookmarks()).
-                    item->setText(i18nc("KFile System Bookmarks", bookmark.text().toUtf8().constData()));
-                    item->setSystemItem(true);
-                }
+    for (int r = topLeft.row(); r <= bottomRight.row(); r++) {
+        const QModelIndex sourceIndex = m_sourceModel->index(r, 0);
+        const KBookmark bookmark = m_sourceModel->bookmarkForIndex(sourceIndex);
+        PlacesItem *placeItem = itemFromBookmark(bookmark);
 
-                switch (item->groupType()) {
-                case PlacesItem::PlacesType:        placesItems.append(item); break;
-                case PlacesItem::RecentlySavedType: recentlySavedItems.append(item); break;
-                case PlacesItem::SearchForType:     searchForItems.append(item); break;
-                case PlacesItem::DevicesType:
-                default:                            Q_ASSERT(false); break;
-                }
-            }
+        if (placeItem && (!m_hiddenItemsShown && m_sourceModel->isHidden(sourceIndex))) {
+            //hide item if it became invisible
+            removeItem(index(placeItem));
+            return;
         }
 
-        bookmark = root.next(bookmark);
-    }
-
-    if (!missingSystemBookmarks.isEmpty()) {
-        // The current bookmarks don't contain all system-bookmarks. Add the missing
-        // bookmarks.
-        foreach (const SystemBookmarkData& data, m_systemBookmarks) {
-            if (missingSystemBookmarks.contains(data.url)) {
-                PlacesItem* item = createSystemPlacesItem(data);
-                switch (item->groupType()) {
-                case PlacesItem::PlacesType:        placesItems.append(item); break;
-                case PlacesItem::RecentlySavedType: recentlySavedItems.append(item); break;
-                case PlacesItem::SearchForType:     searchForItems.append(item); break;
-                case PlacesItem::DevicesType:
-                default:                            Q_ASSERT(false); break;
-                }
-            }
+        if (!placeItem && (m_hiddenItemsShown || !m_sourceModel->isHidden(sourceIndex))) {
+            //show item if it became visible
+            addItemFromSourceModel(sourceIndex);
+            return;
         }
-    }
-
-    // Create items for devices that have not been stored as bookmark yet
-    devicesItems.reserve(devicesItems.count() + devices.count());
-    foreach (const QString& udi, devices) {
-        const KBookmark bookmark = PlacesItem::createDeviceBookmark(m_bookmarkManager, udi);
-        PlacesItem *item = new PlacesItem(bookmark);
-        devicesItems.append(item);
-        connect(item->signalHandler(), &PlacesItemSignalHandler::tearDownExternallyRequested,
-                this, &PlacesItemModel::storageTearDownExternallyRequested);
-    }
-
-    QList<PlacesItem*> items;
-    items.append(placesItems);
-    items.append(recentlySavedItems);
-    items.append(searchForItems);
-    items.append(devicesItems);
 
-    foreach (PlacesItem* item, items) {
-        if (!m_hiddenItemsShown && item->isHidden()) {
-            m_bookmarkedItems.append(item);
-        } else {
-            appendItem(item);
+        if (placeItem && !m_sourceModel->isDevice(sourceIndex)) {
+            placeItem->setText(bookmark.text());
+            placeItem->setIcon(sourceIndex.data(KFilePlacesModel::IconNameRole).toString());
+            placeItem->setUrl(m_sourceModel->url(sourceIndex));
+            placeItem->bookmark().setMetaDataItem(QStringLiteral("OnlyInApp"),
+                                                  bookmark.metaDataItem(QStringLiteral("OnlyInApp")));
+            // must update the bookmark object
+            placeItem->setBookmark(bookmark);
         }
     }
-
-#ifdef PLACESITEMMODEL_DEBUG
-    qCDebug(DolphinDebug) << "Loaded bookmarks";
-    showModelState();
-#endif
 }
 
-bool PlacesItemModel::acceptBookmark(const KBookmark& bookmark,
-                                     const QSet<QString>& availableDevices) const
+void PlacesItemModel::onSourceModelGroupHiddenChanged(KFilePlacesModel::GroupType group, bool hidden)
 {
-    const QString udi = bookmark.metaDataItem(QStringLiteral("UDI"));
-    const QUrl url = bookmark.url();
-    const QString appName = bookmark.metaDataItem(QStringLiteral("OnlyInApp"));
-    const bool deviceAvailable = availableDevices.contains(udi);
-
-    if (balooURLs.contains(url) && appName.isEmpty()) {
-        // Does not accept baloo URLS with empty appName, this came from new KIO model and will cause duplications
-        qCWarning(DolphinDebug) << "Ignore KIO url:" << url;
-        return false;
+    for(const QModelIndex &sourceIndex : m_sourceModel->groupIndexes(group)) {
+        PlacesItem *item = placesItem(mapFromSource(sourceIndex));
+        if (item) {
+            item->setGroupHidden(hidden);
+        }
     }
-
-    const bool allowedHere = (appName.isEmpty()
-                              || appName == KAboutData::applicationData().componentName()
-                              || appName == KAboutData::applicationData().componentName() + AppNamePrefix)
-                             && (m_fileIndexingEnabled || (url.scheme() != QLatin1String("timeline") &&
-                                                           url.scheme() != QLatin1String("search")));
-
-    return (udi.isEmpty() && allowedHere) || deviceAvailable;
 }
 
-PlacesItem* PlacesItemModel::createSystemPlacesItem(const SystemBookmarkData& data)
+void PlacesItemModel::cleanupBookmarks()
 {
-    KBookmark bookmark = PlacesItem::createBookmark(m_bookmarkManager,
-                                                    data.text,
-                                                    data.url,
-                                                    data.icon);
-
-    const QString protocol = data.url.scheme();
-    if (protocol == QLatin1String("timeline") || protocol == QLatin1String("search")) {
-        // As long as the KFilePlacesView from kdelibs is available, the system-bookmarks
-        // for "Recently Saved" and "Search For" should be a setting available only
-        // in the Places Panel (see description of AppNamePrefix for more details).
-        const QString appName = KAboutData::applicationData().componentName() + AppNamePrefix;
-        bookmark.setMetaDataItem(QStringLiteral("OnlyInApp"), appName);
-    }
+    // KIO model now provides support for baloo urls, and because of that we
+    // need to remove old URLs that were visible only in Dolphin to avoid duplication
+    int row = 0;
+    do {
+        const QModelIndex sourceIndex = m_sourceModel->index(row, 0);
+        const KBookmark bookmark = m_sourceModel->bookmarkForIndex(sourceIndex);
+        const QUrl url = bookmark.url();
+        const QString appName = bookmark.metaDataItem(QStringLiteral("OnlyInApp"));
 
-    PlacesItem* item = new PlacesItem(bookmark);
-    item->setSystemItem(true);
-
-    // Create default view-properties for all "Search For" and "Recently Saved" bookmarks
-    // in case if the user has not already created custom view-properties for a corresponding
-    // query yet.
-    const bool createDefaultViewProperties = (item->groupType() == PlacesItem::SearchForType ||
-                                              item->groupType() == PlacesItem::RecentlySavedType) &&
-                                              !GeneralSettings::self()->globalViewProps();
-    if (createDefaultViewProperties) {
-        ViewProperties props(convertedUrl(data.url));
-        if (!props.exist()) {
-            const QString path = data.url.path();
-            if (path == QLatin1String("/documents")) {
-                props.setViewMode(DolphinView::DetailsView);
-                props.setPreviewsShown(false);
-                props.setVisibleRoles({"text", "path"});
-            } else if (path == QLatin1String("/images")) {
-                props.setViewMode(DolphinView::IconsView);
-                props.setPreviewsShown(true);
-                props.setVisibleRoles({"text", "imageSize"});
-            } else if (path == QLatin1String("/audio")) {
-                props.setViewMode(DolphinView::DetailsView);
-                props.setPreviewsShown(false);
-                props.setVisibleRoles({"text", "artist", "album"});
-            } else if (path == QLatin1String("/videos")) {
-                props.setViewMode(DolphinView::IconsView);
-                props.setPreviewsShown(true);
-                props.setVisibleRoles({"text"});
-            } else if (data.url.scheme() == QLatin1String("timeline")) {
-                props.setViewMode(DolphinView::DetailsView);
-                props.setVisibleRoles({"text", "modificationtime"});
-            }
+        if ((appName == KAboutData::applicationData().componentName() ||
+             appName == KAboutData::applicationData().componentName() + AppNameSuffix) && balooURLs.contains(url)) {
+            qCDebug(DolphinDebug) << "Removing old baloo url:" << url;
+            m_sourceModel->removePlace(sourceIndex);
+        } else {
+            row++;
         }
-    }
-
-    return item;
+    } while (row < m_sourceModel->rowCount());
 }
 
-void PlacesItemModel::createSystemBookmarks()
+void PlacesItemModel::loadBookmarks()
 {
-    Q_ASSERT(m_systemBookmarks.isEmpty());
-    Q_ASSERT(m_systemBookmarksIndexes.isEmpty());
-
-    // Note: The context of the I18N_NOOP2 must be "KFile System Bookmarks". The real
-    // i18nc call is done after reading the bookmark. The reason why the i18nc call is not
-    // done here is because otherwise switching the language would not result in retranslating the
-    // bookmarks.
-    m_systemBookmarks.append(SystemBookmarkData(QUrl::fromLocalFile(QDir::homePath()),
-                                                QStringLiteral("user-home"),
-                                                I18N_NOOP2("KFile System Bookmarks", "Home")));
-    m_systemBookmarks.append(SystemBookmarkData(QUrl(QStringLiteral("remote:/")),
-                                                QStringLiteral("network-workgroup"),
-                                                I18N_NOOP2("KFile System Bookmarks", "Network")));
-    m_systemBookmarks.append(SystemBookmarkData(QUrl::fromLocalFile(QStringLiteral("/")),
-                                                QStringLiteral("folder-red"),
-                                                I18N_NOOP2("KFile System Bookmarks", "Root")));
-    m_systemBookmarks.append(SystemBookmarkData(QUrl(QStringLiteral("trash:/")),
-                                                QStringLiteral("user-trash"),
-                                                I18N_NOOP2("KFile System Bookmarks", "Trash")));
-
-    if (m_fileIndexingEnabled) {
-        m_systemBookmarks.append(SystemBookmarkData(QUrl(QStringLiteral("timeline:/today")),
-                                                    QStringLiteral("go-jump-today"),
-                                                    I18N_NOOP2("KFile System Bookmarks", "Today")));
-        m_systemBookmarks.append(SystemBookmarkData(QUrl(QStringLiteral("timeline:/yesterday")),
-                                                    QStringLiteral("view-calendar-day"),
-                                                    I18N_NOOP2("KFile System Bookmarks", "Yesterday")));
-        m_systemBookmarks.append(SystemBookmarkData(QUrl(QStringLiteral("timeline:/thismonth")),
-                                                    QStringLiteral("view-calendar-month"),
-                                                    I18N_NOOP2("KFile System Bookmarks", "This Month")));
-        m_systemBookmarks.append(SystemBookmarkData(QUrl(QStringLiteral("timeline:/lastmonth")),
-                                                    QStringLiteral("view-calendar-month"),
-                                                    I18N_NOOP2("KFile System Bookmarks", "Last Month")));
-        m_systemBookmarks.append(SystemBookmarkData(QUrl(QStringLiteral("search:/documents")),
-                                                    QStringLiteral("folder-text"),
-                                                    I18N_NOOP2("KFile System Bookmarks", "Documents")));
-        m_systemBookmarks.append(SystemBookmarkData(QUrl(QStringLiteral("search:/images")),
-                                                    QStringLiteral("folder-images"),
-                                                    I18N_NOOP2("KFile System Bookmarks", "Images")));
-        m_systemBookmarks.append(SystemBookmarkData(QUrl(QStringLiteral("search:/audio")),
-                                                    QStringLiteral("folder-sound"),
-                                                    I18N_NOOP2("KFile System Bookmarks", "Audio Files")));
-        m_systemBookmarks.append(SystemBookmarkData(QUrl(QStringLiteral("search:/videos")),
-                                                    QStringLiteral("folder-videos"),
-                                                    I18N_NOOP2("KFile System Bookmarks", "Videos")));
+    for(int r = 0, rMax = m_sourceModel->rowCount(); r < rMax; r++) {
+        const QModelIndex sourceIndex = m_sourceModel->index(r, 0);
+        if (m_hiddenItemsShown || !m_sourceModel->isHidden(sourceIndex)) {
+            addItemFromSourceModel(sourceIndex);
+        }
     }
 
-    for (int i = 0; i < m_systemBookmarks.count(); ++i) {
-        m_systemBookmarksIndexes.insert(m_systemBookmarks[i].url, i);
-    }
+#ifdef PLACESITEMMODEL_DEBUG
+    qCDebug(DolphinDebug) << "Loaded bookmarks";
+    showModelState();
+#endif
 }
 
 void PlacesItemModel::clear() {
-    m_bookmarkedItems.clear();
     KStandardItemModel::clear();
 }
 
@@ -981,50 +670,16 @@ void PlacesItemModel::proceedWithTearDown()
     m_deviceToTearDown->teardown();
 }
 
-void PlacesItemModel::initializeAvailableDevices()
+void PlacesItemModel::deleteItem(int index)
 {
-    QString predicate(QStringLiteral("[[[[ StorageVolume.ignored == false AND [ StorageVolume.usage == 'FileSystem' OR StorageVolume.usage == 'Encrypted' ]]"
-        " OR "
-        "[ IS StorageAccess AND StorageDrive.driveType == 'Floppy' ]]"
-        " OR "
-        "OpticalDisc.availableContent & 'Audio' ]"
-        " OR "
-        "StorageAccess.ignored == false ]"));
-
-
-    if (KProtocolInfo::isKnownProtocol(QStringLiteral("mtp"))) {
-        predicate.prepend("[");
-        predicate.append(" OR PortableMediaPlayer.supportedProtocols == 'mtp']");
-    }
-
-    m_predicate = Solid::Predicate::fromString(predicate);
-    Q_ASSERT(m_predicate.isValid());
-
-    Solid::DeviceNotifier* notifier = Solid::DeviceNotifier::instance();
-    connect(notifier, &Solid::DeviceNotifier::deviceAdded,   this, &PlacesItemModel::slotDeviceAdded);
-    connect(notifier, &Solid::DeviceNotifier::deviceRemoved, this, &PlacesItemModel::slotDeviceRemoved);
-
-    const QList<Solid::Device>& deviceList = Solid::Device::listFromQuery(m_predicate);
-    foreach (const Solid::Device& device, deviceList) {
-        m_availableDevices << device.udi();
-    }
+    QModelIndex sourceIndex = mapToSource(index);
+    Q_ASSERT(sourceIndex.isValid());
+    m_sourceModel->removePlace(sourceIndex);
 }
 
-int PlacesItemModel::bookmarkIndex(int index) const
+void PlacesItemModel::refresh()
 {
-    int bookmarkIndex = 0;
-    int modelIndex = 0;
-    while (bookmarkIndex < m_bookmarkedItems.count()) {
-        if (!m_bookmarkedItems[bookmarkIndex]) {
-            if (modelIndex == index) {
-                break;
-            }
-            ++modelIndex;
-        }
-        ++bookmarkIndex;
-    }
-
-    return bookmarkIndex >= m_bookmarkedItems.count() ? -1 : bookmarkIndex;
+    m_sourceModel->refresh();
 }
 
 void PlacesItemModel::hideItem(int index)
@@ -1035,36 +690,6 @@ void PlacesItemModel::hideItem(int index)
     }
 
     shownItem->setHidden(true);
-    if (m_hiddenItemsShown) {
-        // Removing items from the model is not allowed if all hidden
-        // items should be shown.
-        return;
-    }
-
-    const int newIndex = bookmarkIndex(index);
-    if (newIndex >= 0) {
-        const KBookmark hiddenBookmark = shownItem->bookmark();
-        PlacesItem* hiddenItem = new PlacesItem(hiddenBookmark);
-
-        const PlacesItem* previousItem = placesItem(index - 1);
-        KBookmark previousBookmark;
-        if (previousItem) {
-            previousBookmark = previousItem->bookmark();
-        }
-
-        const bool updateBookmark = (m_bookmarkManager->root().indexOf(hiddenBookmark) >= 0);
-        removeItem(index);
-
-        if (updateBookmark) {
-            // removeItem() also removed the bookmark from m_bookmarkManager in
-            // PlacesItemModel::onItemRemoved(). However for hidden items the
-            // bookmark should still be remembered, so readd it again:
-            m_bookmarkManager->root().addBookmark(hiddenBookmark);
-            m_bookmarkManager->root().moveBookmark(hiddenBookmark, previousBookmark);
-        }
-
-        m_bookmarkedItems.insert(newIndex, hiddenItem);
-    }
 }
 
 QString PlacesItemModel::internalMimeType() const
@@ -1078,7 +703,7 @@ int PlacesItemModel::groupedDropIndex(int index, const PlacesItem* item) const
     Q_ASSERT(item);
 
     int dropIndex = index;
-    const PlacesItem::GroupType type = item->groupType();
+    const QString group = item->group();
 
     const int itemCount = count();
     if (index < 0) {
@@ -1088,7 +713,7 @@ int PlacesItemModel::groupedDropIndex(int index, const PlacesItem* item) const
     // Search nearest previous item with the same group
     int previousIndex = -1;
     for (int i = dropIndex - 1; i >= 0; --i) {
-        if (placesItem(i)->groupType() == type) {
+        if (placesItem(i)->group() == group) {
             previousIndex = i;
             break;
         }
@@ -1097,7 +722,7 @@ int PlacesItemModel::groupedDropIndex(int index, const PlacesItem* item) const
     // Search nearest next item with the same group
     int nextIndex = -1;
     for (int i = dropIndex; i < count(); ++i) {
-        if (placesItem(i)->groupType() == type) {
+        if (placesItem(i)->group() == group) {
             nextIndex = i;
             break;
         }
@@ -1128,52 +753,13 @@ bool PlacesItemModel::equalBookmarkIdentifiers(const KBookmark& b1, const KBookm
     }
 }
 
-QUrl PlacesItemModel::createTimelineUrl(const QUrl& url)
+int PlacesItemModel::mapFromSource(const QModelIndex &index) const
 {
-    // TODO: Clarify with the Baloo-team whether it makes sense
-    // provide default-timeline-URLs like 'yesterday', 'this month'
-    // and 'last month'.
-    QUrl timelineUrl;
-
-    const QString path = url.toDisplayString(QUrl::PreferLocalFile);
-    if (path.endsWith(QLatin1String("yesterday"))) {
-        const QDate date = QDate::currentDate().addDays(-1);
-        const int year = date.year();
-        const int month = date.month();
-        const int day = date.day();
-        timelineUrl = QUrl("timeline:/" + timelineDateString(year, month) +
-              '/' + timelineDateString(year, month, day));
-    } else if (path.endsWith(QLatin1String("thismonth"))) {
-        const QDate date = QDate::currentDate();
-        timelineUrl = QUrl("timeline:/" + timelineDateString(date.year(), date.month()));
-    } else if (path.endsWith(QLatin1String("lastmonth"))) {
-        const QDate date = QDate::currentDate().addMonths(-1);
-        timelineUrl = QUrl("timeline:/" + timelineDateString(date.year(), date.month()));
-    } else {
-        Q_ASSERT(path.endsWith(QLatin1String("today")));
-        timelineUrl = url;
-    }
-
-    return timelineUrl;
-}
-
-QString PlacesItemModel::timelineDateString(int year, int month, int day)
-{
-    QString date = QString::number(year) + '-';
-    if (month < 10) {
-        date += '0';
-    }
-    date += QString::number(month);
-
-    if (day >= 1) {
-        date += '-';
-        if (day < 10) {
-            date += '0';
-        }
-        date += QString::number(day);
+    if (!index.isValid()) {
+        return -1;
     }
 
-    return date;
+    return m_indexMap.indexOf(index);
 }
 
 bool PlacesItemModel::isDir(int index) const
@@ -1182,39 +768,38 @@ bool PlacesItemModel::isDir(int index) const
     return true;
 }
 
-QUrl PlacesItemModel::createSearchUrl(const QUrl& url)
+KFilePlacesModel::GroupType PlacesItemModel::groupType(int row) const
 {
-    QUrl searchUrl;
-
-#ifdef HAVE_BALOO
-    const QString path = url.toDisplayString(QUrl::PreferLocalFile);
-    if (path.endsWith(QLatin1String("documents"))) {
-        searchUrl = searchUrlForType(QStringLiteral("Document"));
-    } else if (path.endsWith(QLatin1String("images"))) {
-        searchUrl = searchUrlForType(QStringLiteral("Image"));
-    } else if (path.endsWith(QLatin1String("audio"))) {
-        searchUrl = searchUrlForType(QStringLiteral("Audio"));
-    } else if (path.endsWith(QLatin1String("videos"))) {
-        searchUrl = searchUrlForType(QStringLiteral("Video"));
-    } else {
-        Q_ASSERT(false);
-    }
-#else
-    Q_UNUSED(url);
-#endif
+    return m_sourceModel->groupType(mapToSource(row));
+}
 
-    return searchUrl;
+bool PlacesItemModel::isGroupHidden(KFilePlacesModel::GroupType type) const
+{
+    return m_sourceModel->isGroupHidden(type);
 }
 
-#ifdef HAVE_BALOO
-QUrl PlacesItemModel::searchUrlForType(const QString& type)
+void PlacesItemModel::setGroupHidden(KFilePlacesModel::GroupType type, bool hidden)
 {
-    Baloo::Query query;
-    query.addType(type);
+    return m_sourceModel->setGroupHidden(type, hidden);
+}
 
-    return query.toSearchUrl();
+QModelIndex PlacesItemModel::mapToSource(int row) const
+{
+    return m_indexMap.value(row);
+}
+
+PlacesItem *PlacesItemModel::itemFromBookmark(const KBookmark &bookmark) const
+{
+    const QString id = bookmarkId(bookmark);
+    for (int i = 0, iMax = count(); i < iMax; i++) {
+        PlacesItem *item = placesItem(i);
+        const KBookmark itemBookmark = item->bookmark();
+        if (bookmarkId(itemBookmark) == id) {
+            return item;
+        }
+    }
+    return nullptr;
 }
-#endif
 
 #ifdef PLACESITEMMODEL_DEBUG
 void PlacesItemModel::showModelState()
index 7dd49bf5a7b17f0c92bd867ea76758af9eaa6bb9..a1b23b220190bc6cce7a930c5f553a6041aea62d 100644 (file)
@@ -20,9 +20,8 @@
 #ifndef PLACESITEMMODEL_H
 #define PLACESITEMMODEL_H
 
-#include <config-baloo.h>
-
 #include <kitemviews/kstandarditemmodel.h>
+#include <KFilePlacesModel>
 
 #include <QUrl>
 #include <QHash>
@@ -35,7 +34,6 @@ class KBookmark;
 class KBookmarkManager;
 class PlacesItem;
 class QAction;
-class QTimer;
 
 // #define PLACESITEMMODEL_DEBUG
 
@@ -50,19 +48,26 @@ class PlacesItemModel: public KStandardItemModel
     Q_OBJECT
 
 public:
-    explicit PlacesItemModel(QObject* parent = 0);
-    virtual ~PlacesItemModel();
+    explicit PlacesItemModel(QObject* parent = nullptr);
+    ~PlacesItemModel() override;
 
     /**
-     * @return A new instance of a places item with the given
-     *         attributes.
+     * @brief Create a new place entry in the bookmark file
+     * and add it to the model
      */
-    PlacesItem* createPlacesItem(const QString& text,
-                                 const QUrl& url,
-                                 const QString& iconName = QString());
+    void createPlacesItem(const QString& text,
+                          const QUrl& url,
+                          const QString& iconName = QString(),
+                          int after = -1);
 
     PlacesItem* placesItem(int index) const;
 
+    /**
+     * @brief Mark an item as hiden
+     * @param index of the item to be hidden
+     */
+    void hideItem(int index);
+
     /**
      * If set to true, all items that are marked as hidden
      * will be shown in the view. The items will
@@ -89,15 +94,6 @@ public:
      */
     int closestItem(const QUrl& url) const;
 
-    /**
-     * Appends the item \a item as last element of the group
-     * the item belongs to. If no item with the same group is
-     * present, the item gets appended as last element of the
-     * model. PlacesItemModel takes the ownership
-     * of the item.
-     */
-    void appendItemToGroup(PlacesItem* item);
-
     QAction* ejectAction(int index) const;
     QAction* teardownAction(int index) const;
 
@@ -107,9 +103,9 @@ public:
     bool storageSetupNeeded(int index) const;
     void requestStorageSetup(int index);
 
-    virtual QMimeData* createMimeData(const KItemSet& indexes) const Q_DECL_OVERRIDE;
+    QMimeData* createMimeData(const KItemSet& indexes) const override;
 
-    virtual bool supportsDropping(int index) const Q_DECL_OVERRIDE;
+    bool supportsDropping(int index) const override;
 
     void dropMimeDataBefore(int index, const QMimeData* mimeData);
 
@@ -121,18 +117,32 @@ public:
      */
     static QUrl convertedUrl(const QUrl& url);
 
-    virtual void clear() Q_DECL_OVERRIDE;
+    void clear() override;
 
     void proceedWithTearDown();
 
     /**
-     * Saves the bookmarks and indicates to other applications that the
-     * state of the bookmarks has been changed. Is only called by the
-     * timeout of m_saveBookmarksTimer to prevent unnecessary savings.
+     * @brief Remove item from bookmark
+     *
+     * This function remove the index from bookmark file permanently
+     *
+     * @param index - the item to be removed
      */
-    void saveBookmarks();
+    void deleteItem(int index);
+
+    /**
+    * Force a sync on the bookmarks and indicates to other applications that the
+    * state of the bookmarks has been changed.
+    */
+    void refresh();
+
+    bool isDir(int index) const override;
+
+
+    KFilePlacesModel::GroupType groupType(int row) const;
+    bool isGroupHidden(KFilePlacesModel::GroupType type) const;
+    void setGroupHidden(KFilePlacesModel::GroupType type, bool hidden);
 
-    bool isDir(int index) const Q_DECL_OVERRIDE;
 signals:
     void errorMessage(const QString& message);
     void storageSetupDone(int index, bool success);
@@ -140,26 +150,28 @@ signals:
     void storageTearDownExternallyRequested(const QString& mountPath);
 
 protected:
-    virtual void onItemInserted(int index) Q_DECL_OVERRIDE;
-    virtual void onItemRemoved(int index, KStandardItem* removedItem) Q_DECL_OVERRIDE;
-    virtual void onItemChanged(int index, const QSet<QByteArray>& changedRoles) Q_DECL_OVERRIDE;
+    void onItemInserted(int index) override;
+    void onItemRemoved(int index, KStandardItem* removedItem) override;
+    void onItemChanged(int index, const QSet<QByteArray>& changedRoles) override;
 
 private slots:
-    void slotDeviceAdded(const QString& udi);
-    void slotDeviceRemoved(const QString& udi);
     void slotStorageTearDownDone(Solid::ErrorType error, const QVariant& errorData);
     void slotStorageSetupDone(Solid::ErrorType error, const QVariant& errorData, const QString& udi);
-    void hideItem();
 
-    /**
-     * Updates the bookmarks from the model corresponding to the changed
-     * bookmarks stored by the bookmark-manager. Is called whenever the bookmarks
-     * have been changed by another application.
-     */
-    void updateBookmarks();
+    // source model control
+    void onSourceModelRowsInserted(const QModelIndex &parent, int first, int last);
+    void onSourceModelRowsAboutToBeRemoved(const QModelIndex &parent, int first, int last);
+    void onSourceModelRowsAboutToBeMoved(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row);
+    void onSourceModelRowsMoved(const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row);
+    void onSourceModelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector<int> &roles);
+    void onSourceModelGroupHiddenChanged(KFilePlacesModel::GroupType group, bool hidden);
 
 private:
-    struct SystemBookmarkData;
+    /**
+     * Remove bookmarks created by the previous version of dolphin that are
+     * not valid anymore
+     */
+    void cleanupBookmarks();
 
     /**
      * Loads the bookmarks from the bookmark-manager and creates items for
@@ -167,43 +179,6 @@ private:
      */
     void loadBookmarks();
 
-    /**
-     * @return True, if the bookmark can be accepted in the context of the
-     *         current application (e.g. bookmarks from other applications
-     *         will be ignored).
-     */
-    bool acceptBookmark(const KBookmark& bookmark,
-                        const QSet<QString>& availableDevices) const;
-
-    /**
-     * Creates a PlacesItem for a system-bookmark:
-     * - PlacesItem::isSystemItem() will return true
-     * - Default view-properties will be created for "Search For" items
-     * The item is not inserted to the model yet.
-     */
-    PlacesItem* createSystemPlacesItem(const SystemBookmarkData& data);
-
-    /**
-     * Creates system bookmarks that are shown per default and can
-     * only be hidden but not removed. The result will be stored
-     * in m_systemBookmarks.
-     */
-    void createSystemBookmarks();
-
-    void initializeAvailableDevices();
-
-    /**
-     * @param index Item index related to the model.
-     * @return      Corresponding index related to m_bookmarkedItems.
-     */
-    int bookmarkIndex(int index) const;
-
-    /**
-     * Marks the item with the index \a index as hidden and
-     * removes it from the model so that it gets invisible.
-     */
-    void hideItem(int index);
-
     QString internalMimeType() const;
 
     /**
@@ -220,77 +195,41 @@ private:
     static bool equalBookmarkIdentifiers(const KBookmark& b1, const KBookmark& b2);
 
     /**
-     * @return URL using the timeline-protocol for searching (see convertedUrl()).
-     */
-    static QUrl createTimelineUrl(const QUrl& url);
-
-    /**
-     * Helper method for createTimelineUrl().
-     * @return String that represents a date-path in the format that
-     *         the timeline-protocol expects.
-     */
-    static QString timelineDateString(int year, int month, int day = 0);
-
-    /**
-     * @return URL that can be listed by KIO and results in searching
-     *         for a given term. The URL \a url represents a places-internal
-     *         URL like e.g. "search:/documents" (see convertedUrl()).
-     */
-    static QUrl createSearchUrl(const QUrl& url);
-
-#ifdef HAVE_BALOO
-    /**
-     * Helper method for createSearchUrl()
-     * @return URL that can be listed by KIO and results in searching
-     *         for the given type
+     * Appends the item \a item as last element of the group
+     * the item belongs to. If no item with the same group is
+     * present, the item gets appended as last element of the
+     * model. PlacesItemModel takes the ownership
+     * of the item.
      */
-    static QUrl searchUrlForType(const QString& type);
-#endif
+    void insertSortedItem(PlacesItem* item);
 
 #ifdef PLACESITEMMODEL_DEBUG
     void showModelState();
 #endif
 
+    PlacesItem *itemFromBookmark(const KBookmark &bookmark) const;
+
+    void addItemFromSourceModel(const QModelIndex &index);
+    void removeItemByIndex(const QModelIndex &mapToSource);
+
+    QString bookmarkId(const KBookmark &bookmark) const;
+    void initializeDefaultViewProperties() const;
+
+    int mapFromSource(const QModelIndex &index) const;
+    QModelIndex mapToSource(int row) const;
+
+    static void updateItem(PlacesItem *item, const QModelIndex &index);
+
 private:
-    bool m_fileIndexingEnabled;
     bool m_hiddenItemsShown;
 
-    QSet<QString> m_availableDevices;
-    Solid::Predicate m_predicate;
-    KBookmarkManager* m_bookmarkManager;
-
-    struct SystemBookmarkData
-    {
-        SystemBookmarkData(const QUrl& url,
-                           const QString& icon,
-                           const QString& text) :
-            url(url), icon(icon), text(text) {}
-        QUrl url;
-        QString icon;
-        QString text;
-    };
-
-    QList<SystemBookmarkData> m_systemBookmarks;
-    QHash<QUrl, int> m_systemBookmarksIndexes;
-
-    // Contains hidden and unhidden items that are stored as
-    // bookmark (the model itself only contains items that
-    // are shown in the view). If an entry is 0, then the
-    // places-item is part of the model. If an entry is not
-    // 0, the item is hidden and not part of the model.
-    QList<PlacesItem*> m_bookmarkedItems;
-
-    // Index of the hidden item that should be removed in
-    // removeHiddenItem(). The removing must be done
-    // asynchronously as in the scope of onItemChanged()
-    // removing an item is not allowed.
-    int m_hiddenItemToRemove;
-
     Solid::StorageAccess *m_deviceToTearDown;
 
-    QTimer* m_updateBookmarksTimer;
-
     QHash<QObject*, int> m_storageSetupInProgress;
+
+    QScopedPointer<KFilePlacesModel> m_sourceModel;
+
+    QVector<QPersistentModelIndex> m_indexMap;
 };
 
 #endif
index 6110f717d6638c26e1dd2f8b0f2c1b61d1335ab9..49c8e43c9694cad1bcf319d95c0f509b31131e04 100644 (file)
@@ -48,7 +48,7 @@ class PlacesItemSignalHandler: public QObject
 
 public:
     explicit PlacesItemSignalHandler(PlacesItem* item, QObject* parent = nullptr);
-    virtual ~PlacesItemSignalHandler();
+    ~PlacesItemSignalHandler() override;
 
 public slots:
     /**
index 0b76f18d3b43b2bdc425e1788494150211063672..f7ca7d010dea5487c91d4fdc9e17dd3c711dd3de 100644 (file)
@@ -34,6 +34,7 @@
 #include <KIO/DropJob>
 #include <KIO/EmptyTrashJob>
 #include <KIO/JobUiDelegate>
+#include <KFilePlacesModel>
 #include <KJobWidgets>
 #include <KLocalizedString>
 #include <KIconLoader>
@@ -170,10 +171,10 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos)
 
     QMenu menu(this);
 
-    QAction* emptyTrashAction = 0;
-    QAction* editAction = 0;
-    QAction* teardownAction = 0;
-    QAction* ejectAction = 0;
+    QAction* emptyTrashAction = nullptr;
+    QAction* editAction = nullptr;
+    QAction* teardownAction = nullptr;
+    QAction* ejectAction = nullptr;
 
     const QString label = item->text();
 
@@ -213,7 +214,7 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos)
         editAction = menu.addAction(QIcon::fromTheme("document-properties"), i18nc("@item:inmenu", "Edit..."));
     }
 
-    QAction* removeAction = 0;
+    QAction* removeAction = nullptr;
     if (!isDevice && !item->isSystemItem()) {
         removeAction = menu.addAction(QIcon::fromTheme(QStringLiteral("edit-delete")), i18nc("@item:inmenu", "Remove"));
     }
@@ -222,6 +223,8 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos)
     hideAction->setCheckable(true);
     hideAction->setChecked(item->isHidden());
 
+    buildGroupContextMenu(&menu, index);
+
     QAction* action = menu.exec(pos.toPoint());
     if (action) {
         if (action == emptyTrashAction) {
@@ -239,13 +242,11 @@ void PlacesPanel::slotItemContextMenuRequested(int index, const QPointF& pos)
             if (action == editAction) {
                 editEntry(index);
             } else if (action == removeAction) {
-                m_model->removeItem(index);
-                m_model->saveBookmarks();
+                m_model->deleteItem(index);
             } else if (action == hideAction) {
                 item->setHidden(hideAction->isChecked());
-                m_model->saveBookmarks();
             } else if (action == openInNewWindowAction) {
-                Dolphin::openNewWindow({PlacesItemModel::convertedUrl(m_model->data(index).value("url").toUrl())}, this);
+                Dolphin::openNewWindow({KFilePlacesModel::convertedUrl(m_model->data(index).value("url").toUrl())}, this);
             } else if (action == openInNewTabAction) {
                 // TriggerItem does set up the storage first and then it will
                 // emit the slotItemMiddleClicked signal, because of Qt::MiddleButton.
@@ -267,13 +268,15 @@ void PlacesPanel::slotViewContextMenuRequested(const QPointF& pos)
 
     QAction* addAction = menu.addAction(QIcon::fromTheme(QStringLiteral("document-new")), i18nc("@item:inmenu", "Add Entry..."));
 
-    QAction* showAllAction = 0;
+    QAction* showAllAction = nullptr;
     if (m_model->hiddenCount() > 0) {
         showAllAction = menu.addAction(i18nc("@item:inmenu", "Show All Entries"));
         showAllAction->setCheckable(true);
         showAllAction->setChecked(m_model->hiddenItemsShown());
     }
 
+    buildGroupContextMenu(&menu, m_controller->indexCloseToMousePressedPosition());
+
     QMenu* iconSizeSubMenu = new QMenu(i18nc("@item:inmenu", "Icon Size"), &menu);
 
     struct IconSizeInfo
@@ -327,6 +330,24 @@ void PlacesPanel::slotViewContextMenuRequested(const QPointF& pos)
     selectClosestItem();
 }
 
+QAction *PlacesPanel::buildGroupContextMenu(QMenu *menu, int index)
+{
+    if (index == -1) {
+        return nullptr;
+    }
+
+    KFilePlacesModel::GroupType groupType = m_model->groupType(index);
+    QAction *hideGroupAction = menu->addAction(i18nc("@item:inmenu", "Hide Section '%1'", m_model->item(index)->group()));
+    hideGroupAction->setCheckable(true);
+    hideGroupAction->setChecked(m_model->isGroupHidden(groupType));
+
+    connect(hideGroupAction, &QAction::triggered, this, [this, groupType, hideGroupAction]{
+        m_model->setGroupHidden(groupType, hideGroupAction->isChecked());
+    });
+
+    return hideGroupAction;
+}
+
 void PlacesPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event)
 {
     if (index < 0) {
@@ -334,8 +355,8 @@ void PlacesPanel::slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* even
     }
 
     const PlacesItem* destItem = m_model->placesItem(index);
-    const PlacesItem::GroupType group = destItem->groupType();
-    if (group == PlacesItem::SearchForType || group == PlacesItem::RecentlySavedType) {
+
+    if (destItem->isSearchOrTimelineUrl()) {
         return;
     }
 
@@ -388,15 +409,14 @@ void PlacesPanel::slotItemDropEventStorageSetupDone(int index, bool success)
         delete m_itemDropEvent;
 
         m_itemDropEventIndex = -1;
-        m_itemDropEventMimeData = 0;
-        m_itemDropEvent = 0;
+        m_itemDropEventMimeData = nullptr;
+        m_itemDropEvent = nullptr;
     }
 }
 
 void PlacesPanel::slotAboveItemDropEvent(int index, QGraphicsSceneDragDropEvent* event)
 {
     m_model->dropMimeDataBefore(index, event->mimeData());
-    m_model->saveBookmarks();
 }
 
 void PlacesPanel::slotUrlsDropped(const QUrl& dest, QDropEvent* event, QWidget* parent)
@@ -413,7 +433,7 @@ void PlacesPanel::slotTrashUpdated(KJob* job)
         emit errorMessage(job->errorString());
     }
     // as long as KIO doesn't do this, do it ourselves
-    KNotification::event(QStringLiteral("Trash: emptied"), QString(), QPixmap(), 0, KNotification::DefaultEvent);
+    KNotification::event(QStringLiteral("Trash: emptied"), QString(), QPixmap(), nullptr, KNotification::DefaultEvent);
 }
 
 void PlacesPanel::slotStorageSetupDone(int index, bool success)
@@ -456,9 +476,7 @@ void PlacesPanel::addEntry()
     dialog->setAllowGlobal(true);
     dialog->setUrl(url);
     if (dialog->exec() == QDialog::Accepted) {
-        PlacesItem* item = m_model->createPlacesItem(dialog->text(), dialog->url(), dialog->icon());
-        m_model->appendItemToGroup(item);
-        m_model->saveBookmarks();
+        m_model->createPlacesItem(dialog->text(), dialog->url(), dialog->icon());
     }
 
     delete dialog;
@@ -480,7 +498,7 @@ void PlacesPanel::editEntry(int index)
             oldItem->setText(dialog->text());
             oldItem->setUrl(dialog->url());
             oldItem->setIcon(dialog->icon());
-            m_model->saveBookmarks();
+            m_model->refresh();
         }
     }
 
@@ -517,9 +535,9 @@ void PlacesPanel::triggerItem(int index, Qt::MouseButton button)
         const QUrl url = m_model->data(index).value("url").toUrl();
         if (!url.isEmpty()) {
             if (button == Qt::MiddleButton) {
-                emit placeMiddleClicked(PlacesItemModel::convertedUrl(url));
+                emit placeMiddleClicked(KFilePlacesModel::convertedUrl(url));
             } else {
-                emit placeActivated(PlacesItemModel::convertedUrl(url));
+                emit placeActivated(KFilePlacesModel::convertedUrl(url));
             }
         }
     }
index 4e525a0372d51c98897c16f87049214552d5e524..444785888ec0cfce0fb80b0d4f1a4875980987d6 100644 (file)
@@ -31,6 +31,7 @@ class PlacesItemModel;
 class PlacesView;
 class QGraphicsSceneDragDropEvent;
 class KJob;
+class QMenu;
 /**
  * @brief Combines bookmarks and mounted devices as list.
  */
@@ -40,7 +41,7 @@ class PlacesPanel : public Panel
 
 public:
     explicit PlacesPanel(QWidget* parent);
-    virtual ~PlacesPanel();
+    ~PlacesPanel() override;
     void proceedWithTearDown();
 
 signals:
@@ -51,11 +52,11 @@ signals:
     void storageTearDownExternallyRequested(const QString& mountPath);
 
 protected:
-    virtual bool urlChanged() Q_DECL_OVERRIDE;
-    virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
+    bool urlChanged() override;
+    void showEvent(QShowEvent* event) override;
 
 public slots:
-    virtual void readSettings() Q_DECL_OVERRIDE;
+    void readSettings() override;
 
 private slots:
     void slotItemActivated(int index);
@@ -82,6 +83,8 @@ private:
 
     void triggerItem(int index, Qt::MouseButton button);
 
+    QAction* buildGroupContextMenu(QMenu* menu, int index);
+
 private:
     KItemListController* m_controller;
     PlacesItemModel* m_model;
index b7d3605aa57ea147c67a1f772f1bf90825131e29..849d3f8c903965f6e62e5dfd138c76bb1726abca 100644 (file)
 TerminalPanel::TerminalPanel(QWidget* parent) :
     Panel(parent),
     m_clearTerminal(true),
-    m_mostLocalUrlJob(0),
-    m_layout(0),
-    m_terminal(0),
-    m_terminalWidget(0),
-    m_konsolePart(0),
+    m_mostLocalUrlJob(nullptr),
+    m_layout(nullptr),
+    m_terminal(nullptr),
+    m_terminalWidget(nullptr),
+    m_konsolePart(nullptr),
     m_konsolePartCurrentDirectory(),
     m_sendCdToTerminalHistory()
 {
@@ -69,16 +69,23 @@ QString TerminalPanel::currentWorkingDirectory()
 
 void TerminalPanel::terminalExited()
 {
-    m_terminal = 0;
+    m_terminal = nullptr;
     emit hideTerminalPanel();
 }
 
+bool TerminalPanel::isHiddenInVisibleWindow()
+{
+    return parentWidget()
+        && parentWidget()->isHidden()
+        && m_terminal
+        && (m_terminal->foregroundProcessId() == -1);
+}
+
 void TerminalPanel::dockVisibilityChanged()
 {
     // Only react when the DockWidget itself (not some parent) is hidden. This way we don't
     // respond when e.g. Dolphin is minimized.
-    if (parentWidget() && parentWidget()->isHidden() &&
-        m_terminal && (m_terminal->foregroundProcessId() == -1)) {
+    if (isHiddenInVisibleWindow()) {
         // Make sure that the following "cd /" command will not affect the view.
         disconnect(m_konsolePart, SIGNAL(currentDirectoryChanged(QString)),
                    this, SLOT(slotKonsolePartCurrentDirectoryChanged(QString)));
@@ -117,12 +124,12 @@ void TerminalPanel::showEvent(QShowEvent* event)
 
     if (!m_terminal) {
         m_clearTerminal = true;
-        KPluginFactory* factory = 0;
+        KPluginFactory* factory = nullptr;
         KService::Ptr service = KService::serviceByDesktopName(QStringLiteral("konsolepart"));
         if (service) {
             factory = KPluginLoader(service->library()).factory();
         }
-        m_konsolePart = factory ? (factory->create<KParts::ReadOnlyPart>(this)) : 0;
+        m_konsolePart = factory ? (factory->create<KParts::ReadOnlyPart>(this)) : nullptr;
         if (m_konsolePart) {
             connect(m_konsolePart, &KParts::ReadOnlyPart::destroyed, this, &TerminalPanel::terminalExited);
             m_terminalWidget = m_konsolePart->widget();
@@ -144,7 +151,7 @@ void TerminalPanel::showEvent(QShowEvent* event)
 void TerminalPanel::changeDir(const QUrl& url)
 {
     delete m_mostLocalUrlJob;
-    m_mostLocalUrlJob = 0;
+    m_mostLocalUrlJob = nullptr;
 
     if (url.isLocalFile()) {
         sendCdToTerminal(url.toLocalFile());
@@ -198,7 +205,7 @@ void TerminalPanel::slotMostLocalUrlResult(KJob* job)
         sendCdToTerminal(url.toLocalFile());
     }
 
-    m_mostLocalUrlJob = 0;
+    m_mostLocalUrlJob = nullptr;
 }
 
 void TerminalPanel::slotKonsolePartCurrentDirectoryChanged(const QString& dir)
index db5658e53c3bfb73e0767ee2a23183a42f467561..edaa2a6f3bec0f4944cd13f4d474faf271427d23 100644 (file)
@@ -46,7 +46,7 @@ class TerminalPanel : public Panel
 
 public:
     explicit TerminalPanel(QWidget* parent = nullptr);
-    virtual ~TerminalPanel();
+    ~TerminalPanel() override;
 
     /**
      * @brief This function is used to set the terminal panels's cwd to
@@ -54,6 +54,7 @@ public:
      */
     void goHome();
     QString currentWorkingDirectory();
+    bool isHiddenInVisibleWindow();
 
 public slots:
     void terminalExited();
@@ -68,9 +69,9 @@ signals:
     void changeUrl(const QUrl& url);
 
 protected:
-    virtual bool urlChanged() Q_DECL_OVERRIDE;
+    bool urlChanged() override;
 
-    virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
+    void showEvent(QShowEvent* event) override;
 
 private slots:
     void slotMostLocalUrlResult(KJob* job);
index 996829ee3024c4c76c215e00bfb829f0bc84a504..1e8ab6cea745affe57cf1c8ccc6b3dce503ecc76 100644 (file)
@@ -48,7 +48,7 @@ class DolphinFacetsWidget : public QWidget
 
 public:
     explicit DolphinFacetsWidget(QWidget* parent = nullptr);
-    virtual ~DolphinFacetsWidget();
+    ~DolphinFacetsWidget() override;
 
     QString ratingTerm() const;
     QString facetType() const;
index 3456920089eb972d606b5f5b3aabe7d32fe34539..44de97aa02ed14b99bd9e699a0cf0a0fcd713d3e 100644 (file)
@@ -53,20 +53,20 @@ DolphinSearchBox::DolphinSearchBox(QWidget* parent) :
     QWidget(parent),
     m_startedSearching(false),
     m_active(true),
-    m_topLayout(0),
-    m_searchLabel(0),
-    m_searchInput(0),
-    m_saveSearchAction(0),
-    m_optionsScrollArea(0),
-    m_fileNameButton(0),
-    m_contentButton(0),
-    m_separator(0),
-    m_fromHereButton(0),
-    m_everywhereButton(0),
-    m_facetsToggleButton(0),
-    m_facetsWidget(0),
+    m_topLayout(nullptr),
+    m_searchLabel(nullptr),
+    m_searchInput(nullptr),
+    m_saveSearchAction(nullptr),
+    m_optionsScrollArea(nullptr),
+    m_fileNameButton(nullptr),
+    m_contentButton(nullptr),
+    m_separator(nullptr),
+    m_fromHereButton(nullptr),
+    m_everywhereButton(nullptr),
+    m_facetsToggleButton(nullptr),
+    m_facetsWidget(nullptr),
     m_searchPath(),
-    m_startSearchTimer(0)
+    m_startSearchTimer(nullptr)
 {
 }
 
@@ -310,11 +310,9 @@ void DolphinSearchBox::slotSearchSaved()
     if (searchURL.isValid()) {
         PlacesItemModel model;
         const QString label = i18n("Search for %1 in %2", text(), searchPath().fileName());
-        PlacesItem* item = model.createPlacesItem(label,
-                                                  searchURL,
-                                                  QStringLiteral("folder-saved-search-symbolic"));
-        model.appendItemToGroup(item);
-        model.saveBookmarks();
+        model.createPlacesItem(label,
+                               searchURL,
+                               QStringLiteral("folder-saved-search-symbolic"));
     }
 }
 
index f1ea49091890feaef82e7f4975a668e2b091d86f..c138cfe7f3fb35776923a033b02755151a0b3391 100644 (file)
@@ -46,8 +46,8 @@ class DolphinSearchBox : public QWidget {
     Q_OBJECT
 
 public:
-    explicit DolphinSearchBox(QWidget* parent = 0);
-    virtual ~DolphinSearchBox();
+    explicit DolphinSearchBox(QWidget* parent = nullptr);
+    ~DolphinSearchBox() override;
 
     /**
      * Sets the text that should be used as input for
@@ -99,11 +99,11 @@ public:
     bool isActive() const;
 
 protected:
-    virtual bool event(QEvent* event) Q_DECL_OVERRIDE;
-    virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
-    virtual void hideEvent(QHideEvent* event) Q_DECL_OVERRIDE;
-    virtual void keyReleaseEvent(QKeyEvent* event) Q_DECL_OVERRIDE;
-    virtual bool eventFilter(QObject* obj, QEvent* event) Q_DECL_OVERRIDE;
+    bool event(QEvent* event) override;
+    void showEvent(QShowEvent* event) override;
+    void hideEvent(QHideEvent* event) override;
+    void keyReleaseEvent(QKeyEvent* event) override;
+    bool eventFilter(QObject* obj, QEvent* event) override;
 
 signals:
     /**
index 4589b5d4477a947622236fa10316a97bd39002ed..3eacd522ff93013f903b1b179728ad44ab7f45d5 100644 (file)
@@ -41,7 +41,7 @@ AdditionalInfoDialog::AdditionalInfoDialog(QWidget* parent,
                                            const QList<QByteArray>& visibleRoles) :
     QDialog(parent),
     m_visibleRoles(visibleRoles),
-    m_listWidget(0)
+    m_listWidget(nullptr)
 {
     setWindowTitle(i18nc("@title:window", "Additional Information"));
     setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum);
index fd72a7ce196d58cbf1bee11779e81c983a16cfe2..2a4cd7dbaa496af1a5541c59eb5cdce0fae2e774 100644 (file)
@@ -34,11 +34,11 @@ class AdditionalInfoDialog : public QDialog
 
 public:
     AdditionalInfoDialog(QWidget* parent, const QList<QByteArray>& visibleRoles);
-    virtual ~AdditionalInfoDialog();
+    ~AdditionalInfoDialog() override;
     QList<QByteArray> visibleRoles() const;
 
 public slots:
-    void accept() Q_DECL_OVERRIDE;
+    void accept() override;
 
 private:
     QList<QByteArray> m_visibleRoles;
index 591966759975aef87ba86c0409225e96e591434a..59f8c8eee68500ba36daef79664f4264877b9334 100644 (file)
@@ -26,7 +26,7 @@
 ApplyViewPropsJob::ApplyViewPropsJob(const QUrl& dir,
                                      const ViewProperties& viewProps) :
     KIO::Job(),
-    m_viewProps(0),
+    m_viewProps(nullptr),
     m_progress(0),
     m_dir(dir)
 {
@@ -46,7 +46,7 @@ ApplyViewPropsJob::ApplyViewPropsJob(const QUrl& dir,
 ApplyViewPropsJob::~ApplyViewPropsJob()
 {
     delete m_viewProps;  // the properties are written by the destructor
-    m_viewProps = 0;
+    m_viewProps = nullptr;
 }
 
 void ApplyViewPropsJob::slotEntries(KIO::Job*, const KIO::UDSEntryList& list)
index ea9688718ae4a12d38312dba3271682e7c1bb22d..aeb4a60c6de16caba15af69ac094ecd7fbfda8eb 100644 (file)
@@ -60,11 +60,11 @@ public:
      *                  sub directories.
      */
     ApplyViewPropsJob(const QUrl& dir, const ViewProperties& viewProps);
-    virtual ~ApplyViewPropsJob();
+    ~ApplyViewPropsJob() override;
     int progress() const;
 
 private slots:
-    virtual void slotResult(KJob* job) Q_DECL_OVERRIDE;
+    void slotResult(KJob* job) override;
     void slotEntries(KIO::Job*, const KIO::UDSEntryList&);
 
 private:
index 9584fc8b36f2054af7baf5ff2ba64e9af823bc89..6bcf3cd02bcdaec700c08f7d79b52a4a8fbe8681 100644 (file)
@@ -30,7 +30,7 @@
         <entry name="PreviewsShown" type="Bool" >
             <label context="@label">Previews shown</label>
             <whatsthis context="@info:whatsthis">When this option is enabled, a preview of the file content is shown as an icon.</whatsthis>
-            <default>false</default>
+            <default>true</default>
         </entry>
 
         <entry name="GroupedSorting" type="Bool" >
index 194af28fc5c5ba241b9bfa60caf74cb3c090b9b0..4c8768fde5ca473b0e67f643fc2b64805b12f77d 100644 (file)
@@ -36,8 +36,8 @@ class DolphinSettingsDialog : public KPageDialog
     Q_OBJECT
 
 public:
-    explicit DolphinSettingsDialog(const QUrl& url, QWidget* parent = 0);
-    virtual ~DolphinSettingsDialog();
+    explicit DolphinSettingsDialog(const QUrl& url, QWidget* parent = nullptr);
+    ~DolphinSettingsDialog() override;
 
 signals:
     void settingsChanged();
index 96eaf3d64413c5d71414a32d7d8b766b9992144f..16a3e95c2eff235b3a555f7a80a4db43669672fa 100644 (file)
@@ -37,13 +37,13 @@ class BehaviorSettingsPage : public SettingsPageBase
 
 public:
     BehaviorSettingsPage(const QUrl &url, QWidget* parent);
-    virtual ~BehaviorSettingsPage();
+    ~BehaviorSettingsPage() override;
 
     /** @see SettingsPageBase::applySettings() */
-    virtual void applySettings() Q_DECL_OVERRIDE;
+    void applySettings() override;
 
     /** @see SettingsPageBase::restoreDefaults() */
-    virtual void restoreDefaults() Q_DECL_OVERRIDE;
+    void restoreDefaults() override;
 
 private:
     void loadSettings();
index 620caeb51070e115adcd7d88e2d29f9a4aee7d58..e54fb464a7f64f2e86f06357feb226aa02cb818b 100644 (file)
@@ -40,7 +40,7 @@ public:
     ConfigurePreviewPluginDialog(const QString& pluginName,
                                  const QString& desktopEntryName,
                                  QWidget* parent);
-    virtual ~ConfigurePreviewPluginDialog() = default;
+    ~ConfigurePreviewPluginDialog() override = default;
 };
 
 #endif
index 2419dc0f4343b129a3ab32133d5aaf80bbe68086..90dd0ad37aae6a02c86bf045e879c0cec8734e7b 100644 (file)
@@ -35,9 +35,9 @@ namespace {
 
 ConfirmationsSettingsPage::ConfirmationsSettingsPage(QWidget* parent) :
     SettingsPageBase(parent),
-    m_confirmMoveToTrash(0),
-    m_confirmDelete(0),
-    m_confirmClosingMultipleTabs(0)
+    m_confirmMoveToTrash(nullptr),
+    m_confirmDelete(nullptr),
+    m_confirmClosingMultipleTabs(nullptr)
 {
     QVBoxLayout* topLayout = new QVBoxLayout(this);
 
index e702fe8ae23c0468a8ef5ca5d1526b5a7377271b..f8e5e3540cf7a999a11b828bbe9b753f918a079e 100644 (file)
@@ -32,13 +32,13 @@ class ConfirmationsSettingsPage : public SettingsPageBase
 
 public:
     ConfirmationsSettingsPage(QWidget* parent);
-    virtual ~ConfirmationsSettingsPage();
+    ~ConfirmationsSettingsPage() override;
 
     /** @see SettingsPageBase::applySettings() */
-    virtual void applySettings() Q_DECL_OVERRIDE;
+    void applySettings() override;
 
     /** @see SettingsPageBase::restoreDefaults() */
-    virtual void restoreDefaults() Q_DECL_OVERRIDE;
+    void restoreDefaults() override;
 
 private:
     void loadSettings();
index d8f61ef90b17f00401bd551eea2d1f88c90c807a..f9a2c67d0b0d6971efaa6fe93b6d34ae7722c11b 100644 (file)
@@ -65,7 +65,7 @@ GeneralSettingsPage::GeneralSettingsPage(const QUrl& url, QWidget* parent) :
     m_pages.append(confirmationsPage);
     m_pages.append(statusBarPage);
 
-    topLayout->addWidget(tabWidget, 0, 0);
+    topLayout->addWidget(tabWidget, 0, nullptr);
 }
 
 GeneralSettingsPage::~GeneralSettingsPage()
index 7073258fffe6593e5a8f2ecbcece94f1fb3fa76b..a68fc933b100ef4b265877fe41f1aaddc779ebe2 100644 (file)
@@ -41,13 +41,13 @@ class GeneralSettingsPage : public SettingsPageBase
 
 public:
     GeneralSettingsPage(const QUrl& url, QWidget* parent);
-    virtual ~GeneralSettingsPage();
+    ~GeneralSettingsPage() override;
 
     /** @see SettingsPageBase::applySettings() */
-    virtual void applySettings() Q_DECL_OVERRIDE;
+    void applySettings() override;
 
     /** @see SettingsPageBase::restoreDefaults() */
-    virtual void restoreDefaults() Q_DECL_OVERRIDE;
+    void restoreDefaults() override;
 
 private:
     QList<SettingsPageBase*> m_pages;
index 1a92cd16c30380a5da9fe112b5e258f6b9c0a955..e579a572d09d560fffc3612d7733f12795cd496f 100644 (file)
@@ -26,6 +26,7 @@
 #include <KLocalizedString>
 #include <KServiceTypeTrader>
 #include <KService>
+#include <KIO/PreviewJob>
 
 #include <settings/serviceitemdelegate.h>
 #include <settings/servicemodel.h>
@@ -51,9 +52,9 @@ namespace {
 PreviewsSettingsPage::PreviewsSettingsPage(QWidget* parent) :
     SettingsPageBase(parent),
     m_initialized(false),
-    m_listView(0),
+    m_listView(nullptr),
     m_enabledPreviewPlugins(),
-    m_remoteFileSizeBox(0)
+    m_remoteFileSizeBox(nullptr)
 {
     QVBoxLayout* topLayout = new QVBoxLayout(this);
 
@@ -172,11 +173,8 @@ void PreviewsSettingsPage::loadPreviewPlugins()
 
 void PreviewsSettingsPage::loadSettings()
 {
-    KConfigGroup globalConfig(KSharedConfig::openConfig(), "PreviewSettings");
-    m_enabledPreviewPlugins = globalConfig.readEntry("Plugins", QStringList()
-                                                     << QStringLiteral("directorythumbnail")
-                                                     << QStringLiteral("imagethumbnail")
-                                                     << QStringLiteral("jpegthumbnail"));
+    const KConfigGroup globalConfig(KSharedConfig::openConfig(), QStringLiteral("PreviewSettings"));
+    m_enabledPreviewPlugins = globalConfig.readEntry("Plugins", KIO::PreviewJob::defaultPlugins());
 
     const qulonglong defaultRemotePreview = static_cast<qulonglong>(MaxRemotePreviewSize) * 1024 * 1024;
     const qulonglong maxRemoteByteSize = globalConfig.readEntry("MaximumRemoteSize", defaultRemotePreview);
index 6e896f05ecdf4c406c92fa7c5410462be69cfbfb..0bac4da650a00cf78fc1850f2b35817d4b05ce6a 100644 (file)
@@ -35,20 +35,20 @@ class PreviewsSettingsPage : public SettingsPageBase
 
 public:
     PreviewsSettingsPage(QWidget* parent);
-    virtual ~PreviewsSettingsPage();
+    ~PreviewsSettingsPage() override;
 
     /**
      * Applies the general settings for the view modes
      * The settings are persisted automatically when
      * closing Dolphin.
      */
-    virtual void applySettings() Q_DECL_OVERRIDE;
+    void applySettings() override;
 
     /** Restores the settings to default values. */
-    virtual void restoreDefaults() Q_DECL_OVERRIDE;
+    void restoreDefaults() override;
 
 protected:
-    virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
+    void showEvent(QShowEvent* event) override;
 
 private slots:
     void configureService(const QModelIndex& index);
index 60835437162e832ff28ce2c28fbd294be8413eea..d85f0aaa1549792c2d92c0091688a4683c47d549 100644 (file)
@@ -32,13 +32,13 @@ class StatusBarSettingsPage : public SettingsPageBase
 
 public:
     StatusBarSettingsPage(QWidget* parent);
-    virtual ~StatusBarSettingsPage();
+    ~StatusBarSettingsPage() override;
 
     /** @see SettingsPageBase::applySettings() */
-    virtual void applySettings() Q_DECL_OVERRIDE;
+    void applySettings() override;
 
     /** @see SettingsPageBase::restoreDefaults() */
-    virtual void restoreDefaults() Q_DECL_OVERRIDE;
+    void restoreDefaults() override;
 
 private:
     void loadSettings();
index f5ac4cd55651547a42720144219d39d6a5b2a3ba..3aedf507505714e7ced18d81178ab75bbc9c8a11 100644 (file)
@@ -65,7 +65,7 @@ DolphinGeneralConfigModule::DolphinGeneralConfigModule(QWidget* parent, const QV
     m_pages.append(previewsPage);
     m_pages.append(confirmationsPage);
 
-    topLayout->addWidget(tabWidget, 0, 0);
+    topLayout->addWidget(tabWidget, 0, nullptr);
 }
 
 DolphinGeneralConfigModule::~DolphinGeneralConfigModule()
index 50331a75c45a73db0c027df9d7489f72566ec01c..66e42009f81b82f5811d5bb23630bd4cf2015581 100644 (file)
@@ -34,10 +34,10 @@ class DolphinGeneralConfigModule : public KCModule
 
 public:
     DolphinGeneralConfigModule(QWidget* parent, const QVariantList& args);
-    virtual ~DolphinGeneralConfigModule();
+    ~DolphinGeneralConfigModule() override;
 
-    virtual void save() Q_DECL_OVERRIDE;
-    virtual void defaults() Q_DECL_OVERRIDE;
+    void save() override;
+    void defaults() override;
 
 private:
     QList<SettingsPageBase*> m_pages;
index 9ec6ca166ac18adc711bca71e1261b55d9ed7f8e..54cf7ed3c0b29ec395df97c27b73a6c3d8145f38 100644 (file)
@@ -30,7 +30,7 @@ K_PLUGIN_FACTORY(KCMDolphinNavigationConfigFactory, registerPlugin<DolphinNaviga
 
 DolphinNavigationConfigModule::DolphinNavigationConfigModule(QWidget* parent, const QVariantList& args) :
     KCModule(parent),
-    m_navigation(0)
+    m_navigation(nullptr)
 {
     Q_UNUSED(args);
 
@@ -41,7 +41,7 @@ DolphinNavigationConfigModule::DolphinNavigationConfigModule(QWidget* parent, co
 
     m_navigation = new NavigationSettingsPage(this);
     connect(m_navigation, &NavigationSettingsPage::changed, this, static_cast<void(DolphinNavigationConfigModule::*)()>(&DolphinNavigationConfigModule::changed));
-    topLayout->addWidget(m_navigation, 0, 0);
+    topLayout->addWidget(m_navigation, 0, nullptr);
 }
 
 DolphinNavigationConfigModule::~DolphinNavigationConfigModule()
index e8de0753e68d46a4e95c58659a23692a6b5d916e..2bcc7ababe2ae7ac2315c1384188c5c0d72a9171 100644 (file)
@@ -33,10 +33,10 @@ class DolphinNavigationConfigModule : public KCModule
 
 public:
     DolphinNavigationConfigModule(QWidget* parent, const QVariantList& args);
-    virtual ~DolphinNavigationConfigModule();
+    ~DolphinNavigationConfigModule() override;
 
-    virtual void save() Q_DECL_OVERRIDE;
-    virtual void defaults() Q_DECL_OVERRIDE;
+    void save() override;
+    void defaults() override;
 
 private:
     NavigationSettingsPage* m_navigation;
index 39136724edffd13900fe028f53f0edca5f5e7f24..5d011c627343bb15271b584121098ec3f784f811 100644 (file)
@@ -30,7 +30,7 @@ K_PLUGIN_FACTORY(KCMDolphinServicesConfigFactory, registerPlugin<DolphinServices
 
 DolphinServicesConfigModule::DolphinServicesConfigModule(QWidget* parent, const QVariantList& args) :
     KCModule(parent),
-    m_services(0)
+    m_services(nullptr)
 {
     Q_UNUSED(args);
 
@@ -41,7 +41,7 @@ DolphinServicesConfigModule::DolphinServicesConfigModule(QWidget* parent, const
 
     m_services = new ServicesSettingsPage(this);
     connect(m_services, &ServicesSettingsPage::changed, this, static_cast<void(DolphinServicesConfigModule::*)()>(&DolphinServicesConfigModule::changed));
-    topLayout->addWidget(m_services, 0, 0);
+    topLayout->addWidget(m_services, 0, nullptr);
 }
 
 DolphinServicesConfigModule::~DolphinServicesConfigModule()
index 8a63bb045d134c6e9ebc7e64bb936da020fca043..6c6af6728a12f8beee2a7ee4579089886515af98 100644 (file)
@@ -33,10 +33,10 @@ class DolphinServicesConfigModule : public KCModule
 
 public:
     DolphinServicesConfigModule(QWidget* parent, const QVariantList& args);
-    virtual ~DolphinServicesConfigModule();
+    ~DolphinServicesConfigModule() override;
 
-    virtual void save() Q_DECL_OVERRIDE;
-    virtual void defaults() Q_DECL_OVERRIDE;
+    void save() override;
+    void defaults() override;
 
 private:
     ServicesSettingsPage* m_services;
index 710ebc70b64665306a6c68dffe43e9e751fb7236..af9b49026b9821bec992cb53749d1ac346414a2c 100644 (file)
@@ -66,7 +66,7 @@ DolphinViewModesConfigModule::DolphinViewModesConfigModule(QWidget* parent, cons
     m_tabs.append(compactTab);
     m_tabs.append(detailsTab);
 
-    topLayout->addWidget(tabWidget, 0, 0);
+    topLayout->addWidget(tabWidget, 0, nullptr);
 }
 
 DolphinViewModesConfigModule::~DolphinViewModesConfigModule()
index 0a0b0ff10df22019a9e1c12a3b40011deaa1b2fe..c3775adff9d1b90c27ff719f7e918e4816aa4fe5 100644 (file)
@@ -33,10 +33,10 @@ class DolphinViewModesConfigModule : public KCModule
 
 public:
     DolphinViewModesConfigModule(QWidget* parent, const QVariantList& args);
-    virtual ~DolphinViewModesConfigModule();
+    ~DolphinViewModesConfigModule() override;
 
-    virtual void save() Q_DECL_OVERRIDE;
-    virtual void defaults() Q_DECL_OVERRIDE;
+    void save() override;
+    void defaults() override;
 
 private:
     void reparseConfiguration();
index e37a35d8eb9e6141319243338882e254c4f5518f..82015480a8b9b6f5ae06281fbc384b193b7a4fd5 100644 (file)
@@ -28,8 +28,8 @@
 
 NavigationSettingsPage::NavigationSettingsPage(QWidget* parent) :
     SettingsPageBase(parent),
-    m_openArchivesAsFolder(0),
-    m_autoExpandFolders(0)
+    m_openArchivesAsFolder(nullptr),
+    m_autoExpandFolders(nullptr)
 {
     QVBoxLayout* topLayout = new QVBoxLayout(this);
     QWidget* vBox = new QWidget(this);
index 5410a4efaa042b4c6bc05941a832f591427826f8..d58a8e8110477467fd5fdff446339cb876095435 100644 (file)
@@ -32,13 +32,13 @@ class NavigationSettingsPage : public SettingsPageBase
 
 public:
     NavigationSettingsPage(QWidget* parent);
-    virtual ~NavigationSettingsPage();
+    ~NavigationSettingsPage() override;
 
     /** @see SettingsPageBase::applySettings() */
-    virtual void applySettings() Q_DECL_OVERRIDE;
+    void applySettings() override;
 
     /** @see SettingsPageBase::restoreDefaults() */
-    virtual void restoreDefaults() Q_DECL_OVERRIDE;
+    void restoreDefaults() override;
 
 private:
     void loadSettings();
index 9f0ced40c8633f99ed41b751465236fd088a07f8..7b0d216db7c00963626ddcb25ca91f718694bfce 100644 (file)
@@ -33,20 +33,20 @@ class ServiceItemDelegate : public KWidgetItemDelegate
     Q_OBJECT
 
 public:
-    explicit ServiceItemDelegate(QAbstractItemView* itemView, QObject* parent = 0);
-    virtual ~ServiceItemDelegate();
+    explicit ServiceItemDelegate(QAbstractItemView* itemView, QObject* parent = nullptr);
+    ~ServiceItemDelegate() override;
 
-    virtual QSize sizeHint(const QStyleOptionViewItem &option,
-                           const QModelIndex &index) const Q_DECL_OVERRIDE;
+    QSize sizeHint(const QStyleOptionViewItem &option,
+                           const QModelIndex &index) const override;
 
-    virtual void paint(QPainter* painter, const QStyleOptionViewItem& option,
-                       const QModelIndex& index) const Q_DECL_OVERRIDE;
+    void paint(QPainter* painter, const QStyleOptionViewItem& option,
+                       const QModelIndex& index) const override;
 
-    virtual QList<QWidget*> createItemWidgets(const QModelIndex&) const Q_DECL_OVERRIDE;
+    QList<QWidget*> createItemWidgets(const QModelIndex&) const override;
 
-    virtual void updateItemWidgets(const QList<QWidget*> widgets,
+    void updateItemWidgets(const QList<QWidget*> widgets,
                                    const QStyleOptionViewItem& option,
-                                   const QPersistentModelIndex& index) const Q_DECL_OVERRIDE;
+                                   const QPersistentModelIndex& index) const override;
 
 signals:
     void requestServiceConfiguration(const QModelIndex& index);
index f2b91c7e4af1abe49650db3b79424442fbdeb474..a08844b822fa388df904d902190e948eb32dc65e 100644 (file)
@@ -44,13 +44,13 @@ public:
         ConfigurableRole
     };
 
-    explicit ServiceModel(QObject* parent = 0);
-    virtual ~ServiceModel();
+    explicit ServiceModel(QObject* parent = nullptr);
+    ~ServiceModel() override;
 
-    virtual bool insertRows(int row, int count, const QModelIndex & parent = QModelIndex()) Q_DECL_OVERRIDE;
-    virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) Q_DECL_OVERRIDE;
-    virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const Q_DECL_OVERRIDE;
-    virtual int rowCount(const QModelIndex& parent = QModelIndex()) const Q_DECL_OVERRIDE;
+    bool insertRows(int row, int count, const QModelIndex & parent = QModelIndex()) override;
+    bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
+    QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
+    int rowCount(const QModelIndex& parent = QModelIndex()) const override;
 
  private:
     struct ServiceItem
index 2b9b8f46fb3d869c02d40c0f69af18fb468ac331..a0d9effc8d5eb698ed323f745929496846a3f5f3 100644 (file)
@@ -58,9 +58,9 @@ namespace
 ServicesSettingsPage::ServicesSettingsPage(QWidget* parent) :
     SettingsPageBase(parent),
     m_initialized(false),
-    m_serviceModel(0),
-    m_sortModel(0),
-    m_listView(0),
+    m_serviceModel(nullptr),
+    m_sortModel(nullptr),
+    m_listView(nullptr),
     m_enabledVcsPlugins()
 {
     QVBoxLayout* topLayout = new QVBoxLayout(this);
index a883aa947b720db406a878bc7e944a4a34786c36..c1239c9f5fd2a1fda1036942768874218365db33 100644 (file)
@@ -36,16 +36,16 @@ class ServicesSettingsPage : public SettingsPageBase
 
 public:
     ServicesSettingsPage(QWidget* parent);
-    virtual ~ServicesSettingsPage();
+    ~ServicesSettingsPage() override;
 
     /** @see SettingsPageBase::applySettings() */
-    virtual void applySettings() Q_DECL_OVERRIDE;
+    void applySettings() override;
 
     /** @see SettingsPageBase::restoreDefaults() */
-    virtual void restoreDefaults() Q_DECL_OVERRIDE;
+    void restoreDefaults() override;
 
 protected:
-    virtual void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
+    void showEvent(QShowEvent* event) override;
 
 private slots:
     /**
index 05973d45291bdce8d277b443b358d64da04946e5..2bc1dfaaa88defa4dbc5e4f7deeeaf18eb4502c0 100644 (file)
@@ -31,8 +31,8 @@ class SettingsPageBase : public QWidget
     Q_OBJECT
 
 public:
-    explicit SettingsPageBase(QWidget* parent = 0);
-    virtual ~SettingsPageBase();
+    explicit SettingsPageBase(QWidget* parent = nullptr);
+    ~SettingsPageBase() override;
 
     /**
      * Must be implemented by a derived class to
index 7a69cd3d61b42f479db7c19e2db8c2848b5696d8..da278e37159adf6a759a05e8ef02ce700766e43c 100644 (file)
@@ -37,13 +37,13 @@ class StartupSettingsPage : public SettingsPageBase
 
 public:
     StartupSettingsPage(const QUrl& url, QWidget* parent);
-    virtual ~StartupSettingsPage();
+    ~StartupSettingsPage() override;
 
     /** @see SettingsPageBase::applySettings() */
-    virtual void applySettings() Q_DECL_OVERRIDE;
+    void applySettings() override;
 
     /** @see SettingsPageBase::restoreDefaults() */
-    virtual void restoreDefaults() Q_DECL_OVERRIDE;
+    void restoreDefaults() override;
 
 private slots:
     void slotSettingsChanged();
index 5c88aeab79d16156d1b5251127aa3baf5b0d2900..57631b7602a83f36ab98fd029a90f3cc2b0a1c9a 100644 (file)
@@ -31,13 +31,13 @@ class TrashSettingsPage : public SettingsPageBase
 
 public:
     TrashSettingsPage(QWidget* parent);
-    virtual ~TrashSettingsPage();
+    ~TrashSettingsPage() override;
 
     /** @see SettingsPageBase::applySettings() */
-    virtual void applySettings() Q_DECL_OVERRIDE;
+    void applySettings() override;
 
     /** @see SettingsPageBase::restoreDefaults() */
-    virtual void restoreDefaults() Q_DECL_OVERRIDE;
+    void restoreDefaults() override;
 
 private:
     void loadSettings();
index b9c5d97cf8e899600faf32c221a37ef496f74494..c185fc55dc1d2fa4bbfee930955b557b3c74dec0 100644 (file)
@@ -29,8 +29,8 @@
 
 DolphinFontRequester::DolphinFontRequester(QWidget* parent) :
     QWidget(parent),
-    m_modeCombo(0),
-    m_chooseFontButton(0),
+    m_modeCombo(nullptr),
+    m_chooseFontButton(nullptr),
     m_mode(SystemFont),
     m_customFont()
 {
index 6ef6e3e72ad3a6bb18f4ec9536742fbabcec03f1..3f355e3141ce21080b64f0a2ba426cdc59068c56 100644 (file)
@@ -41,7 +41,7 @@ public:
     };
 
     DolphinFontRequester(QWidget* parent);
-    virtual ~DolphinFontRequester();
+    ~DolphinFontRequester() override;
 
     void setMode(Mode mode);
     Mode mode() const;
index 3ed57715a56495ba57c5279b61c62b997dbd3e45..ab87201e2938b248d9e1dc76f38bfc668704fe4a 100644 (file)
@@ -56,7 +56,7 @@ ViewSettingsPage::ViewSettingsPage(QWidget* parent) :
     m_tabs.append(compactTab);
     m_tabs.append(detailsTab);
 
-    topLayout->addWidget(tabWidget, 0, 0);
+    topLayout->addWidget(tabWidget, 0, nullptr);
 }
 
 ViewSettingsPage::~ViewSettingsPage()
index 61671077efd787973b299ddee42873526d84f65b..4f57e5c19100186c79640b257c4229bed4815d31 100644 (file)
@@ -37,13 +37,13 @@ class ViewSettingsPage : public SettingsPageBase
 
 public:
     ViewSettingsPage(QWidget* parent);
-    virtual ~ViewSettingsPage();
+    ~ViewSettingsPage() override;
 
     /** @see SettingsPageBase::applySettings() */
-    virtual void applySettings() Q_DECL_OVERRIDE;
+    void applySettings() override;
 
     /** @see SettingsPageBase::restoreDefaults() */
-    virtual void restoreDefaults() Q_DECL_OVERRIDE;
+    void restoreDefaults() override;
 
 private:
     QList<ViewSettingsTab*> m_tabs;
index a673769ade679fce5c42debee6848729399995ae..bfa3aa16ef539183cc809764ca0aef834d3441bd 100644 (file)
 ViewSettingsTab::ViewSettingsTab(Mode mode, QWidget* parent) :
     QWidget(parent),
     m_mode(mode),
-    m_defaultSizeSlider(0),
-    m_previewSizeSlider(0),
-    m_fontRequester(0),
-    m_widthBox(0),
-    m_maxLinesBox(0),
-    m_expandableFolders(0)
+    m_defaultSizeSlider(nullptr),
+    m_previewSizeSlider(nullptr),
+    m_fontRequester(nullptr),
+    m_widthBox(nullptr),
+    m_maxLinesBox(nullptr),
+    m_expandableFolders(nullptr)
 {
     QVBoxLayout* topLayout = new QVBoxLayout(this);
 
@@ -202,7 +202,7 @@ void ViewSettingsTab::applySettings()
 
 void ViewSettingsTab::restoreDefaultSettings()
 {
-    KConfigSkeleton* settings = 0;
+    KConfigSkeleton* settings = nullptr;
     switch (m_mode) {
     case IconsMode:   settings = IconsModeSettings::self(); break;
     case CompactMode: settings = CompactModeSettings::self(); break;
index 6bea95b903c3a921b310e829ff7dab4ef9562357..8b1ffc428d9584f785d1d54fd0af1a087405afb7 100644 (file)
@@ -43,8 +43,8 @@ public:
         DetailsMode
     };
 
-    explicit ViewSettingsTab(Mode mode, QWidget* parent = 0);
-    virtual ~ViewSettingsTab();
+    explicit ViewSettingsTab(Mode mode, QWidget* parent = nullptr);
+    ~ViewSettingsTab() override;
 
     void applySettings();
     void restoreDefaultSettings();
index c317ed052edebbbf8afc73ed3943c7dae1d3c3de..980ab0bba465d73e92f09fcfce5726d81334a75b 100644 (file)
@@ -52,19 +52,19 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
     QDialog(dolphinView),
     m_isDirty(false),
     m_dolphinView(dolphinView),
-    m_viewProps(0),
-    m_viewMode(0),
-    m_sortOrder(0),
-    m_sorting(0),
-    m_sortFoldersFirst(0),
-    m_previewsShown(0),
-    m_showInGroups(0),
-    m_showHiddenFiles(0),
-    m_additionalInfo(0),
-    m_applyToCurrentFolder(0),
-    m_applyToSubFolders(0),
-    m_applyToAllFolders(0),
-    m_useAsDefault(0)
+    m_viewProps(nullptr),
+    m_viewMode(nullptr),
+    m_sortOrder(nullptr),
+    m_sorting(nullptr),
+    m_sortFoldersFirst(nullptr),
+    m_previewsShown(nullptr),
+    m_showInGroups(nullptr),
+    m_showHiddenFiles(nullptr),
+    m_additionalInfo(nullptr),
+    m_applyToCurrentFolder(nullptr),
+    m_applyToSubFolders(nullptr),
+    m_applyToAllFolders(nullptr),
+    m_useAsDefault(nullptr)
 {
     Q_ASSERT(dolphinView);
     const bool useGlobalViewProps = GeneralSettings::globalViewProps();
@@ -217,7 +217,7 @@ ViewPropertiesDialog::~ViewPropertiesDialog()
 {
     m_isDirty = false;
     delete m_viewProps;
-    m_viewProps = 0;
+    m_viewProps = nullptr;
 
     KConfigGroup dialogConfig(KSharedConfig::openConfig(QStringLiteral("dolphinrc")), "ViewPropertiesDialog");
     KWindowConfig::saveWindowSize(windowHandle(), dialogConfig);
index 5490be85bfa555d4d1cb42df77d8b0ac29d35c66..35c18718e1d5e48d4d35502dffda8daff9e990bf 100644 (file)
@@ -45,10 +45,10 @@ class DOLPHIN_EXPORT ViewPropertiesDialog : public QDialog
 
 public:
     explicit ViewPropertiesDialog(DolphinView* dolphinView);
-    virtual ~ViewPropertiesDialog();
+    ~ViewPropertiesDialog() override;
 
 public slots:
-    void accept() Q_DECL_OVERRIDE;
+    void accept() override;
 
 private slots:
     void slotApply();
index 56fee80279f47f607a39fb84fa61c7cdaebe4dc1..1878c8137269791b55d773684ff01bed1fc46d08 100644 (file)
@@ -39,12 +39,12 @@ ViewPropsProgressInfo::ViewPropsProgressInfo(QWidget* parent,
                                              const ViewProperties& viewProps) :
     QDialog(parent),
     m_dir(dir),
-    m_viewProps(0),
-    m_label(0),
-    m_progressBar(0),
-    m_dirSizeJob(0),
-    m_applyViewPropsJob(0),
-    m_timer(0)
+    m_viewProps(nullptr),
+    m_label(nullptr),
+    m_progressBar(nullptr),
+    m_dirSizeJob(nullptr),
+    m_applyViewPropsJob(nullptr),
+    m_timer(nullptr)
 {
     const QSize minSize = minimumSize();
     setMinimumSize(QSize(320, minSize.height()));
@@ -96,13 +96,13 @@ ViewPropsProgressInfo::ViewPropsProgressInfo(QWidget* parent,
 ViewPropsProgressInfo::~ViewPropsProgressInfo()
 {
     delete m_viewProps;
-    m_viewProps = 0;
+    m_viewProps = nullptr;
 }
 
 void ViewPropsProgressInfo::closeEvent(QCloseEvent* event)
 {
     m_timer->stop();
-    m_applyViewPropsJob = 0;
+    m_applyViewPropsJob = nullptr;
     QDialog::closeEvent(event);
 }
 
@@ -110,12 +110,12 @@ void ViewPropsProgressInfo::reject()
 {
     if (m_dirSizeJob) {
         m_dirSizeJob->kill();
-        m_dirSizeJob = 0;
+        m_dirSizeJob = nullptr;
     }
 
     if (m_applyViewPropsJob) {
         m_applyViewPropsJob->kill();
-        m_applyViewPropsJob = 0;
+        m_applyViewPropsJob = nullptr;
     }
 
     QDialog::reject();
@@ -144,7 +144,7 @@ void ViewPropsProgressInfo::applyViewProperties()
     m_label->setText(i18nc("@info:progress", "Folders: %1", subdirs));
     m_progressBar->setMaximum(subdirs);
 
-    m_dirSizeJob = 0;
+    m_dirSizeJob = nullptr;
 
     m_applyViewPropsJob = new ApplyViewPropsJob(m_dir, *m_viewProps);
     connect(m_applyViewPropsJob, &ApplyViewPropsJob::result,
index cd7aa50ceae397de41014ec023185419312ed22c..e69de29762ac05edc64d238d830ce565dd33af10 100644 (file)
@@ -53,13 +53,13 @@ public:
                           const QUrl& dir,
                           const ViewProperties& viewProps);
 
-    virtual ~ViewPropsProgressInfo();
+    ~ViewPropsProgressInfo() override;
 
 protected:
-    virtual void closeEvent(QCloseEvent* event) Q_DECL_OVERRIDE;
+    void closeEvent(QCloseEvent* event) override;
 
 public slots:
-    void reject() Q_DECL_OVERRIDE;
+    void reject() override;
 
 private slots:
     void updateProgress();
index 31d4ab81a58a396dffe5e6876b7958f52b77d46c..16683309dc9af1a6677ac15721f165fd31d4cd06 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <QIcon>
 #include <KLocalizedString>
+#include <KSqueezedTextLabel>
 #include <QMenu>
 
 #include "statusbarspaceinfo.h"
@@ -49,21 +50,20 @@ DolphinStatusBar::DolphinStatusBar(QWidget* parent) :
     QWidget(parent),
     m_text(),
     m_defaultText(),
-    m_label(0),
-    m_spaceInfo(0),
-    m_zoomSlider(0),
-    m_progressBar(0),
-    m_stopButton(0),
+    m_label(nullptr),
+    m_spaceInfo(nullptr),
+    m_zoomSlider(nullptr),
+    m_progressBar(nullptr),
+    m_stopButton(nullptr),
     m_progress(100),
-    m_showProgressBarTimer(0),
-    m_resetToDefaultTextTimer(0),
+    m_showProgressBarTimer(nullptr),
+    m_resetToDefaultTextTimer(nullptr),
     m_textTimestamp()
 {
     // Initialize text label
-    m_label = new QLabel(this);
+    m_label = new KSqueezedTextLabel(m_text, this);
     m_label->setWordWrap(true);
     m_label->setTextFormat(Qt::PlainText);
-    m_label->installEventFilter(this);
 
     // Initialize zoom widget
     m_zoomSlider = new QSlider(Qt::Horizontal, this);
@@ -127,9 +127,9 @@ DolphinStatusBar::DolphinStatusBar(QWidget* parent) :
     QHBoxLayout* topLayout = new QHBoxLayout(this);
     topLayout->setContentsMargins(2, 0, 2, 0);
     topLayout->setSpacing(4);
-    topLayout->addWidget(m_label);
-    topLayout->addWidget(m_zoomSlider);
-    topLayout->addWidget(m_spaceInfo);
+    topLayout->addWidget(m_label, 1);
+    topLayout->addWidget(m_zoomSlider, 1);
+    topLayout->addWidget(m_spaceInfo, 1);
     topLayout->addWidget(m_stopButton);
     topLayout->addWidget(m_progressTextLabel);
     topLayout->addWidget(m_progressBar);
@@ -282,14 +282,6 @@ void DolphinStatusBar::contextMenuEvent(QContextMenuEvent* event)
     }
 }
 
-bool DolphinStatusBar::eventFilter(QObject* obj, QEvent* event)
-{
-    if (obj == m_label && event->type() == QEvent::Resize) {
-        updateLabelText();
-    }
-    return QWidget::eventFilter(obj, event);
-}
-
 void DolphinStatusBar::showZoomSliderToolTip(int zoomLevel)
 {
     updateZoomSliderToolTip(zoomLevel);
@@ -320,18 +312,7 @@ void DolphinStatusBar::updateProgressInfo()
 void DolphinStatusBar::updateLabelText()
 {
     const QString text = m_text.isEmpty() ? m_defaultText : m_text;
-
-    // Set status bar text and elide it if too long
-    QFontMetrics fontMetrics(m_label->font());
-    const QString elidedText = fontMetrics.elidedText(text, Qt::ElideRight, m_label->width());
-    m_label->setText(elidedText);
-
-    // If the text has been elided, set the original text as tooltip
-    if (text != elidedText) {
-        m_label->setToolTip(Qt::convertFromPlainText(text));
-    } else {
-        m_label->setToolTip(QString());
-    }
+    m_label->setText(text);
 }
 
 void DolphinStatusBar::slotResetToDefaultText()
index 1a4ccf682fb0dbe361d6f2cbc23a209d7f9c1ddc..0b0004e47e1676bd61129493763b66599f60343b 100644 (file)
@@ -30,6 +30,7 @@ class QProgressBar;
 class QToolButton;
 class QSlider;
 class QTimer;
+class KSqueezedTextLabel;
 
 /**
  * @brief Represents the statusbar of a Dolphin view.
@@ -43,7 +44,7 @@ class DolphinStatusBar : public QWidget
 
 public:
     DolphinStatusBar(QWidget* parent);
-    virtual ~DolphinStatusBar();
+    ~DolphinStatusBar() override;
 
     QString text() const;
 
@@ -101,8 +102,7 @@ signals:
     void zoomLevelChanged(int zoomLevel);
 
 protected:
-    virtual void contextMenuEvent(QContextMenuEvent* event) Q_DECL_OVERRIDE;
-    virtual bool eventFilter(QObject* obj, QEvent* event) Q_DECL_OVERRIDE;
+    void contextMenuEvent(QContextMenuEvent* event) override;
 
 private slots:
     void showZoomSliderToolTip(int zoomLevel);
@@ -140,7 +140,7 @@ private:
 private:
     QString m_text;
     QString m_defaultText;
-    QLabel* m_label;
+    KSqueezedTextLabel* m_label;
     StatusBarSpaceInfo* m_spaceInfo;
 
     QSlider* m_zoomSlider;
index c3d2aa67753836c33bc74f28d2ec941d6629dc6f..ea24c4eea69283e2657ede3d2fb302883f15de71 100644 (file)
@@ -53,8 +53,8 @@ class MountPointObserver : public QObject
 {
     Q_OBJECT
 
-    explicit MountPointObserver(const QUrl& url, QObject* parent = 0);
-    virtual ~MountPointObserver() {}
+    explicit MountPointObserver(const QUrl& url, QObject* parent = nullptr);
+    ~MountPointObserver() override {}
 
 public:
     /**
index 48796ac5a0d549e9e37bddd3a9f0e31c7d0e1a65..bcdc0b61cdb1630dd51e133e9ccd9469359bbdbf 100644 (file)
@@ -36,7 +36,7 @@ Q_GLOBAL_STATIC(MountPointObserverCacheSingleton, s_MountPointObserverCache)
 MountPointObserverCache::MountPointObserverCache() :
     m_observerForMountPoint(),
     m_mountPointForObserver(),
-    m_updateTimer(0)
+    m_updateTimer(nullptr)
 {
     m_updateTimer = new QTimer(this);
 }
index 8a1496d8932b421d41e75924cfb9d16a5dc822b1..74cef0674b646c94d6a60c7de8d62d4a74fa49e8 100644 (file)
@@ -31,7 +31,7 @@ class MountPointObserverCache : public QObject
     Q_OBJECT
 
     MountPointObserverCache();
-    virtual ~MountPointObserverCache();
+    ~MountPointObserverCache() override;
 
 public:
     static MountPointObserverCache* instance();
index 0fb018727c5e7ea68d583c4f633621c886ab3b26..8f45c18f84b3c8394a922266f1ece7bf3126216d 100644 (file)
@@ -25,7 +25,7 @@
 
 SpaceInfoObserver::SpaceInfoObserver(const QUrl& url, QObject* parent) :
     QObject(parent),
-    m_mountPointObserver(0),
+    m_mountPointObserver(nullptr),
     m_dataSize(0),
     m_dataAvailable(0)
 {
@@ -39,7 +39,7 @@ SpaceInfoObserver::~SpaceInfoObserver()
 {
     if (m_mountPointObserver) {
         m_mountPointObserver->deref();
-        m_mountPointObserver = 0;
+        m_mountPointObserver = nullptr;
     }
 }
 
@@ -60,7 +60,7 @@ void SpaceInfoObserver::setUrl(const QUrl& url)
         if (m_mountPointObserver) {
             disconnect(m_mountPointObserver, &MountPointObserver::spaceInfoChanged, this, &SpaceInfoObserver::spaceInfoChanged);
             m_mountPointObserver->deref();
-            m_mountPointObserver = 0;
+            m_mountPointObserver = nullptr;
         }
 
         m_mountPointObserver = newObserver;
index e1311abde592aefcbe222085d25f17250dcb6396..144d11fa7f9fdf3b9fa9d1c7c1ee7f8b78cb46c9 100644 (file)
@@ -32,8 +32,8 @@ class SpaceInfoObserver : public QObject
     Q_OBJECT
 
 public:
-    explicit SpaceInfoObserver(const QUrl& url, QObject* parent = 0);
-    virtual ~SpaceInfoObserver();
+    explicit SpaceInfoObserver(const QUrl& url, QObject* parent = nullptr);
+    ~SpaceInfoObserver() override;
 
     quint64 size() const;
     quint64 available() const;
index f364fcf5bc3d9ee28d2248ae85422a7e90da9021..6b6a6d61081daf2211f3f606acf67fc01cba6f6e 100644 (file)
@@ -31,7 +31,7 @@
 
 StatusBarSpaceInfo::StatusBarSpaceInfo(QWidget* parent) :
     KCapacityBar(KCapacityBar::DrawTextInline, parent),
-    m_observer(0)
+    m_observer(nullptr)
 {
     setCursor(Qt::PointingHandCursor);
 }
index 326c419ab3dc709f5bc4ab23f73e727d1106b3a4..87e9f776b47db79990bd2dcc16b151f80510dc0f 100644 (file)
@@ -40,16 +40,16 @@ class StatusBarSpaceInfo : public KCapacityBar
     Q_OBJECT
 
 public:
-    explicit StatusBarSpaceInfo(QWidget* parent = 0);
-    virtual ~StatusBarSpaceInfo();
+    explicit StatusBarSpaceInfo(QWidget* parent = nullptr);
+    ~StatusBarSpaceInfo() override;
 
     void setUrl(const QUrl& url);
     QUrl url() const;
 
 protected:
-    void showEvent(QShowEvent* event) Q_DECL_OVERRIDE;
-    void hideEvent(QHideEvent* event) Q_DECL_OVERRIDE;
-    void mousePressEvent(QMouseEvent* event) Q_DECL_OVERRIDE;
+    void showEvent(QShowEvent* event) override;
+    void hideEvent(QHideEvent* event) override;
+    void mousePressEvent(QMouseEvent* event) override;
 
 private slots:
     void slotValuesChanged();
index 13bd963f9f04c0ac343bed13dcf9204490ebc794..c656173a8d77510a40ddb95ae892010fec56a1f7 100644 (file)
@@ -58,4 +58,10 @@ ecm_add_test(dolphinmainwindowtest.cpp
 TEST_NAME dolphinmainwindowtest
 LINK_LIBRARIES dolphinprivate dolphinstatic Qt5::Test)
 
-ecm_add_test(draganddrophelpertest.cpp LINK_LIBRARIES dolphinprivate Qt5::Test)
\ No newline at end of file
+ecm_add_test(draganddrophelpertest.cpp LINK_LIBRARIES dolphinprivate Qt5::Test)
+
+# PlacesItemModelTest
+ecm_add_test(placesitemmodeltest.cpp
+TEST_NAME placesitemmodeltest
+LINK_LIBRARIES dolphinprivate dolphinstatic Qt5::Test)
+
diff --git a/src/tests/data/fakecomputer.xml b/src/tests/data/fakecomputer.xml
new file mode 100644 (file)
index 0000000..48be046
--- /dev/null
@@ -0,0 +1,387 @@
+<!-- Please note that in this file we indent more than necessary so that the
+     device tree is visible -->
+
+<machine>
+    <!-- This is a computer -->
+    <device udi="/org/kde/solid/fakehw/computer">
+        <property key="name">Computer</property>
+        <property key="vendor">Solid</property>
+    </device>
+
+        <!-- Two CPUs -->
+        <device udi="/org/kde/solid/fakehw/acpi_CPU0">
+            <property key="name">Solid Processor #0</property>
+            <property key="interfaces">Processor</property>
+            <property key="vendor">Acme Corporation</property>
+            <property key="parent">/org/kde/solid/fakehw/computer</property>
+            <property key="number">0</property>
+            <property key="maxSpeed">3200</property>
+            <property key="canChangeFrequency">true</property>
+            <property key="instructionSets">mmx,sse</property>
+        </device>
+        <device udi="/org/kde/solid/fakehw/acpi_CPU1">
+            <property key="name">Solid Processor #1</property>
+            <property key="interfaces">Processor</property>
+            <property key="vendor">Acme Corporation</property>
+            <property key="parent">/org/kde/solid/fakehw/computer</property>
+            <property key="number">1</property>
+            <property key="maxSpeed">3200</property>
+            <property key="canChangeFrequency">true</property>
+        </device>
+
+        <!-- Platform Device for a floppy drive -->
+        <device udi="/org/kde/solid/fakehw/platform_floppy_0">
+            <property key="name">Platform Device (floppy)</property>
+            <property key="parent">/org/kde/solid/fakehw/computer</property>
+        </device>
+            <!-- The actual floppy device -->
+            <device udi="/org/kde/solid/fakehw/platform_floppy_0_storage">
+                <property key="name">PC Floppy Drive</property>
+                <property key="interfaces">StorageDrive,Block</property>
+                <property key="parent">/org/kde/solid/fakehw/platform_floppy_0</property>
+
+                <property key="minor">0</property>
+                <property key="major">2</property>
+                <property key="device">/dev/fd0</property>
+
+                <property key="bus">platform</property>
+                <property key="driveType">floppy</property>
+                <property key="isRemovable">true</property>
+                <property key="isEjectRequired">false</property>
+                <property key="isHotpluggable">false</property>
+                <property key="isMediaCheckEnabled">false</property>
+            </device>
+                <!-- A (generally) virtual volume tracking the floppy drive state -->
+                <device udi="/org/kde/solid/fakehw/platform_floppy_0_storage_virt_volume">
+                    <property key="name">Floppy Disk</property>
+                    <property key="interfaces">Block,StorageVolume,StorageAccess</property>
+                    <property key="parent">/org/kde/solid/fakehw/platform_floppy_0_storage</property>
+
+                    <property key="minor">0</property>
+                    <property key="major">2</property>
+                    <property key="device">/dev/fd0</property>
+
+                    <property key="isIgnored">false</property>
+                    <property key="isMounted">true</property>
+                    <property key="mountPoint">/media/floppy0</property>
+                    <property key="usage">filesystem</property>
+                </device>
+
+
+
+        <!-- Primary IDE controller -->
+        <device udi="/org/kde/solid/fakehw/pci_001">
+            <property key="name">99021 IDE Controller #1</property>
+            <property key="vendor">Acme Corporation</property>
+            <property key="parent">/org/kde/solid/fakehw/computer</property>
+        </device>
+
+            <!-- Master device... -->
+            <device udi="/org/kde/solid/fakehw/pci_001_ide_0_0">
+                <property key="name">IDE device (master)</property>
+                <property key="parent">/org/kde/solid/fakehw/pci_001</property>
+            </device>
+                <!-- ... is a 250GB disk... -->
+                <device udi="/org/kde/solid/fakehw/storage_serial_HD56890I">
+                    <property key="name">HD250GB</property>
+                    <property key="vendor">Acme Corporation</property>
+                    <property key="interfaces">StorageDrive,Block</property>
+                    <property key="parent">/org/kde/solid/fakehw/pci_001_ide_0_0</property>
+
+                    <property key="minor">0</property>
+                    <property key="major">3</property>
+                    <property key="device">/dev/hda</property>
+
+                    <property key="bus">scsi</property>
+                    <property key="driveType">disk</property>
+                    <property key="isRemovable">false</property>
+                    <property key="isEjectRequired">false</property>
+                    <property key="isHotpluggable">false</property>
+                    <property key="isMediaCheckEnabled">false</property>
+                    <property key="product">HD250GBSATA</property>
+                </device>
+                    <!-- ... with five partitions:
+                              - one physical partition (the root /, ext3, 20GB)
+                              - one extended containing three logical volumes:
+                                  - a swap volume (2GB)
+                                  - /home volume (xfs, 208GB)
+                                  - /foreign volume (ntfs, 20GB)
+                    -->
+                    <device udi="/org/kde/solid/fakehw/volume_uuid_feedface">
+                        <property key="name">/</property>
+                        <property key="interfaces">Block,StorageVolume,StorageAccess</property>
+                        <property key="parent">/org/kde/solid/fakehw/storage_serial_HD56890I</property>
+
+                        <property key="minor">1</property>
+                        <property key="major">3</property>
+                        <property key="device">/dev/hda1</property>
+
+                        <property key="isIgnored">true</property>
+                        <property key="isMounted">true</property>
+                        <property key="mountPoint">/</property>
+                        <property key="usage">filesystem</property>
+                        <property key="fsType">ext3</property>
+                        <property key="label">Root</property>
+                        <property key="uuid">feedface</property>
+                        <property key="size">21474836480</property>
+                    </device>
+                    <device udi="/org/kde/solid/fakehw/volume_uuid_c0ffee">
+                        <property key="name">/home</property>
+                        <property key="interfaces">Block,StorageVolume,StorageAccess</property>
+                        <property key="parent">/org/kde/solid/fakehw/storage_serial_HD56890I</property>
+
+                        <property key="minor">6</property>
+                        <property key="major">3</property>
+                        <property key="device">/dev/hda6</property>
+
+                        <property key="isIgnored">true</property>
+                        <property key="isMounted">true</property>
+                        <property key="mountPoint">/home</property>
+                        <property key="usage">filesystem</property>
+                        <property key="fsType">xfs</property>
+                        <property key="label">Home</property>
+                        <property key="uuid">c0ffee</property>
+                        <property key="size">223338299392</property>
+                    </device>
+                    <device udi="/org/kde/solid/fakehw/volume_uuid_f00ba7">
+                        <property key="name">/foreign</property>
+                        <property key="interfaces">Block,StorageVolume,StorageAccess</property>
+                        <property key="parent">/org/kde/solid/fakehw/storage_serial_HD56890I</property>
+
+                        <property key="minor">7</property>
+                        <property key="major">3</property>
+                        <property key="device">/dev/hda7</property>
+
+                        <property key="isIgnored">false</property>
+                        <property key="isMounted">true</property>
+                        <property key="mountPoint">/foreign</property>
+                        <property key="usage">filesystem</property>
+                        <property key="fsType">ntfs</property>
+                        <property key="label">Foreign</property>
+                        <property key="uuid">f00ba7</property>
+                        <property key="size">21474836480</property>
+                    </device>
+                    <device udi="/org/kde/solid/fakehw/volume_part2_size_1024">
+                        <property key="name">StorageVolume</property>
+                        <property key="interfaces">Block,StorageVolume,StorageAccess</property>
+                        <property key="parent">/org/kde/solid/fakehw/storage_serial_HD56890I</property>
+
+                        <property key="minor">2</property>
+                        <property key="major">3</property>
+                        <property key="device">/dev/hda2</property>
+
+                        <property key="isIgnored">true</property>
+                        <property key="isMounted">false</property>
+                        <property key="usage">other</property>
+                        <property key="size">1024</property>
+                    </device>
+                    <device udi="/org/kde/solid/fakehw/volume_part5_size_1048576">
+                        <property key="name">StorageVolume (swap)</property>
+                        <property key="interfaces">Block,StorageVolume,StorageAccess</property>
+                        <property key="parent">/org/kde/solid/fakehw/storage_serial_HD56890I</property>
+
+                        <property key="minor">5</property>
+                        <property key="major">3</property>
+                        <property key="device">/dev/hda5</property>
+
+                        <property key="isIgnored">true</property>
+                        <property key="isMounted">false</property>
+                        <property key="usage">other</property>
+                        <property key="fsType">swap</property>
+                        <property key="size">2147483648</property>
+                    </device>
+
+
+        <!-- Secondary IDE controller -->
+        <device udi="/org/kde/solid/fakehw/pci_002">
+            <property key="name">99021 IDE Controller #2</property>
+            <property key="vendor">Acme Corporation</property>
+            <property key="parent">/org/kde/solid/fakehw/computer</property>
+        </device>
+
+            <!-- Master device... -->
+            <device udi="/org/kde/solid/fakehw/pci_002_ide_1_0">
+                <property key="name">IDE device (master)</property>
+                <property key="parent">/org/kde/solid/fakehw/pci_002</property>
+            </device>
+                <!-- ... is a DVD writer... -->
+                <device udi="/org/kde/solid/fakehw/storage_model_solid_writer">
+                    <property key="name">Solid IDE DVD Writer</property>
+                    <property key="vendor">Acme Corporation</property>
+                    <property key="interfaces">Block,StorageDrive,OpticalDrive</property>
+                    <property key="parent">/org/kde/solid/fakehw/pci_002_ide_1_0</property>
+
+                    <property key="minor">0</property>
+                    <property key="major">22</property>
+                    <property key="device">/dev/hdc</property>
+
+                    <property key="bus">ide</property>
+                    <property key="driveType">cdrom</property>
+                    <property key="isRemovable">true</property>
+                    <property key="isEjectRequired">true</property>
+                    <property key="isHotpluggable">false</property>
+                    <property key="isMediaCheckEnabled">true</property>
+                    <property key="product">Solid DVD Writer</property>
+
+                    <property key="supportedMedia">cdr,cdrw,dvd,dvdr,dvdrw</property>
+                    <property key="readSpeed">4234</property>
+                    <property key="writeSpeed">4234</property>
+                    <property key="writeSpeeds">4234,2822,2117,1411,706</property>
+                </device>
+                    <!-- ... with a cd-r in it -->
+                    <device udi="/org/kde/solid/fakehw/volume_uuid_5011">
+                        <property key="name">FooDistro i386</property>
+                        <property key="interfaces">Block,StorageVolume,OpticalDisc,StorageAccess</property>
+                        <property key="parent">/org/kde/solid/fakehw/storage_model_solid_writer</property>
+
+                        <property key="discType">cd_rw</property>
+                        <property key="isAppendable">false</property>
+                        <property key="isRewritable">true</property>
+                        <property key="isBlank">false</property>
+                        <property key="availableContent">data</property>
+                        <property key="mountPoint">/media/cdrom</property>
+
+                        <property key="uuid">5011</property>
+                        <property key="size">731047936</property>
+                        <property key="label">FooDistro i386</property>
+                    </device>
+
+            <!-- Slave device... -->
+            <device udi="/org/kde/solid/fakehw/pci_002_ide_1_1">
+                <property key="name">IDE device (slave)</property>
+                <property key="parent">/org/kde/solid/fakehw/pci_002</property>
+            </device>
+                <!-- ... is a DVD reader... -->
+                <device udi="/org/kde/solid/fakehw/storage_model_solid_reader">
+                    <property key="name">Solid IDE DVD Reader</property>
+                    <property key="vendor">Acme Corporation</property>
+                    <property key="interfaces">Block,StorageDrive,OpticalDrive</property>
+                    <property key="parent">/org/kde/solid/fakehw/pci_002_ide_1_1</property>
+
+                    <property key="minor">0</property>
+                    <property key="major">22</property>
+                    <property key="device">/dev/hdc</property>
+
+                    <property key="bus">ide</property>
+                    <property key="driveType">cdrom</property>
+                    <property key="isRemovable">true</property>
+                    <property key="isEjectRequired">true</property>
+                    <property key="isHotpluggable">false</property>
+                    <property key="isMediaCheckEnabled">true</property>
+                    <property key="product">Solid DVD Reader</property>
+
+                    <property key="supportedMedia">cdr,cdrw,dvd,dvdr,dvdrw,dvdram,dvdplusr,dvdplusrw</property>
+                    <property key="readSpeed">4234</property>
+                </device>
+                    <!-- ... with a DVD Video in it -->
+                    <device udi="/org/kde/solid/fakehw/volume_label_SOLIDMAN_BEGINS">
+                        <property key="name">SolidMan Begins</property>
+                        <property key="interfaces">Block,StorageVolume,OpticalDisc</property>
+                        <property key="parent">/org/kde/solid/fakehw/storage_model_solid_reader</property>
+
+                        <property key="discType">dvd_rom</property>
+                        <property key="isAppendable">false</property>
+                        <property key="isRewritable">false</property>
+                        <property key="isBlank">false</property>
+                        <property key="availableContent">dvdvideo</property>
+
+                        <property key="uuid">5012</property>
+                        <property key="size">8033075200</property>
+                        <property key="label">SolidMan Begins</property>
+                    </device>
+
+
+
+        <!-- First USB Controller -->
+        <device udi="/org/kde/solid/fakehw/pci_8086_265c">
+            <property key="name">99021 USB2 EHCI Controller #1</property>
+            <property key="vendor">Acme Corporation</property>
+            <property key="parent">/org/kde/solid/fakehw/computer</property>
+        </device>
+            <!-- Host Controller -->
+            <device udi="/org/kde/solid/fakehw/usb_device_0_0_1d_7">
+                <property key="name">EHCI Host Controller</property>
+                <property key="vendor">Kernel ehci_hcd</property>
+                <property key="parent">/org/kde/solid/fakehw/pci_8086_265c</property>
+            </device>
+                <!-- USB Device -->
+                <device udi="/org/kde/solid/fakehw/usb_device_4e8_5041">
+                    <property key="name">Acme XO-Y4</property>
+                    <property key="parent">/org/kde/solid/fakehw/usb_device_0_0_1d_7</property>
+                </device>
+                    <!-- Mass Storage Interface -->
+                    <device udi="/org/kde/solid/fakehw/usb_device_4e8_5041_if0">
+                        <property key="name">USB Mass Storage Inferface</property>
+                        <property key="parent">/org/kde/solid/fakehw/usb_device_4e8_5041</property>
+                    </device>
+                        <!-- SCSI Adapter -->
+                        <device udi="/org/kde/solid/fakehw/usb_device_4e8_5041_if0_scsi_host">
+                            <property key="name">SCSI Host Adapter</property>
+                            <property key="parent">/org/kde/solid/fakehw/usb_device_4e8_5041_if0</property>
+                        </device>
+                        <!-- SCSI Device -->
+                            <device udi="/org/kde/solid/fakehw/usb_device_4e8_5041_if0_scsi_host_scsi_device_lun0">
+                                <property key="name">SCSI Device</property>
+                                <property key="parent">/org/kde/solid/fakehw/usb_device_4e8_5041_if0_scsi_host</property>
+                            </device>
+                                <!-- We finally find the storage device, which is a portable media player... -->
+                                <device udi="/org/kde/solid/fakehw/storage_serial_XOY4_5206">
+                                    <property key="name">XO-Y4</property>
+                                    <property key="vendor">Acme Electronics</property>
+                                    <property key="interfaces">StorageDrive,Block,PortableMediaPlayer</property>
+                                    <property key="parent">/org/kde/solid/fakehw/usb_device_4e8_5041_if0_scsi_host_scsi_device_lun0</property>
+
+                                    <property key="minor">0</property>
+                                    <property key="major">8</property>
+                                    <property key="device">/dev/sda</property>
+
+                                    <property key="bus">usb</property>
+                                    <property key="driveType">disk</property>
+                                    <property key="isRemovable">true</property>
+                                    <property key="isEjectRequired">true</property>
+                                    <property key="isHotpluggable">true</property>
+                                    <property key="isMediaCheckEnabled">true</property>
+                                    <property key="product">XO-Y4</property>
+
+                                    <property key="accessMethod">MassStorage</property>
+                                    <property key="outputFormats">audio/x-mp3</property>
+                                    <property key="inputFormats">audio/x-wav,audio/x-mp3,audio/vorbis</property>
+                                    <property key="playlistFormats">audio/x-mpegurl</property>
+                                </device>
+                                    <!-- ... with a partition since it's a USB Mass Storage device -->
+                                    <device udi="/org/kde/solid/fakehw/volume_part1_size_993284096">
+                                        <property key="name">StorageVolume (vfat)</property>
+                                        <property key="interfaces">Block,StorageVolume,StorageAccess</property>
+                                        <property key="parent">/org/kde/solid/fakehw/storage_serial_XOY4_5206</property>
+
+                                        <property key="minor">1</property>
+                                        <property key="major">8</property>
+                                        <property key="device">/dev/sda1</property>
+
+                                        <property key="isIgnored">false</property>
+                                        <property key="isMounted">true</property>
+                                        <property key="mountPoint">/media/XO-Y4</property>
+                                        <property key="usage">filesystem</property>
+                                        <property key="fsType">vfat</property>
+                                        <property key="size">993284096</property>
+                                    </device>
+
+        <device udi="/org/kde/solid/fakehw/fstab">
+            <property key="name">Network Shares</property>
+            <property key="product">Network Shares</property>
+            <property key="vendor">KDE</property>
+            <property key="parent">/org/kde/solid/fakehw/computer</property>
+        </device>
+            <device udi="/org/kde/solid/fakehw/fstab/thehost/solidpath">
+                <property key="parent">/org/kde/solid/fstab</property>
+                <property key="interfaces">NetworkShare,StorageAccess</property>
+                <property key="vendor">/solidpath</property>
+                <property key="product">thehost</property>
+                <property key="type">nfs</property>
+                <property key="url">nfs://thehost/solid-path</property>
+                <property key="filePath">/media/nfs</property>
+                <property key="isIgnored">false</property>
+                <property key="isMounted">true</property>
+                <property key="mountPoint">/media/nfs</property>
+            </device>
+</machine>
index cac4f7a587bf520901fe58eb124b664013eeb24a..196018045c13ed72651116e2b2d76bc0a7586264 100644 (file)
@@ -52,7 +52,7 @@ void KFileItemListViewTest::init()
     m_model->m_dirLister->setAutoUpdate(false);
 
     m_listView = new KFileItemListView();
-    m_listView->onModelChanged(m_model, 0);
+    m_listView->onModelChanged(m_model, nullptr);
 
     m_graphicsView = new QGraphicsView();
     m_graphicsView->show();
@@ -62,16 +62,16 @@ void KFileItemListViewTest::init()
 void KFileItemListViewTest::cleanup()
 {
     delete m_graphicsView;
-    m_graphicsView = 0;
+    m_graphicsView = nullptr;
 
     delete m_listView;
-    m_listView = 0;
+    m_listView = nullptr;
 
     delete m_model;
-    m_model = 0;
+    m_model = nullptr;
 
     delete m_testDir;
-    m_testDir = 0;
+    m_testDir = nullptr;
 }
 
 /**
index b8e089530db9380d03457c567cf9298b11f5ba9a..471818d98eefd237c16674e5c4ec6abccdb52d8f 100644 (file)
@@ -126,10 +126,10 @@ void KFileItemModelTest::init()
 void KFileItemModelTest::cleanup()
 {
     delete m_model;
-    m_model = 0;
+    m_model = nullptr;
 
     delete m_testDir;
-    m_testDir = 0;
+    m_testDir = nullptr;
 }
 
 void KFileItemModelTest::testDefaultRoles()
index 92d05c4d452d3d68ebf1b4fcf1f2d929db8bca08..926a781675f044be8c1e047a31c6d3bfc52e76a8 100644 (file)
@@ -58,7 +58,7 @@ public:
     int styleHint(StyleHint hint,
                   const QStyleOption* option = nullptr,
                   const QWidget* widget = nullptr,
-                  QStyleHintReturn* returnData = nullptr) const Q_DECL_OVERRIDE
+                  QStyleHintReturn* returnData = nullptr) const override
     {
         switch (hint) {
         case QStyle::SH_ItemView_ActivateItemOnSingleClick:
@@ -149,10 +149,10 @@ void KItemListControllerTest::initTestCase()
 void KItemListControllerTest::cleanupTestCase()
 {
     delete m_container;
-    m_container = 0;
+    m_container = nullptr;
 
     delete m_testDir;
-    m_testDir = 0;
+    m_testDir = nullptr;
 }
 
 /** Before each test, the current item, selection, and item size are reset to the defaults. */
index 48e8dce04d6f6bb0c3efd4f54fed83f60c8580f8..daa03ae204ae4683016cdb90b30f0ea6984f2dac 100644 (file)
@@ -30,8 +30,8 @@ class DummyModel : public KItemModelBase
 public:
     DummyModel();
     void setCount(int count);
-    int count() const Q_DECL_OVERRIDE;
-    QHash<QByteArray, QVariant> data(int index) const Q_DECL_OVERRIDE;
+    int count() const override;
+    QHash<QByteArray, QVariant> data(int index) const override;
 
 private:
     int m_count;
@@ -99,10 +99,10 @@ void KItemListSelectionManagerTest::init()
 void KItemListSelectionManagerTest::cleanup()
 {
     delete m_selectionManager;
-    m_selectionManager = 0;
+    m_selectionManager = nullptr;
 
     delete m_model;
-    m_model = 0;
+    m_model = nullptr;
 }
 
 void KItemListSelectionManagerTest::testConstructor()
index 889748f35c21b50796a8ba491fd16e068dd036ab..daa8f1e56ceccee72506ddb895bf46c5e6451df7 100644 (file)
@@ -51,7 +51,7 @@ void KStandardItemModelTest::init()
 void KStandardItemModelTest::cleanup()
 {
     delete m_model;
-    m_model = 0;
+    m_model = nullptr;
 }
 
 void KStandardItemModelTest::testNewItems()
diff --git a/src/tests/placesitemmodeltest.cpp b/src/tests/placesitemmodeltest.cpp
new file mode 100644 (file)
index 0000000..a74b3ea
--- /dev/null
@@ -0,0 +1,850 @@
+/***************************************************************************
+ *   Copyright (C) 2017 by Renato Araujo Oliveira <renato.araujo@kdab.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            *
+ ***************************************************************************/
+
+#include <QTest>
+#include <QSignalSpy>
+#include <QDebug>
+#include <QList>
+#include <QByteArray>
+#include <QStandardPaths>
+#include <QAction>
+#include <QDBusInterface>
+#include <QUrlQuery>
+
+#include <KBookmarkManager>
+#include <KConfig>
+#include <KConfigGroup>
+#include <KAboutData>
+#include <KFilePlacesModel>
+
+#include "panels/places/placesitemmodel.h"
+#include "panels/places/placesitem.h"
+#include "views/viewproperties.h"
+#include "kitemviews/kitemrange.h"
+
+Q_DECLARE_METATYPE(KItemRangeList)
+Q_DECLARE_METATYPE(KItemRange)
+
+#ifdef Q_OS_WIN
+//c:\ as root for windows
+#define KDE_ROOT_PATH "C:\\"
+#else
+#define KDE_ROOT_PATH "/"
+#endif
+
+static QString bookmarksFile()
+{
+    return QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/user-places.xbel";
+}
+
+class PlacesItemModelTest : public QObject
+{
+    Q_OBJECT
+
+private slots:
+    void init();
+    void cleanup();
+
+    void initTestCase();
+    void cleanupTestCase();
+
+    void testModelSort();
+    void testGroups();
+    void testDeletePlace();
+    void testPlaceItem_data();
+    void testPlaceItem();
+    void testTearDownDevice();
+    void testDefaultViewProperties_data();
+    void testDefaultViewProperties();
+    void testClear();
+    void testHideItem();
+    void testSystemItems();
+    void testEditBookmark();
+    void testEditAfterCreation();
+    void testEditMetadata();
+    void testRefresh();
+    void testIcons_data();
+    void testIcons();
+    void testDragAndDrop();
+    void testHideDevices();
+    void testDuplicatedEntries();
+    void renameAfterCreation();
+
+private:
+    PlacesItemModel* m_model;
+    QSet<int> m_tobeRemoved;
+    QMap<QString, QDBusInterface *> m_interfacesMap;
+
+    void setBalooEnabled(bool enabled);
+    int indexOf(const QUrl &url);
+    QDBusInterface *fakeManager();
+    QDBusInterface *fakeDevice(const QString &udi);
+    QStringList placesUrls(PlacesItemModel *model = nullptr) const;
+    QStringList initialUrls() const;
+    void createPlaceItem(const QString &text, const QUrl &url, const QString &icon);
+    void removePlaceAfter(int index);
+    void cancelPlaceRemoval(int index);
+    void removeTestUserData();
+    QMimeData *createMimeData(const QList<int> &indexes) const;
+};
+
+#define CHECK_PLACES_URLS(urls)                                             \
+    {                                                                       \
+        QStringList places = placesUrls();                                  \
+        if (places != urls) {                                               \
+            qWarning() << "Expected:" << urls;                              \
+            qWarning() << "Got:" << places;                                 \
+            QCOMPARE(places, urls);                                         \
+        }                                                                   \
+    }
+
+void PlacesItemModelTest::setBalooEnabled(bool enabled)
+{
+    KConfig config(QStringLiteral("baloofilerc"));
+    KConfigGroup basicSettings = config.group("Basic Settings");
+    basicSettings.writeEntry("Indexing-Enabled", enabled);
+    config.sync();
+}
+
+int PlacesItemModelTest::indexOf(const QUrl &url)
+{
+    for (int r = 0; r < m_model->count(); r++) {
+        if (m_model->placesItem(r)->url() == url) {
+            return r;
+        }
+    }
+    return -1;
+}
+
+QDBusInterface *PlacesItemModelTest::fakeManager()
+{
+    return fakeDevice(QStringLiteral("/org/kde/solid/fakehw"));
+}
+
+QDBusInterface *PlacesItemModelTest::fakeDevice(const QString &udi)
+{
+    if (m_interfacesMap.contains(udi)) {
+        return m_interfacesMap[udi];
+    }
+
+    QDBusInterface *iface = new QDBusInterface(QDBusConnection::sessionBus().baseService(), udi);
+    m_interfacesMap[udi] = iface;
+
+    return iface;
+}
+
+QStringList PlacesItemModelTest::placesUrls(PlacesItemModel *model) const
+{
+    QStringList urls;
+    if (!model) {
+        model = m_model;
+    }
+
+    for (int row = 0; row < model->count(); ++row) {
+        urls << model->placesItem(row)->url().toDisplayString(QUrl::PreferLocalFile);
+    }
+    return urls;
+}
+
+QStringList PlacesItemModelTest::initialUrls() const
+{
+    static QStringList urls;
+    if (urls.isEmpty()) {
+        urls << QDir::homePath() << QStringLiteral(KDE_ROOT_PATH) << QStringLiteral("trash:/")
+             << QStringLiteral("remote:/")
+             << QStringLiteral("timeline:/today") << QStringLiteral("timeline:/yesterday") << QStringLiteral("timeline:/thismonth") << QStringLiteral("timeline:/lastmonth")
+             << QStringLiteral("search:/documents") << QStringLiteral("search:/images") << QStringLiteral("search:/audio") << QStringLiteral("search:/videos")
+             << QStringLiteral("/media/nfs") << QStringLiteral("/foreign")
+             << QStringLiteral("/media/floppy0") << QStringLiteral("/media/XO-Y4") << QStringLiteral("/media/cdrom");
+    }
+    return urls;
+}
+
+void PlacesItemModelTest::createPlaceItem(const QString &text, const QUrl &url, const QString &icon)
+{
+    m_model->createPlacesItem(text, url, icon);
+}
+
+void PlacesItemModelTest::removePlaceAfter(int index)
+{
+    m_tobeRemoved.insert(index);
+}
+
+void PlacesItemModelTest::cancelPlaceRemoval(int index)
+{
+    m_tobeRemoved.remove(index);
+}
+
+void PlacesItemModelTest::removeTestUserData()
+{
+    // user hardcoded path to avoid removal of any user personal data
+    QDir dir(QStringLiteral("/home/renato/.qttest/share/placesitemmodeltest"));
+    if (dir.exists()) {
+        QVERIFY(dir.removeRecursively());
+    }
+}
+
+QMimeData *PlacesItemModelTest::createMimeData(const QList<int> &indexes) const
+{
+    QByteArray itemData;
+    QDataStream stream(&itemData, QIODevice::WriteOnly);
+    QList<QUrl> urls;
+
+    for (int index : indexes) {
+        const QUrl itemUrl = m_model->placesItem(index)->url();
+        if (itemUrl.isValid()) {
+            urls << itemUrl;
+        }
+        stream << index;
+    }
+
+    QMimeData* mimeData = new QMimeData();
+    mimeData->setUrls(urls);
+    // copied from PlacesItemModel::internalMimeType()
+    const QString internalMimeType = "application/x-dolphinplacesmodel-" +
+            QString::number((qptrdiff)m_model);
+    mimeData->setData(internalMimeType, itemData);
+    return mimeData;
+}
+
+void PlacesItemModelTest::init()
+{
+    m_model = new PlacesItemModel();
+    // WORKAROUND: need to wait for bookmark to load, check: PlacesItemModel::updateBookmarks
+    QTest::qWait(300);
+    QCOMPARE(m_model->count(), 17);
+}
+
+void PlacesItemModelTest::cleanup()
+{
+    for (int i : m_tobeRemoved) {
+        int before = m_model->count();
+        m_model->deleteItem(i);
+        QTRY_COMPARE(m_model->count(), before - 1);
+    }
+    m_tobeRemoved.clear();
+    delete m_model;
+    m_model = nullptr;
+    removeTestUserData();
+}
+
+void PlacesItemModelTest::initTestCase()
+{
+    QStandardPaths::setTestModeEnabled(true);
+    // remove test user data
+    removeTestUserData();
+
+    const QString fakeHw = QFINDTESTDATA("data/fakecomputer.xml");
+    QVERIFY(!fakeHw.isEmpty());
+    qputenv("SOLID_FAKEHW", QFile::encodeName(fakeHw));
+
+    setBalooEnabled(true);
+    const QString bookmarsFileName = bookmarksFile();
+    if (QFileInfo::exists(bookmarsFileName)) {
+        // Ensure we'll have a clean bookmark file to start
+        QVERIFY(QFile::remove(bookmarsFileName));
+    }
+
+    qRegisterMetaType<KItemRangeList>();
+    qRegisterMetaType<KItemRange>();
+}
+
+void PlacesItemModelTest::cleanupTestCase()
+{
+    qDeleteAll(m_interfacesMap);
+    QFile::remove(bookmarksFile());
+
+    // Remove any previous properties file
+    removeTestUserData();
+}
+
+void PlacesItemModelTest::testModelSort()
+{
+    CHECK_PLACES_URLS(initialUrls());
+}
+
+void PlacesItemModelTest::testGroups()
+{
+    const auto groups = m_model->groups();
+
+    QCOMPARE(groups.size(), 6);
+
+    QCOMPARE(groups.at(0).first, 0);
+    QCOMPARE(groups.at(0).second.toString(), QStringLiteral("Places"));
+
+    QCOMPARE(groups.at(1).first, 3);
+    QCOMPARE(groups.at(1).second.toString(), QStringLiteral("Remote"));
+
+    QCOMPARE(groups.at(2).first, 4);
+    QCOMPARE(groups.at(2).second.toString(), QStringLiteral("Recently Saved"));
+
+    QCOMPARE(groups.at(3).first, 8);
+    QCOMPARE(groups.at(3).second.toString(), QStringLiteral("Search For"));
+
+    QCOMPARE(groups.at(4).first, 12);
+    QCOMPARE(groups.at(4).second.toString(), QStringLiteral("Devices"));
+
+    QCOMPARE(groups.at(5).first, 14);
+    QCOMPARE(groups.at(5).second.toString(), QStringLiteral("Removable Devices"));
+}
+
+void PlacesItemModelTest::testPlaceItem_data()
+{
+    QTest::addColumn<QUrl>("url");
+    QTest::addColumn<bool>("expectedIsHidden");
+    QTest::addColumn<bool>("expectedIsSystemItem");
+    QTest::addColumn<QString>("expectedGroup");
+    QTest::addColumn<bool>("expectedStorageSetupNeeded");
+
+    // places
+    QTest::newRow("Places - Home") << QUrl::fromLocalFile(QDir::homePath()) << false << true << QStringLiteral("Places") << false;
+
+    // baloo -search
+    QTest::newRow("Baloo - Documents") << QUrl("search:/documents") << false << true << QStringLiteral("Search For") << false;
+
+    // baloo - timeline
+    QTest::newRow("Baloo - Last Month") << QUrl("timeline:/lastmonth") << false << true << QStringLiteral("Recently Saved") << false;
+
+    // devices
+    QTest::newRow("Devices - Floppy") << QUrl("file:///media/floppy0") << false << false << QStringLiteral("Removable Devices") << false;
+}
+
+void PlacesItemModelTest::testPlaceItem()
+{
+    QFETCH(QUrl, url);
+    QFETCH(bool, expectedIsHidden);
+    QFETCH(bool, expectedIsSystemItem);
+    QFETCH(QString, expectedGroup);
+    QFETCH(bool, expectedStorageSetupNeeded);
+
+    const int index = indexOf(url);
+    PlacesItem *item = m_model->placesItem(index);
+    QCOMPARE(item->url(), url);
+    QCOMPARE(item->isHidden(), expectedIsHidden);
+    QCOMPARE(item->isSystemItem(), expectedIsSystemItem);
+    QCOMPARE(item->group(), expectedGroup);
+    QCOMPARE(item->storageSetupNeeded(), expectedStorageSetupNeeded);
+}
+
+void PlacesItemModelTest::testDeletePlace()
+{
+    const QUrl tempUrl = QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::TempLocation));
+    QStringList urls = initialUrls();
+    QSignalSpy itemsInsertedSpy(m_model, &PlacesItemModel::itemsInserted);
+    QSignalSpy itemsRemovedSpy(m_model, &PlacesItemModel::itemsRemoved);
+
+    PlacesItemModel *model = new PlacesItemModel();
+
+    // create a new place
+    createPlaceItem(QStringLiteral("Temporary Dir"), tempUrl, QString());
+    urls.insert(3, tempUrl.toLocalFile());
+
+    // check if the new entry was created
+    QTRY_COMPARE(itemsInsertedSpy.count(), 1);
+    CHECK_PLACES_URLS(urls);
+    QTRY_COMPARE(model->count(), m_model->count());
+
+    // delete item
+    m_model->deleteItem(3);
+
+    // make sure that the new item is removed
+    QTRY_COMPARE(itemsRemovedSpy.count(), 1);
+    QTRY_COMPARE(m_model->count(), 17);
+    CHECK_PLACES_URLS(initialUrls());
+    QTRY_COMPARE(model->count(), m_model->count());
+}
+
+void PlacesItemModelTest::testTearDownDevice()
+{
+    const QUrl mediaUrl = QUrl::fromLocalFile(QStringLiteral("/media/XO-Y4"));
+    int index = indexOf(mediaUrl);
+    QVERIFY(index != -1);
+
+    auto ejectAction = m_model->ejectAction(index);
+    QVERIFY(!ejectAction);
+
+    auto teardownAction = m_model->teardownAction(index);
+    QVERIFY(teardownAction);
+
+    QCOMPARE(m_model->count(), 17);
+
+    QSignalSpy spyItemsRemoved(m_model, &PlacesItemModel::itemsRemoved);
+    fakeManager()->call(QStringLiteral("unplug"), "/org/kde/solid/fakehw/volume_part1_size_993284096");
+    QTRY_COMPARE(m_model->count(), 16);
+    QCOMPARE(spyItemsRemoved.count(), 1);
+    const QList<QVariant> spyItemsRemovedArgs = spyItemsRemoved.takeFirst();
+    const KItemRangeList removedRange = spyItemsRemovedArgs.at(0).value<KItemRangeList>();
+    QCOMPARE(removedRange.size(), 1);
+    QCOMPARE(removedRange.first().index, index);
+    QCOMPARE(removedRange.first().count, 1);
+
+    QCOMPARE(indexOf(mediaUrl), -1);
+
+    QSignalSpy spyItemsInserted(m_model, &PlacesItemModel::itemsInserted);
+    fakeManager()->call(QStringLiteral("plug"), "/org/kde/solid/fakehw/volume_part1_size_993284096");
+    QTRY_COMPARE(m_model->count(), 17);
+    QCOMPARE(spyItemsInserted.count(), 1);
+    index = indexOf(mediaUrl);
+
+    const QList<QVariant> args = spyItemsInserted.takeFirst();
+    const KItemRangeList insertedRange = args.at(0).value<KItemRangeList>();
+    QCOMPARE(insertedRange.size(), 1);
+    QCOMPARE(insertedRange.first().index, index);
+    QCOMPARE(insertedRange.first().count, 1);
+}
+
+void PlacesItemModelTest::testDefaultViewProperties_data()
+{
+    QTest::addColumn<QUrl>("url");
+    QTest::addColumn<DolphinView::Mode>("expectedViewMode");
+    QTest::addColumn<bool>("expectedPreviewShow");
+    QTest::addColumn<QList<QByteArray> >("expectedVisibleRole");
+
+    // places
+    QTest::newRow("Places - Home") << QUrl::fromLocalFile(QDir::homePath()) << DolphinView::IconsView << true << QList<QByteArray>({"text"});
+
+    // baloo -search
+    QTest::newRow("Baloo - Documents") << QUrl("search:/documents") << DolphinView::DetailsView << false << QList<QByteArray>({"text", "path"});
+
+    // audio files
+    QTest::newRow("Places - Audio") << QUrl("search:/audio") << DolphinView::DetailsView << false << QList<QByteArray>({"text", "artist", "album"});
+
+    // baloo - timeline
+    QTest::newRow("Baloo - Last Month") << QUrl("timeline:/lastmonth") << DolphinView::DetailsView << true << QList<QByteArray>({"text", "modificationtime"});
+
+    // devices
+    QTest::newRow("Devices - Floppy") << QUrl("file:///media/floppy0") << DolphinView::IconsView << true << QList<QByteArray>({"text"});
+
+}
+
+void PlacesItemModelTest::testDefaultViewProperties()
+{
+    QFETCH(QUrl, url);
+    QFETCH(DolphinView::Mode, expectedViewMode);
+    QFETCH(bool, expectedPreviewShow);
+    QFETCH(QList<QByteArray>, expectedVisibleRole);
+
+    ViewProperties properties(KFilePlacesModel::convertedUrl(url));
+    QCOMPARE(properties.viewMode(), expectedViewMode);
+    QCOMPARE(properties.previewsShown(), expectedPreviewShow);
+    QCOMPARE(properties.visibleRoles(), expectedVisibleRole);
+}
+
+void PlacesItemModelTest::testClear()
+{
+    QCOMPARE(m_model->count(), 17);
+    m_model->clear();
+    QCOMPARE(m_model->count(), 0);
+    QCOMPARE(m_model->hiddenCount(), 0);
+    m_model->refresh();
+    QTRY_COMPARE(m_model->count(), 17);
+}
+
+void PlacesItemModelTest::testHideItem()
+{
+    const QUrl mediaUrl = QUrl::fromLocalFile(QStringLiteral("/media/XO-Y4"));
+    const int index = indexOf(mediaUrl);
+
+    PlacesItem *item = m_model->placesItem(index);
+
+    QSignalSpy spyItemsRemoved(m_model, &PlacesItemModel::itemsRemoved);
+    QList<QVariant> spyItemsRemovedArgs;
+    KItemRangeList removedRange;
+
+    QSignalSpy spyItemsInserted(m_model, &PlacesItemModel::itemsInserted);
+    QList<QVariant> spyItemsInsertedArgs;
+    KItemRangeList insertedRange;
+    QVERIFY(item);
+
+    // hide an item
+    item->setHidden(true);
+
+    // check if items removed was fired
+    QTRY_COMPARE(m_model->count(), 16);
+    QCOMPARE(spyItemsRemoved.count(), 1);
+    spyItemsRemovedArgs = spyItemsRemoved.takeFirst();
+    removedRange = spyItemsRemovedArgs.at(0).value<KItemRangeList>();
+    QCOMPARE(removedRange.size(), 1);
+    QCOMPARE(removedRange.first().index, index);
+    QCOMPARE(removedRange.first().count, 1);
+
+    // allow model to show hidden items
+    m_model->setHiddenItemsShown(true);
+
+    // check if the items inserted was fired
+    spyItemsInsertedArgs = spyItemsInserted.takeFirst();
+    insertedRange = spyItemsInsertedArgs.at(0).value<KItemRangeList>();
+    QCOMPARE(insertedRange.size(), 1);
+    QCOMPARE(insertedRange.first().index, index);
+    QCOMPARE(insertedRange.first().count, 1);
+
+    // mark item as visible
+    item = m_model->placesItem(index);
+    item->setHidden(false);
+
+     // mark model to hide invisible items
+    m_model->setHiddenItemsShown(true);
+
+    QTRY_COMPARE(m_model->count(), 17);
+}
+
+void PlacesItemModelTest::testSystemItems()
+{
+    QCOMPARE(m_model->count(), 17);
+    for (int r = 0; r < m_model->count(); r++) {
+        QCOMPARE(m_model->placesItem(r)->isSystemItem(), !m_model->placesItem(r)->device().isValid());
+    }
+
+    QSignalSpy itemsInsertedSpy(m_model, &PlacesItemModel::itemsInserted);
+
+    // create a new entry (non system item)
+    createPlaceItem(QStringLiteral("Temporary Dir"),  QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::TempLocation)), QString());
+
+    // check if the new entry was created
+    QTRY_COMPARE(itemsInsertedSpy.count(), 1);
+
+    // make sure the new place get removed
+    removePlaceAfter(3);
+
+    QList<QVariant> args = itemsInsertedSpy.takeFirst();
+    KItemRangeList range = args.at(0).value<KItemRangeList>();
+    QCOMPARE(range.first().index, 3);
+    QCOMPARE(range.first().count, 1);
+    QVERIFY(!m_model->placesItem(3)->isSystemItem());
+    QCOMPARE(m_model->count(), 18);
+
+    QTest::qWait(300);
+    // check if the removal signal is correct
+    QSignalSpy itemsRemovedSpy(m_model, &PlacesItemModel::itemsRemoved);
+    m_model->deleteItem(3);
+    QTRY_COMPARE(itemsRemovedSpy.count(), 1);
+    args = itemsRemovedSpy.takeFirst();
+    range = args.at(0).value<KItemRangeList>();
+    QCOMPARE(range.first().index, 3);
+    QCOMPARE(range.first().count, 1);
+    QTRY_COMPARE(m_model->count(), 17);
+
+    //cancel removal (it was removed above)
+    cancelPlaceRemoval(3);
+}
+
+void PlacesItemModelTest::testEditBookmark()
+{
+    const QUrl tempUrl = QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::TempLocation));
+    QScopedPointer<PlacesItemModel> other(new PlacesItemModel());
+
+    createPlaceItem(QStringLiteral("Temporary Dir"), QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::TempLocation)), QString());
+
+    // make sure that the new item will be removed later
+    removePlaceAfter(3);
+
+    QSignalSpy itemsChangedSply(m_model, &PlacesItemModel::itemsChanged);
+
+    // modify place text
+    m_model->item(3)->setText(QStringLiteral("Renamed place"));
+    m_model->refresh();
+
+    // check if the correct signal was fired
+    QTRY_COMPARE(itemsChangedSply.count(), 1);
+    QList<QVariant> args = itemsChangedSply.takeFirst();
+    KItemRangeList range = args.at(0).value<KItemRangeList>();
+    QCOMPARE(range.first().index, 3);
+    QCOMPARE(range.first().count, 1);
+    QSet<QByteArray> roles = args.at(1).value<QSet<QByteArray> >();
+    QCOMPARE(roles.size(), 1);
+    QCOMPARE(*roles.begin(), QByteArrayLiteral("text"));
+    QCOMPARE(m_model->item(3)->text(), QStringLiteral("Renamed place"));
+
+    // check if the item was updated in the other model
+    QTRY_COMPARE(other->item(3)->text(), QStringLiteral("Renamed place"));
+}
+
+void PlacesItemModelTest::testEditAfterCreation()
+{
+    const QUrl tempUrl = QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::TempLocation));
+    QSignalSpy itemsInsertedSpy(m_model, &PlacesItemModel::itemsInserted);
+
+    // create a new place
+    createPlaceItem(QStringLiteral("Temporary Dir"), tempUrl, QString());
+    QTRY_COMPARE(itemsInsertedSpy.count(), 1);
+
+    PlacesItemModel *model = new PlacesItemModel();
+    QTRY_COMPARE(model->count(), m_model->count());
+
+    // make sure that the new item will be removed later
+    removePlaceAfter(3);
+
+    // modify place text
+    PlacesItem *item = m_model->placesItem(3);
+    item->setText(QStringLiteral("Renamed place"));
+    m_model->refresh();
+
+    // check if the second model got the changes
+    QTRY_COMPARE(model->count(), m_model->count());
+    QTRY_COMPARE(model->placesItem(3)->text(), m_model->placesItem(3)->text());
+    QTRY_COMPARE(model->placesItem(3)->bookmark().metaDataItem(QStringLiteral("OnlyInApp")),
+                 m_model->placesItem(3)->bookmark().metaDataItem(QStringLiteral("OnlyInApp")));
+    QTRY_COMPARE(model->placesItem(3)->icon(), m_model->placesItem(3)->icon());
+    QTRY_COMPARE(model->placesItem(3)->url(), m_model->placesItem(3)->url());
+}
+
+void PlacesItemModelTest::testEditMetadata()
+{
+    const QUrl tempUrl = QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::TempLocation));
+    QSignalSpy itemsInsertedSpy(m_model, &PlacesItemModel::itemsInserted);
+
+    // create a new place
+    createPlaceItem(QStringLiteral("Temporary Dir"), tempUrl, QString());
+    QTRY_COMPARE(itemsInsertedSpy.count(), 1);
+
+    // check if the new entry was created
+    PlacesItemModel *model = new PlacesItemModel();
+    QTRY_COMPARE(model->count(), m_model->count());
+
+    // make sure that the new item will be removed later
+    removePlaceAfter(3);
+
+    // modify place metadata
+    PlacesItem *item = m_model->placesItem(3);
+    item->bookmark().setMetaDataItem(QStringLiteral("OnlyInApp"), KAboutData::applicationData().componentName());
+    m_model->refresh();
+
+    // check if the place was modified in both models
+    QTRY_COMPARE(model->placesItem(3)->bookmark().metaDataItem(QStringLiteral("OnlyInApp")),
+                 KAboutData::applicationData().componentName());
+    QTRY_COMPARE(model->placesItem(3)->text(), m_model->placesItem(3)->text());
+    QTRY_COMPARE(model->placesItem(3)->bookmark().metaDataItem(QStringLiteral("OnlyInApp")),
+                 m_model->placesItem(3)->bookmark().metaDataItem(QStringLiteral("OnlyInApp")));
+    QTRY_COMPARE(model->placesItem(3)->icon(), m_model->placesItem(3)->icon());
+    QTRY_COMPARE(model->placesItem(3)->url(), m_model->placesItem(3)->url());
+}
+
+void PlacesItemModelTest::testRefresh()
+{
+    const QUrl tempUrl = QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::TempLocation));
+    QSignalSpy itemsInsertedSpy(m_model, &PlacesItemModel::itemsInserted);
+
+    // create a new place
+    createPlaceItem(QStringLiteral("Temporary Dir"), tempUrl, QString());
+    QTRY_COMPARE(itemsInsertedSpy.count(), 1);
+
+    PlacesItemModel *model = new PlacesItemModel();
+    QTRY_COMPARE(model->count(), m_model->count());
+
+    // make sure that the new item will be removed later
+    removePlaceAfter(3);
+
+    PlacesItem *item = m_model->placesItem(3);
+    PlacesItem *sameItem = model->placesItem(3);
+    QCOMPARE(item->text(), sameItem->text());
+
+    // modify place text
+    item->setText(QStringLiteral("Renamed place"));
+
+    // item from another model is not affected at the moment
+    QVERIFY(item->text() != sameItem->text());
+
+    // propagate change
+    m_model->refresh();
+
+    // item must be equal
+    QTRY_COMPARE(item->text(), sameItem->text());
+}
+
+void PlacesItemModelTest::testIcons_data()
+{
+    QTest::addColumn<QUrl>("url");
+    QTest::addColumn<QString>("expectedIconName");
+
+    // places
+    QTest::newRow("Places - Home") << QUrl::fromLocalFile(QDir::homePath()) << QStringLiteral("user-home");
+
+    // baloo -search
+    QTest::newRow("Baloo - Documents") << QUrl("search:/documents") << QStringLiteral("folder-text");
+
+    // baloo - timeline
+    QTest::newRow("Baloo - Last Month") << QUrl("timeline:/lastmonth") << QStringLiteral("view-calendar-month");
+
+    // devices
+    QTest::newRow("Devices - Floppy") << QUrl("file:///media/floppy0") << QStringLiteral("blockdevice");
+}
+
+void PlacesItemModelTest::testIcons()
+{
+    QFETCH(QUrl, url);
+    QFETCH(QString, expectedIconName);
+
+    PlacesItem *item = m_model->placesItem(indexOf(url));
+    QCOMPARE(item->icon(), expectedIconName);
+
+    for (int r = 0; r < m_model->count(); r++) {
+        QVERIFY(!m_model->placesItem(r)->icon().isEmpty());
+    }
+}
+
+void PlacesItemModelTest::testDragAndDrop()
+{
+    QList<QVariant> args;
+    KItemRangeList range;
+    QStringList urls = initialUrls();
+    QSignalSpy itemsInsertedSpy(m_model, &PlacesItemModel::itemsInserted);
+    QSignalSpy itemsRemovedSpy(m_model, &PlacesItemModel::itemsRemoved);
+
+    CHECK_PLACES_URLS(initialUrls());
+    // Move the KDE_ROOT_PATH at the end of the places list will case it to be moved to the end of the places group
+    QMimeData *dropData = createMimeData(QList<int>() << 1);
+    m_model->dropMimeDataBefore(m_model->count() - 1, dropData);
+    urls.move(1, 2);
+    delete dropData;
+
+    QTRY_COMPARE(itemsInsertedSpy.count(), 1);
+    QTRY_COMPARE(itemsRemovedSpy.count(), 1);
+
+    // remove item from actual position
+    args = itemsRemovedSpy.takeFirst();
+    range = args.at(0).value<KItemRangeList>();
+    QCOMPARE(range.size(), 1);
+    QCOMPARE(range.at(0).count, 1);
+    QCOMPARE(range.at(0).index, 1);
+
+    // insert intem in his group
+    args = itemsInsertedSpy.takeFirst();
+    range = args.at(0).value<KItemRangeList>();
+    QCOMPARE(range.size(), 1);
+    QCOMPARE(range.at(0).count, 1);
+    QCOMPARE(range.at(0).index, 2);
+
+    CHECK_PLACES_URLS(urls);
+
+    itemsInsertedSpy.clear();
+    itemsRemovedSpy.clear();
+
+    // Move the KDE_ROOT_PATH to his original position
+    dropData = createMimeData(QList<int>() << 2);
+    m_model->dropMimeDataBefore(1, dropData);
+    urls.move(2, 1);
+    delete dropData;
+
+    QTRY_COMPARE(itemsInsertedSpy.count(), 1);
+    QTRY_COMPARE(itemsRemovedSpy.count(), 1);
+
+    // remove item from actual position
+    args = itemsRemovedSpy.takeFirst();
+    range = args.at(0).value<KItemRangeList>();
+    QCOMPARE(range.size(), 1);
+    QCOMPARE(range.at(0).count, 1);
+    QCOMPARE(range.at(0).index, 2);
+
+    // insert intem in the requested position
+    args = itemsInsertedSpy.takeFirst();
+    range = args.at(0).value<KItemRangeList>();
+    QCOMPARE(range.size(), 1);
+    QCOMPARE(range.at(0).count, 1);
+    QCOMPARE(range.at(0).index, 1);
+
+    CHECK_PLACES_URLS(urls);
+}
+
+void PlacesItemModelTest::testHideDevices()
+{
+    QSignalSpy itemsRemoved(m_model, &PlacesItemModel::itemsRemoved);
+    QStringList urls = initialUrls();
+
+    m_model->setGroupHidden(KFilePlacesModel::RemovableDevicesType, true);
+    QTRY_VERIFY(m_model->isGroupHidden(KFilePlacesModel::RemovableDevicesType));
+    QTRY_COMPARE(itemsRemoved.count(), 3);
+
+    // remove removable-devices
+    urls.removeOne(QStringLiteral("/media/floppy0"));
+    urls.removeOne(QStringLiteral("/media/XO-Y4"));
+    urls.removeOne(QStringLiteral("/media/cdrom"));
+
+    // check if the correct urls was removed
+    CHECK_PLACES_URLS(urls);
+
+    delete m_model;
+    m_model = new PlacesItemModel();
+    QTRY_COMPARE(m_model->count(), urls.count());
+    CHECK_PLACES_URLS(urls);
+
+    // revert changes
+    m_model->setGroupHidden(KFilePlacesModel::RemovableDevicesType, false);
+    urls = initialUrls();
+    QTRY_COMPARE(m_model->count(), urls.count());
+    CHECK_PLACES_URLS(urls);
+}
+
+void PlacesItemModelTest::testDuplicatedEntries()
+{
+    QStringList urls = initialUrls();
+    // create a duplicated entry on bookmark
+    KBookmarkManager *bookmarkManager = KBookmarkManager::managerForFile(bookmarksFile(), QStringLiteral("kfilePlaces"));
+    KBookmarkGroup root = bookmarkManager->root();
+    KBookmark bookmark = root.addBookmark(QStringLiteral("Duplicated Search Videos"), QUrl("search:/videos"), {});
+
+    const QString id = QUuid::createUuid().toString();
+    bookmark.setMetaDataItem(QStringLiteral("ID"), id);
+    bookmark.setMetaDataItem(QStringLiteral("OnlyInApp"), KAboutData::applicationData().componentName());
+    bookmarkManager->emitChanged(bookmarkManager->root());
+
+    PlacesItemModel *newModel = new PlacesItemModel();
+    QTRY_COMPARE(placesUrls(newModel).count(QStringLiteral("search:/videos")), 1);
+    QTRY_COMPARE(urls, placesUrls(newModel));
+    delete newModel;
+}
+
+void PlacesItemModelTest::renameAfterCreation()
+{
+    const QUrl tempUrl = QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::TempLocation));
+    QStringList urls = initialUrls();
+    PlacesItemModel *model = new PlacesItemModel();
+
+    CHECK_PLACES_URLS(urls);
+    QTRY_COMPARE(model->count(), m_model->count());
+
+    // create a new place
+    createPlaceItem(QStringLiteral("Temporary Dir"), tempUrl, QString());
+    urls.insert(3, tempUrl.toLocalFile());
+
+    // make sure that the new item will be removed later
+    removePlaceAfter(3);
+
+    CHECK_PLACES_URLS(urls);
+    QCOMPARE(model->count(), m_model->count());
+
+
+    // modify place text
+    QSignalSpy changedSpy(m_model, &PlacesItemModel::itemsChanged);
+
+    PlacesItem *item = m_model->placesItem(3);
+    item->setText(QStringLiteral("New Temporary Dir"));
+    item->setUrl(item->url());
+    item->setIcon(item->icon());
+    m_model->refresh();
+
+    QTRY_COMPARE(changedSpy.count(), 1);
+
+    // check if the place was modified in both models
+    QTRY_COMPARE(m_model->placesItem(3)->text(), QStringLiteral("New Temporary Dir"));
+    QTRY_COMPARE(model->placesItem(3)->text(), QStringLiteral("New Temporary Dir"));
+}
+
+QTEST_MAIN(PlacesItemModelTest)
+
+#include "placesitemmodeltest.moc"
index 114afdc33c9082830cc545eb7ee27f01125e7157..5193bb35a23bbee63f4e08055e9c12bdfe5086ba 100644 (file)
@@ -56,7 +56,7 @@ void ViewPropertiesTest::init()
 void ViewPropertiesTest::cleanup()
 {
     delete m_testDir;
-    m_testDir = 0;
+    m_testDir = nullptr;
 
     GeneralSettings::self()->setGlobalViewProps(m_globalViewProps);
     GeneralSettings::self()->save();
index af73ac9377de712fd3ec0c8572fb536fc51d8ff9..a04bc68282cd0d852b394e0e364eb0aff1e2b657 100644 (file)
@@ -37,10 +37,10 @@ class DOLPHIN_EXPORT DolphinFileItemListWidget : public KFileItemListWidget
 
 public:
     DolphinFileItemListWidget(KItemListWidgetInformant* informant, QGraphicsItem* parent);
-    virtual ~DolphinFileItemListWidget();
+    ~DolphinFileItemListWidget() override;
 
 protected:
-    virtual void refreshCache() Q_DECL_OVERRIDE;
+    void refreshCache() override;
 
 private:
     static QPixmap overlayForState(KVersionControlPlugin::ItemVersion version, int size);
index a3740cb261c92be1d5fc77d6f61641a2551d7f08..a1472c6610146ec840c8726621a1dec372a95e0e 100644 (file)
@@ -30,6 +30,7 @@
 #include <kitemviews/kitemlistcontroller.h>
 #include <kitemviews/kitemliststyleoption.h>
 
+#include <KIO/PreviewJob>
 
 #include <views/viewmodecontroller.h>
 
@@ -94,11 +95,7 @@ void DolphinItemListView::readSettings()
     updateGridSize();
 
     const KConfigGroup globalConfig(KSharedConfig::openConfig(), "PreviewSettings");
-    const QStringList plugins = globalConfig.readEntry("Plugins", QStringList()
-                                                       << QStringLiteral("directorythumbnail")
-                                                       << QStringLiteral("imagethumbnail")
-                                                       << QStringLiteral("jpegthumbnail"));
-    setEnabledPlugins(plugins);
+    setEnabledPlugins(globalConfig.readEntry("Plugins", KIO::PreviewJob::defaultPlugins()));
 
     endTransaction();
 }
index 7eec6f17afbc1e4ed900e30f79db6ed52116fb8a..ff14fbe7c4d7e4a4068ded15c1cf646a73052f1f 100644 (file)
@@ -39,8 +39,8 @@ class DOLPHIN_EXPORT DolphinItemListView : public KFileItemListView
     Q_OBJECT
 
 public:
-    explicit DolphinItemListView(QGraphicsWidget* parent = 0);
-    virtual ~DolphinItemListView();
+    explicit DolphinItemListView(QGraphicsWidget* parent = nullptr);
+    ~DolphinItemListView() override;
 
     void setZoomLevel(int level);
     int zoomLevel() const;
@@ -49,14 +49,14 @@ public:
     void writeSettings();
 
 protected:
-    virtual KItemListWidgetCreatorBase* defaultWidgetCreator() const Q_DECL_OVERRIDE;
-    virtual bool itemLayoutSupportsItemExpanding(ItemLayout layout) const Q_DECL_OVERRIDE;
-    virtual void onItemLayoutChanged(ItemLayout current, ItemLayout previous) Q_DECL_OVERRIDE;
-    virtual void onPreviewsShownChanged(bool shown) Q_DECL_OVERRIDE;
-    virtual void onVisibleRolesChanged(const QList<QByteArray>& current,
-                                       const QList<QByteArray>& previous) Q_DECL_OVERRIDE;
+    KItemListWidgetCreatorBase* defaultWidgetCreator() const override;
+    bool itemLayoutSupportsItemExpanding(ItemLayout layout) const override;
+    void onItemLayoutChanged(ItemLayout current, ItemLayout previous) override;
+    void onPreviewsShownChanged(bool shown) override;
+    void onVisibleRolesChanged(const QList<QByteArray>& current,
+                                       const QList<QByteArray>& previous) override;
 
-    virtual void updateFont() Q_DECL_OVERRIDE;
+    void updateFont() override;
 
 private:
     void updateGridSize();
index 275e1c4fb0445752bbe7cf016413eaf12f68c100..6379adb31456c7486798c6768d1b3c9d8fbe9c2d 100644 (file)
@@ -54,7 +54,7 @@ void DolphinNewFileMenuObserver::detach(const DolphinNewFileMenu* menu)
 }
 
 DolphinNewFileMenuObserver::DolphinNewFileMenuObserver() :
-    QObject(0)
+    QObject(nullptr)
 {
 }
 
index df4621f171bf91d65c2c5a9cc2895316f2c96219..2386bce1eee927e288559f62022f73310e58342a 100644 (file)
@@ -48,7 +48,7 @@ signals:
 
 private:
     DolphinNewFileMenuObserver();
-    virtual ~DolphinNewFileMenuObserver();
+    ~DolphinNewFileMenuObserver() override;
 
     friend class DolphinNewFileMenuObserverSingleton;
 };
index 28ff52cb3ff7ab3c8d2a29af11896611cf9318d2..ca1cea2c7fbc7ab6c1096e707b65d22bed236f80 100644 (file)
@@ -40,7 +40,7 @@ class DOLPHIN_EXPORT DolphinRemoteEncoding: public QObject
   Q_OBJECT
 public:
   DolphinRemoteEncoding(QObject* parent, DolphinViewActionHandler* actionHandler);
-  ~DolphinRemoteEncoding();
+  ~DolphinRemoteEncoding() override;
 
 public Q_SLOTS:
   void slotAboutToOpenUrl();
index cd802eec1c1612016b493d0e6d5daa50793454be..e40e49d6e4a755c3032b650d8197feb754527f2b 100644 (file)
@@ -87,19 +87,19 @@ DolphinView::DolphinView(const QUrl& url, QWidget* parent) :
     m_viewPropertiesContext(),
     m_mode(DolphinView::IconsView),
     m_visibleRoles(),
-    m_topLayout(0),
-    m_model(0),
-    m_view(0),
-    m_container(0),
-    m_toolTipManager(0),
-    m_selectionChangedTimer(0),
+    m_topLayout(nullptr),
+    m_model(nullptr),
+    m_view(nullptr),
+    m_container(nullptr),
+    m_toolTipManager(nullptr),
+    m_selectionChangedTimer(nullptr),
     m_currentItemUrl(),
     m_scrollToCurrentItem(false),
     m_restoredContentsPosition(),
     m_selectedUrls(),
     m_clearSelectionBeforeSelectingNewItems(false),
     m_markFirstNewlySelectedItemAsCurrent(false),
-    m_versionControlObserver(0),
+    m_versionControlObserver(nullptr),
     m_twoClicksRenamingTimer(nullptr)
 {
     m_topLayout = new QVBoxLayout(this);
@@ -912,7 +912,7 @@ void DolphinView::slotHeaderContextMenuRequested(const QPointF& pos)
 #endif
 
     QString groupName;
-    QMenu* groupMenu = 0;
+    QMenu* groupMenu = nullptr;
 
     // Add all roles to the menu that can be shown or hidden by the user
     const QList<KFileItemModel::RoleInfo> rolesInfo = KFileItemModel::rolesInformation();
@@ -923,7 +923,7 @@ void DolphinView::slotHeaderContextMenuRequested(const QPointF& pos)
         }
 
         const QString text = m_model->roleDescription(info.role);
-        QAction* action = 0;
+        QAction* action = nullptr;
         if (info.group.isEmpty()) {
             action = menu->addAction(text);
         } else {
@@ -1094,11 +1094,11 @@ void DolphinView::dropUrls(const QUrl &destUrl, QDropEvent *dropEvent, QWidget *
 
 void DolphinView::slotModelChanged(KItemModelBase* current, KItemModelBase* previous)
 {
-    if (previous != 0) {
+    if (previous != nullptr) {
         Q_ASSERT(qobject_cast<KFileItemModel*>(previous));
         KFileItemModel* fileItemModel = static_cast<KFileItemModel*>(previous);
         disconnect(fileItemModel, &KFileItemModel::directoryLoadingCompleted, this, &DolphinView::slotDirectoryLoadingCompleted);
-        m_versionControlObserver->setModel(0);
+        m_versionControlObserver->setModel(nullptr);
     }
 
     if (current) {
@@ -1356,17 +1356,21 @@ void DolphinView::updateViewState()
 {
     if (m_currentItemUrl != QUrl()) {
         KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
-        const int currentIndex = m_model->index(m_currentItemUrl);
-        if (currentIndex != -1) {
-            selectionManager->setCurrentItem(currentIndex);
-
-            // scroll to current item and reset the state
-            if (m_scrollToCurrentItem) {
-                m_view->scrollToItem(currentIndex);
-                m_scrollToCurrentItem = false;
+
+        // if there is a selection already, leave it that way
+        if (!selectionManager->hasSelection()) {
+            const int currentIndex = m_model->index(m_currentItemUrl);
+            if (currentIndex != -1) {
+                selectionManager->setCurrentItem(currentIndex);
+
+                // scroll to current item and reset the state
+                if (m_scrollToCurrentItem) {
+                    m_view->scrollToItem(currentIndex);
+                    m_scrollToCurrentItem = false;
+                }
+            } else {
+                selectionManager->setCurrentItem(0);
             }
-        } else {
-            selectionManager->setCurrentItem(0);
         }
 
         m_currentItemUrl = QUrl();
@@ -1384,26 +1388,29 @@ void DolphinView::updateViewState()
     if (!m_selectedUrls.isEmpty()) {
         KItemListSelectionManager* selectionManager = m_container->controller()->selectionManager();
 
-        if (m_clearSelectionBeforeSelectingNewItems) {
-            selectionManager->clearSelection();
-            m_clearSelectionBeforeSelectingNewItems = false;
-        }
+        // if there is a selection already, leave it that way
+        if (!selectionManager->hasSelection()) {
+            if (m_clearSelectionBeforeSelectingNewItems) {
+                selectionManager->clearSelection();
+                m_clearSelectionBeforeSelectingNewItems = false;
+            }
 
-        KItemSet selectedItems = selectionManager->selectedItems();
+            KItemSet selectedItems = selectionManager->selectedItems();
 
-        QList<QUrl>::iterator it = m_selectedUrls.begin();
-        while (it != m_selectedUrls.end()) {
-            const int index = m_model->index(*it);
-            if (index >= 0) {
-                selectedItems.insert(index);
-                it = m_selectedUrls.erase(it);
-            } else {
-                 ++it;
+            QList<QUrl>::iterator it = m_selectedUrls.begin();
+            while (it != m_selectedUrls.end()) {
+                const int index = m_model->index(*it);
+                if (index >= 0) {
+                    selectedItems.insert(index);
+                    it = m_selectedUrls.erase(it);
+                } else {
+                    ++it;
+                }
             }
-        }
 
-        selectionManager->beginAnchoredSelection(selectionManager->currentItem());
-        selectionManager->setSelectedItems(selectedItems);
+            selectionManager->beginAnchoredSelection(selectionManager->currentItem());
+            selectionManager->setSelectedItems(selectedItems);
+        }
     }
 }
 
index 2df1cf9e4caa2c7e762bb9c179c6c23070a9f028..61f6af1e2fcfb358d24cfbfc4731407cd300e4e0 100644 (file)
@@ -93,7 +93,7 @@ public:
      */
     DolphinView(const QUrl& url, QWidget* parent);
 
-    virtual ~DolphinView();
+    ~DolphinView() override;
 
     /**
      * Returns the current active URL, where all actions are applied.
@@ -370,7 +370,7 @@ public slots:
     void stopLoading();
 
     /** Activates the view if the item list container gets focus. */
-    virtual bool eventFilter(QObject* watched, QEvent* event) Q_DECL_OVERRIDE;
+    bool eventFilter(QObject* watched, QEvent* event) override;
 
 signals:
     /**
@@ -552,10 +552,10 @@ signals:
 
 protected:
     /** Changes the zoom level if Control is pressed during a wheel event. */
-    virtual void wheelEvent(QWheelEvent* event) Q_DECL_OVERRIDE;
+    void wheelEvent(QWheelEvent* event) override;
 
-    virtual void hideEvent(QHideEvent* event) Q_DECL_OVERRIDE;
-    virtual bool event(QEvent* event) Q_DECL_OVERRIDE;
+    void hideEvent(QHideEvent* event) override;
+    bool event(QEvent* event) override;
 
 private slots:
     /**
index 10aae11ce6f30d6630cfe116614905184d3bc9f5..9debd51731e0f43c2c65d15e838dd1d538a2d183 100644 (file)
@@ -49,7 +49,7 @@
 DolphinViewActionHandler::DolphinViewActionHandler(KActionCollection* collection, QObject* parent) :
     QObject(parent),
     m_actionCollection(collection),
-    m_currentView(0),
+    m_currentView(nullptr),
     m_sortByActions(),
     m_visibleRoles()
 {
@@ -62,7 +62,7 @@ void DolphinViewActionHandler::setCurrentView(DolphinView* view)
     Q_ASSERT(view);
 
     if (m_currentView) {
-        disconnect(m_currentView, 0, this, 0);
+        disconnect(m_currentView, nullptr, this, nullptr);
     }
 
     m_currentView = view;
@@ -233,8 +233,8 @@ QActionGroup* DolphinViewActionHandler::createFileItemRolesActionGroup(const QSt
     }
 
     QString groupName;
-    KActionMenu* groupMenu = 0;
-    QActionGroup* groupMenuGroup = 0;
+    KActionMenu* groupMenu = nullptr;
+    QActionGroup* groupMenuGroup = nullptr;
 
     bool indexingEnabled = false;
 #ifdef HAVE_BALOO
@@ -249,7 +249,7 @@ QActionGroup* DolphinViewActionHandler::createFileItemRolesActionGroup(const QSt
             continue;
         }
 
-        KToggleAction* action = 0;
+        KToggleAction* action = nullptr;
         const QString name = groupPrefix + info.role;
         if (info.group.isEmpty()) {
             action = m_actionCollection->add<KToggleAction>(name);
@@ -590,7 +590,7 @@ void DolphinViewActionHandler::slotAdjustViewProperties()
 
 void DolphinViewActionHandler::slotProperties()
 {
-    KPropertiesDialog* dialog = 0;
+    KPropertiesDialog* dialog = nullptr;
     const KFileItemList list = m_currentView->selectedItems();
     if (list.isEmpty()) {
         const QUrl url = m_currentView->url();
index 831a9d43e08be707514235df07fb87435b80cf4c..e944227df9f9859d01382041202b821145c842b0 100644 (file)
@@ -60,6 +60,6 @@ KIO::DropJob* DragAndDropHelper::dropUrls(const QUrl& destUrl, QDropEvent* event
         return job;
     }
 
-    return 0;
+    return nullptr;
 }
 
index 6309bfbdfecf6b4c95b4e996ecd3d58c2416bbe1..2e1fa863444a228a0e705b76a423e963b88fb447 100644 (file)
@@ -24,6 +24,7 @@
 #include <KIO/CopyJob>
 #include <KIO/FileUndoManager>
 #include <KJobUiDelegate>
+#include <KIO/BatchRenameJob>
 
 #include <QHBoxLayout>
 #include <QLabel>
@@ -39,10 +40,10 @@ RenameDialog::RenameDialog(QWidget *parent, const KFileItemList& items) :
     QDialog(parent),
     m_renameOneItem(false),
     m_newName(),
-    m_lineEdit(0),
+    m_lineEdit(nullptr),
     m_items(items),
     m_allExtensionsDifferent(true),
-    m_spinBox(0)
+    m_spinBox(nullptr)
 {
     const QSize minSize = minimumSize();
     setMinimumSize(QSize(320, minSize.height()));
@@ -72,7 +73,7 @@ RenameDialog::RenameDialog(QWidget *parent, const KFileItemList& items) :
 
     QVBoxLayout* topLayout = new QVBoxLayout(page);
 
-    QLabel* editLabel = 0;
+    QLabel* editLabel = nullptr;
     if (m_renameOneItem) {
         m_newName = items.first().name();
         editLabel = new QLabel(xi18nc("@label:textbox", "Rename the item <filename>%1</filename> to:", m_newName),
@@ -148,38 +149,32 @@ RenameDialog::~RenameDialog()
 {
 }
 
-void RenameDialog::renameItem(const KFileItem &item, const QString& newName)
+void RenameDialog::slotAccepted()
 {
-    const QUrl oldUrl = item.url();
-    QUrl newUrl = oldUrl.adjusted(QUrl::RemoveFilename);
-    newUrl.setPath(newUrl.path() + KIO::encodeFileName(newName));
-
     QWidget* widget = parentWidget();
     if (!widget) {
         widget = this;
     }
 
-    KIO::Job * job = KIO::moveAs(oldUrl, newUrl, KIO::HideProgressInfo);
+    KIO::FileUndoManager::CommandType cmdType;
+    if (m_renameOneItem) {
+        Q_ASSERT(m_items.count() == 1);
+        cmdType = KIO::FileUndoManager::Rename;
+    } else {
+        cmdType = KIO::FileUndoManager::BatchRename;
+    }
+
+    const QList<QUrl> srcList = m_items.urlList();
+    KIO::BatchRenameJob* job = KIO::batchRename(srcList, m_lineEdit->text(), m_spinBox->value(), QLatin1Char('#'));
     KJobWidgets::setWindow(job, widget);
-    KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Rename, {oldUrl}, newUrl, job);
+    const QUrl parentUrl = srcList.first().adjusted(QUrl::RemoveFilename | QUrl::StripTrailingSlash);
+    KIO::FileUndoManager::self()->recordJob(cmdType, srcList, parentUrl, job);
 
-    if (!job->error()) {
-        m_renamedItems << newUrl;
-    }
+    connect(job, &KIO::BatchRenameJob::fileRenamed, this, &RenameDialog::slotFileRenamed);
+    connect(job, &KIO::BatchRenameJob::result, this, &RenameDialog::slotResult);
 
     job->uiDelegate()->setAutoErrorHandlingEnabled(true);
-}
 
-void RenameDialog::slotAccepted()
-{
-    m_newName = m_lineEdit->text();
-
-    if (m_renameOneItem) {
-        Q_ASSERT(m_items.count() == 1);
-        renameItem(m_items.first(), m_newName);
-    } else {
-        renameItems();
-    }
     accept();
 }
 
@@ -201,55 +196,22 @@ void RenameDialog::slotTextChanged(const QString& newName)
     m_okButton->setEnabled(enable);
 }
 
-void RenameDialog::showEvent(QShowEvent* event)
+void RenameDialog::slotFileRenamed(const QUrl &oldUrl, const QUrl &newUrl)
 {
-    m_lineEdit->setFocus();
-
-    QDialog::showEvent(event);
+    Q_UNUSED(oldUrl)
+    m_renamedItems << newUrl;
 }
 
-void RenameDialog::renameItems()
+void RenameDialog::slotResult(KJob *job)
 {
-    // Iterate through all items and rename them...
-    int index = m_spinBox->value();
-    foreach (const KFileItem& item, m_items) {
-        QString newName = indexedName(m_newName, index, QLatin1Char('#'));
-        ++index;
-
-        const QUrl oldUrl = item.url();
-        QMimeDatabase db;
-        const QString extension = db.suffixForFileName(oldUrl.path().toLower());
-        if (!extension.isEmpty()) {
-            newName.append(QLatin1Char('.'));
-            newName.append(extension);
-        }
-
-        if (oldUrl.fileName() != newName) {
-            renameItem(item, newName);
-        }
-    }
-
-    if (!m_items.empty()) {
+    if (!job->error()) {
         emit renamingFinished(m_renamedItems);
     }
 }
 
-QString RenameDialog::indexedName(const QString& name, int index, const QChar& indexPlaceHolder)
+void RenameDialog::showEvent(QShowEvent* event)
 {
-    QString newName = name;
-
-    QString indexString = QString::number(index);
-
-    // Insert leading zeros if necessary
-    const int minIndexLength = name.count(indexPlaceHolder);
-    while (indexString.length() < minIndexLength) {
-        indexString.prepend(QLatin1Char('0'));
-    }
-
-    // Replace the index placeholders by the indexString
-    const int placeHolderStart = newName.indexOf(indexPlaceHolder);
-    newName.replace(placeHolderStart, minIndexLength, indexString);
+    m_lineEdit->setFocus();
 
-    return newName;
+    QDialog::showEvent(event);
 }
-
index 7ead0ca9f8531dd2ca156329706b18c6afd6469b..8da770895f92b2a0e9ab13d41d19418ce9e4506f 100644 (file)
@@ -29,7 +29,7 @@
 class QLineEdit;
 class QSpinBox;
 class QPushButton;
-
+class KJob;
 /**
  * @brief Dialog for renaming a variable number of files.
  */
@@ -39,7 +39,7 @@ class DOLPHIN_EXPORT RenameDialog : public QDialog
 
 public:
     explicit RenameDialog(QWidget* parent, const KFileItemList& items);
-    virtual ~RenameDialog();
+    ~RenameDialog() override;
 
 signals:
     void renamingFinished(const QList<QUrl>& urls);
@@ -47,23 +47,12 @@ signals:
 private slots:
     void slotAccepted();
     void slotTextChanged(const QString& newName);
+    void slotFileRenamed(const QUrl& oldUrl, const QUrl& newUrl);
+    void slotResult(KJob* job);
 
 protected:
     void showEvent(QShowEvent* event) override;
 
-private:
-    void renameItems();
-    void renameItem(const KFileItem &item, const QString& newName);
-
-    /**
-     * @return Returns the string \p name, where the characters represented by
-     *         \p indexPlaceHolder get replaced by the index \p index.
-     *         E. g. Calling indexedName("Test #.jpg", 12, '#') returns "Test 12.jpg".
-     *         A connected sequence of placeholders results in leading zeros:
-     *         indexedName("Test ####.jpg", 12, '#') returns "Test 0012.jpg".
-     */
-    static QString indexedName(const QString& name, int index, const QChar& indexPlaceHolder);
-
 private:
     bool m_renameOneItem;
     QList<QUrl> m_renamedItems;
index 52eeb3b710a57b7afa921184e670ae9cfe968d2f..cabfc0617614bf0444d3cf05b123926f00f0f879 100644 (file)
@@ -41,9 +41,9 @@
 
 DolphinFileMetaDataWidget::DolphinFileMetaDataWidget(QWidget* parent) :
     QWidget(parent),
-    m_preview(0),
-    m_name(0),
-    m_fileMetaDataWidget(0)
+    m_preview(nullptr),
+    m_name(nullptr),
+    m_fileMetaDataWidget(nullptr)
 {
     // Create widget for file preview
     m_preview = new QLabel(this);
index c5c228766bef3eb3ef93ba4b77e0c420990de124..6dcc5237c197241862f98a7d8ef53d124ad25454 100644 (file)
@@ -45,8 +45,8 @@ class DolphinFileMetaDataWidget : public QWidget
     Q_OBJECT
 
 public:
-    DolphinFileMetaDataWidget(QWidget* parent = 0);
-    virtual ~DolphinFileMetaDataWidget();
+    DolphinFileMetaDataWidget(QWidget* parent = nullptr);
+    ~DolphinFileMetaDataWidget() override;
 
     void setPreview(const QPixmap& pixmap);
     QPixmap preview() const;
index 9375172eb4feefb70a3c8ca07d9debe0145ddc84..3d3598ff5f53fb991a2b3760bbe299063a8396eb 100644 (file)
 
 ToolTipManager::ToolTipManager(QWidget* parent) :
     QObject(parent),
-    m_showToolTipTimer(0),
-    m_contentRetrievalTimer(0),
-    m_transientParent(0),
-    m_fileMetaDataWidget(0),
+    m_showToolTipTimer(nullptr),
+    m_contentRetrievalTimer(nullptr),
+    m_transientParent(nullptr),
+    m_fileMetaDataWidget(nullptr),
     m_toolTipRequested(false),
     m_metaDataRequested(false),
     m_appliedWaitCursor(false),
index 9f1f104f1a57b48ef7a80a4bfd0b0d68a37b968a..746d6cb67de2e97406f4a83fa00914c9c7e92583 100644 (file)
@@ -43,7 +43,7 @@ class ToolTipManager : public QObject
 
 public:
     explicit ToolTipManager(QWidget* parent);
-    virtual ~ToolTipManager();
+    ~ToolTipManager() override;
 
     /**
      * Triggers the showing of the tooltip for the item \p item
index 1696f975c76dfc378ba79035535bb33f72863e79..a3be381f3ff31de8e6c6645ec583447159861055 100644 (file)
@@ -144,8 +144,8 @@ public:
         MissingVersion
     };
 
-    KVersionControlPlugin(QObject* parent = 0);
-    virtual ~KVersionControlPlugin();
+    KVersionControlPlugin(QObject* parent = nullptr);
+    ~KVersionControlPlugin() override;
 
     /**
      * Returns the name of the file which stores
index e4413fabfb4752e69da51a3879a15427f2a00500..574402dcdea3be2c206155ee8ac304f24af7cb75 100644 (file)
@@ -25,7 +25,7 @@
 UpdateItemStatesThread::UpdateItemStatesThread(KVersionControlPlugin* plugin,
                                                const QMap<QString, QVector<VersionControlObserver::ItemState> >& itemStates) :
     QThread(),
-    m_globalPluginMutex(0),
+    m_globalPluginMutex(nullptr),
     m_plugin(plugin),
     m_itemStates(itemStates)
 {
index 3dc03fc75bdfb7884e3f451064254a7644b16488..d33a64cc7fdf4c5d4c91be9eedcf772da4409c0f 100644 (file)
@@ -46,12 +46,12 @@ public:
      */
     UpdateItemStatesThread(KVersionControlPlugin* plugin,
                            const QMap<QString, QVector<VersionControlObserver::ItemState> >& itemStates);
-    virtual ~UpdateItemStatesThread();
+    ~UpdateItemStatesThread() override;
 
     QMap<QString, QVector<VersionControlObserver::ItemState> > itemStates() const;
 
 protected:
-    virtual void run() Q_DECL_OVERRIDE;
+    void run() override;
 
 private:
     QMutex* m_globalPluginMutex; // Protects the m_plugin globally
index c794408825c62cf962d9c97ca72ba34a10a22a1f..44dffac45d8784a43f930538b848a45690eb95ce 100644 (file)
@@ -37,10 +37,10 @@ VersionControlObserver::VersionControlObserver(QObject* parent) :
     m_pendingItemStatesUpdate(false),
     m_versionedDirectory(false),
     m_silentUpdate(false),
-    m_model(0),
-    m_dirVerificationTimer(0),
-    m_plugin(0),
-    m_updateItemStatesThread(0)
+    m_model(nullptr),
+    m_dirVerificationTimer(nullptr),
+    m_plugin(nullptr),
+    m_updateItemStatesThread(nullptr)
 {
     // The verification timer specifies the timeout until the shown directory
     // is checked whether it is versioned. Per default it is assumed that users
@@ -58,7 +58,7 @@ VersionControlObserver::~VersionControlObserver()
 {
     if (m_plugin) {
         m_plugin->disconnect(this);
-        m_plugin = 0;
+        m_plugin = nullptr;
     }
 }
 
@@ -163,7 +163,7 @@ void VersionControlObserver::verifyDirectory()
 void VersionControlObserver::slotThreadFinished()
 {
     UpdateItemStatesThread* thread = m_updateItemStatesThread;
-    m_updateItemStatesThread = 0; // The thread deletes itself automatically (see updateItemStates())
+    m_updateItemStatesThread = nullptr; // The thread deletes itself automatically (see updateItemStates())
 
     if (!m_plugin || !thread) {
         return;
@@ -266,7 +266,7 @@ KVersionControlPlugin* VersionControlObserver::searchPlugin(const QUrl& director
     if (!pluginsAvailable) {
         // A searching for plugins has already been done, but no
         // plugins are installed
-        return 0;
+        return nullptr;
     }
 
     if (plugins.isEmpty()) {
@@ -285,13 +285,13 @@ KVersionControlPlugin* VersionControlObserver::searchPlugin(const QUrl& director
         }
         if (plugins.isEmpty()) {
             pluginsAvailable = false;
-            return 0;
+            return nullptr;
         }
     }
 
     // We use the number of upUrl() calls to find the best matching plugin
     // for the given directory. The smaller value, the better it is (0 is best).
-    KVersionControlPlugin* bestPlugin = 0;
+    KVersionControlPlugin* bestPlugin = nullptr;
     int bestScore = INT_MAX;
 
     // Verify whether the current directory contains revision information
index c817c21879c3dd38bbdb733302560f2ce4fa6eb9..2c2fe2940c3ebf793f33be689ef18ad08dde9f6d 100644 (file)
@@ -50,8 +50,8 @@ class DOLPHIN_EXPORT VersionControlObserver : public QObject
     Q_OBJECT
 
 public:
-    explicit VersionControlObserver(QObject* parent = 0);
-    virtual ~VersionControlObserver();
+    explicit VersionControlObserver(QObject* parent = nullptr);
+    ~VersionControlObserver() override;
 
     void setModel(KFileItemModel* model);
     KFileItemModel* model() const;
index 4b1ff2083e7335960b8a307ad33e5b446119872d..6fa43c38b1cc69d1ac4c0b91e6c09501e261acb6 100644 (file)
@@ -38,8 +38,8 @@ class DOLPHIN_EXPORT ViewModeController : public QObject
     Q_OBJECT
 
 public:
-    explicit ViewModeController(QObject* parent = 0);
-    virtual ~ViewModeController();
+    explicit ViewModeController(QObject* parent = nullptr);
+    ~ViewModeController() override;
 
     /**
      * @return URL that is shown by the view mode implementation.
index ca52be8907cee97063f2f0ec655b052b348221aa..e2be188198b57e2fb94aa511f10a4aba6d4e4487 100644 (file)
@@ -50,7 +50,7 @@ namespace {
 ViewProperties::ViewProperties(const QUrl& url) :
     m_changedProps(false),
     m_autoSave(true),
-    m_node(0)
+    m_node(nullptr)
 {
     GeneralSettings* settings = GeneralSettings::self();
     const bool useGlobalViewProps = settings->globalViewProps() || url.isEmpty();
@@ -140,7 +140,7 @@ ViewProperties::~ViewProperties()
     }
 
     delete m_node;
-    m_node = 0;
+    m_node = nullptr;
 }
 
 void ViewProperties::setViewMode(DolphinView::Mode mode)