From 36e024d9a3ba022436d940ebb94581bc734bea41 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 19 Jan 2012 13:54:57 +0100 Subject: [PATCH] removed the voting system --- src/adaptors/adaptors.pri | 13 - .../voting/UBAbstractVotingSystem.cpp | 78 ----- src/adaptors/voting/UBAbstractVotingSystem.h | 82 ----- .../voting/UBReply2005VotingSystem.cpp | 151 ---------- src/adaptors/voting/UBReply2005VotingSystem.h | 60 ---- .../voting/UBReplyWRS970VotingSystem.cpp | 279 ------------------ .../voting/UBReplyWRS970VotingSystem.h | 63 ---- src/api/UBWidgetVotingSystemAPI.cpp | 112 ------- src/api/UBWidgetVotingSystemAPI.h | 54 ---- src/api/api.pri | 6 +- src/domain/UBW3CWidget.cpp | 11 - src/domain/UBW3CWidget.h | 2 - 12 files changed, 2 insertions(+), 909 deletions(-) delete mode 100644 src/adaptors/voting/UBAbstractVotingSystem.cpp delete mode 100644 src/adaptors/voting/UBAbstractVotingSystem.h delete mode 100644 src/adaptors/voting/UBReply2005VotingSystem.cpp delete mode 100644 src/adaptors/voting/UBReply2005VotingSystem.h delete mode 100644 src/adaptors/voting/UBReplyWRS970VotingSystem.cpp delete mode 100644 src/adaptors/voting/UBReplyWRS970VotingSystem.h delete mode 100644 src/api/UBWidgetVotingSystemAPI.cpp delete mode 100644 src/api/UBWidgetVotingSystemAPI.h diff --git a/src/adaptors/adaptors.pri b/src/adaptors/adaptors.pri index 1e79c60b..b69d434f 100644 --- a/src/adaptors/adaptors.pri +++ b/src/adaptors/adaptors.pri @@ -19,7 +19,6 @@ HEADERS += src/adaptors/UBExportAdaptor.h\ HEADERS += src/adaptors/publishing/UBDocumentPublisher.h \ src/adaptors/publishing/UBSvgSubsetRasterizer.h -HEADERS += src/adaptors/voting/UBAbstractVotingSystem.h SOURCES += src/adaptors/UBExportAdaptor.cpp\ @@ -42,15 +41,3 @@ SOURCES += src/adaptors/UBExportAdaptor.cpp\ SOURCES += \ src/adaptors/publishing/UBSvgSubsetRasterizer.cpp - -SOURCES += src/adaptors/voting/UBAbstractVotingSystem.cpp - - -win32 { - - SOURCES += src/adaptors/voting/UBReply2005VotingSystem.cpp \ - src/adaptors/voting/UBReplyWRS970VotingSystem.cpp - - HEADERS += src/adaptors/voting/UBReply2005VotingSystem.h \ - src/adaptors/voting/UBReplyWRS970VotingSystem.h -} diff --git a/src/adaptors/voting/UBAbstractVotingSystem.cpp b/src/adaptors/voting/UBAbstractVotingSystem.cpp deleted file mode 100644 index 25c1d2a9..00000000 --- a/src/adaptors/voting/UBAbstractVotingSystem.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * 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 3 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 . - */ - -#include "UBAbstractVotingSystem.h" - -#ifdef Q_WS_WIN - -#include "UBReply2005VotingSystem.h" -#include "UBReplyWRS970VotingSystem.h" - -#endif - -#include "gui/UBMainWindow.h" - -#include "core/memcheck.h" - -UBAbstractVotingSystem::UBAbstractVotingSystem(QObject *parent) - : QObject(parent) -{ - // NOOP - -} - - -UBAbstractVotingSystem::~UBAbstractVotingSystem() -{ - // NOOP -} - - -void UBAbstractVotingSystem::setLastError(QString pLastError) -{ - mLastError = pLastError; - qDebug() << "Voting System error: " << pLastError; -} - - -UBAbstractVotingSystem* UBVotingSystemFactory::createVotingSystem() -{ - -#ifdef Q_WS_WIN - - // TODO UB 4.x .. be smarter - UBReplyWRS970VotingSystem* wrs970 = new UBReplyWRS970VotingSystem(UBApplication::mainWindow); - - if (wrs970->isVotingSystemAvailable()) - return wrs970; - else - { - delete wrs970; - - UBReply2005VotingSystem* reply2005 = new UBReply2005VotingSystem(UBApplication::mainWindow); - - if (reply2005->isVotingSystemAvailable()) - return reply2005; - else - delete reply2005; - - return 0; - } - -#else - return 0; -#endif - -} diff --git a/src/adaptors/voting/UBAbstractVotingSystem.h b/src/adaptors/voting/UBAbstractVotingSystem.h deleted file mode 100644 index b573b5f3..00000000 --- a/src/adaptors/voting/UBAbstractVotingSystem.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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 3 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 . - */ - -#ifndef UBABSTRACTVOTINGSYSTEM_H_ -#define UBABSTRACTVOTINGSYSTEM_H_ - -#include - -#include "core/UBApplication.h" - -class UBAbstractVotingSystem : public QObject -{ - Q_OBJECT; - - Q_PROPERTY(QString lastError READ lastError); - - public: - UBAbstractVotingSystem(QObject *parent = 0); - virtual ~UBAbstractVotingSystem(); - - virtual bool connectToVotingSystem() = 0; - - virtual bool startPolling() = 0; - - virtual bool stopPolling() = 0; - - virtual bool disconnectFromVotingSystem() = 0; - - virtual QMap votingState() = 0; - - QString lastError() const - { - return mLastError; - } - - signals: - - void voteReceived(int keypadID, int value); - - void errorReceived(const QString& error); - - protected: - - void setLastError(QString pLastError); - - private: - - QString mLastError; - -}; - -class UBVotingSystemFactory : public QObject -{ - private: - UBVotingSystemFactory() - { - // NOOP - } - - ~UBVotingSystemFactory() - { - // NOOP - } - - public: - - static UBAbstractVotingSystem* createVotingSystem(); -}; - -#endif /* UBABSTRACTVOTINGSYSTEM_H_ */ diff --git a/src/adaptors/voting/UBReply2005VotingSystem.cpp b/src/adaptors/voting/UBReply2005VotingSystem.cpp deleted file mode 100644 index 3e3f11f9..00000000 --- a/src/adaptors/voting/UBReply2005VotingSystem.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/* - * 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 3 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 . - */ - -#include "UBReply2005VotingSystem.h" - -#include "core/UBSettings.h" - -#include "core/memcheck.h" - -UBReply2005VotingSystem::UBReply2005VotingSystem(QWidget *parent) - : UBAbstractVotingSystem(parent) - , mParent(parent) - , mReplyVotingSystem(0) - , mMaxKeyValue(99) -{ - // NOOP -} - -UBReply2005VotingSystem::~UBReply2005VotingSystem() -{ - if (mReplyVotingSystem) - delete mReplyVotingSystem; -} - -bool UBReply2005VotingSystem::isVotingSystemAvailable() -{ - if (!mReplyVotingSystem) - mReplyVotingSystem = new ReplyXControl1::ReplyX(mParent); - - return (!mReplyVotingSystem->isNull()); -} - - -bool UBReply2005VotingSystem::connectToVotingSystem() -{ - bool result = false; - - if (isVotingSystemAvailable()) - { - connect(mReplyVotingSystem, SIGNAL(OnKeypadDataReceived(int, int)), - this, SLOT(keypadDataReceived(int, int))); - - mReplyVotingSystem->SetSerialPort(UBSettings::settings()->replyWWSerialPort->get().toInt()); - mReplyVotingSystem->SetReplyModel(ReplyXControl1::mReply2005); - - result = mReplyVotingSystem->Connect(); - - if (!result) - setLastError("Cannot connect to voting system"); - } - else - { - setLastError("Reply2005 driver not available"); - } - - return result; -} - -void UBReply2005VotingSystem::keypadDataReceived(int keyPadID, int val) -{ - qDebug() << "received vote from " << keyPadID << " : " << val; - - mVotes.insert(keyPadID, val); - - emit voteReceived(keyPadID, val); -} - - -bool UBReply2005VotingSystem::startPolling() -{ - mVotes.clear(); - - if (isVotingSystemAvailable()) - { - mReplyVotingSystem->StartPolling(); - } - else - { - setLastError("Reply2005 driver not available"); - } - - return true; -} - - -bool UBReply2005VotingSystem::stopPolling() -{ - if (isVotingSystemAvailable()) - { - mReplyVotingSystem->StopPolling(); - } - else - { - setLastError("Reply2005 driver not available"); - } - - return true; -} - - -bool UBReply2005VotingSystem::disconnectFromVotingSystem() -{ - if (isVotingSystemAvailable()) - { - mReplyVotingSystem->Disconnect(); - } - else - { - setLastError("Reply2005 driver not available"); - } - - return true; -} - -QMap UBReply2005VotingSystem::votingState() -{ - QMap results; - - for(int i = 0; i < mMaxKeyValue; i++) - { - results.insert(i, 0); - } - - foreach(int vote, mVotes.values()) - { - int voteCount = 0; - - if(results.keys().contains(vote)) - { - voteCount = results.value(vote); - voteCount++; - results.insert(vote, voteCount); - } - } - - return results; -} - - diff --git a/src/adaptors/voting/UBReply2005VotingSystem.h b/src/adaptors/voting/UBReply2005VotingSystem.h deleted file mode 100644 index 15fbff12..00000000 --- a/src/adaptors/voting/UBReply2005VotingSystem.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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 3 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 . - */ - -#ifndef UBREPLY2005VOTINGSYSTEM_H_ -#define UBREPLY2005VOTINGSYSTEM_H_ - -#include "UBAbstractVotingSystem.h" - -#include - -#include "replyxcontrol1.h" - -class UBReply2005VotingSystem: public UBAbstractVotingSystem -{ - Q_OBJECT; - - public: - UBReply2005VotingSystem(QWidget *parent = 0); - virtual ~UBReply2005VotingSystem(); - - public slots: - - virtual bool connectToVotingSystem(); - virtual bool disconnectFromVotingSystem(); - - virtual bool startPolling(); - virtual bool stopPolling(); - - virtual QMap votingState(); - - bool isVotingSystemAvailable(); - - protected: - ReplyXControl1::ReplyX *mReplyVotingSystem; - - private: - - QWidget* mParent; - - QMap mVotes; - - int mMaxKeyValue; - - private slots: - void keypadDataReceived(int, int); -}; - -#endif /* UBREPLY2005VOTINGSYSTEM_H_ */ diff --git a/src/adaptors/voting/UBReplyWRS970VotingSystem.cpp b/src/adaptors/voting/UBReplyWRS970VotingSystem.cpp deleted file mode 100644 index e60d5233..00000000 --- a/src/adaptors/voting/UBReplyWRS970VotingSystem.cpp +++ /dev/null @@ -1,279 +0,0 @@ -/* - * 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 3 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 . - */ - -#include "UBReplyWRS970VotingSystem.h" - -#include "core/UBSettings.h" -#include "core/UBApplication.h" - -#include "core/memcheck.h" - -UBReplyWRS970VotingSystem::UBReplyWRS970VotingSystem(QWidget *parent) - : UBAbstractVotingSystem(parent) - , mParent(parent) - , mReplyVotingSystem(0) - , mMaxKeyValue(99) - , mCurrentQuestionNumber(0) -{ - // NOOP -} - - -UBReplyWRS970VotingSystem::~UBReplyWRS970VotingSystem() -{ - if (mReplyVotingSystem) - delete mReplyVotingSystem; -} - - -bool UBReplyWRS970VotingSystem::isVotingSystemAvailable() -{ - if (!mReplyVotingSystem) - { - mReplyVotingSystem = new WRS970::WRS970X(mParent); - - connect(mReplyVotingSystem, SIGNAL(OnKeypadData(QString, int, int, QString, int, QString, int, int)), - this, SLOT(keypadData(QString, int, int, QString, int, QString, int, int))); - - connect(mReplyVotingSystem, SIGNAL(OnError(QString)), this, SLOT(error(QString))); - connect(mReplyVotingSystem, SIGNAL(OnDebug(QString)), this, SLOT(debug(QString))); - - mReplyVotingSystem->SetVersion3(true); - mReplyVotingSystem->SetExceptionsEnabled(false); - mReplyVotingSystem->SetErrorsEnabled(true); - - bool ok; - int maxKeypadsAllowed = UBSettings::settings()->replyPlusMaxKeypads->get().toInt(&ok); - - if (ok) - { - mReplyVotingSystem->SetMaxKeypadsAllowed(maxKeypadsAllowed); - - for(int i = 0 ; i < maxKeypadsAllowed; i += 100) - { - mReplyVotingSystem->AddStaticKeypad("00000", i + 1, true); - } - } - - if (UBApplication::app()->isVerbose()) - { - mReplyVotingSystem->SetDebugEnabled(true); - } - } - - return (!mReplyVotingSystem->isNull()); -} - - -bool UBReplyWRS970VotingSystem::connectToVotingSystem() -{ - bool connected = false; - - if (isVotingSystemAvailable()) - { - mCurrentQuestionNumber = 0; - QString targetBase; - - QString connectionURL = UBSettings::settings()->replyPlusConnectionURL->get().toString(); - - if (connectionURL.toLower() == "usb") - { - QString baseSerial = mReplyVotingSystem->GetAvailableBases(false); - - if (baseSerial == "No device found") - { - setLastError("No WRS970 device found via USB"); - return false; - } - - QStringList bases = baseSerial.split(","); - - if (bases.count() == 0) - { - setLastError("No base found via USB"); - return false; - } - - targetBase = bases.at(0); - - mReplyVotingSystem->Connect(targetBase); - } - else - { - QString ip; - QString port; - - targetBase = connectionURL; - - QStringList addressTokens = connectionURL.split(":"); - - if (addressTokens.length() > 0) - ip = addressTokens.at(0); - - if (addressTokens.length() > 1) - port = addressTokens.at(1); - - if (ip.length() > 0) - { - mReplyVotingSystem->SetCommType(WRS970::ctTCP); - mReplyVotingSystem->SetTCPAddress(ip); - - bool ok; - int iPort = port.toInt(&ok); - - if (port.length() > 0 && ok) - mReplyVotingSystem->SetTCPPort(iPort); - } - - mReplyVotingSystem->Connect(NULL); - - } - - connected = mReplyVotingSystem->Connected(); - - if (!connected) - setLastError("Error connecting to base " + targetBase); - - qDebug() << "Reply WRS 970 connected:" << connected; - - if (connected) - { - QString addressingMode = UBSettings::settings()->replyPlusAddressingMode->get().toString(); - - if (addressingMode.toLower() == "static") - mReplyVotingSystem->SetAddressMode(WRS970::addrStatic); - else - mReplyVotingSystem->SetAddressMode(WRS970::addrDynamic); - } - } - else - { - setLastError("WRS970 driver not available"); - } - - return connected; -} - - -void UBReplyWRS970VotingSystem::keypadData(QString serialNumber, int keypadID, int timeStamp, QString version - , int batteryLevel, QString value, int questionNumber, int keypadType) -{ - Q_UNUSED(serialNumber); - Q_UNUSED(timeStamp); - Q_UNUSED(version); - Q_UNUSED(batteryLevel); - Q_UNUSED(questionNumber); - Q_UNUSED(keypadType); - - qDebug() << "Received vote from " << keypadID << " : " << value; - - mVotes.insert(keypadID, value.toInt()); - - emit voteReceived(keypadID, value.toInt()); -} - - -void UBReplyWRS970VotingSystem::error(QString error) -{ - setLastError(error); - - emit errorReceived(error); - - //UBApplication::showMessage(tr("Voting System Error: %1").arg(error)); -} - - -void UBReplyWRS970VotingSystem::debug(QString error) -{ - qDebug() << error; -} - - - -bool UBReplyWRS970VotingSystem::startPolling() -{ - mVotes.clear(); - - if (isVotingSystemAvailable()) - { - ++mCurrentQuestionNumber; - mReplyVotingSystem->BeginQuestion(mCurrentQuestionNumber, WRS970::atSingleDigit); - } - else - { - setLastError("WRS970 driver not available"); - } - - return true; -} - - -bool UBReplyWRS970VotingSystem::stopPolling() -{ - if (isVotingSystemAvailable()) - { - //mReplyVotingSystem-> - } - else - { - setLastError("WRS970 driver not available"); - } - - return true; -} - - -bool UBReplyWRS970VotingSystem::disconnectFromVotingSystem() -{ - if (isVotingSystemAvailable()) - { - mReplyVotingSystem->Disconnect(); - } - else - { - setLastError("WRS970 driver not available"); - } - - return true; -} - -QMap UBReplyWRS970VotingSystem::votingState() -{ - QMap results; - - for(int i = 0; i < mMaxKeyValue; i++) - { - results.insert(i, 0); - } - - foreach(int vote, mVotes.values()) - { - if(results.keys().contains(vote)) - { - int voteCount = results.value(vote); - voteCount++; - results.insert(vote, voteCount); - } - } - - foreach(int key, results.keys()) - { - qDebug() << "Vote" << key << ":" << results.value(key); - } - - return results; -} - - diff --git a/src/adaptors/voting/UBReplyWRS970VotingSystem.h b/src/adaptors/voting/UBReplyWRS970VotingSystem.h deleted file mode 100644 index 4aa82679..00000000 --- a/src/adaptors/voting/UBReplyWRS970VotingSystem.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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 3 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 . - */ - -#ifndef UBREPLYWRS970VOTINGSYSTEM_H_ -#define UBREPLYWRS970VOTINGSYSTEM_H_ - -#include "UBAbstractVotingSystem.h" - -#include "wrs970.h" - -class UBReplyWRS970VotingSystem : public UBAbstractVotingSystem -{ - Q_OBJECT; - - public: - UBReplyWRS970VotingSystem(QWidget *parent = 0); - virtual ~UBReplyWRS970VotingSystem(); - - public slots: - - virtual bool connectToVotingSystem(); - virtual bool disconnectFromVotingSystem(); - - virtual bool startPolling(); - virtual bool stopPolling(); - - virtual QMap votingState(); - - bool isVotingSystemAvailable(); - - protected: - WRS970::WRS970X *mReplyVotingSystem; - - private: - - QWidget* mParent; - QMap mVotes; - int mMaxKeyValue; - int mCurrentQuestionNumber; - - private slots: - - void keypadData(QString, int, int, QString, int, QString, int, int); - - void error(QString error); - - void debug(QString error); - -}; - -#endif /* UBREPLYWRS970VOTINGSYSTEM_H_ */ diff --git a/src/api/UBWidgetVotingSystemAPI.cpp b/src/api/UBWidgetVotingSystemAPI.cpp deleted file mode 100644 index cd52de74..00000000 --- a/src/api/UBWidgetVotingSystemAPI.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - * 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 3 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 . - */ - -#include "UBWidgetVotingSystemAPI.h" - -#include "adaptors/voting/UBAbstractVotingSystem.h" - -#include "core/memcheck.h" - -UBWidgetVotingSystemAPI::UBWidgetVotingSystemAPI(QObject* parent) - : QObject(parent) - , mVotingSystem(0) -{ - // NOOP -} - - -UBWidgetVotingSystemAPI::~UBWidgetVotingSystemAPI() -{ - // NOOP -} - - -QString UBWidgetVotingSystemAPI::lastError() -{ - return mLastError; -} - - -void UBWidgetVotingSystemAPI::setLastError(const QString& pLastError) -{ - mLastError = pLastError; - qDebug() << mLastError; - - emit error(mLastError); -} - - -void UBWidgetVotingSystemAPI::errorReceived(const QString& pLastError) -{ - setLastError(pLastError); -} - - -bool UBWidgetVotingSystemAPI::startPoll() -{ - if (!mVotingSystem) - { - mVotingSystem = UBVotingSystemFactory::createVotingSystem(); - } - - if (!mVotingSystem) - { - setLastError("No voting system available"); - return false; - } - - connect(mVotingSystem, SIGNAL(errorReceived(const QString&)), this, SLOT(errorReceived(const QString&))); - - bool connected = mVotingSystem->connectToVotingSystem(); - - if (!connected) - { - return false; - } - - bool started = mVotingSystem->startPolling(); - - if (!started) - { - return false; - } - - return true; -} - - -QVariantMap UBWidgetVotingSystemAPI::closePoll() -{ - if (!mVotingSystem) - return QVariantMap(); - - mVotingSystem->stopPolling(); - - QMap results = mVotingSystem->votingState(); - - mVotingSystem->disconnectFromVotingSystem(); - - delete mVotingSystem; - mVotingSystem = 0; - - QVariantMap scriptResults; - - foreach(int key, results.keys()) - { - scriptResults.insert(QString("%1").arg(key), QVariant(results.value(key))); - } - - return scriptResults; -} diff --git a/src/api/UBWidgetVotingSystemAPI.h b/src/api/UBWidgetVotingSystemAPI.h deleted file mode 100644 index 1497fee8..00000000 --- a/src/api/UBWidgetVotingSystemAPI.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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 3 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 . - */ - -#ifndef UBWIDGETVOTINGSYSTEMAPI_H_ -#define UBWIDGETVOTINGSYSTEMAPI_H_ - -#include - -class UBAbstractVotingSystem; - -class UBWidgetVotingSystemAPI : public QObject -{ - Q_OBJECT; - - Q_PROPERTY(QString lastError READ lastError); - - public: - UBWidgetVotingSystemAPI(QObject* parent = 0); - virtual ~UBWidgetVotingSystemAPI(); - - QString lastError(); - void setLastError(const QString& pLastError); - - signals: - void error(const QString&); - - public slots: - - bool startPoll(); - QVariantMap closePoll(); - - private slots: - - void errorReceived(const QString& error); - - private: - UBAbstractVotingSystem* mVotingSystem; - QString mLastError; - -}; - -#endif /* UBWIDGETVOTINGSYSTEMAPI_H_ */ diff --git a/src/api/api.pri b/src/api/api.pri index a7e6f521..f4de505e 100644 --- a/src/api/api.pri +++ b/src/api/api.pri @@ -2,14 +2,12 @@ HEADERS += src/api/UBWidgetUniboardAPI.h \ src/api/UBLibraryAPI.h \ src/api/UBW3CWidgetAPI.h \ - src/api/UBWidgetMessageAPI.h \ - src/api/UBWidgetVotingSystemAPI.h + src/api/UBWidgetMessageAPI.h SOURCES += src/api/UBWidgetUniboardAPI.cpp \ src/api/UBLibraryAPI.cpp \ src/api/UBW3CWidgetAPI.cpp \ - src/api/UBWidgetMessageAPI.cpp \ - src/api/UBWidgetVotingSystemAPI.cpp + src/api/UBWidgetMessageAPI.cpp diff --git a/src/domain/UBW3CWidget.cpp b/src/domain/UBW3CWidget.cpp index 6d7a0fe8..ad0d4be9 100644 --- a/src/domain/UBW3CWidget.cpp +++ b/src/domain/UBW3CWidget.cpp @@ -24,7 +24,6 @@ #include "core/UBApplication.h" #include "core/UBSettings.h" #include "api/UBWidgetUniboardAPI.h" -#include "api/UBWidgetVotingSystemAPI.h" #include "board/UBBoardController.h" @@ -219,18 +218,8 @@ void UBW3CWidget::javaScriptWindowObjectCleared() page()->mainFrame()->addToJavaScriptWindowObject("sankore", uniboardAPI); - UBWidgetVotingSystemAPI *votingSystem = new UBWidgetVotingSystemAPI(this); - page()->mainFrame()->addToJavaScriptWindowObject("voting", votingSystem); - - connect(votingSystem, SIGNAL(error(const QString&)) , this, SLOT(votingSystemError(const QString&))); } -void UBW3CWidget::votingSystemError(const QString& error) -{ - page()->mainFrame()->evaluateJavaScript("if(voting.onerror) { voting.onerror('" + error +"');}"); -} - - bool UBW3CWidget::hasNPAPIWrapper(const QString& pMimeType) { loadNPAPIWrappersTemplates(); diff --git a/src/domain/UBW3CWidget.h b/src/domain/UBW3CWidget.h index b2518c71..f407370b 100644 --- a/src/domain/UBW3CWidget.h +++ b/src/domain/UBW3CWidget.h @@ -117,8 +117,6 @@ class UBW3CWidget : public UBAbstractWidget void javaScriptWindowObjectCleared(); - void votingSystemError(const QString&); - }; #endif /* UBW3CWIDGET_H_ */