Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
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 <qt/guiconstants.h>
9
10#include <QAbstractListModel>
11
12#include <cassert>
13#include <cstdint>
14
15namespace interfaces {
16class Node;
17}
18
20class QNetworkProxy;
22
23extern const char *DEFAULT_GUI_PROXY_HOST;
24static constexpr uint16_t DEFAULT_GUI_PROXY_PORT = 9050;
25
30static inline int PruneMiBtoGB(int64_t mib) {
31 return (mib * 1024 * 1024 + GB_BYTES - 1) / GB_BYTES;
32}
33
38static inline int64_t PruneGBtoMiB(int gb) {
39 return gb * GB_BYTES / 1024 / 1024;
40}
41
48class OptionsModel : public QAbstractListModel {
50
51public:
52 explicit OptionsModel(QObject *parent = nullptr,
53 bool resetSettings = false);
54
55 enum OptionID {
57 HideTrayIcon, // bool
59 MapPortUPnP, // bool
62 ProxyUse, // bool
63 ProxyIP, // QString
64 ProxyPort, // int
65 ProxyUseTor, // bool
66 ProxyIPTor, // QString
68 DisplayUnit, // BitcoinUnits::Unit
69 ThirdPartyTxUrls, // QString
70 Language, // QString
73 Prune, // bool
74 PruneSize, // int
77 Listen, // bool
79 };
80
81 void Init(bool resetSettings = false);
82 void Reset();
83
84 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
85 QVariant data(const QModelIndex &index,
86 int role = Qt::DisplayRole) const override;
87 bool setData(const QModelIndex &index, const QVariant &value,
88 int role = Qt::EditRole) override;
91 void setDisplayUnit(const QVariant &value);
92
93 /* Explicit getters */
94 bool getHideTrayIcon() const { return fHideTrayIcon; }
95 bool getMinimizeToTray() const { return fMinimizeToTray; }
96 bool getMinimizeOnClose() const { return fMinimizeOnClose; }
97 int getDisplayUnit() const { return nDisplayUnit; }
99 bool getProxySettings(QNetworkProxy &proxy) const;
104
105 /* Explicit setters */
106 void SetPruneEnabled(bool prune, bool force = false);
107 void SetPruneTargetGB(int prune_target_gb, bool force = false);
108
109 /* Restart flag helper */
110 void setRestartRequired(bool fRequired);
111 bool isRestartRequired() const;
112
114 assert(m_node);
115 return *m_node;
116 }
118 assert(!m_node);
119 m_node = &node;
120 }
121
122private:
124 /* Qt-only settings */
132 /* settings that were overridden by command-line */
134
135 // Add option to list of GUI options overridden through command line/config
136 // file
137 void addOverriddenOption(const std::string &option);
138
139 // Check settings version and upgrade default values if required
140 void checkAndMigrate();
142 void displayUnitChanged(int unit);
145};
146
147#endif // BITCOIN_QT_OPTIONSMODEL_H
Interface from Qt to configuration data structure for Bitcoin client.
int getDisplayUnit() const
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
QString strOverriddenByCommandLine
bool getProxySettings(QNetworkProxy &proxy) const
bool isRestartRequired() const
void Init(bool resetSettings=false)
bool getCoinControlFeatures() const
bool fCoinControlFeatures
interfaces::Node * m_node
interfaces::Node & node() const
void setDisplayUnit(const QVariant &value)
Updates current unit in memory, settings and emits displayUnitChanged(newUnit) signal.
void coinControlFeaturesChanged(bool)
QString strThirdPartyTxUrls
int rowCount(const QModelIndex &parent=QModelIndex()) const override
void SetPruneTargetGB(int prune_target_gb, bool force=false)
void SetPruneEnabled(bool prune, bool force=false)
void displayUnitChanged(int unit)
bool getMinimizeToTray() const
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
const QString & getOverriddenByCommandLine()
bool getMinimizeOnClose() const
void setNode(interfaces::Node &node)
QString getThirdPartyTxUrls() const
void checkAndMigrate()
bool getHideTrayIcon() const
QString language
void addOverriddenOption(const std::string &option)
bool fMinimizeOnClose
void setRestartRequired(bool fRequired)
void hideTrayIconChanged(bool)
Top-level interface for a bitcoin node (bitcoind process).
Definition node.h:59
static constexpr uint64_t GB_BYTES
Definition init.h:28
static int PruneMiBtoGB(int64_t mib)
Convert configured prune target MiB to displayed GB.
static int64_t PruneGBtoMiB(int gb)
Convert displayed prune target GB to configured MiB.
QT_END_NAMESPACE const char * DEFAULT_GUI_PROXY_HOST
static constexpr uint16_t DEFAULT_GUI_PROXY_PORT
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition random.h:85
assert(!tx.IsCoinBase())