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

List:       kde-commits
Subject:    KDE/kdevplatform
From:       Aleix Pol Gonzalez <aleixpol () gmail ! com>
Date:       2009-11-12 1:24:28
Message-ID: 1257989068.152023.20654.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1047749 by apol:

Make it possible to have home pages in every documentation provider.
Provide a default implementation for the viewer.


 M  +9 -0      interfaces/idocumentation.cpp  
 M  +1 -4      interfaces/idocumentation.h  
 M  +3 -0      interfaces/idocumentationprovider.h  
 M  +1 -1      language/duchain/navigation/abstractdeclarationnavigationcontext.cpp  
 M  +12 -10    shell/documentationview.cpp  
 M  +1 -0      shell/documentationview.h  


--- trunk/KDE/kdevplatform/interfaces/idocumentation.cpp #1047748:1047749
@@ -18,6 +18,7 @@
 */
 
 #include "idocumentation.h"
+#include <qtextbrowser.h>
 
 namespace KDevelop
 {
@@ -25,4 +26,12 @@
 IDocumentation::~IDocumentation()
 {}
 
+QWidget* IDocumentation::documentationWidget(QWidget* parent)
+{
+    QTextBrowser* widget=new QTextBrowser(parent);
+    widget->setReadOnly(true);
+    widget->setText(description());
+    return widget;
 }
+
+}
--- trunk/KDE/kdevplatform/interfaces/idocumentation.h #1047748:1047749
@@ -45,11 +45,8 @@
         /** @returns a widget with all the needed documentation information.
             \param parent defines the widget's parent
         */
-        virtual QWidget* documentationWidget(QWidget* parent=0)=0;
+        virtual QWidget* documentationWidget(QWidget* parent=0);
         
-        /** @returns whether the widget can provide extended information. */
-        virtual bool providesWidget() const =0;
-        
         virtual IDocumentationProvider* provider()=0;
 };
 
--- trunk/KDE/kdevplatform/interfaces/idocumentationprovider.h #1047748:1047749
@@ -53,6 +53,9 @@
         /** @returns a name to identify the provider to the user. */
         virtual QString name() const=0;
         
+        /** @returns a documentation item where we can show some home page \
information such a context index. */ +        virtual KSharedPtr<IDocumentation> \
homePage() const=0; +        
     Q_SIGNALS:
         virtual void addHistory(const KSharedPtr<IDocumentation>& doc)=0;
 };
--- trunk/KDE/kdevplatform/language/duchain/navigation/abstractdeclarationnavigationcontext.cpp \
#1047748:1047749 @@ -272,7 +272,7 @@
     }
   }
   
-    if(!shorten && doc && doc->providesWidget()) {
+    if(!shorten) {
       modifyHtml() += "<br />" + i18n("Show documentation for ");
       makeLink( prettyQualifiedIdentifier(m_declaration).toString(), m_declaration, \
NavigationAction::ShowDocumentation );  }
--- trunk/KDE/kdevplatform/shell/documentationview.cpp #1047748:1047749
@@ -85,10 +85,12 @@
     setWindowIcon(KIcon("documentation"));
     setLayout(new QVBoxLayout(this));
     mActions=new KToolBar(this);
+    mActions->setToolButtonStyle(Qt::ToolButtonIconOnly);
     layout()->addWidget(mActions);
     mBack=mActions->addAction(KIcon("go-previous"), i18n("Back"));
     mForward=mActions->addAction(KIcon("go-next"), i18n("Forward"));
     mActions->addSeparator();
+    mActions->addAction(KIcon("go-home"), i18n("Home"), this, SLOT(showHome()));
     mProviders=new QComboBox(mActions);
     mProviders->setFocusPolicy(Qt::NoFocus);
     mProvidersModel=new ProvidersModel(mProviders);
@@ -143,6 +145,13 @@
     updateView();
 }
 
+void DocumentationView::showHome()
+{
+    KDevelop::IDocumentationProvider* \
prov=mProvidersModel->provider(mProviders->currentIndex()); +    
+    showDocumentation(prov->homePage());
+}
+
 void DocumentationView::changedSelection()
 {
     changeProvider(mIdentifiers->completer()->currentIndex());
@@ -152,7 +161,8 @@
 {
     if(idx.isValid())
     {
-        KSharedPtr<KDevelop::IDocumentation> \
doc=mProvidersModel->provider(mProviders->currentIndex())->documentationForIndex(idx);
 +        KDevelop::IDocumentationProvider* \
prov=mProvidersModel->provider(mProviders->currentIndex()); +        \
KSharedPtr<KDevelop::IDocumentation> doc=prov->documentationForIndex(idx);  if(doc)
             showDocumentation(doc);
     }
@@ -186,15 +196,7 @@
     
     delete lastview;
     
-    QWidget* w;
-    if((*mCurrent)->providesWidget())
-        w=(*mCurrent)->documentationWidget(this);
-    else {
-        QTextBrowser* widget=new QTextBrowser(this);
-        widget->setReadOnly(true);
-        widget->setText((*mCurrent)->description());
-        w=widget;
-    }
+    QWidget* w=(*mCurrent)->documentationWidget(this);
     Q_ASSERT(w);
     layout()->addWidget(w);
 }
--- trunk/KDE/kdevplatform/shell/documentationview.h #1047748:1047749
@@ -44,6 +44,7 @@
         void changedSelection();
         void changedProvider(int);
         void changeProvider(const QModelIndex &);
+        void showHome();
         
     private:
         void updateView();


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

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