1
0

qconf.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. /*
  2. * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
  3. * Released under the terms of the GNU GPL v2.0.
  4. */
  5. #if QT_VERSION < 0x040000
  6. #include <qlistview.h>
  7. #else
  8. #include <q3listview.h>
  9. #endif
  10. #include <qsettings.h>
  11. #if QT_VERSION < 0x040000
  12. #define Q3ValueList QValueList
  13. #define Q3PopupMenu QPopupMenu
  14. #define Q3ListView QListView
  15. #define Q3ListViewItem QListViewItem
  16. #define Q3VBox QVBox
  17. #define Q3TextBrowser QTextBrowser
  18. #define Q3MainWindow QMainWindow
  19. #define Q3Action QAction
  20. #define Q3ToolBar QToolBar
  21. #define Q3ListViewItemIterator QListViewItemIterator
  22. #define Q3FileDialog QFileDialog
  23. #endif
  24. class ConfigView;
  25. class ConfigList;
  26. class ConfigItem;
  27. class ConfigLineEdit;
  28. class ConfigMainWindow;
  29. class ConfigSettings : public QSettings {
  30. public:
  31. ConfigSettings();
  32. Q3ValueList<int> readSizes(const QString& key, bool *ok);
  33. bool writeSizes(const QString& key, const Q3ValueList<int>& value);
  34. };
  35. enum colIdx {
  36. promptColIdx, nameColIdx, noColIdx, modColIdx, yesColIdx, dataColIdx, colNr
  37. };
  38. enum listMode {
  39. singleMode, menuMode, symbolMode, fullMode, listMode
  40. };
  41. enum optionMode {
  42. normalOpt = 0, allOpt, promptOpt
  43. };
  44. class ConfigList : public Q3ListView {
  45. Q_OBJECT
  46. typedef class Q3ListView Parent;
  47. public:
  48. ConfigList(ConfigView* p, const char *name = 0);
  49. void reinit(void);
  50. ConfigView* parent(void) const
  51. {
  52. return (ConfigView*)Parent::parent();
  53. }
  54. ConfigItem* findConfigItem(struct menu *);
  55. protected:
  56. void keyPressEvent(QKeyEvent *e);
  57. void contentsMousePressEvent(QMouseEvent *e);
  58. void contentsMouseReleaseEvent(QMouseEvent *e);
  59. void contentsMouseMoveEvent(QMouseEvent *e);
  60. void contentsMouseDoubleClickEvent(QMouseEvent *e);
  61. void focusInEvent(QFocusEvent *e);
  62. void contextMenuEvent(QContextMenuEvent *e);
  63. public slots:
  64. void setRootMenu(struct menu *menu);
  65. void updateList(ConfigItem *item);
  66. void setValue(ConfigItem* item, tristate val);
  67. void changeValue(ConfigItem* item);
  68. void updateSelection(void);
  69. void saveSettings(void);
  70. signals:
  71. void menuChanged(struct menu *menu);
  72. void menuSelected(struct menu *menu);
  73. void parentSelected(void);
  74. void gotFocus(struct menu *);
  75. public:
  76. void updateListAll(void)
  77. {
  78. updateAll = true;
  79. updateList(NULL);
  80. updateAll = false;
  81. }
  82. ConfigList* listView()
  83. {
  84. return this;
  85. }
  86. ConfigItem* firstChild() const
  87. {
  88. return (ConfigItem *)Parent::firstChild();
  89. }
  90. int mapIdx(colIdx idx)
  91. {
  92. return colMap[idx];
  93. }
  94. void addColumn(colIdx idx, const QString& label)
  95. {
  96. colMap[idx] = Parent::addColumn(label);
  97. colRevMap[colMap[idx]] = idx;
  98. }
  99. void removeColumn(colIdx idx)
  100. {
  101. int col = colMap[idx];
  102. if (col >= 0) {
  103. Parent::removeColumn(col);
  104. colRevMap[col] = colMap[idx] = -1;
  105. }
  106. }
  107. void setAllOpen(bool open);
  108. void setParentMenu(void);
  109. bool menuSkip(struct menu *);
  110. template <class P>
  111. void updateMenuList(P*, struct menu*);
  112. bool updateAll;
  113. QPixmap symbolYesPix, symbolModPix, symbolNoPix;
  114. QPixmap choiceYesPix, choiceNoPix;
  115. QPixmap menuPix, menuInvPix, menuBackPix, voidPix;
  116. bool showName, showRange, showData;
  117. enum listMode mode;
  118. enum optionMode optMode;
  119. struct menu *rootEntry;
  120. QColorGroup disabledColorGroup;
  121. QColorGroup inactivedColorGroup;
  122. Q3PopupMenu* headerPopup;
  123. private:
  124. int colMap[colNr];
  125. int colRevMap[colNr];
  126. };
  127. class ConfigItem : public Q3ListViewItem {
  128. typedef class Q3ListViewItem Parent;
  129. public:
  130. ConfigItem(Q3ListView *parent, ConfigItem *after, struct menu *m, bool v)
  131. : Parent(parent, after), menu(m), visible(v), goParent(false)
  132. {
  133. init();
  134. }
  135. ConfigItem(ConfigItem *parent, ConfigItem *after, struct menu *m, bool v)
  136. : Parent(parent, after), menu(m), visible(v), goParent(false)
  137. {
  138. init();
  139. }
  140. ConfigItem(Q3ListView *parent, ConfigItem *after, bool v)
  141. : Parent(parent, after), menu(0), visible(v), goParent(true)
  142. {
  143. init();
  144. }
  145. ~ConfigItem(void);
  146. void init(void);
  147. void okRename(int col);
  148. void updateMenu(void);
  149. void testUpdateMenu(bool v);
  150. ConfigList* listView() const
  151. {
  152. return (ConfigList*)Parent::listView();
  153. }
  154. ConfigItem* firstChild() const
  155. {
  156. return (ConfigItem *)Parent::firstChild();
  157. }
  158. ConfigItem* nextSibling() const
  159. {
  160. return (ConfigItem *)Parent::nextSibling();
  161. }
  162. void setText(colIdx idx, const QString& text)
  163. {
  164. Parent::setText(listView()->mapIdx(idx), text);
  165. }
  166. QString text(colIdx idx) const
  167. {
  168. return Parent::text(listView()->mapIdx(idx));
  169. }
  170. void setPixmap(colIdx idx, const QPixmap& pm)
  171. {
  172. Parent::setPixmap(listView()->mapIdx(idx), pm);
  173. }
  174. const QPixmap* pixmap(colIdx idx) const
  175. {
  176. return Parent::pixmap(listView()->mapIdx(idx));
  177. }
  178. void paintCell(QPainter* p, const QColorGroup& cg, int column, int width, int align);
  179. ConfigItem* nextItem;
  180. struct menu *menu;
  181. bool visible;
  182. bool goParent;
  183. };
  184. class ConfigLineEdit : public QLineEdit {
  185. Q_OBJECT
  186. typedef class QLineEdit Parent;
  187. public:
  188. ConfigLineEdit(ConfigView* parent);
  189. ConfigView* parent(void) const
  190. {
  191. return (ConfigView*)Parent::parent();
  192. }
  193. void show(ConfigItem *i);
  194. void keyPressEvent(QKeyEvent *e);
  195. public:
  196. ConfigItem *item;
  197. };
  198. class ConfigView : public Q3VBox {
  199. Q_OBJECT
  200. typedef class Q3VBox Parent;
  201. public:
  202. ConfigView(QWidget* parent, const char *name = 0);
  203. ~ConfigView(void);
  204. static void updateList(ConfigItem* item);
  205. static void updateListAll(void);
  206. bool showName(void) const { return list->showName; }
  207. bool showRange(void) const { return list->showRange; }
  208. bool showData(void) const { return list->showData; }
  209. public slots:
  210. void setShowName(bool);
  211. void setShowRange(bool);
  212. void setShowData(bool);
  213. void setOptionMode(QAction *);
  214. signals:
  215. void showNameChanged(bool);
  216. void showRangeChanged(bool);
  217. void showDataChanged(bool);
  218. public:
  219. ConfigList* list;
  220. ConfigLineEdit* lineEdit;
  221. static ConfigView* viewList;
  222. ConfigView* nextView;
  223. static QAction *showNormalAction;
  224. static QAction *showAllAction;
  225. static QAction *showPromptAction;
  226. };
  227. class ConfigInfoView : public Q3TextBrowser {
  228. Q_OBJECT
  229. typedef class Q3TextBrowser Parent;
  230. public:
  231. ConfigInfoView(QWidget* parent, const char *name = 0);
  232. bool showDebug(void) const { return _showDebug; }
  233. public slots:
  234. void setInfo(struct menu *menu);
  235. void saveSettings(void);
  236. void setShowDebug(bool);
  237. signals:
  238. void showDebugChanged(bool);
  239. void menuSelected(struct menu *);
  240. protected:
  241. void symbolInfo(void);
  242. void menuInfo(void);
  243. QString debug_info(struct symbol *sym);
  244. static QString print_filter(const QString &str);
  245. static void expr_print_help(void *data, struct symbol *sym, const char *str);
  246. Q3PopupMenu* createPopupMenu(const QPoint& pos);
  247. void contentsContextMenuEvent(QContextMenuEvent *e);
  248. struct symbol *sym;
  249. struct menu *_menu;
  250. bool _showDebug;
  251. };
  252. class ConfigSearchWindow : public QDialog {
  253. Q_OBJECT
  254. typedef class QDialog Parent;
  255. public:
  256. ConfigSearchWindow(ConfigMainWindow* parent, const char *name = 0);
  257. public slots:
  258. void saveSettings(void);
  259. void search(void);
  260. protected:
  261. QLineEdit* editField;
  262. QPushButton* searchButton;
  263. QSplitter* split;
  264. ConfigView* list;
  265. ConfigInfoView* info;
  266. struct symbol **result;
  267. };
  268. class ConfigMainWindow : public Q3MainWindow {
  269. Q_OBJECT
  270. static Q3Action *saveAction;
  271. static void conf_changed(void);
  272. public:
  273. ConfigMainWindow(void);
  274. public slots:
  275. void changeMenu(struct menu *);
  276. void setMenuLink(struct menu *);
  277. void listFocusChanged(void);
  278. void goBack(void);
  279. void loadConfig(void);
  280. bool saveConfig(void);
  281. void saveConfigAs(void);
  282. void searchConfig(void);
  283. void showSingleView(void);
  284. void showSplitView(void);
  285. void showFullView(void);
  286. void showIntro(void);
  287. void showAbout(void);
  288. void saveSettings(void);
  289. protected:
  290. void closeEvent(QCloseEvent *e);
  291. ConfigSearchWindow *searchWindow;
  292. ConfigView *menuView;
  293. ConfigList *menuList;
  294. ConfigView *configView;
  295. ConfigList *configList;
  296. ConfigInfoView *helpText;
  297. Q3ToolBar *toolBar;
  298. Q3Action *backAction;
  299. QSplitter* split1;
  300. QSplitter* split2;
  301. };