Debian Codegraph @

HercConfiguration/Configuration.h

raw symbols SCIP
1 /*
2 * File: Configuration.h
3 *
4 * Author: Jacob Dekel
5 * Created on: Aug 7, 2009
6 *
7 * Copyright (c) 2009-2013 Jacob Dekel
8 * $Id$
9 *
10 * This object manages the Hercules configuration
11 *
12 * This program is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 *
25 */
26
27 #ifndef CONFIGURATION_H
28 #define CONFIGURATION_H
29
30 #include "ConfigFile.h"
31 #include "HerculesStudio.h"
32 #include "ConfigurationEditor.h"
33 #include "DevicesWidget.h"
34
35 #include "ui_Configuration.h"
36
37 #include <QSyntaxHighlighter>
38 #include <QtWidgets/QDialog>
39
40 struct ConfigTableEntry
41 {
42 std::string keyword;
43 void (*populator)(Ui::ConfigurationClass *, const ConfigLine *, ConfigurationEditor::Direction dir);
44 };
45
46 class Configuration : public QDialog
47 {
48 Q_OBJECT
49
50 public:
51 Configuration(ConfigFile* confignFile, bool newConfig = false, QWidget *parent = 0);
52 virtual ~Configuration();
53
54 class DoubleDigitSpinBox : public QSpinBox
55 {
56 public:
57 DoubleDigitSpinBox(QWidget * parent = 0, bool appendPlus=false);
58 protected:
59 virtual int valueFromText(const QString& text) const;
60 virtual QString textFromValue(int value) const;
61 private:
62 bool mAppendPlus;
63 };
64
65 class HexSpinBox : public QSpinBox
66 {
67 public:
68 HexSpinBox(QWidget * parent = 0);
69 virtual QString textFromValue(int value) const;
70 protected:
71 virtual int valueFromText(const QString& text) const;
72 QValidator::State validate(QString & input, int & pos) const;
73 };
74
75 protected:
76 virtual void resizeEvent ( QResizeEvent * event );
77
78 private:
79 Ui::ConfigurationClass ui;
80 DevicesWidget * mDevWgt;
81 QPlainTextEdit * mFreeEdit;
82 QSyntaxHighlighter * mSyntaxHighlighter;
83 QWidget * mParent;
84 ConfigFile * mConfigFile;
85 bool mNewConfig;
86 bool mChanged; // text changed since last validation
87 bool mTimerSet; // validation timer was set
88
89 int mCurrTab;
90 int mLastSys; // updated by blockCountChanged()
91 static struct ConfigTableEntry mConfigTable[];
92 friend class ConfigHighlight;
93
94 void initilize();
95 void populate(ConfigurationEditor::Direction);
96 void handleHighlight(const ConfigLine& configLine, QTextCursor& cursor, QTextCharFormat& format);
97
98 signals:
99 void OKSignal();
100
101 private slots:
102 void okPressed();
103 void cancelPressed();
104 void autoMountBrowsePressed();
105 void autoScsiMountChanged();
106 void cpuPrioChanged(int);
107 void devPrioChanged(int);
108 void hercPrioChanged(int);
109 void todPrioChanged(int);
110 void ecpSvmChanged(int);
111 void httpPortChanged(int);
112 void httpRootBrowsePressed();
113 void modPathBrowsePressed();
114 void tabChanged(int);
115 void blockCountChangedSlot();
116 };
117
118 class ConfigHighlight : public QSyntaxHighlighter
119 {
120 Q_OBJECT
121 public:
122 ConfigHighlight(QWidget * parent);
123
124 protected:
125 void highlightBlock(const QString &text);
126
127 private:
128 QDialog mDummyConfig;
129 Ui::ConfigurationClass mDummyUi;
130 QColor mGreen;
131 QColor mRed;
132 QColor mBlack;
133 QColor mBlue;
134 QColor mGray;
135
136 };
137
138 #endif // CONFIGURATION_H