1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-27 16:54:15 +01:00

Fixed conditions

Added support for negative values
Added support to "play once per update"
Added "never" rule for value sound
Several other bugfixes
This commit is contained in:
zedamota 2011-12-03 02:36:47 +00:00
parent f5c7dba0b1
commit 78e25b1b8c
5 changed files with 106 additions and 49 deletions

View File

@ -49,6 +49,7 @@ class NotificationItem : public QObject
public: public:
enum { eDefaultTimeout = 15 }; // in sec enum { eDefaultTimeout = 15 }; // in sec
enum {equal,bigger,smaller,inrange};
explicit NotificationItem(QObject *parent = 0); explicit NotificationItem(QObject *parent = 0);
void copyTo(NotificationItem*) const; void copyTo(NotificationItem*) const;
@ -57,8 +58,11 @@ public:
DECLARE_SOUND(2) DECLARE_SOUND(2)
DECLARE_SOUND(3) DECLARE_SOUND(3)
QString range() const { return _rangeLimit; } bool getCurrentUpdatePlayed() const {return _currentUpdatePlayed;}
void setRange(QString text) { _rangeLimit = text; } void setCurrentUpdatePlayed(bool value){_currentUpdatePlayed=value;}
int getCondition() const { return _condition; }
void setCondition(int value) { _condition = value; }
QString getSayOrder() const { return _sayOrder; } QString getSayOrder() const { return _sayOrder; }
void setSayOrder(QString text) { _sayOrder = text; } void setSayOrder(QString text) { _sayOrder = text; }
@ -100,8 +104,8 @@ public:
UAVDataObject* getUAVObject(void); UAVDataObject* getUAVObject(void);
UAVObjectField* getUAVObjectField(void); UAVObjectField* getUAVObjectField(void);
void seriaize(QDataStream& stream); void serialize(QDataStream& stream);
void deseriaize(QDataStream& stream); void deserialize(QDataStream& stream);
/** /**
* Convert notification item fields in single string, * Convert notification item fields in single string,
@ -152,6 +156,8 @@ private:
private: private:
bool _currentUpdatePlayed;
QTimer* _timer; QTimer* _timer;
//! time from putting notification in queue till moment when notification became out-of-date //! time from putting notification in queue till moment when notification became out-of-date
@ -175,7 +181,7 @@ private:
QString _objectField; QString _objectField;
//! fire condition for UAV field value (lower, greater, in range) //! fire condition for UAV field value (lower, greater, in range)
QString _rangeLimit; int _condition;
//! possible sounds(at least one required to play notification) //! possible sounds(at least one required to play notification)
QString _sound1; QString _sound1;

View File

@ -45,7 +45,9 @@ static const QString cStrBefore1st("Before first");
static const QString cStrBefore2nd("Before second"); static const QString cStrBefore2nd("Before second");
static const QString cStrAfter2nd("After second"); static const QString cStrAfter2nd("After second");
static const QString cStrRetryOncePUpdate("Repeat Once per update");
static const QString cStrRetryOnce("Repeat Once"); static const QString cStrRetryOnce("Repeat Once");
static const QString cStrRetryInstantly("Repeat Instantly"); static const QString cStrRetryInstantly("Repeat Instantly");
static const QString cStrRetry10sec("Repeat 10 seconds"); static const QString cStrRetry10sec("Repeat 10 seconds");
static const QString cStrRetry30sec("Repeat 30 seconds"); static const QString cStrRetry30sec("Repeat 30 seconds");
@ -58,6 +60,7 @@ QStringList NotificationItem::retryValues;
NotificationItem::NotificationItem(QObject *parent) NotificationItem::NotificationItem(QObject *parent)
: QObject(parent) : QObject(parent)
, _currentUpdatePlayed(false)
, isNowPlaying(0) , isNowPlaying(0)
, _isPlayed(false) , _isPlayed(false)
, _timer(NULL) , _timer(NULL)
@ -66,7 +69,7 @@ NotificationItem::NotificationItem(QObject *parent)
, _currentLanguage("default") , _currentLanguage("default")
, _dataObject("") , _dataObject("")
, _objectField("") , _objectField("")
, _rangeLimit("Equal to") , _condition(0)
, _sound1("") , _sound1("")
, _sound2("") , _sound2("")
, _sound3("") , _sound3("")
@ -78,12 +81,14 @@ NotificationItem::NotificationItem(QObject *parent)
, _mute(false) , _mute(false)
{ {
NotificationItem::sayOrderValues.clear(); NotificationItem::sayOrderValues.clear();
NotificationItem::sayOrderValues.append(cStrNever);
NotificationItem::sayOrderValues.append(cStrBefore1st); NotificationItem::sayOrderValues.append(cStrBefore1st);
NotificationItem::sayOrderValues.append(cStrBefore2nd); NotificationItem::sayOrderValues.append(cStrBefore2nd);
NotificationItem::sayOrderValues.append(cStrAfter2nd); NotificationItem::sayOrderValues.append(cStrAfter2nd);
NotificationItem::retryValues.clear(); NotificationItem::retryValues.clear();
NotificationItem::retryValues.append(cStrRetryOnce); NotificationItem::retryValues.append(cStrRetryOnce);
NotificationItem::retryValues.append(cStrRetryOncePUpdate);
NotificationItem::retryValues.append(cStrRetryInstantly); NotificationItem::retryValues.append(cStrRetryInstantly);
NotificationItem::retryValues.append(cStrRetry10sec); NotificationItem::retryValues.append(cStrRetry10sec);
NotificationItem::retryValues.append(cStrRetry30sec); NotificationItem::retryValues.append(cStrRetry30sec);
@ -100,7 +105,7 @@ void NotificationItem::copyTo(NotificationItem* that) const
that->_soundCollectionPath = _soundCollectionPath; that->_soundCollectionPath = _soundCollectionPath;
that->_dataObject = _dataObject; that->_dataObject = _dataObject;
that->_objectField = _objectField; that->_objectField = _objectField;
that->_rangeLimit = _rangeLimit; that->_condition = _condition;
that->_sound1 = _sound1; that->_sound1 = _sound1;
that->_sound2 = _sound2; that->_sound2 = _sound2;
that->_sound3 = _sound3; that->_sound3 = _sound3;
@ -120,7 +125,7 @@ void NotificationItem::saveState(QSettings* settings) const
settings->setValue(QLatin1String("CurrentLanguage"), getCurrentLanguage()); settings->setValue(QLatin1String("CurrentLanguage"), getCurrentLanguage());
settings->setValue(QLatin1String("ObjectField"), getObjectField()); settings->setValue(QLatin1String("ObjectField"), getObjectField());
settings->setValue(QLatin1String("DataObject"), getDataObject()); settings->setValue(QLatin1String("DataObject"), getDataObject());
settings->setValue(QLatin1String("RangeLimit"), range()); settings->setValue(QLatin1String("RangeLimit"), getCondition());
settings->setValue(QLatin1String("Value1"), singleValue()); settings->setValue(QLatin1String("Value1"), singleValue());
settings->setValue(QLatin1String("Value2"), valueRange2()); settings->setValue(QLatin1String("Value2"), valueRange2());
settings->setValue(QLatin1String("Sound1"), getSound1()); settings->setValue(QLatin1String("Sound1"), getSound1());
@ -139,7 +144,7 @@ void NotificationItem::restoreState(QSettings* settings)
setCurrentLanguage(settings->value(QLatin1String("CurrentLanguage"), tr("")).toString()); setCurrentLanguage(settings->value(QLatin1String("CurrentLanguage"), tr("")).toString());
setDataObject(settings->value(QLatin1String("DataObject"), tr("")).toString()); setDataObject(settings->value(QLatin1String("DataObject"), tr("")).toString());
setObjectField(settings->value(QLatin1String("ObjectField"), tr("")).toString()); setObjectField(settings->value(QLatin1String("ObjectField"), tr("")).toString());
setRange(settings->value(QLatin1String("RangeLimit"), tr("")).toString()); setCondition(settings->value(QLatin1String("RangeLimit"), tr("")).toInt());
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());
@ -152,13 +157,14 @@ void NotificationItem::restoreState(QSettings* settings)
setMute(settings->value(QLatin1String("Mute"), tr("")).toInt()); setMute(settings->value(QLatin1String("Mute"), tr("")).toInt());
} }
void NotificationItem::seriaize(QDataStream& stream) void NotificationItem::serialize(QDataStream& stream)
{ {
stream << this->_soundCollectionPath; stream << this->_soundCollectionPath;
stream << this->_currentLanguage; stream << this->_currentLanguage;
stream << this->_dataObject; stream << this->_dataObject;
stream << this->_objectField; stream << this->_objectField;
stream << this->_rangeLimit; stream << this->_condition;
qNotifyDebug()<<"getOptionsPageValues seriaize"<<_condition;
stream << this->_sound1; stream << this->_sound1;
stream << this->_sound2; stream << this->_sound2;
stream << this->_sound3; stream << this->_sound3;
@ -170,13 +176,13 @@ void NotificationItem::seriaize(QDataStream& stream)
stream << this->_mute; stream << this->_mute;
} }
void NotificationItem::deseriaize(QDataStream& stream) void NotificationItem::deserialize(QDataStream& stream)
{ {
stream >> this->_soundCollectionPath; stream >> this->_soundCollectionPath;
stream >> this->_currentLanguage; stream >> this->_currentLanguage;
stream >> this->_dataObject; stream >> this->_dataObject;
stream >> this->_objectField; stream >> this->_objectField;
stream >> this->_rangeLimit; stream >> this->_condition;
stream >> this->_sound1; stream >> this->_sound1;
stream >> this->_sound2; stream >> this->_sound2;
stream >> this->_sound3; stream >> this->_sound3;
@ -252,7 +258,7 @@ void NotificationItem::disposeExpireTimer()
int getValuePosition(QString sayOrder) int getValuePosition(QString sayOrder)
{ {
return NotificationItem::sayOrderValues.indexOf(sayOrder); return NotificationItem::sayOrderValues.indexOf(sayOrder)-1;
} }
QString NotificationItem::checkSoundExists(QString fileName) QString NotificationItem::checkSoundExists(QString fileName)
@ -275,11 +281,16 @@ QString NotificationItem::checkSoundExists(QString fileName)
QStringList valueToSoundList(QString value) QStringList valueToSoundList(QString value)
{ {
// replace point chr if exists // replace point chr if exists
value = value.replace(',', '.'); value = value.replace(',', '.');
QStringList numberParts = value.trimmed().split("."); QStringList numberParts = value.trimmed().split(".");
QStringList digitWavs; QStringList digitWavs;
if(numberParts.at(0).toInt()<0)
{
digitWavs.append("moved");
numberParts[0]=QString::number(numberParts.at(0).toInt()*-1);
}
if ( (numberParts.at(0).size() == 1) || (numberParts.at(0).toInt() < 20) ) { if ( (numberParts.at(0).size() == 1) || (numberParts.at(0).toInt() < 20) ) {
// [1] check, is this number < 20, these numbers played by one wav file // [1] check, is this number < 20, these numbers played by one wav file
digitWavs.append(numberParts.at(0)); digitWavs.append(numberParts.at(0));

View File

@ -246,7 +246,7 @@ 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" && if (ntf->retryString() != "Repeat Instantly" && ntf->retryString() != "Repeat Once per update" &&
ntf->retryString() != "Repeat Once" && ntf->_isPlayed) ntf->retryString() != "Repeat Once" && ntf->_isPlayed)
continue; continue;
@ -345,6 +345,7 @@ void SoundNotifyPlugin::stateChanged(Phonon::State newstate, Phonon::State oldst
NotificationItem* notification = _pendingNotifications.takeFirst(); NotificationItem* notification = _pendingNotifications.takeFirst();
qNotifyDebug_if(notification) << "play audioFree - " << notification->toString(); qNotifyDebug_if(notification) << "play audioFree - " << notification->toString();
playNotification(notification); playNotification(notification);
qNotifyDebug()<<"end playNotification";
} }
} else { } else {
if (newstate == Phonon::ErrorState) { if (newstate == Phonon::ErrorState) {
@ -356,13 +357,13 @@ void SoundNotifyPlugin::stateChanged(Phonon::State newstate, Phonon::State oldst
} }
} }
bool checkRange(QString fieldValue, QString enumValue, QStringList values, char direction) bool checkRange(QString fieldValue, QString enumValue, QStringList values, int direction)
{ {
bool ret = false; bool ret = false;
switch(direction) switch(direction)
{ {
case 'E': case NotificationItem::equal:
ret = !QString::compare(enumValue, fieldValue, Qt::CaseInsensitive) ? true : false; ret = !QString::compare(enumValue, fieldValue, Qt::CaseInsensitive) ? true : false;
break; break;
@ -373,21 +374,21 @@ bool checkRange(QString fieldValue, QString enumValue, QStringList values, char
return ret; return ret;
} }
bool checkRange(double fieldValue, double min, double max, char 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 'E': case NotificationItem::equal:
ret = (fieldValue == min); ret = (fieldValue == min);
break; break;
case 'G': case NotificationItem::bigger:
ret = (fieldValue > min); ret = (fieldValue > min);
break; break;
case 'L': case NotificationItem::smaller:
ret = (fieldValue < min); ret = (fieldValue < min);
break; break;
@ -406,7 +407,7 @@ void SoundNotifyPlugin::checkNotificationRule(NotificationItem* notification, UA
if (notification->mute()) if (notification->mute())
return; return;
QString direction = notification->range(); int direction = notification->getCondition();
QString fieldName = notification->getObjectField(); QString fieldName = notification->getObjectField();
UAVObjectField* field = object->getField(fieldName); UAVObjectField* field = object->getField(fieldName);
@ -415,15 +416,25 @@ void SoundNotifyPlugin::checkNotificationRule(NotificationItem* notification, UA
QVariant value = field->getValue(); QVariant value = field->getValue();
if(UAVObjectField::ENUM == field->getType()) { if(UAVObjectField::ENUM == field->getType()) {
qNotifyDebug()<<"Check range ENUM"<<value.toString()<<"|"<<notification->singleValue().toString()<<"|"<<field->getOptions()<<"|"<<
direction<<checkRange(value.toString(),
notification->singleValue().toString(),
field->getOptions(),
direction);;
condition = checkRange(value.toString(), condition = checkRange(value.toString(),
notification->singleValue().toString(), notification->singleValue().toString(),
field->getOptions(), field->getOptions(),
direction[0].toAscii()); direction);
} else { } else {
qNotifyDebug()<<"Check range VAL"<<value.toString()<<"|"<<notification->singleValue().toString()<<"|"<<field->getOptions()<<"|"<<
direction<<checkRange(value.toDouble(),
notification->singleValue().toDouble(),
notification->valueRange2(),
direction);
condition = checkRange(value.toDouble(), condition = checkRange(value.toDouble(),
notification->singleValue().toDouble(), notification->singleValue().toDouble(),
notification->valueRange2(), notification->valueRange2(),
direction[0].toAscii()); direction);
} }
notification->_isPlayed = condition; notification->_isPlayed = condition;
@ -431,9 +442,11 @@ void SoundNotifyPlugin::checkNotificationRule(NotificationItem* notification, UA
// we should reset _isPlayed flag and stop repeat timer // we should reset _isPlayed flag and stop repeat timer
if (!notification->_isPlayed) { if (!notification->_isPlayed) {
notification->stopTimer(); notification->stopTimer();
notification->setCurrentUpdatePlayed(false);
return; return;
} }
if(notification->retryString() == "Repeat Once per update" && notification->getCurrentUpdatePlayed())
return;
volatile QMutexLocker lock(&_mutex); volatile QMutexLocker lock(&_mutex);
if (!playNotification(notification)) { if (!playNotification(notification)) {
@ -473,7 +486,10 @@ bool SoundNotifyPlugin::playNotification(NotificationItem* notification)
if (notification->retryString() == "Repeat Once") { if (notification->retryString() == "Repeat Once") {
_toRemoveNotifications.append(_notificationList.takeAt(_notificationList.indexOf(notification))); _toRemoveNotifications.append(_notificationList.takeAt(_notificationList.indexOf(notification)));
} else { }
else if(notification->retryString() == "Repeat Once per update")
notification->setCurrentUpdatePlayed(true);
else {
if (notification->retryString() != "Repeat Instantly") { if (notification->retryString() != "Repeat Instantly") {
QRegExp rxlen("(\\d+)"); QRegExp rxlen("(\\d+)");
QString value; QString value;
@ -505,7 +521,9 @@ bool SoundNotifyPlugin::playNotification(NotificationItem* notification)
ms->setAutoDelete(true); ms->setAutoDelete(true);
phonon.mo->enqueue(*ms); phonon.mo->enqueue(*ms);
} }
qNotifyDebug()<<"begin play";
phonon.mo->play(); phonon.mo->play();
qNotifyDebug()<<"end play";
phonon.firstPlay = false; // On Linux, you sometimes have to nudge Phonon to play 1 time before phonon.firstPlay = false; // On Linux, you sometimes have to nudge Phonon to play 1 time before
// the state is not "Loading" anymore. // the state is not "Loading" anymore.
return true; return true;

View File

@ -57,7 +57,7 @@ NotifyPluginOptionsPage::NotifyPluginOptionsPage(QObject *parent)
: IOptionsPage(parent) : IOptionsPage(parent)
, _objManager(*ExtensionSystem::PluginManager::instance()->getObject<UAVObjectManager>()) , _objManager(*ExtensionSystem::PluginManager::instance()->getObject<UAVObjectManager>())
, _owner(qobject_cast<SoundNotifyPlugin*>(parent)) , _owner(qobject_cast<SoundNotifyPlugin*>(parent))
, _dynamicFieldLimit(NULL) , _dynamicFieldCondition(NULL)
, _dynamicFieldWidget(NULL) , _dynamicFieldWidget(NULL)
, _dynamicFieldType(-1) , _dynamicFieldType(-1)
, _sayOrder(NULL) , _sayOrder(NULL)
@ -74,7 +74,7 @@ QWidget *NotifyPluginOptionsPage::createPage(QWidget *parent)
//main widget //main widget
QWidget* optionsPageWidget = new QWidget; QWidget* optionsPageWidget = new QWidget;
_dynamicFieldWidget = NULL; _dynamicFieldWidget = NULL;
_dynamicFieldLimit = NULL; _dynamicFieldCondition = NULL;
resetFieldType(); resetFieldType();
//save ref to form, needed for binding dynamic fields in future //save ref to form, needed for binding dynamic fields in future
_form = optionsPageWidget; _form = optionsPageWidget;
@ -224,8 +224,8 @@ void NotifyPluginOptionsPage::addDynamicFieldLayout()
labelValueIs->setSizePolicy(labelSizePolicy); labelValueIs->setSizePolicy(labelSizePolicy);
_optionsPage->dynamicValueLayout->addWidget(labelValueIs); _optionsPage->dynamicValueLayout->addWidget(labelValueIs);
_dynamicFieldLimit = new QComboBox(_form); _dynamicFieldCondition = new QComboBox(_form);
_optionsPage->dynamicValueLayout->addWidget(_dynamicFieldLimit); _optionsPage->dynamicValueLayout->addWidget(_dynamicFieldCondition);
UAVObjectField* field = getObjectFieldFromSelected(); UAVObjectField* field = getObjectFieldFromSelected();
addDynamicField(field); addDynamicField(field);
} }
@ -245,23 +245,42 @@ void NotifyPluginOptionsPage::addDynamicField(UAVObjectField* objField)
return; return;
} }
disconnect(_dynamicFieldLimit, SIGNAL(currentIndexChanged(QString)), disconnect(_dynamicFieldCondition, SIGNAL(currentIndexChanged(QString)),
this, SLOT(on_changedIndex_rangeValue(QString))); this, SLOT(on_changedIndex_rangeValue(QString)));
_dynamicFieldLimit->clear(); _dynamicFieldCondition->clear();
QStringList rangeValues; QStringList rangeValues;
QList<int> rangeCode;
if (UAVObjectField::ENUM == objField->getType()) { if (UAVObjectField::ENUM == objField->getType()) {
rangeValues << cStrEqualTo << cStrInRange; rangeValues << cStrEqualTo << cStrInRange;
_dynamicFieldLimit->addItems(rangeValues); rangeCode<<NotificationItem::equal<<NotificationItem::inrange;
_dynamicFieldLimit->setCurrentIndex(rangeValues.indexOf(_selectedNotification->range())); 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);
} else { } else {
rangeValues << cStrEqualTo << cStrLargeThan << cStrLowerThan << cStrInRange; rangeValues << cStrEqualTo << cStrLargeThan << cStrLowerThan << cStrInRange;
_dynamicFieldLimit->addItems(rangeValues); rangeCode<<NotificationItem::equal<<NotificationItem::bigger<<NotificationItem::smaller<<NotificationItem::inrange;
connect(_dynamicFieldLimit, SIGNAL(currentIndexChanged(QString)), 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)),
this, SLOT(on_changedIndex_rangeValue(QString))); this, SLOT(on_changedIndex_rangeValue(QString)));
} }
addDynamicFieldWidget(objField); addDynamicFieldWidget(objField);
} }
@ -295,16 +314,16 @@ void NotifyPluginOptionsPage::addDynamicFieldWidget(UAVObjectField* objField)
break; break;
default: default:
Q_ASSERT(_dynamicFieldLimit); Q_ASSERT(_dynamicFieldCondition);
if (_dynamicFieldLimit->currentText() == cStrInRange) { if (_dynamicFieldCondition->currentText() == cStrInRange) {
_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;");
(static_cast<QLineEdit*>(_dynamicFieldWidget))->setText("0000000000"); (static_cast<QLineEdit*>(_dynamicFieldWidget))->setText("0000000000");
(static_cast<QLineEdit*>(_dynamicFieldWidget))->setCursorPosition(0); (static_cast<QLineEdit*>(_dynamicFieldWidget))->setCursorPosition(0);
} else { } else {
_dynamicFieldWidget = new QDoubleSpinBox(_form); _dynamicFieldWidget = new QDoubleSpinBox(_form);
(dynamic_cast<QDoubleSpinBox*>(_dynamicFieldWidget))->setRange(000.00, 999.99); (dynamic_cast<QDoubleSpinBox*>(_dynamicFieldWidget))->setRange(-999.99, 999.99);
} }
break; break;
}; };
@ -351,7 +370,8 @@ void NotifyPluginOptionsPage::getOptionsPageValues(NotificationItem* notificatio
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->currentText());
notification->setRange(_dynamicFieldLimit->currentText()); notification->setCondition(_dynamicFieldCondition->itemData(_dynamicFieldCondition->currentIndex()).toInt());
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 {
@ -360,7 +380,7 @@ void NotifyPluginOptionsPage::getOptionsPageValues(NotificationItem* notificatio
else { else {
if (QLineEdit* rangeValue = dynamic_cast<QLineEdit*>(_dynamicFieldWidget)) { if (QLineEdit* rangeValue = dynamic_cast<QLineEdit*>(_dynamicFieldWidget)) {
QString str = rangeValue->text(); QString str = rangeValue->text();
QStringList range = str.split('-'); QStringList range = str.split(':');
notification->setSingleValue(range.at(0).toDouble()); notification->setSingleValue(range.at(0).toDouble());
notification->setValueRange2(range.at(1).toDouble()); notification->setValueRange2(range.at(1).toDouble());
} }
@ -435,11 +455,12 @@ 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)
if (-1 != _dynamicFieldLimit->findText(notification->range())) { {
_dynamicFieldLimit->setCurrentIndex(_dynamicFieldLimit->findText(notification->range())); if (_dynamicFieldCondition->itemData(x)==notification->getCondition()) {
_dynamicFieldCondition->setCurrentIndex(x);
}
} }
if (-1 != _sayOrder->findText(notification->getSayOrder())) { if (-1 != _sayOrder->findText(notification->getSayOrder())) {
_sayOrder->setCurrentIndex(_sayOrder->findText(notification->getSayOrder())); _sayOrder->setCurrentIndex(_sayOrder->findText(notification->getSayOrder()));
} }
@ -505,6 +526,7 @@ void NotifyPluginOptionsPage::on_changedIndex_soundLanguage(int index)
_optionsPage->Sound1->clear(); _optionsPage->Sound1->clear();
_optionsPage->Sound2->clear(); _optionsPage->Sound2->clear();
_optionsPage->Sound3->clear(); _optionsPage->Sound3->clear();
_optionsPage->Sound1->addItem("");
_optionsPage->Sound1->addItems(listSoundFiles); _optionsPage->Sound1->addItems(listSoundFiles);
_optionsPage->Sound2->addItem(""); _optionsPage->Sound2->addItem("");
_optionsPage->Sound2->addItems(listSoundFiles); _optionsPage->Sound2->addItems(listSoundFiles);

View File

@ -152,7 +152,7 @@ private:
QScopedPointer<Ui::NotifyPluginOptionsPage> _optionsPage; QScopedPointer<Ui::NotifyPluginOptionsPage> _optionsPage;
//! Widget to convinient selection of condition for field value (equal, lower, greater) //! Widget to convinient selection of condition for field value (equal, lower, greater)
QComboBox* _dynamicFieldLimit; QComboBox* _dynamicFieldCondition;
//! Represents edit widget for dynamic UAVObjectfield, //! Represents edit widget for dynamic UAVObjectfield,
//! can be spinbox - for numerics, combobox - enums, or //! can be spinbox - for numerics, combobox - enums, or