summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2018-11-03 10:48:38 +0100
committerArno <arno@disconnect.de>2018-11-03 10:48:38 +0100
commit58f0265365114a8241260d137833437cee3d400b (patch)
tree1820ad6bc2ae1c0f757e1b2aa8e76dffa2e7eee2
parent40566bc0acc854f7bb49bb67ee816314e2943b38 (diff)
downloadSheMov-58f0265365114a8241260d137833437cee3d400b.tar.gz
SheMov-58f0265365114a8241260d137833437cee3d400b.tar.bz2
SheMov-58f0265365114a8241260d137833437cee3d400b.zip
Move fuzzyCheck to Helper namespace
-rw-r--r--helper.cpp14
-rw-r--r--helper.h1
-rw-r--r--movieinfopage.cpp12
3 files changed, 16 insertions, 11 deletions
diff --git a/helper.cpp b/helper.cpp
index 88b243d..b1f277b 100644
--- a/helper.cpp
+++ b/helper.cpp
@@ -384,6 +384,20 @@ namespace Helper {
return PicData();
}
+ QStringList fuzzyCheck(const QString &subtitle){
+ QStringList retval;
+ QSqlDatabase db = QSqlDatabase::database("treedb");
+ db.open();
+ QSqlQuery fuzzyQ(db);
+ fuzzyQ.prepare("SELECT tsubtitle FROM seriesparts WHERE regexp_replace(tsubtitle, '[ .,''!-]', '', 'g') = lower(regexp_replace(:st, '[ .,''!-]', '', 'g'))");
+ fuzzyQ.bindValue(":st", subtitle);
+ fuzzyQ.exec();
+ while(fuzzyQ.next()){
+ retval << fuzzyQ.value(0).toString();
+ }
+ return retval;
+ }
+
Duration::Duration() : mHours(0), mMinutes(0), mSeconds(0) {}
Duration::Duration(qint64 seconds){
diff --git a/helper.h b/helper.h
index a3f0f3e..d37490e 100644
--- a/helper.h
+++ b/helper.h
@@ -52,6 +52,7 @@ namespace Helper {
PicData convertArchivefileToPng(PicData data);
const QIcon icon(const QColor &bg, const QColor &fg, const QChar c, bool bold, bool drawEllipse);
QAction *createSeparator(QWidget *parent);
+ QStringList fuzzyCheck(const QString &subtitle);
class Duration {
public:
Duration();
diff --git a/movieinfopage.cpp b/movieinfopage.cpp
index 55a5075..425a252 100644
--- a/movieinfopage.cpp
+++ b/movieinfopage.cpp
@@ -321,17 +321,7 @@ void MovieInfoPage::toLower(){
}
void MovieInfoPage::fuzzyCheck(){
- QString subtitle = mSubtitle->text();
- QStringList res;
- QSqlDatabase db = QSqlDatabase::database("treedb");
- db.open();
- QSqlQuery fuzzyQ(db);
- fuzzyQ.prepare("SELECT tsubtitle FROM seriesparts WHERE regexp_replace(tsubtitle, '[ .,''!-]', '', 'g') = lower(regexp_replace(:st, '[ .,''!-]', '', 'g'))");
- fuzzyQ.bindValue(":st", subtitle);
- fuzzyQ.exec();
- while(fuzzyQ.next()){
- res << fuzzyQ.value(0).toString();
- }
+ QStringList res = Helper::fuzzyCheck(mSubtitle->text());
if(!res.isEmpty()){
QString msg = QString(tr("Already have:<ul>"));
for(int i = 0; i < res.count() && i < 5; ++i){