2011-09-14 23:38:18 +02:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
*
|
|
|
|
* @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 <coreplugin/iuavgadgetconfiguration.h>
|
|
|
|
#include "qsettings.h"
|
|
|
|
#include <qstringlist.h>
|
|
|
|
#include <QTimer>
|
|
|
|
|
|
|
|
using namespace Core;
|
|
|
|
|
|
|
|
#define DECLARE_SOUND(number) \
|
|
|
|
QString getSound##number() const { return _sound##number; } \
|
|
|
|
void setSound##number(QString text) { _sound##number = text; } \
|
|
|
|
|
|
|
|
|
|
|
|
class NotificationItem : public QObject
|
|
|
|
{
|
2011-09-16 17:39:20 +02:00
|
|
|
Q_OBJECT
|
2011-09-14 23:38:18 +02:00
|
|
|
public:
|
2011-09-16 17:39:20 +02:00
|
|
|
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; }
|
2011-09-14 23:38:18 +02:00
|
|
|
|
2011-09-16 17:39:20 +02:00
|
|
|
double getSpinBoxValue() const { return _spinBoxValue; }
|
|
|
|
void setSpinBoxValue(double value) { _spinBoxValue = value; }
|
2011-09-14 23:38:18 +02:00
|
|
|
|
|
|
|
|
2011-09-16 17:39:20 +02:00
|
|
|
QString getDataObject() const { return _dataObject; }
|
|
|
|
void setDataObject(QString text) { _dataObject = text; }
|
2011-09-14 23:38:18 +02:00
|
|
|
|
2011-09-16 17:39:20 +02:00
|
|
|
QString getObjectField() const { return _objectField; }
|
|
|
|
void setObjectField(QString text) { _objectField = text; }
|
2011-09-14 23:38:18 +02:00
|
|
|
|
2011-09-16 17:39:20 +02:00
|
|
|
QString getSoundCollectionPath() const { return _soundCollectionPath; }
|
|
|
|
void setSoundCollectionPath(QString path) { _soundCollectionPath = path; }
|
2011-09-14 23:38:18 +02:00
|
|
|
|
2011-09-16 17:39:20 +02:00
|
|
|
QString getCurrentLanguage() const { return _currentLanguage; }
|
|
|
|
void setCurrentLanguage(QString text) { _currentLanguage = text; }
|
2011-09-14 23:38:18 +02:00
|
|
|
|
2011-09-16 17:39:20 +02:00
|
|
|
QStringList getMessageSequence() const { return _messageSequence; }
|
|
|
|
void setMessageSequence(QStringList sequence) { _messageSequence = sequence; }
|
2011-09-14 23:38:18 +02:00
|
|
|
|
2011-09-18 23:30:57 +02:00
|
|
|
QString retryString() const { return _repeatString; }
|
|
|
|
void setRetryString(QString value) { _repeatString = value; }
|
2011-09-14 23:38:18 +02:00
|
|
|
|
2011-09-18 23:30:57 +02:00
|
|
|
int lifetime() const { return _expireTimeout; }
|
|
|
|
void setLifetime(int value) { _expireTimeout = value; }
|
2011-09-14 23:38:18 +02:00
|
|
|
|
2011-09-18 23:30:57 +02:00
|
|
|
bool mute() const { return _mute; }
|
|
|
|
void setMute(bool value) { _mute = value; }
|
2011-09-14 23:38:18 +02:00
|
|
|
|
2011-09-16 17:39:20 +02:00
|
|
|
void saveState(QSettings* settings) const;
|
|
|
|
void restoreState(QSettings* settings);
|
2011-09-14 23:38:18 +02:00
|
|
|
|
2011-09-18 23:30:57 +02:00
|
|
|
|
|
|
|
void seriaize(QDataStream& stream);
|
|
|
|
void deseriaize(QDataStream& stream);
|
|
|
|
|
2011-09-16 17:39:20 +02:00
|
|
|
QString parseNotifyMessage();
|
2011-09-14 23:38:18 +02:00
|
|
|
|
2011-09-16 17:39:20 +02:00
|
|
|
QTimer* getTimer() const { return _timer; }
|
|
|
|
void startTimer(int value);
|
|
|
|
void stopTimer();
|
|
|
|
void disposeTimer();
|
2011-09-14 23:38:18 +02:00
|
|
|
|
2011-09-16 17:39:20 +02:00
|
|
|
QTimer* getExpireTimer() const { return _expireTimer; }
|
|
|
|
void startExpireTimer();
|
|
|
|
void stopExpireTimer();
|
2011-09-14 23:38:18 +02:00
|
|
|
|
2011-09-16 17:39:20 +02:00
|
|
|
void disposeExpireTimer();
|
2011-09-14 23:38:18 +02:00
|
|
|
|
2011-09-16 17:39:20 +02:00
|
|
|
bool isNowPlaying;
|
|
|
|
bool firstStart;
|
2011-09-14 23:38:18 +02:00
|
|
|
|
|
|
|
private:
|
2011-09-16 17:39:20 +02:00
|
|
|
void checkSoundFilesExisting();
|
|
|
|
|
|
|
|
private:
|
|
|
|
QTimer* _timer;
|
|
|
|
|
|
|
|
//! time from putting notification in queue till moment when notification became out-of-date
|
|
|
|
//! NOTE: each notification has it lifetime, this time setups individually for each notification
|
|
|
|
//! according to its priority
|
|
|
|
QTimer* _expireTimer;
|
|
|
|
|
|
|
|
QStringList _messageSequence;
|
2011-09-14 23:38:18 +02:00
|
|
|
|
2011-09-16 17:39:20 +02:00
|
|
|
//! path to folder with sound files
|
|
|
|
QString _soundCollectionPath;
|
2011-09-14 23:38:18 +02:00
|
|
|
|
2011-09-16 17:39:20 +02:00
|
|
|
//! language in what notifications will be spelled
|
|
|
|
QString _currentLanguage;
|
2011-09-14 23:38:18 +02:00
|
|
|
|
2011-09-16 17:39:20 +02:00
|
|
|
//! one UAV object per one notification
|
|
|
|
QString _dataObject;
|
2011-09-14 23:38:18 +02:00
|
|
|
|
2011-09-16 17:39:20 +02:00
|
|
|
//! one field value change can be assigned to one notification
|
|
|
|
QString _objectField;
|
2011-09-14 23:38:18 +02:00
|
|
|
|
2011-09-16 17:39:20 +02:00
|
|
|
//! poled UAV field value
|
|
|
|
QString _dataValue;
|
2011-09-14 23:38:18 +02:00
|
|
|
|
2011-09-16 17:39:20 +02:00
|
|
|
//! possible sounds(at least one required to play notification)
|
|
|
|
QString _sound1;
|
|
|
|
QString _sound2;
|
|
|
|
QString _sound3;
|
2011-09-14 23:38:18 +02:00
|
|
|
|
2011-09-16 17:39:20 +02:00
|
|
|
//! order in what sounds 1-3 will be played
|
|
|
|
QString _sayOrder;
|
2011-09-14 23:38:18 +02:00
|
|
|
|
2011-09-16 17:39:20 +02:00
|
|
|
double _spinBoxValue;
|
2011-09-14 23:38:18 +02:00
|
|
|
|
2011-09-16 17:39:20 +02:00
|
|
|
//! how often or what periodicaly notification should be played
|
2011-09-18 23:30:57 +02:00
|
|
|
QString _repeatString;
|
2011-09-14 23:38:18 +02:00
|
|
|
|
2011-09-16 17:39:20 +02:00
|
|
|
//! time after event occured till notification became invalid
|
|
|
|
//! and will be removed from list
|
|
|
|
int _expireTimeout;
|
2011-09-14 23:38:18 +02:00
|
|
|
|
2011-09-16 17:39:20 +02:00
|
|
|
//! enables/disables playing of current notification
|
2011-09-18 23:30:57 +02:00
|
|
|
bool _mute;
|
2011-09-14 23:38:18 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(NotificationItem*)
|
|
|
|
|
|
|
|
#endif // NotificationItem_H
|