From 9d6c79522dde67a1810d6a040bd40e12f8eaae44 Mon Sep 17 00:00:00 2001 From: Carlos Bohórquez Date: Fri, 11 Sep 2015 14:53:30 +0200 Subject: Several changes Use the global variable sessionsettings_config_file in all places that must be used. QSettings::setPath was already setted so it's not needed. Deleted. Instead using variable for date and time format in case user settings aren't setted, now we go to Qt::DefaultLocaleShortDate. To perform this operation, we must work with Date and Time separately. Now DirWidget::date_format is an QStringList, first item for date and second for time. The QDateTime with format "yyyyMMddhhmmsszzz" is stored on whatsThis variable for being used in sort operations. CQTreeWidgetItem operator< function has been simplified. Now, to check dates, we used the value stored in whatsThis. --- lumina-fm/widgets/DirWidget.h | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'lumina-fm/widgets/DirWidget.h') diff --git a/lumina-fm/widgets/DirWidget.h b/lumina-fm/widgets/DirWidget.h index 474531f3..6f0e3d8b 100644 --- a/lumina-fm/widgets/DirWidget.h +++ b/lumina-fm/widgets/DirWidget.h @@ -54,7 +54,7 @@ public: void setShowCloseButton(bool show); //Date format for show items - static QString getDateFormat(); + static QStringList getDateFormat(); static void setDateFormat(); public slots: @@ -98,7 +98,7 @@ private: //Functions for internal use void setupConnections(); QStringList currentSelection(); - static QString date_format; + static QStringList date_format; private slots: //UI BUTTONS/Actions @@ -185,22 +185,8 @@ public: inline virtual bool operator<(const QTreeWidgetItem &tmp) const { int column = this->treeWidget()->sortColumn(); // We are in date text - if(column == DirWidget::DATEMOD || column == DirWidget::DATECREATE) { - // Get the stored text and try to convert to QDateTime - QString text = this->text(column); - QString text_tmp = tmp.text(column); - QDateTime date_time = QDateTime::fromString(text, DirWidget::getDateFormat()); - QDateTime date_time_tmp = QDateTime::fromString(text_tmp, DirWidget::getDateFormat()); - // If the conversion are ok in both objects, compare them - if(date_time.isValid() && date_time_tmp.isValid()) - return date_time < date_time_tmp; - // If some of the dates are invalid, use the base class implementation (order by string) - else { - if(DEBUG) - qDebug() << "Cannot convert the date. Texts arrived are " << text << " and " << text_tmp; - return QTreeWidgetItem::operator <(tmp); - } - } + if(column == DirWidget::DATEMOD || column == DirWidget::DATECREATE) + return this->whatsThis(column) < tmp.whatsThis(column); // We are in size text else if(column == DirWidget::SIZE) { QString text = this->text(column); -- cgit