]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Simplify DolphinController: don't remember the show-preview state in the controller...
authorPeter Penz <peter.penz19@gmail.com>
Fri, 26 Oct 2007 19:02:33 +0000 (19:02 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Fri, 26 Oct 2007 19:02:33 +0000 (19:02 +0000)
svn path=/trunk/KDE/kdebase/apps/; revision=729726

src/dolphincolumnview.cpp
src/dolphincolumnview.h
src/dolphincolumnwidget.cpp
src/dolphincontroller.cpp
src/dolphincontroller.h
src/dolphiniconsview.cpp
src/dolphiniconsview.h
src/dolphinview.cpp
src/dolphinview.h

index 7f6b37830ade1f8a3a1de3b58ede98b222b5f8cf..f69dc207ee7d1aba4f6b9f875388eefd57cbbd1e 100644 (file)
@@ -66,13 +66,15 @@ DolphinColumnView::DolphinColumnView(QWidget* parent, DolphinController* control
             this, SLOT(zoomIn()));
     connect(controller, SIGNAL(zoomOut()),
             this, SLOT(zoomOut()));
-    connect(controller->dolphinView(), SIGNAL(showHiddenFilesChanged()),
-            this, SLOT(slotShowHiddenFilesChanged()));
-    connect(controller, SIGNAL(showPreviewChanged(bool)),
-            this, SLOT(slotShowPreviewChanged(bool)));
     connect(controller, SIGNAL(activationChanged(bool)),
             this, SLOT(updateColumnsBackground(bool)));
 
+    const DolphinView* view = controller->dolphinView();
+    connect(view, SIGNAL(showHiddenFilesChanged()),
+            this, SLOT(slotShowHiddenFilesChanged()));
+    connect(view, SIGNAL(showPreviewChanged()),
+            this, SLOT(slotShowPreviewChanged()));
+
     connect(horizontalScrollBar(), SIGNAL(valueChanged(int)),
             this, SLOT(moveContentHorizontally(int)));
 
@@ -417,8 +419,9 @@ void DolphinColumnView::slotShowHiddenFilesChanged()
     }
 }
 
