dRonin  adbada4
dRonin GCS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
notificationitem.h
Go to the documentation of this file.
1 
15 /*
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation; either version 3 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful, but
22  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
23  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24  * for more details.
25  *
26  * You should have received a copy of the GNU General Public License along
27  * with this program; if not, see <http://www.gnu.org/licenses/>
28  */
29 
30 #ifndef NOTIFICATION_ITEM_H
31 #define NOTIFICATION_ITEM_H
32 
34 #include "qsettings.h"
35 #include <qstringlist.h>
36 #include <QTimer>
37 
38 using namespace Core;
39 
40 #define DECLARE_SOUND(number) \
41  QString getSound##number() const { return _sound##number; } \
42  void setSound##number(QString text) { _sound##number = text; }
43 
44 class UAVDataObject;
45 class UAVObjectField;
46 
47 class NotificationItem : public QObject
48 {
49  Q_OBJECT
50 public:
51  enum { eDefaultTimeout = 15 }; // in sec
52 
53  enum { never, beforeFirst, beforeSecond, afterSecond };
54  enum {
60  repeat1minute
61  };
62 
63  explicit NotificationItem(QObject *parent = nullptr);
64 
65  void copyTo(NotificationItem *) const;
66 
68  DECLARE_SOUND(2)
69  DECLARE_SOUND(3)
70 
71  bool getCurrentUpdatePlayed() const { return _currentUpdatePlayed; }
72  void setCurrentUpdatePlayed(bool value) { _currentUpdatePlayed = value; }
73 
74  int getCondition() const { return _condition; }
75  void setCondition(int value) { _condition = value; }
76 
77  int getSayOrder() const { return _sayOrder; }
78  void setSayOrder(int text) { _sayOrder = text; }
79 
80  QVariant singleValue() const { return _singleValue; }
81  void setSingleValue(QVariant value) { _singleValue = value; }
82 
83  double valueRange2() const { return _valueRange2; }
84  void setValueRange2(double value) { _valueRange2 = value; }
85 
86  QString getDataObject() const { return _dataObject; }
87  void setDataObject(QString text) { _dataObject = text; }
88 
89  QString getObjectField() const { return _objectField; }
90  void setObjectField(QString text) { _objectField = text; }
91 
92  QString getSoundCollectionPath() const { return _soundCollectionPath; }
93  void setSoundCollectionPath(QString path) { _soundCollectionPath = path; }
94 
95  QString getCurrentLanguage() const { return _currentLanguage; }
96  void setCurrentLanguage(QString text) { _currentLanguage = text; }
97 
98  QStringList getMessageSequence() const { return _messageSequence; }
99  void setMessageSequence(QStringList sequence) { _messageSequence = sequence; }
100 
101  int retryValue() const { return _repeatValue; }
102  void setRetryValue(int value) { _repeatValue = value; }
103 
104  int lifetime() const { return _expireTimeout; }
105  void setLifetime(int value) { _expireTimeout = value; }
106 
107  bool mute() const { return _mute; }
108  void setMute(bool value) { _mute = value; }
109 
110  void saveState(QSettings *settings) const;
111  void restoreState(QSettings *settings);
112 
113  UAVDataObject *getUAVObject(void);
114  UAVObjectField *getUAVObjectField(void);
115 
116  void serialize(QDataStream &stream);
117  void deserialize(QDataStream &stream);
118 
125  QString toString();
126 
134  QStringList &toSoundList();
135 
142  QString getSoundCaption(QString fileName);
143 
144  QTimer *getTimer() const { return _timer; }
145  void startTimer(int value);
146  void restartTimer();
147  void stopTimer();
148  void disposeTimer();
149 
150  QTimer *getExpireTimer() const { return _expireTimer; }
151  void startExpireTimer();
152  void stopExpireTimer();
153 
154  void disposeExpireTimer();
155 
157  bool _isPlayed;
158 
159  static QStringList sayOrderValues;
160  static QStringList retryValues;
161 
162 private:
163  QString checkSoundExists(QString fileName);
164 
165 private:
166  bool _currentUpdatePlayed;
167 
168  QTimer *_timer;
169 
173  QTimer *_expireTimer;
174 
176  QStringList _messageSequence;
177 
179  QString _soundCollectionPath;
180 
182  QString _currentLanguage;
183 
185  QString _dataObject;
186 
188  QString _objectField;
189 
191  int _condition;
192 
194  QString _sound1;
195  QString _sound2;
196  QString _sound3;
197 
199  int _sayOrder;
200 
202  QVariant _singleValue;
203 
205  // double _valueRange1;
206  double _valueRange2;
207 
209  int _repeatValue;
210 
213  int _expireTimeout;
214 
216  bool _mute;
217 };
218 
220 
221 #endif // NotificationItem_H
QVariant singleValue() const
void setObjectField(QString text)
QString getObjectField() const
void setMute(bool value)
void setMessageSequence(QStringList sequence)
QString getCurrentLanguage() const
int getSayOrder() const
DECLARE_SOUND(1) DECLARE_SOUND(2) DECLARE_SOUND(3) bool getCurrentUpdatePlayed() const
int getCondition() const
void setSayOrder(int text)
void setCurrentUpdatePlayed(bool value)
bool mute() const
QTimer * getExpireTimer() const
void setDataObject(QString text)
static QStringList sayOrderValues
int lifetime() const
void setSoundCollectionPath(QString path)
static QStringList retryValues
QString getSoundCollectionPath() const
double valueRange2() const
QTimer * getTimer() const
QString getDataObject() const
Q_DECLARE_METATYPE(Core::Internal::MenuActionContainer *) using namespace Core
int retryValue() const
void setCurrentLanguage(QString text)
void setSingleValue(QVariant value)
void setCondition(int value)
QStringList getMessageSequence() const
void setLifetime(int value)
void setRetryValue(int value)
void setValueRange2(double value)