Skip to content

Commit

Permalink
Refine TXHistoryDialog includes
Browse files Browse the repository at this point in the history
 - add destructor
 - remove unused members
 - remove unused headers
 - forward declare classes
 - sort headers
 - ...
  • Loading branch information
dexX7 committed May 18, 2015
1 parent 52c9d0f commit bffaeb0
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 94 deletions.
105 changes: 45 additions & 60 deletions src/qt/txhistorydialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,70 +5,56 @@
#include "txhistorydialog.h"
#include "ui_txhistorydialog.h"

#include "omnicore_qtutils.h"

#include "clientmodel.h"
#include "guiutil.h"
#include "optionsmodel.h"
#include "walletmodel.h"

#include "mastercore.h"
#include "mastercore_rpc.h"
#include "mastercore_sp.h"
#include "mastercore_tx.h"
#include "omnicore_pending.h"

#include "init.h"
#include "main.h"
#include "primitives/transaction.h"
#include "sync.h"
#include "txdb.h"
#include "uint256.h"
#include "wallet.h"
#include "base58.h"
#include "ui_interface.h"
#include "walletmodel.h"

#include <boost/filesystem.hpp>

#include "leveldb/db.h"
#include "leveldb/write_batch.h"
#include "json/json_spirit_value.h"
#include "json/json_spirit_writer_template.h"

// potentially overzealous includes here
#include "base58.h"
#include "rpcserver.h"
#include "init.h"
#include "util.h"
#include <fstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <string>
#include <boost/assign/list_of.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/find.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/format.hpp>
#include <boost/filesystem.hpp>
#include "json/json_spirit_utils.h"
#include "json/json_spirit_value.h"
#include "leveldb/db.h"
#include "leveldb/write_batch.h"
// end potentially overzealous includes

using namespace json_spirit;
#include "mastercore.h"
using namespace mastercore;

// potentially overzealous using here
using namespace std;
using namespace boost;
using namespace boost::assign;
using namespace leveldb;
// end potentially overzealous using

#include "mastercore_dex.h"
#include "mastercore_tx.h"
#include "mastercore_sp.h"
#include "mastercore_rpc.h"
#include "mastercore_parse_string.h"
#include "omnicore_qtutils.h"
#include <stdint.h>
#include <list>
#include <map>
#include <string>
#include <vector>

#include <QAbstractItemModel>
#include <QAction>
#include <QDateTime>
#include <QMessageBox>
#include <QScrollBar>
#include <QTextDocument>
#include <QListWidget>
#include <QDialog>
#include <QHeaderView>
#include <QIcon>
#include <QMenu>
#include <QTextEdit>
#include <QModelIndex>
#include <QPoint>
#include <QResizeEvent>
#include <QSortFilterProxyModel>
#include <QString>
#include <QTableWidgetItem>
#include <QWidget>

using std::string;
using namespace json_spirit;
using namespace mastercore;

TXHistoryDialog::TXHistoryDialog(QWidget *parent) :
QDialog(parent),
Expand All @@ -77,7 +63,6 @@ TXHistoryDialog::TXHistoryDialog(QWidget *parent) :
walletModel(0)
{
ui->setupUi(this);
this->walletModel = walletModel;
// setup
ui->txHistoryTable->setColumnCount(7);
ui->txHistoryTable->setHorizontalHeaderItem(2, new QTableWidgetItem(" "));
Expand Down Expand Up @@ -145,6 +130,11 @@ TXHistoryDialog::TXHistoryDialog(QWidget *parent) :

}

TXHistoryDialog::~TXHistoryDialog()
{
delete ui;
}

