optionsmodel.h 2.39 KB
Newer Older
1
2
3
4
// Copyright (c) 2011-2013 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

5
6
7
8
9
#ifndef OPTIONSMODEL_H
#define OPTIONSMODEL_H

#include <QAbstractListModel>

10
11
/** Interface from Qt to configuration data structure for Bitcoin client.
   To Qt, the options are presented as a list with the different options
12
13
14
15
   laid out vertically.
   This can be changed to a tree once the settings become sufficiently
   complex.
 */
16
17
18
class OptionsModel : public QAbstractListModel
{
    Q_OBJECT
Philip Kaufmann's avatar
Philip Kaufmann committed
19

20
public:
Gavin Andresen's avatar
Gavin Andresen committed
21
    explicit OptionsModel(QObject *parent = 0);
22
23

    enum OptionID {
24
25
26
27
28
29
30
31
32
33
34
35
36
        StartAtStartup,         // bool
        MinimizeToTray,         // bool
        MapPortUPnP,            // bool
        MinimizeOnClose,        // bool
        ProxyUse,               // bool
        ProxyIP,                // QString
        ProxyPort,              // int
        ProxySocksVersion,      // int
        Fee,                    // qint64
        DisplayUnit,            // BitcoinUnits::Unit
        DisplayAddresses,       // bool
        Language,               // QString
        CoinControlFeatures,    // bool
37
        OptionIDRowCount,
38
39
    };

Gavin Andresen's avatar
Gavin Andresen committed
40
    void Init();
41
    void Reset();
Gavin Andresen's avatar
Gavin Andresen committed
42
43
44
45

    /* Migrate settings from wallet.dat after app initialization */
    bool Upgrade(); /* returns true if settings upgraded */

46
47
48
49
    int rowCount(const QModelIndex & parent = QModelIndex()) const;
    QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
    bool setData(const QModelIndex & index, const QVariant & value, int role = Qt::EditRole);

50
51
    /* Explicit getters */
    qint64 getTransactionFee();
52
53
54
55
    bool getMinimizeToTray() { return fMinimizeToTray; }
    bool getMinimizeOnClose() { return fMinimizeOnClose; }
    int getDisplayUnit() { return nDisplayUnit; }
    bool getDisplayAddresses() { return bDisplayAddresses; }
56
    QString getLanguage() { return language; }
57
    bool getProxySettings(QString& proxyIP, quint16 &proxyPort) const;
58
    bool getCoinControlFeatures() { return fCoinControlFeatures; }
Philip Kaufmann's avatar
Philip Kaufmann committed
59

60
private:
61
    int nDisplayUnit;
62
    bool bDisplayAddresses;
Gavin Andresen's avatar
Gavin Andresen committed
63
64
    bool fMinimizeToTray;
    bool fMinimizeOnClose;
65
    QString language;
Cozz Lovan's avatar
Cozz Lovan committed
66
    bool fCoinControlFeatures;
Philip Kaufmann's avatar
Philip Kaufmann committed
67

68
signals:
69
    void displayUnitChanged(int unit);
Cozz Lovan's avatar
Cozz Lovan committed
70
71
    void transactionFeeChanged(qint64);
    void coinControlFeaturesChanged(bool);
72
73
74
};

#endif // OPTIONSMODEL_H