]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphindetailsview.cpp
* if the system font is changed during Dolphin is open, take care to update the used...
[dolphin.git] / src / dolphindetailsview.cpp
index df5246bedba18d9f103d6c08308d21f950fd5b6b..75481fb36a0636c35a8b07d19651c5a2f3fb8718 100644 (file)
@@ -54,17 +54,19 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr
     m_elasticBandOrigin(),
     m_elasticBandDestination()
 {
+    const DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
+    Q_ASSERT(settings != 0);
     Q_ASSERT(controller != 0);
 
     setAcceptDrops(true);
-    setRootIsDecorated(false);
     setSortingEnabled(true);
     setUniformRowHeights(true);
     setSelectionBehavior(SelectItems);
     setDragDropMode(QAbstractItemView::DragDrop);
     setDropIndicatorShown(false);
     setAlternatingRowColors(true);
-    setItemsExpandable(false);
+    setRootIsDecorated(settings->expandableFolders());
+    setItemsExpandable(settings->expandableFolders());
 
     setMouseTracking(true);
     viewport()->setAttribute(Qt::WA_Hover);
@@ -118,11 +120,14 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr
     connect(controller->dolphinView(), SIGNAL(additionalInfoChanged()),
             this, SLOT(updateColumnVisibility()));
 
-    // apply the details mode settings to the widget
-    const DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
-    Q_ASSERT(settings != 0);
-
-    m_font = QFont(settings->fontFamily(), settings->fontSize());
+    if (settings->useSystemFont()) {
+        m_font = KGlobalSettings::generalFont();
+    } else {
+        m_font = QFont(settings->fontFamily(),
+                       settings->fontSize(),
+                       settings->fontWeight(),
+                       settings->italicFont());
+    }
 
 // TODO: Remove this check when 4.3.2 is released and KDE requires it... this
 //       check avoids a division by zero happening on versions before 4.3.1.
@@ -136,6 +141,9 @@ DolphinDetailsView::DolphinDetailsView(QWidget* parent, DolphinController* contr
     updateDecorationSize();
 
     setFocus();
+
+    connect(KGlobalSettings::self(), SIGNAL(kdisplayFontChanged()),
+            this, SLOT(updateFont()));
 }
 
 DolphinDetailsView::~DolphinDetailsView()
@@ -229,11 +237,30 @@ void DolphinDetailsView::mouseMoveEvent(QMouseEvent* event)
             setSelection(selRect, QItemSelectionModel::Select);
         }
 
-        QTreeView::mouseMoveEvent(event);
+        // TODO: see comment at end of method
+        // QTreeView::mouseMoveEvent(event);
+        QAbstractItemView::mouseMoveEvent(event);
         updateElasticBand();
     } else {
-        QTreeView::mouseMoveEvent(event);
+        // TODO: see comment at end of method
+        //QTreeView::mouseMoveEvent(event);
+        QAbstractItemView::mouseMoveEvent(event);
     }
+
+    // The original implementation of QTreeView::mouseMoveEvent() looks like this (Qt4.4):
+    //
+    // void QTreeView::mouseMoveEvent(QMouseEvent *event)
+    // {
+    //     Q_D(QTreeView);
+    //     if (d->itemDecorationAt(event->pos()) == -1) // ### what about expanding/collapsing state ?
+    //         QAbstractItemView::mouseMoveEvent(event);
+    // }
+    //
+    // This prevents that the signal 'entered()' is emitted when the mouse is above a decoration,
+    // although the hovered item has changed. The SelectionManager is connected to 'entered()'
+    // and assumes that the old item is selected. This is currently bypassed by skipping
+    // the base implementation and invoking QAbstractItemView::mouseMoveEvent() directly.
+    // Submitted a bug report to Trolltech, bug ID is still pending.
 }
 
 void DolphinDetailsView::mouseReleaseEvent(QMouseEvent* event)
@@ -532,6 +559,16 @@ void DolphinDetailsView::requestActivation()
     m_controller->requestActivation();
 }
 
+void DolphinDetailsView::updateFont()
+{
+    const DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();
+    Q_ASSERT(settings != 0);
+
+    if (settings->useSystemFont()) {
+        m_font = KGlobalSettings::generalFont();
+    }
+}
+
 bool DolphinDetailsView::isZoomInPossible() const
 {
     DetailsModeSettings* settings = DolphinSettings::instance().detailsModeSettings();