Changeset View
Changeset View
Standalone View
Standalone View
src/plugins/queries/kexiquerydesignerguieditor.cpp
Context not available. | |||||
53 | #include <KLocalizedString> | 53 | #include <KLocalizedString> | ||
---|---|---|---|---|---|
54 | 54 | | |||
55 | #include <QDomDocument> | 55 | #include <QDomDocument> | ||
56 | #include <QRegExp> | 56 | #include <QRegularExpression> | ||
57 | #include <QSplitter> | 57 | #include <QSplitter> | ||
58 | #include <QDragMoveEvent> | 58 | #include <QDragMoveEvent> | ||
59 | #include <QDropEvent> | 59 | #include <QDropEvent> | ||
Context not available. | |||||
1377 | return KDbExpression(); | 1377 | return KDbExpression(); | ||
1378 | 1378 | | |||
1379 | KDbExpression valueExpr; | 1379 | KDbExpression valueExpr; | ||
1380 | QRegExp re; | 1380 | QRegularExpressionMatch match; | ||
1381 | if (str.length() >= 2 && | 1381 | if (str.length() >= 2 && | ||
1382 | ( | 1382 | ( | ||
1383 | (str.startsWith(QLatin1Char('"')) && str.endsWith(QLatin1Char('"'))) | 1383 | (str.startsWith(QLatin1Char('"')) && str.endsWith(QLatin1Char('"'))) | ||
Context not available. | |||||
1386 | valueExpr = KDbConstExpression(KDbToken::CHARACTER_STRING_LITERAL, str.mid(1, str.length() - 2)); | 1386 | valueExpr = KDbConstExpression(KDbToken::CHARACTER_STRING_LITERAL, str.mid(1, str.length() - 2)); | ||
1387 | } else if (str.startsWith(QLatin1Char('[')) && str.endsWith(QLatin1Char(']'))) { | 1387 | } else if (str.startsWith(QLatin1Char('[')) && str.endsWith(QLatin1Char(']'))) { | ||
1388 | valueExpr = KDbQueryParameterExpression(str.mid(1, str.length() - 2)); | 1388 | valueExpr = KDbQueryParameterExpression(str.mid(1, str.length() - 2)); | ||
1389 | } else if ((re = QRegExp("(\\d{1,4})-(\\d{1,2})-(\\d{1,2})")).exactMatch(str)) { | 1389 | } else if ((match = QRegularExpression("^(\\d{1,4})-(\\d{1,2})-(\\d{1,2})$").match(str)).hasMatch()) { | ||
1390 | valueExpr = KDbConstExpression(KDbToken::DATE_CONST, QDate::fromString( | 1390 | valueExpr = KDbConstExpression(KDbToken::DATE_CONST, QDate::fromString( | ||
1391 | re.cap(1).rightJustified(4, '0') + "-" + re.cap(2).rightJustified(2, '0') | 1391 | match.captured(1).rightJustified(4, '0') + "-" + match.captured(2).rightJustified(2, '0') | ||
1392 | + "-" + re.cap(3).rightJustified(2, '0'), Qt::ISODate)); | 1392 | + "-" + match.captured(3).rightJustified(2, '0'), Qt::ISODate)); | ||
1393 | } else if ((re = QRegExp("(\\d{1,2}):(\\d{1,2})")).exactMatch(str) | 1393 | } else if ((match = QRegularExpression("^(\\d{1,2}):(\\d{1,2})$").match(str)).hasMatch() | ||
1394 | || (re = QRegExp("(\\d{1,2}):(\\d{1,2}):(\\d{1,2})")).exactMatch(str)) { | 1394 | || (match = QRegularExpression("^(\\d{1,2}):(\\d{1,2}):(\\d{1,2})$").match(str)).hasMatch()) { | ||
1395 | QString res = re.cap(1).rightJustified(2, '0') + ":" + re.cap(2).rightJustified(2, '0') | 1395 | QString res = match.captured(1).rightJustified(2, '0') + ":" + match.captured(2).rightJustified(2, '0') | ||
1396 | + ":" + re.cap(3).rightJustified(2, '0'); | 1396 | + ":" + match.captured(3).rightJustified(2, '0'); | ||
1397 | // qDebug() << res; | 1397 | // qDebug() << res; | ||
1398 | valueExpr = KDbConstExpression(KDbToken::TIME_CONST, QTime::fromString(res, Qt::ISODate)); | 1398 | valueExpr = KDbConstExpression(KDbToken::TIME_CONST, QTime::fromString(res, Qt::ISODate)); | ||
1399 | } else if ((re = QRegExp("(\\d{1,4})-(\\d{1,2})-(\\d{1,2})\\s+(\\d{1,2}):(\\d{1,2})")).exactMatch(str) | 1399 | } else if ((match = QRegularExpression("^(\\d{1,4})-(\\d{1,2})-(\\d{1,2})\\s+(\\d{1,2}):(\\d{1,2})$").match(str)).hasMatch() | ||
1400 | || (re = QRegExp("(\\d{1,4})-(\\d{1,2})-(\\d{1,2})\\s+(\\d{1,2}):(\\d{1,2}):(\\d{1,2})")).exactMatch(str)) { | 1400 | || (match = QRegularExpression("^(\\d{1,4})-(\\d{1,2})-(\\d{1,2})\\s+(\\d{1,2}):(\\d{1,2}):(\\d{1,2})$").match(str)).hasMatch()) { | ||
1401 | QString res = re.cap(1).rightJustified(4, '0') + "-" + re.cap(2).rightJustified(2, '0') | 1401 | QString res = match.captured(1).rightJustified(4, '0') + "-" + match.captured(2).rightJustified(2, '0') | ||
1402 | + "-" + re.cap(3).rightJustified(2, '0') | 1402 | + "-" + match.captured(3).rightJustified(2, '0') | ||
1403 | + "T" + re.cap(4).rightJustified(2, '0') + ":" + re.cap(5).rightJustified(2, '0') | 1403 | + "T" + match.captured(4).rightJustified(2, '0') + ":" + match.captured(5).rightJustified(2, '0') | ||
1404 | + ":" + re.cap(6).rightJustified(2, '0'); | 1404 | + ":" + match.captured(6).rightJustified(2, '0'); | ||
1405 | // qDebug() << res; | 1405 | // qDebug() << res; | ||
1406 | valueExpr = KDbConstExpression(KDbToken::DATETIME_CONST, | 1406 | valueExpr = KDbConstExpression(KDbToken::DATETIME_CONST, | ||
1407 | QDateTime::fromString(res, Qt::ISODate)); | 1407 | QDateTime::fromString(res, Qt::ISODate)); | ||
Context not available. |