Dogecoin Core  1.14.2
P2P Digital Currency
optionsmodel.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2016 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 
22 class OptionsModel : public QAbstractListModel
23 {
24  Q_OBJECT
25 
26 public:
27  explicit OptionsModel(QObject *parent = 0, bool resetSettings = false);
28 
29  enum OptionID {
30  StartAtStartup, // bool
31  HideTrayIcon, // bool
32  MinimizeToTray, // bool
33  MapPortUPnP, // bool
34  MinimizeOnClose, // bool
35  ProxyUse, // bool
36  ProxyIP, // QString
37  ProxyPort, // int
38  ProxyUseTor, // bool
39  ProxyIPTor, // QString
40  ProxyPortTor, // int
41  DisplayUnit, // BitcoinUnits::Unit
42  ThirdPartyTxUrls, // QString
43  Language, // QString
46  DatabaseCache, // int
48  Listen, // bool
50  };
51 
52  void Init(bool resetSettings = false);
53  void Reset();
54 
55  int rowCount(const QModelIndex & parent = QModelIndex()) const;
56  QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
57  bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
59  void setDisplayUnit(const QVariant &value);
60 
61  /* Explicit getters */
62  bool getHideTrayIcon() { return fHideTrayIcon; }
65  int getDisplayUnit() { return nDisplayUnit; }
67  bool getProxySettings(QNetworkProxy& proxy) const;
70 
71  /* Restart flag helper */
72  void setRestartRequired(bool fRequired);
73  bool isRestartRequired();
74 
75 private:
76  /* Qt-only settings */
80  QString language;
84  /* settings that were overridden by command-line */
86 
87  // Add option to list of GUI options overridden through command line/config file
88  void addOverriddenOption(const std::string &option);
89 
90  // Check settings version and upgrade default values if required
91  void checkAndMigrate();
92 Q_SIGNALS:
93  void displayUnitChanged(int unit);
95  void hideTrayIconChanged(bool);
96 };
97 
98 #endif // BITCOIN_QT_OPTIONSMODEL_H
Interface from Qt to configuration data structure for Bitcoin client.
Definition: optionsmodel.h:23
QString strOverriddenByCommandLine
Definition: optionsmodel.h:85
bool getProxySettings(QNetworkProxy &proxy) const
bool getHideTrayIcon()
Definition: optionsmodel.h:62
void Init(bool resetSettings=false)
bool fCoinControlFeatures
Definition: optionsmodel.h:83
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
int getDisplayUnit()
Definition: optionsmodel.h:65
void setDisplayUnit(const QVariant &value)
Updates current unit in memory, settings and emits displayUnitChanged(newUnit) signal.
void coinControlFeaturesChanged(bool)
QString strThirdPartyTxUrls
Definition: optionsmodel.h:82
QString getThirdPartyTxUrls()
Definition: optionsmodel.h:66
bool isRestartRequired()
void displayUnitChanged(int unit)
bool getMinimizeOnClose()
Definition: optionsmodel.h:64
bool fHideTrayIcon
Definition: optionsmodel.h:77
bool fMinimizeToTray
Definition: optionsmodel.h:78
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
const QString & getOverriddenByCommandLine()
Definition: optionsmodel.h:69
int rowCount(const QModelIndex &parent=QModelIndex()) const
bool getCoinControlFeatures()
Definition: optionsmodel.h:68
OptionsModel(QObject *parent=0, bool resetSettings=false)
void checkAndMigrate()
QString language
Definition: optionsmodel.h:80
void addOverriddenOption(const std::string &option)
bool getMinimizeToTray()
Definition: optionsmodel.h:63
bool fMinimizeOnClose
Definition: optionsmodel.h:79
void setRestartRequired(bool fRequired)
void hideTrayIconChanged(bool)