00001 // -*- Mode: C++; tab-width: 2; -*- 00002 // vi: set ts=2: 00003 // 00004 // $Id: helpViewer.h,v 1.2.18.1 2007/03/25 21:26:21 oliver Exp $ 00005 // 00006 00007 #ifndef BALL_VIEW_WIDGETS_HELPVIEWER_H 00008 #define BALL_VIEW_WIDGETS_HELPVIEWER_H 00009 00010 #ifndef BALL_VIEW_WIDGETS_DOCKWIDGET_H 00011 # include <BALL/VIEW/WIDGETS/dockWidget.h> 00012 #endif 00013 00014 #include <QtGui/QTextBrowser> 00015 00016 namespace BALL 00017 { 00018 namespace VIEW 00019 { 00020 00021 class BALL_VIEW_EXPORT MyTextBrowser 00022 : public QTextBrowser 00023 { 00024 Q_OBJECT 00025 00026 public: 00027 00028 MyTextBrowser(QWidget* parent, const char* name = 0); 00029 00030 public slots: 00031 00032 // void setBackwardAvailable(bool b); 00033 00034 // void setForwardAvailable(bool b); 00035 00036 protected: 00037 00038 // virtual QMenu* createPopupMenu(const QPoint& pos); 00039 00040 bool forward_, backward_; 00041 }; 00042 00066 class BALL_VIEW_EXPORT HelpViewer 00067 : public DockWidget 00068 { 00069 Q_OBJECT 00070 00071 public: 00072 00073 BALL_EMBEDDABLE(HelpViewer, DockWidget) 00074 00075 00076 HelpViewer(QWidget* parent, const char* name = 0); 00077 00079 virtual ~HelpViewer(); 00080 00083 virtual void initializeWidget(MainControl& main_control); 00084 00091 virtual void onNotify(Message *message); 00092 00094 virtual void showHelp(const String& URL); 00095 00097 virtual void showHelp(const String& URL, String entry); 00098 00100 void setDefaultPage(const String& url); 00101 00103 const String& getDefaultPage() const; 00104 00106 void setProject(const String& project) { project_ = project;} 00107 00109 String getProject() const { return project_;} 00110 00112 void setBaseDirectory(const String& dir); 00113 00115 const String& getBaseDirectory() const; 00116 00118 virtual void registerForHelpSystem(const QObject* object, const String& docu_entry); 00119 00121 void unregisterForHelpSystem(const QObject* object); 00122 00124 bool showHelpFor(const QObject* object); 00125 00127 bool showDocumentationForObject(); 00128 00130 bool hasHelpFor(const QObject* object) const; 00131 00133 String getHelpEntryFor(const QObject* object) const; 00134 00136 void setWhatsThisEnabled(bool state) { whats_this_ = state;} 00137 00139 bool isWhatsThisEnabled() const {return whats_this_;} 00140 00142 void showDocumentationFor(const String& classname, const String& member); 00143 00144 public slots: 00145 00147 virtual void showHelp(); 00148 00150 void enterWhatsThisMode(); 00151 00153 void exitWhatsThisMode(); 00154 00156 bool eventFilter(QObject* obj, QEvent* e); 00157 00158 protected: 00159 00160 void collectClasses_(); 00161 00162 String project_; 00163 String default_page_; 00164 String base_dir_; 00165 MyTextBrowser* browser_; 00166 bool whats_this_mode_; 00167 bool ignore_event_; 00168 bool whats_this_; 00169 QAction* whats_action_; 00170 00171 HashMap<const QObject*, String> docu_entries_; 00172 StringHashMap<String> classes_to_files_; 00173 }; 00174 00175 } } // namespaces 00176 00177 #endif // BALL_VIEW_WIDGETS_HELPVIEWER_H