Browse Source

Make singleton

recurring
adityapk00 5 years ago
parent
commit
4aa63a3db2
  1. 5
      src/recurring.cpp
  2. 11
      src/recurring.h
  3. 5
      src/sendtab.cpp

5
src/recurring.cpp

@ -108,4 +108,7 @@ QDateTime Recurring::getNextPaymentDate(Schedule s) {
return nextDate;
}
}
// Singleton
Recurring* Recurring::instance = nullptr;

11
src/recurring.h

@ -37,12 +37,15 @@ struct RecurringPaymentInfo {
class Recurring
{
public:
Recurring() = default;
static Recurring* getInstance() { if (!instance) { instance = new Recurring(); } return instance; }
static RecurringPaymentInfo* getNewRecurringFromTx(QWidget* parent, MainWindow* main, Tx tx, RecurringPaymentInfo* rpi);
RecurringPaymentInfo* getNewRecurringFromTx(QWidget* parent, MainWindow* main, Tx tx, RecurringPaymentInfo* rpi);
static QDateTime getNextPaymentDate(Schedule s);
static void updateInfoWithTx(RecurringPaymentInfo* r, Tx tx);
QDateTime getNextPaymentDate(Schedule s);
void updateInfoWithTx(RecurringPaymentInfo* r, Tx tx);
private:
Recurring() = default;
static Recurring* instance;
};

5
src/sendtab.cpp

@ -103,7 +103,8 @@ void MainWindow::setupSendTab() {
void MainWindow::editSchedule() {
// Open the edit schedule dialog
RecurringPaymentInfo* recurringInfo = Recurring::getNewRecurringFromTx(this, this, createTxFromSendPage(), this->sendTxRecurringInfo);
RecurringPaymentInfo* recurringInfo = Recurring::getInstance()->getNewRecurringFromTx(this, this,
createTxFromSendPage(), this->sendTxRecurringInfo);
if (recurringInfo == nullptr) {
}
@ -505,7 +506,7 @@ bool MainWindow::confirmTx(Tx tx, RecurringPaymentInfo* rpi) {
// Update the recurring info with the latest Tx
if (rpi != nullptr) {
Recurring::updateInfoWithTx(rpi, tx);
Recurring::getInstance()->updateInfoWithTx(rpi, tx);
}
// Show a confirmation dialog

Loading…
Cancel
Save