18 : QAbstractTableModel(parent), walletModel(parent) {
20 std::vector<std::string> vReceiveRequests;
22 for (
const std::string &request : vReceiveRequests) {
55 if (role == Qt::DisplayRole || role == Qt::EditRole) {
57 switch (
index.column()) {
62 return tr(
"(no label)");
68 role == Qt::DisplayRole) {
69 return tr(
"(no message)");
75 role == Qt::DisplayRole) {
76 return tr(
"(no amount requested)");
77 }
else if (role == Qt::EditRole) {
88 }
else if (role == Qt::TextAlignmentRole) {
90 return (
int)(Qt::AlignRight | Qt::AlignVCenter);
97 const QVariant &value,
int role) {
102 Qt::Orientation orientation,
104 if (orientation == Qt::Horizontal) {
105 if (role == Qt::DisplayRole && section <
columns.size()) {
116 Q_EMIT headerDataChanged(Qt::Horizontal,
Amount,
Amount);
123 ? tr(
"Requested") +
" (" +
132 const QModelIndex &parent)
const {
135 return createIndex(row, column);
139 const QModelIndex &parent) {
143 for (
int i = 0; i <
count; ++i) {
151 beginRemoveRows(parent, row, row +
count - 1);
161 return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
169 newEntry.
date = QDateTime::currentDateTime();
176 newEntry.
id, ss.
str())) {
185 std::vector<uint8_t>
data(recipient.begin(), recipient.end());
205 beginInsertRows(QModelIndex(), 0, 0);
206 list.prepend(recipient);
214 index(0, 0, QModelIndex()),
226 if (
order == Qt::DescendingOrder) {
227 std::swap(pLeft, pRight);
232 return pLeft->
date.toTime_t() < pRight->
date.toTime_t();
240 return pLeft->
id < pRight->
id;
static QString format(int unit, const Amount amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD, bool justify=false)
Format as string.
static QString shortName(int unit)
Short name.
Double ended buffer combining vector and stream-like interfaces.
int getDisplayUnit() const
void displayUnitChanged(int unit)
SendCoinsRecipient recipient
bool operator()(const RecentRequestEntry &left, const RecentRequestEntry &right) const
bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex()) override
QVariant headerData(int section, Qt::Orientation orientation, int role) const override
bool setData(const QModelIndex &index, const QVariant &value, int role) override
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
QVariant data(const QModelIndex &index, int role) const override
const RecentRequestEntry & entry(int row) const
~RecentRequestsTableModel()
void sort(int column, Qt::SortOrder order=Qt::AscendingOrder) override
QList< RecentRequestEntry > list
int rowCount(const QModelIndex &parent) const override
void updateAmountColumnTitle()
Updates the column title to "Amount (DisplayUnit)" and emits headerDataChanged() signal for table hea...
QString getAmountTitle()
Gets title for amount column including current display unit if optionsModel reference available.
WalletModel * walletModel
Qt::ItemFlags flags(const QModelIndex &index) const override
void addNewRequest(const SendCoinsRecipient &recipient)
RecentRequestsTableModel(WalletModel *parent)
int64_t nReceiveRequestsMaxId
int columnCount(const QModelIndex &parent) const override
Interface to Bitcoin wallet from Qt view code.
void loadReceiveRequests(std::vector< std::string > &vReceiveRequests)
bool saveReceiveRequest(const std::string &sAddress, const int64_t nId, const std::string &sRequest)
OptionsModel * getOptionsModel()
static constexpr int CLIENT_VERSION
bitcoind-res.rc includes this file, but it cannot cope with real c++ code.
QString dateTimeStr(const QDateTime &date)
static constexpr Amount zero() noexcept