]> cloud.milkyroute.net Git - dolphin.git/commitdiff
layout improvements in the icons view:
authorPeter Penz <peter.penz19@gmail.com>
Thu, 10 May 2007 20:29:10 +0000 (20:29 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Thu, 10 May 2007 20:29:10 +0000 (20:29 +0000)
* do a text wrapping if the number of lines is > 1 (TODO: bugfix of KFileItemDelegate necessary, currently the text might overlap with the icon)
* increase the height for the text area if an additional information like type, date, ... is shown

svn path=/trunk/KDE/kdebase/apps/; revision=663320

src/dolphin_iconsmodesettings.kcfg
src/dolphincontroller.cpp
src/dolphincontroller.h
src/dolphiniconsview.cpp
src/dolphiniconsview.h
src/dolphinview.cpp
src/iconsviewsettingspage.cpp

index 4915ef58b78aab48496fc262a05f280c93605ffe..45d40d5e95161c69b6443481125c72ff6cf7f9ed 100644 (file)
@@ -28,7 +28,7 @@
         </entry>
        <entry name="GridHeight" type="Int">
             <label>Grid height</label>
-            <default code="true">K3Icon::SizeMedium + (KGlobalSettings::generalFont().pointSize() * 6)</default>
+            <default code="true">K3Icon::SizeMedium + (KGlobalSettings::generalFont().pointSize() * 3)</default>
         </entry>
         <entry name="GridWidth" type="Int">
             <label>Grid width</label>
@@ -44,7 +44,7 @@
         </entry>
         <entry name="NumberOfTextlines" type="Int">
             <label>Number of textlines</label>
-            <default>2</default>
+            <default>1</default>
         </entry>
         <entry name="Preview" type="Bool">
             <label>Show preview</label>
index 545d365bdee28760af25654ddec6d43e22b73bf4..762526b3ce2149009f2143d4ae3b846da374c32b 100644 (file)
@@ -22,6 +22,7 @@
 DolphinController::DolphinController(QObject* parent) :
     QObject(parent),
     m_showPreview(false),
+    m_showAdditionalInfo(false),
     m_zoomInPossible(false),
     m_zoomOutPossible(false)
 {
@@ -60,11 +61,19 @@ void DolphinController::indicateSortOrderChange(Qt::SortOrder order)
     emit sortOrderChanged(order);
 }
 
-void DolphinController::setShowPreview(bool showPreview)
+void DolphinController::setShowPreview(bool show)
 {
-    if (m_showPreview != showPreview) {
-        m_showPreview = showPreview;
-        emit showPreviewChanged(showPreview);
+    if (m_showPreview != show) {
+        m_showPreview = show;
+        emit showPreviewChanged(show);
+    }
+}
+
+void DolphinController::setShowAdditionalInfo(bool show)
+{
+    if (m_showAdditionalInfo != show) {
+        m_showAdditionalInfo = show;
+        emit showAdditionalInfoChanged(show);
     }
 }
 
index b975558e239acd2b7bd22daba88a44000b5b66f2..b9431f3a79b86b71526b2ded5b7a21699f38ed51 100644 (file)
@@ -54,14 +54,8 @@ public:
     explicit DolphinController(QObject* parent);
     virtual ~DolphinController();
 
-    void setUrl(const KUrl& url)
-    {
-        m_url = url;
-    }
-    const KUrl& url() const
-    {
-        return m_url;
-    }
+    inline void setUrl(const KUrl& url);
+    inline const KUrl& url() const;
 
     void triggerContextMenuRequest(const QPoint& pos);
 
@@ -75,31 +69,19 @@ public:
 
     void indicateSortOrderChange(Qt::SortOrder order);
 
-    void setShowPreview(bool showPreview);
-    bool showPreview() const
-    {
-        return m_showPreview;
-    }
+    void setShowPreview(bool show);
+    inline bool showPreview() const;
+
+    void setShowAdditionalInfo(bool show);
+    inline bool showAdditionalInfo() const;
 
     void triggerZoomIn();
-    void setZoomInPossible(bool possible)
-    {
-        m_zoomInPossible = possible;
-    }
-    bool isZoomInPossible() const
-    {
-        return m_zoomInPossible;
-    }
+    inline void setZoomInPossible(bool possible);
+    inline bool isZoomInPossible() const;
 
     void triggerZoomOut();
-    void setZoomOutPossible(bool possible)
-    {
-        m_zoomOutPossible = possible;
-    }
-    bool isZoomOutPossible() const
-    {
-        return m_zoomOutPossible;
-    }
+    inline void setZoomOutPossible(bool possible);
+    inline bool isZoomOutPossible() const;
 
 public slots:
     void triggerItem(const QModelIndex& index);
@@ -137,9 +119,15 @@ signals:
 
     /**
      * Is emitted if the state for showing previews has been
-     * changed to \a showPreview.
+     * changed to \a show.
      */
-    void showPreviewChanged(bool showPreview);
+    void showPreviewChanged(bool show);
+
+    /**
+     * Is emitted if the state for showing additional info has been
+     * changed to \a show.
+     */
+    void showAdditionalInfoChanged(bool show);
 
     /**
      * Is emitted if the item with the index \a index should be triggered.
@@ -159,9 +147,50 @@ signals:
 
 private:
     bool m_showPreview;
+    bool m_showAdditionalInfo;
     bool m_zoomInPossible;
     bool m_zoomOutPossible;
     KUrl m_url;
 };
 
+void DolphinController::setUrl(const KUrl& url)
+{
+    m_url = url;
+}
+
+const KUrl& DolphinController::url() const
+{
+    return m_url;
+}
+
+bool DolphinController::showPreview() const
+{
+    return m_showPreview;
+}
+
+bool DolphinController::showAdditionalInfo() const
+{
+    return m_showAdditionalInfo;
+}
+
+void DolphinController::setZoomInPossible(bool possible)
+{
+    m_zoomInPossible = possible;
+}
+
+bool DolphinController::isZoomInPossible() const
+{
+    return m_zoomInPossible;
+}
+
+void DolphinController::setZoomOutPossible(bool possible)
+{
+    m_zoomOutPossible = possible;
+}
+
+bool DolphinController::isZoomOutPossible() const
+{
+    return m_zoomOutPossible;
+}
+
 #endif
index 25a8581f4d8b2ddd793b9b4e18bddc9e85ba7f00..c2262c1bcb295648f154e40108206762c1dc51bd 100644 (file)
@@ -52,7 +52,9 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
     connect(this, SIGNAL(activated(const QModelIndex&)),
             controller, SLOT(triggerItem(const QModelIndex&)));
     connect(controller, SIGNAL(showPreviewChanged(bool)),
-            this, SLOT(updateGridSize(bool)));
+            this, SLOT(slotShowPreviewChanged(bool)));
+    connect(controller, SIGNAL(showAdditionalInfoChanged(bool)),
+            this, SLOT(slotShowAdditionalInfoChanged(bool)));
     connect(controller, SIGNAL(zoomIn()),
             this, SLOT(zoomIn()));
     connect(controller, SIGNAL(zoomOut()),
@@ -69,8 +71,12 @@ DolphinIconsView::DolphinIconsView(QWidget* parent, DolphinController* controlle
     font.setItalic(settings->italicFont());
     font.setBold(settings->boldFont());
     m_viewOptions.font = font;
+    if (settings->numberOfTextlines() > 1) {
+        m_viewOptions.textElideMode = Qt::ElideNone;
+        m_viewOptions.features = QStyleOptionViewItemV2::WrapText;
+    }
 
-    updateGridSize(controller->showPreview());
+    updateGridSize(controller->showPreview(), controller->showAdditionalInfo());
 
     if (settings->arrangement() == QListView::TopToBottom) {
         setFlow(QListView::LeftToRight);
@@ -121,30 +127,14 @@ void DolphinIconsView::dropEvent(QDropEvent* event)
     KListView::dropEvent(event);
 }
 
-void DolphinIconsView::updateGridSize(bool showPreview)
+void DolphinIconsView::slotShowPreviewChanged(bool showPreview)
 {
-    const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
-    Q_ASSERT(settings != 0);
-
-    int gridWidth = settings->gridWidth();
-    int gridHeight = settings->gridHeight();
-    int size = settings->iconSize();
-
-    if (showPreview) {
-        const int previewSize = settings->previewSize();
-        const int diff = previewSize - size;
-        Q_ASSERT(diff >= 0);
-        gridWidth  += diff;
-        gridHeight += diff;
-
-        size = previewSize;
-    }
-
-    m_viewOptions.decorationSize = QSize(size, size);
-    setGridSize(QSize(gridWidth, gridHeight));
+    updateGridSize(showPreview, m_controller->showAdditionalInfo());
+}
 
-    m_controller->setZoomInPossible(isZoomInPossible());
-    m_controller->setZoomOutPossible(isZoomOutPossible());
+void DolphinIconsView::slotShowAdditionalInfoChanged(bool showAdditionalInfo)
+{
+    updateGridSize(m_controller->showPreview(), showAdditionalInfo);
 }
 
 void DolphinIconsView::zoomIn()
@@ -173,7 +163,7 @@ void DolphinIconsView::zoomIn()
         settings->setGridWidth(settings->gridWidth() + diff);
         settings->setGridHeight(settings->gridHeight() + diff);
 
-        updateGridSize(showPreview);
+        updateGridSize(showPreview, m_controller->showAdditionalInfo());
     }
 }
 
@@ -204,7 +194,7 @@ void DolphinIconsView::zoomOut()
         settings->setGridWidth(settings->gridWidth() - diff);
         settings->setGridHeight(settings->gridHeight() - diff);
 
-        updateGridSize(showPreview);
+        updateGridSize(showPreview, m_controller->showAdditionalInfo());
     }
 }
 
@@ -252,4 +242,34 @@ int DolphinIconsView::decreasedIconSize(int size) const
     return decSize;
 }
 
+void DolphinIconsView::updateGridSize(bool showPreview, bool showAdditionalInfo)
+{
+    const IconsModeSettings* settings = DolphinSettings::instance().iconsModeSettings();
+    Q_ASSERT(settings != 0);
+
+    int gridWidth = settings->gridWidth();
+    int gridHeight = settings->gridHeight();
+    int size = settings->iconSize();
+
+    if (showPreview) {
+        const int previewSize = settings->previewSize();
+        const int diff = previewSize - size;
+        Q_ASSERT(diff >= 0);
+        gridWidth  += diff;
+        gridHeight += diff;
+
+        size = previewSize;
+    }
+
+    if (showAdditionalInfo) {
+        gridHeight += m_viewOptions.font.pointSize() * 2;
+    }
+
+    m_viewOptions.decorationSize = QSize(size, size);
+    setGridSize(QSize(gridWidth, gridHeight));
+
+    m_controller->setZoomInPossible(isZoomInPossible());
+    m_controller->setZoomOutPossible(isZoomOutPossible());
+}
+
 #include "dolphiniconsview.moc"
index fce8f62bd4a5ce23fbdb9afd8b7202543efce5b1..212ed3e787cdd8613a29b056f6b658dc517860d8 100644 (file)
@@ -51,12 +51,8 @@ protected:
     virtual void dropEvent(QDropEvent* event);
 
 private slots:
-    /**
-     * Updates the size of the grid
-     * depending on the state of \a showPreview.
-     */
-    void updateGridSize(bool showPreview);
-
+    void slotShowPreviewChanged(bool show);
+    void slotShowAdditionalInfoChanged(bool show);
     void zoomIn();
     void zoomOut();
 
@@ -70,9 +66,15 @@ private:
     /** Returns the decreased icon size for the size \a size. */
     int decreasedIconSize(int size) const;
 
+    /**
+     * Updates the size of the grid depending on the state
+     * of \a showPreview and \a showAdditionalInfo.
+     */
+    void updateGridSize(bool showPreview, bool showAdditionalInfo);
+
 private:
     DolphinController* m_controller;
-    QStyleOptionViewItem m_viewOptions;
+    QStyleOptionViewItemV2 m_viewOptions;
 };
 
 #endif
index 84b765d4d8ecb307f0c3e474bbad332a0f9b9426..4188959f1e3e9dbc7a3f7715bea97e676755a210 100644 (file)
@@ -460,6 +460,7 @@ void DolphinView::setAdditionalInfo(KFileItemDelegate::AdditionalInformation inf
     ViewProperties props(m_urlNavigator->url());
     props.setAdditionalInfo(info);
 
+    m_controller->setShowAdditionalInfo(info != KFileItemDelegate::NoInformation);
     m_fileItemDelegate->setAdditionalInformation(info);
 
     emit additionalInfoChanged(info);
@@ -701,8 +702,8 @@ void DolphinView::changeDirectory(const KUrl& url)
 
     KFileItemDelegate::AdditionalInformation info = props.additionalInfo();
     if (info != m_fileItemDelegate->additionalInformation()) {
+        m_controller->setShowAdditionalInfo(info != KFileItemDelegate::NoInformation);
         m_fileItemDelegate->setAdditionalInformation(info);
-
         emit additionalInfoChanged(info);
     }
 
index 3bba6f12fc45aa177e4016a265400eb206109d08..2cd56043f624183051d25e6bf18d7e74c36130e6 100644 (file)
@@ -161,13 +161,15 @@ void IconsViewSettingsPage::applySettings()
                             QListView::TopToBottom;
     settings->setArrangement(arrangement);
 
+    const int numberOfTextlines = m_textlinesCountBox->value();
+
     const int defaultSize = settings->iconSize();
     int gridWidth = defaultSize;
     int gridHeight = defaultSize;
     const int textSizeIndex = m_textWidthBox->currentIndex();
     if (arrangement == QListView::TopToBottom) {
         gridWidth += TopToBottomBase + textSizeIndex * TopToBottomInc;
-        gridHeight += fontSize * 6;
+        gridHeight += fontSize * (2 + numberOfTextlines);
     } else {
         gridWidth += LeftToRightBase + textSizeIndex * LeftToRightInc;
     }
@@ -180,7 +182,7 @@ void IconsViewSettingsPage::applySettings()
     settings->setItalicFont(font.italic());
     settings->setBoldFont(font.bold());
 
-    settings->setNumberOfTextlines(m_textlinesCountBox->value());
+    settings->setNumberOfTextlines(numberOfTextlines);
 
     settings->setGridSpacing(GridSpacingBase +
                              m_gridSpacingBox->currentIndex() * GridSpacingInc);