]> Some of my projects - localmylist.git/commitdiff
Add Search tab to localmylist-management and remove search-gui.
authorAPTX <marek321@gmail.com>
Thu, 2 May 2013 14:53:05 +0000 (16:53 +0200)
committerAPTX <marek321@gmail.com>
Thu, 2 May 2013 14:53:05 +0000 (16:53 +0200)
localmylist-management/localmylist-management.pro
localmylist-management/registertabs.cpp
localmylist-management/tabs/searchtab.cpp [new file with mode: 0644]
localmylist-management/tabs/searchtab.h [new file with mode: 0644]
localmylist-management/tabs/searchtab.ui [new file with mode: 0644]
localmylist.pro
search-gui/main.cpp [deleted file]
search-gui/mainwindow.cpp [deleted file]
search-gui/mainwindow.h [deleted file]
search-gui/mainwindow.ui [deleted file]
search-gui/search-gui.pro [deleted file]

index 43cd8c72a1e2233ec0b2bf2ff80581872b92b52f..3e0a512ddf818fd97b55c35ee85cab951e1d08a9 100644 (file)
@@ -21,6 +21,7 @@ SOURCES += main.cpp\
        tabwidget.cpp \
        abstracttab.cpp \
        tabs/mylisttab.cpp \
+       tabs/searchtab.cpp \
        tabs/reportstab.cpp \
        tabs/unknownfilestab.cpp \
        registertabs.cpp
@@ -36,12 +37,14 @@ HEADERS += mainwindow.h \
        tabwidget.h \
        abstracttab.h \
        tabs/mylisttab.h \
+       tabs/searchtab.h \
        tabs/reportstab.h \
        tabs/unknownfilestab.h
 
 FORMS += mainwindow.ui \
        databaseconnectiondialog.ui \
        tabs/mylisttab.ui \
+       tabs/searchtab.ui \
        tabs/reportstab.ui \
        tabs/unknownfilestab.ui
 
index 9ec593deaa265255897a6f890c6a3b3a7bb8455c..41e7efb3f5f5c26486a6e78f704b6758ca0ea167 100644 (file)
@@ -1,11 +1,13 @@
 #include "tabwidget.h"
 #include "tabs/mylisttab.h"
+#include "tabs/searchtab.h"
 #include "tabs/reportstab.h"
 #include "tabs/unknownfilestab.h"
 
 void registerTabs()
 {
        TabWidget::registerTab<MyListTab>();
+       TabWidget::registerTab<SearchTab>();
        TabWidget::registerTab<ReportsTab>();
        TabWidget::registerTab<UnknownFilesTab>();
 }
