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

List:       kde-commits
Subject:    kdevelop/parts/valgrind
From:       Harald Fernengel <harald () trolltech ! com>
Date:       2003-01-02 1:34:54
[Download RAW message or body]

CVS commit by harald: 

added rmb menu to expand/collapse all items


  M +43 -1     valgrind_widget.cpp   1.2
  M +6 -0      valgrind_widget.h   1.2


--- kdevelop/parts/valgrind/valgrind_widget.cpp  #1.1:1.2
@@ -1,4 +1,5 @@
 #include <qlayout.h>
 #include <qpainter.h>
+#include <qpopupmenu.h>
 
 #include <kparts/part.h>
@@ -100,6 +101,14 @@ ValgrindWidget::ValgrindWidget( Valgrind
   vbl->addWidget( lv );
   
+  popup = new QPopupMenu( lv, "valPopup" );
+  popup->insertItem( i18n( "Expand all items" ), this, SLOT(expandAll()), 0, 0 );
+  popup->insertItem( i18n( "Collapse all items" ), this, SLOT(collapseAll()), 0, 1 );
+
+  connect( popup, SIGNAL(aboutToShow()),
+           this, SLOT(aboutToShowPopup()) ); 
   connect( lv, SIGNAL(executed(QListViewItem*)),
            this, SLOT(executed(QListViewItem*)) );
+  connect( lv, SIGNAL(contextMenu(KListView*, QListViewItem*, const QPoint&)),
+           this, SLOT(slotContextMenu(KListView*, QListViewItem*, const QPoint&)) );
 }
 
@@ -158,4 +167,37 @@ void ValgrindWidget::executed( QListView
     _part->topLevel()->lowerView( this );
   }
+}
+
+void ValgrindWidget::expandAll()
+{
+  QListViewItem* child = lv->firstChild();
+  while ( child ) {
+    child->setOpen( true );
+    child = child->nextSibling();
+  }
+}
+
+void ValgrindWidget::collapseAll()
+{
+  QListViewItem* child = lv->firstChild();
+  while ( child ) {
+    child->setOpen( false );
+    child = child->nextSibling();
+  }
+}
+
+void ValgrindWidget::aboutToShowPopup()
+{
+  bool en = (lv->firstChild() != 0);
+  popup->setItemEnabled( 0, en );
+  popup->setItemEnabled( 1, en );
+}
+
+void ValgrindWidget::slotContextMenu( KListView* l, QListViewItem* /*i*/, const QPoint& p )
+{
+  if ( l != lv )
+    return;
+
+  popup->exec( p );
 }
 

--- kdevelop/parts/valgrind/valgrind_widget.h  #1.1:1.2
@@ -11,4 +11,5 @@ class ValgrindPart;
 class KListView;
 class QListViewItem;
+class QPopupMenu;
 
 class ValgrindWidget : public QWidget
@@ -28,4 +29,8 @@ signals:
 private slots:
   void executed( QListViewItem* item );
+  void slotContextMenu( KListView* l, QListViewItem* i, const QPoint& p );
+  void expandAll();
+  void collapseAll();
+  void aboutToShowPopup();
     
 private:
@@ -33,4 +38,5 @@ private:
   int msgNumber;
   ValgrindPart* _part;
+  QPopupMenu* popup;
 };
 


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

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