Statistics - initial version
authorSakari Poussa <spoussa@gmail.com>
Tue, 24 Nov 2009 19:50:52 +0000 (21:50 +0200)
committerSakari Poussa <spoussa@gmail.com>
Tue, 24 Nov 2009 19:50:52 +0000 (21:50 +0200)
scorecard.pro
src/main-window.cpp
src/main-window.h
src/table-model.cpp

index f3dd8da..b074d32 100644 (file)
@@ -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
 
index 1fa5527..db65fc0 100644 (file)
@@ -1,12 +1,9 @@
 #include <QtGui>
-#include <QDirModel>
-#include <QListView>
-#include <QStandardItemModel>
 
 #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<Score *> &scoreList, QList <Club *> &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<Score *> &list)
index 753a131..fd49cfe 100644 (file)
@@ -2,6 +2,7 @@
 #include <QTableView>
 #include <QPushButton>
 #include <QToolBar>
+#include <QTextEdit>
 #include <QVBoxLayout>
 #include <QItemSelectionModel>
 #include <QList>
@@ -45,6 +46,7 @@ private:
 
   void loadSettings(void);
   Club *findClub(QString &name);
+  void getStat(QTextEdit *);
 
   QList<Score *> scoreList;
   QList<Club *> clubList;
index 529b43d..d076684 100644 (file)
@@ -277,7 +277,7 @@ QVariant ScoreTableModel::data(const QModelIndex &index, int role) const
     }
   }
   //
-  // DATA
+  // NUMBERS
   //
   if (role == Qt::DisplayRole) {