Skip to content

Commit

Permalink
Proposal Monitor Section (#41)
Browse files Browse the repository at this point in the history
Proposals Monitor Section
  • Loading branch information
devfsc authored and alejandromgk committed Sep 4, 2018
1 parent da7175d commit bb8dbc5
Show file tree
Hide file tree
Showing 24 changed files with 1,406 additions and 5 deletions.
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 0)
define(_CLIENT_VERSION_MINOR, 12)
define(_CLIENT_VERSION_REVISION, 3)
define(_CLIENT_VERSION_BUILD, 1)
define(_CLIENT_VERSION_REVISION, 4)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2018)
AC_INIT([Paccoin Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[https://github.com/paccoinpay/paccoin/issues],[paccoincore])
Expand Down
20 changes: 19 additions & 1 deletion src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ QT_MOC_CPP = \
qt/moc_overviewpage.cpp \
qt/moc_peertablemodel.cpp \
qt/moc_paymentserver.cpp \
qt/moc_columnalignedlayout.cpp \
qt/moc_proposalfilterproxy.cpp \
qt/moc_proposaltablemodel.cpp \
qt/moc_proposallist.cpp \
qt/moc_qvalidatedlineedit.cpp \
qt/moc_qvaluecombobox.cpp \
qt/moc_receivecoinsdialog.cpp \
Expand Down Expand Up @@ -142,6 +146,11 @@ BITCOIN_QT_H = \
qt/paymentserver.h \
qt/peertablemodel.h \
qt/platformstyle.h \
qt/columnalignedlayout.h \
qt/proposalfilterproxy.h \
qt/proposallist.h \
qt/proposalrecord.h \
qt/proposaltablemodel.h \
qt/qvalidatedlineedit.h \
qt/qvaluecombobox.h \
qt/receivecoinsdialog.h \
Expand Down Expand Up @@ -226,6 +235,7 @@ RES_ICONS = \
qt/res/icons/drkblue/fontsmaller.png \
qt/res/icons/drkblue/transaction_abandoned.png \
qt/res/icons/drkblue/network_disabled.png \
qt/res/icons/drkblue/proposal.png \
qt/res/icons/crownium/add.png \
qt/res/icons/crownium/address-book.png \
qt/res/icons/crownium/browse.png \
Expand Down Expand Up @@ -280,6 +290,7 @@ RES_ICONS = \
qt/res/icons/crownium/fontsmaller.png \
qt/res/icons/crownium/transaction_abandoned.png \
qt/res/icons/crownium/network_disabled.png \
qt/res/icons/crownium/proposal.png \
qt/res/icons/light/add.png \
qt/res/icons/light/address-book.png \
qt/res/icons/light/browse.png \
Expand Down Expand Up @@ -334,6 +345,7 @@ RES_ICONS = \
qt/res/icons/light/fontsmaller.png \
qt/res/icons/light/transaction_abandoned.png \
qt/res/icons/light/network_disabled.png \
qt/res/icons/light/proposal.png \
qt/res/icons/trad/add.png \
qt/res/icons/trad/address-book.png \
qt/res/icons/trad/browse.png \
Expand Down Expand Up @@ -387,7 +399,8 @@ RES_ICONS = \
qt/res/icons/trad/fontbigger.png \
qt/res/icons/trad/fontsmaller.png \
qt/res/icons/trad/transaction_abandoned.png \
qt/res/icons/trad/network_disabled.png
qt/res/icons/trad/network_disabled.png \
qt/res/icons/trad/proposal.png

BITCOIN_QT_CPP = \
qt/bantablemodel.cpp \
Expand Down Expand Up @@ -432,6 +445,11 @@ BITCOIN_QT_CPP += \
qt/overviewpage.cpp \
qt/paymentrequestplus.cpp \
qt/paymentserver.cpp \
qt/columnalignedlayout.cpp \
qt/proposalfilterproxy.cpp \
qt/proposallist.cpp \
qt/proposalrecord.cpp \
qt/proposaltablemodel.cpp \
qt/receivecoinsdialog.cpp \
qt/receiverequestdialog.cpp \
qt/recentrequeststablemodel.cpp \
Expand Down
4 changes: 2 additions & 2 deletions src/clientversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
//! These need to be macros, as clientversion.cpp's and paccoin*-res.rc's voodoo requires it
#define CLIENT_VERSION_MAJOR 0
#define CLIENT_VERSION_MINOR 12
#define CLIENT_VERSION_REVISION 3
#define CLIENT_VERSION_BUILD 1
#define CLIENT_VERSION_REVISION 4
#define CLIENT_VERSION_BUILD 0

//! Set to true for release, false for prerelease or test build
#define CLIENT_VERSION_IS_RELEASE true
Expand Down
22 changes: 22 additions & 0 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *platformStyle, const NetworkStyle *n
overviewAction(0),
historyAction(0),
masternodeAction(0),
proposalAction(0),
quitAction(0),
sendCoinsAction(0),
sendCoinsMenuAction(0),
Expand Down Expand Up @@ -354,6 +355,17 @@ void BitcoinGUI::createActions()
connect(masternodeAction, SIGNAL(triggered()), this, SLOT(gotoMasternodePage()));
}

proposalAction = new QAction(QIcon(":/icons/" + theme + "/proposal"), tr("&Proposals"), this);
proposalAction->setStatusTip(tr("Browse proposals"));
proposalAction->setToolTip(proposalAction->statusTip());
proposalAction->setCheckable(true);
#ifdef Q_OS_MAC
proposalAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_6));
#else
proposalAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_6));
#endif
tabGroup->addAction(proposalAction);

