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

List:       kde-commits
Subject:    KDE/kdevplatform/plugins/standardoutputview
From:       Andreas Pakulat <apaku () gmx ! de>
Date:       2008-07-03 9:23:11
Message-ID: 1215076991.565879.18075.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 827529 by apaku:

New Options for
 - focussing the outputview when using next/prev item selection
 - disabling activation item when using next/prev item selection
BUG:19688
PS: Icons will come later


 M  +35 -7     outputwidget.cpp  
 M  +3 -0      outputwidget.h  


--- trunk/KDE/kdevplatform/plugins/standardoutputview/outputwidget.cpp #827528:827529
@@ -34,6 +34,7 @@
 #include <kmenu.h>
 #include <kaction.h>
 #include <kdebug.h>
+#include <ktoggleaction.h>
 #include <klocale.h>
 #include <kicon.h>
 #include <ktabwidget.h>
@@ -72,6 +73,14 @@
         addAction(nextAction);
     }
 
+    activateOnSelect = new KToggleAction( KIcon(), i18n("Select activated Item"), \
this ); +    connect( activateOnSelect, SIGNAL(triggered()), this, \
SLOT(enableActivateOnSelect())); +    addAction(activateOnSelect);
+    focusOnSelect = new KToggleAction( KIcon(), i18n("Focus when selecting Item"), \
this ); +    connect( focusOnSelect, SIGNAL(triggered()), this, \
SLOT(enableFocusOnSelect())); +    addAction(focusOnSelect);
+
+
     connect( data, SIGNAL( outputAdded( int ) ),
              this, SLOT( addOutput( int ) ) );
 
@@ -123,11 +132,11 @@
     {
         OutputData* od = data->outputdata.value(id);
         scrollModelViewMapper->removeMappings( views.value( id )->model() );
-        views.value( id )->setModel(data->outputdata.value(id)->model);
-        if( data->outputdata.value(id)->behaviour & \
KDevelop::IOutputView::AutoScroll && data->outputdata.value(id)->model ) +        \
views.value( id )->setModel(od->model); +        if( od->behaviour & \
KDevelop::IOutputView::AutoScroll && od->model )  {
-            scrollModelViewMapper->setMapping( data->outputdata.value(id)->model, id \
                );
-            connect( data->outputdata.value(id)->model,SIGNAL(rowsInserted(const \
QModelIndex&, int, int)), +            scrollModelViewMapper->setMapping( od->model, \
id ); +            connect( od->model,SIGNAL(rowsInserted(const QModelIndex&, int, \
int)),  scrollModelViewMapper, SLOT(map()) );
         }
     }
@@ -208,6 +217,12 @@
 
     if( !widget || !widget->isVisible() )
         return;
+
+    if( focusOnSelect->isChecked() && !widget->hasFocus() )
+    {
+        widget->setFocus( Qt::OtherFocusReason );
+    }
+
     QAbstractItemView *view = dynamic_cast<QAbstractItemView*>(widget);
     if( !view )
         return;
@@ -216,12 +231,16 @@
     KDevelop::IOutputViewModel *iface = \
dynamic_cast<KDevelop::IOutputViewModel*>(absmodel);  if( iface )
     {
-        kDebug() << "activating next item";
+        kDebug() << "selecting next item";
         QModelIndex index = iface->nextHighlightIndex( view->currentIndex() );
         if( index.isValid() )
         {
             view->setCurrentIndex( index );
-            iface->activate( index );
+            view->scrollTo( index );
+            if( activateOnSelect->isChecked() )
+            {
+                iface->activate( index );
+            }
         }
     }
 }
@@ -235,6 +254,11 @@
     if( !view )
         return;
 
+    if( focusOnSelect->isChecked() && !widget->hasFocus() )
+    {
+        widget->setFocus( Qt::OtherFocusReason );
+    }
+
     QAbstractItemModel *absmodel = view->model();
     KDevelop::IOutputViewModel *iface = \
dynamic_cast<KDevelop::IOutputViewModel*>(absmodel);  if( iface )
@@ -244,7 +268,11 @@
         if( index.isValid() )
         {
             view->setCurrentIndex( index );
-            iface->activate( index );
+            view->scrollTo( index );
+            if( activateOnSelect->isChecked() )
+            {
+                iface->activate( index );
+            }
         }
     }
 }
--- trunk/KDE/kdevplatform/plugins/standardoutputview/outputwidget.h #827528:827529
@@ -32,6 +32,7 @@
 class QToolButton;
 class ToolViewData;
 class KTabWidget;
+class KToggleAction;
 class QModelIndex;
 class KAction;
 
@@ -72,6 +73,8 @@
     KAction* nextAction;
     KAction* previousAction;
     QSignalMapper* scrollModelViewMapper;
+    KToggleAction* activateOnSelect;
+    KToggleAction* focusOnSelect;
 };
 
 #endif


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

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