language/duchain
abstractnavigationcontext.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
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
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;
00142 NavigationAction m_selectedLinkAction;
00143
00144 NavigationContextPointer registerChild(DeclarationPointer );
00145 NavigationContextPointer registerChild( AbstractNavigationContext* context );
00146 QList<NavigationContextPointer> m_children;
00147
00148 bool m_shorten;
00149
00150 int m_currentLine;
00151
00152
00153 int m_linkCount;
00154
00155 int m_currentPositionLine;
00156 QMap<QString, NavigationAction> m_links;
00157 QMap<int, int> m_linkLines;
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;
00176 };
00177
00178 }
00179
00180 #endif