Corner case handling. Copyright update
[scorecard] / src / main-window.cpp
index 5b4b546..98351e2 100644 (file)
@@ -58,10 +58,6 @@ void MainWindow::loadSettings(void)
 {
   bool external = false;
 
-#ifndef Q_WS_HILDON
-  topDir = ".";
-#endif
-
   QDir mmc(mmcDir);
   if (mmc.exists())
     external = true;
@@ -69,12 +65,16 @@ void MainWindow::loadSettings(void)
   // TODO: make via user option, automatic will never work
   external = false;
 
+#ifndef Q_WS_HILDON
+  dataDir = "./" + dataDirName;
+#else
   if (external) {
     dataDir = mmcDir + "/" + appName + "/" + dataDirName;
   }
   else {
     dataDir = topDir + "/" + appName + "/" + dataDirName;
   }
+#endif
   scoreFile = dataDir + "/" + scoreFileName;
   clubFile = dataDir + "/" + clubFileName;
 
@@ -103,7 +103,7 @@ void MainWindow::createLayout(QWidget *parent)
   QHBoxLayout *mainLayout = new QHBoxLayout(parent);
   mainLayout->addLayout(tableLayout);
   mainLayout->addLayout(buttonLayout);
-  setLayout(mainLayout);
+  parent->setLayout(mainLayout);
 }
 
 // Setup 'score' tab view
@@ -135,6 +135,7 @@ void MainWindow::createTableView(QList<Score *> &scoreList, QList <Club *> &club
   // Fill out all the space with the tables
   table->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
   table->verticalHeader()->setResizeMode(QHeaderView::Stretch);
+  table->verticalHeader()->setAutoFillBackground(true);
   table->horizontalHeader()->hide();
 }
 
@@ -231,7 +232,7 @@ void MainWindow::createActions()
 
 void MainWindow::createMenus()
 {
-  menu = menuBar()->addMenu(tr("fremantle"));
+  menu = menuBar()->addMenu("");
 #if 0
   menu->addAction(viewScoreAct);
   menu->addAction(viewCourseAct);
@@ -344,6 +345,11 @@ void MainWindow::editCourse()
 {
   Course *course = scoreTableModel->getCourse();
 
+  if (!course) {
+    qWarning() << "No course on edit";
+    return;
+  }
+
   CourseDialog *courseDialog = new CourseDialog(this);
   courseDialog->init(course);