[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-04-23 20:55:22
Message-ID: 1208984122.353058.32148.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 800297 by apaku:

Fix the logic of who owns the listview, outputdata as the "model" part cannot do \
that.


 M  +38 -27    outputwidget.cpp  
 M  +1 -1      outputwidget.h  
 M  +10 -7     standardoutputview.cpp  
 M  +3 -1      toolviewdata.cpp  
 M  +1 -1      toolviewdata.h  


--- trunk/KDE/kdevplatform/plugins/standardoutputview/outputwidget.cpp #800296:800297
@@ -74,8 +74,8 @@
 void OutputWidget::changeDelegate( int id )
 {
     kDebug(9500) << "delegate changed for id:" << id;
-    if( data->outputdata.contains( id ) && data->outputdata.value(id)->view )
-        data->outputdata.value(id)->view->setItemDelegate(data->outputdata.value(id)->delegate);
 +    if( data->outputdata.contains( id ) && views.contains( id ) )
+        views.value(id)->setItemDelegate(data->outputdata.value(id)->delegate);
     else
         addOutput(id);
 }
@@ -83,13 +83,15 @@
 void OutputWidget::changeModel( int id )
 {
     kDebug(9500) << "model changed for id:" << id;
-    if( data->outputdata.contains( id ) && data->outputdata.value(id)->view )
+    if( data->outputdata.contains( id ) && views.contains( id ) )
     {
-        data->outputdata.value(id)->view->setModel(data->outputdata.value(id)->model);
 +        OutputData* od = data->outputdata.value(id);
+        kDebug() << "output:" << od << "id of output:" << od->id << "title:" << \
od->title  << "tv id" << od->toolView->toolViewId << "tv title:" << \
od->toolView->title; +        views.value( id \
                )->setModel(data->outputdata.value(id)->model);
         if( data->outputdata.value(id)->behaviour && \
KDevelop::IOutputView::AutoScroll )  {
             connect( data->outputdata.value(id)->model, SIGNAL(rowsInserted(const \
                QModelIndex&, int, int)),
-                     data->outputdata.value(id)->view, SLOT(scrollToBottom()) );
+                     views.value(id), SLOT(scrollToBottom()) );
         }
     }
     else
@@ -100,9 +102,9 @@
 
 void OutputWidget::removeOutput( int id )
 {
-    if( data->outputdata.contains( id ) )
+    if( data->outputdata.contains( id ) && views.contains( id ) )
     {
-        QListView* w = data->outputdata.value(id)->view;
+        QListView* w = views.value(id);
         int idx = indexOf( w );
         if( idx != -1 )
         {
@@ -118,12 +120,12 @@
     QWidget* widget = currentWidget();
     if( !widget )
         return;
-    foreach( OutputData* data, data->outputdata )
+    foreach( int id, views.keys() )
     {
-        if( data->view == widget )
+        if( views.value(id) == widget )
         {
-            int id = data->id;
-            if( data->behaviour & KDevelop::IOutputView::AllowUserClose )
+            OutputData* od = data->outputdata.value(id);
+            if( od->behaviour & KDevelop::IOutputView::AllowUserClose )
             {
                 removeOutput( id );
             }
@@ -196,27 +198,36 @@
 
 QListView* OutputWidget::createListView(int id)
 {
-    kDebug(9500) << "creating listview";
-    QListView* listview = new QListView(this);
-    listview->setEditTriggers( QAbstractItemView::NoEditTriggers );
-    data->outputdata.value(id)->view = listview;
-    connect( listview, SIGNAL(activated(const QModelIndex&)),
-             this, SLOT(activate(const QModelIndex&)));
-    connect( listview, SIGNAL(clicked(const QModelIndex&)),
-             this, SLOT(activate(const QModelIndex&)));
-
-    addTab( listview, data->outputdata.value(id)->title );
-    changeModel( id );
-    changeDelegate( id );
-    return listview;
+    if( !views.contains(id) )
+    {
+        kDebug(9500) << "creating listview";
+        QListView* listview = new QListView(this);
+        listview->setEditTriggers( QAbstractItemView::NoEditTriggers );
+        views[id] = listview;
+        connect( listview, SIGNAL(activated(const QModelIndex&)),
+                 this, SLOT(activate(const QModelIndex&)));
+        connect( listview, SIGNAL(clicked(const QModelIndex&)),
+                 this, SLOT(activate(const QModelIndex&)));
+    
+        addTab( listview, data->outputdata.value(id)->title );
+        changeModel( id );
+        changeDelegate( id );
+        return listview;
+    } else
+    {
+        return views.value(id);
+    }
 }
 
 void OutputWidget::raiseOutput(int id)
 {
-    int idx = indexOf( data->outputdata.value(id)->view );
-    if( idx >= 0 )
+    if( views.contains(id) )
     {
-        setCurrentIndex( idx );
+        int idx = indexOf( views.value(id) );
+        if( idx >= 0 )
+        {
+            setCurrentIndex( idx );
+        }
     }
 }
 
--- trunk/KDE/kdevplatform/plugins/standardoutputview/outputwidget.h #800296:800297
@@ -52,10 +52,10 @@
 
     Q_SIGNALS:
         void outputRemoved( int, int );
-
     private:
         QListView* createListView(int id);
 
+        QMap<int, QListView*> views;
         ToolViewData* data;
         QToolButton* m_closeButton;
 };
--- trunk/KDE/kdevplatform/plugins/standardoutputview/standardoutputview.cpp \
#800296:800297 @@ -94,14 +94,17 @@
 {
     foreach( ToolViewData* d, toolviews )
     {
-        if( d->views.contains(v) && d->views.count() == 1 )
+        if( d->views.contains(v) )
         {
-            toolviews.remove( d->toolViewId );
-            ids.removeAll( d->toolViewId );
-            delete d;
-        } else
-        {
-            d->views.removeAll(v);
+            if( d->views.count() == 1 )
+            {
+                toolviews.remove( d->toolViewId );
+                ids.removeAll( d->toolViewId );
+                delete d;
+            } else
+            {
+                d->views.removeAll(v);
+            }
         }
     }
 }
--- trunk/KDE/kdevplatform/plugins/standardoutputview/toolviewdata.cpp #800296:800297
@@ -20,8 +20,10 @@
 
 #include "toolviewdata.h"
 
+#include <kdebug.h>
+
 OutputData::OutputData( ToolViewData* tv )
-    : QObject( tv ), delegate(0), model(0), toolView(tv), view(0), id(-1)
+    : QObject( tv ), delegate(0), model(0), toolView(tv), id(-1)
 {
 }
 
--- trunk/KDE/kdevplatform/plugins/standardoutputview/toolviewdata.h #800296:800297
@@ -47,7 +47,6 @@
     ToolViewData* toolView;
     KDevelop::IOutputView::Behaviours behaviour;
     QString title;
-    QListView* view;
     int id;
     void setModel( QAbstractItemModel* model);
     void setDelegate( QAbstractItemDelegate* delegate);
@@ -63,6 +62,7 @@
     ToolViewData( QObject* parent );
     ~ToolViewData();
     OutputData* addOutput( int id, const QString& title, \
KDevelop::IOutputView::Behaviours behave ); +    // If we would adhere to \
model-view-separation strictly, then this member would move into standardoutputview, \
but its more convenient this way.  QList<Sublime::View*> views;
     StandardOutputView* plugin;
     QMap<int, OutputData*> outputdata;


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

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