-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #380 from YACReader/develop
9.12
- Loading branch information
Showing
46 changed files
with
2,068 additions
and
335 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
#include "search_query.h" | ||
#include "query_parser.h" | ||
|
||
#include <QtCore> | ||
#include <QSqlQuery> | ||
|
||
QSqlQuery foldersSearchQuery(QSqlDatabase &db, const QString &filter) | ||
{ | ||
QueryParser parser; | ||
auto result = parser.parse(filter.toStdString()); | ||
|
||
std::string queryString(SEARCH_FOLDERS_QUERY); | ||
result.buildSqlString(queryString); | ||
queryString += " AND f.id <> 1 ORDER BY f.parentId,f.name"; | ||
|
||
QSqlQuery selectQuery(db); | ||
selectQuery.prepare(queryString.c_str()); | ||
result.bindValues(selectQuery); | ||
|
||
selectQuery.exec(); | ||
|
||
return selectQuery; | ||
} | ||
|
||
QSqlQuery comicsSearchQuery(QSqlDatabase &db, const QString &filter) | ||
{ | ||
QueryParser parser; | ||
auto result = parser.parse(filter.toStdString()); | ||
|
||
std::string queryString(SEARCH_COMICS_QUERY); | ||
result.buildSqlString(queryString); | ||
queryString += " LIMIT :limit"; | ||
|
||
QSqlQuery selectQuery(db); | ||
selectQuery.prepare(queryString.c_str()); | ||
selectQuery.bindValue(":limit", 500); // TODO, load this value from settings | ||
result.bindValues(selectQuery); | ||
|
||
selectQuery.exec(); | ||
|
||
return selectQuery; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
#ifndef SEARCHQUERY_H | ||
#define SEARCHQUERY_H | ||
|
||
#include <QSqlDatabase> | ||
|
||
QSqlQuery foldersSearchQuery(QSqlDatabase &db, const QString &filter); | ||
QSqlQuery comicsSearchQuery(QSqlDatabase &db, const QString &filter); | ||
|
||
#endif // SEARCHQUERY_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include <QNetworkInterface> | ||
#include "ip_config_helper.h" | ||
#include "qnaturalsorting.h" | ||
|
||
// 192.168 (most comon local subnet for ips are always put first) | ||
// IPs are sorted using natoral sorting | ||
|
||
QList<QString> getIpAddresses() | ||
{ | ||
auto ipComparator = [](const QString &ip1, const QString &ip2) { | ||
if (ip1.startsWith("192.168") && ip2.startsWith("192.168")) | ||
return naturalSortLessThanCI(ip1, ip2); | ||
|
||
if (ip1.startsWith("192.168")) | ||
return true; | ||
|
||
if (ip2.startsWith("192.168")) | ||
return false; | ||
|
||
return naturalSortLessThanCI(ip1, ip2); | ||
}; | ||
|
||
QList<QString> addresses; | ||
for (auto add : QNetworkInterface::allAddresses()) { | ||
// Exclude loopback, local, multicast | ||
if (add.isGlobal()) { | ||
addresses.push_back(add.toString()); | ||
} | ||
} | ||
|
||
std::sort(addresses.begin(), addresses.end(), ipComparator); | ||
return addresses; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#ifndef YR_IP_CONFIG_HELPER | ||
#define YR_IP_CONFIG_HELPER | ||
QList<QString> getIpAddresses(); | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.