From: Sakari Poussa Date: Fri, 13 Aug 2010 13:29:05 +0000 (+0300) Subject: TODO list update. Initial screen for pro mode X-Git-Url: http://vcs.maemo.org/git/?p=scorecard;a=commitdiff_plain;h=3a7b84c6a869df89c2e922a1af84bab3e89107f2 TODO list update. Initial screen for pro mode --- diff --git a/TODO b/TODO index 6e36f11..c9bfe00 100644 --- a/TODO +++ b/TODO @@ -1,15 +1,67 @@ -TOP Items -- Bug: New club/score with more than one comma (e.g xxx, yyy, zzz) does not work +Updated: 10-Aug-2010 -TODO General: -- New score dialog should be the same as main view (f.ex showing - subtotals, totals, and score colors). -- Use syslog -- Year filters and maybe more, must be easy to apply +This file contains to todo items for the N900 scorecard application. + +New Features and Enhancements: +------------------------------ + + - Exact HCP not just a integer (not 10 but 10.1) + + - Use the HCP (must be stored to the score since HCP keeps chaning) + + - To be able to score for 1-4 person + + - Stablefort point system (also during the play) + + - Sync golf courses and scores to a server, share with + others. Online course repository: Ability to upload courses online + for others to download and use. + + - Able to add putts, fairway hits, green in regulation, penalties + per hole + + - 9th hole tally: A tally of your score after 9 holes. + + - Autosave: no matter how many holes you have entered, your score is + still saved. I have had a couple time where I have been on the + 10th or 11th hole and I accidentally click the top of the screen, + this then cancels the score-entry window. This could also be a + prompt for save. + + - Virtual 'HCP' adjustment based on scores entered. eg. You set to + like 20, then after 5/10 rounds entered, it calculates your + virtual-handicap or similar. + + - HCP Colouring based on actual/entered HCP. eg, if you are a 18 hcp + golfer it colours your hole score based on this, not par. + + +Usability: +---------- + + - Bigger input screen for adding the score, perhaps only the first + nine on the first screen or only one hole per screen. It was very + hard to see the score when the sun is shining + + - Year filters and maybe more, must be easy to apply + +Refactoring: +------------ + + - New score dialog should be the same as main view (f.ex showing + subtotals, totals, and score colors). + + - Use syslog + + +Settings: +--------- -Settings - Play/view mode: shots or points + - Data store: internal or external MMC -TODO Debian packaging -- install data to SD card if present +Installation: +------------- + + - install data to SD card if present diff --git a/src/main-window.cpp b/src/main-window.cpp index 154ba3e..08e61fd 100644 --- a/src/main-window.cpp +++ b/src/main-window.cpp @@ -252,7 +252,7 @@ void MainWindow::loadSettings(void) // Start of 0.19 migration // Copy existing user data to new location // 0.18 and earlier: score.xml and club.xml are in /opt/scorecard/data - // 0.19 and later: score.xml and club.xml are in /home/user/.scorecard + // 0.19 and later: score.xml and club.xml are in /home/user/MyDocs/.scorecard QString scoreFileOld = dataDir + "/" + scoreFileName; QString clubFileOld = dataDir + "/" + clubFileName; @@ -476,6 +476,8 @@ void MainWindow::newScore() QString title = "New Score: " + courseName + ", " + date; scoreDialog->setWindowTitle(title); + qDebug() << clubName << courseName; + Club *club = findClub(clubName); if (!club) { showNote(tr("No club")); @@ -486,6 +488,7 @@ void MainWindow::newScore() showNote(tr("Error: no such course:")); return; } + scoreDialog->init(course); result = scoreDialog->exec(); if (result) { diff --git a/src/score-dialog.cpp b/src/score-dialog.cpp index 25a4f28..29b5189 100644 --- a/src/score-dialog.cpp +++ b/src/score-dialog.cpp @@ -478,7 +478,7 @@ void ScoreDialog18::showNote(QString msg) // ScoreDialogSingle based on QDialog // Usage: edit scorecard data for single hole //////////////////////////////////////////////////////////////////////////////// -ScoreDialogSingle::ScoreDialogSingle(QWidget *parent) : QDialog(parent) +ScoreDialogSingle::ScoreDialogSingle(QWidget *parent) : ScoreDialog(parent) { TRACE; resize(800, 400); @@ -536,7 +536,10 @@ void ScoreDialogSingle::createLayout(QWidget *parent) void ScoreDialogSingle::createTable(QWidget *parent) { TRACE; - table = new QTableWidget(5, 5, parent); + table = new QTableWidget(ROWS, COLS, parent); + QFont font; + font.setPointSize(32); + table->setFont(font); table->horizontalHeader()->setResizeMode(QHeaderView::Stretch); table->verticalHeader()->setResizeMode(QHeaderView::Stretch); @@ -545,7 +548,7 @@ void ScoreDialogSingle::createTable(QWidget *parent) table->setStyleSheet(defaultStyleSheet); QStringList headers; - headers << "" << "Par" << "HCP" << "Score" << "" << "Par" << "HCP" << "Score"; + headers << "Hole" << "Par" << "HCP" << "Score" << "Putts" << "Fairway" << "Green"; table->setVerticalHeaderLabels(headers); } @@ -565,3 +568,139 @@ void ScoreDialogSingle::createButton(QWidget *parent) pushButtonFinish = new QPushButton(tr("Finish")); connect(pushButtonFinish, SIGNAL(clicked()), this, SLOT(finish())); } + +void ScoreDialogSingle::init(Course *course, Score *score) +{ + TRACE; + QTableWidgetItem *holeNum, *par, *hcp, *scoreItem, *putts, *fairway, *green; + + for (int i = 0; i < 3; i++) { + par = new QTableWidgetItem(course->getPar(i)); + hcp = new QTableWidgetItem(course->getHcp(i)); + + if (score) + scoreItem = new QTableWidgetItem(score->getScore(i)); + else + scoreItem = new QTableWidgetItem(""); + + putts = new QTableWidgetItem("2"); + fairway = new QTableWidgetItem("Yes"); + green = new QTableWidgetItem("Yes"); + + holeNum = new QTableWidgetItem(QString::number(i+1)); + + holeNum->setTextAlignment(Qt::AlignCenter); + holeNum->setFlags(Qt::NoItemFlags); + holeNum->setForeground(ScoreColor::holeBg()); + + par->setTextAlignment(Qt::AlignCenter); + par->setFlags(Qt::NoItemFlags); + + hcp->setTextAlignment(Qt::AlignCenter); + hcp->setFlags(Qt::NoItemFlags); + + scoreItem->setTextAlignment(Qt::AlignCenter); + putts->setTextAlignment(Qt::AlignCenter); + fairway->setTextAlignment(Qt::AlignCenter); + green->setTextAlignment(Qt::AlignCenter); + + table->setItem(ROW_HOLE, i, holeNum); + table->setItem(ROW_PAR, i, par); + table->setItem(ROW_HCP, i, hcp); + table->setItem(ROW_SCORE, i, scoreItem); + table->setItem(ROW_PUTTS, i, putts); + table->setItem(ROW_FAIRWAY, i, fairway); + table->setItem(ROW_GREEN, i, green); + } + // Set focus to 1st cell + table->setCurrentCell(ROW_SCORE, 0); + if (!score) + setDefaultScore(table); +} + +// Set default score to par if not set +// TODO: merge the two methods since they are the same +void ScoreDialogSingle::setDefaultScore(QTableWidget *table) +{ + int row = table->currentRow(); + int col = table->currentColumn(); + + if (row == ROW_SCORE) + row = ROW_PAR; + else { + qDebug() << "ERROR: unknown row in default score"; + return; + } + QTableWidgetItem *par = table->item(row, col); + QTableWidgetItem *score = table->item(row + 2, col); + + if (par && score && score->text() == "") { + QVariant value(par->text()); + score->setData(Qt::DisplayRole, value); + } +} + +void ScoreDialogSingle::up(void) +{ + QTableWidgetItem *item = table->currentItem(); + + if (!item) { + qWarning() << "ERROR: no current item"; + return; + } + + int i = (item->text()).toInt(); + QVariant value(i+1); + item->setData(Qt::DisplayRole, value); +} + +void ScoreDialogSingle::down(void) +{ + QTableWidgetItem *item = table->currentItem(); + + if (!item) + return; + + int i = (item->text()).toInt(); + QVariant value(i-1); + item->setData(Qt::DisplayRole, value); +} + +void ScoreDialogSingle::next(void) +{ + if (table) { + QTableWidgetItem *item = table->currentItem(); + moveToNextCell(item); + setDefaultScore(table); + } +} + +void ScoreDialogSingle::moveToNextCell(QTableWidgetItem *item) +{ + if (!item) + return; + + QTableWidget *table = item->tableWidget(); + + if (!table) + return; + + int row = table->currentRow(); + int col = table->currentColumn(); + + qDebug() << row << col; + if (row < (ROWS - 1)) { + row++; + } + else if (row == (ROWS - 1)) { + row = ROW_SCORE; + col = (col == COLS-1) ? 0 : col + 1; + } + qDebug() << row << col; + table->setCurrentCell(row, col); +} + +void ScoreDialogSingle::results(QVector &scores) +{ + TRACE; +} diff --git a/src/score-dialog.h b/src/score-dialog.h index 380c097..8d0d934 100644 --- a/src/score-dialog.h +++ b/src/score-dialog.h @@ -106,7 +106,7 @@ public: void results(QVector &scores); bool validate(void); - private slots: +private slots: void up(void); void down(void); void next(void); @@ -141,7 +141,7 @@ private: }; // Class for editing single hole in one dialog -class ScoreDialogSingle: public QDialog +class ScoreDialogSingle: public ScoreDialog { Q_OBJECT; @@ -152,11 +152,22 @@ public: void init(Course *course, Score *score = 0); void results(QVector &scores); +private slots: + void up(void); + void down(void); + void next(void); + //void finish(void); + private: + enum { ROWS = 7, COLS = 3 }; + enum { ROW_HOLE = 0, ROW_PAR = 1, ROW_HCP = 2, ROW_SCORE = 3, ROW_PUTTS = 4, ROW_FAIRWAY = 5, ROW_GREEN = 6 }; + void createTable(QWidget *parent = 0); void createButton(QWidget *parent = 0); void createLayout(QWidget *parent = 0); + void setDefaultScore(QTableWidget *table); + void moveToNextCell(QTableWidgetItem *item); // Widgets QTableWidget *table;