mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-02 10:24:11 +01:00
Changed conditions base on strings to enums.
This commit is contained in:
parent
78e25b1b8c
commit
b45044b8c3
@ -49,7 +49,10 @@ class NotificationItem : public QObject
|
|||||||
public:
|
public:
|
||||||
enum { eDefaultTimeout = 15 }; // in sec
|
enum { eDefaultTimeout = 15 }; // in sec
|
||||||
|
|
||||||
enum {equal,bigger,smaller,inrange};
|
enum {never,beforeFirst,beforeSecond,afterSecond};
|
||||||
|
enum {repeatOncePerUpdate,repeatOnce,repeatInstantly,repeat10seconds,
|
||||||
|
repeat30seconds,repeat1minute};
|
||||||
|
|
||||||
explicit NotificationItem(QObject *parent = 0);
|
explicit NotificationItem(QObject *parent = 0);
|
||||||
|
|
||||||
void copyTo(NotificationItem*) const;
|
void copyTo(NotificationItem*) const;
|
||||||
@ -64,8 +67,8 @@ public:
|
|||||||
int getCondition() const { return _condition; }
|
int getCondition() const { return _condition; }
|
||||||
void setCondition(int value) { _condition = value; }
|
void setCondition(int value) { _condition = value; }
|
||||||
|
|
||||||
QString getSayOrder() const { return _sayOrder; }
|
int getSayOrder() const { return _sayOrder; }
|
||||||
void setSayOrder(QString text) { _sayOrder = text; }
|
void setSayOrder(int text) { _sayOrder = text; }
|
||||||
|
|
||||||
QVariant singleValue() const { return _singleValue; }
|
QVariant singleValue() const { return _singleValue; }
|
||||||
void setSingleValue(QVariant value) { _singleValue = value; }
|
void setSingleValue(QVariant value) { _singleValue = value; }
|
||||||
@ -88,8 +91,8 @@ public:
|
|||||||
QStringList getMessageSequence() const { return _messageSequence; }
|
QStringList getMessageSequence() const { return _messageSequence; }
|
||||||
void setMessageSequence(QStringList sequence) { _messageSequence = sequence; }
|
void setMessageSequence(QStringList sequence) { _messageSequence = sequence; }
|
||||||
|
|
||||||
QString retryString() const { return _repeatString; }
|
int retryValue() const { return _repeatValue; }
|
||||||
void setRetryString(QString value) { _repeatString = value; }
|
void setRetryValue(int value) { _repeatValue = value; }
|
||||||
|
|
||||||
int lifetime() const { return _expireTimeout; }
|
int lifetime() const { return _expireTimeout; }
|
||||||
void setLifetime(int value) { _expireTimeout = value; }
|
void setLifetime(int value) { _expireTimeout = value; }
|
||||||
@ -189,7 +192,7 @@ private:
|
|||||||
QString _sound3;
|
QString _sound3;
|
||||||
|
|
||||||
//! order in what sounds 1-3 will be played
|
//! order in what sounds 1-3 will be played
|
||||||
QString _sayOrder;
|
int _sayOrder;
|
||||||
|
|
||||||
//! one-side range, value(numeric or ENUM type) maybe lower, greater or in range
|
//! one-side range, value(numeric or ENUM type) maybe lower, greater or in range
|
||||||
QVariant _singleValue;
|
QVariant _singleValue;
|
||||||
@ -199,7 +202,7 @@ private:
|
|||||||
double _valueRange2;
|
double _valueRange2;
|
||||||
|
|
||||||
//! how often or what periodicaly notification should be played
|
//! how often or what periodicaly notification should be played
|
||||||
QString _repeatString;
|
int _repeatValue;
|
||||||
|
|
||||||
//! time after event occured till notification became invalid
|
//! time after event occured till notification became invalid
|
||||||
//! and will be removed from list
|
//! and will be removed from list
|
||||||
|
@ -40,18 +40,7 @@
|
|||||||
#include "notifylogging.h"
|
#include "notifylogging.h"
|
||||||
|
|
||||||
|
|
||||||
static const QString cStrNever("Never");
|
|
||||||
static const QString cStrBefore1st("Before first");
|
|
||||||
static const QString cStrBefore2nd("Before second");
|
|
||||||
static const QString cStrAfter2nd("After second");
|
|
||||||
|
|
||||||
static const QString cStrRetryOncePUpdate("Repeat Once per update");
|
|
||||||
static const QString cStrRetryOnce("Repeat Once");
|
|
||||||
|
|
||||||
static const QString cStrRetryInstantly("Repeat Instantly");
|
|
||||||
static const QString cStrRetry10sec("Repeat 10 seconds");
|
|
||||||
static const QString cStrRetry30sec("Repeat 30 seconds");
|
|
||||||
static const QString cStrRetry1min("Repeat 1 minute");
|
|
||||||
|
|
||||||
|
|
||||||
QStringList NotificationItem::sayOrderValues;
|
QStringList NotificationItem::sayOrderValues;
|
||||||
@ -73,26 +62,27 @@ NotificationItem::NotificationItem(QObject *parent)
|
|||||||
, _sound1("")
|
, _sound1("")
|
||||||
, _sound2("")
|
, _sound2("")
|
||||||
, _sound3("")
|
, _sound3("")
|
||||||
, _sayOrder(cStrNever)
|
, _sayOrder(never)
|
||||||
, _singleValue(0)
|
, _singleValue(0)
|
||||||
, _valueRange2(0)
|
, _valueRange2(0)
|
||||||
, _repeatString(cStrRetryInstantly)
|
, _repeatValue(repeatInstantly)
|
||||||
, _expireTimeout(eDefaultTimeout)
|
, _expireTimeout(eDefaultTimeout)
|
||||||
, _mute(false)
|
, _mute(false)
|
||||||
{
|
{
|
||||||
|
|
||||||
NotificationItem::sayOrderValues.clear();
|
NotificationItem::sayOrderValues.clear();
|
||||||
NotificationItem::sayOrderValues.append(cStrNever);
|
NotificationItem::sayOrderValues.insert(never,QString(tr("Never")));
|
||||||
NotificationItem::sayOrderValues.append(cStrBefore1st);
|
NotificationItem::sayOrderValues.insert(beforeFirst,QString(tr("Before first")));
|
||||||
NotificationItem::sayOrderValues.append(cStrBefore2nd);
|
NotificationItem::sayOrderValues.insert(beforeSecond,QString(tr("Before second")));
|
||||||
NotificationItem::sayOrderValues.append(cStrAfter2nd);
|
NotificationItem::sayOrderValues.insert(afterSecond,QString(tr("After second")));
|
||||||
|
|
||||||
NotificationItem::retryValues.clear();
|
NotificationItem::retryValues.clear();
|
||||||
NotificationItem::retryValues.append(cStrRetryOnce);
|
NotificationItem::retryValues.insert(repeatOnce,QString(tr("Repeat Once")));
|
||||||
NotificationItem::retryValues.append(cStrRetryOncePUpdate);
|
NotificationItem::retryValues.insert(repeatOncePerUpdate,QString(tr("Repeat Once per update")));
|
||||||
NotificationItem::retryValues.append(cStrRetryInstantly);
|
NotificationItem::retryValues.insert(repeatInstantly,QString(tr("Repeat Instantly")));
|
||||||
NotificationItem::retryValues.append(cStrRetry10sec);
|
NotificationItem::retryValues.insert(repeat10seconds,QString(tr("Repeat 10 seconds")));
|
||||||
NotificationItem::retryValues.append(cStrRetry30sec);
|
NotificationItem::retryValues.insert(repeat30seconds,QString(tr("Repeat 30 seconds")));
|
||||||
NotificationItem::retryValues.append(cStrRetry1min);
|
NotificationItem::retryValues.insert(repeat1minute,QString(tr("Repeat 1 minute")));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +102,7 @@ void NotificationItem::copyTo(NotificationItem* that) const
|
|||||||
that->_sayOrder = _sayOrder;
|
that->_sayOrder = _sayOrder;
|
||||||
that->_singleValue = _singleValue;
|
that->_singleValue = _singleValue;
|
||||||
that->_valueRange2 = _valueRange2;
|
that->_valueRange2 = _valueRange2;
|
||||||
that->_repeatString = _repeatString;
|
that->_repeatValue = _repeatValue;
|
||||||
that->_expireTimeout = _expireTimeout;
|
that->_expireTimeout = _expireTimeout;
|
||||||
that->_mute = _mute;
|
that->_mute = _mute;
|
||||||
|
|
||||||
@ -132,7 +122,7 @@ void NotificationItem::saveState(QSettings* settings) const
|
|||||||
settings->setValue(QLatin1String("Sound2"), getSound2());
|
settings->setValue(QLatin1String("Sound2"), getSound2());
|
||||||
settings->setValue(QLatin1String("Sound3"), getSound3());
|
settings->setValue(QLatin1String("Sound3"), getSound3());
|
||||||
settings->setValue(QLatin1String("SayOrder"), getSayOrder());
|
settings->setValue(QLatin1String("SayOrder"), getSayOrder());
|
||||||
settings->setValue(QLatin1String("Repeat"), retryString());
|
settings->setValue(QLatin1String("Repeat"), retryValue());
|
||||||
settings->setValue(QLatin1String("ExpireTimeout"), lifetime());
|
settings->setValue(QLatin1String("ExpireTimeout"), lifetime());
|
||||||
settings->setValue(QLatin1String("Mute"), mute());
|
settings->setValue(QLatin1String("Mute"), mute());
|
||||||
}
|
}
|
||||||
@ -148,11 +138,11 @@ void NotificationItem::restoreState(QSettings* settings)
|
|||||||
setSound1(settings->value(QLatin1String("Sound1"), tr("")).toString());
|
setSound1(settings->value(QLatin1String("Sound1"), tr("")).toString());
|
||||||
setSound2(settings->value(QLatin1String("Sound2"), tr("")).toString());
|
setSound2(settings->value(QLatin1String("Sound2"), tr("")).toString());
|
||||||
setSound3(settings->value(QLatin1String("Sound3"), tr("")).toString());
|
setSound3(settings->value(QLatin1String("Sound3"), tr("")).toString());
|
||||||
setSayOrder(settings->value(QLatin1String("SayOrder"), tr("")).toString());
|
setSayOrder(settings->value(QLatin1String("SayOrder"), tr("")).toInt());
|
||||||
QVariant value = settings->value(QLatin1String("Value1"), tr(""));
|
QVariant value = settings->value(QLatin1String("Value1"), tr(""));
|
||||||
setSingleValue(value);
|
setSingleValue(value);
|
||||||
setValueRange2(settings->value(QLatin1String("Value2"), tr("")).toDouble());
|
setValueRange2(settings->value(QLatin1String("Value2"), tr("")).toDouble());
|
||||||
setRetryString(settings->value(QLatin1String("Repeat"), tr("")).toString());
|
setRetryValue(settings->value(QLatin1String("Repeat"), tr("")).toInt());
|
||||||
setLifetime(settings->value(QLatin1String("ExpireTimeout"), tr("")).toInt());
|
setLifetime(settings->value(QLatin1String("ExpireTimeout"), tr("")).toInt());
|
||||||
setMute(settings->value(QLatin1String("Mute"), tr("")).toInt());
|
setMute(settings->value(QLatin1String("Mute"), tr("")).toInt());
|
||||||
}
|
}
|
||||||
@ -171,7 +161,7 @@ void NotificationItem::serialize(QDataStream& stream)
|
|||||||
stream << this->_sayOrder;
|
stream << this->_sayOrder;
|
||||||
stream << this->_singleValue;
|
stream << this->_singleValue;
|
||||||
stream << this->_valueRange2;
|
stream << this->_valueRange2;
|
||||||
stream << this->_repeatString;
|
stream << this->_repeatValue;
|
||||||
stream << this->_expireTimeout;
|
stream << this->_expireTimeout;
|
||||||
stream << this->_mute;
|
stream << this->_mute;
|
||||||
}
|
}
|
||||||
@ -189,7 +179,7 @@ void NotificationItem::deserialize(QDataStream& stream)
|
|||||||
stream >> this->_sayOrder;
|
stream >> this->_sayOrder;
|
||||||
stream >> this->_singleValue;
|
stream >> this->_singleValue;
|
||||||
stream >> this->_valueRange2;
|
stream >> this->_valueRange2;
|
||||||
stream >> this->_repeatString;
|
stream >> this->_repeatValue;
|
||||||
stream >> this->_expireTimeout;
|
stream >> this->_expireTimeout;
|
||||||
stream >> this->_mute;
|
stream >> this->_mute;
|
||||||
}
|
}
|
||||||
@ -356,7 +346,7 @@ QString NotificationItem::toString()
|
|||||||
UAVObjectField* field = getUAVObjectField();
|
UAVObjectField* field = getUAVObjectField();
|
||||||
QString value = stringFromValue(singleValue(), field);
|
QString value = stringFromValue(singleValue(), field);
|
||||||
|
|
||||||
int pos = getValuePosition(getSayOrder().trimmed());
|
int pos = getSayOrder()-1;
|
||||||
QStringList lst;
|
QStringList lst;
|
||||||
lst.append(getSoundCaption(getSound1()));
|
lst.append(getSoundCaption(getSound1()));
|
||||||
lst.append(getSoundCaption(getSound2()));
|
lst.append(getSoundCaption(getSound2()));
|
||||||
@ -391,7 +381,7 @@ QStringList& NotificationItem::toSoundList()
|
|||||||
|
|
||||||
// generate queue of sound files to play
|
// generate queue of sound files to play
|
||||||
_messageSequence.clear();
|
_messageSequence.clear();
|
||||||
int pos = getValuePosition(getSayOrder().trimmed());
|
int pos = getSayOrder()-1;
|
||||||
QStringList lst;
|
QStringList lst;
|
||||||
if(!getSound1().isEmpty())
|
if(!getSound1().isEmpty())
|
||||||
lst.append(getSound1());
|
lst.append(getSound1());
|
||||||
|
@ -246,8 +246,8 @@ void SoundNotifyPlugin::on_arrived_Notification(UAVObject *object)
|
|||||||
// notification can be accepted again;
|
// notification can be accepted again;
|
||||||
// 2. Once time notifications, they removed immediately after first playing;
|
// 2. Once time notifications, they removed immediately after first playing;
|
||||||
// 3. Instant notifications(played one by one without interval);
|
// 3. Instant notifications(played one by one without interval);
|
||||||
if (ntf->retryString() != "Repeat Instantly" && ntf->retryString() != "Repeat Once per update" &&
|
if (ntf->retryValue() != NotificationItem::repeatInstantly && ntf->retryValue() != NotificationItem::repeatOncePerUpdate &&
|
||||||
ntf->retryString() != "Repeat Once" && ntf->_isPlayed)
|
ntf->retryValue() != NotificationItem::repeatOnce && ntf->_isPlayed)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
qNotifyDebug() << QString("new notification: | %1 | %2 | val1: %3 | val2: %4")
|
qNotifyDebug() << QString("new notification: | %1 | %2 | val1: %3 | val2: %4")
|
||||||
@ -363,7 +363,7 @@ bool checkRange(QString fieldValue, QString enumValue, QStringList values, int d
|
|||||||
bool ret = false;
|
bool ret = false;
|
||||||
switch(direction)
|
switch(direction)
|
||||||
{
|
{
|
||||||
case NotificationItem::equal:
|
case NotifyPluginOptionsPage::equal:
|
||||||
ret = !QString::compare(enumValue, fieldValue, Qt::CaseInsensitive) ? true : false;
|
ret = !QString::compare(enumValue, fieldValue, Qt::CaseInsensitive) ? true : false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -377,18 +377,18 @@ bool checkRange(QString fieldValue, QString enumValue, QStringList values, int d
|
|||||||
bool checkRange(double fieldValue, double min, double max, int direction)
|
bool checkRange(double fieldValue, double min, double max, int direction)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
Q_ASSERT(min < max);
|
//Q_ASSERT(min < max);
|
||||||
switch(direction)
|
switch(direction)
|
||||||
{
|
{
|
||||||
case NotificationItem::equal:
|
case NotifyPluginOptionsPage::equal:
|
||||||
ret = (fieldValue == min);
|
ret = (fieldValue == min);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NotificationItem::bigger:
|
case NotifyPluginOptionsPage::bigger:
|
||||||
ret = (fieldValue > min);
|
ret = (fieldValue > min);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NotificationItem::smaller:
|
case NotifyPluginOptionsPage::smaller:
|
||||||
ret = (fieldValue < min);
|
ret = (fieldValue < min);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -445,7 +445,7 @@ void SoundNotifyPlugin::checkNotificationRule(NotificationItem* notification, UA
|
|||||||
notification->setCurrentUpdatePlayed(false);
|
notification->setCurrentUpdatePlayed(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(notification->retryString() == "Repeat Once per update" && notification->getCurrentUpdatePlayed())
|
if(notification->retryValue() == NotificationItem::repeatOncePerUpdate && notification->getCurrentUpdatePlayed())
|
||||||
return;
|
return;
|
||||||
volatile QMutexLocker lock(&_mutex);
|
volatile QMutexLocker lock(&_mutex);
|
||||||
|
|
||||||
@ -484,17 +484,17 @@ bool SoundNotifyPlugin::playNotification(NotificationItem* notification)
|
|||||||
_nowPlayingNotification = notification;
|
_nowPlayingNotification = notification;
|
||||||
notification->stopExpireTimer();
|
notification->stopExpireTimer();
|
||||||
|
|
||||||
if (notification->retryString() == "Repeat Once") {
|
if (notification->retryValue() == NotificationItem::repeatOnce) {
|
||||||
_toRemoveNotifications.append(_notificationList.takeAt(_notificationList.indexOf(notification)));
|
_toRemoveNotifications.append(_notificationList.takeAt(_notificationList.indexOf(notification)));
|
||||||
}
|
}
|
||||||
else if(notification->retryString() == "Repeat Once per update")
|
else if(notification->retryValue() == NotificationItem::repeatOncePerUpdate)
|
||||||
notification->setCurrentUpdatePlayed(true);
|
notification->setCurrentUpdatePlayed(true);
|
||||||
else {
|
else {
|
||||||
if (notification->retryString() != "Repeat Instantly") {
|
if (notification->retryValue() != NotificationItem::repeatInstantly) {
|
||||||
QRegExp rxlen("(\\d+)");
|
QRegExp rxlen("(\\d+)");
|
||||||
QString value;
|
QString value;
|
||||||
int timer_value;
|
int timer_value=0;
|
||||||
int pos = rxlen.indexIn(notification->retryString());
|
int pos = rxlen.indexIn(NotificationItem::retryValues.at(notification->retryValue()));
|
||||||
if (pos > -1) {
|
if (pos > -1) {
|
||||||
value = rxlen.cap(1); // "189"
|
value = rxlen.cap(1); // "189"
|
||||||
|
|
||||||
|
@ -47,11 +47,7 @@
|
|||||||
#include "notifytablemodel.h"
|
#include "notifytablemodel.h"
|
||||||
#include "notifylogging.h"
|
#include "notifylogging.h"
|
||||||
|
|
||||||
static const char* cStrEqualTo = "Equal to";
|
QStringList NotifyPluginOptionsPage::conditionValues;
|
||||||
static const char* cStrLargeThan = "Large than";
|
|
||||||
static const char* cStrLowerThan = "Lower than";
|
|
||||||
static const char* cStrInRange = "In range";
|
|
||||||
|
|
||||||
|
|
||||||
NotifyPluginOptionsPage::NotifyPluginOptionsPage(QObject *parent)
|
NotifyPluginOptionsPage::NotifyPluginOptionsPage(QObject *parent)
|
||||||
: IOptionsPage(parent)
|
: IOptionsPage(parent)
|
||||||
@ -63,7 +59,13 @@ NotifyPluginOptionsPage::NotifyPluginOptionsPage(QObject *parent)
|
|||||||
, _sayOrder(NULL)
|
, _sayOrder(NULL)
|
||||||
, _form(NULL)
|
, _form(NULL)
|
||||||
, _selectedNotification(NULL)
|
, _selectedNotification(NULL)
|
||||||
{}
|
{
|
||||||
|
NotifyPluginOptionsPage::conditionValues.insert(equal,tr("Equal to"));
|
||||||
|
NotifyPluginOptionsPage::conditionValues.insert(bigger,tr("Large than"));
|
||||||
|
NotifyPluginOptionsPage::conditionValues.insert(smaller,tr("Lower than"));
|
||||||
|
NotifyPluginOptionsPage::conditionValues.insert(inrange,tr("In range"));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
NotifyPluginOptionsPage::~NotifyPluginOptionsPage()
|
NotifyPluginOptionsPage::~NotifyPluginOptionsPage()
|
||||||
{}
|
{}
|
||||||
@ -249,38 +251,16 @@ void NotifyPluginOptionsPage::addDynamicField(UAVObjectField* objField)
|
|||||||
this, SLOT(on_changedIndex_rangeValue(QString)));
|
this, SLOT(on_changedIndex_rangeValue(QString)));
|
||||||
|
|
||||||
_dynamicFieldCondition->clear();
|
_dynamicFieldCondition->clear();
|
||||||
QStringList rangeValues;
|
_dynamicFieldCondition->addItems(NotifyPluginOptionsPage::conditionValues);
|
||||||
QList<int> rangeCode;
|
|
||||||
if (UAVObjectField::ENUM == objField->getType()) {
|
if (UAVObjectField::ENUM == objField->getType()) {
|
||||||
rangeValues << cStrEqualTo << cStrInRange;
|
_dynamicFieldCondition->removeItem(smaller);
|
||||||
rangeCode<<NotificationItem::equal<<NotificationItem::inrange;
|
_dynamicFieldCondition->removeItem(bigger);
|
||||||
int x=0;
|
|
||||||
int selected=0;
|
|
||||||
foreach (QString value, rangeValues) {
|
|
||||||
_dynamicFieldCondition->addItem(value,rangeCode[x]);
|
|
||||||
if(_selectedNotification->getCondition()==rangeCode[x])
|
|
||||||
selected=x;
|
|
||||||
++x;
|
|
||||||
}
|
}
|
||||||
qNotifyDebug()<<"setcurrentindex"<<x;
|
_dynamicFieldCondition->setCurrentIndex(_dynamicFieldCondition->findText(NotifyPluginOptionsPage::conditionValues.at(_selectedNotification->getCondition())));
|
||||||
_dynamicFieldCondition->setCurrentIndex(selected);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
rangeValues << cStrEqualTo << cStrLargeThan << cStrLowerThan << cStrInRange;
|
|
||||||
rangeCode<<NotificationItem::equal<<NotificationItem::bigger<<NotificationItem::smaller<<NotificationItem::inrange;
|
|
||||||
int x=0;
|
|
||||||
int selected=0;
|
|
||||||
foreach (QString value, rangeValues) {
|
|
||||||
_dynamicFieldCondition->addItem(value,rangeCode[x]);
|
|
||||||
if(_selectedNotification->getCondition()==rangeCode[x])
|
|
||||||
selected=x;
|
|
||||||
++x;
|
|
||||||
}
|
|
||||||
qNotifyDebug()<<"setcurrentindex"<<x;
|
|
||||||
_dynamicFieldCondition->setCurrentIndex(selected);
|
|
||||||
connect(_dynamicFieldCondition, SIGNAL(currentIndexChanged(QString)),
|
connect(_dynamicFieldCondition, SIGNAL(currentIndexChanged(QString)),
|
||||||
this, SLOT(on_changedIndex_rangeValue(QString)));
|
this, SLOT(on_changedIndex_rangeValue(QString)));
|
||||||
}
|
|
||||||
addDynamicFieldWidget(objField);
|
addDynamicFieldWidget(objField);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,7 +295,7 @@ void NotifyPluginOptionsPage::addDynamicFieldWidget(UAVObjectField* objField)
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
Q_ASSERT(_dynamicFieldCondition);
|
Q_ASSERT(_dynamicFieldCondition);
|
||||||
if (_dynamicFieldCondition->currentText() == cStrInRange) {
|
if (NotifyPluginOptionsPage::conditionValues.indexOf(_dynamicFieldCondition->currentText()) == NotifyPluginOptionsPage::inrange) {
|
||||||
_dynamicFieldWidget = new QLineEdit(_form);
|
_dynamicFieldWidget = new QLineEdit(_form);
|
||||||
|
|
||||||
(static_cast<QLineEdit*>(_dynamicFieldWidget))->setInputMask("#999.99 : #999.99;");
|
(static_cast<QLineEdit*>(_dynamicFieldWidget))->setInputMask("#999.99 : #999.99;");
|
||||||
@ -369,9 +349,8 @@ void NotifyPluginOptionsPage::getOptionsPageValues(NotificationItem* notificatio
|
|||||||
notification->setSound1(_optionsPage->Sound1->currentText());
|
notification->setSound1(_optionsPage->Sound1->currentText());
|
||||||
notification->setSound2(_optionsPage->Sound2->currentText());
|
notification->setSound2(_optionsPage->Sound2->currentText());
|
||||||
notification->setSound3(_optionsPage->Sound3->currentText());
|
notification->setSound3(_optionsPage->Sound3->currentText());
|
||||||
notification->setSayOrder(_sayOrder->currentText());
|
notification->setSayOrder(_sayOrder->currentIndex());
|
||||||
notification->setCondition(_dynamicFieldCondition->itemData(_dynamicFieldCondition->currentIndex()).toInt());
|
notification->setCondition(NotifyPluginOptionsPage::conditionValues.indexOf(_dynamicFieldCondition->currentText()));
|
||||||
qNotifyDebug()<<"getOptionsPageValues SETRANGE"<<_dynamicFieldCondition->currentIndex()<<_dynamicFieldCondition->itemData(_dynamicFieldCondition->currentIndex()).toInt();
|
|
||||||
if (QDoubleSpinBox* spinValue = dynamic_cast<QDoubleSpinBox*>(_dynamicFieldWidget))
|
if (QDoubleSpinBox* spinValue = dynamic_cast<QDoubleSpinBox*>(_dynamicFieldWidget))
|
||||||
notification->setSingleValue(spinValue->value());
|
notification->setSingleValue(spinValue->value());
|
||||||
else {
|
else {
|
||||||
@ -455,15 +434,10 @@ void NotifyPluginOptionsPage::updateConfigView(NotificationItem* notification)
|
|||||||
_optionsPage->SoundCollectionList->setCurrentIndex(_optionsPage->SoundCollectionList->findText("default"));
|
_optionsPage->SoundCollectionList->setCurrentIndex(_optionsPage->SoundCollectionList->findText("default"));
|
||||||
_optionsPage->Sound3->setCurrentIndex(_optionsPage->Sound3->findText(notification->getSound3()));
|
_optionsPage->Sound3->setCurrentIndex(_optionsPage->Sound3->findText(notification->getSound3()));
|
||||||
}
|
}
|
||||||
for(int x=0;x<_dynamicFieldCondition->count();++x)
|
|
||||||
{
|
_dynamicFieldCondition->setCurrentIndex(_dynamicFieldCondition->findText(NotifyPluginOptionsPage::conditionValues.at(notification->getCondition())));
|
||||||
if (_dynamicFieldCondition->itemData(x)==notification->getCondition()) {
|
|
||||||
_dynamicFieldCondition->setCurrentIndex(x);
|
_sayOrder->setCurrentIndex(notification->getSayOrder());
|
||||||
}
|
|
||||||
}
|
|
||||||
if (-1 != _sayOrder->findText(notification->getSayOrder())) {
|
|
||||||
_sayOrder->setCurrentIndex(_sayOrder->findText(notification->getSayOrder()));
|
|
||||||
}
|
|
||||||
|
|
||||||
setDynamicFieldValue(notification);
|
setDynamicFieldValue(notification);
|
||||||
|
|
||||||
@ -613,7 +587,7 @@ void NotifyPluginOptionsPage::on_clicked_buttonAddNotification()
|
|||||||
delete notification;
|
delete notification;
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
notification->setSayOrder(_sayOrder->currentText());
|
notification->setSayOrder(_sayOrder->currentIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
_notifyRulesModel->entryAdded(notification);
|
_notifyRulesModel->entryAdded(notification);
|
||||||
@ -638,7 +612,7 @@ void NotifyPluginOptionsPage::on_clicked_buttonModifyNotification()
|
|||||||
{
|
{
|
||||||
NotificationItem* notification = new NotificationItem;
|
NotificationItem* notification = new NotificationItem;
|
||||||
getOptionsPageValues(notification);
|
getOptionsPageValues(notification);
|
||||||
notification->setRetryString(_privListNotifications.at(_notifyRulesSelection->currentIndex().row())->retryString());
|
notification->setRetryValue(_privListNotifications.at(_notifyRulesSelection->currentIndex().row())->retryValue());
|
||||||
notification->setLifetime(_privListNotifications.at(_notifyRulesSelection->currentIndex().row())->lifetime());
|
notification->setLifetime(_privListNotifications.at(_notifyRulesSelection->currentIndex().row())->lifetime());
|
||||||
notification->setMute(_privListNotifications.at(_notifyRulesSelection->currentIndex().row())->mute());
|
notification->setMute(_privListNotifications.at(_notifyRulesSelection->currentIndex().row())->mute());
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ class NotifyPluginOptionsPage : public IOptionsPage
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
enum {equal,bigger,smaller,inrange};
|
||||||
explicit NotifyPluginOptionsPage(QObject *parent = 0);
|
explicit NotifyPluginOptionsPage(QObject *parent = 0);
|
||||||
~NotifyPluginOptionsPage();
|
~NotifyPluginOptionsPage();
|
||||||
QString id() const { return QLatin1String("settings"); }
|
QString id() const { return QLatin1String("settings"); }
|
||||||
@ -72,6 +72,7 @@ public:
|
|||||||
void apply();
|
void apply();
|
||||||
void finish();
|
void finish();
|
||||||
void restoreFromSettings();
|
void restoreFromSettings();
|
||||||
|
static QStringList conditionValues;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void updateNotifications(QList<NotificationItem*> list);
|
void updateNotifications(QList<NotificationItem*> list);
|
||||||
|
@ -52,7 +52,7 @@ bool NotifyTableModel::setData(const QModelIndex &index,
|
|||||||
}
|
}
|
||||||
if (index.isValid() && role == Qt::EditRole) {
|
if (index.isValid() && role == Qt::EditRole) {
|
||||||
if (eRepeatValue == index.column())
|
if (eRepeatValue == index.column())
|
||||||
_list.at(index.row())->setRetryString(value.toString());
|
_list.at(index.row())->setRetryValue(NotificationItem::retryValues.indexOf(value.toString()));
|
||||||
else {
|
else {
|
||||||
if (eExpireTimer == index.column())
|
if (eExpireTimer == index.column())
|
||||||
_list.at(index.row())->setLifetime(value.toInt());
|
_list.at(index.row())->setLifetime(value.toInt());
|
||||||
@ -85,7 +85,7 @@ QVariant NotifyTableModel::data(const QModelIndex &index, int role) const
|
|||||||
return _list.at(index.row())->toString();
|
return _list.at(index.row())->toString();
|
||||||
|
|
||||||
case eRepeatValue:
|
case eRepeatValue:
|
||||||
return _list.at(index.row())->retryString();
|
return (NotificationItem::retryValues.at(_list.at(index.row())->retryValue()));
|
||||||
|
|
||||||
case eExpireTimer:
|
case eExpireTimer:
|
||||||
return _list.at(index.row())->lifetime();
|
return _list.at(index.row())->lifetime();
|
||||||
|
Loading…
Reference in New Issue
Block a user