// These showNormalIfMinimized are needed because Send Coins and Receive Coins
// can be triggered from the tray menu, and need to show the GUI to be useful.
connect(overviewAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
Expand All @@ -368,6 +380,8 @@ void BitcoinGUI::createActions()
connect(receiveCoinsMenuAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage()));
connect(historyAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage()));
connect(proposalAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(proposalAction, SIGNAL(triggered()), this, SLOT(gotoProposalPage()));
#endif // ENABLE_WALLET

quitAction = new QAction(QIcon(":/icons/" + theme + "/quit"), tr("E&xit"), this);
Expand Down Expand Up @@ -573,6 +587,7 @@ void BitcoinGUI::createToolBars()
{
toolbar->addAction(masternodeAction);
}
toolbar->addAction(proposalAction);
toolbar->setMovable(false); // remove unused icon in upper left corner
overviewAction->setChecked(true);

Expand Down Expand Up @@ -713,6 +728,7 @@ void BitcoinGUI::setWalletActionsEnabled(bool enabled)
receiveCoinsAction->setEnabled(enabled);
receiveCoinsMenuAction->setEnabled(enabled);
historyAction->setEnabled(enabled);
proposalAction->setEnabled(enabled);
QSettings settings;
if (settings.value("fShowMasternodesTab").toBool() && masternodeAction) {
masternodeAction->setEnabled(enabled);
Expand Down Expand Up @@ -892,6 +908,12 @@ void BitcoinGUI::gotoMasternodePage()
}
}

void BitcoinGUI::gotoProposalPage()
{
proposalAction->setChecked(true);
if (walletFrame) walletFrame->gotoProposalPage();
}

