From 1355cfe131e9bbaa209f79f7d9987a73b69285d3 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Sun, 8 May 2011 22:23:31 +0200 Subject: [PATCH] add all (unpopulated) dialogs --- .gitignore | 2 + AboutDialog.cpp | 6 ++ AboutDialog.h | 18 ++++++ AddressBookDialog.cpp | 7 +++ AddressBookDialog.h | 18 ++++++ BitcoinGUI.cpp | 18 +++++- BitcoinGUI.h | 14 ++--- SendCoinsDialog.cpp | 6 ++ SendCoinsDialog.h | 18 ++++++ SettingsDialog.cpp | 7 +++ SettingsDialog.h | 18 ++++++ TODO | 5 +- TransactionTableModel.cpp | 25 +++++++-- TransactionTableModel.h | 14 ++++- bitcoin.pro | 12 +++- bitcoin.pro.user | 113 -------------------------------------- moc_BitcoinGUI.cpp | 79 -------------------------- 17 files changed, 169 insertions(+), 211 deletions(-) create mode 100644 AboutDialog.cpp create mode 100644 AboutDialog.h create mode 100644 AddressBookDialog.cpp create mode 100644 AddressBookDialog.h create mode 100644 SendCoinsDialog.cpp create mode 100644 SendCoinsDialog.h create mode 100644 SettingsDialog.cpp create mode 100644 SettingsDialog.h delete mode 100644 bitcoin.pro.user delete mode 100644 moc_BitcoinGUI.cpp diff --git a/.gitignore b/.gitignore index d6ff91a9..a261fd9c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ *~ *.o +moc_*.cpp +*.pro.user diff --git a/AboutDialog.cpp b/AboutDialog.cpp new file mode 100644 index 00000000..dd2ec9f9 --- /dev/null +++ b/AboutDialog.cpp @@ -0,0 +1,6 @@ +#include "AboutDialog.h" + +AboutDialog::AboutDialog(QWidget *parent) : + QDialog(parent) +{ +} diff --git a/AboutDialog.h b/AboutDialog.h new file mode 100644 index 00000000..13721210 --- /dev/null +++ b/AboutDialog.h @@ -0,0 +1,18 @@ +#ifndef ABOUTDIALOG_H +#define ABOUTDIALOG_H + +#include + +class AboutDialog : public QDialog +{ + Q_OBJECT +public: + explicit AboutDialog(QWidget *parent = 0); + +signals: + +public slots: + +}; + +#endif // ABOUTDIALOG_H diff --git a/AddressBookDialog.cpp b/AddressBookDialog.cpp new file mode 100644 index 00000000..7e853ede --- /dev/null +++ b/AddressBookDialog.cpp @@ -0,0 +1,7 @@ +#include "AddressBookDialog.h" + +AddressBookDialog::AddressBookDialog(QWidget *parent) : + QDialog(parent) +{ +} + diff --git a/AddressBookDialog.h b/AddressBookDialog.h new file mode 100644 index 00000000..3a27aa62 --- /dev/null +++ b/AddressBookDialog.h @@ -0,0 +1,18 @@ +#ifndef ADDRESSBOOKDIALOG_H +#define ADDRESSBOOKDIALOG_H + +#include + +class AddressBookDialog : public QDialog +{ + Q_OBJECT +public: + explicit AddressBookDialog(QWidget *parent = 0); + +signals: + +public slots: + +}; + +#endif // ADDRESSBOOKDIALOG_H diff --git a/BitcoinGUI.cpp b/BitcoinGUI.cpp index 0b81f72f..f07b8280 100644 --- a/BitcoinGUI.cpp +++ b/BitcoinGUI.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -86,9 +87,24 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): * QAbstractItemView::ExtendedSelection */ QTableView *transaction_table = new QTableView(this); + TransactionTableModel *transaction_model = new TransactionTableModel(this); transaction_table->setModel(transaction_model); - + transaction_table->setSelectionBehavior(QAbstractItemView::SelectRows); + transaction_table->setSelectionMode(QAbstractItemView::ExtendedSelection); + + transaction_table->horizontalHeader()->resizeSection( + TransactionTableModel::Status, 112); + transaction_table->horizontalHeader()->resizeSection( + TransactionTableModel::Date, 112); + transaction_table->horizontalHeader()->setResizeMode( + TransactionTableModel::Description, QHeaderView::Stretch); + transaction_table->horizontalHeader()->resizeSection( + TransactionTableModel::Debit, 79); + transaction_table->horizontalHeader()->resizeSection( + TransactionTableModel::Credit, 79); + /* TODO: alignment; debit/credit columns must align right */ + QTabBar *tabs = new QTabBar(this); tabs->addTab("All transactions"); tabs->addTab("Sent/Received"); diff --git a/BitcoinGUI.h b/BitcoinGUI.h index e4ff2fe6..590bb3ef 100644 --- a/BitcoinGUI.h +++ b/BitcoinGUI.h @@ -1,5 +1,5 @@ -#ifndef H_BITCOINGUI -#define H_BITCOINGUI +#ifndef BITCOINGUI_H +#define BITCOINGUI_H #include @@ -7,14 +7,14 @@ class BitcoinGUI : public QMainWindow { Q_OBJECT public: - BitcoinGUI(QWidget *parent = 0); + explicit BitcoinGUI(QWidget *parent = 0); /* Transaction table tab indices */ enum { - ALL_TRANSACTIONS = 0, - SENT_RECEIVED = 1, - SENT = 2, - RECEIVED = 3 + AllTransactions = 0, + SentReceived = 1, + Sent = 2, + Received = 3 } TabIndex; private slots: void currentChanged(int tab); diff --git a/SendCoinsDialog.cpp b/SendCoinsDialog.cpp new file mode 100644 index 00000000..a89a58dc --- /dev/null +++ b/SendCoinsDialog.cpp @@ -0,0 +1,6 @@ +#include "SendCoinsDialog.h" + +SendCoinsDialog::SendCoinsDialog(QWidget *parent) : + QDialog(parent) +{ +} diff --git a/SendCoinsDialog.h b/SendCoinsDialog.h new file mode 100644 index 00000000..f2720c37 --- /dev/null +++ b/SendCoinsDialog.h @@ -0,0 +1,18 @@ +#ifndef SENDCOINSDIALOG_H +#define SENDCOINSDIALOG_H + +#include + +class SendCoinsDialog : public QDialog +{ + Q_OBJECT +public: + explicit SendCoinsDialog(QWidget *parent = 0); + +signals: + +public slots: + +}; + +#endif // SENDCOINSDIALOG_H diff --git a/SettingsDialog.cpp b/SettingsDialog.cpp new file mode 100644 index 00000000..d2ce01ee --- /dev/null +++ b/SettingsDialog.cpp @@ -0,0 +1,7 @@ +#include "SettingsDialog.h" + +SettingsDialog::SettingsDialog(QWidget *parent) : + QDialog(parent) +{ +} + diff --git a/SettingsDialog.h b/SettingsDialog.h new file mode 100644 index 00000000..7bbfb1f8 --- /dev/null +++ b/SettingsDialog.h @@ -0,0 +1,18 @@ +#ifndef SETTINGSDIALOG_H +#define SETTINGSDIALOG_H + +#include + +class SettingsDialog : public QDialog +{ + Q_OBJECT +public: + explicit SettingsDialog(QWidget *parent = 0); + +signals: + +public slots: + +}; + +#endif // SETTINGSDIALOG_H diff --git a/TODO b/TODO index 934b231b..4729921c 100644 --- a/TODO +++ b/TODO @@ -23,6 +23,9 @@ Table [columns]: Credit ** Table should be the same in all tabs. Do we really need different widgets? + -> yes, to have different proxy views + + ** Table rows are much too high? Status bar: Permanent status indicators: @@ -46,5 +49,5 @@ AboutDialog - Address Book icon - - Translation + diff --git a/TransactionTableModel.cpp b/TransactionTableModel.cpp index 0f352960..e5cf2581 100644 --- a/TransactionTableModel.cpp +++ b/TransactionTableModel.cpp @@ -1,5 +1,14 @@ #include "TransactionTableModel.h" +/* Credit and Debit columns are right-aligned as they contain numbers */ +static Qt::AlignmentFlag column_alignments[] = { + Qt::AlignLeft, + Qt::AlignLeft, + Qt::AlignLeft, + Qt::AlignRight, + Qt::AlignRight + }; + TransactionTableModel::TransactionTableModel(QObject *parent): QAbstractTableModel(parent) { @@ -28,18 +37,24 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const /* index.row(), index.column() */ /* Return QString */ return QString("test"); + } else if (role == Qt::TextAlignmentRole) + { + return column_alignments[index.column()]; } return QVariant(); } QVariant TransactionTableModel::headerData(int section, Qt::Orientation orientation, int role) const { - if(role != Qt::DisplayRole) - return QVariant(); - - if(orientation == Qt::Horizontal) + if(role == Qt::DisplayRole) + { + if(orientation == Qt::Horizontal) + { + return columns[section]; + } + } else if (role == Qt::TextAlignmentRole) { - return columns[section]; + return column_alignments[section]; } return QVariant(); } diff --git a/TransactionTableModel.h b/TransactionTableModel.h index 9071ed66..8913f1d9 100644 --- a/TransactionTableModel.h +++ b/TransactionTableModel.h @@ -1,5 +1,5 @@ -#ifndef H_TRANSACTIONTABLEMODEL -#define H_TRANSACTIONTABLEMODEL +#ifndef TRANSACTIONTABLEMODEL_H +#define TRANSACTIONTABLEMODEL_H #include #include @@ -8,7 +8,15 @@ class TransactionTableModel : public QAbstractTableModel { Q_OBJECT public: - TransactionTableModel(QObject *parent = 0); + explicit TransactionTableModel(QObject *parent = 0); + + enum { + Status = 0, + Date = 1, + Description = 2, + Debit = 3, + Credit = 4 + } ColumnIndex; int rowCount(const QModelIndex &parent) const; int columnCount(const QModelIndex &parent) const; diff --git a/bitcoin.pro b/bitcoin.pro index 26a3216f..4f794ac6 100644 --- a/bitcoin.pro +++ b/bitcoin.pro @@ -9,6 +9,14 @@ INCLUDEPATH += . # Input HEADERS += BitcoinGUI.h \ - TransactionTableModel.h + TransactionTableModel.h \ + SendCoinsDialog.h \ + SettingsDialog.h \ + AddressBookDialog.h \ + AboutDialog.h SOURCES += bitcoin.cpp BitcoinGUI.cpp \ - TransactionTableModel.cpp + TransactionTableModel.cpp \ + SendCoinsDialog.cpp \ + SettingsDialog.cpp \ + AddressBookDialog.cpp \ + AboutDialog.cpp diff --git a/bitcoin.pro.user b/bitcoin.pro.user deleted file mode 100644 index 48022383..00000000 --- a/bitcoin.pro.user +++ /dev/null @@ -1,113 +0,0 @@ - - - - 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 - - diff --git a/moc_BitcoinGUI.cpp b/moc_BitcoinGUI.cpp deleted file mode 100644 index 3c024d31..00000000 --- a/moc_BitcoinGUI.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** Meta object code from reading C++ file 'BitcoinGUI.h' -** -** Created: Sat May 7 20:43:39 2011 -** by: The Qt Meta Object Compiler version 62 (Qt 4.7.0) -** -** WARNING! All changes made in this file will be lost! -*****************************************************************************/ - -#include "BitcoinGUI.h" -#if !defined(Q_MOC_OUTPUT_REVISION) -#error "The header file 'BitcoinGUI.h' doesn't include ." -#elif Q_MOC_OUTPUT_REVISION != 62 -#error "This file was generated using the moc from 4.7.0. It" -#error "cannot be used with the include files from this version of Qt." -#error "(The moc has changed too much.)" -#endif - -QT_BEGIN_MOC_NAMESPACE -static const uint qt_meta_data_BitcoinGUI[] = { - - // content: - 5, // revision - 0, // classname - 0, 0, // classinfo - 1, 14, // methods - 0, 0, // properties - 0, 0, // enums/sets - 0, 0, // constructors - 0, // flags - 0, // signalCount - - // slots: signature, parameters, type, tag, flags - 16, 12, 11, 11, 0x08, - - 0 // eod -}; - -static const char qt_meta_stringdata_BitcoinGUI[] = { - "BitcoinGUI\0\0tab\0currentChanged(int)\0" -}; - -const QMetaObject BitcoinGUI::staticMetaObject = { - { &QMainWindow::staticMetaObject, qt_meta_stringdata_BitcoinGUI, - qt_meta_data_BitcoinGUI, 0 } -}; - -#ifdef Q_NO_DATA_RELOCATION -const QMetaObject &BitcoinGUI::getStaticMetaObject() { return staticMetaObject; } -#endif //Q_NO_DATA_RELOCATION - -const QMetaObject *BitcoinGUI::metaObject() const -{ - return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject; -} - -void *BitcoinGUI::qt_metacast(const char *_clname) -{ - if (!_clname) return 0; - if (!strcmp(_clname, qt_meta_stringdata_BitcoinGUI)) - return static_cast(const_cast< BitcoinGUI*>(this)); - return QMainWindow::qt_metacast(_clname); -} - -int BitcoinGUI::qt_metacall(QMetaObject::Call _c, int _id, void **_a) -{ - _id = QMainWindow::qt_metacall(_c, _id, _a); - if (_id < 0) - return _id; - if (_c == QMetaObject::InvokeMetaMethod) { - switch (_id) { - case 0: currentChanged((*reinterpret_cast< int(*)>(_a[1]))); break; - default: ; - } - _id -= 1; - } - return _id; -} -QT_END_MOC_NAMESPACE