[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdevelop/languages/cpp/debugger
From:       Vladimir Prus <ghost () cs ! msu ! su>
Date:       2008-04-19 14:57:47
Message-ID: 1208617067.136330.20645.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 798823 by vprus:

Automatically resize the tooltip vertically if the content no longer fits.


 M  +18 -3     tooltipwidget.cpp  
 M  +4 -1      tooltipwidget.h  
 M  +4 -1      util/treeview.h  


--- trunk/KDE/kdevelop/languages/cpp/debugger/tooltipwidget.cpp #798822:798823
@@ -20,6 +20,7 @@
 #include <QMouseEvent>
 #include <QHeaderView>
 #include <QLabel>
+#include <QScrollBar>
 #include <KTextEditor/View>
 
 using namespace GDBDebugger;
@@ -44,14 +45,21 @@
     
     QVBoxLayout* l = new QVBoxLayout(this);
     l->setContentsMargins(0, 0, 0, 0);
-    QTreeView* view = new GDBDebugger::AsyncTreeView(model_, this);
+    AsyncTreeView* view = new AsyncTreeView(model_, this);
     view->header()->resizeSection(0, 200);
     view->header()->resizeSection(1, 90);
     view->header()->hide();
     view->setSelectionBehavior(QAbstractItemView::SelectRows);
-    view->setSelectionMode(QAbstractItemView::SingleSelection);    
+    view->setSelectionMode(QAbstractItemView::SingleSelection);
+    view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
     l->addWidget(view);
 
+    itemHeight_ = view->indexRowSizeHint(model_->indexForItem(var_, 0));
+    connect(view->verticalScrollBar(),
+            SIGNAL(rangeChanged(int, int)),
+            this,
+            SLOT(slotRangeChanged(int, int)));
+
     selection_ = view->selectionModel();
     selection_->select(model_->indexForItem(var_, 0), 
                        QItemSelectionModel::Rows
@@ -68,7 +76,8 @@
     connect(label, SIGNAL(linkActivated(const QString&)),
             this, SLOT(slotLinkActivated(const QString&)));
     connect(label2, SIGNAL(linkActivated(const QString&)),
-            this, SLOT(slotLinkActivated(const QString&)));
+            this, SLOT(slotLinkActivated(const QString&)));    
+
         
     move(position);
     resize(300, 100);
@@ -145,4 +154,10 @@
     hide();
 }
 
+void VariableToolTip::slotRangeChanged(int min, int max)
+{
+    Q_ASSERT(min == 0);
+    resize(width(), height() + max*itemHeight_);
+}
+
 #include "tooltipwidget.moc"
--- trunk/KDE/kdevelop/languages/cpp/debugger/tooltipwidget.h #798822:798823
@@ -3,14 +3,15 @@
 #define TOOLTIP_H_f2dc78af9cdf452ce712f673b2bbcd00
 
 #include "util/activetooltip.h"
+#include "util/treeview.h"
 #include "mi/gdbmi.h"
 
 #include <QPoint>
 
 class QItemSelectionModel;
 class QString;
+class QResizeEvent;
 
-
 namespace GDBDebugger
 {
     class TreeModel;
@@ -34,12 +35,14 @@
 
     private slots:
         void slotLinkActivated(const QString& link);
+        void slotRangeChanged(int min, int max);
 
     private:
         TreeModel* model_;
         Variable* var_;
         QItemSelectionModel* selection_;
         GDBController* controller_;
+        int itemHeight_;
     };
 }
 
--- trunk/KDE/kdevelop/languages/cpp/debugger/util/treeview.h #798822:798823
@@ -11,9 +11,12 @@
     class AsyncTreeView : public QTreeView
     {
         Q_OBJECT
-        public:
+    public:
         AsyncTreeView(TreeModel* model, QWidget *parent);
 
+        // Well, I really, really, need this.
+        using QTreeView::indexRowSizeHint;
+
     private slots:
         void slotExpanded(const QModelIndex &index);
         void slotCollapsed(const QModelIndex &index);
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic