Wladimir J. van der Laan
14 years ago
11 changed files with 179 additions and 20 deletions
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
#ifndef OPTIONSMODEL_H |
||||
#define OPTIONSMODEL_H |
||||
|
||||
#include <QAbstractListModel> |
||||
|
||||
class OptionsModel : public QAbstractListModel |
||||
{ |
||||
Q_OBJECT |
||||
public: |
||||
explicit OptionsModel(QObject *parent = 0); |
||||
|
||||
enum OptionID { |
||||
StartAtStartup, |
||||
MinimizeToTray, |
||||
MapPortUPnP, |
||||
MinimizeOnClose, |
||||
ConnectSOCKS4, |
||||
ProxyIP, |
||||
ProxyPort, |
||||
Fee, |
||||
OptionIDRowCount |
||||
}; |
||||
|
||||
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); |
||||
|
||||
signals: |
||||
|
||||
public slots: |
||||
|
||||
}; |
||||
|
||||
#endif // OPTIONSMODEL_H
|
@ -0,0 +1,52 @@
@@ -0,0 +1,52 @@
|
||||
#include "optionsmodel.h" |
||||
#include "main.h" |
||||
|
||||
#include <QDebug> |
||||
|
||||
OptionsModel::OptionsModel(QObject *parent) : |
||||
QAbstractListModel(parent) |
||||
{ |
||||
} |
||||
|
||||
int OptionsModel::rowCount(const QModelIndex & parent) const |
||||
{ |
||||
return OptionIDRowCount; |
||||
} |
||||
|
||||
QVariant OptionsModel::data(const QModelIndex & index, int role) const |
||||
{ |
||||
qDebug() << "OptionsModel::data" << " " << index.row() << " " << role; |
||||
if(role == Qt::EditRole) |
||||
{ |
||||
/* Delegate to specific column handlers */ |
||||
switch(index.row()) |
||||
{ |
||||
case StartAtStartup: |
||||
return QVariant(); |
||||
case MinimizeToTray: |
||||
return QVariant(fMinimizeToTray); |
||||
case MapPortUPnP: |
||||
return QVariant(fUseUPnP); |
||||
case MinimizeOnClose: |
||||
return QVariant(fMinimizeOnClose); |
||||
case ConnectSOCKS4: |
||||
return QVariant(fUseProxy); |
||||
case ProxyIP: |
||||
return QVariant(QString::fromStdString(addrProxy.ToStringIP())); |
||||
case ProxyPort: |
||||
return QVariant(QString::fromStdString(addrProxy.ToStringPort())); |
||||
case Fee: |
||||
return QVariant(QString::fromStdString(FormatMoney(nTransactionFee))); |
||||
default: |
||||
return QVariant(); |
||||
} |
||||
} |
||||
return QVariant(); |
||||
} |
||||
|
||||
bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, int role) |
||||
{ |
||||
qDebug() << "OptionsModel::setData" << " " << index.row() << "=" << value; |
||||
emit dataChanged(index, index); |
||||
return true; |
||||
} |
Loading…
Reference in new issue