-void DolphinColumnView::slotShowPreviewChanged(bool show)
+void DolphinColumnView::slotShowPreviewChanged()
 {
+    const bool show = m_controller->dolphinView()->showPreview();
     foreach (DolphinColumnWidget* column, m_columns) {
         column->setShowPreview(show);
     }
index 1c972ad39f1e26b764db43f1d79fea3099e64fe2..af393ce8185273048367e74f30bef47522140350 100644 (file)
@@ -129,7 +129,7 @@ private slots:
     void updateColumnsBackground(bool active);
 
     void slotShowHiddenFilesChanged();
-    void slotShowPreviewChanged(bool show);
+    void slotShowPreviewChanged();
 
 private:
     bool isZoomInPossible() const;
index c24ae50c20f65404505ca14b634d244d24f97575..c212e6ad82ec2778733739bc62ca7dfa1a264f4f 100644 (file)
@@ -336,7 +336,7 @@ void DolphinColumnWidget::generatePreviews(const KFileItemList& items)
     // TODO: same implementation as in DolphinView; create helper class
     // for generatePreviews(), showPreview() and isCutItem()
 
-    if (m_view->m_controller->showPreview()) {
+    if (m_view->m_controller->dolphinView()->showPreview()) {
         KIO::PreviewJob* job = KIO::filePreview(items, 128);
         connect(job, SIGNAL(gotPreview(const KFileItem&, const QPixmap&)),
                 this, SLOT(showPreview(const KFileItem&, const QPixmap&)));
index bdb97170b4e2c1c3567369f26131b1f181e5290a..897d4266bc8b2eca039b594c8818de735cba9f57 100644 (file)
@@ -23,7 +23,6 @@
 
 DolphinController::DolphinController(DolphinView* dolphinView) :
     QObject(dolphinView),
-    m_showPreview(false),
     m_zoomInPossible(false),
     m_zoomOutPossible(false),
     m_url(),
@@ -85,14 +84,6 @@ void DolphinController::indicateAdditionalInfoChange(const KFileItemDelegate::In
     emit additionalInfoChanged(info);
 }
 
-void DolphinController::setShowPreview(bool show)
-{
-    if (m_showPreview != show) {
-        m_showPreview = show;
-        emit showPreviewChanged(show);
-    }
-}
-
 void DolphinController::indicateActivationChange(bool active)
 {
     emit activationChanged(active);
index d1b0799bfdaa1961fcae986542723fef18ba2053..c5f0e1a2bedfa27739b253d2b8ff800cac825ee5 100644 (file)
@@ -159,14 +159,6 @@ public:
      */
     void indicateAdditionalInfoChange(const KFileItemDelegate::InformationList& info);
 
-    /**
-     * Informs the view implementation about a change of the show preview
-     * state and is invoked by the abstract Dolphin view.
-     * The signal showPreviewChanged() is emitted.
-     */
-    void setShowPreview(bool show);
-    bool showPreview() const;
-
     /**
      * Informs the view implementation about a change of the activation
      * state and is invoked by the abstract Dolphin view. The signal
@@ -290,14 +282,6 @@ signals:
      */
     void additionalInfoChanged(const KFileItemDelegate::InformationList& info);
 
-    /**
-     * Is emitted if the state for showing previews has been
-     * changed to \a show by the abstract Dolphin view.
-     * The view implementation might connect to this signal if custom
-     * updates are required in this case.
-     */
-    void showPreviewChanged(bool show);
-
     /**
      * Is emitted if the activation state has been changed to \a active
      * by the abstract Dolphin view.
@@ -341,7 +325,6 @@ signals:
     void zoomOut();
 
 private:
-    bool m_showPreview;
     bool m_zoomInPossible;
     bool m_zoomOutPossible;
     KUrl m_url;
@@ -358,11 +341,6 @@ inline const KUrl& DolphinController::url() const
     return m_url;
 }
 
-inline bool DolphinController::showPreview() const
-{
-    return m_showPreview;
-}
-
 inline void DolphinController::setZoomInPossible(bool possible)
 {
     m_zoomInPossible = possible;
index 5107d56979d9c4831d3c1217ea8e44eee6d778b6..30e47da899fc3be77dc2438977bd5f5a39f758a8 100644 (file)
@@ -61,15 +61,17 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
     }
     connect(this, SIGNAL(viewportEntered()),
             controller, SLOT(emitViewportEntered()));
-    connect(controller, SIGNAL(showPreviewChanged(bool)),
-            this, SLOT(slotShowPreviewChanged(bool)));
-    connect(controller->dolphinView(), SIGNAL(additionalInfoChanged(const KFileItemDelegate::InformationList&)),
-            this, SLOT(slotAdditionalInfoChanged(const KFileItemDelegate::InformationList&)));
     connect(controller, SIGNAL(zoomIn()),
             this, SLOT(zoomIn()));
     connect(controller, SIGNAL(zoomOut()),
             this, SLOT(zoomOut()));
 
+    const DolphinView* view = controller->dolphinView();
+    connect(view, SIGNAL(showPreviewChanged()),
+            this, SLOT(slotShowPreviewChanged()));
+    connect(view, SIGNAL(additionalInfoChanged(const KFileItemDelegate::InformationList&)),
+            this, SLOT(slotAdditionalInfoChanged(const KFileItemDelegate::InformationList&)));
+
     connect(this, SIGNAL(entered(const QModelIndex&)),
             this, SLOT(slotEntered(const QModelIndex&)));
 
@@ -86,7 +88,7 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
     m_viewOptions.font = font;
 
     setWordWrap(settings->numberOfTextlines() > 1);
-    updateGridSize(controller->showPreview(), 0);
+    updateGridSize(view->showPreview(), 0);
 
     if (settings->arrangement() == QListView::TopToBottom) {
         setFlow(QListView::LeftToRight);
@@ -246,15 +248,17 @@ void DolphinIconsView::slotEntered(const QModelIndex& index)
     m_controller->emitItemEntered(itemForIndex(index));
 }
 
-void DolphinIconsView::slotShowPreviewChanged(bool showPreview)
+void DolphinIconsView::slotShowPreviewChanged()
 {
-    const int infoCount = m_controller->dolphinView()->additionalInfo().count();
-    updateGridSize(showPreview, infoCount);
+    const DolphinView* view = m_controller->dolphinView();
+    const int infoCount = view->additionalInfo().count();
+    updateGridSize(view->showPreview(), infoCount);
 }
 
 void DolphinIconsView::slotAdditionalInfoChanged(const KFileItemDelegate::InformationList& info)
 {
-    updateGridSize(m_controller->showPreview(), info.count());
+    const bool showPreview = m_controller->dolphinView()->showPreview();
+    updateGridSize(showPreview, info.count());
 }
 
 void DolphinIconsView::zoomIn()
@@ -265,7 +269,7 @@ void DolphinIconsView::zoomIn()
         const int oldIconSize = settings->iconSize();
         int newIconSize = oldIconSize;
 
-        const bool showPreview = m_controller->showPreview();
+        const bool showPreview = m_controller->dolphinView()->showPreview();
         if (showPreview) {
             const int previewSize = increasedIconSize(settings->previewSize());
             settings->setPreviewSize(previewSize);
@@ -296,7 +300,7 @@ void DolphinIconsView::zoomOut()
         const int oldIconSize = settings->iconSize();
         int newIconSize = oldIconSize;
 
-        const bool showPreview = m_controller->showPreview();
+        const bool showPreview = m_controller->dolphinView()->showPreview();
         if (showPreview) {
             const int previewSize = decreasedIconSize(settings->previewSize());
             settings->setPreviewSize(previewSize);
@@ -323,14 +327,16 @@ void DolphinIconsView::zoomOut()
 bool DolphinIconsView::isZoomInPossible() const
 {
     IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
-    const int size = m_controller->showPreview() ? settings->previewSize() : settings->iconSize();
+    const bool showPreview = m_controller->dolphinView()->showPreview();
+    const int size = showPreview ? settings->previewSize() : settings->iconSize();
     return size < KIconLoader::SizeEnormous;
 }
 
 bool DolphinIconsView::isZoomOutPossible() const
 {
     IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
-    const int size = m_controller->showPreview() ? settings->previewSize() : settings->iconSize();
+    const bool showPreview = m_controller->dolphinView()->showPreview();
+    const int size = showPreview ? settings->previewSize() : settings->iconSize();
     return size > KIconLoader::SizeSmall;
 }
 
index 2b7d00bf00e71278695c8b21225dff993dea63cb..ae0a6299dfbb6d7e9928b792e10b70247d7dbb12 100644 (file)
@@ -64,7 +64,7 @@ protected:
 private slots:
     void triggerItem(const QModelIndex& index);
     void slotEntered(const QModelIndex& index);
-    void slotShowPreviewChanged(bool show);
+    void slotShowPreviewChanged();
     void slotAdditionalInfoChanged(const KFileItemDelegate::InformationList& info);
     void zoomIn();
     void zoomOut();
index c44afb21999613181b5668e6279fb828dc6150b3..c280b40d0f8f972f2c08c7c323ee41fe6f0dd2e6 100644 (file)
@@ -61,6 +61,7 @@ DolphinView::DolphinView(QWidget* parent,
                          DolphinSortFilterProxyModel* proxyModel) :
     QWidget(parent),
     m_active(true),
+    m_showPreview(false),
     m_loadingDirectory(false),
     m_storedCategorizedSorting(false),
     m_mode(DolphinView::IconsView),
@@ -227,11 +228,16 @@ DolphinView::Mode DolphinView::mode() const
 
 void DolphinView::setShowPreview(bool show)
 {
+    if (m_showPreview == show) {
+        return;
+    }
+
     const KUrl viewPropsUrl = viewPropertiesUrl();
     ViewProperties props(viewPropsUrl);
     props.setShowPreview(show);
 
-    m_controller->setShowPreview(show);
+    m_showPreview = show;
+
     emit showPreviewChanged();
 
     loadDirectory(viewPropsUrl, true);
@@ -239,7 +245,7 @@ void DolphinView::setShowPreview(bool show)
 
 bool DolphinView::showPreview() const
 {
-    return m_controller->showPreview();
+    return m_showPreview;
 }
 
 void DolphinView::setShowHiddenFiles(bool show)
@@ -556,7 +562,7 @@ void DolphinView::triggerItem(const KFileItem& item)
 
 void DolphinView::generatePreviews(const KFileItemList& items)
 {
-    if (m_controller->showPreview()) {
+    if (m_controller->dolphinView()->showPreview()) {
         KIO::PreviewJob* job = KIO::filePreview(items, 128);
         connect(job, SIGNAL(gotPreview(const KFileItem&, const QPixmap&)),
                 this, SLOT(showPreview(const KFileItem&, const QPixmap&)));
@@ -683,8 +689,8 @@ void DolphinView::applyViewProperties(const KUrl& url)
     }
 
     const bool showPreview = props.showPreview();
-    if (showPreview != m_controller->showPreview()) {
-        m_controller->setShowPreview(showPreview);
+    if (showPreview != m_showPreview) {
+        m_showPreview = showPreview;
         emit showPreviewChanged();
     }
 }
index 9b56e85a8e1c927ad6f8591b608414d0d8d0f22a..442ff5a60751944db3552a4f347b55b6d6e19cb4 100644 (file)
@@ -605,6 +605,7 @@ private:
     };
 
     bool m_active;
+    bool m_showPreview;
     bool m_loadingDirectory;
     bool m_storedCategorizedSorting;
     Mode m_mode;