forked from gridcoin-community/Gridcoin-Research
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
afaa766
commit a22ecfc
Showing
6 changed files
with
268 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
// Copyright (c) 2014-2023 The Gridcoin developers | ||
// Distributed under the MIT/X11 software license, see the accompanying | ||
// file COPYING or https://opensource.org/licenses/mit-license.php. | ||
|
||
#include "editsidestakedialog.h" | ||
#include "ui_editsidestakedialog.h" | ||
#include "sidestaketablemodel.h" | ||
#include "guiutil.h" | ||
#include "qt/decoration.h" | ||
|
||
#include <QDataWidgetMapper> | ||
#include <QMessageBox> | ||
|
||
EditSideStakeDialog::EditSideStakeDialog(Mode mode, QWidget* parent) | ||
: QDialog(parent) | ||
, ui(new Ui::EditSideStakeDialog) | ||
, mapper(nullptr) | ||
, mode(mode) | ||
, model(nullptr) | ||
{ | ||
ui->setupUi(this); | ||
|
||
resize(GRC::ScaleSize(this, width(), height())); | ||
|
||
//GUIUtil::setupAddressWidget(ui->addressEdit, this); | ||
|
||
switch(mode) | ||
{ | ||
case NewSideStake: | ||
setWindowTitle(tr("New SideStake")); | ||
//ui->addressEdit->setEnabled(false); | ||
break; | ||
case EditSideStake: | ||
setWindowTitle(tr("Edit SideStake")); | ||
//ui->addressEdit->setEnabled(false); | ||
break; | ||
} | ||
assert(false); | ||
|
||
mapper = new QDataWidgetMapper(this); | ||
mapper->setSubmitPolicy(QDataWidgetMapper::ManualSubmit); | ||
} | ||
|
||
EditSideStakeDialog::~EditSideStakeDialog() | ||
{ | ||
delete ui; | ||
} | ||
|
||
void EditSideStakeDialog::setModel(SideStakeTableModel *model) | ||
{ | ||
this->model = model; | ||
if (!model) { | ||
return; | ||
} | ||
|
||
//mapper->setModel(model); | ||
//mapper->addMapping(ui->labelEdit, AddressTableModel::Label); | ||
//mapper->addMapping(ui->addressEdit, AddressTableModel::Address); | ||
} | ||
|
||
void EditSideStakeDialog::loadRow(int row) | ||
{ | ||
mapper->setCurrentIndex(row); | ||
} | ||
|
||
bool EditSideStakeDialog::saveCurrentRow() | ||
{ | ||
if(!model) | ||
return false; | ||
|
||
switch(mode) | ||
{ | ||
case NewSideStake: | ||
break; | ||
case EditSideStake: | ||
break; | ||
} | ||
return false; | ||
} | ||
|
||
void EditSideStakeDialog::accept() | ||
{ | ||
if (!model) { | ||
return; | ||
} | ||
|
||
/* | ||
if(!saveCurrentRow()) | ||
{ | ||
switch(model->getEditStatus()) | ||
{ | ||
case AddressTableModel::OK: | ||
// Failed with unknown reason. Just reject. | ||
break; | ||
case AddressTableModel::NO_CHANGES: | ||
// No changes were made during edit operation. Just reject. | ||
break; | ||
case AddressTableModel::INVALID_ADDRESS: | ||
QMessageBox::warning(this, windowTitle(), | ||
tr("The entered address \"%1\" is not a valid Gridcoin address.").arg(ui->addressEdit->text()), | ||
QMessageBox::Ok, QMessageBox::Ok); | ||
break; | ||
case AddressTableModel::DUPLICATE_ADDRESS: | ||
QMessageBox::warning(this, windowTitle(), | ||
tr("The entered address \"%1\" is already in the address book.").arg(ui->addressEdit->text()), | ||
QMessageBox::Ok, QMessageBox::Ok); | ||
break; | ||
case AddressTableModel::WALLET_UNLOCK_FAILURE: | ||
QMessageBox::critical(this, windowTitle(), | ||
tr("Could not unlock wallet."), | ||
QMessageBox::Ok, QMessageBox::Ok); | ||
break; | ||
case AddressTableModel::KEY_GENERATION_FAILURE: | ||
QMessageBox::critical(this, windowTitle(), | ||
tr("New key generation failed."), | ||
QMessageBox::Ok, QMessageBox::Ok); | ||
break; | ||
} | ||
return; | ||
} | ||
*/ | ||
|
||
QDialog::accept(); | ||
} | ||
|
||
/* | ||
QString EditSideStakeDialog::getAddress() const | ||
{ | ||
return address; | ||
} | ||
void EditSideStakeDialog::setAddress(const QString &address) | ||
{ | ||
this->address = address; | ||
ui->addressEdit->setText(address); | ||
} | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright (c) 2014-2023 The Gridcoin developers | ||
// Distributed under the MIT/X11 software license, see the accompanying | ||
// file COPYING or https://opensource.org/licenses/mit-license.php. | ||
|
||
#ifndef BITCOIN_QT_EDITSIDESTAKEDIALOG_H | ||
#define BITCOIN_QT_EDITSIDESTAKEDIALOG_H | ||
|
||
#include <QDialog> | ||
|
||
QT_BEGIN_NAMESPACE | ||
class QDataWidgetMapper; | ||
QT_END_NAMESPACE | ||
|
||
namespace Ui { | ||
class EditSideStakeDialog; | ||
} | ||
class SideStakeTableModel; | ||
|
||
/** Dialog for editing an address and associated information. | ||
*/ | ||
class EditSideStakeDialog : public QDialog | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
enum Mode { | ||
NewSideStake, | ||
EditSideStake | ||
}; | ||
|
||
explicit EditSideStakeDialog(Mode mode, QWidget* parent = nullptr); | ||
~EditSideStakeDialog(); | ||
|
||
void setModel(SideStakeTableModel *model); | ||
void loadRow(int row); | ||
|
||
//QString getAddress() const; | ||
//void setAddress(const QString &address); | ||
|
||
public slots: | ||
void accept(); | ||
|
||
private: | ||
bool saveCurrentRow(); | ||
|
||
Ui::EditSideStakeDialog *ui; | ||
QDataWidgetMapper *mapper; | ||
Mode mode; | ||
SideStakeTableModel *model; | ||
|
||
QString address; | ||
}; | ||
#endif // BITCOIN_QT_EDITSIDESTAKEDIALOG_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>EditSideStakeDialog</class> | ||
<widget class="QDialog" name="EditSideStakeDialog"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>400</width> | ||
<height>300</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Dialog</string> | ||
</property> | ||
<widget class="QDialogButtonBox" name="buttonBox"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>30</x> | ||
<y>240</y> | ||
<width>341</width> | ||
<height>32</height> | ||
</rect> | ||
</property> | ||
<property name="orientation"> | ||
<enum>Qt::Horizontal</enum> | ||
</property> | ||
<property name="standardButtons"> | ||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> | ||
</property> | ||
</widget> | ||
</widget> | ||
<resources/> | ||
<connections> | ||
<connection> | ||
<sender>buttonBox</sender> | ||
<signal>accepted()</signal> | ||
<receiver>EditSideStakeDialog</receiver> | ||
<slot>accept()</slot> | ||
<hints> | ||
<hint type="sourcelabel"> | ||
<x>248</x> | ||
<y>254</y> | ||
</hint> | ||
<hint type="destinationlabel"> | ||
<x>157</x> | ||
<y>274</y> | ||
</hint> | ||
</hints> | ||
</connection> | ||
<connection> | ||
<sender>buttonBox</sender> | ||
<signal>rejected()</signal> | ||
<receiver>EditSideStakeDialog</receiver> | ||
<slot>reject()</slot> | ||
<hints> | ||
<hint type="sourcelabel"> | ||
<x>316</x> | ||
<y>260</y> | ||
</hint> | ||
<hint type="destinationlabel"> | ||
<x>286</x> | ||
<y>274</y> | ||
</hint> | ||
</hints> | ||
</connection> | ||
</connections> | ||
</ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters