PIVX Core  5.6.99
P2P Digital Currency
coldstakingwidget.h
Go to the documentation of this file.
1 // Copyright (c) 2019-2021 The PIVX 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 PIVX_QT_COLDSTAKINGWIDGET_H
6 #define PIVX_QT_COLDSTAKINGWIDGET_H
7 
9 #include "addressholder.h"
10 #include "addresstablemodel.h"
11 #include "coincontroldialog.h"
12 #include "coldstakingmodel.h"
13 #include "contactsdropdown.h"
15 #include "pwidget.h"
16 #include "sendmultirow.h"
17 #include "tooltipmenu.h"
18 #include "transactiontablemodel.h"
19 #include "txviewholder.h"
20 
21 #include <QAction>
22 #include <QLabel>
23 #include <QWidget>
24 #include <QSpacerItem>
25 #include <atomic>
26 
27 class PIVXGUI;
28 class WalletModel;
29 class CSDelegationHolder;
30 
31 namespace Ui {
32 class ColdStakingWidget;
33 }
34 
35 QT_BEGIN_NAMESPACE
36 class QModelIndex;
37 QT_END_NAMESPACE
38 
39 class ColdStakingWidget : public PWidget
40 {
41  Q_OBJECT
42 
43 public:
44  explicit ColdStakingWidget(PIVXGUI* parent);
46 
47  void loadWalletModel() override;
48  void run(int type) override;
49  void onError(QString error, int type) override;
50 
51  void showEvent(QShowEvent *event) override;
52 
53 public Q_SLOTS:
54  void walletSynced(bool sync);
55 
56 private Q_SLOTS:
57  void changeTheme(bool isLightTheme, QString &theme) override;
58  void handleAddressClicked(const QModelIndex &index);
59  void handleMyColdAddressClicked(const QModelIndex &rIndex);
60  void onCoinControlClicked();
61  void onColdStakeClicked();
62  void updateDisplayUnit();
63  void showList(bool show);
64  void onSendClicked();
65  void onDelegateSelected(bool delegate);
66  void onEditClicked();
67  void onDeleteClicked();
68  void onCopyClicked();
69  void onCopyOwnerClicked();
70  void onAddressCopyClicked();
71  void onAddressEditClicked();
72  void onTxArrived(const QString& hash, const bool isCoinStake, const bool isMNReward, const bool isCSAnyType);
73  void onContactsClicked(bool ownerAdd);
74  void clearAll();
75  void onLabelClicked();
77  void onOwnerAddressChanged();
79  void onSortChanged(int idx);
80  void onSortOrderChanged(int idx);
81  void filterChanged(const QString& str);
82 
83 private:
84  Ui::ColdStakingWidget *ui = nullptr;
94  QAction *btnOwnerContact = nullptr;
95  QSpacerItem *spacerDiv = nullptr;
96 
97  bool isInDelegation = true;
99 
101  TooltipMenu* menu = nullptr;
104  bool isShowingDialog = false;
105  bool isChainSync = false;
106 
108  int64_t lastRefreshTime{0};
109  std::atomic<bool> isLoading;
110 
111  // Cached index
112  QModelIndex index;
113  QModelIndex addressIndex;
114 
115  // Cached sort type and order
117  Qt::SortOrder sortOrder = Qt::AscendingOrder;
118 
119  int nDisplayUnit{0};
120 
121  void showAddressGenerationDialog(bool isPaymentRequest);
122  void onContactsClicked();
123  void tryRefreshDelegations();
124  bool refreshDelegations();
125  void onLabelClicked(QString dialogTitle, const QModelIndex &index, const bool isMyColdStakingAddresses);
127  void sortAddresses();
129 };
130 
131 #endif // PIVX_QT_COLDSTAKINGWIDGET_H
Qt model of the address book in the core.
@ Label
User specified label.
void onSortOrderChanged(int idx)
void showAddressGenerationDialog(bool isPaymentRequest)
std::atomic< bool > isLoading
Qt::SortOrder sortOrder
AddressTableModel * addressTableModel
void run(int type) override
void onDelegateSelected(bool delegate)
FurAbstractListItemDelegate * addressDelegate
AddressHolder * addressHolder
TooltipMenu * menuAddresses
CoinControlDialog * coinControlDialog
TransactionTableModel * txModel
SendMultiRow * sendMultiRow
void onTxArrived(const QString &hash, const bool isCoinStake, const bool isMNReward, const bool isCSAnyType)
void handleMyColdAddressClicked(const QModelIndex &rIndex)
ColdStakingModel * csModel
AddressFilterProxyModel * addressesFilter
void loadWalletModel() override
void onError(QString error, int type) override
ContactsDropdown * menuContacts
void onSortChanged(int idx)
void walletSynced(bool sync)
QSpacerItem * spacerDiv
AddressTableModel::ColumnIndex sortType
CSDelegationHolder * txHolder
Ui::ColdStakingWidget * ui
void changeTheme(bool isLightTheme, QString &theme) override
void filterChanged(const QString &str)
ColdStakingWidget(PIVXGUI *parent)
void showList(bool show)
void showEvent(QShowEvent *event) override
FurAbstractListItemDelegate * delegate
void handleAddressClicked(const QModelIndex &index)
QModelIndex addressIndex
PIVX GUI main class.
Definition: pivxgui.h:46
UI model for the transaction table of a wallet.
Interface to PIVX wallet from Qt view code.
Definition: walletmodel.h:109
bool isLightTheme()
Definition: qtutils.cpp:210
bool error(const char *fmt, const Args &... args)
Definition: system.h:77