From: Sakari Poussa Date: Tue, 24 Nov 2009 19:50:52 +0000 (+0200) Subject: Statistics - initial version X-Git-Url: http://git.maemo.org/git/?p=scorecard;a=commitdiff_plain;h=08bc75ee508474556da5cdba854f5ba49e9b1eb4 Statistics - initial version --- diff --git a/scorecard.pro b/scorecard.pro index f3dd8da..b074d32 100644 --- a/scorecard.pro +++ b/scorecard.pro @@ -17,6 +17,7 @@ src/main-window.h \ src/score-dialog.h \ src/course-dialog.h \ src/table-model.h \ +src/stat-model.h \ src/xml-dom-parser.h \ src/data.h @@ -26,6 +27,7 @@ src/main-window.cpp \ src/score-dialog.cpp \ src/course-dialog.cpp \ src/table-model.cpp \ +src/stat-model.cpp \ src/xml-dom-parser.cpp \ src/data.cpp diff --git a/src/main-window.cpp b/src/main-window.cpp index 1fa5527..db65fc0 100644 --- a/src/main-window.cpp +++ b/src/main-window.cpp @@ -1,12 +1,9 @@ #include -#include -#include -#include #include "main-window.h" #include "score-dialog.h" #include "course-dialog.h" -#include "xml-parser.h" +#include "stat-model.h" #include "xml-dom-parser.h" QString appName("scorecard"); @@ -41,7 +38,6 @@ MainWindow::MainWindow(QMainWindow *parent): QMainWindow(parent) // Sort the scores based on dates qSort(scoreList.begin(), scoreList.end(), dateLessThan); - createActions(); createMenus(); @@ -123,7 +119,6 @@ void MainWindow::createTableView(QList &scoreList, QList &club table->showGrid(); table->setModel(scoreTableModel); - QItemSelectionModel selectionModel(); table->setSelectionMode(QAbstractItemView::NoSelection); scoreTableModel->setScore(scoreList); @@ -416,37 +411,43 @@ void MainWindow::editScore() void MainWindow::viewStatistics() { - QMainWindow *statWindow = new QMainWindow(this); + QMainWindow *win = new QMainWindow(this); + QString title = "Statistics"; + win->setWindowTitle(title); - //QWidget *centralWidget = new QWidget(statWindow); + StatModel *statModel = new StatModel(clubList, scoreList); - //setCentralWidget(centralWidget); + QTableView *table = new QTableView; + table->showGrid(); + table->setSelectionMode(QAbstractItemView::NoSelection); + table->horizontalHeader()->setResizeMode(QHeaderView::Stretch); + table->verticalHeader()->setResizeMode(QHeaderView::Stretch); + table->verticalHeader()->setAutoFillBackground(true); + table->setModel(statModel); + QWidget *central = new QWidget(win); + win->setCentralWidget(central); - QString foo = "some longer text is needed here : 17"; - QTextEdit *textEdit = new QTextEdit(foo); - - QLabel *label = new QLabel; - label->setScaledContents(true); + QPushButton *b1 = new QPushButton("Graphs"); - QString text = "foo : bar"; + QVBoxLayout *buttonLayout = new QVBoxLayout; + buttonLayout->addWidget(b1); - text.append("Scores: 17"); + QTextEdit *textEdit = new QTextEdit; + //getStat(textEdit); - label->setAlignment(Qt::AlignCenter); - label->setText(text); + textEdit->setReadOnly(true); - QString title = "Statistics"; - statWindow->setWindowTitle(title); + QVBoxLayout *infoLayout = new QVBoxLayout; + infoLayout->addWidget(table); - QVBoxLayout *layout = new QVBoxLayout; - //layout->addWidget(label); - layout->addWidget(textEdit); + QHBoxLayout *mainLayout = new QHBoxLayout(central); + mainLayout->addLayout(infoLayout); + mainLayout->addLayout(buttonLayout); - //statWindow->setLayout(layout); + central->setLayout(mainLayout); - //setCentralWidget(statWindow); - statWindow->show(); + win->show(); } void MainWindow::loadScoreFile(QString &fileName, QList &list) diff --git a/src/main-window.h b/src/main-window.h index 753a131..fd49cfe 100644 --- a/src/main-window.h +++ b/src/main-window.h @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -45,6 +46,7 @@ private: void loadSettings(void); Club *findClub(QString &name); + void getStat(QTextEdit *); QList scoreList; QList clubList; diff --git a/src/table-model.cpp b/src/table-model.cpp index 529b43d..d076684 100644 --- a/src/table-model.cpp +++ b/src/table-model.cpp @@ -277,7 +277,7 @@ QVariant ScoreTableModel::data(const QModelIndex &index, int role) const } } // - // DATA + // NUMBERS // if (role == Qt::DisplayRole) {