Line data Source code
1 : // Copyright (c) 2011-2013 The Bitcoin Core developers
2 : // Distributed under the MIT software license, see the accompanying
3 : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 :
5 : #ifndef BITCOIN_QT_OPTIONSMODEL_H
6 : #define BITCOIN_QT_OPTIONSMODEL_H
7 :
8 : #include "amount.h"
9 :
10 : #include <QAbstractListModel>
11 :
12 : QT_BEGIN_NAMESPACE
13 : class QNetworkProxy;
14 : QT_END_NAMESPACE
15 :
16 : /** Interface from Qt to configuration data structure for Bitcoin client.
17 : To Qt, the options are presented as a list with the different options
18 : laid out vertically.
19 : This can be changed to a tree once the settings become sufficiently
20 : complex.
21 : */
22 1 : class OptionsModel : public QAbstractListModel
23 : {
24 : Q_OBJECT
25 :
26 : public:
27 : explicit OptionsModel(QObject *parent = 0);
28 :
29 : enum OptionID {
30 : StartAtStartup, // bool
31 : MinimizeToTray, // bool
32 : MapPortUPnP, // bool
33 : MinimizeOnClose, // bool
34 : ProxyUse, // bool
35 : ProxyIP, // QString
36 : ProxyPort, // int
37 : ProxyUseTor, // bool
38 : ProxyIPTor, // QString
39 : ProxyPortTor, // int
40 : DisplayUnit, // BitcoinUnits::Unit
41 : ThirdPartyTxUrls, // QString
42 : Language, // QString
43 : CoinControlFeatures, // bool
44 : ThreadsScriptVerif, // int
45 : DatabaseCache, // int
46 : SpendZeroConfChange, // bool
47 : Listen, // bool
48 : OptionIDRowCount,
49 : };
50 :
51 : void Init();
52 : void Reset();
53 :
54 : int rowCount(const QModelIndex & parent = QModelIndex()) const;
55 : QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
56 : bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
57 : /** Updates current unit in memory, settings and emits displayUnitChanged(newUnit) signal */
58 : void setDisplayUnit(const QVariant &value);
59 :
60 : /* Explicit getters */
61 0 : bool getMinimizeToTray() { return fMinimizeToTray; }
62 0 : bool getMinimizeOnClose() { return fMinimizeOnClose; }
63 0 : int getDisplayUnit() { return nDisplayUnit; }
64 0 : QString getThirdPartyTxUrls() { return strThirdPartyTxUrls; }
65 : bool getProxySettings(QNetworkProxy& proxy) const;
66 0 : bool getCoinControlFeatures() { return fCoinControlFeatures; }
67 0 : const QString& getOverriddenByCommandLine() { return strOverriddenByCommandLine; }
68 :
69 : /* Restart flag helper */
70 : void setRestartRequired(bool fRequired);
71 : bool isRestartRequired();
72 :
73 : private:
74 : /* Qt-only settings */
75 : bool fMinimizeToTray;
76 : bool fMinimizeOnClose;
77 : QString language;
78 : int nDisplayUnit;
79 : QString strThirdPartyTxUrls;
80 : bool fCoinControlFeatures;
81 : /* settings that were overriden by command-line */
82 : QString strOverriddenByCommandLine;
83 :
84 : /// Add option to list of GUI options overridden through command line/config file
85 : void addOverriddenOption(const std::string &option);
86 :
87 : Q_SIGNALS:
88 : void displayUnitChanged(int unit);
89 : void coinControlFeaturesChanged(bool);
90 : };
91 :
92 : #endif // BITCOIN_QT_OPTIONSMODEL_H
|