diff --git a/BitcoinGUI.cpp b/BitcoinGUI.cpp index b18a18b8..0b81f72f 100644 --- a/BitcoinGUI.cpp +++ b/BitcoinGUI.cpp @@ -2,6 +2,7 @@ * W.J. van der Laan 2011 */ #include "BitcoinGUI.h" +#include "TransactionTableModel.h" #include #include @@ -27,7 +28,6 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): setWindowTitle("Bitcoin"); setWindowIcon(QIcon("bitcoin.png")); - QAction *quit = new QAction(QIcon("quit.png"), "&Quit", this); QAction *sendcoins = new QAction(QIcon("send.png"), "&Send coins", this); QAction *addressbook = new QAction(QIcon("address-book.png"), "&Address book", this); @@ -53,13 +53,13 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): /* Address:
: New... : Paste to clipboard */ QHBoxLayout *hbox_address = new QHBoxLayout(); - hbox_address->addWidget(new QLabel("Your Bitcoin Address:")); + hbox_address->addWidget(new QLabel(tr("Your Bitcoin Address:"))); QLineEdit *edit_address = new QLineEdit(); edit_address->setReadOnly(true); hbox_address->addWidget(edit_address); QPushButton *button_new = new QPushButton(trUtf8("&New\u2026")); - QPushButton *button_clipboard = new QPushButton("&Copy to clipboard"); + QPushButton *button_clipboard = new QPushButton(tr("&Copy to clipboard")); hbox_address->addWidget(button_new); hbox_address->addWidget(button_clipboard); @@ -80,12 +80,14 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): /* Transaction table: * TransactionView * TransactionModel - * Selection behaviour + * Selection behavior * selection mode * QAbstractItemView::SelectItems * QAbstractItemView::ExtendedSelection */ QTableView *transaction_table = new QTableView(this); + TransactionTableModel *transaction_model = new TransactionTableModel(this); + transaction_table->setModel(transaction_model); QTabBar *tabs = new QTabBar(this); tabs->addTab("All transactions"); diff --git a/TransactionTableModel.cpp b/TransactionTableModel.cpp new file mode 100644 index 00000000..0f352960 --- /dev/null +++ b/TransactionTableModel.cpp @@ -0,0 +1,53 @@ +#include "TransactionTableModel.h" + +TransactionTableModel::TransactionTableModel(QObject *parent): + QAbstractTableModel(parent) +{ + columns << "Status" << "Date" << "Description" << "Debit" << "Credit"; +} + +int TransactionTableModel::rowCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + return 5; +} + +int TransactionTableModel::columnCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent); + return columns.length(); +} + +QVariant TransactionTableModel::data(const QModelIndex &index, int role) const +{ + if(!index.isValid()) + return QVariant(); + + if(role == Qt::DisplayRole) + { + /* index.row(), index.column() */ + /* Return QString */ + return QString("test"); + } + return QVariant(); +} + +QVariant TransactionTableModel::headerData(int section, Qt::Orientation orientation, int role) const +{ + if(role != Qt::DisplayRole) + return QVariant(); + + if(orientation == Qt::Horizontal) + { + return columns[section]; + } + return QVariant(); +} + +Qt::ItemFlags TransactionTableModel::flags(const QModelIndex &index) const +{ + if (!index.isValid()) + return Qt::ItemIsEnabled; + + return QAbstractTableModel::flags(index); +} diff --git a/TransactionTableModel.h b/TransactionTableModel.h new file mode 100644 index 00000000..9071ed66 --- /dev/null +++ b/TransactionTableModel.h @@ -0,0 +1,23 @@ +#ifndef H_TRANSACTIONTABLEMODEL +#define H_TRANSACTIONTABLEMODEL + +#include +#include + +class TransactionTableModel : public QAbstractTableModel +{ + Q_OBJECT +public: + TransactionTableModel(QObject *parent = 0); + + int rowCount(const QModelIndex &parent) const; + int columnCount(const QModelIndex &parent) const; + QVariant data(const QModelIndex &index, int role) const; + QVariant headerData(int section, Qt::Orientation orientation, int role) const; + Qt::ItemFlags flags(const QModelIndex &index) const; +private: + QStringList columns; +}; + +#endif + diff --git a/bitcoin.pro b/bitcoin.pro index ab440fab..26a3216f 100644 --- a/bitcoin.pro +++ b/bitcoin.pro @@ -8,5 +8,7 @@ DEPENDPATH += . INCLUDEPATH += . # Input -HEADERS += BitcoinGUI.h -SOURCES += bitcoin.cpp BitcoinGUI.cpp +HEADERS += BitcoinGUI.h \ + TransactionTableModel.h +SOURCES += bitcoin.cpp BitcoinGUI.cpp \ + TransactionTableModel.cpp diff --git a/bitcoin.pro.user b/bitcoin.pro.user new file mode 100644 index 00000000..48022383 --- /dev/null +++ b/bitcoin.pro.user @@ -0,0 +1,113 @@ + + + + ProjectExplorer.Project.ActiveTarget + 0 + + + ProjectExplorer.Project.EditorSettings + + System + + + + ProjectExplorer.Project.Target.0 + + Desktop + Qt4ProjectManager.Target.DesktopTarget + 0 + 0 + + + qmake + QtProjectManager.QMakeBuildStep + + + + Make + Qt4ProjectManager.MakeStep + false + + + + 2 + + Make + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + false + + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + /store/orion/projects/bitcoin/bitcoin-qt + 4 + 0 + false + + + + qmake + QtProjectManager.QMakeBuildStep + + + + Make + Qt4ProjectManager.MakeStep + false + + + + 2 + + Make + Qt4ProjectManager.MakeStep + true + + clean + + + + 1 + false + + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + /store/orion/projects/bitcoin/bitcoin-qt + 4 + 0 + false + + 2 + + bitcoin + Qt4ProjectManager.Qt4RunConfiguration + 2 + + bitcoin.pro + false + false + + false + false + + + 1 + + + + ProjectExplorer.Project.TargetCount + 1 + + + ProjectExplorer.Project.Updater.FileVersion + 4 + +