• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • KDevelop Platform Libraries
  • Sitemap
  • Contact Us
 

language/duchain

abstractnavigationcontext.h

00001 /*
00002    Copyright 2007 David Nolden <david.nolden.kdevelop@art-master.de>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License version 2 as published by the Free Software Foundation.
00007 
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012 
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016    Boston, MA 02110-1301, USA.
00017 */
00018 
00019 #ifndef ABSTRACTNAVIGATIONCONTEXT_H
00020 #define ABSTRACTNAVIGATIONCONTEXT_H
00021 
00022 #include <KDE/KSharedPtr>
00023 
00024 #include "../../languageexport.h"
00025 #include "../duchainpointer.h"
00026 #include "navigationaction.h"
00027 #include "../types/structuretype.h"
00028 
00029 
00030 
00031 namespace KDevelop {
00032 
00038 struct KDEVPLATFORMLANGUAGE_EXPORT Colorizer
00039 {
00040   Colorizer(const QString& color, bool bold=false, bool italic=false) : m_color(color), m_bold(bold), m_italic(italic) {
00041   }
00042 
00043   QString operator()(const QString& str) const
00044   {
00045     QString ret = "<font color=\"#" + m_color + "\">" + str + "</font>";
00046     if( m_bold )
00047       ret = "<b>"+ret+"</b>";
00048 
00049     if( m_italic )
00050       ret = "<i>"+ret+"</i>";
00051     return ret;
00052   }
00053 
00054   QString m_color;
00055   bool m_bold, m_italic;
00056 };
00057 
00058 class AbstractNavigationContext;
00059 typedef KSharedPtr<AbstractNavigationContext> NavigationContextPointer;
00060 
00061 class KDEVPLATFORMLANGUAGE_EXPORT AbstractNavigationContext : public KShared
00062 {
00063   public:
00064     AbstractNavigationContext( KDevelop::TopDUContextPointer topContext = KDevelop::TopDUContextPointer(), AbstractNavigationContext* previousContext = 0 );
00065 
00066     virtual ~AbstractNavigationContext() {
00067     }
00068 
00069     void nextLink();
00070     void previousLink();
00071     void up();
00072     void down();
00073     void setPrefixSuffix( const QString& prefix, const QString& suffix );
00074     NavigationContextPointer accept();
00075     NavigationContextPointer back();
00076     NavigationContextPointer accept(IndexedDeclaration decl);
00077     NavigationContextPointer acceptLink(const QString& link);
00078     NavigationAction currentAction() const;
00079 
00080     virtual QString name() const = 0;
00082     virtual QString html(bool shorten = false);
00087     virtual QWidget* widget() const;
00088     
00091     virtual bool isWidgetMaximized() const;
00092 
00095     bool alreadyComputed() const;
00096     
00097     void setTopContext(TopDUContextPointer context);
00098 
00099     TopDUContextPointer topContext() const;
00100 
00101     NavigationContextPointer executeLink(QString link);
00102     
00103   protected:
00104     
00105     virtual void setPreviousContext(AbstractNavigationContext* previous);
00106     
00107     struct TextHandler {
00108       TextHandler(AbstractNavigationContext* c) : context(c) {
00109       }
00110       void operator+=(const QString& str) const {
00111         context->addHtml(str);
00112       }
00113       AbstractNavigationContext* context;
00114     };
00115     
00117     virtual NavigationContextPointer executeKeyAction(QString key);
00118 
00120     void addHtml(QString html);
00122     QString currentHtml() const;
00124     TextHandler modifyHtml() {
00125       return TextHandler(this);
00126     }
00127 
00128     //Clears the computed html and links
00129     void clear();
00130     
00131     NavigationContextPointer execute(NavigationAction& action);
00132 
00133     void addExternalHtml( const QString& text );
00134 
00136     virtual void makeLink( const QString& name, DeclarationPointer declaration, NavigationAction::Type actionType );
00137 
00139     void makeLink( const QString& name, QString targetId, const NavigationAction& action);
00140 
00141     int m_selectedLink; //The link currently selected
00142     NavigationAction m_selectedLinkAction; //Target of the currently selected link
00143 
00144     NavigationContextPointer registerChild(DeclarationPointer /*declaration*/);
00145     NavigationContextPointer registerChild( AbstractNavigationContext* context );
00146     QList<NavigationContextPointer> m_children; //Useed to keep alive all children until this is deleted
00147 
00148     bool m_shorten;
00149 
00150     int m_currentLine;
00151 
00152     //A counter used while building the html-code to count the used links.
00153     int m_linkCount;
00154     //Something else than -1 if the current position is represented by a line-number, not a link.
00155     int m_currentPositionLine;
00156     QMap<QString, NavigationAction> m_links;
00157     QMap<int, int> m_linkLines; //Holds the line for each link
00158     QMap<int, NavigationAction> m_intLinks;
00159     AbstractNavigationContext* m_previousContext;
00160     QString m_prefix, m_suffix;
00161     KDevelop::TopDUContextPointer m_topContext;
00162 
00163     virtual QString declarationKind(DeclarationPointer decl);
00164 
00165     static const Colorizer typeHighlight;
00166     static const Colorizer errorHighlight;
00167     static const Colorizer labelHighlight;
00168     static const Colorizer codeHighlight;
00169     static const Colorizer propertyHighlight;
00170     static const Colorizer navigationHighlight;
00171     static const Colorizer importantHighlight;
00172     static const Colorizer commentHighlight;
00173     static const Colorizer nameHighlight;
00174   private:
00175     QString m_currentText; //Here the text is built
00176 };
00177 
00178 }
00179 
00180 #endif

language/duchain

Skip menu "language/duchain"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

KDevelop Platform Libraries

Skip menu "KDevelop Platform Libraries"
  • interfaces
  • language
  •   codegen
  •   duchain
  •   editor
  • outputview
  • project
  • shell
  • sublime
  • util
  • vcs
Generated for KDevelop Platform Libraries by doxygen 1.5.9-20090814
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal