Skip to content

Commit

Permalink
EditSideStakeDialog (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescowens committed Oct 6, 2023
1 parent afaa766 commit a22ecfc
Show file tree
Hide file tree
Showing 6 changed files with 268 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ QT_FORMS_UI = \
qt/forms/consolidateunspentwizardsendpage.ui \
qt/forms/diagnosticsdialog.ui \
qt/forms/editaddressdialog.ui \
qt/forms/editsidestakedialog.ui \
qt/forms/favoritespage.ui \
qt/forms/intro.ui \
qt/forms/mrcrequestpage.ui \
Expand Down Expand Up @@ -143,6 +144,7 @@ QT_MOC_CPP = \
qt/moc_csvmodelwriter.cpp \
qt/moc_diagnosticsdialog.cpp \
qt/moc_editaddressdialog.cpp \
qt/moc_editsidestakedialog.cpp \
qt/moc_favoritespage.cpp \
qt/moc_guiutil.cpp \
qt/moc_intro.cpp \
Expand Down Expand Up @@ -250,6 +252,7 @@ GRIDCOINRESEARCH_QT_H = \
qt/decoration.h \
qt/diagnosticsdialog.h \
qt/editaddressdialog.h \
qt/editsidestakedialog.h \
qt/favoritespage.h \
qt/guiconstants.h \
qt/guiutil.h \
Expand Down Expand Up @@ -342,6 +345,7 @@ GRIDCOINRESEARCH_QT_CPP = \
qt/decoration.cpp \
qt/diagnosticsdialog.cpp \
qt/editaddressdialog.cpp \
qt/editsidestakedialog.cpp \
qt/favoritespage.cpp \
qt/guiutil.cpp \
qt/intro.cpp \
Expand Down
1 change: 1 addition & 0 deletions src/qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ add_library(gridcoinqt STATIC
decoration.cpp
diagnosticsdialog.cpp
editaddressdialog.cpp
editsidestakedialog.cpp
favoritespage.cpp
guiutil.cpp
intro.cpp
Expand Down
138 changes: 138 additions & 0 deletions src/qt/editsidestakedialog.cpp
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);
}
*/
53 changes: 53 additions & 0 deletions src/qt/editsidestakedialog.h
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
68 changes: 68 additions & 0 deletions src/qt/forms/editsidestakedialog.ui
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>
4 changes: 4 additions & 0 deletions src/qt/optionsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,10 @@ void OptionsDialog::on_applyButton_clicked()

void OptionsDialog::newSideStakeButton_clicked()
{
if (!model) {
return;
}


}

Expand Down

0 comments on commit a22ecfc

Please sign in to comment.