]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Minor API-cleanups for DolphinView
authorPeter Penz <peter.penz19@gmail.com>
Wed, 11 Apr 2012 14:42:46 +0000 (16:42 +0200)
committerPeter Penz <peter.penz19@gmail.com>
Wed, 11 Apr 2012 14:43:11 +0000 (16:43 +0200)
src/dolphinmainwindow.cpp
src/dolphinpart.cpp
src/dolphinviewcontainer.cpp
src/dolphinviewcontainer.h
src/views/dolphinview.cpp
src/views/dolphinview.h

index 22d8af3c3b286953936ea5bd5d1ac6588c6950df..9b2a1cea85f15d4b3aa88d02b7c341c9be723190 100644 (file)
@@ -2088,9 +2088,9 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container)
             this, SLOT(openNewTab(KUrl)));
     connect(view, SIGNAL(requestContextMenu(QPoint,KFileItem,KUrl,QList<QAction*>)),
             this, SLOT(openContextMenu(QPoint,KFileItem,KUrl,QList<QAction*>)));
-    connect(view, SIGNAL(startedDirLoading(KUrl)),
+    connect(view, SIGNAL(dirLoadingStarted()),
             this, SLOT(enableStopAction()));
-    connect(view, SIGNAL(finishedDirLoading(KUrl)),
+    connect(view, SIGNAL(dirLoadingCompleted()),
             this, SLOT(disableStopAction()));
     connect(view, SIGNAL(goBackRequested()),
             this, SLOT(goBack()));
index bb944bad0bd77047faf395bf422b152cea8ee2bd..4f89709d3bbf603892571c89e49acc7adabffd6e 100644 (file)
@@ -477,7 +477,7 @@ void DolphinPart::openSelectionDialog(const QString& title, const QString& text,
 
     if (okClicked && !pattern.isEmpty()) {
         QRegExp patternRegExp(pattern, Qt::CaseSensitive, QRegExp::Wildcard);
-        m_view->setItemSelectionEnabled(patternRegExp, selectItems);
+        m_view->selectItems(patternRegExp, selectItems);
     }
 }
 
@@ -608,7 +608,7 @@ DolphinPart* DolphinPartFileInfoExtension::part() const
 
 bool DolphinPartFileInfoExtension::hasSelection() const
 {
-    return part()->view()->hasSelection();
+    return part()->view()->selectedItemsCount() > 0;
 }
 
 KParts::FileInfoExtension::QueryModes DolphinPartFileInfoExtension::supportedQueryModes() const
index a6049992f7868c61f8f89991e2eebf53b6cfb5a3..7b9152d1e54434af7223908562d36232f5877921 100644 (file)
@@ -99,8 +99,8 @@ DolphinViewContainer::DolphinViewContainer(const KUrl& url, QWidget* parent) :
     connect(m_view, SIGNAL(infoMessage(QString)),               this, SLOT(showInfoMessage(QString)));
     connect(m_view, SIGNAL(itemActivated(KFileItem)),           this, SLOT(slotItemActivated(KFileItem)));
     connect(m_view, SIGNAL(redirection(KUrl,KUrl)),             this, SLOT(redirect(KUrl,KUrl)));
-    connect(m_view, SIGNAL(startedDirLoading(KUrl)),            this, SLOT(slotStartedDirLoading()));
-    connect(m_view, SIGNAL(finishedDirLoading(KUrl)),           this, SLOT(slotFinishedDirLoading()));
+    connect(m_view, SIGNAL(dirLoadingStarted()),                this, SLOT(slotDirLoadingStarted()));
+    connect(m_view, SIGNAL(dirLoadingCompleted()),              this, SLOT(slotDirLoadingCompleted()));
     connect(m_view, SIGNAL(itemCountChanged()),                 this, SLOT(delayedStatusBarUpdate()));
     connect(m_view, SIGNAL(dirLoadingProgress(int)),            this, SLOT(updateDirLoadingProgress(int)));
     connect(m_view, SIGNAL(dirSortingProgress(int)),            this, SLOT(updateSortingProgress(int)));
@@ -348,7 +348,7 @@ void DolphinViewContainer::updateSortingProgress(int percent)
     m_statusBar->setProgress(percent);
 }
 
-void DolphinViewContainer::slotStartedDirLoading()
+void DolphinViewContainer::slotDirLoadingStarted()
 {
     if (isSearchUrl(url())) {
         // Search KIO-slaves usually don't provide any progress information. Give
@@ -364,7 +364,7 @@ void DolphinViewContainer::slotStartedDirLoading()
     }
 }
 
-void DolphinViewContainer::slotFinishedDirLoading()
+void DolphinViewContainer::slotDirLoadingCompleted()
 {
     if (!m_statusBar->progressText().isEmpty()) {
         m_statusBar->setProgressText(QString());
index de3bd60a64e756341a24f14dae16ec3d0fd8259d..a853671dbcd0ddbf6e052bcfb900247538a925dc 100644 (file)
@@ -162,13 +162,13 @@ private slots:
      * Updates the statusbar to show an undetermined progress with the correct
      * context information whether a searching or a directory loading is done.
      */
-    void slotStartedDirLoading();
+    void slotDirLoadingStarted();
 
     /**
      * Assures that the viewport position is restored and updates the
      * statusbar to reflect the current content.
      */
-    void slotFinishedDirLoading();
+    void slotDirLoadingCompleted();
 
     /**
      * Handles clicking on an item. If the item is a directory, the
index 137b73d0902e7b4a143fa12efd20b1caf234edc9..8171751e4b8ed8955df66da14cf8f0efe5a66125 100644 (file)
@@ -347,7 +347,7 @@ void DolphinView::markUrlAsCurrent(const KUrl& url)
     m_currentItemUrl = url;
 }
 
-void DolphinView::setItemSelectionEnabled(const QRegExp& pattern, bool enabled)
+void DolphinView::selectItems(const QRegExp& pattern, bool enabled)
 {
     const KItemListSelectionManager::SelectionMode mode = enabled
                                                         ? KItemListSelectionManager::Select
@@ -490,23 +490,6 @@ QString DolphinView::nameFilter() const
     return fileItemModel()->nameFilter();
 }
 
-void DolphinView::calculateItemCount(int& fileCount,
-                                     int& folderCount,
-                                     KIO::filesize_t& totalFileSize) const
-{
-    const KFileItemModel* model = fileItemModel();
-    const int itemCount = model->count();
-    for (int i = 0; i < itemCount; ++i) {
-        const KFileItem item = model->fileItem(i);
-        if (item.isDir()) {
-            ++folderCount;
-        } else {
-            ++fileCount;
-            totalFileSize += item.size();
-        }
-    }
-}
-
 QString DolphinView::statusBarText() const
 {
     QString summary;
@@ -517,7 +500,7 @@ QString DolphinView::statusBarText() const
     int fileCount = 0;
     KIO::filesize_t totalFileSize = 0;
 
-    if (hasSelection()) {
+    if (m_container->controller()->selectionManager()->hasSelection()) {
         // Give a summary of the status of the selected files
         const KFileItemList list = selectedItems();
         foreach (const KFileItem& item, list) {
@@ -1120,11 +1103,6 @@ void DolphinView::saveState(QDataStream& stream)
     stream << fileItemModel()->expandedUrls();
 }
 
-bool DolphinView::hasSelection() const
-{
-    return m_container->controller()->selectionManager()->hasSelection();
-}
-
 KFileItem DolphinView::rootItem() const
 {
     return fileItemModel()->rootItem();
@@ -1209,6 +1187,23 @@ void DolphinView::hideToolTip()
     }
 }
 
+void DolphinView::calculateItemCount(int& fileCount,
+                                     int& folderCount,
+                                     KIO::filesize_t& totalFileSize) const
+{
+    const KFileItemModel* model = fileItemModel();
+    const int itemCount = model->count();
+    for (int i = 0; i < itemCount; ++i) {
+        const KFileItem item = model->fileItem(i);
+        if (item.isDir()) {
+            ++folderCount;
+        } else {
+            ++fileCount;
+            totalFileSize += item.size();
+        }
+    }
+}
+
 void DolphinView::showHoverInformation(const KFileItem& item)
 {
     emit requestItemInfo(item);
@@ -1237,16 +1232,16 @@ void DolphinView::slotDirLoadingStarted()
         emit writeStateChanged(m_isFolderWritable);
     }
 
-    emit startedDirLoading(url());
+    emit dirLoadingStarted();
 }
 
 void DolphinView::slotDirLoadingCompleted()
 {
-    // Update the view-state. This has to be done using a Qt::QueuedConnection
+    // Update the view-state. This has to be done asynchronously
     // because the view might not be in its final state yet.
     QTimer::singleShot(0, this, SLOT(updateViewState()));
 
-    emit finishedDirLoading(url());
+    emit dirLoadingCompleted();
 
     updateWritableState();
 }
index 9c674d03a540038bfa6b2f310f6b74e43b7af40f..b181ea3abfa0371cbb3a379effe54732f5f31df7 100644 (file)
@@ -189,7 +189,7 @@ public:
      * All items that match to the pattern \a pattern will get selected
      * if \a enabled is true and deselected if  \a enabled is false.
      */
-    void setItemSelectionEnabled(const QRegExp& pattern, bool enabled);
+    void selectItems(const QRegExp& pattern, bool enabled);
 
     /**
      * Sets the zoom level to \a level. It is assured that the used
@@ -199,18 +199,6 @@ public:
     void setZoomLevel(int level);
     int zoomLevel() const;
 
-    /**
-     * Returns true, if zooming in is possible. If false is returned,
-     * the maximum zooming level has been reached.
-     */
-    bool isZoomInPossible() const;
-
-    /**
-     * Returns true, if zooming out is possible. If false is returned,
-     * the minimum zooming level has been reached.
-     */
-    bool isZoomOutPossible() const;
-
     void setSortRole(const QByteArray& role);
     QByteArray sortRole() const;
 
@@ -227,9 +215,7 @@ public:
     /** Returns the additional information which should be shown for the items. */
     QList<QByteArray> visibleRoles() const;
 
-    /** Reloads the current directory. */
     void reload();
-
     void stopLoading();
 
     /**
@@ -250,16 +236,6 @@ public:
     void setNameFilter(const QString& nameFilter);
     QString nameFilter() const;
 
-    /**
-     * Calculates the number of currently shown files into
-     * \a fileCount and the number of folders into \a folderCount.
-     * The size of all files is written into \a totalFileSize.
-     * It is recommend using this method instead of asking the
-     * directory lister or the model directly, as it takes
-     * filtering and hierarchical previews into account.
-     */
-    void calculateItemCount(int& fileCount, int& folderCount, KIO::filesize_t& totalFileSize) const;
-
     /**
      * Returns a textual representation of the state of the current
      * folder or selected items, suitable for use in the status bar.
@@ -304,9 +280,6 @@ public:
      */
     void saveState(QDataStream& stream);
 
-    /** Returns true, if at least one item is selected. */
-    bool hasSelection() const;
-
     /**
      * Returns the root item which represents the current URL.
      */
@@ -479,17 +452,17 @@ signals:
 
     /**
      * Is emitted after DolphinView::setUrl() has been invoked and
-     * the directory \a url is currently loaded. If this signal is emitted,
+     * the current directory is loaded. If this signal is emitted,
      * it is assured that the view contains already the correct root
      * URL and property settings.
      */
-    void startedDirLoading(const KUrl& url);
+    void dirLoadingStarted();
 
     /**
      * Is emitted after the directory triggered by DolphinView::setUrl()
      * has been loaded.
      */
-    void finishedDirLoading(const KUrl& url);
+    void dirLoadingCompleted();
 
     /**
      * Is emitted after DolphinView::setUrl() has been invoked and provides
@@ -503,12 +476,6 @@ signals:
      */
     void dirSortingProgress(int percent);
 
-    /**
-     * Is emitted if the DolphinView::setUrl() is invoked but the URL is not
-     * a directory.
-     */
-    void urlIsFileError(const KUrl& file);
-
     /**
      * Emitted when the file-item-model emits redirection.
      * Testcase: fish://localhost
@@ -679,6 +646,16 @@ private slots:
 
     void hideToolTip();
 
+    /**
+     * Calculates the number of currently shown files into
+     * \a fileCount and the number of folders into \a folderCount.
+     * The size of all files is written into \a totalFileSize.
+     * It is recommend using this method instead of asking the
+     * directory lister or the model directly, as it takes
+     * filtering and hierarchical previews into account.
+     */
+    void calculateItemCount(int& fileCount, int& folderCount, KIO::filesize_t& totalFileSize) const;
+
 private:
     KFileItemModel* fileItemModel() const;