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

List:       kde-commits
Subject:    KDE/kdevplatform/plugins/contextbrowser
From:       David Nolden <david.nolden.kde () art-master ! de>
Date:       2008-11-01 13:00:21
Message-ID: 1225544421.694991.12802.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 878507 by zwabel:

When showing the code-browser from a previously hidden state, update its \
navigation-widget and the declaration-list box to the current context, so they \
initially contain the right information.


 M  +43 -14    contextbrowserview.cpp  
 M  +4 -2      contextbrowserview.h  


--- trunk/KDE/kdevplatform/plugins/contextbrowser/contextbrowserview.cpp \
#878506:878507 @@ -24,12 +24,15 @@
 #include <QHBoxLayout>
 #include <QLabel>
 #include <QToolButton>
+#include <QShowEvent>
 #include <QAction>
 #include <QMenu>
 #include <KIcon>
 #include <KTextBrowser>
 #include <KLocale>
 #include <KComboBox>
+#include <ktexteditor/document.h>
+#include <ktexteditor/view.h>
 
 #include <language/duchain/declaration.h>
 #include <language/duchain/topducontext.h>
@@ -457,6 +460,28 @@
     m_plugin->unRegisterToolView(this);
 }
 
+void ContextBrowserView::showEvent(QShowEvent* event) {
+    if(m_navigationWidgetDeclaration.isValid()) {
+        DUChainReadLocker lock(DUChain::lock());
+        TopDUContext* top = m_lastUsedTopContext.data();
+        if(top) {
+            //Update the navigation-widget
+            Declaration* decl = m_navigationWidgetDeclaration.getDeclaration(top);
+            setDeclaration(decl, top, true);
+            
+            //Update the declaration combo-box
+            DUContext* context = 0;
+            KDevelop::IDocument* doc = \
ICore::self()->documentController()->activeDocument(); +            if(doc && \
doc->textDocument() && doc->textDocument()->activeView()) { +                \
KTextEditor::Cursor c = doc->textDocument()->activeView()->cursorPosition(); +        \
context = getContextAt(top->url().toUrl(), c); +            }
+            m_contextCtrl->updateDeclarationListBox(context);
+        }
+    }
+    QWidget::showEvent(event);
+}
+
 bool ContextBrowserView::isLocked() const {
     bool isLocked;
     if (m_allowLockedUpdate) {
@@ -487,13 +512,15 @@
     }
 }
 
-void ContextBrowserView::setDeclaration(KDevelop::Declaration* decl, \
                KDevelop::TopDUContext* topContext) {
-    if (!isLocked() && isVisible()) {  // NO-OP if toolview is hidden, for \
performance reasons +void ContextBrowserView::setDeclaration(KDevelop::Declaration* \
decl, KDevelop::TopDUContext* topContext, bool force) { +    m_lastUsedTopContext = \
IndexedTopDUContext(topContext); +    
+    if(m_navigationWidgetDeclaration == decl->id() && !force)
+        return;
+    m_navigationWidgetDeclaration = decl->id();
+    
+    if (!isLocked() && (isVisible() || force)) {  // NO-OP if toolview is hidden, \
for performance reasons  
-        if(m_navigationWidgetDeclaration == decl->id())
-            return;
-        m_navigationWidgetDeclaration = decl->id();
-        
         QWidget* w = m_declarationCtrl->createWidget(decl, topContext);
         updateMainWidget(w);
     }
@@ -511,16 +538,18 @@
 }
 
 void ContextBrowserView::setContext(KDevelop::DUContext* context) {
+    m_lastUsedTopContext = IndexedTopDUContext(context->topContext());
+    
+    if(context->owner()) {
+        if(context->owner()->id() == m_navigationWidgetDeclaration)
+            return;
+        m_navigationWidgetDeclaration = context->owner()->id();
+    }else{
+        m_navigationWidgetDeclaration = DeclarationId();
+    }
+    
     if (!isLocked() && isVisible()) { // NO-OP if toolview is hidden, for \
performance reasons  
-        if(context->owner()) {
-            if(context->owner()->id() == m_navigationWidgetDeclaration)
-                return;
-            m_navigationWidgetDeclaration = context->owner()->id();
-        }else{
-            m_navigationWidgetDeclaration = DeclarationId();
-        }
-        
         QWidget* w = m_contextCtrl->createWidget(context);
         updateMainWidget(w);
     }
--- trunk/KDE/kdevplatform/plugins/contextbrowser/contextbrowserview.h #878506:878507
@@ -51,7 +51,7 @@
 
         //duchain must be locked
         void setContext(KDevelop::DUContext* context);
-        void setDeclaration(KDevelop::Declaration* decl, KDevelop::TopDUContext* \
topContext); +        void setDeclaration(KDevelop::Declaration* decl, \
KDevelop::TopDUContext* topContext, bool force = false);  void \
                setSpecialNavigationWidget(QWidget*);
         void updateHistory(KDevelop::DUContext*, const KDevelop::SimpleCursor&);
         void updateMainWidget(QWidget*);
@@ -67,6 +67,7 @@
         void updateLockIcon(bool); 
 
     private:
+        virtual void showEvent(QShowEvent* event);
         bool isLocked() const;
         void resetWidget();
 
@@ -79,6 +80,7 @@
         QWidget* m_navigationWidget;
         KDevelop::DeclarationId m_navigationWidgetDeclaration;
         bool m_allowLockedUpdate;
+        KDevelop::IndexedTopDUContext m_lastUsedTopContext;
 };
 
 // handles Context related operations for ContextBrowserView
@@ -116,6 +118,7 @@
             QString alternativeString;
         };
 
+        void updateDeclarationListBox(KDevelop::DUContext* context);
     public Q_SLOTS:
         void historyNext();
         void historyPrevious();
@@ -126,7 +129,6 @@
         void comboItemActivated(int index);
         void documentJumpPerformed( KDevelop::IDocument* newDocument, \
KTextEditor::Cursor newCursor, KDevelop::IDocument* previousDocument, \
KTextEditor::Cursor previousCursor);  private:
-        void updateDeclarationListBox(KDevelop::DUContext* context);
         bool isPreviousEntry(KDevelop::DUContext*, const KDevelop::SimpleCursor& \
cursor);  QString actionTextFor(int historyIndex);
         void updateButtonState();


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

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