[Pkg-owncloud-commits] [owncloud-client] 272/484: ActivityDelegate: Make the row height public accessible.

Sandro Knauß hefee-guest at moszumanska.debian.org
Wed Dec 16 00:37:52 UTC 2015


This is an automated email from the git hooks/post-receive script.

hefee-guest pushed a commit to branch master
in repository owncloud-client.

commit a1551ef6ab1af129b095d5d2ccd0490d5e0b20f7
Author: Klaas Freitag <freitag at owncloud.com>
Date:   Fri Nov 6 11:41:32 2015 +0100

    ActivityDelegate: Make the row height public accessible.
    
    Now it can be used to be set on the other two treeviews.
---
 src/gui/activityitemdelegate.cpp | 40 +++++++++++++++++++++++++++++-----------
 src/gui/activityitemdelegate.h   |  5 +++++
 2 files changed, 34 insertions(+), 11 deletions(-)

diff --git a/src/gui/activityitemdelegate.cpp b/src/gui/activityitemdelegate.cpp
index cbd95f7..cbb8513 100644
--- a/src/gui/activityitemdelegate.cpp
+++ b/src/gui/activityitemdelegate.cpp
@@ -28,23 +28,41 @@
 
 namespace OCC {
 
-QSize ActivityItemDelegate::sizeHint(const QStyleOptionViewItem & option ,
-                                     const QModelIndex & /* index */) const
+int ActivityItemDelegate::_iconHeight = 0;
+int ActivityItemDelegate::_margin = 0;
+
+int ActivityItemDelegate::iconHeight()
 {
-    QFont font = option.font;
+    if( _iconHeight == 0 ) {
+        QStyleOptionViewItem option;
+        QFont font = option.font;
 
-    QFontMetrics fm(font);
-    int iconHeight = qRound(fm.height() / 5.0 * 8.0);
-    int margin = fm.height()/4;
+        QFontMetrics fm(font);
 
-    // TODO: set a different height for the day-line
+        _iconHeight = qRound(fm.height() / 5.0 * 8.0);
+    }
+    return _iconHeight;
+}
 
-    // calc height
+int ActivityItemDelegate::rowHeight()
+{
+    if( _margin == 0 ) {
+    QStyleOptionViewItem opt;
 
-    int h = iconHeight;          // lets display the icon
-    h += 2*margin;               // two times margin
+    QFont f = opt.font;
+    QFontMetrics fm(f);
+
+    _margin = fm.height()/4;
+    }
+    return iconHeight() + 2 * _margin;
+}
+
+QSize ActivityItemDelegate::sizeHint(const QStyleOptionViewItem & option ,
+                                     const QModelIndex & /* index */) const
+{
+    QFont font = option.font;
 
-    return QSize( 0, h);
+    return QSize( 0, rowHeight() );
 }
 
 void ActivityItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
diff --git a/src/gui/activityitemdelegate.h b/src/gui/activityitemdelegate.h
index 521eb06..7ef5cef 100644
--- a/src/gui/activityitemdelegate.h
+++ b/src/gui/activityitemdelegate.h
@@ -39,6 +39,11 @@ public:
     bool editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option,
                       const QModelIndex& index ) Q_DECL_OVERRIDE;
 
+    static int rowHeight();
+    static int iconHeight();
+private:
+    static int _margin;
+    static int _iconHeight;
 };
 
 } // namespace OCC

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git



More information about the Pkg-owncloud-commits mailing list