diff --git a/localmylist-management/tabs/searchtab.cpp b/localmylist-management/tabs/searchtab.cpp
new file mode 100644 (file)
index 0000000..01b07fd
--- /dev/null
@@ -0,0 +1,88 @@
+#include "searchtab.h"
+#include "ui_searchtab.h"
+
+#include <QSqlQueryModel>
+#include <QSqlQuery>
+
+#include "mylist.h"
+
+using namespace LocalMyList;
+
+SearchTab::SearchTab(QWidget *parent) :
+       AbstractTabBase(parent),
+       ui(new Ui::SearchTab)
+{
+       ui->setupUi(this);
+       m_label = name();
+}
+
+SearchTab::~SearchTab()
+{
+       delete ui;
+}
+
+QString SearchTab::staticId()
+{
+       return "search";
+}
+
+QString SearchTab::name()
+{
+       return tr("Search");
+}
+
+void SearchTab::init()
+{
+       model = new QSqlQueryModel(this);
+       ui->view->setModel(model);
+}
+
+void SearchTab::activate()
+{
+}
+
+void SearchTab::on_input_textChanged(const QString &text)
+{
+       QString query;
+
+       if (text.isEmpty())
+       {
+               model->setQuery(QSqlQuery());
+               return;
+       }
+
+       if (text.length() > 3)
+               query = "%" + text + "%";
+       else
+               query = text + "%";
+
+       QSqlQuery &q = MyList::instance()->database()->prepare(
+       "SELECT a.aid, b.title AS main_title, a.title, a.language, a.type FROM anime_title a "
+       "       LEFT JOIN anime_title b on b.aid = a.aid "
+       "       WHERE a.title ILIKE :query "
+       "               AND b.type = 1 "
+       "       ORDER BY a.title ASC, a.aid ASC "
+       "       LIMIT 100");
+       q.bindValue(":word", text);
+       q.bindValue(":query", query);
+
+       MyList::instance()->database()->exec(q);
+       model->setQuery(q);
+
+       model->setHeaderData(0, Qt::Horizontal, tr("aid"));
+       model->setHeaderData(1, Qt::Horizontal, tr("Main Title"));
+       model->setHeaderData(2, Qt::Horizontal, tr("Title"));
+       model->setHeaderData(3, Qt::Horizontal, tr("Language"));
+       model->setHeaderData(4, Qt::Horizontal, tr("Type"));
+
+       ui->view->resizeColumnsToContents();
+
+/*
+       "SELECT a.aid, b.title AS main_title, a.title, a.language, a.type, a.title <-> :word AS distance FROM anime_title a "
+       "       LEFT JOIN anime_title b on b.aid = a.aid "
+       "       WHERE a.title ILIKE :query "
+       "               AND b.type = 1 "
+       "       ORDER BY distance ASC, a.title ASC, a.aid ASC "
+       "       LIMIT 100");
+*/
+}
diff --git a/localmylist-management/tabs/searchtab.h b/localmylist-management/tabs/searchtab.h
new file mode 100644 (file)
index 0000000..00cdbb8
--- /dev/null
@@ -0,0 +1,35 @@
+#ifndef SEARCHTAB_H
+#define SEARCHTAB_H
+
+#include "abstracttab.h"
+
+namespace Ui {
+class SearchTab;
+}
+
+class QSqlQueryModel;
+
+class SearchTab : public AbstractTabBase<SearchTab>
+{
+       Q_OBJECT
+
+public:
+       explicit SearchTab(QWidget *parent = 0);
+       ~SearchTab();
+
+       static QString staticId();
+       static QString name();
+
+       void init();
+       void activate();
+
+private slots:
+       void on_input_textChanged(const QString &text);
+
+private:
+       Ui::SearchTab *ui;
+
+       QSqlQueryModel *model;
+};
+
+#endif // SEARCHTAB_H
diff --git a/localmylist-management/tabs/searchtab.ui b/localmylist-management/tabs/searchtab.ui
new file mode 100644 (file)
index 0000000..af779a8
--- /dev/null
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>SearchTab</class>
+ <widget class="QWidget" name="SearchTab">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>300</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Form</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <property name="leftMargin">
+    <number>0</number>
+   </property>
+   <property name="rightMargin">
+    <number>0</number>
+   </property>
+   <property name="bottomMargin">
+    <number>0</number>
+   </property>
+   <item>
+    <widget class="FilterLineEdit" name="input"/>
+   </item>
+   <item>
+    <widget class="QTableView" name="view"/>
+   </item>
+  </layout>
+ </widget>
+ <customwidgets>
+  <customwidget>
+   <class>FilterLineEdit</class>
+   <extends>QLineEdit</extends>
+   <header>filterlineedit.h</header>
+  </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
index 845238b49e8685694b624683fce98a53d1012db5..7c4ca3657a6c3860b553a2ecb3fa8ec6924b39d2 100644 (file)
@@ -11,10 +11,6 @@ SUBDIRS += localmylist
 
 !nogui {
        SUBDIRS += localmylist-management
-
-       !notools {
-               SUBDIRS += search-gui
-       }
 }
 
 !notools {
diff --git a/search-gui/main.cpp b/search-gui/main.cpp
deleted file mode 100644 (file)
index 24a397b..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-#include <QApplication>
-#include "mainwindow.h"
-
-int main(int argc, char *argv[])
-{
-       QApplication a(argc, argv);
-       MainWindow w;
-       w.show();
-       
-       return a.exec();
-}
diff --git a/search-gui/mainwindow.cpp b/search-gui/mainwindow.cpp
deleted file mode 100644 (file)
index 08f40c3..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-#include "mainwindow.h"
-#include "ui_mainwindow.h"
-
-#include <QSqlQuery>
-#include <QSqlError>
-#include "database.h"
-#include "mylist.h"
-
-#include <QDebug>
-
-using namespace LocalMyList;
-
-MainWindow::MainWindow(QWidget *parent) :
-       QMainWindow(parent),
-       ui(new Ui::MainWindow)
-{
-       ui->setupUi(this);
-       MyList::instance()->loadLocalSettings();
-       MyList::instance()->database()->connect();
-
-       model = new QSqlQueryModel(this);
-
-       ui->resultView->setModel(model);
-       on_search_textChanged("");
-}
-
-MainWindow::~MainWindow()
-{
-       delete ui;
-}
-
-void MainWindow::on_search_textChanged(const QString &text)
-{
-
-       QString query;
-
-       if (text.isEmpty())
-       {
-               model->setQuery(QSqlQuery());
-               return;
-       }
-
-       if (text.length() > 3)
-               query = "%" + text + "%";
-       else
-               query = text + "%";
-
-       QSqlQuery &q = MyList::instance()->database()->prepare(
-       "SELECT a.aid, b.title AS main_title, a.title, a.language, a.type, a.title <-> :word AS distance FROM anime_title a "
-       "       LEFT JOIN anime_title b on b.aid = a.aid "
-       "       WHERE a.title ILIKE :query "
-       "               AND b.type = 1 "
-       "       ORDER BY distance ASC, a.title ASC, a.aid ASC "
-       "       LIMIT 100");
-       q.bindValue(":word", text);
-       q.bindValue(":query", query);
-
-       MyList::instance()->database()->exec(q);
-       model->setQuery(q);
-       ui->resultView->resizeColumnsToContents();
-
-}
diff --git a/search-gui/mainwindow.h b/search-gui/mainwindow.h
deleted file mode 100644 (file)
index 53b9ccd..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef MAINWINDOW_H
-#define MAINWINDOW_H
-
-#include <QMainWindow>
-#include <QSqlQueryModel>
-
-namespace Ui {
-       class MainWindow;
-}
-
-namespace LocalMyList {
-       class Database;
-}
-
-class MainWindow : public QMainWindow
-{
-       Q_OBJECT
-       
-public:
-       explicit MainWindow(QWidget *parent = 0);
-       ~MainWindow();
-       
-private slots:
-       void on_search_textChanged(const QString &arg1);
-
-private:
-       Ui::MainWindow *ui;
-       QSqlQueryModel *model;
-       LocalMyList::Database *db;
-};
-
-#endif // MAINWINDOW_H
diff --git a/search-gui/mainwindow.ui b/search-gui/mainwindow.ui
deleted file mode 100644 (file)
index b878805..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>MainWindow</class>
- <widget class="QMainWindow" name="MainWindow">
-  <property name="geometry">
-   <rect>
-    <x>0</x>
-    <y>0</y>
-    <width>400</width>
-    <height>300</height>
-   </rect>
-  </property>
-  <property name="windowTitle">
-   <string>MainWindow</string>
-  </property>
-  <widget class="QWidget" name="centralWidget">
-   <layout class="QVBoxLayout" name="verticalLayout">
-    <item>
-     <widget class="QLineEdit" name="search"/>
-    </item>
-    <item>
-     <widget class="QTableView" name="resultView"/>
-    </item>
-   </layout>
-  </widget>
-  <widget class="QMenuBar" name="menuBar">
-   <property name="geometry">
-    <rect>
-     <x>0</x>
-     <y>0</y>
-     <width>400</width>
-     <height>21</height>
-    </rect>
-   </property>
-  </widget>
-  <widget class="QToolBar" name="mainToolBar">
-   <attribute name="toolBarArea">
-    <enum>TopToolBarArea</enum>
-   </attribute>
-   <attribute name="toolBarBreak">
-    <bool>false</bool>
-   </attribute>
-  </widget>
-  <widget class="QStatusBar" name="statusBar"/>
- </widget>
- <layoutdefault spacing="6" margin="11"/>
- <resources/>
- <connections/>
-</ui>
diff --git a/search-gui/search-gui.pro b/search-gui/search-gui.pro
deleted file mode 100644 (file)
index 863323f..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-QT       += core gui
-greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
-
-include(../config.pri)
-
-TARGET = lml-search-gui
-DESTDIR = ../build
-TEMPLATE = app
-
-
-SOURCES += main.cpp\
-               mainwindow.cpp
-
-HEADERS += mainwindow.h
-
-FORMS += mainwindow.ui
-
-include(../localmylist.pri)
-
-target.path = $${PREFIX}/bin
-INSTALLS += target