diff --git a/ground/ground.pro.user.2.1pre1 b/ground/ground.pro.user.2.1pre1
new file mode 100644
index 000000000..0a2acf277
--- /dev/null
+++ b/ground/ground.pro.user.2.1pre1
@@ -0,0 +1,311 @@
+
+
+
+ ProjectExplorer.Project.ActiveTarget
+ 0
+
+
+ ProjectExplorer.Project.EditorSettings
+
+ System
+
+
+
+ ProjectExplorer.Project.Target.0
+
+ Desktop
+ Qt4ProjectManager.Target.DesktopTarget
+ 0
+ 0
+
+
+ qmake
+ QtProjectManager.QMakeBuildStep
+
+
+
+ Make
+ Qt4ProjectManager.MakeStep
+ false
+
+
+
+ 2
+
+ Make
+ Qt4ProjectManager.MakeStep
+ true
+
+ clean
+
+
+
+ 1
+ false
+
+ Qt in PATH Debug
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 2
+ D:/!Work/OpenSource/OpenPilot/op/OpenPilot/ground-build
+ 2
+ 2
+ true
+
+
+
+ qmake
+ QtProjectManager.QMakeBuildStep
+
+
+
+ Make
+ Qt4ProjectManager.MakeStep
+ false
+
+
+
+ 2
+
+ Make
+ Qt4ProjectManager.MakeStep
+ true
+
+ clean
+
+
+
+ 1
+ false
+
+ Qt in PATH Release
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 0
+ D:/!Work/OpenSource/OpenPilot/op/OpenPilot/ground-build
+ 2
+ 2
+ true
+
+
+
+ qmake
+ QtProjectManager.QMakeBuildStep
+
+
+
+ Make
+ Qt4ProjectManager.MakeStep
+ false
+
+
+
+ 2
+
+ Make
+ Qt4ProjectManager.MakeStep
+ true
+
+ clean
+
+
+
+ 1
+ false
+
+ 4.6.2 Debug
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 2
+ D:/!Work/OpenSource/OpenPilot/op/OpenPilot/ground-build
+ 13
+ 2
+ true
+
+
+
+ qmake
+ QtProjectManager.QMakeBuildStep
+
+
+
+ Make
+ Qt4ProjectManager.MakeStep
+ false
+
+
+
+ 2
+
+ Make
+ Qt4ProjectManager.MakeStep
+ true
+
+ clean
+
+
+
+ 1
+ false
+
+ 4.6.2 Release
+ Qt4ProjectManager.Qt4BuildConfiguration
+ 0
+ D:/!Work/OpenSource/OpenPilot/op/OpenPilot/ground-build
+ 13
+ 2
+ true
+
+ 4
+
+ bin
+ Qt4ProjectManager.Qt4RunConfiguration
+ 2
+
+ openpilotgcs/bin/bin.pro
+ false
+ false
+
+ false
+ false
+
+
+
+ translations
+ Qt4ProjectManager.Qt4RunConfiguration
+ 2
+
+ openpilotgcs/share/openpilotgcs/translations/translations.pro
+ false
+ false
+
+ false
+ false
+
+
+
+ uavobjgenerator
+ Qt4ProjectManager.Qt4RunConfiguration
+ 2
+
+ uavobjgenerator/uavobjgenerator.pro
+ false
+ false
+
+ false
+ false
+
+
+
+ app
+ Qt4ProjectManager.Qt4RunConfiguration
+ 2
+
+ openpilotgcs/src/app/app.pro
+ false
+ false
+
+ false
+ false
+
+
+
+ berkeley
+ Qt4ProjectManager.Qt4RunConfiguration
+ 2
+
+ openpilotgcs/src/libs/libqxt/src/berkeley/berkeley.pro
+ false
+ false
+
+ false
+ false
+
+
+
+ designer
+ Qt4ProjectManager.Qt4RunConfiguration
+ 2
+
+ openpilotgcs/src/libs/libqxt/src/designer/designer.pro
+ false
+ false
+
+ false
+ false
+
+
+
+ gui
+ Qt4ProjectManager.Qt4RunConfiguration
+ 2
+
+ openpilotgcs/src/libs/libqxt/src/gui/gui.pro
+ false
+ false
+
+ false
+ false
+
+
+
+ network
+ Qt4ProjectManager.Qt4RunConfiguration
+ 2
+
+ openpilotgcs/src/libs/libqxt/src/network/network.pro
+ false
+ false
+
+ false
+ false
+
+
+
+ sql
+ Qt4ProjectManager.Qt4RunConfiguration
+ 2
+
+ openpilotgcs/src/libs/libqxt/src/sql/sql.pro
+ false
+ false
+
+ false
+ false
+
+
+
+ web
+ Qt4ProjectManager.Qt4RunConfiguration
+ 2
+
+ openpilotgcs/src/libs/libqxt/src/web/web.pro
+ false
+ false
+
+ false
+ false
+
+
+
+ zeroconf
+ Qt4ProjectManager.Qt4RunConfiguration
+ 2
+
+ openpilotgcs/src/libs/libqxt/src/zeroconf/zeroconf.pro
+ false
+ false
+
+ false
+ false
+
+
+ 11
+
+
+
+ ProjectExplorer.Project.TargetCount
+ 1
+
+
+ ProjectExplorer.Project.Updater.FileVersion
+ 4
+
+
diff --git a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/lks94projection.h b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/lks94projection.h
index 4eee20aaa..dc895f04c 100644
--- a/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/lks94projection.h
+++ b/ground/openpilotgcs/src/libs/opmapcontrol/src/internals/projections/lks94projection.h
@@ -28,7 +28,7 @@
#define LKS94PROJECTION_H
#include
#include "cmath"
-#include "../pureprojection.h"
+#include "D:\!Work\OpenSource\OpenPilot\OpenPilot\ground\openpilotgcs\src\libs\opmapcontrol\src\internals\pureprojection.h"
namespace projections {
diff --git a/ground/openpilotgcs/src/plugins/notify/NotificationItem.h b/ground/openpilotgcs/src/plugins/notify/NotificationItem.h
new file mode 100644
index 000000000..c09e64982
--- /dev/null
+++ b/ground/openpilotgcs/src/plugins/notify/NotificationItem.h
@@ -0,0 +1,154 @@
+/**
+ ******************************************************************************
+ *
+ * @file NotificationItem.h
+ * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
+ * @brief Notify Plugin configuration header
+ * @see The GNU Public License (GPL) Version 3
+ * @defgroup notifyplugin
+ * @{
+ *
+ *****************************************************************************/
+/*
+ * 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, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#ifndef NOTIFICATION_ITEM_H
+#define NOTIFICATION_ITEM_H
+
+#include
+#include "qsettings.h"
+#include
+#include
+
+using namespace Core;
+
+#define DECLARE_SOUND(number) \
+ QString getSound##number() const { return _sound##number; } \
+ void setSound##number(QString text) { _sound##number = text; } \
+
+// QString getSound2() const { return _sound2; }
+// void setSound2(QString text) { _sound2 = text; }
+
+// QString getSound3() const { return _sound3; }
+// void setSound3(QString text) { _sound3 = text; }
+
+class NotificationItem : public QObject
+{
+ Q_OBJECT
+public:
+ explicit NotificationItem(QObject *parent = 0);
+
+ void copyTo(NotificationItem*) const;
+
+ DECLARE_SOUND(1)
+ DECLARE_SOUND(2)
+ DECLARE_SOUND(3)
+
+ QString getValue() const { return _dataValue; }
+ void setValue(QString text) { _dataValue = text; }
+
+ QString getSayOrder() const { return _sayOrder; }
+ void setSayOrder(QString text) { _sayOrder = text; }
+
+ double getSpinBoxValue() const { return _spinBoxValue; }
+ void setSpinBoxValue(double value) { _spinBoxValue = value; }
+
+
+ QString getDataObject() const { return _dataObject; }
+ void setDataObject(QString text) { _dataObject = text; }
+
+ QString getObjectField() const { return _objectField; }
+ void setObjectField(QString text) { _objectField = text; }
+
+ QString getSoundCollectionPath() const { return _soundCollectionPath; }
+ void setSoundCollectionPath(QString path) { _soundCollectionPath = path; }
+
+ QString getCurrentLanguage() const { return _currentLanguage; }
+ void setCurrentLanguage(QString text) { _currentLanguage = text; }
+
+ QStringList getMessageSequence() const { return _messageSequence; }
+ void setMessageSequence(QStringList sequence) { _messageSequence = sequence; }
+
+ QString getRepeatFlag() const { return _repeatString; }
+ void setRepeatFlag(QString value) { _repeatString = value; }
+
+ bool getRepeatTimeout() const { return _repeatTimeout; }
+ void setRepeatTimeout(bool value) { _repeatTimeout = value; }
+
+ int getExpireTimeout() const { return _expireTimeout; }
+ void setExpireTimeout(int value) { _expireTimeout = value; }
+
+ bool getEnableFlag() const { return _enableFlag; }
+ void setEnableFlag(bool value) { _enableFlag = value; }
+
+ void saveState(QSettings* settings) const;
+ void restoreState(QSettings* settings);
+ QString parseNotifyMessage();
+
+ QTimer* timer;
+ QTimer* expireTimer;
+ bool isNowPlaying; //
+ bool firstStart;
+
+private:
+
+ QStringList _messageSequence;
+
+ //! path to folder with sound files
+ QString _soundCollectionPath;
+
+ //! language in what notifications will be spelled
+ QString _currentLanguage;
+
+ //! one UAV object per one notification
+ QString _dataObject;
+
+ //! one field value change can be assigned to one notification
+ QString _objectField;
+
+ //! poled UAV field value
+ QString _dataValue;
+
+ //! possible sounds(at least one required to play notification)
+ QString _sound1;
+ QString _sound2;
+ QString _sound3;
+
+ //! order in what sounds 1-3 will be played
+ QString _sayOrder;
+
+ double _spinBoxValue;
+
+ QString _repeatString;
+
+ //! time when next notification must be fired
+ bool _repeatTimeout;
+
+ //! how often or what periodicaly notification should be played
+ int _repeatTimerValue;
+
+ //! time after event occured till notification became invalid
+ //! and will be removed from list
+ int _expireTimeout;
+
+ //! enables/disables playing of current notification
+ bool _enableFlag;
+};
+
+Q_DECLARE_METATYPE(NotificationItem*)
+
+#endif // NotificationItem_H
diff --git a/ground/openpilotgcs/src/plugins/notify/notify.pro b/ground/openpilotgcs/src/plugins/notify/notify.pro
index 9ebebfa22..e70392a6a 100644
--- a/ground/openpilotgcs/src/plugins/notify/notify.pro
+++ b/ground/openpilotgcs/src/plugins/notify/notify.pro
@@ -10,9 +10,9 @@ QT += phonon
HEADERS += notifyplugin.h \
notifypluginoptionspage.h \
- notifypluginconfiguration.h \
notifyitemdelegate.h \
- notifytablemodel.h
+ notifytablemodel.h \
+ NotificationItem.h
SOURCES += notifyplugin.cpp \
notifypluginoptionspage.cpp \
diff --git a/ground/openpilotgcs/src/plugins/notify/notifyitemdelegate.cpp b/ground/openpilotgcs/src/plugins/notify/notifyitemdelegate.cpp
index 7a2fc2ef4..d6e5161fc 100644
--- a/ground/openpilotgcs/src/plugins/notify/notifyitemdelegate.cpp
+++ b/ground/openpilotgcs/src/plugins/notify/notifyitemdelegate.cpp
@@ -25,136 +25,135 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "notifyitemdelegate.h"
#include
+#include "notifyitemdelegate.h"
+#include "notifytablemodel.h"
- NotifyItemDelegate::NotifyItemDelegate(QStringList items,QObject *parent)
- : QItemDelegate(parent),
- m_parent(parent),
- m_items(items) {
+NotifyItemDelegate::NotifyItemDelegate(QStringList items, QObject* parent)
+ : QItemDelegate(parent)
+ , _parent(parent)
+ , _items(items)
+{
- }
+}
- QWidget *NotifyItemDelegate::createEditor(QWidget *parent,
- const QStyleOptionViewItem &,
- const QModelIndex &index) const
- {
- if (index.column() == 1) {
- QComboBox* editor = new QComboBox(parent);
- editor->clear();
- editor->addItems(m_items);
- //repeatEditor->setCurrentIndex(0);
- //repeatEditor->setItemDelegate(new RepeatCounterDelegate());
-
- //connect(repeatEditor,SIGNAL(activated (const QString& )),this,SLOT(selectRow(const QString& )));
- //QTableWidgetItem* item = qobject_cast(parent);
- //((QTableWidgetItem*)parent)->setSelected(true);
-// connect(editor, SIGNAL(editingFinished()),
-// this, SLOT(commitAndCloseEditor()));
- return editor;
- } else
- {
- if(index.column() == 2)
- {
- QSpinBox* editor = new QSpinBox(parent);
- connect(editor, SIGNAL(editingFinished()),
- this, SLOT(commitAndCloseEditor()));
- return editor;
- }
-
- }
- QLineEdit *editor = new QLineEdit(parent);
-// connect(editor, SIGNAL(editingFinished()),
-// this, SLOT(commitAndCloseEditor()));
- return editor;
- }
-
- void NotifyItemDelegate::commitAndCloseEditor()
- {
- QLineEdit *editor = qobject_cast(sender());
- if (editor)
- {
- emit commitData(editor);
- emit closeEditor(editor);
-
- } else {
- QComboBox* editor = qobject_cast(sender());
- if (editor)
- {
- emit commitData(editor);
- emit closeEditor(editor);
- } else {
- QSpinBox* editor = qobject_cast(sender());
- if (editor)
- {
- emit commitData(editor);
- emit closeEditor(editor);
- }
- }
- }
- }
-
- void NotifyItemDelegate::setEditorData(QWidget *editor,
- const QModelIndex &index) const
- {
- QLineEdit *edit = qobject_cast(editor);
- if (edit) {
- edit->setText(index.model()->data(index, Qt::EditRole).toString());
- } else {
- QComboBox * repeatEditor = qobject_cast(editor);
- if (repeatEditor)
- repeatEditor->setCurrentIndex(repeatEditor->findText(index.model()->data(index, Qt::EditRole).toString()));
- else {
- QSpinBox * expireEditor = qobject_cast(editor);
- if (expireEditor)
- expireEditor->setValue(index.model()->data(index, Qt::EditRole).toInt());
- }
- }
- }
-
- void NotifyItemDelegate::setModelData(QWidget *editor,
- QAbstractItemModel *model, const QModelIndex &index) const
- {
- QLineEdit *edit = qobject_cast(editor);
- if (edit) {
- model->setData(index, edit->text());
- } else {
- QComboBox * repeatEditor = qobject_cast(editor);
- if (repeatEditor) {
- model->setData(index, repeatEditor->currentText());
-
- } else {
- QSpinBox * expireEditor = qobject_cast(editor);
- if (expireEditor) {
- //expireEditor->interpretText();
- model->setData(index, expireEditor->value(), Qt::EditRole);
+QWidget *NotifyItemDelegate::createEditor(QWidget* parent,
+ const QStyleOptionViewItem& /*none*/,
+ const QModelIndex& index) const
+{
+ if(eREPEAT_VALUE == index.column()) {
+ QComboBox* editor = new QComboBox(parent);
+ editor->clear();
+ editor->addItems(_items);
+ return editor;
+ } else {
+ if(eEXPIRE_TIME == index.column()) {
+ QSpinBox* editor = new QSpinBox(parent);
+ connect(editor, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()));
+ return editor;
+ } else {
+ if(eENABLE_NOTIFICATION == index.column()) {
+ QCheckBox* editor = new QCheckBox(parent);
+ connect(editor, SIGNAL(editingFinished()), this, SLOT(commitAndCloseEditor()));
+ return editor;
}
- }
- }
- }
+ }
+ }
+ QLineEdit *editor = new QLineEdit(parent);
+ return editor;
+}
+void NotifyItemDelegate::commitAndCloseEditor()
+{
+ QLineEdit* editor = qobject_cast(sender());
+ if (editor) {
+ emit commitData(editor);
+ emit closeEditor(editor);
+ } else {
+ QComboBox* editor = qobject_cast(sender());
+ if (editor)
+ {
+ emit commitData(editor);
+ emit closeEditor(editor);
+ } else {
+ QSpinBox* editor = qobject_cast(sender());
+ if (editor)
+ {
+ emit commitData(editor);
+ emit closeEditor(editor);
+ } else {
+ QCheckBox* editor = qobject_cast(sender());
+ if (editor)
+ {
+ emit commitData(editor);
+ emit closeEditor(editor);
+ }
+ }
+ }
+ }
+}
+
+void NotifyItemDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
+{
+ QLineEdit* edit = qobject_cast(editor);
+ if(edit) {
+ edit->setText(index.model()->data(index, Qt::EditRole).toString());
+ } else {
+ QComboBox* repeatEditor = qobject_cast(editor);
+ if(repeatEditor)
+ repeatEditor->setCurrentIndex(repeatEditor->findText(index.model()->data(index, Qt::EditRole).toString()));
+ else {
+ QSpinBox* expireEditor = qobject_cast(editor);
+ if(expireEditor)
+ expireEditor->setValue(index.model()->data(index, Qt::EditRole).toInt());
+ else {
+ QCheckBox* enablePlayEditor = qobject_cast(editor);
+ if (enablePlayEditor)
+ enablePlayEditor->setChecked(index.model()->data(index, Qt::EditRole).toBool());
+ }
+ }
+ }
+}
+
+void NotifyItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
+{
+ QLineEdit *edit = qobject_cast(editor);
+ if(edit) {
+ model->setData(index, edit->text());
+ } else {
+ QComboBox * repeatEditor = qobject_cast(editor);
+ if(repeatEditor) {
+ model->setData(index, repeatEditor->currentText());
+ } else {
+ QSpinBox * expireEditor = qobject_cast(editor);
+ if(expireEditor) {
+ model->setData(index, expireEditor->value(), Qt::EditRole);
+ } else {
+ QCheckBox* enablePlayEditor = qobject_cast(editor);
+ if (enablePlayEditor) {
+ model->setData(index, enablePlayEditor->isChecked(), Qt::EditRole);
+ }
+ }
+ }
+ }
+}
void NotifyItemDelegate::selectRow(const QString & text)
{
- //QList list = ((QTableWidget*)(sender()->parent()))->findItems(text,Qt::MatchExactly);
QComboBox* combo = qobject_cast(sender());
QTableWidget* table = new QTableWidget;
table = (QTableWidget*)(combo->parent());
- qDebug()<columnCount();
- qDebug()<rowCount();
- qDebug()<currentRow();
- //table->setCurrentIndex(1);
- //table->findItems(text,Qt::MatchExactly);
- //item->model()->index()
- //item->setSelected(true);
+
+ qDebug() << table->columnCount();
+ qDebug() << table->rowCount();
+ qDebug() << table->currentRow();
}
-QSize NotifyItemDelegate::sizeHint ( const QStyleOptionViewItem & option,
- const QModelIndex & index ) const
+QSize NotifyItemDelegate::sizeHint(const QStyleOptionViewItem & option,
+ const QModelIndex & index) const
{
QSize s = QItemDelegate::sizeHint(option, index);
s.setHeight(10);
-
return s;
}
diff --git a/ground/openpilotgcs/src/plugins/notify/notifyitemdelegate.h b/ground/openpilotgcs/src/plugins/notify/notifyitemdelegate.h
index 40d6ced20..01fa0794d 100644
--- a/ground/openpilotgcs/src/plugins/notify/notifyitemdelegate.h
+++ b/ground/openpilotgcs/src/plugins/notify/notifyitemdelegate.h
@@ -31,21 +31,6 @@
#include
#include
-//class RepeatCounterDelegate : public QItemDelegate
-//{
-// Q_OBJECT
-
-//public:
-// RepeatCounterDelegate(QObject *parent = 0);
-// QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &,
-// const QModelIndex &index) const;
-// void setEditorData(QWidget *editor, const QModelIndex &index) const;
-// void setModelData(QWidget *editor, QAbstractItemModel *model,
-// const QModelIndex &index) const;
-
-//private slots:
-// void commitAndCloseEditor();
-//};
class NotifyItemDelegate : public QItemDelegate
{
@@ -58,19 +43,16 @@ public:
void setEditorData(QWidget *editor, const QModelIndex &index) const;
void setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const;
-// bool editorEvent(QEvent * event, QAbstractItemModel * model,
-// const QStyleOptionViewItem & option, const QModelIndex & index );
QSize sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const;
-private:
- QObject* m_parent;
- QStringList m_items;
- QComboBox* repeatEditor;
-
-
private slots:
void selectRow(const QString & text);
void commitAndCloseEditor();
+
+private:
+ QObject* _parent;
+ QStringList _items;
+
};
#endif // NOTIFYITEMDELEGATE_H
diff --git a/ground/openpilotgcs/src/plugins/notify/notifyplugin.cpp b/ground/openpilotgcs/src/plugins/notify/notifyplugin.cpp
index 8735f8b60..c959925b4 100644
--- a/ground/openpilotgcs/src/plugins/notify/notifyplugin.cpp
+++ b/ground/openpilotgcs/src/plugins/notify/notifyplugin.cpp
@@ -26,7 +26,7 @@
*/
#include "notifyplugin.h"
-#include "notifypluginconfiguration.h"
+#include "notificationitem.h"
#include "notifypluginoptionspage.h"
#include
#include
@@ -37,15 +37,29 @@
#include
#include "qxttimer.h"
+#include "backendcapabilities.h"
static const QString VERSION = "1.0.0";
//#define DEBUG_NOTIFIES
+#ifdef DEBUG_NOTIFIES
+QDebug qNotifyDebug()
+#endif
+#ifndef DEBUG_NOTIFIES
+QNoDebug qNotifyDebug()
+#endif
+{
+#ifdef DEBUG_NOTIFIES
+ return qDebug();
+#endif
+ return QNoDebug();
+}
+
SoundNotifyPlugin::SoundNotifyPlugin()
{
- phonon.mo = NULL;
- configured = false;
+ phonon.mo = NULL;
+ configured = false;
// Do nothing
}
@@ -121,7 +135,7 @@ void SoundNotifyPlugin::readConfig( QSettings* settings, UAVConfigInfo *configIn
int size = settings->beginReadArray("listNotifies");
for (int i = 0; i < size; ++i) {
settings->setArrayIndex(i);
- NotifyPluginConfiguration* notification = new NotifyPluginConfiguration;
+ NotificationItem* notification = new NotificationItem;
notification->restoreState(settings);
lstNotifications.append(notification);
}
@@ -145,7 +159,7 @@ void SoundNotifyPlugin::readConfig_0_0_0(){
int size = settings->beginReadArray("listNotifies");
for (int i = 0; i < size; ++i) {
settings->setArrayIndex(i);
- NotifyPluginConfiguration* notification = new NotifyPluginConfiguration;
+ NotificationItem* notification = new NotificationItem;
notification->restoreState(settings);
lstNotifications.append(notification);
}
@@ -185,7 +199,7 @@ void SoundNotifyPlugin::onAutopilotDisconnect()
void SoundNotifyPlugin::resetNotification(void)
{
//first, reject empty args and unknown fields.
- foreach(NotifyPluginConfiguration* notify,lstNotifications) {
+ foreach(NotificationItem* notify,lstNotifications) {
if(notify->timer)
{
disconnect(notify->timer, SIGNAL(timeout()), this, SLOT(repeatTimerHandler()));
@@ -207,7 +221,7 @@ void SoundNotifyPlugin::resetNotification(void)
update list of notifies;
will be perform on OK or APPLY press of option page
*/
-void SoundNotifyPlugin::updateNotificationList(QList list)
+void SoundNotifyPlugin::updateNotificationList(QList list)
{
removedNotifies.clear();
resetNotification();
@@ -224,10 +238,10 @@ void SoundNotifyPlugin::connectNotifications()
if (obj != NULL)
disconnect(obj,SIGNAL(objectUpdated(UAVObject*)),this,SLOT(appendNotification(UAVObject*)));
}
- if(phonon.mo != NULL) {
- delete phonon.mo;
- phonon.mo = NULL;
- }
+ if(phonon.mo != NULL) {
+ delete phonon.mo;
+ phonon.mo = NULL;
+ }
if(!enableSound) return;
@@ -240,25 +254,10 @@ void SoundNotifyPlugin::connectNotifications()
removedNotifies.clear();
//first, reject empty args and unknown fields.
- foreach(NotifyPluginConfiguration* notify,lstNotifications) {
+ foreach(NotificationItem* notify, lstNotifications) {
notify->firstStart=true;
notify->isNowPlaying=false;
-// if(notify->timer)
-// {
-// disconnect(notify->timer, SIGNAL(timeout()), this, SLOT(repeatTimerHandler()));
-// notify->timer->stop();
-// delete notify->timer;
-// notify->timer = NULL;
-// }
-// if(notify->expireTimer)
-// {
-// disconnect(notify->expireTimer, SIGNAL(timeout()), this, SLOT(expireTimerHandler()));
-// notify->expireTimer->stop();
-// delete notify->expireTimer;
-// notify->expireTimer = NULL;
-// }
-
UAVDataObject* obj = dynamic_cast( objManager->getObject(notify->getDataObject()) );
if (obj != NULL ) {
if(!lstNotifiedUAVObjects.contains(obj)) {
@@ -269,27 +268,25 @@ void SoundNotifyPlugin::connectNotifications()
std::cout << "Error: Object is unknown (" << notify->getDataObject().toStdString() << ")." << std::endl;
}
- if(lstNotifications.isEmpty()) return;
- // set notification message to current event
- phonon.mo = Phonon::createPlayer(Phonon::NotificationCategory);
- phonon.mo->clearQueue();
- phonon.firstPlay = true;
-#ifdef DEBUG_NOTIFIES
- QList audioOutputDevices =
- Phonon::BackendCapabilities::availableAudioOutputDevices();
- foreach(Phonon::AudioOutputDevice dev, audioOutputDevices) {
- qDebug() << "Notify: Audio Output device: " << dev.name() << " - " << dev.description();
- }
-#endif
- connect(phonon.mo,SIGNAL(stateChanged(Phonon::State,Phonon::State)),
- this,SLOT(stateChanged(Phonon::State,Phonon::State)));
+ if(lstNotifications.isEmpty()) return;
+ // set notification message to current event
+ phonon.mo = Phonon::createPlayer(Phonon::NotificationCategory);
+ phonon.mo->clearQueue();
+ phonon.firstPlay = true;
+ QList audioOutputDevices =
+ Phonon::BackendCapabilities::availableAudioOutputDevices();
+ foreach(Phonon::AudioOutputDevice dev, audioOutputDevices) {
+ qNotifyDebug() << "Notify: Audio Output device: " << dev.name() << " - " << dev.description();
+ }
+ connect(phonon.mo, SIGNAL(stateChanged(Phonon::State,Phonon::State)),
+ this, SLOT(stateChanged(Phonon::State,Phonon::State)));
}
void SoundNotifyPlugin::appendNotification(UAVObject *object)
{
disconnect(object, SIGNAL(objectUpdated(UAVObject*)), this, SLOT(appendNotification(UAVObject*)));
- foreach(NotifyPluginConfiguration* notification, lstNotifications) {
+ foreach(NotificationItem* notification, lstNotifications) {
if(object->getName()!=notification->getDataObject())
continue;
@@ -306,7 +303,7 @@ void SoundNotifyPlugin::appendNotification(UAVObject *object)
}
-void SoundNotifyPlugin::checkNotificationRule(NotifyPluginConfiguration* notification, UAVObject* object)
+void SoundNotifyPlugin::checkNotificationRule(NotificationItem* notification, UAVObject* object)
{
bool condition=false;
double threshold;
@@ -350,7 +347,7 @@ void SoundNotifyPlugin::checkNotificationRule(NotifyPluginConfiguration* notific
#endif
// if audio is busy, start expiration timer
//ms = (notification->getExpiredTimeout()[in sec])*1000
- //QxtTimer::singleShot(notification->getExpireTimeout()*1000, this, SLOT(expirationTimerHandler(NotifyPluginConfiguration*)), qVariantFromValue(notification));
+ //QxtTimer::singleShot(notification->getExpireTimeout()*1000, this, SLOT(expirationTimerHandler(NotificationItem*)), qVariantFromValue(notification));
pendingNotifications.append(notification);
if(!notification->expireTimer)
{
@@ -363,21 +360,22 @@ void SoundNotifyPlugin::checkNotificationRule(NotifyPluginConfiguration* notific
}
}
-bool SoundNotifyPlugin::playNotification(NotifyPluginConfiguration* notification)
+bool SoundNotifyPlugin::playNotification(NotificationItem* notification)
{
// Check: race condition, if phonon.mo got deleted don't go further
if (phonon.mo == NULL)
return false;
+ if(!notification->getEnableFlag()) return true;
+
#ifdef DEBUG_NOTIFIES
qDebug() << "Phonon State: " << phonon.mo->state();
#endif
- if((phonon.mo->state()==Phonon::PausedState) ||
- (phonon.mo->state()==Phonon::StoppedState) ||
- phonon.firstPlay)
+ if((phonon.mo->state()==Phonon::PausedState)
+ || (phonon.mo->state()==Phonon::StoppedState)
+ || phonon.firstPlay)
{
// don't fire expire timer
- //notification->expire = false;
nowPlayingConfiguration = notification;
if(notification->expireTimer)
notification->expireTimer->stop();
@@ -385,7 +383,6 @@ bool SoundNotifyPlugin::playNotification(NotifyPluginConfiguration* notification
if(notification->getRepeatFlag()=="Repeat Once")
{
removedNotifies.append(lstNotifications.takeAt(lstNotifications.indexOf(notification)));
- //if(!notification->firstStart) return true;
}
else {
if(notification->getRepeatFlag()!="Repeat Instantly")
@@ -407,24 +404,21 @@ bool SoundNotifyPlugin::playNotification(NotifyPluginConfiguration* notification
}
if(!notification->timer->isActive())
notification->timer->start();
-
- //QxtTimer::singleShot(timer_value, this, SLOT(repeatTimerHandler(NotifyPluginConfiguration*)), qVariantFromValue(notification));
}
}
notification->firstStart=false;
- phonon.mo->clear();
+ phonon.mo->clear();
QString str = notification->parseNotifyMessage();
-#ifdef DEBUG_NOTIFIES
- qDebug() << "play notification - " << str;
-#endif
- foreach(QString item, notification->getNotifyMessageList()) {
- Phonon::MediaSource *ms = new Phonon::MediaSource(item);
- ms->setAutoDelete(true);
- phonon.mo->enqueue(*ms);
- }
+ qNotifyDebug() << "play notification - " << str;
+
+ foreach(QString item, notification->getMessageSequence()) {
+ Phonon::MediaSource *ms = new Phonon::MediaSource(item);
+ ms->setAutoDelete(true);
+ phonon.mo->enqueue(*ms);
+ }
phonon.mo->play();
- phonon.firstPlay = false; // On Linux, you sometimes have to nudge Phonon to play 1 time before
- // the state is not "Loading" anymore.
+ phonon.firstPlay = false; // On Linux, you sometimes have to nudge Phonon to play 1 time before
+ // the state is not "Loading" anymore.
}
else
return false; // if audio is busy
@@ -432,20 +426,9 @@ bool SoundNotifyPlugin::playNotification(NotifyPluginConfiguration* notification
return true;
}
-//void SoundNotifyPlugin::repeatTimerHandler(NotifyPluginConfiguration* notification)
-//{
-// qDebug() << "repeatTimerHandler - " << notification->parseNotifyMessage();
-
-// ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
-// UAVObjectManager *objManager = pm->getObject();
-// UAVObject* object = objManager->getObject(notification->getDataObject());
-// if(object)
-// checkNotificationRule(notification,object);
-//}
-
void SoundNotifyPlugin::repeatTimerHandler()
{
- NotifyPluginConfiguration* notification = static_cast(sender()->parent());
+ NotificationItem* notification = static_cast(sender()->parent());
#ifdef DEBUG_NOTIFIES
qDebug() << "repeatTimerHandler - " << notification->parseNotifyMessage();
#endif
@@ -459,7 +442,7 @@ void SoundNotifyPlugin::repeatTimerHandler()
void SoundNotifyPlugin::expireTimerHandler()
{
// fire expire timer
- NotifyPluginConfiguration* notification = static_cast(sender()->parent());
+ NotificationItem* notification = static_cast(sender()->parent());
notification->expireTimer->stop();
if(!pendingNotifications.isEmpty())
@@ -494,7 +477,7 @@ void SoundNotifyPlugin::stateChanged(Phonon::State newstate, Phonon::State oldst
nowPlayingConfiguration=NULL;
if(!pendingNotifications.isEmpty())
{
- NotifyPluginConfiguration* notification = pendingNotifications.takeFirst();
+ NotificationItem* notification = pendingNotifications.takeFirst();
#ifdef DEBUG_NOTIFIES
qDebug() << "play audioFree - " << notification->parseNotifyMessage();
#endif
diff --git a/ground/openpilotgcs/src/plugins/notify/notifyplugin.h b/ground/openpilotgcs/src/plugins/notify/notifyplugin.h
index 0d0eb50d8..afd68fecc 100644
--- a/ground/openpilotgcs/src/plugins/notify/notifyplugin.h
+++ b/ground/openpilotgcs/src/plugins/notify/notifyplugin.h
@@ -32,7 +32,7 @@
#include "uavtalk/telemetrymanager.h"
#include "uavobjectmanager.h"
#include "uavobject.h"
-#include "notifypluginconfiguration.h"
+#include "notificationitem.h"
#include
#include
@@ -44,10 +44,12 @@ class NotifyPluginOptionsPage;
typedef struct {
Phonon::MediaObject* mo;
- NotifyPluginConfiguration* notify;
- bool firstPlay;
+ NotificationItem* notify;
+ bool firstPlay;
} PhononObject, *pPhononObject;
+
+
class SoundNotifyPlugin : public Core::IConfigurablePlugin
{
Q_OBJECT
@@ -62,48 +64,42 @@ public:
void shutdown();
- QList getListNotifications() { return lstNotifications; }
- //void setListNotifications(QList& list_notify) { }
- NotifyPluginConfiguration* getCurrentNotification(){ return ¤tNotification;}
+ QList getListNotifications() { return lstNotifications; }
+ NotificationItem* getCurrentNotification(){ return ¤tNotification;}
bool getEnableSound() const { return enableSound; }
void setEnableSound(bool value) {enableSound = value; }
-
-
private:
bool configured; // just for migration,delete later
bool enableSound;
QList< QList* > lstMediaSource;
QStringList mediaSource;
- //QMap mapMediaObjects;
QMultiMap mapMediaObjects;
-
QSettings* settings;
QList lstNotifiedUAVObjects;
+ QList lstNotifications;
+ QList pendingNotifications;
+ QList removedNotifies;
- QList lstNotifications;
- QList pendingNotifications;
- QList removedNotifies;
-
- NotifyPluginConfiguration currentNotification;
- NotifyPluginConfiguration* nowPlayingConfiguration;
+ NotificationItem currentNotification;
+ NotificationItem* nowPlayingConfiguration;
QString m_field;
PhononObject phonon;
NotifyPluginOptionsPage *mop;
TelemetryManager* telMngr;
- bool playNotification(NotifyPluginConfiguration* notification);
- void checkNotificationRule(NotifyPluginConfiguration* notification, UAVObject* object);
+ bool playNotification(NotificationItem* notification);
+ void checkNotificationRule(NotificationItem* notification, UAVObject* object);
void readConfig_0_0_0();
private slots:
void onTelemetryManagerAdded(QObject* obj);
void onAutopilotDisconnect();
void connectNotifications();
- void updateNotificationList(QList list);
+ void updateNotificationList(QList list);
void resetNotification(void);
void appendNotification(UAVObject *object);
void repeatTimerHandler(void);
diff --git a/ground/openpilotgcs/src/plugins/notify/notifypluginconfiguration.cpp b/ground/openpilotgcs/src/plugins/notify/notifypluginconfiguration.cpp
index 94b88421e..8d5cb25e3 100644
--- a/ground/openpilotgcs/src/plugins/notify/notifypluginconfiguration.cpp
+++ b/ground/openpilotgcs/src/plugins/notify/notifypluginconfiguration.cpp
@@ -1,7 +1,7 @@
/**
******************************************************************************
*
- * @file notifyPluginConfiguration.cpp
+ * @file NotificationItem.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Notify Plugin configuration
* @see The GNU Public License (GPL) Version 3
@@ -25,60 +25,60 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "notifypluginconfiguration.h"
+#include "NotificationItem.h"
#include
#include
#include "utils/pathutils.h"
-NotifyPluginConfiguration::NotifyPluginConfiguration(QObject *parent) :
+NotificationItem::NotificationItem(QObject *parent) :
QObject(parent),
isNowPlaying(0),
firstStart(1),
- soundCollectionPath(""),
- currentLanguage("default"),
- dataObject(""),
- objectField(""),
- value("Equal to"),
- sound1(""),
- sound2(""),
- sound3(""),
- sayOrder("Never"),
- spinBoxValue(0),
- repeatString("Repeat Instantly"),
- repeatTimeout(true),
- expireTimeout(15)
+ _soundCollectionPath(""),
+ _currentLanguage("default"),
+ _dataObject(""),
+ _objectField(""),
+ _dataValue("Equal to"),
+ _sound1(""),
+ _sound2(""),
+ _sound3(""),
+ _sayOrder("Never"),
+ _spinBoxValue(0),
+ _repeatString("Repeat Instantly"),
+ _repeatTimeout(true),
+ _expireTimeout(15)
{
timer = NULL;
expireTimer = NULL;
}
-void NotifyPluginConfiguration::copyTo(NotifyPluginConfiguration* that) const
+void NotificationItem::copyTo(NotificationItem* that) const
{
that->isNowPlaying = isNowPlaying;
that->firstStart = firstStart;
- that->soundCollectionPath = soundCollectionPath;
- that->currentLanguage = currentLanguage;
- that->soundCollectionPath = soundCollectionPath;
- that->dataObject = dataObject;
- that->objectField = objectField;
- that->value = value;
- that->sound1 = sound1;
- that->sound2 = sound2;
- that->sound3 = sound3;
- that->sayOrder = sayOrder;
- that->spinBoxValue = spinBoxValue;
- that->repeatString = repeatString;
- that->repeatTimeout = repeatTimeout;
- that->expireTimeout = expireTimeout;
+ that->_soundCollectionPath = _soundCollectionPath;
+ that->_currentLanguage = _currentLanguage;
+ that->_soundCollectionPath = _soundCollectionPath;
+ that->_dataObject = _dataObject;
+ that->_objectField = _objectField;
+ that->_dataValue = _dataValue;
+ that->_sound1 = _sound1;
+ that->_sound2 = _sound2;
+ that->_sound3 = _sound3;
+ that->_sayOrder = _sayOrder;
+ that->_spinBoxValue = _spinBoxValue;
+ that->_repeatString = _repeatString;
+ that->_repeatTimeout = _repeatTimeout;
+ that->_expireTimeout = _expireTimeout;
}
-void NotifyPluginConfiguration::saveState(QSettings* settings) const
+void NotificationItem::saveState(QSettings* settings) const
{
- settings->setValue("SoundCollectionPath", Utils::PathUtils().RemoveDataPath(getSoundCollectionPath()));
+ settings->setValue("SoundCollectionPath", Utils::PathUtils().RemoveDataPath(getSoundCollectionPath()));
settings->setValue(QLatin1String("CurrentLanguage"), getCurrentLanguage());
settings->setValue(QLatin1String("ObjectField"), getObjectField());
settings->setValue(QLatin1String("DataObject"), getDataObject());
@@ -92,7 +92,7 @@ void NotifyPluginConfiguration::saveState(QSettings* settings) const
settings->setValue(QLatin1String("ExpireTimeout"), getExpireTimeout());
}
-void NotifyPluginConfiguration::restoreState(QSettings* settings)
+void NotificationItem::restoreState(QSettings* settings)
{
//settings = Core::ICore::instance()->settings();
setSoundCollectionPath(Utils::PathUtils().InsertDataPath(settings->value(QLatin1String("SoundCollectionPath"), tr("")).toString()));
@@ -110,7 +110,7 @@ void NotifyPluginConfiguration::restoreState(QSettings* settings)
}
-QString NotifyPluginConfiguration::parseNotifyMessage()
+QString NotificationItem::parseNotifyMessage()
{
// tips:
// check of *.wav files exist needed for playing phonon queues;
@@ -121,30 +121,30 @@ QString NotifyPluginConfiguration::parseNotifyMessage()
str = QString("%L1 ").arg(getSpinBoxValue());
int position = 0xFF;
// generate queue of sound files to play
- notifyMessageList.clear();
+ _messageSequence.clear();
- if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath() + "/" + getCurrentLanguage()+"/"+getSound1()+".wav")))
- notifyMessageList.append(QDir::toNativeSeparators(getSoundCollectionPath() + "/" + getCurrentLanguage()+"/"+getSound1()+".wav"));
+ if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath() + "/" + getCurrentLanguage()+"/"+getSound1()+".wav")))
+ _messageSequence.append(QDir::toNativeSeparators(getSoundCollectionPath() + "/" + getCurrentLanguage()+"/"+getSound1()+".wav"));
else
- if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath() + "/default/"+getSound1()+".wav")))
- notifyMessageList.append(QDir::toNativeSeparators(getSoundCollectionPath() + "/default/"+getSound1()+".wav"));
+ if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath() + "/default/"+getSound1()+".wav")))
+ _messageSequence.append(QDir::toNativeSeparators(getSoundCollectionPath() + "/default/"+getSound1()+".wav"));
- if(getSound2()!="")
+ if("" != getSound2())
{
- if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath() + "/" + getCurrentLanguage()+"/"+getSound2()+".wav")))
- notifyMessageList.append(QDir::toNativeSeparators(getSoundCollectionPath() + "/" + getCurrentLanguage()+"/"+getSound2()+".wav"));
+ if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath() + "/" + getCurrentLanguage()+"/"+getSound2()+".wav")))
+ _messageSequence.append(QDir::toNativeSeparators(getSoundCollectionPath() + "/" + getCurrentLanguage()+"/"+getSound2()+".wav"));
else
- if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath() + "/default/"+getSound2()+".wav")))
- notifyMessageList.append(QDir::toNativeSeparators(getSoundCollectionPath() + "/default/"+getSound2()+".wav"));
+ if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath() + "/default/"+getSound2()+".wav")))
+ _messageSequence.append(QDir::toNativeSeparators(getSoundCollectionPath() + "/default/"+getSound2()+".wav"));
}
- if(getSound3()!="")
+ if("" != getSound3())
{
- if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath()+ "/" + getCurrentLanguage()+"/"+getSound3()+".wav")))
- notifyMessageList.append(QDir::toNativeSeparators(getSoundCollectionPath()+ "/" + getCurrentLanguage()+"/"+getSound3()+".wav"));
+ if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath()+ "/" + getCurrentLanguage()+"/"+getSound3()+".wav")))
+ _messageSequence.append(QDir::toNativeSeparators(getSoundCollectionPath()+ "/" + getCurrentLanguage()+"/"+getSound3()+".wav"));
else
- if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath()+"/default/"+getSound3()+".wav")))
- notifyMessageList.append(QDir::toNativeSeparators(getSoundCollectionPath()+"/default/"+getSound3()+".wav"));
+ if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath()+"/default/"+getSound3()+".wav")))
+ _messageSequence.append(QDir::toNativeSeparators(getSoundCollectionPath()+"/default/"+getSound3()+".wav"));
}
switch(str1.at(0).toAscii())
@@ -178,7 +178,7 @@ QString NotifyPluginConfiguration::parseNotifyMessage()
break;
}
- if(position!=0xFF)
+ if(position != 0xFF)
{
QStringList numberParts = QString("%1").arg(getSpinBoxValue()).trimmed().split(".");
QStringList numberFiles;
@@ -212,9 +212,9 @@ QString NotifyPluginConfiguration::parseNotifyMessage()
}
}
- if(numberParts.size()>1) {
+ if(1 < numberParts.size()) {
numberFiles.append("point");
- if((numberParts.at(1).size()==1) /*|| (numberParts.at(1).toInt()<20)*/)
+ if((numberParts.at(1).size()==1))
numberFiles.append(numberParts.at(1));
else {
if(numberParts.at(1).left(1)=="0")
@@ -226,20 +226,18 @@ QString NotifyPluginConfiguration::parseNotifyMessage()
}
foreach(QString fileName,numberFiles) {
fileName+=".wav";
- QString filePath = QDir::toNativeSeparators(getSoundCollectionPath()+"/"+ getCurrentLanguage()+"/"+fileName);
+ QString filePath = QDir::toNativeSeparators(getSoundCollectionPath()+"/"+ getCurrentLanguage()+"/"+fileName);
if(QFile::exists(filePath))
- notifyMessageList.insert(position++,QDir::toNativeSeparators(getSoundCollectionPath()+ "/"+getCurrentLanguage()+"/"+fileName));
+ _messageSequence.insert(position++,QDir::toNativeSeparators(getSoundCollectionPath()+ "/"+getCurrentLanguage()+"/"+fileName));
else {
- if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath()+"/default/"+fileName)))
- notifyMessageList.insert(position++,QDir::toNativeSeparators(getSoundCollectionPath()+"/default/"+fileName));
+ if(QFile::exists(QDir::toNativeSeparators(getSoundCollectionPath()+"/default/"+fileName)))
+ _messageSequence.insert(position++,QDir::toNativeSeparators(getSoundCollectionPath()+"/default/"+fileName));
else {
- notifyMessageList.clear();
+ _messageSequence.clear();
break; // if no some of *.wav files, then don't play number!
}
}
}
}
-
- //str.replace(QString(".wav | .mp3"), QString(""));
return str;
}
diff --git a/ground/openpilotgcs/src/plugins/notify/notifypluginconfiguration.h b/ground/openpilotgcs/src/plugins/notify/notifypluginconfiguration.h
deleted file mode 100644
index ad13a82a0..000000000
--- a/ground/openpilotgcs/src/plugins/notify/notifypluginconfiguration.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/**
- ******************************************************************************
- *
- * @file notifypluginconfiguration.h
- * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
- * @brief Notify Plugin configuration header
- * @see The GNU Public License (GPL) Version 3
- * @defgroup notifyplugin
- * @{
- *
- *****************************************************************************/
-/*
- * 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, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-
-#ifndef NOTIFYPLUGINCONFIGURATION_H
-#define NOTIFYPLUGINCONFIGURATION_H
-#include
-#include "qsettings.h"
-#include
-#include
-
-using namespace Core;
-
-class NotifyPluginConfiguration : public QObject
-{
- Q_OBJECT
-public:
- explicit NotifyPluginConfiguration(QObject *parent = 0);
-
- QTimer* timer;
- QTimer* expireTimer;
- bool isNowPlaying; //
- bool firstStart;
-
- void copyTo(NotifyPluginConfiguration*) const;
-
- QString getSound1() const { return sound1; }
- void setSound1(QString text) {sound1 = text; }
-
- QString getSound2() const { return sound2; }
- void setSound2(QString text) {sound2 = text; }
-
- QString getSound3() const { return sound3; }
- void setSound3(QString text) {sound3 = text; }
-
- QString getValue() const { return value; }
- void setValue(QString text) {value = text; }
-
- QString getSayOrder() const { return sayOrder; }
- void setSayOrder(QString text) {sayOrder = text; }
-
- double getSpinBoxValue() const { return spinBoxValue; }
- void setSpinBoxValue(double value) {spinBoxValue = value; }
-
-
- QString getDataObject() const { return dataObject; }
- void setDataObject(QString text) {dataObject = text; }
-
- QString getObjectField() const { return objectField; }
- void setObjectField(QString text) { objectField = text; }
-
- QString getSoundCollectionPath() const { return soundCollectionPath; }
- void setSoundCollectionPath(QString text) { soundCollectionPath = text; }
-
- QString getCurrentLanguage() const { return currentLanguage; }
- void setCurrentLanguage(QString text) { currentLanguage = text; }
-
- QStringList getNotifyMessageList() const { return notifyMessageList; }
- void setNotifyMessageList(QStringList text) { notifyMessageList = text; }
-
- QString getRepeatFlag() const { return repeatString; }
- void setRepeatFlag(QString value) { repeatString = value; }
-
- bool getRepeatTimeout() const { return repeatTimeout; }
- void setRepeatTimeout(bool value) { repeatTimeout = value; }
-
- int getExpireTimeout() const { return expireTimeout; }
- void setExpireTimeout(int value) { expireTimeout = value; }
-
-
-
- void saveState(QSettings* settings) const;
- void restoreState(QSettings* settings);
- QString parseNotifyMessage();
-
-private:
- QStringList notifyMessageList;
- QString soundCollectionPath;
- QString currentLanguage;
- QString dataObject;
- QString objectField;
-
- QString value;
- QString sound1;
- QString sound2;
- QString sound3;
- QString sayOrder;
- double spinBoxValue;
- QString repeatString;
- bool repeatTimeout;
- int repeatTimerValue;
- int expireTimeout;
-
-};
-
-Q_DECLARE_METATYPE(NotifyPluginConfiguration*)
-
-#endif // NOTIFYPLUGINCONFIGURATION_H
diff --git a/ground/openpilotgcs/src/plugins/notify/notifypluginoptionspage.cpp b/ground/openpilotgcs/src/plugins/notify/notifypluginoptionspage.cpp
index 5dee5678a..48d8f9132 100644
--- a/ground/openpilotgcs/src/plugins/notify/notifypluginoptionspage.cpp
+++ b/ground/openpilotgcs/src/plugins/notify/notifypluginoptionspage.cpp
@@ -27,7 +27,7 @@
#include "notifypluginoptionspage.h"
#include
-#include "notifypluginconfiguration.h"
+#include "notificationitem.h"
#include "ui_notifypluginoptionspage.h"
#include "extensionsystem/pluginmanager.h"
#include "utils/pathutils.h"
@@ -44,7 +44,7 @@
#include "notifyitemdelegate.h"
#include "notifytablemodel.h"
-NotifyPluginOptionsPage::NotifyPluginOptionsPage(/*NotifyPluginConfiguration *config,*/ QObject *parent) :
+NotifyPluginOptionsPage::NotifyPluginOptionsPage(/*NotificationItem *config,*/ QObject *parent) :
IOptionsPage(parent),
owner((SoundNotifyPlugin*)parent),
currentCollectionPath(""),
@@ -95,36 +95,29 @@ QWidget *NotifyPluginOptionsPage::createPage(QWidget *parent)
connect(options_page->buttonAdd, SIGNAL(pressed()), this, SLOT(on_buttonAddNotification_clicked()));
connect(options_page->buttonDelete, SIGNAL(pressed()), this, SLOT(on_buttonDeleteNotification_clicked()));
connect(options_page->buttonModify, SIGNAL(pressed()), this, SLOT(on_buttonModifyNotification_clicked()));
-// connect(options_page->buttonTestSound1, SIGNAL(clicked()), this, SLOT(on_buttonTestSound1_clicked()));
-// connect(options_page->buttonTestSound2, SIGNAL(clicked()), this, SLOT(on_buttonTestSound2_clicked()));
connect(options_page->buttonPlayNotification, SIGNAL(clicked()), this, SLOT(on_buttonTestSoundNotification_clicked()));
connect(options_page->chkEnableSound, SIGNAL(toggled(bool)), this, SLOT(on_chkEnableSound_toggled(bool)));
-
connect(options_page->UAVObject, SIGNAL(currentIndexChanged(QString)), this, SLOT(on_UAVObject_indexChanged(QString)));
- connect(this, SIGNAL(updateNotifications(QList)),
- owner, SLOT(updateNotificationList(QList)));
+ connect(this, SIGNAL(updateNotifications(QList)),
+ owner, SLOT(updateNotificationList(QList)));
connect(this, SIGNAL(resetNotification()),owner, SLOT(resetNotification()));
//emit resetNotification();
+ privListNotifications.clear();
- privListNotifications.clear();
-
- for (int i = 0; i < owner->getListNotifications().size(); ++i) {
- NotifyPluginConfiguration* notification = new NotifyPluginConfiguration();
- owner->getListNotifications().at(i)->copyTo(notification);
- privListNotifications.append(notification);
+ for (int i = 0; i < owner->getListNotifications().size(); ++i) {
+ NotificationItem* notification = new NotificationItem();
+ owner->getListNotifications().at(i)->copyTo(notification);
+ privListNotifications.append(notification);
}
- updateConfigView(owner->getCurrentNotification());
+ updateConfigView(owner->getCurrentNotification());
- options_page->chkEnableSound->setChecked(owner->getEnableSound());
+ options_page->chkEnableSound->setChecked(owner->getEnableSound());
- QStringList headerStrings;
- headerStrings << "Name" << "Repeats" << "Lifetime,sec";
-
- notifyRulesModel = new NotifyTableModel(&privListNotifications,headerStrings);
+ notifyRulesModel = new NotifyTableModel(&privListNotifications);
options_page->notifyRulesView->setModel(notifyRulesModel);
options_page->notifyRulesView->resizeRowsToContents();
notifyRulesSelection = new QItemSelectionModel(notifyRulesModel);
@@ -135,50 +128,28 @@ QWidget *NotifyPluginOptionsPage::createPage(QWidget *parent)
connect(this, SIGNAL(entryAdded(int)),
notifyRulesModel, SLOT(entryAdded(int)));
+
options_page->notifyRulesView->setSelectionModel(notifyRulesSelection);
options_page->notifyRulesView->setItemDelegate(new NotifyItemDelegate(delegateItems,this));
- options_page->notifyRulesView->setColumnWidth(0,200);
- options_page->notifyRulesView->setColumnWidth(1,150);
- options_page->notifyRulesView->setColumnWidth(2,100);
+ options_page->notifyRulesView->setColumnWidth(eMESSAGE_NAME,200);
+ options_page->notifyRulesView->setColumnWidth(eREPEAT_VALUE,120);
+ options_page->notifyRulesView->setColumnWidth(eEXPIRE_TIME,100);
+ options_page->notifyRulesView->setColumnWidth(eENABLE_NOTIFICATION,60);
options_page->buttonModify->setEnabled(false);
options_page->buttonDelete->setEnabled(false);
options_page->buttonPlayNotification->setEnabled(false);
-// sound1 = Phonon::createPlayer(Phonon::NotificationCategory);
-// sound2 = Phonon::createPlayer(Phonon::NotificationCategory);
notifySound = Phonon::createPlayer(Phonon::NotificationCategory);
-// audioOutput = new Phonon::AudioOutput(Phonon::NotificationCategory, this);
-// Phonon::createPath(sound1, audioOutput);
-// Phonon::createPath(sound2, audioOutput);
-// Phonon::createPath(notifySound, audioOutput);
-
-// connect(sound1,SIGNAL(stateChanged(Phonon::State,Phonon::State)),SLOT(changeButtonText(Phonon::State,Phonon::State)));
-// connect(sound2,SIGNAL(stateChanged(Phonon::State,Phonon::State)),SLOT(changeButtonText(Phonon::State,Phonon::State)));
connect(notifySound,SIGNAL(stateChanged(Phonon::State,Phonon::State)),
this,SLOT(changeButtonText(Phonon::State,Phonon::State)));
+ connect(notifySound, SIGNAL(finished(void)), this, SLOT(onFinishedPlaying(void)));
return optionsPageWidget;
}
-void NotifyPluginOptionsPage::showPersistentComboBox( const QModelIndex & parent, int start, int end )
-{
-// for (int i=start; itableNotifications->openPersistentEditor(options_page->tableNotifications->item(i,1));
-// }
-}
-
-void NotifyPluginOptionsPage::showPersistentComboBox2( const QModelIndex & topLeft, const QModelIndex & bottomRight )
-{
- //for (QModelIndex i=topLeft; itableNotifications->openPersistentEditor(options_page->tableNotifications->item(options_page->tableNotifications->currentRow(),1));
- }
-}
-
-
-void NotifyPluginOptionsPage::getOptionsPageValues(NotifyPluginConfiguration* notification)
+void NotifyPluginOptionsPage::getOptionsPageValues(NotificationItem* notification)
{
notification->setSoundCollectionPath(options_page->SoundDirectoryPathChooser->path());
notification->setCurrentLanguage(options_page->SoundCollectionList->currentText());
@@ -191,26 +162,16 @@ void NotifyPluginOptionsPage::getOptionsPageValues(NotifyPluginConfiguration* no
notification->setValue(options_page->Value->currentText());
notification->setSpinBoxValue(options_page->ValueSpinBox->value());
-// if(notifyRulesSelection->currentIndex().row()>-1)
-// {
-// //qDebug() << "delegate value:" << options_page->tableNotifications->item(options_page->tableNotifications->currentRow(),1)->data(Qt::EditRole);
-// notification->setRepeatFlag(notifyRulesModel->data(notifyRulesSelection->currentIndex(),Qt::DisplayRole).toString());
-// }
}
-////////////////////////////////////////////
-// Called when the user presses apply or OK.
-//
-// Saves the current values
-//
-////////////////////////////////////////////
+/*!
+* Called when the user presses apply or OK.
+* Saves the current values
+*/
void NotifyPluginOptionsPage::apply()
{
-
- getOptionsPageValues(owner->getCurrentNotification());
-
+ getOptionsPageValues(owner->getCurrentNotification());
owner->setEnableSound(options_page->chkEnableSound->isChecked());
- //owner->setListNotifications(privListNotifications);
emit updateNotifications(privListNotifications);
}
@@ -218,25 +179,22 @@ void NotifyPluginOptionsPage::finish()
{
disconnect(notifySound,SIGNAL(stateChanged(Phonon::State,Phonon::State)),
this,SLOT(changeButtonText(Phonon::State,Phonon::State)));
- if(notifySound)
- {
+ if (notifySound) {
notifySound->stop();
notifySound->clear();
}
-
- delete options_page;
+ if (options_page)
+ delete options_page;
}
-
-
//////////////////////////////////////////////////////////////////////////////
// Fills in the combo box when value is changed in the
//