cistka
This commit is contained in:
parent
233832f496
commit
a43b1742b0
@ -221,7 +221,6 @@ set(APP_SOURCES
|
||||
src/core/debugging.cpp
|
||||
src/core/settings.cpp
|
||||
src/core/systemfactory.cpp
|
||||
src/core/datetime.cpp
|
||||
src/core/localization.cpp
|
||||
src/core/dynamicshortcuts.cpp
|
||||
src/core/basenetworkaccessmanager.cpp
|
||||
|
@ -92,8 +92,8 @@ QSqlDatabase DatabaseFactory::initialize(const QString &connection_name) {
|
||||
QString::SkipEmptyParts);
|
||||
database.exec("BEGIN TRANSACTION");
|
||||
|
||||
foreach(QString i, statements) {
|
||||
query = database.exec(i);
|
||||
foreach(const QString &statement, statements) {
|
||||
query = database.exec(statement);
|
||||
if (query.lastError().isValid()) {
|
||||
qFatal("Database initialization failed. Initialization script '%s' is not correct.",
|
||||
APP_DB_INIT_FILE);
|
||||
|
@ -1,33 +0,0 @@
|
||||
#include <QLocale>
|
||||
#include <QRegExp>
|
||||
#include <QStringList>
|
||||
|
||||
#include "core/datetime.h"
|
||||
|
||||
|
||||
DateTime::DateTime() {
|
||||
}
|
||||
|
||||
QDateTime DateTime::fromString(const QString &date_time) {
|
||||
QString date = date_time.simplified();
|
||||
QDateTime dt;
|
||||
QString temp;
|
||||
QLocale locale(QLocale::C);
|
||||
QStringList date_patterns;
|
||||
date_patterns << "yyyy-MM-ddTHH:mm:ss" << "MMM dd yyyy hh:mm:ss" <<
|
||||
"MMM hd yyyy hh:mm:ss" << "ddd, dd MMM yyyy HH:mm:ss" <<
|
||||
"dd MMM yyyy" << "yyyy-MM-dd HH:mm:ss.z" << "yyyy-MM-dd";
|
||||
|
||||
// Iterate over patterns and check if input date/time matches the pattern.
|
||||
foreach (QString pattern, date_patterns) {
|
||||
temp = date.left(pattern.size());
|
||||
dt = locale.toDateTime(temp, pattern);
|
||||
if (dt.isValid()) {
|
||||
return dt;
|
||||
}
|
||||
}
|
||||
|
||||
qWarning("Problem with parsing date '%s', returning invalid QDateTime instance.",
|
||||
qPrintable(date));
|
||||
return QDateTime();
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
#ifndef DATE_H
|
||||
#define DATE_H
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
|
||||
class DateTime {
|
||||
private:
|
||||
explicit DateTime();
|
||||
|
||||
public:
|
||||
// Returns QDatetime instance from input QString.
|
||||
// If parsing fails, then invalid QDateTime is returned.
|
||||
// NOTE: Format of input date-time string is brute-force-determined.
|
||||
static QDateTime fromString(const QString &date_time);
|
||||
};
|
||||
|
||||
#endif // DATE_H
|
@ -19,7 +19,7 @@ QList<Language> Localization::getInstalledLanguages() {
|
||||
QDir::Name);
|
||||
QTranslator translator;
|
||||
|
||||
foreach (QFileInfo file, file_list) {
|
||||
foreach (const QFileInfo &file, file_list) {
|
||||
if (translator.load(file.absoluteFilePath())) {
|
||||
Language new_language;
|
||||
new_language.m_name = translator.translate("QObject", "LANG_NAME");
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "qtsingleapplication/qtsingleapplication.h"
|
||||
|
||||
#include "core/defs.h"
|
||||
#include "core/datetime.h"
|
||||
#include "core/textfactory.h"
|
||||
#include "core/messagesmodel.h"
|
||||
#include "core/databasefactory.h"
|
||||
#include "gui/iconthemefactory.h"
|
||||
@ -82,7 +82,7 @@ Message MessagesModel::messageAt(int row_index) const {
|
||||
message.m_contents = rec.value(MSG_DB_CONTENTS_INDEX).toString();
|
||||
message.m_title = rec.value(MSG_DB_TITLE_INDEX).toString();
|
||||
message.m_url = rec.value(MSG_DB_URL_INDEX).toString();
|
||||
message.m_updated = DateTime::fromString(rec.value(MSG_DB_DUPDATED_INDEX).toString());
|
||||
message.m_updated = TextFactory::parseDateTime(rec.value(MSG_DB_DUPDATED_INDEX).toString());
|
||||
|
||||
return message;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QDateTime>
|
||||
#include <QLocale>
|
||||
#include <QRegExp>
|
||||
|
||||
@ -27,7 +26,7 @@ QDateTime TextFactory::parseDateTime(const QString &date_time) {
|
||||
"YYYY-MM-DDThh:mm:ssTZD";
|
||||
|
||||
// Iterate over patterns and check if input date/time matches the pattern.
|
||||
foreach (QString pattern, date_patterns) {
|
||||
foreach (const QString &pattern, date_patterns) {
|
||||
temp = date.left(pattern.size());
|
||||
dt = locale.toDateTime(temp, pattern);
|
||||
if (dt.isValid()) {
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef TEXTFACTORY_H
|
||||
#define TEXTFACTORY_H
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
#include "core/defs.h"
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
|
||||
#include "core/datetime.h"
|
||||
#include "core/textfactory.h"
|
||||
#include "gui/formabout.h"
|
||||
#include "gui/iconthemefactory.h"
|
||||
|
||||
@ -64,8 +64,8 @@ FormAbout::FormAbout(QWidget *parent) : QDialog(parent), m_ui(new Ui::FormAbout)
|
||||
CMAKE_SYSTEM,
|
||||
CMAKE_VERSION,
|
||||
APP_REVISION,
|
||||
DateTime::fromString(QString("%1 %2").arg(__DATE__,
|
||||
__TIME__)).toString(Qt::DefaultLocaleShortDate),
|
||||
TextFactory::parseDateTime(QString("%1 %2").arg(__DATE__,
|
||||
__TIME__)).toString(Qt::DefaultLocaleShortDate),
|
||||
QT_VERSION_STR,
|
||||
qVersion(),
|
||||
APP_NAME));
|
||||
|
Loading…
x
Reference in New Issue
Block a user