From: Willem Liu Date: Sun, 26 Sep 2010 16:51:00 +0000 (+0200) Subject: Added sort alphabetically. Changed Checked bottom to Checked to bottom. X-Git-Tag: easylist-0.3.9 X-Git-Url: http://git.maemo.org/git/?p=easylist;a=commitdiff_plain;h=55dcf825a423aaa09db5b9fea911614700223f88 Added sort alphabetically. Changed Checked bottom to Checked to bottom. --- diff --git a/debian/changelog b/debian/changelog index 04c223d..d132f6b 100755 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,7 @@ easylist (0.3.9) unstable; urgency=low - * Fixed a small bug. When going to Edit list mode the list text is saved to QSettings. + * Alphabetical sorting now possible. + * Label "Checked bottom" changed to "Checked to bottom". + * Automatic display orientation detection now possible. -- Willem Liu Tue, 07 Sep 2010 13:56:12 +0200 diff --git a/easylist.pro.user b/easylist.pro.user index 84b0fed..7ad3617 100755 --- a/easylist.pro.user +++ b/easylist.pro.user @@ -2,7 +2,7 @@ ProjectExplorer.Project.ActiveTarget - 1 + 0 ProjectExplorer.Project.EditorSettings diff --git a/src/mainform.cpp b/src/mainform.cpp index 690c94c..9584bc0 100755 --- a/src/mainform.cpp +++ b/src/mainform.cpp @@ -12,6 +12,12 @@ MainForm::MainForm(QWidget *parent) : connect(SystemSettings::getInstance(), SIGNAL(signalKeyboardClosed(bool)), this, SLOT(keyboardClosed(bool))); + ui->actionAuto_Orientation->setChecked(settings->value(AUTO_ORIENTATION).toBool()); + on_actionAuto_Orientation_triggered(); + + ui->actionSort_A_Z->setChecked(settings->value(SORT_A_Z).toBool()); + on_actionSort_A_Z_triggered(); + // Set a default value for CHECKED_ITEMS_TO_BOTTOM if(settings->contains(CHECKED_ITEMS_TO_BOTTOM) == false) { @@ -35,13 +41,16 @@ MainForm::MainForm(QWidget *parent) : } // If keyboard is opened at start. We do landscape mode. // Otherwise we do what's read from the QSettings. - if(SystemSettings::getInstance()->getKeyboardClosed() == false) + if(ui->actionAuto_Orientation->isChecked() == false) { - setLandscapeMode(true); - } - else - { - setLandscapeMode(landscape); + if(SystemSettings::getInstance()->getKeyboardClosed() == false) + { + setLandscapeMode(true); + } + else + { + setLandscapeMode(landscape); + } } // Populate the QStackedWidget. ListForm is set as the current widget. @@ -108,13 +117,16 @@ void MainForm::changeWidget(SlideWidget * currentWidget) void MainForm::keyboardClosed(bool closed) { // When keyboard is opened. - if(closed == false) - { - setLandscapeMode(true); - } - else + if(ui->actionAuto_Orientation->isChecked() == false) { - setLandscapeMode(landscape); + if(closed == false) + { + setLandscapeMode(true); + } + else + { + setLandscapeMode(landscape); + } } } @@ -125,6 +137,7 @@ void MainForm::setLandscapeMode(bool landscape) tempLandscapeMode = true; qDebug() << LANDSCAPE; #ifdef Q_WS_MAEMO_5 + setAttribute(Qt::WA_Maemo5AutoOrientation, false); setAttribute(Qt::WA_Maemo5LandscapeOrientation, true); setAttribute(Qt::WA_Maemo5PortraitOrientation, false); #endif @@ -134,6 +147,7 @@ void MainForm::setLandscapeMode(bool landscape) tempLandscapeMode = false; qDebug() << PORTRAIT; #ifdef Q_WS_MAEMO_5 + setAttribute(Qt::WA_Maemo5AutoOrientation, false); setAttribute(Qt::WA_Maemo5PortraitOrientation, true); setAttribute(Qt::WA_Maemo5LandscapeOrientation, false); #endif @@ -144,8 +158,10 @@ void MainForm::on_actionRotate_triggered() { qDebug() << "Rotate"; - landscape = !tempLandscapeMode; + landscape = (width() < height()); settings->setValue(LANDSCAPE, landscape); + ui->actionAuto_Orientation->setChecked(false); + settings->setValue(AUTO_ORIENTATION, ui->actionAuto_Orientation->isChecked()); setLandscapeMode(landscape); } @@ -175,6 +191,8 @@ void MainForm::closeEvent(QCloseEvent *event) void MainForm::on_actionAuto_Orientation_triggered() { + settings->setValue(AUTO_ORIENTATION, ui->actionAuto_Orientation->isChecked()); + qDebug() << "Auto orientation" << ui->actionAuto_Orientation->isChecked(); if(ui->actionAuto_Orientation->isChecked()) { #ifdef Q_WS_MAEMO_5 @@ -185,9 +203,12 @@ void MainForm::on_actionAuto_Orientation_triggered() } else { -#ifdef Q_WS_MAEMO_5 - setAttribute(Qt::WA_Maemo5AutoOrientation, false); -#endif setLandscapeMode(landscape); } } + +void MainForm::on_actionSort_A_Z_triggered() +{ + settings->setValue(SORT_A_Z, ui->actionSort_A_Z->isChecked()); + MyCheckBoxContainer::getInstance()->setSortAlphabetically(ui->actionSort_A_Z->isChecked()); +} diff --git a/src/mainform.h b/src/mainform.h index 0155c51..6954f66 100755 --- a/src/mainform.h +++ b/src/mainform.h @@ -22,7 +22,9 @@ #define CHECKED_ITEMS_TO_BOTTOM "CheckedItemsToBottom" #define LANDSCAPE "Landscape" #define PORTRAIT "Portrait" +#define AUTO_ORIENTATION "AutoOrientation" #define LIST_TEXT "ListText" +#define SORT_A_Z "SortAlphabetically" namespace Ui { class MainForm; @@ -55,6 +57,7 @@ protected: void closeEvent(QCloseEvent *event); private slots: + void on_actionSort_A_Z_triggered(); void on_actionAuto_Orientation_triggered(); void on_actionChecked_bottom_triggered(); void on_actionAbout_triggered(); diff --git a/src/mainform.ui b/src/mainform.ui index 3c7b546..6a59343 100755 --- a/src/mainform.ui +++ b/src/mainform.ui @@ -53,7 +53,7 @@ - Checked bottom + Checked to bottom @@ -63,6 +63,13 @@ + + + Sort A-Z + + + + @@ -83,7 +90,7 @@ true - Checked bottom + Checked to bottom @@ -94,6 +101,14 @@ Auto Orientation + + + true + + + Sort A-Z + + diff --git a/src/mycheckboxcontainer.cpp b/src/mycheckboxcontainer.cpp index 5296f17..edcab32 100755 --- a/src/mycheckboxcontainer.cpp +++ b/src/mycheckboxcontainer.cpp @@ -8,6 +8,7 @@ MyCheckBoxContainer::MyCheckBoxContainer() ++instances; qDebug() << "MyCheckBoxContainer instances:" << instances; sortToBottom = false; + sortAlphabetically = false; } MyCheckBoxContainer::~MyCheckBoxContainer() @@ -29,6 +30,10 @@ MyCheckBoxContainer * MyCheckBoxContainer::getInstance() void MyCheckBoxContainer::add(QString item) { QStringList list = item.split("\n"); + if(sortAlphabetically) + { + list.sort(); + } foreach(QString item, list) { if(item.length() > 0) @@ -52,6 +57,7 @@ void MyCheckBoxContainer::add(QString item) void MyCheckBoxContainer::set(QString item) { + qDebug() << item; clear(); add(item); } @@ -77,11 +83,43 @@ void MyCheckBoxContainer::sortCheckedToBottom() { if(item->isChecked()) { - tempListChecked.append(item); + if(sortAlphabetically) + { + int size = tempListChecked.size(); + int pos = 0; + for(pos = 0; pos < size; ++pos) + { + if(tempListChecked[pos]->text() > item->text()) + { + break; + } + } + tempListChecked.insert(pos, item); + } + else + { + tempListChecked.append(item); + } } else { - tempList.append(item); + if(sortAlphabetically) + { + int size = tempList.size(); + int pos = 0; + for(pos = 0; pos < size; ++pos) + { + if(tempList[pos]->text() > item->text()) + { + break; + } + } + tempList.insert(pos, item); + } + else + { + tempList.append(item); + } } } checkBoxes.clear(); @@ -117,6 +155,10 @@ void MyCheckBoxContainer::uncheckAll() { item->setChecked(false); } + if(sortAlphabetically) + { + set(getListText()); + } } void MyCheckBoxContainer::removeChecked() @@ -140,6 +182,15 @@ void MyCheckBoxContainer::setSortCheckedToBottom(bool sortToBottom) sortCheckedToBottom(); } +void MyCheckBoxContainer::setSortAlphabetically(bool sortAlphabetically) +{ + this->sortAlphabetically = sortAlphabetically; + if(sortAlphabetically) + { + set(getListText()); + } +} + void MyCheckBoxContainer::clickedAction() { qDebug() << "Clicked a MyCheckBox"; diff --git a/src/mycheckboxcontainer.h b/src/mycheckboxcontainer.h index efffb63..91f3de6 100755 --- a/src/mycheckboxcontainer.h +++ b/src/mycheckboxcontainer.h @@ -24,6 +24,7 @@ public: void uncheckAll(); void removeChecked(); void setSortCheckedToBottom(bool sortToBottom); + void setSortAlphabetically(bool sortAlphabetically); void sortCheckedToBottom(); private: @@ -32,6 +33,7 @@ private: static int instances; bool sortToBottom; + bool sortAlphabetically; MyCheckBoxContainer(); signals: