editaddressdialog.h raw

   1  // Copyright (c) 2011-present The Bitcoin 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 BITCOIN_QT_EDITADDRESSDIALOG_H
   6  #define BITCOIN_QT_EDITADDRESSDIALOG_H
   7  
   8  #include <QDialog>
   9  
  10  class AddressTableModel;
  11  
  12  namespace Ui {
  13      class EditAddressDialog;
  14  }
  15  
  16  QT_BEGIN_NAMESPACE
  17  class QDataWidgetMapper;
  18  QT_END_NAMESPACE
  19  
  20  /** Dialog for editing an address and associated information.
  21   */
  22  class EditAddressDialog : public QDialog
  23  {
  24      Q_OBJECT
  25  
  26  public:
  27      enum Mode {
  28          NewSendingAddress,
  29          EditReceivingAddress,
  30          EditSendingAddress
  31      };
  32  
  33      explicit EditAddressDialog(Mode mode, QWidget *parent = nullptr);
  34      ~EditAddressDialog();
  35  
  36      void setModel(AddressTableModel *model);
  37      void loadRow(int row);
  38  
  39      QString getAddress() const;
  40      void setAddress(const QString &address);
  41  
  42  public Q_SLOTS:
  43      void accept() override;
  44  
  45  private:
  46      bool saveCurrentRow();
  47  
  48      /** Return a descriptive string when adding an already-existing address fails. */
  49      QString getDuplicateAddressWarning() const;
  50  
  51      Ui::EditAddressDialog *ui;
  52      QDataWidgetMapper* mapper{nullptr};
  53      Mode mode;
  54      AddressTableModel* model{nullptr};
  55  
  56      QString address;
  57  };
  58  
  59  #endif // BITCOIN_QT_EDITADDRESSDIALOG_H
  60