Added confirmation prompt when deleting List.
[easylist] / mainform.cpp
index 9eac1d8..0c61735 100755 (executable)
@@ -8,6 +8,9 @@ MainForm::MainForm(QWidget *parent) :
     ui->setupUi(this);\r
     settings = new QSettings(WILLEM_LIU, EASY_LIST);\r
 \r
+    requestWebpage = new RequestWebpage(this);\r
+    connect(requestWebpage, SIGNAL(finished(QNetworkReply*)), this, SLOT(slotSyncList(QNetworkReply*)));\r
+\r
     newIndex = 0;\r
     connect(SystemSettings::getInstance(), SIGNAL(signalKeyboardClosed(bool)), this, SLOT(keyboardClosed(bool)));\r
 \r
@@ -56,6 +59,7 @@ MainForm::MainForm(QWidget *parent) :
     listForm = new ListForm(this);\r
     editForm = new EditForm(this);\r
     chooseListForm = new ChooseListForm(this);\r
+    settingsForm = new SettingsForm(this);\r
 \r
     connect(listForm, SIGNAL(signalTransitionOutFinished()), this, SLOT(stateOutFinished()));\r
     connect(listForm, SIGNAL(signalNavigate(int)), this, SLOT(changeWidget(int)));\r
@@ -66,9 +70,13 @@ MainForm::MainForm(QWidget *parent) :
     connect(chooseListForm, SIGNAL(signalTransitionOutFinished()), this, SLOT(stateOutFinished()));\r
     connect(chooseListForm, SIGNAL(signalNavigate(int)), this, SLOT(changeWidget(int)));\r
 \r
+    connect(settingsForm, SIGNAL(signalTransitionOutFinished()), this, SLOT(stateOutFinished()));\r
+    connect(settingsForm, SIGNAL(signalNavigate(int)), this, SLOT(changeWidget(int)));\r
+\r
     ui->stackedWidget->addWidget(listForm);\r
     ui->stackedWidget->addWidget(editForm);\r
     ui->stackedWidget->addWidget(chooseListForm);\r
+    ui->stackedWidget->addWidget(settingsForm);\r
     ui->stackedWidget->setCurrentWidget(listForm);\r
 }\r
 \r
@@ -125,7 +133,7 @@ void MainForm::setLandscapeMode(bool landscape)
     {\r
         tempLandscapeMode = true;\r
         qDebug() << LANDSCAPE;\r
-#ifdef Q_WS_MAEMO_5\r
+#if defined(Q_WS_MAEMO_5) || defined(Q_WS_HILDON)\r
         setAttribute(Qt::WA_Maemo5AutoOrientation, false);\r
         setAttribute(Qt::WA_Maemo5LandscapeOrientation, true);\r
         setAttribute(Qt::WA_Maemo5PortraitOrientation, false);\r
@@ -135,7 +143,7 @@ void MainForm::setLandscapeMode(bool landscape)
     {\r
         tempLandscapeMode = false;\r
         qDebug() << PORTRAIT;\r
-#ifdef Q_WS_MAEMO_5\r
+#if defined(Q_WS_MAEMO_5) || defined(Q_WS_HILDON)\r
         setAttribute(Qt::WA_Maemo5AutoOrientation, false);\r
         setAttribute(Qt::WA_Maemo5PortraitOrientation, true);\r
         setAttribute(Qt::WA_Maemo5LandscapeOrientation, false);\r
@@ -158,9 +166,14 @@ void MainForm::on_actionAbout_triggered()
 {\r
     qDebug() << "About";\r
     QString aboutText;\r
-    aboutText.append("EasyList (c) 2010\n\n");\r
-    aboutText.append("Created by Willem Liu.\n");\r
-    aboutText.append("Created with QtCreator.\n");\r
+    aboutText.append("<html><body>");\r
+    aboutText.append("EasyList (c) 2010-");\r
+    aboutText.append(QDate::currentDate().toString("yyyy"));\r
+    aboutText.append("<br><br>");\r
+    aboutText.append("Created by Willem Liu.<br>");\r
+    aboutText.append("Created with QtCreator.<br><br>");\r
+    aboutText.append("Please <a href='http://www.willemliu.nl/donate'>donate</a> any amount you deem this app is worthy to keep me going on.<br><br>");\r
+    aboutText.append("</body></html>");\r
     QMessageBox::about(this, "EasyList", aboutText);\r
 }\r
 \r
@@ -208,3 +221,39 @@ void MainForm::on_actionLists_triggered()
     listForm->saveList();\r
     changeWidget(2);\r
 }\r
+\r
+void MainForm::on_actionSync_triggered()\r
+{\r
+    QString username = settings->value(USERNAME, "").toString();\r
+    QString password = settings->value(PASSWORD, "").toString();\r
+    QString url = settings->value(SYNC_URL, DEFAULT_SYNC_URL).toString();\r
+    url.append("?username=" + username);\r
+    url.append("&password=" + password);\r
+    qDebug() << url;\r
+    requestWebpage->post(url,settings->value(LIST_TEXT,"").toString().toUtf8());\r
+    //requestWebpage->fetch(url);\r
+}\r
+\r
+void MainForm::slotSyncList(QNetworkReply* pReply)\r
+{\r
+    settings->setValue(LIST_TEXT, MyCheckBoxContainer::getInstance()->getListText());\r
+    SystemSettings::getInstance()->saveCurrentList();\r
+    QByteArray data=pReply->readAll();\r
+    QString list = QString::fromUtf8(data);\r
+    settings->setValue(LIST_TEXT, list);\r
+    settings->setValue(SELECTED_LIST_NAME, SYNC_LIST_NAME);\r
+    settings->setValue(SYNC_LIST_NAME, settings->value(LIST_TEXT, ""));\r
+    QStringList listNames = settings->value(LIST_NAMES, "").toStringList();\r
+    if(listNames.contains(SYNC_LIST_NAME) == false)\r
+    {\r
+        listNames.append(SYNC_LIST_NAME);\r
+    }\r
+    settings->setValue(LIST_NAMES, QVariant(listNames));\r
+    changeWidget(0);\r
+    pReply->deleteLater();\r
+}\r
+\r
+void MainForm::on_actionSetting_triggered()\r
+{\r
+    changeWidget(3);\r
+}\r