BSHA3  0.17.99
P2P Blockchain, based on Bitcoin
optionsmodel.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2018 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 namespace interfaces {
13 class Node;
14 }
15 
16 QT_BEGIN_NAMESPACE
17 class QNetworkProxy;
18 QT_END_NAMESPACE
19 
20 extern const char *DEFAULT_GUI_PROXY_HOST;
21 static constexpr unsigned short DEFAULT_GUI_PROXY_PORT = 9050;
22 
29 class OptionsModel : public QAbstractListModel
30 {
31  Q_OBJECT
32 
33 public:
34  explicit OptionsModel(interfaces::Node& node, QObject *parent = 0, bool resetSettings = false);
35 
36  enum OptionID {
37  StartAtStartup, // bool
38  HideTrayIcon, // bool
39  MinimizeToTray, // bool
40  MapPortUPnP, // bool
41  MinimizeOnClose, // bool
42  ProxyUse, // bool
43  ProxyIP, // QString
44  ProxyPort, // int
45  ProxyUseTor, // bool
46  ProxyIPTor, // QString
47  ProxyPortTor, // int
48  DisplayUnit, // BitcoinUnits::Unit
49  ThirdPartyTxUrls, // QString
50  Language, // QString
53  Prune, // bool
54  PruneSize, // int
55  DatabaseCache, // int
57  Listen, // bool
59  };
60 
61  void Init(bool resetSettings = false);
62  void Reset();
63 
64  int rowCount(const QModelIndex & parent = QModelIndex()) const;
65  QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
66  bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);
68  void setDisplayUnit(const QVariant &value);
69 
70  /* Explicit getters */
71  bool getHideTrayIcon() const { return fHideTrayIcon; }
72  bool getMinimizeToTray() const { return fMinimizeToTray; }
73  bool getMinimizeOnClose() const { return fMinimizeOnClose; }
74  int getDisplayUnit() const { return nDisplayUnit; }
75  QString getThirdPartyTxUrls() const { return strThirdPartyTxUrls; }
76  bool getProxySettings(QNetworkProxy& proxy) const;
79 
80  /* Restart flag helper */
81  void setRestartRequired(bool fRequired);
82  bool isRestartRequired() const;
83 
84  interfaces::Node& node() const { return m_node; }
85 
86 private:
88  /* Qt-only settings */
92  QString language;
96  /* settings that were overridden by command-line */
98 
99  // Add option to list of GUI options overridden through command line/config file
100  void addOverriddenOption(const std::string &option);
101 
102  // Check settings version and upgrade default values if required
103  void checkAndMigrate();
104 Q_SIGNALS:
105  void displayUnitChanged(int unit);
106  void coinControlFeaturesChanged(bool);
107  void hideTrayIconChanged(bool);
108 };
109 
110 #endif // BITCOIN_QT_OPTIONSMODEL_H
OptionsModel(interfaces::Node &node, QObject *parent=0, bool resetSettings=false)
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
void addOverriddenOption(const std::string &option)
void hideTrayIconChanged(bool)
bool getProxySettings(QNetworkProxy &proxy) const
const QString & getOverriddenByCommandLine()
Definition: optionsmodel.h:78
QString language
Definition: optionsmodel.h:92
void coinControlFeaturesChanged(bool)
bool fMinimizeOnClose
Definition: optionsmodel.h:91
int getDisplayUnit() const
Definition: optionsmodel.h:74
bool isRestartRequired() const
interfaces::Node & node() const
Definition: optionsmodel.h:84
interfaces::Node & m_node
Definition: optionsmodel.h:87
void setDisplayUnit(const QVariant &value)
Updates current unit in memory, settings and emits displayUnitChanged(newUnit) signal.
bool fHideTrayIcon
Definition: optionsmodel.h:89
bool fMinimizeToTray
Definition: optionsmodel.h:90
void Init(bool resetSettings=false)
void displayUnitChanged(int unit)
QString getThirdPartyTxUrls() const
Definition: optionsmodel.h:75
bool fCoinControlFeatures
Definition: optionsmodel.h:95
bool getCoinControlFeatures() const
Definition: optionsmodel.h:77
void checkAndMigrate()
bool getMinimizeOnClose() const
Definition: optionsmodel.h:73
QT_END_NAMESPACE const char * DEFAULT_GUI_PROXY_HOST
void setRestartRequired(bool fRequired)
Interface from Qt to configuration data structure for Bitcoin client.
Definition: optionsmodel.h:29
QString strThirdPartyTxUrls
Definition: optionsmodel.h:94
bool getMinimizeToTray() const
Definition: optionsmodel.h:72
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const
int rowCount(const QModelIndex &parent=QModelIndex()) const
Top-level interface for a bitcoin node (bsha3d process).
Definition: node.h:35
bool getHideTrayIcon() const
Definition: optionsmodel.h:71
QString strOverriddenByCommandLine
Definition: optionsmodel.h:97