void BitcoinGUI::gotoReceiveCoinsPage()
{
receiveCoinsAction->setChecked(true);
Expand Down
4 changes: 4 additions & 0 deletions src/qt/bitcoingui.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class WalletModel;
class HelpMessageDialog;
class ModalOverlay;
class MasternodeList;
class ProposalList;

class CWallet;

Expand Down Expand Up @@ -97,6 +98,7 @@ class BitcoinGUI : public QMainWindow
QAction *overviewAction;
QAction *historyAction;
QAction *masternodeAction;
QAction *proposalAction;
QAction *quitAction;
QAction *sendCoinsAction;
QAction *sendCoinsMenuAction;
Expand Down Expand Up @@ -219,6 +221,8 @@ private Q_SLOTS:
void gotoHistoryPage();
/** Switch to masternode page */
void gotoMasternodePage();
/** Switch to proposal page */
void gotoProposalPage();
/** Switch to receive coins page */
void gotoReceiveCoinsPage();
/** Switch to send coins page */
Expand Down
38 changes: 38 additions & 0 deletions src/qt/columnalignedlayout.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include "columnalignedlayout.h"
#include <QHeaderView>

ColumnAlignedLayout::ColumnAlignedLayout()
: QHBoxLayout()
{

}

ColumnAlignedLayout::ColumnAlignedLayout(QWidget *parent)
: QHBoxLayout(parent)
{

}

void ColumnAlignedLayout::setGeometry(const QRect &r)
{
QHBoxLayout::setGeometry(r);

if (!headerView) {
return;
}

int widgetX = parentWidget()->mapToGlobal(QPoint(0, 0)).x();
int headerX = headerView->mapToGlobal(QPoint(0, 0)).x();
int delta = headerX - widgetX;

for (int ii = 0; ii < headerView->count(); ++ii) {
int pos = headerView->sectionViewportPosition(ii);
int size = headerView->sectionSize(ii);

auto item = itemAt(ii);
auto r = item->geometry();
r.setLeft(pos + delta);
r.setWidth(size);
item->setGeometry(r);
}
}
21 changes: 21 additions & 0 deletions src/qt/columnalignedlayout.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef COLUMNALIGNEDLAYOUT_H
#define COLUMNALIGNEDLAYOUT_H

#include <QHBoxLayout>

class QHeaderView;

class ColumnAlignedLayout : public QHBoxLayout
{
Q_OBJECT
public:
ColumnAlignedLayout();
explicit ColumnAlignedLayout(QWidget *parent);
void setTableColumnsToTrack(QHeaderView *view) { headerView = view; }

private:
void setGeometry(const QRect &r);
QHeaderView *headerView;
};

#endif // COLUMNALIGNEDLAYOUT_H
4 changes: 4 additions & 0 deletions src/qt/paccoin.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<file alias="eye_plus">res/icons/drkblue/eye_plus.png</file>
<file alias="options">res/icons/drkblue/configure.png</file>
<file alias="receiving_addresses">res/icons/drkblue/receive.png</file>
<file alias="proposal">res/icons/drkblue/proposal.png</file>
<file alias="editpaste">res/icons/drkblue/editpaste.png</file>
<file alias="editcopy">res/icons/drkblue/editcopy.png</file>
<file alias="add">res/icons/drkblue/add.png</file>
Expand Down Expand Up @@ -82,6 +83,7 @@
<file alias="eye_plus">res/icons/crownium/eye_plus.png</file>
<file alias="options">res/icons/crownium/configure.png</file>
<file alias="receiving_addresses">res/icons/crownium/receive.png</file>
<file alias="proposal">res/icons/crownium/proposal.png</file>
<file alias="editpaste">res/icons/crownium/editpaste.png</file>
<file alias="editcopy">res/icons/crownium/editcopy.png</file>
<file alias="add">res/icons/crownium/add.png</file>
Expand Down Expand Up @@ -138,6 +140,7 @@
<file alias="eye_plus">res/icons/light/eye_plus.png</file>
<file alias="options">res/icons/light/configure.png</file>
<file alias="receiving_addresses">res/icons/light/receive.png</file>
<file alias="proposal">res/icons/light/proposal.png</file>
<file alias="editpaste">res/icons/light/editpaste.png</file>
<file alias="editcopy">res/icons/light/editcopy.png</file>
<file alias="add">res/icons/light/add.png</file>
Expand Down Expand Up @@ -194,6 +197,7 @@
<file alias="eye_plus">res/icons/trad/eye_plus.png</file>
<file alias="options">res/icons/trad/configure.png</file>
<file alias="receiving_addresses">res/icons/trad/receive.png</file>
<file alias="proposal">res/icons/trad/proposal.png</file>
<file alias="editpaste">res/icons/trad/editpaste.png</file>
<file alias="editcopy">res/icons/trad/editcopy.png</file>
<file alias="add">res/icons/trad/add.png</file>
Expand Down
112 changes: 112 additions & 0 deletions src/qt/proposalfilterproxy.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// Copyright (c) 2011-2013 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include "proposalfilterproxy.h"
#include "proposaltablemodel.h"

#include <cstdlib>

#include <QDateTime>

const QDateTime ProposalFilterProxy::MIN_DATE = QDateTime::fromTime_t(0);
const QDateTime ProposalFilterProxy::MAX_DATE = QDateTime::fromTime_t(0xFFFFFFFF);

ProposalFilterProxy::ProposalFilterProxy(QObject *parent) :
QSortFilterProxyModel(parent),
startDate(MIN_DATE),
endDate(MAX_DATE),
proposalName(),
minAmount(0),
minPercentage(-100),
minYesVotes(0),
minNoVotes(0),
minAbsoluteYesVotes(INT_MIN)
{
}

bool ProposalFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
{
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);

int proposalStartDate = index.data(ProposalTableModel::StartDateRole).toInt();
int proposalEndDate = index.data(ProposalTableModel::EndDateRole).toInt();
QString propName = index.data(ProposalTableModel::ProposalRole).toString();
qint64 amount = llabs(index.data(ProposalTableModel::AmountRole).toLongLong());
int yesVotes = index.data(ProposalTableModel::YesVotesRole).toInt();
int noVotes = index.data(ProposalTableModel::NoVotesRole).toInt();
int absoluteYesVotes = index.data(ProposalTableModel::AbsoluteYesVotesRole).toInt();
int percentage = index.data(ProposalTableModel::PercentageRole).toInt();

if(proposalStartDate < (startDate.toMSecsSinceEpoch() / 1000))
return false;
if(proposalEndDate > (endDate.toMSecsSinceEpoch() / 1000))
return false;
if(!propName.contains(proposalName, Qt::CaseInsensitive))
return false;
if(amount < minAmount)
return false;
if(yesVotes < minYesVotes)
return false;
if(noVotes < minNoVotes)
return false;
if(absoluteYesVotes < minAbsoluteYesVotes)
return false;
if(percentage < minPercentage)
return false;

return true;
}

