forked from dashpay/dash
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
24 changed files
with
1,406 additions
and
5 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
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,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); | ||
} | ||
} |
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,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 |
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,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); | ||
} |
Oops, something went wrong.