From f7ff7eba66ca187d60f0f6a7a83d72fea59b0546 Mon Sep 17 00:00:00 2001 From: Willem Liu Date: Thu, 16 Sep 2010 18:40:31 +0200 Subject: [PATCH] Changed changelog, copyright. Support for sorting checked items to bottom. --- debian/changelog | 6 +-- debian/copyright | 12 +++--- easylist.pro.user | 38 ++++++++++------- src/listwindow.ui | 18 ++++++++ src/mainwindow.cpp | 120 +++++++++++++++++++++++++++++++++++++++++++++------- src/mainwindow.h | 12 +++++- src/src.pro | 7 +-- 7 files changed, 166 insertions(+), 47 deletions(-) diff --git a/debian/changelog b/debian/changelog index 0a1e8f3..1bf933a 100755 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,5 @@ -easylist (0.1) unstable; urgency=low +easylist (0.3.4) unstable; urgency=low - * Initial Release. + * Now supports sorting checked items to bottom of the list. - -- unknown <> Tue, 07 Sep 2010 13:56:12 +0200 + -- Willem Liu Tue, 07 Sep 2010 13:56:12 +0200 diff --git a/debian/copyright b/debian/copyright index 9ebd3a4..a283cb7 100755 --- a/debian/copyright +++ b/debian/copyright @@ -1,17 +1,15 @@ -This package was debianized by unknown <> on +This package was debianized by Willem Liu on Tue, 07 Sep 2010 13:56:12 +0200. -It was downloaded from +It was downloaded from http://gitorious.org/easylist Upstream Author(s): - - + Willem Liu Copyright: - - + Copyright (C) 2010 Willem Liu License: @@ -32,7 +30,7 @@ License: On Debian systems, the complete text of the GNU General Public License can be found in `/usr/share/common-licenses/GPL'. -The Debian packaging is (C) 2010, unknown <> and +The Debian packaging is (C) 2010, Willem Liu and is licensed under the GPL, see above. diff --git a/easylist.pro.user b/easylist.pro.user index 2e04f1b..43780d5 100755 --- a/easylist.pro.user +++ b/easylist.pro.user @@ -46,7 +46,7 @@ Debug Qt4ProjectManager.Qt4BuildConfiguration 2 - C:/dev/cpp/easylist-build-desktop + C:/dev/cpp/easylist-0.3.4-build-desktop 20 2 false @@ -80,7 +80,7 @@ Release Qt4ProjectManager.Qt4BuildConfiguration 0 - C:/dev/cpp/easylist-build-desktop + C:/dev/cpp/easylist-0.3.4-build-desktop 20 2 true @@ -123,14 +123,15 @@ + true Qt4ProjectManager.MaemoPackageCreationStep - C:/dev/cpp/easylist/src/data/26x26/easylist.png - C:/dev/cpp/easylist/src/data/40x40/easylist.png - C:/dev/cpp/easylist/src/data/48x48/easylist.png - C:/dev/cpp/easylist/src/data/64x64/easylist.png - C:/dev/cpp/easylist/src/easylist.desktop + C:/dev/cpp/easylist-0.3.4/src/data/26x26/easylist.png + C:/dev/cpp/easylist-0.3.4/src/data/40x40/easylist.png + C:/dev/cpp/easylist-0.3.4/src/data/48x48/easylist.png + C:/dev/cpp/easylist-0.3.4/src/data/64x64/easylist.png + C:/dev/cpp/easylist-0.3.4/src/easylist.desktop false /usr/local/bin/easylist @@ -141,6 +142,7 @@ /usr/share/icons/hicolor/64x64/apps/easylist.png /usr/share/applications/hildon/easylist.desktop + 0.0.1 3 @@ -158,7 +160,7 @@ Debug Qt4ProjectManager.Qt4BuildConfiguration 2 - C:/dev/cpp/easylist + C:/dev/cpp/easylist-0.3.4 4 9 false @@ -177,14 +179,15 @@ + true Qt4ProjectManager.MaemoPackageCreationStep - C:/dev/cpp/easylist/src/easylist.desktop - C:/dev/cpp/easylist/src/data/26x26/easylist.png - C:/dev/cpp/easylist/src/data/40x40/easylist.png - C:/dev/cpp/easylist/src/data/48x48/easylist.png - C:/dev/cpp/easylist/src/data/64x64/easylist.png + C:/dev/cpp/easylist-0.3.4/src/easylist.desktop + C:/dev/cpp/easylist-0.3.4/src/data/26x26/easylist.png + C:/dev/cpp/easylist-0.3.4/src/data/40x40/easylist.png + C:/dev/cpp/easylist-0.3.4/src/data/48x48/easylist.png + C:/dev/cpp/easylist-0.3.4/src/data/64x64/easylist.png false /opt/easylist/bin/easylist @@ -195,6 +198,7 @@ /usr/share/icons/hicolor/48x48/apps/easylist.png /usr/share/icons/hicolor/64x64/apps/easylist.png + 0.3.4 3 @@ -212,7 +216,7 @@ Release Qt4ProjectManager.Qt4BuildConfiguration 0 - C:/dev/cpp/easylist + C:/dev/cpp/easylist-0.3.4 4 9 false @@ -223,9 +227,11 @@ New Maemo Run Configuration Qt4ProjectManager.MaemoRunConfiguration - 1 - + + + + 1 diff --git a/src/listwindow.ui b/src/listwindow.ui index a05a46d..266fa28 100755 --- a/src/listwindow.ui +++ b/src/listwindow.ui @@ -112,8 +112,15 @@ + + + Checked Bottom + + + + @@ -125,6 +132,17 @@ Rotate + + + true + + + false + + + Checked Bottom + + diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 0207601..8bab599 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -24,8 +24,6 @@ #include "ui_mainwindow.h" #include "ui_listwindow.h" -#define DBUS_KEYBOARD_SLIDE "/org/freedesktop/Hal/devices/platform_slide" - /** * Constructor. * Settings are initialised here. @@ -46,14 +44,21 @@ MainWindow::MainWindow(QWidget *parent) : QString("PropertyModified"), this, SLOT(slotKeyboardSlide())); // Initialise the settings. - settings = new QSettings("WillemLiu", "easylist"); + settings = new QSettings(WILLEM_LIU, EASY_LIST); + + // Set a default value for CHECKED_ITEMS_TO_BOTTOM + if(settings->contains(CHECKED_ITEMS_TO_BOTTOM) == false) + { + settings->setValue(CHECKED_ITEMS_TO_BOTTOM, false); + } + // We always start in landscape mode. - landscape = settings->value("Landscape").toBool(); - if(settings->contains("Landscape")) + landscape = settings->value(LANDSCAPE).toBool(); + if(settings->contains(LANDSCAPE)) { - landscape = settings->value("Landscape").toBool(); + landscape = settings->value(LANDSCAPE).toBool(); } - settings->setValue("Landscape", landscape); + settings->setValue(LANDSCAPE, landscape); // If keyboard is opened at start. We do landscape mode. // Otherwise we do what's read from the QSettings. if(isKeyboardClosed() == false) @@ -66,6 +71,7 @@ MainWindow::MainWindow(QWidget *parent) : } // Auto-detect portrait/landscape mode. Only works on top widget. // setAttribute(Qt::WA_Maemo5AutoOrientation, true); + showListWindow(); } @@ -141,12 +147,14 @@ void MainWindow::slotEditWindowCancel() void MainWindow::slotEditWindowSave() { qDebug() << "Save"; - settings->setValue("ListText", editUi->textEdit->toPlainText()); + settings->setValue(LIST_TEXT, editUi->textEdit->toPlainText()); showListWindow(); } /** * Slot for action from Clear selected button in de the list window. + * It clears all QCheckBoxes from the layout, removes all checked items from + * the list text and finally calls generateList(). * * @fn slotListWindowClearSelected */ @@ -164,7 +172,7 @@ void MainWindow::slotListWindowClearSelected() } } - settings->setValue("ListText", listText); + settings->setValue(LIST_TEXT, listText); generateList(); } @@ -197,7 +205,72 @@ void MainWindow::slotListWindowSaveChecked() listText.append("\n"); } - settings->setValue("ListText", listText); + settings->setValue(LIST_TEXT, listText); +} + +/** + * Is called when a checkbox has been clicked. + * + * @fn slotActionCheckBox + * @param bool checked - true if checkbox is checked. + */ +void MainWindow::slotActionCheckBox(bool checked) +{ + qDebug() << "CheckBox checked=" << checked; + slotListWindowSaveChecked(); + if(settings->value(CHECKED_ITEMS_TO_BOTTOM).toBool()) + { + slotSortCheckedBottom(); + // Remove all the checkboxes from the screen. + foreach(QCheckBox * cb, checkBoxes) + { + cb->deleteLater(); + } + generateList(); + } + else + { + qDebug() << "No need to sort items to bottom"; + } +} + +/** + * Sort checked items to bottom of the list text and returns the new list text. + * + * @fn slotSortCheckedBottom + * + * @return QString - the new list text. + */ +QString MainWindow::slotSortCheckedBottom() +{ + QString result(settings->value(LIST_TEXT).toString()); + if(settings->value(CHECKED_ITEMS_TO_BOTTOM).toBool()) + { + QStringList list = result.split("\n"); + QString listText(""); + QString checkedListText(""); + foreach(QString item, list) + { + if(item.length() > 0) + { + if(item.startsWith("!")) + { + checkedListText.append(item); + checkedListText.append("\n"); + } + else + { + listText.append(item); + listText.append("\n"); + } + } + } + listText.append(checkedListText); + qDebug() << "Sort checked items to bottom"; + settings->setValue(LIST_TEXT, listText); + result = listText; + } + return result; } /** @@ -209,7 +282,7 @@ void MainWindow::showEditWindow() { slotListWindowSaveChecked(); editUi->setupUi(this); - editUi->textEdit->setText(settings->value("ListText").toString()); + editUi->textEdit->setText(settings->value(LIST_TEXT).toString()); connect(editUi->savePushButton, SIGNAL(clicked()), this, SLOT(slotEditWindowSave())); connect(editUi->cancelPushButton, SIGNAL(clicked()), this, SLOT(slotEditWindowCancel())); } @@ -223,9 +296,12 @@ void MainWindow::showListWindow() { listUi->setupUi(this); listUi->listVerticalLayout->setAlignment(Qt::AlignTop); + listUi->actionChecked_Bottom->setChecked(settings->value(CHECKED_ITEMS_TO_BOTTOM).toBool()); + slotSortCheckedBottom(); generateList(); connect(listUi->editListPushButton, SIGNAL(clicked()), this, SLOT(slotListWindowEdit())); connect(listUi->clearSelectedPushButton, SIGNAL(clicked()), this, SLOT(slotListWindowClearSelected())); + connect(listUi->menuChecked_Bottom, SIGNAL(triggered(QAction*)), this, SLOT(slotActionCheckedBottom(QAction*))); connect(listUi->menuAbout, SIGNAL(triggered(QAction*)), this, SLOT(slotActionAbout(QAction*))); connect(listUi->menuRotate, SIGNAL(triggered(QAction*)), this, SLOT(slotActionRotate(QAction*))); } @@ -241,7 +317,7 @@ void MainWindow::generateList() qDebug() << "Generate List"; checkBoxes.clear(); - QString text = settings->value("ListText").toString(); + QString text = settings->value(LIST_TEXT).toString(); QStringList list = text.split("\n"); foreach(QString item, list) @@ -249,6 +325,7 @@ void MainWindow::generateList() if(item.length() > 0) { QCheckBox * cb = new QCheckBox(item); + connect(cb, SIGNAL(clicked(bool)), this, SLOT(slotActionCheckBox(bool))); if(item.startsWith("!")) { QString itemName(item.right(item.length()-1)); @@ -285,7 +362,7 @@ void MainWindow::slotActionRotate(QAction* action) qDebug() << "Rotate" << action->text(); landscape = !tempLandscapeMode; - settings->setValue("Landscape", landscape); + settings->setValue(LANDSCAPE, landscape); setLandscapeMode(landscape); } @@ -297,14 +374,14 @@ void MainWindow::setLandscapeMode(bool landscape) if(landscape) { tempLandscapeMode = true; - qDebug() << "Landscape"; + qDebug() << LANDSCAPE; setAttribute(Qt::WA_Maemo5LandscapeOrientation, true); setAttribute(Qt::WA_Maemo5PortraitOrientation, false); } else { tempLandscapeMode = false; - qDebug() << "Portrait"; + qDebug() << PORTRAIT; setAttribute(Qt::WA_Maemo5PortraitOrientation, true); setAttribute(Qt::WA_Maemo5LandscapeOrientation, false); } @@ -325,3 +402,16 @@ void MainWindow::slotActionAbout(QAction* action) aboutText.append("Created with QtCreator.\n"); QMessageBox::about(this, "EasyList", aboutText); } + +/** + * Is called when the Checked Bottom menu item is triggered. + * The menu item is a checkable item. So we need to check if it's checked or not. + * + * @fn slotActionCheckedBottom + * @param QAction* action - the action. + */ +void MainWindow::slotActionCheckedBottom(QAction* action) +{ + qDebug() << "Checked Bottom" << action->text() << listUi->actionChecked_Bottom->isChecked(); + settings->setValue(CHECKED_ITEMS_TO_BOTTOM, listUi->actionChecked_Bottom->isChecked()); +} diff --git a/src/mainwindow.h b/src/mainwindow.h index d0a63bb..121270b 100755 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -33,6 +33,14 @@ #include #include +#define WILLEM_LIU "WillemLiu" +#define EASY_LIST "easylist" +#define DBUS_KEYBOARD_SLIDE "/org/freedesktop/Hal/devices/platform_slide" +#define CHECKED_ITEMS_TO_BOTTOM "CheckedItemsToBottom" +#define LANDSCAPE "Landscape" +#define PORTRAIT "Portrait" +#define LIST_TEXT "ListText" + namespace Ui { class EditWindow; class ListWindow; @@ -69,10 +77,12 @@ public slots: void slotListWindowEdit(); void slotListWindowClearSelected(); void slotListWindowSaveChecked(); - + void slotActionCheckBox(bool checked); + QString slotSortCheckedBottom(); void slotKeyboardSlide(); private slots: + void slotActionCheckedBottom(QAction* action); void slotActionAbout(QAction* action); void slotActionRotate(QAction* action); }; diff --git a/src/src.pro b/src/src.pro index 6b6f419..5f7c16f 100755 --- a/src/src.pro +++ b/src/src.pro @@ -23,14 +23,11 @@ FORMS += mainwindow.ui \ listwindow.ui CONFIG += mobility -MOBILITY = unix { #VARIABLES - isEmpty(PREFIX) { - PREFIX = /usr/local - } - BINDIR = $$PREFIX/bin + PREFIX = /usr + BINDIR = /opt/easylist/bin DATADIR = $$PREFIX/share DEFINES += DATADIR=\\\"$$DATADIR\\\" PKGDATADIR=\\\"$$PKGDATADIR\\\" -- 1.7.9.5