void ProposalFilterProxy::setProposalStart(const QDateTime &date)
{
this->startDate = date;
invalidateFilter();
}

void ProposalFilterProxy::setProposalEnd(const QDateTime &date)
{
this->endDate = date;
invalidateFilter();
}

void ProposalFilterProxy::setProposal(const QString &proposal)
{
this->proposalName = proposal;
invalidateFilter();
}

void ProposalFilterProxy::setMinAmount(const CAmount& minimum)
{
this->minAmount = minimum;
invalidateFilter();
}

void ProposalFilterProxy::setMinPercentage(const CAmount& minimum)
{
this->minPercentage = minimum;
invalidateFilter();
}

void ProposalFilterProxy::setMinYesVotes(const CAmount& minimum)
{
this->minYesVotes = minimum;
invalidateFilter();
}

void ProposalFilterProxy::setMinNoVotes(const CAmount& minimum)
{
this->minNoVotes = minimum;
invalidateFilter();
}

void ProposalFilterProxy::setMinAbsoluteYesVotes(const CAmount& minimum)
{
this->minAbsoluteYesVotes = minimum;
invalidateFilter();
}

int ProposalFilterProxy::rowCount(const QModelIndex &parent) const
{
return QSortFilterProxyModel::rowCount(parent);
}
Loading

0 comments on commit bb8dbc5

Please sign in to comment.