void TXHistoryDialog::setClientModel(ClientModel *model)
{
this->clientModel = model;
Expand Down Expand Up @@ -209,7 +199,7 @@ int TXHistoryDialog::PopulateHistoryMap()
// STO has no inbound transaction, so we need to use an insert methodology here - get STO receipts affecting me
string mySTOReceipts = s_stolistdb->getMySTOReceipts("");
std::vector<std::string> vecReceipts;
boost::split(vecReceipts, mySTOReceipts, boost::is_any_of(","), token_compress_on);
boost::split(vecReceipts, mySTOReceipts, boost::is_any_of(","), boost::token_compress_on);
int64_t lastTXBlock = 999999; // set artificially high initially until first wallet tx is processed
// iterate through wallet entries backwards
std::list<CAccountingEntry> acentries;
Expand Down Expand Up @@ -244,15 +234,15 @@ int TXHistoryDialog::PopulateHistoryMap()
uint256 blockHash = 0;
if (!GetTransaction(hash, wtx, blockHash, true)) continue;
blockHash = pwtx->hashBlock;
if ((0 == blockHash) || (NULL == mapBlockIndex[blockHash])) continue;
CBlockIndex* pBlockIndex = mapBlockIndex[blockHash];
if ((0 == blockHash) || (NULL == GetBlockIndex(blockHash))) continue;
CBlockIndex* pBlockIndex = GetBlockIndex(blockHash);
if (NULL == pBlockIndex) continue;
int blockHeight = pBlockIndex->nHeight; // get the height of the transaction

// ### START STO INSERTION CHECK ###
for(uint32_t i = 0; i<vecReceipts.size(); i++) {
std::vector<std::string> svstr;
boost::split(svstr, vecReceipts[i], boost::is_any_of(":"), token_compress_on);
boost::split(svstr, vecReceipts[i], boost::is_any_of(":"), boost::token_compress_on);
if(4 == svstr.size()) // make sure expected num items
{
if((atoi(svstr[1]) < lastTXBlock) && (atoi(svstr[1]) > blockHeight))
Expand Down Expand Up @@ -570,11 +560,6 @@ void TXHistoryDialog::showDetails()
}
}

void TXHistoryDialog::accept()
{

}

void TXHistoryDialog::resizeEvent(QResizeEvent* event)
{
QWidget::resizeEvent(event);
Expand Down
48 changes: 14 additions & 34 deletions src/qt/txhistorydialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@
#include "guiutil.h"
#include "uint256.h"

#include <map>

#include <QDialog>
#include <QString>
#include <QTableWidget>
#include <QTextEdit>
#include <QDialogButtonBox>
#include <QPushButton>

class ClientModel;
class OptionsModel;
class WalletModel;

QT_BEGIN_NAMESPACE
class QUrl;
class QMenu;
class QModelIndex;
class QPoint;
class QResizeEvent;
class QString;
class QWidget;
QT_END_NAMESPACE

namespace Ui {
Expand Down Expand Up @@ -49,46 +50,25 @@ class TXHistoryDialog : public QDialog
Q_OBJECT

public:
//void FullRefresh();
explicit TXHistoryDialog(QWidget *parent = 0);
~TXHistoryDialog();

void setClientModel(ClientModel *model);
void setWalletModel(WalletModel *model);

void accept();
/** Set up the tab chain manually, as Qt messes up the tab chain by default in some cases (issue https://bugreports.qt-project.org/browse/QTBUG-10907).
*/
QDialog *txDlg;
QWidget *setupTabChain(QWidget *prev);
QTableWidgetItem *iconCell;
QTableWidgetItem *dateCell;
QTableWidgetItem *typeCell;
QTableWidgetItem *amountCell;
QTableWidgetItem *addressCell;
QTableWidgetItem *txidCell;
QTableWidgetItem *sortKeyCell;
QLayout *dlgLayout;
QTextEdit *dlgTextEdit;
QDialogButtonBox *buttonBox;
QPushButton *closeButton;

GUIUtil::TableViewLastColumnResizingFixer *borrowedColumnResizingFixer;

virtual void resizeEvent(QResizeEvent* event);

HistoryMap txHistoryMap;
std::string shrinkTxType(int txType, bool *fundsMoved);

public slots:
//void switchButtonClicked();

private:
Ui::txHistoryDialog *ui;
ClientModel *clientModel;
WalletModel *walletModel;
GUIUtil::TableViewLastColumnResizingFixer *borrowedColumnResizingFixer;
QMenu *contextMenu;
HistoryMap txHistoryMap;

private slots:
void contextualMenu(const QPoint &);
void contextualMenu(const QPoint &point);
void showDetails();
void copyAddress();
void copyAmount();
Expand All @@ -99,7 +79,7 @@ private slots:
void checkSort(int column);

signals:
void doubleClicked(const QModelIndex&);
void doubleClicked(const QModelIndex& idx);
// Fired when a message should be reported to the user
void message(const QString &title, const QString &message, unsigned int style);
};
Expand Down

0 comments on commit bffaeb0

Please sign in to comment.