Fixed label wraping.
[medard] / src / mainwindow.cpp
index c82f413..f612990 100644 (file)
@@ -17,7 +17,7 @@
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#ifdef Q_WS_MAEMO_6
+#ifdef MEEGO_EDITION_HARMATTAN
 #include <MLayout>
 #include <MAction>
 #include <MWidgetAction>
@@ -30,7 +30,7 @@
 #include "aboutdialog.h"
 #include "mainwindow.h"
 
-#ifdef Q_WS_MAEMO_6
+#ifdef MEEGO_EDITION_HARMATTAN
 MainWindow::MainWindow(QGraphicsItem *parent) : MApplicationPage(parent)
 {
     m_downloader = new MedardDownloader();
@@ -48,12 +48,10 @@ MainWindow::MainWindow(QGraphicsItem *parent) : MApplicationPage(parent)
 
     m_forecastInitialDateLabel = new MLabel();
     m_forecastInitialDateLabel->setAlignment(Qt::AlignCenter);
-    m_forecastInitialDateLabel->setWordWrap(true);
-//    m_forecastInitialDateLabel->setDisabled(true);
+    m_forecastInitialDateLabel->setEnabled(false);
 
     m_forecastDateLabel = new MLabel();
     m_forecastDateLabel->setAlignment(Qt::AlignCenter);
-    m_forecastDateLabel->setWordWrap(true);
 
     m_downloadRetryButton = new MButton(tr("Download again"));
     m_downloadRetryButton->setPreferredWidth(220);
@@ -128,10 +126,9 @@ MainWindow::~MainWindow()
     delete m_downloader;
 }
 
-#ifdef Q_WS_MAEMO_6
+#ifdef MEEGO_EDITION_HARMATTAN
 void MainWindow::setupUi()
 {
-    setAttribute(Qt::WA_LockPortraitOrientation, true);
     setWindowTitle(tr("Medard"));
     setPannable(false);
 
@@ -141,11 +138,13 @@ void MainWindow::setupUi()
     mainLayout->addItem(m_forecast);
 
     QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical);
+    layout->setContentsMargins(4, 4, 4, 4);
+    layout->setSpacing(8);
     mainLayout->addItem(layout);
 
     layout->addItem(m_forecastTypeLabel);
+/*    layout->addItem(m_forecastInitialDateLabel); */
     layout->addItem(m_forecastDateLabel);
-    layout->addItem(m_forecastInitialDateLabel);
     layout->addItem(m_downloadRetryButton);
 
     QGraphicsLinearLayout *dayNavigationBox = new QGraphicsLinearLayout(Qt::Horizontal);
@@ -203,7 +202,7 @@ void MainWindow::setupUi()
 }
 #endif
 
