2 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
3 * Released under the terms of the GNU GPL v2.0.
6 #if QT_VERSION < 0x040000
9 #include <q3listview.h>
11 #include <qsettings.h>
13 #if QT_VERSION < 0x040000
14 #define Q3ValueList QValueList
15 #define Q3PopupMenu QPopupMenu
16 #define Q3ListView QListView
17 #define Q3ListViewItem QListViewItem
19 #define Q3TextBrowser QTextBrowser
20 #define Q3MainWindow QMainWindow
21 #define Q3Action QAction
22 #define Q3ToolBar QToolBar
23 #define Q3ListViewItemIterator QListViewItemIterator
24 #define Q3FileDialog QFileDialog
31 class ConfigMainWindow
;
33 class ConfigSettings
: public QSettings
{
36 Q3ValueList
<int> readSizes(const QString
& key
, bool *ok
);
37 bool writeSizes(const QString
& key
, const Q3ValueList
<int>& value
);
41 promptColIdx
, nameColIdx
, noColIdx
, modColIdx
, yesColIdx
, dataColIdx
, colNr
44 singleMode
, menuMode
, symbolMode
, fullMode
, listMode
47 normalOpt
= 0, allOpt
, promptOpt
50 class ConfigList
: public Q3ListView
{
52 typedef class Q3ListView Parent
;
54 ConfigList(ConfigView
* p
, const char *name
= 0);
56 ConfigView
* parent(void) const
58 return (ConfigView
*)Parent::parent();
60 ConfigItem
* findConfigItem(struct menu
*);
63 void keyPressEvent(QKeyEvent
*e
);
64 void contentsMousePressEvent(QMouseEvent
*e
);
65 void contentsMouseReleaseEvent(QMouseEvent
*e
);
66 void contentsMouseMoveEvent(QMouseEvent
*e
);
67 void contentsMouseDoubleClickEvent(QMouseEvent
*e
);
68 void focusInEvent(QFocusEvent
*e
);
69 void contextMenuEvent(QContextMenuEvent
*e
);
72 void setRootMenu(struct menu
*menu
);
74 void updateList(ConfigItem
*item
);
75 void setValue(ConfigItem
* item
, tristate val
);
76 void changeValue(ConfigItem
* item
);
77 void updateSelection(void);
78 void saveSettings(void);
80 void menuChanged(struct menu
*menu
);
81 void menuSelected(struct menu
*menu
);
82 void parentSelected(void);
83 void gotFocus(struct menu
*);
86 void updateListAll(void)
92 ConfigList
* listView()
96 ConfigItem
* firstChild() const
98 return (ConfigItem
*)Parent::firstChild();
100 int mapIdx(colIdx idx
)
104 void addColumn(colIdx idx
, const QString
& label
)
106 colMap
[idx
] = Parent::addColumn(label
);
107 colRevMap
[colMap
[idx
]] = idx
;
109 void removeColumn(colIdx idx
)
111 int col
= colMap
[idx
];
113 Parent::removeColumn(col
);
114 colRevMap
[col
] = colMap
[idx
] = -1;
117 void setAllOpen(bool open
);
118 void setParentMenu(void);
120 bool menuSkip(struct menu
*);
123 void updateMenuList(P
*, struct menu
*);
127 QPixmap symbolYesPix
, symbolModPix
, symbolNoPix
;
128 QPixmap choiceYesPix
, choiceNoPix
;
129 QPixmap menuPix
, menuInvPix
, menuBackPix
, voidPix
;
131 bool showName
, showRange
, showData
;
133 enum optionMode optMode
;
134 struct menu
*rootEntry
;
135 QColorGroup disabledColorGroup
;
136 QColorGroup inactivedColorGroup
;
137 Q3PopupMenu
* headerPopup
;
141 int colRevMap
[colNr
];
144 class ConfigItem
: public Q3ListViewItem
{
145 typedef class Q3ListViewItem Parent
;
147 ConfigItem(Q3ListView
*parent
, ConfigItem
*after
, struct menu
*m
, bool v
)
148 : Parent(parent
, after
), menu(m
), visible(v
), goParent(false)
152 ConfigItem(ConfigItem
*parent
, ConfigItem
*after
, struct menu
*m
, bool v
)
153 : Parent(parent
, after
), menu(m
), visible(v
), goParent(false)
157 ConfigItem(Q3ListView
*parent
, ConfigItem
*after
, bool v
)
158 : Parent(parent
, after
), menu(0), visible(v
), goParent(true)
164 void okRename(int col
);
165 void updateMenu(void);
166 void testUpdateMenu(bool v
);
167 ConfigList
* listView() const
169 return (ConfigList
*)Parent::listView();
171 ConfigItem
* firstChild() const
173 return (ConfigItem
*)Parent::firstChild();
175 ConfigItem
* nextSibling() const
177 return (ConfigItem
*)Parent::nextSibling();
179 void setText(colIdx idx
, const QString
& text
)
181 Parent::setText(listView()->mapIdx(idx
), text
);
183 QString
text(colIdx idx
) const
185 return Parent::text(listView()->mapIdx(idx
));
187 void setPixmap(colIdx idx
, const QPixmap
& pm
)
189 Parent::setPixmap(listView()->mapIdx(idx
), pm
);
191 const QPixmap
* pixmap(colIdx idx
) const
193 return Parent::pixmap(listView()->mapIdx(idx
));
195 void paintCell(QPainter
* p
, const QColorGroup
& cg
, int column
, int width
, int align
);
197 ConfigItem
* nextItem
;
203 class ConfigLineEdit
: public QLineEdit
{
205 typedef class QLineEdit Parent
;
207 ConfigLineEdit(ConfigView
* parent
);
208 ConfigView
* parent(void) const
210 return (ConfigView
*)Parent::parent();
212 void show(ConfigItem
*i
);
213 void keyPressEvent(QKeyEvent
*e
);
219 class ConfigView
: public Q3VBox
{
221 typedef class Q3VBox Parent
;
223 ConfigView(QWidget
* parent
, const char *name
= 0);
225 static void updateList(ConfigItem
* item
);
226 static void updateListAll(void);
228 bool showName(void) const { return list
->showName
; }
229 bool showRange(void) const { return list
->showRange
; }
230 bool showData(void) const { return list
->showData
; }
232 void setShowName(bool);
233 void setShowRange(bool);
234 void setShowData(bool);
235 void setOptionMode(QAction
*);
237 void showNameChanged(bool);
238 void showRangeChanged(bool);
239 void showDataChanged(bool);
242 ConfigLineEdit
* lineEdit
;
244 static ConfigView
* viewList
;
245 ConfigView
* nextView
;
247 static QAction
*showNormalAction
;
248 static QAction
*showAllAction
;
249 static QAction
*showPromptAction
;
252 class ConfigInfoView
: public Q3TextBrowser
{
254 typedef class Q3TextBrowser Parent
;
256 ConfigInfoView(QWidget
* parent
, const char *name
= 0);
257 bool showDebug(void) const { return _showDebug
; }
260 void setInfo(struct menu
*menu
);
261 void saveSettings(void);
262 void setShowDebug(bool);
265 void showDebugChanged(bool);
266 void menuSelected(struct menu
*);
269 void symbolInfo(void);
271 QString
debug_info(struct symbol
*sym
);
272 static QString
print_filter(const QString
&str
);
273 static void expr_print_help(void *data
, struct symbol
*sym
, const char *str
);
274 Q3PopupMenu
* createPopupMenu(const QPoint
& pos
);
275 void contentsContextMenuEvent(QContextMenuEvent
*e
);
282 class ConfigSearchWindow
: public QDialog
{
284 typedef class QDialog Parent
;
286 ConfigSearchWindow(ConfigMainWindow
* parent
, const char *name
= 0);
289 void saveSettings(void);
293 QLineEdit
* editField
;
294 QPushButton
* searchButton
;
297 ConfigInfoView
* info
;
299 struct symbol
**result
;
302 class ConfigMainWindow
: public Q3MainWindow
{
305 static Q3Action
*saveAction
;
306 static void conf_changed(void);
308 ConfigMainWindow(void);
310 void changeMenu(struct menu
*);
311 void setMenuLink(struct menu
*);
312 void listFocusChanged(void);
314 void loadConfig(void);
315 bool saveConfig(void);
316 void saveConfigAs(void);
317 void searchConfig(void);
318 void showSingleView(void);
319 void showSplitView(void);
320 void showFullView(void);
321 void showIntro(void);
322 void showAbout(void);
323 void saveSettings(void);
326 void closeEvent(QCloseEvent
*e
);
328 ConfigSearchWindow
*searchWindow
;
329 ConfigView
*menuView
;
330 ConfigList
*menuList
;
331 ConfigView
*configView
;
332 ConfigList
*configList
;
333 ConfigInfoView
*helpText
;
335 Q3Action
*backAction
;