From afa034e0adbbeaf337e34671efd44f5e487c17ba Mon Sep 17 00:00:00 2001 From: lvaatamoinen Date: Tue, 20 Oct 2009 13:33:29 +0000 Subject: [PATCH] - Added AlertWaiter and QBittorentSession - Initial thread / signal -experimenting git-svn-id: file:///svnroot/qtrapids/trunk@10 42ac0dd5-4c8c-4c71-bb3e-ecdfe252ffda --- qtrapids.kdevelop | 16 +++++++----- src/engine/AlertWaiterThread.cpp | 51 +++++++++++++++++++++++++++++++++++++ src/engine/AlertWaiterThread.h | 46 +++++++++++++++++++++++++++++++++ src/engine/QBittorrentSession.cpp | 31 ++++++++++++++++++++++ src/engine/QBittorrentSession.h | 39 ++++++++++++++++++++++++++++ src/engine/engine.pro | 20 ++++++++++++++- src/gui/MainWindow.cpp | 9 +++++++ src/gui/MainWindow.h | 6 +++++ src/gui/gui.pro | 13 +++++++++- src/src.pro | 7 +++-- 10 files changed, 225 insertions(+), 13 deletions(-) create mode 100644 src/engine/AlertWaiterThread.cpp create mode 100644 src/engine/AlertWaiterThread.h create mode 100644 src/engine/QBittorrentSession.cpp create mode 100644 src/engine/QBittorrentSession.h diff --git a/qtrapids.kdevelop b/qtrapids.kdevelop index c8a115f..b476a37 100644 --- a/qtrapids.kdevelop +++ b/qtrapids.kdevelop @@ -146,25 +146,27 @@ - /home/vaatala/Projects/qtrapids/trunk + /home/vaatala/Projects/qtrapids/trunk/bin/qtrapids executable - /home/vaatala/Projects/qtrapids - false + /home/vaatala/Projects/qtrapids/trunk/bin + true false false false false - + + + - + /home/vaatala/Projects/qtrapids/trunk - + @@ -205,7 +207,7 @@ Doxygen Documentation Collection qtrapids.tag - + diff --git a/src/engine/AlertWaiterThread.cpp b/src/engine/AlertWaiterThread.cpp new file mode 100644 index 0000000..7a2f90f --- /dev/null +++ b/src/engine/AlertWaiterThread.cpp @@ -0,0 +1,51 @@ +/*************************************************************************** + * Copyright (C) 2009 by Lassi Väätämöinen * + * lassi.vaatamoinen@ixonos.com * + * * + * 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, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + +#include + +#include "AlertWaiterThread.h" + +AlertWaiterThread::AlertWaiterThread(QObject* parent): QThread(parent) +{ +} + + +AlertWaiterThread::~AlertWaiterThread() +{ +} + + +void AlertWaiterThread::run() +{ + while (true) + { + qDebug() << "AlertWaiter running"; + emit alert(); + sleep(2); + } +} + + +// =================== SIGNALS ======================= +// AlertWaiterThread::alert() +// { +// } + + diff --git a/src/engine/AlertWaiterThread.h b/src/engine/AlertWaiterThread.h new file mode 100644 index 0000000..5ba3bf6 --- /dev/null +++ b/src/engine/AlertWaiterThread.h @@ -0,0 +1,46 @@ +/*************************************************************************** + * Copyright (C) 2009 by Lassi Väätämöinen * + * lassi.vaatamoinen@ixonos.com * + * * + * 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, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef ALERTWAITERTHREAD_H +#define ALERTWAITERTHREAD_H + +#include + +/** + @author Lassi Väätämöinen +*/ +class AlertWaiterThread : public QThread +{ + Q_OBJECT + + public: + AlertWaiterThread(QObject* parent = 0); + + ~AlertWaiterThread(); + + void run(); // Overridden from QThread + + signals: + void alert(); + + private: + +}; + +#endif diff --git a/src/engine/QBittorrentSession.cpp b/src/engine/QBittorrentSession.cpp new file mode 100644 index 0000000..34198c8 --- /dev/null +++ b/src/engine/QBittorrentSession.cpp @@ -0,0 +1,31 @@ +/*************************************************************************** + * Copyright (C) 2009 by Lassi Väätämöinen * + * lassi.vaatamoinen@ixonos.com * + * * + * 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, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include "QBittorrentSession.h" + +QBittorrentSession::QBittorrentSession() +{ +} + + +QBittorrentSession::~QBittorrentSession() +{ +} + + diff --git a/src/engine/QBittorrentSession.h b/src/engine/QBittorrentSession.h new file mode 100644 index 0000000..19de9d7 --- /dev/null +++ b/src/engine/QBittorrentSession.h @@ -0,0 +1,39 @@ +/*************************************************************************** + * Copyright (C) 2009 by Lassi Väätämöinen * + * lassi.vaatamoinen@ixonos.com * + * * + * 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, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#ifndef QBITTORRENTSESSION_H +#define QBITTORRENTSESSION_H + +/** + @author Lassi Väätämöinen +*/ +class QBittorrentSession { + + public: + QBittorrentSession(); + + ~QBittorrentSession(); + public slots: + private slots: + private: + + +}; + +#endif diff --git a/src/engine/engine.pro b/src/engine/engine.pro index 566e172..2344e7e 100644 --- a/src/engine/engine.pro +++ b/src/engine/engine.pro @@ -1,2 +1,20 @@ -TEMPLATE = subdirs + +TEMPLATE = lib + +CONFIG += dll \ + debug + +VERSION = 0.1 + +HEADERS += AlertWaiterThread.h + +SOURCES += AlertWaiterThread.cpp + +QT -= gui + +CONFIG -= release + +TARGET = qtbittorrent + +DESTDIR = ../../bin diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index dc1d73e..9615959 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -29,6 +29,7 @@ #include "DownloadView.h" #include "SeedView.h" +#include "AlertWaiterThread.h" #include "MainWindow.h" @@ -85,6 +86,10 @@ MainWindow::MainWindow(): addToolBar(Qt::TopToolBarArea, toolBar); connect(toolBar, SIGNAL(actionTriggered(QAction*)), this, SLOT(handleToolBarAction(QAction*))); + + alertWaiter_ = new AlertWaiterThread(this); + connect(alertWaiter_, SIGNAL(alert()), this, SLOT(on_alert())); + alertWaiter_->start(); } @@ -114,3 +119,7 @@ void MainWindow::handleToolBarAction(QAction* action) } } +void MainWindow::on_alert() +{ + qDebug() << "MainWindow: got alert()"; +} diff --git a/src/gui/MainWindow.h b/src/gui/MainWindow.h index fc89cdc..4bae579 100644 --- a/src/gui/MainWindow.h +++ b/src/gui/MainWindow.h @@ -27,6 +27,8 @@ class QTabWidget; class DownloadView; class SeedView; +class AlertWaiterThread; + /** @author Lassi Väätämöinen */ @@ -44,10 +46,14 @@ class MainWindow : public QMainWindow { void on_aboutQtAction_clicked(); void handleToolBarAction(QAction* action); + void on_alert(); + private: QTabWidget *tabWidget_; DownloadView *dlView_; SeedView *seedView_; + + AlertWaiterThread *alertWaiter_; }; #endif diff --git a/src/gui/gui.pro b/src/gui/gui.pro index 8d105ec..24598ed 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -14,5 +14,16 @@ CONFIG -= release CONFIG += debug \ qtestlib -DESTDIR = ../../ +TARGETDEPS += ../engine/liblibqtbittorrent.so + +DESTDIR = ../../bin + +INCLUDEPATH += ../engine + +LIBS += -L../../bin \ + -lqtbittorrent \ + -L/home/vaatala/Projects/qtrapids/trunk/bin \ + -L../engine + +QMAKE_LFLAGS_DEBUG += -L. diff --git a/src/src.pro b/src/src.pro index c6c5594..8923296 100644 --- a/src/src.pro +++ b/src/src.pro @@ -1,14 +1,13 @@ SUBDIRS += gui \ engine -SOURCES += qtrapids.cpp \ - main.cpp -HEADERS += qtrapids.h + CONFIG += warn_on \ thread \ qt + TARGET = qtrapids DESTDIR = ../bin -RESOURCES = application.qrc + TEMPLATE = subdirs -- 1.7.9.5