-#ifdef Q_WS_MAEMO_6
+#ifdef MEEGO_EDITION_HARMATTAN
 void MainWindow::setupMenu()
 {
     QStringList forecastDomainList;
@@ -318,7 +317,7 @@ void MainWindow::loadSettings()
     int forecastType = settings.value("ForecastType").toInt();
 
     m_downloader->setForecastDomain((MedardDownloader::ForecastDomain) forecastDomain);
-#ifdef Q_WS_MAEMO_6
+#ifdef MEEGO_EDITION_HARMATTAN
     m_forecastDomainComboBox->setCurrentIndex(forecastDomain);
 #else
     m_domainActionGroup->actions().at(forecastDomain)->setChecked(true);
@@ -373,25 +372,55 @@ void MainWindow::hideNavigationButtons(bool showRetryButton)
 void MainWindow::updateNavigationButtons()
 {
     if ((m_downloader->forecastDateOffset() - 24) < m_downloader->minForecastDateOffset()) {
-//        m_minusDayButton->setDisabled(true);
-//        m_plusDayButton->setDisabled(false);
+#ifdef MEEGO_EDITION_HARMATTAN
+        m_minusDayButton->setEnabled(false);
+        m_plusDayButton->setEnabled(true);
+#else
+        m_minusDayButton->setDisabled(true);
+        m_plusDayButton->setDisabled(false);
+#endif
     } else if ((m_downloader->forecastDateOffset() + 24) > m_downloader->maxForecastDateOffset()) {
-//        m_minusDayButton->setDisabled(false);
-//        m_plusDayButton->setDisabled(true);
+#ifdef MEEGO_EDITION_HARMATTAN
+        m_minusDayButton->setEnabled(true);
+        m_plusDayButton->setEnabled(false);
+#else
+        m_minusDayButton->setDisabled(false);
+        m_plusDayButton->setDisabled(true);
+#endif
     } else {
-//        m_minusDayButton->setDisabled(false);
-//        m_plusDayButton->setDisabled(false);
+#ifdef MEEGO_EDITION_HARMATTAN
+        m_minusDayButton->setEnabled(true);
+        m_plusDayButton->setEnabled(true);
+#else
+        m_minusDayButton->setDisabled(false);
+        m_plusDayButton->setDisabled(false);
+#endif
     }
 
     if ((m_downloader->forecastDateOffset() - 1) < m_downloader->minForecastDateOffset()) {
-//        m_minusHourButton->setDisabled(true);
-//        m_plusHourButton->setDisabled(false);
+#ifdef MEEGO_EDITION_HARMATTAN
+        m_minusHourButton->setEnabled(false);
+        m_plusHourButton->setEnabled(true);
+#else
+        m_minusHourButton->setDisabled(true);
+        m_plusHourButton->setDisabled(false);
+#endif
     } else if ((m_downloader->forecastDateOffset() + 1) > m_downloader->maxForecastDateOffset()) {
-//        m_minusHourButton->setDisabled(false);
-//        m_plusHourButton->setDisabled(true);
+#ifdef MEEGO_EDITION_HARMATTAN
+        m_minusHourButton->setEnabled(true);
+        m_plusHourButton->setEnabled(false);
+#else
+        m_minusHourButton->setDisabled(false);
+        m_plusHourButton->setDisabled(true);
+#endif
     } else {
-//        m_minusHourButton->setDisabled(false);
-//        m_plusHourButton->setDisabled(false);
+#ifdef MEEGO_EDITION_HARMATTAN
+        m_minusHourButton->setEnabled(true);
+        m_plusHourButton->setEnabled(true);
+#else
+        m_minusHourButton->setDisabled(false);
+        m_plusHourButton->setDisabled(false);
+#endif
     }
 }
 
@@ -415,7 +444,7 @@ void MainWindow::setForecastDateOffset(int offset)
 
 void MainWindow::seaLevelPreasureMenuClicked()
 {
-#ifdef Q_WS_MAEMO_6
+#ifdef MEEGO_EDITION_HARMATTAN
     m_forecastTypeComboBox->setCurrentIndex(MedardDownloader::SeaLevelPressure);
 #endif
     setForecastType(tr("Sea Level Pressure"), MedardDownloader::SeaLevelPressure);
@@ -423,7 +452,7 @@ void MainWindow::seaLevelPreasureMenuClicked()
 
 void MainWindow::precipitationMenuClicked()
 {
-#ifdef Q_WS_MAEMO_6
+#ifdef MEEGO_EDITION_HARMATTAN
     m_forecastTypeComboBox->setCurrentIndex(MedardDownloader::Precipitation);
 #endif
     setForecastType(tr("Precipitation"), MedardDownloader::Precipitation);
@@ -431,7 +460,7 @@ void MainWindow::precipitationMenuClicked()
 
 void MainWindow::windVelocityMenuClicked()
 {
-#ifdef Q_WS_MAEMO_6
+#ifdef MEEGO_EDITION_HARMATTAN
     m_forecastTypeComboBox->setCurrentIndex(MedardDownloader::WindVelocity);
 #endif
     setForecastType(tr("Wind Velocity"), MedardDownloader::WindVelocity);
@@ -439,7 +468,7 @@ void MainWindow::windVelocityMenuClicked()
 
 void MainWindow::cloudinessMenuClicked()
 {
-#ifdef Q_WS_MAEMO_6
+#ifdef MEEGO_EDITION_HARMATTAN
     m_forecastTypeComboBox->setCurrentIndex(MedardDownloader::Cloudiness);
 #endif
     setForecastType(tr("Cloudiness"), MedardDownloader::Cloudiness);
@@ -447,7 +476,7 @@ void MainWindow::cloudinessMenuClicked()
 
 void MainWindow::temperatureMenuClicked()
 {
-#ifdef Q_WS_MAEMO_6
+#ifdef MEEGO_EDITION_HARMATTAN
     m_forecastTypeComboBox->setCurrentIndex(MedardDownloader::Temperature);
 #endif
     setForecastType(tr("Temperature"), MedardDownloader::Temperature);
@@ -456,7 +485,7 @@ void MainWindow::temperatureMenuClicked()
 void MainWindow::aboutMenuClicked()
 {
     AboutDialog *dialog = new AboutDialog();
-#ifdef Q_WS_MAEMO_6
+#ifdef MEEGO_EDITION_HARMATTAN
     dialog->appear(MSceneWindow::DestroyWhenDismissed);
 #else
     dialog->exec();
@@ -491,7 +520,7 @@ void MainWindow::minusHourClicked()
     setForecastDateOffset(-1);
 }
 
-#ifdef Q_WS_MAEMO_6
+#ifdef MEEGO_EDITION_HARMATTAN
 void MainWindow::forecastDomainChanged(int index)
 {
     m_forecast->clearImage(false);
@@ -554,11 +583,11 @@ void MainWindow::forecastDomainChanged(QAction *action)
 void MainWindow::downloadedFinished(const QString &filename, const QDateTime &date)
 {
     m_forecast->setImage(filename);
-    m_forecastInitialDateLabel->setText(tr("Forecast from:\n") +
-                                          m_downloader->forecastInitialDate().toString("dd.MM.yyyy hh:mm"));
+    m_forecastInitialDateLabel->setText(tr("Forecast from:<br>") +
+                                          m_downloader->forecastInitialDate().toString("dd.MM.yyyy, hh:mm"));
 
     /* upcase the first letter of name of day */
-    QString temp = date.toString("dddd\ndd.MM.yyyy hh:mm");
+    QString temp = date.toString("dddd<br>dd.MM.yyyy, hh:mm");
     m_forecastDateLabel->setText(temp.replace(0, 1, temp.at(0).toUpper()));
 
     showNavigationButtons();