-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbitcoinaddresstypes.cpp
More file actions
88 lines (78 loc) · 2.32 KB
/
bitcoinaddresstypes.cpp
File metadata and controls
88 lines (78 loc) · 2.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// Copyright (c) 2011-2018 The CleanCoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <qt/CleanCoinaddresstypes.h>
#include <QStringList>
CleanCoinAddressTypes::CleanCoinAddressTypes(QObject *parent):
QAbstractListModel(parent),
addressTypeList(availableAddressTypes())
{
}
QList<CleanCoinAddressTypes::AddressType> CleanCoinAddressTypes::availableAddressTypes()
{
QList<CleanCoinAddressTypes::AddressType> addressTypeList;
addressTypeList.append(LEGACY);
addressTypeList.append(NESTED_SEGWIT);
addressTypeList.append(NATIVE_SEGWIT);
return addressTypeList;
}
bool CleanCoinAddressTypes::valid(int addressType)
{
switch(addressType)
{
case LEGACY:
case NESTED_SEGWIT:
case NATIVE_SEGWIT:
return true;
default:
return false;
}
}
QString CleanCoinAddressTypes::longName(int addressType)
{
switch(addressType)
{
case LEGACY: return QString("Legacy");
case NESTED_SEGWIT: return QString("Nested Segwit");
case NATIVE_SEGWIT: return QString("Native Segwit");
default: return QString("???");
}
}
QString CleanCoinAddressTypes::shortName(int addressType)
{
return longName(addressType);
}
QString CleanCoinAddressTypes::description(int addressType)
{
switch(addressType)
{
case LEGACY: return QString("Legacy CleanCoin address. P2PKH");
case NESTED_SEGWIT: return QString("Nested Segwit address. P2SH");
case NATIVE_SEGWIT: return QString("Native Segwit address. P2WPKH");
default: return QString("???");
}
}
int CleanCoinAddressTypes::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent);
return addressTypeList.size();
}
QVariant CleanCoinAddressTypes::data(const QModelIndex &index, int role) const
{
int row = index.row();
if(row >= 0 && row < addressTypeList.size())
{
AddressType addressType = addressTypeList.at(row);
switch(role)
{
case Qt::EditRole:
case Qt::DisplayRole:
return QVariant(longName(addressType));
case Qt::ToolTipRole:
return QVariant(description(addressType));
case AddressTypeRole:
return QVariant(static_cast<int>(addressType));
}
}
return QVariant();
}