[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [sprinter/gko/master] test: stub in a helper class to do things in the event loop (e.g. load all run
From:       Aaron J. Seigo <aseigo () kde ! org>
Date:       2014-03-06 10:20:18
Message-ID: E1WLVPW-0007ZS-71 () scm ! kde ! org
[Download RAW message or body]

Git commit 5322898841bf0e34786c98b10f5b3ce33ccee13a by Aaron J. Seigo.
Committed on 24/02/2014 at 14:25.
Pushed by aseigo into branch 'gko/master'.

stub in a helper class to do things in the event loop (e.g. load all runners)

A  +43   -0    test/helper.cpp     [License: GPL (v2+)]
A  +41   -0    test/helper.h     [License: GPL (v2+)]
M  +23   -13   test/main.cpp

http://commits.kde.org/sprinter/5322898841bf0e34786c98b10f5b3ce33ccee13a

diff --git a/test/helper.cpp b/test/helper.cpp
new file mode 100644
index 0000000..2650643
--- /dev/null
+++ b/test/helper.cpp
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2014 Aaron Seigo <aseigo@kde.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "helper.h"
+
+#include <QDebug>
+
+Helper::Helper(QObject *parent)
+    : QObject(parent),
+      m_session(new Sprinter::QuerySession(this))
+{
+}
+
+Helper::~Helper()
+{
+
+}
+
+Sprinter::QuerySession *Helper::session()
+{
+    return m_session;
+}
+
+void Helper::loadAllRunners()
+{
+    qDebug() << "loading all runnears";
+}
+
+#include "moc_helper.cpp"
diff --git a/test/helper.h b/test/helper.h
new file mode 100644
index 0000000..c9d193f
--- /dev/null
+++ b/test/helper.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2014 Aaron Seigo <aseigo@kde.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef HELPER_H
+#define HELPER_H
+
+#include <QObject>
+
+#include "sprinter/querysession.h"
+
+class Helper : public QObject
+{
+    Q_OBJECT
+public:
+    Helper(QObject *parent = 0);
+    ~Helper();
+
+    Sprinter::QuerySession *session();
+
+public Q_SLOTS:
+    void loadAllRunners();
+
+private:
+    Sprinter::QuerySession *m_session;
+};
+
+#endif
\ No newline at end of file
diff --git a/test/main.cpp b/test/main.cpp
index d1eeb6b..795438b 100644
--- a/test/main.cpp
+++ b/test/main.cpp
@@ -29,13 +29,16 @@
 
 #include "sprinter/querysession.h"
 
+#include "helper.h"
+
 using namespace Sprinter;
 
 int main(int argc, char** argv)
 {
     QApplication app(argc, argv);
 
-    QuerySession *manager = new QuerySession;
+    Helper *helper = new Helper;
+    QuerySession *session = helper->session();
 
     QSplitter *splitter = new QSplitter;
 
@@ -44,24 +47,24 @@ int main(int argc, char** argv)
     QLineEdit *edit = new QLineEdit(top);
     edit->setPlaceholderText("Enter search term");
     QObject::connect(edit, SIGNAL(textChanged(QString)),
-                     manager, SLOT(setQuery(QString)));
-    QObject::connect(manager, SIGNAL(queryChanged(QString)),
+                     session, SLOT(setQuery(QString)));
+    QObject::connect(session, SIGNAL(queryChanged(QString)),
                      edit, SLOT(setText(QString)));
     QTreeView *matchView = new QTreeView(top);
-    matchView->setModel(manager);
+    matchView->setModel(session);
     matchView->setAllColumnsShowFocus(true);
     QObject::connect(matchView, SIGNAL(doubleClicked(QModelIndex)),
-                     manager, SLOT(executeMatch(QModelIndex)));
+                     session, SLOT(executeMatch(QModelIndex)));
 
     QPushButton *defaultMatchButton = new QPushButton(top);
     defaultMatchButton->setText("Default matches");
     QObject::connect(defaultMatchButton, SIGNAL(clicked()),
-                     manager, SLOT(requestDefaultMatches()));
+                     session, SLOT(requestDefaultMatches()));
 
     QPushButton *moreMatchesButton = new QPushButton(top);
     moreMatchesButton->setText("More matches");
     QObject::connect(moreMatchesButton, SIGNAL(clicked()),
-                     manager, SLOT(requestMoreMatches()));
+                     session, SLOT(requestMoreMatches()));
 
     QGridLayout *matchLayout = new QGridLayout(top);
     matchLayout->addWidget(edit, 0, 0, 1, 2);
@@ -71,14 +74,21 @@ int main(int argc, char** argv)
     splitter->addWidget(top);
 
     top = new QWidget(splitter);
-    QVBoxLayout *runnerLayout = new QVBoxLayout(top);
-    runnerLayout->addWidget(new QLabel("Runners"));
+    QGridLayout *runnerLayout = new QGridLayout(top);
+    runnerLayout->addWidget(new QLabel("Runners"), 0, 0);
+
+    QPushButton *loadAllRunnersButton = new QPushButton(top);
+    loadAllRunnersButton->setText("Load all");
+    QObject::connect(loadAllRunnersButton, SIGNAL(clicked()),
+                     helper, SLOT(loadAllRunners()));
+    runnerLayout->addWidget(loadAllRunnersButton, 0, 1);
+
     QTreeView *runnerView = new QTreeView(top);
-    runnerView->setModel(manager->runnerModel());
+    runnerView->setModel(session->runnerModel());
     runnerView->setAllColumnsShowFocus(true);
     QObject::connect(runnerView, SIGNAL(doubleClicked(QModelIndex)),
-                     manager->runnerModel(), SLOT(loadRunner(QModelIndex)));
-    runnerLayout->addWidget(runnerView);
+                     session->runnerModel(), SLOT(loadRunner(QModelIndex)));
+    runnerLayout->addWidget(runnerView, 1, 0, 1, 2);
     splitter->addWidget(top);
 
     QAction *action = new QAction(top);
@@ -89,7 +99,7 @@ int main(int argc, char** argv)
     action = new QAction(top);
     action->setShortcut(Qt::Key_Escape);
     top->addAction(action);
-    QObject::connect(action, SIGNAL(triggered()), manager, SLOT(halt()));
+    QObject::connect(action, SIGNAL(triggered()), session, SLOT(halt()));
 
     splitter->resize(1000, 700);
     splitter->show();

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic