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 // combo box ////////////////////////////////////////////////////////////////////////////// void NotifyPluginOptionsPage::on_UAVObject_indexChanged(QString val) { options_page->UAVObjectField->clear(); - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - UAVObjectManager *objManager = pm->getObject(); + ExtensionSystem::PluginManager* pm = ExtensionSystem::PluginManager::instance(); + UAVObjectManager* objManager = pm->getObject(); UAVDataObject* obj = dynamic_cast( objManager->getObject(val) ); QList fieldList = obj->getFields(); foreach (UAVObjectField* field, fieldList) { @@ -258,8 +216,8 @@ void NotifyPluginOptionsPage::on_soundLanguage_indexChanged(int index) { options_page->SoundCollectionList->setCurrentIndex(index); - currentCollectionPath = options_page->SoundDirectoryPathChooser->path() + - QDir::toNativeSeparators("/" + options_page->SoundCollectionList->currentText()); + currentCollectionPath = options_page->SoundDirectoryPathChooser->path() + + QDir::toNativeSeparators("/" + options_page->SoundCollectionList->currentText()); QDir dirPath(currentCollectionPath); QStringList filters; @@ -280,30 +238,38 @@ void NotifyPluginOptionsPage::on_soundLanguage_indexChanged(int index) void NotifyPluginOptionsPage::changeButtonText(Phonon::State newstate, Phonon::State oldstate) { - if(newstate == Phonon::PausedState || newstate == Phonon::StoppedState){ + Q_ASSERT(Phonon::ErrorState != newstate); + + if (newstate == Phonon::PausedState || newstate == Phonon::StoppedState) { options_page->buttonPlayNotification->setText("Play"); options_page->buttonPlayNotification->setIcon(QPixmap(":/notify/images/play.png")); - } - else - if(newstate == Phonon::PlayingState) { - options_page->buttonPlayNotification->setText("Stop"); - options_page->buttonPlayNotification->setIcon(QPixmap(":/notify/images/stop.png")); + } else { + if (newstate == Phonon::PlayingState) { + options_page->buttonPlayNotification->setText("Stop"); + options_page->buttonPlayNotification->setIcon(QPixmap(":/notify/images/stop.png")); + } } } +void NotifyPluginOptionsPage::onFinishedPlaying() +{ + notifySound->clear(); +} void NotifyPluginOptionsPage::on_buttonTestSoundNotification_clicked() { - // QList messageNotify; - NotifyPluginConfiguration *notification; + NotificationItem* notification = NULL; - if(notifyRulesSelection->currentIndex().row()==-1) return; - - notifySound->clearQueue(); + if (-1 == notifyRulesSelection->currentIndex().row()) + return; + notifySound->clearQueue(); notification = privListNotifications.at(notifyRulesSelection->currentIndex().row()); notification->parseNotifyMessage(); - foreach(QString item, notification->getNotifyMessageList()) - notifySound->enqueue(Phonon::MediaSource(item)); + QStringList sequence = notification->getMessageSequence(); + Q_ASSERT(!!sequence.size()); + foreach(QString item, sequence) + notifySound->enqueue(Phonon::MediaSource(item)); + notifySound->play(); } @@ -316,25 +282,24 @@ void NotifyPluginOptionsPage::on_chkEnableSound_toggled(bool state) audioOutput->setMuted(state1); } -void NotifyPluginOptionsPage::updateConfigView(NotifyPluginConfiguration* notification) +void NotifyPluginOptionsPage::updateConfigView(NotificationItem* notification) { QString path = notification->getSoundCollectionPath(); - if(path=="") - { + if (path == "") { //QDir dir = QDir::currentPath(); //path = QDir::currentPath().left(QDir::currentPath().indexOf("OpenPilot",0,Qt::CaseSensitive))+"../share/sounds"; - path = Utils::PathUtils().InsertDataPath("%%DATAPATH%%sounds"); + path = Utils::PathUtils().InsertDataPath("%%DATAPATH%%sounds"); } + options_page->SoundDirectoryPathChooser->setPath(path); - if(options_page->SoundCollectionList->findText(notification->getCurrentLanguage())!=-1){ + if (-1 != options_page->SoundCollectionList->findText(notification->getCurrentLanguage())){ options_page->SoundCollectionList->setCurrentIndex(options_page->SoundCollectionList->findText(notification->getCurrentLanguage())); - } - else + } else { options_page->SoundCollectionList->setCurrentIndex(options_page->SoundCollectionList->findText("default")); + } - - if(options_page->UAVObject->findText(notification->getDataObject())!=-1){ + if (options_page->UAVObject->findText(notification->getDataObject())!=-1){ options_page->UAVObject->setCurrentIndex(options_page->UAVObject->findText(notification->getDataObject())); } @@ -349,15 +314,13 @@ void NotifyPluginOptionsPage::updateConfigView(NotifyPluginConfiguration* notifi } } - if(options_page->UAVObjectField->findText(notification->getObjectField())!=-1){ + if (-1 != options_page->UAVObjectField->findText(notification->getObjectField())) { options_page->UAVObjectField->setCurrentIndex(options_page->UAVObjectField->findText(notification->getObjectField())); } - if(options_page->Sound1->findText(notification->getSound1())!=-1){ + if (-1 != options_page->Sound1->findText(notification->getSound1())) { options_page->Sound1->setCurrentIndex(options_page->Sound1->findText(notification->getSound1())); - } - else - { + } else { // show item from default location options_page->SoundCollectionList->setCurrentIndex(options_page->SoundCollectionList->findText("default")); options_page->Sound1->setCurrentIndex(options_page->Sound1->findText(notification->getSound1())); @@ -366,10 +329,9 @@ void NotifyPluginOptionsPage::updateConfigView(NotifyPluginConfiguration* notifi //options_page->Sound1->setCurrentIndex(-1); } - if(options_page->Sound2->findText(notification->getSound2())!=-1) { + if (-1 != options_page->Sound2->findText(notification->getSound2())) { options_page->Sound2->setCurrentIndex(options_page->Sound2->findText(notification->getSound2())); - } - else { + } else { // show item from default location options_page->SoundCollectionList->setCurrentIndex(options_page->SoundCollectionList->findText("default")); options_page->Sound2->setCurrentIndex(options_page->Sound2->findText(notification->getSound2())); @@ -378,33 +340,33 @@ void NotifyPluginOptionsPage::updateConfigView(NotifyPluginConfiguration* notifi //options_page->Sound2->setCurrentIndex(-1); } - if(options_page->Sound3->findText(notification->getSound3())!=-1) { + if (-1 != options_page->Sound3->findText(notification->getSound3())) { options_page->Sound3->setCurrentIndex(options_page->Sound3->findText(notification->getSound3())); - } - else { + } else { // show item from default location options_page->SoundCollectionList->setCurrentIndex(options_page->SoundCollectionList->findText("default")); options_page->Sound3->setCurrentIndex(options_page->Sound3->findText(notification->getSound3())); } - if(options_page->Value->findText(notification->getValue())!=-1) { + if (-1 != options_page->Value->findText(notification->getValue())) { options_page->Value->setCurrentIndex(options_page->Value->findText(notification->getValue())); } - if(options_page->SayOrder->findText(notification->getSayOrder())!=-1) { + if (-1 != options_page->SayOrder->findText(notification->getSayOrder())) { options_page->SayOrder->setCurrentIndex(options_page->SayOrder->findText(notification->getSayOrder())); } + options_page->ValueSpinBox->setValue(notification->getSpinBoxValue()); } void NotifyPluginOptionsPage::on_tableNotification_changeSelection( const QItemSelection & selected, const QItemSelection & deselected ) { - bool select = true; + bool select = false; notifySound->stop(); - if(selected.indexes().size()) + if (selected.indexes().size()) { + select = true; updateConfigView(privListNotifications.at(selected.indexes().at(0).row())); - else - select = false; + } options_page->buttonModify->setEnabled(select); options_page->buttonDelete->setEnabled(select); @@ -412,13 +374,11 @@ void NotifyPluginOptionsPage::on_tableNotification_changeSelection( const QItemS } - void NotifyPluginOptionsPage::on_buttonAddNotification_clicked() { - NotifyPluginConfiguration* notification = new NotifyPluginConfiguration; + NotificationItem* notification = new NotificationItem; - if(options_page->SoundDirectoryPathChooser->path()=="") - { + if (options_page->SoundDirectoryPathChooser->path()=="") { QPalette textPalette=options_page->SoundDirectoryPathChooser->palette(); textPalette.setColor(QPalette::Normal,QPalette::Text, Qt::red); options_page->SoundDirectoryPathChooser->setPalette(textPalette); @@ -433,20 +393,20 @@ void NotifyPluginOptionsPage::on_buttonAddNotification_clicked() notification->setValue(options_page->Value->currentText()); notification->setSpinBoxValue(options_page->ValueSpinBox->value()); - if(options_page->Sound1->currentText()!="") + if (options_page->Sound1->currentText().size() > 0) notification->setSound1(options_page->Sound1->currentText()); notification->setSound2(options_page->Sound2->currentText()); notification->setSound3(options_page->Sound3->currentText()); - if(((options_page->Sound2->currentText()=="")&&(options_page->SayOrder->currentText()=="After second")) - || ((options_page->Sound3->currentText()=="")&&(options_page->SayOrder->currentText()=="After third"))) + if ( ((!options_page->Sound2->currentText().size()) && (options_page->SayOrder->currentText()=="After second")) + || ((!options_page->Sound3->currentText().size()) && (options_page->SayOrder->currentText()=="After third")) ) { return; - else + } else { notification->setSayOrder(options_page->SayOrder->currentText()); - + } privListNotifications.append(notification); - emit entryAdded(privListNotifications.size()-1); + emit entryAdded(privListNotifications.size() - 1); notifyRulesSelection->setCurrentIndex(notifyRulesModel->index(privListNotifications.size()-1,0,QModelIndex()), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows); } @@ -455,7 +415,9 @@ void NotifyPluginOptionsPage::on_buttonAddNotification_clicked() void NotifyPluginOptionsPage::on_buttonDeleteNotification_clicked() { notifyRulesModel->removeRow(notifyRulesSelection->currentIndex().row()); - if(!notifyRulesModel->rowCount() && (notifyRulesSelection->currentIndex().row() > 0 && notifyRulesSelection->currentIndex().row() < notifyRulesModel->rowCount())) + if (!notifyRulesModel->rowCount() + && (notifyRulesSelection->currentIndex().row() > 0 + && notifyRulesSelection->currentIndex().row() < notifyRulesModel->rowCount()) ) { options_page->buttonDelete->setEnabled(false); options_page->buttonModify->setEnabled(false); @@ -466,7 +428,7 @@ void NotifyPluginOptionsPage::on_buttonDeleteNotification_clicked() void NotifyPluginOptionsPage::on_buttonModifyNotification_clicked() { - NotifyPluginConfiguration* notification = new NotifyPluginConfiguration; + NotificationItem* notification = new NotificationItem; getOptionsPageValues(notification); notification->setRepeatFlag(privListNotifications.at(notifyRulesSelection->currentIndex().row())->getRepeatFlag()); privListNotifications.replace(notifyRulesSelection->currentIndex().row(),notification); diff --git a/ground/openpilotgcs/src/plugins/notify/notifypluginoptionspage.h b/ground/openpilotgcs/src/plugins/notify/notifypluginoptionspage.h index 9d159e2a4..31da8373f 100644 --- a/ground/openpilotgcs/src/plugins/notify/notifypluginoptionspage.h +++ b/ground/openpilotgcs/src/plugins/notify/notifypluginoptionspage.h @@ -45,7 +45,7 @@ class NotifyTableModel; -class NotifyPluginConfiguration; +class NotificationItem; class SoundNotifyPlugin; namespace Ui { @@ -59,7 +59,7 @@ class NotifyPluginOptionsPage : public IOptionsPage { Q_OBJECT public: - explicit NotifyPluginOptionsPage(/*NotifyPluginConfiguration *config, */QObject *parent = 0); + explicit NotifyPluginOptionsPage(/*NotificationItem *config, */QObject *parent = 0); QString id() const { return QLatin1String("settings"); } QString trName() const { return tr("settings"); } @@ -73,8 +73,8 @@ public: void finish(); void restoreFromSettings(); - void updateConfigView(NotifyPluginConfiguration* notification); - void getOptionsPageValues(NotifyPluginConfiguration* notification); + void updateConfigView(NotificationItem* notification); + void getOptionsPageValues(NotificationItem* notification); private: UAVObjectManager *objManager; @@ -90,24 +90,18 @@ private: QStringList delegateItems; NotifyTableModel* notifyRulesModel; QItemSelectionModel *notifyRulesSelection; - QList privListNotifications; + QList privListNotifications; Ui::NotifyPluginOptionsPage *options_page; - //NotifyPluginConfiguration *notify; signals: - void updateNotifications(QList list); + void updateNotifications(QList list); void resetNotification(void); void entryUpdated(int index); void entryAdded(int position); private slots: - void showPersistentComboBox( const QModelIndex & parent, int start, int end ); - void showPersistentComboBox2 ( const QModelIndex & topLeft, const QModelIndex & bottomRight ); - -// void on_buttonTestSound1_clicked(); -// void on_buttonTestSound2_clicked(); void on_buttonTestSoundNotification_clicked(); void on_buttonAddNotification_clicked(); @@ -119,6 +113,9 @@ private slots: void on_UAVObject_indexChanged(QString val); void changeButtonText(Phonon::State newstate, Phonon::State oldstate); void on_chkEnableSound_toggled(bool state); + + void onFinishedPlaying(void); + }; #endif // NOTIFYPLUGINOPTIONSPAGE_H diff --git a/ground/openpilotgcs/src/plugins/notify/notifypluginoptionspage.ui b/ground/openpilotgcs/src/plugins/notify/notifypluginoptionspage.ui index b3f48432a..4645bd14a 100644 --- a/ground/openpilotgcs/src/plugins/notify/notifypluginoptionspage.ui +++ b/ground/openpilotgcs/src/plugins/notify/notifypluginoptionspage.ui @@ -24,7 +24,7 @@ 10 10 - 501 + 551 81 @@ -36,7 +36,7 @@ 10 20 - 481 + 531 51 @@ -89,7 +89,7 @@ p, li { white-space: pre-wrap; } 10 220 - 501 + 551 211 @@ -101,7 +101,7 @@ p, li { white-space: pre-wrap; } 10 180 - 481 + 531 26 @@ -203,7 +203,7 @@ p, li { white-space: pre-wrap; } 10 20 - 481 + 531 151 @@ -226,7 +226,7 @@ p, li { white-space: pre-wrap; } 10 100 - 501 + 551 31 @@ -272,7 +272,7 @@ p, li { white-space: pre-wrap; } 7 130 - 501 + 551 20 @@ -285,7 +285,7 @@ p, li { white-space: pre-wrap; } 10 180 - 501 + 551 31 @@ -390,7 +390,7 @@ p, li { white-space: pre-wrap; } 10 150 - 501 + 551 31 diff --git a/ground/openpilotgcs/src/plugins/notify/notifytablemodel.cpp b/ground/openpilotgcs/src/plugins/notify/notifytablemodel.cpp index 6f0584d70..6e503cbd8 100644 --- a/ground/openpilotgcs/src/plugins/notify/notifytablemodel.cpp +++ b/ground/openpilotgcs/src/plugins/notify/notifytablemodel.cpp @@ -26,17 +26,30 @@ */ #include "notifytablemodel.h" +#include + +NotifyTableModel::NotifyTableModel(QList* parentList, QObject* parent) + : QAbstractTableModel(parent) +{ + _headerStrings << "Name" << "Repeats" << "Lifetime,sec" << "Enable"; + _list.reset(parentList); +} + bool NotifyTableModel::setData(const QModelIndex &index, const QVariant &value, int role) { if (index.isValid() && role == Qt::EditRole) { - if(index.column()==1) + if(eREPEAT_VALUE == index.column()) _list->at(index.row())->setRepeatFlag(value.toString()); - else - if(index.column()==2) + else { + if(eEXPIRE_TIME == index.column()) _list->at(index.row())->setExpireTimeout(value.toInt()); - + else { + if(eENABLE_NOTIFICATION == index.column()) + _list->at(index.row())->setEnableFlag(value.toBool()); + } + } emit dataChanged(index, index); return true; } @@ -45,9 +58,10 @@ bool NotifyTableModel::setData(const QModelIndex &index, QVariant NotifyTableModel::data(const QModelIndex &index, int role) const { - - if (!index.isValid()) + if (!index.isValid()) { + qWarning() << "NotifyTableModel::data - index.isValid()"; return QVariant(); + } if (index.row() >= _list->size()) return QVariant(); @@ -56,15 +70,18 @@ QVariant NotifyTableModel::data(const QModelIndex &index, int role) const { switch(index.column()) { - case 0: + case eMESSAGE_NAME: return _list->at(index.row())->parseNotifyMessage(); - case 1: + case eREPEAT_VALUE: return _list->at(index.row())->getRepeatFlag(); - case 2: + case eEXPIRE_TIME: return _list->at(index.row())->getExpireTimeout(); + case eENABLE_NOTIFICATION: + return _list->at(index.row())->getEnableFlag(); + default: return QVariant(); } @@ -72,12 +89,8 @@ QVariant NotifyTableModel::data(const QModelIndex &index, int role) const else { if (Qt::SizeHintRole == role){ - //QVariant size = data(index, Qt::SizeHintRole); return QVariant(10); } - // if(role == Qt::DecorationRole) - // if (index.column() == 0) - // return defectsIcons[defectList->at(index.row()).id-1]; } return QVariant(); } @@ -88,7 +101,7 @@ QVariant NotifyTableModel::headerData(int section, Qt::Orientation orientation, return QVariant(); if (orientation == Qt::Horizontal) - return headerStrings.at(section); + return _headerStrings.at(section); else if(orientation == Qt::Vertical) return QString("%1").arg(section); @@ -100,12 +113,6 @@ bool NotifyTableModel::insertRows(int position, int rows, const QModelIndex &ind { Q_UNUSED(index); beginInsertRows(QModelIndex(), position, position+rows-1); - -// for (int row=0; row < rows; ++row) { -// _list->append(position); -// } - - endInsertRows(); return true; } diff --git a/ground/openpilotgcs/src/plugins/notify/notifytablemodel.h b/ground/openpilotgcs/src/plugins/notify/notifytablemodel.h index 65aa82a86..978605fbe 100644 --- a/ground/openpilotgcs/src/plugins/notify/notifytablemodel.h +++ b/ground/openpilotgcs/src/plugins/notify/notifytablemodel.h @@ -31,26 +31,28 @@ #include #include -#include "notifypluginconfiguration.h" +#include "notificationitem.h" + +enum ColumnNames { eMESSAGE_NAME, eREPEAT_VALUE, eEXPIRE_TIME, eENABLE_NOTIFICATION }; class NotifyTableModel : public QAbstractTableModel { Q_OBJECT - public: - NotifyTableModel(QList *parentList, const QStringList& parentHeaderList, QObject *parent = 0) - : QAbstractTableModel(parent), - _list(parentList), - headerStrings(parentHeaderList) - { } - int rowCount(const QModelIndex &parent = QModelIndex()) const + enum {eColumnCount = 4 }; + +public: + + NotifyTableModel(QList* parentList, QObject* parent = 0); + + int rowCount(const QModelIndex& parent = QModelIndex()) const { return _list->count(); } int columnCount(const QModelIndex &/*parent*/) const { - return 3; + return eColumnCount; } Qt::ItemFlags flags(const QModelIndex &index) const @@ -71,8 +73,8 @@ private slots: void entryUpdated(int offset); void entryAdded(int position); private: - QList *_list; - QStringList headerStrings; + QScopedPointer > _list; + QStringList _headerStrings; }; diff --git a/openpilotgcs.bat b/openpilotgcs.bat new file mode 100644 index 000000000..a656aa85b --- /dev/null +++ b/openpilotgcs.bat @@ -0,0 +1,3 @@ +cd D:\Qt\4.7.3\bin\ + +call D:\!Work\OpenSource\OpenPilot\OpenPilot\build\ground\openpilotgcs\bin\openpilotgcs.exe \ No newline at end of file