|
From: <cn...@us...> - 2022-12-04 19:51:15
|
Revision: 1316
http://sourceforge.net/p/seq/svn/1316
Author: cn187
Date: 2022-12-04 19:51:14 +0000 (Sun, 04 Dec 2022)
Log Message:
-----------
Fix prefs issues with saving/restoring/toggling message filters
Modified Paths:
--------------
showeq/branches/cn187_devel/src/interface.cpp
showeq/branches/cn187_devel/src/xmlconv.cpp
showeq/branches/cn187_devel/src/xmlpreferences.cpp
Modified: showeq/branches/cn187_devel/src/interface.cpp
===================================================================
--- showeq/branches/cn187_devel/src/interface.cpp 2022-11-30 03:49:18 UTC (rev 1315)
+++ showeq/branches/cn187_devel/src/interface.cpp 2022-12-04 19:51:14 UTC (rev 1316)
@@ -5536,6 +5536,10 @@
void EQInterface::toggleTypeFilter(QAction* type)
{
+
+ if (type->text() == "&Enable All" || type->text() == "&Disable All")
+ return;
+
uint64_t enabledTypes = m_terminal->enabledTypes();
int id = type->data().value<int>();
@@ -5560,7 +5564,7 @@
for (int i = MT_Guild; i <= MT_Max; i++)
{
typeName = MessageEntry::messageTypeString((MessageType)i);
- if (!typeName.isEmpty())
+ if (!typeName.isEmpty() && m_action_term_MessageTypeFilters[i])
m_action_term_MessageTypeFilters[i]->setChecked(false);
}
}
@@ -5581,6 +5585,10 @@
void EQInterface::toggleShowUserFilter(QAction* filter)
{
+
+ if (filter->text() == "&Enable All" || filter->text() == "&Disable All")
+ return;
+
uint32_t enabledShowUserFilters = m_terminal->enabledShowUserFilters();
int id = filter->data().value<int>();
@@ -5627,6 +5635,9 @@
void EQInterface::toggleHideUserFilter(QAction* filter)
{
+ if (filter->text() == "&Enable All" || filter->text() == "&Disable All")
+ return;
+
uint32_t enabledHideUserFilters = m_terminal->enabledHideUserFilters();
int id = filter->data().value<int>();
Modified: showeq/branches/cn187_devel/src/xmlconv.cpp
===================================================================
--- showeq/branches/cn187_devel/src/xmlconv.cpp 2022-11-30 03:49:18 UTC (rev 1315)
+++ showeq/branches/cn187_devel/src/xmlconv.cpp 2022-12-04 19:51:14 UTC (rev 1316)
@@ -288,53 +288,14 @@
{
QString value = e.attribute("value");
- // borrowed more or less from Qt 3.2 (since we have to support older)
- uint64_t val = 0;
- const QChar* p = value.unicode();
- int l = value.length();
- const uint64_t max_mult = UINT64_MAX / 16;
- if (!p)
- {
- qWarning("Invalid value for tag: %s", e.tagName().toLatin1().data());
- return false;
- }
+ uint64_t tmp = value.toULongLong(&ok, 16);
- while ( l && p->isSpace() ) // skip leading space
- l--,p++;
- if ( !l )
- return false;
- if ( *p == '+' )
- l--,p++;
-
- if ( !l || !ok_in_hex(*p) )
+ if (!ok)
return false;
- while ( l && ok_in_hex(*p) )
- {
- l--;
- uint dv;
- if ( p->isDigit() )
- dv = p->digitValue();
- else
- {
- if ( *p >= 'a' && *p <= 'f' )
- dv = p->toLatin1() - 'a' + 10;
- else
- dv = p->toLatin1() - 'A' + 10;
- }
- if ( val > max_mult || (val == max_mult && dv > UINT64_MAX % 16) )
- return false;
- val = 16 * val + dv;
- p++;
- }
- //fromRawData() creates a reference to the existing data
- QByteArray ba_ref = QByteArray::fromRawData((const char*)&val, sizeof(uint64_t));
- //so we make a (deep) copy
- QByteArray ba = ba_ref;
+ v.setValue(tmp);
- v = ba;
- ok = true;
}
else if (e.tagName() == "list")
{
@@ -360,27 +321,55 @@
switch (v.type())
{
- case QVariant::String:
+ case QMetaType::QString:
e.setTagName("string");
e.setAttribute("value", v.toString().toUtf8().data());
break;
- case QVariant::Int:
+ case QMetaType::Int:
e.setTagName("int");
e.setAttribute("value", v.toInt());
break;
- case QVariant::UInt:
+ case QMetaType::UInt:
e.setTagName("uint");
e.setAttribute("value", v.toUInt());
break;
- case QVariant::Double:
+ case QMetaType::Long:
+ case QMetaType::LongLong:
+ {
+ e.setTagName("int64");
+ QString val;
+#if (QT_VERSION >= QT_VERSION_CHECK(5,5,0))
+ val = QString::asprintf("%0.16x", v.toLongLong());
+#else
+ val = v.toLongLong();
+ val.sprintf("%0.16x", v.toLongLong());
+#endif
+ e.setAttribute("value", val);
+ break;
+ }
+ case QMetaType::ULong:
+ case QMetaType::ULongLong:
+ {
+ e.setTagName("uint64");
+ QString val;
+#if (QT_VERSION >= QT_VERSION_CHECK(5,5,0))
+ val = QString::asprintf("%0.16x", v.toULongLong());
+#else
+ val = v.toULongLong();
+ val.sprintf("%0.16x", v.toULongLong());
+#endif
+ e.setAttribute("value", val);
+ break;
+ }
+ case QMetaType::Double:
e.setTagName("double");
e.setAttribute("value", v.toDouble());
break;
- case QVariant::Bool:
+ case QMetaType::Bool:
e.setTagName("bool");
e.setAttribute("value", boolString(v.toBool()));
break;
- case QVariant::Color:
+ case QMetaType::QColor:
{
e.setTagName("color");
QColor color = v.value<QColor>();
@@ -389,7 +378,7 @@
e.setAttribute("blue", color.blue());
}
break;
- case QVariant::Pen:
+ case QMetaType::QPen:
{
e.setTagName("pen");
QPen pen = v.value<QPen>();
@@ -401,7 +390,7 @@
e.setAttribute("join", pen.joinStyle());
}
break;
- case QVariant::Brush:
+ case QMetaType::QBrush:
{
e.setTagName("brush");
QBrush brush = v.value<QBrush>();
@@ -411,7 +400,7 @@
e.setAttribute("style", brush.style());
}
break;
- case QVariant::Point:
+ case QMetaType::QPoint:
{
e.setTagName("point");
QPoint point = v.toPoint();
@@ -419,7 +408,7 @@
e.setAttribute("y", point.y());
}
break;
- case QVariant::Rect:
+ case QMetaType::QRect:
{
e.setTagName("rect");
QRect rect = v.toRect();
@@ -429,7 +418,7 @@
e.setAttribute("height", rect.height());
}
break;
- case QVariant::Size:
+ case QMetaType::QSize:
{
e.setTagName("size");
QSize qsize = v.toSize();
@@ -437,7 +426,7 @@
e.setAttribute("height", qsize.height());
}
break;
- case QVariant::Font:
+ case QMetaType::QFont:
{
e.setTagName("font");
QFont f(v.value<QFont>());
@@ -449,7 +438,7 @@
e.setAttribute("strikeout", boolString(f.strikeOut()));
}
break;
- case QVariant::SizePolicy:
+ case QMetaType::QSizePolicy:
{
e.setTagName("sizepolicy");
QSizePolicy sp(v.value<QSizePolicy>());
@@ -459,12 +448,12 @@
e.setAttribute("verstretch", sp.verticalStretch());
}
break;
- case QVariant::Cursor:
+ case QMetaType::QCursor:
e.setTagName("cursor");
e.setAttribute("shape", v.value<QCursor>().shape());
break;
- case QVariant::StringList:
+ case QMetaType::QStringList:
{
e.setTagName("stringlist");
uint j;
@@ -515,50 +504,11 @@
}
break;
- case QVariant::KeySequence:
+ case QMetaType::QKeySequence:
e.setTagName("key");
e.setAttribute("sequence", (QString)v.value<QKeySequence>().toString());
break;
- case QVariant::ByteArray: // this is only for [u]int64_t
- {
- e.setTagName("uint64");
- QByteArray ba = v.toByteArray();
-
- // make sure this only handles [u]int64_t's
- if (ba.size() != sizeof(uint64_t))
- {
- qWarning("Don't know how to persist variant of type: %s (%d) (size=%d)!",
- v.typeName(), v.type(), ba.size());
- ok = false;
- break;
- }
-
- // convert the data back into a uint64_t
- uint64_t num = *(uint64_t*)ba.data();
-
- QChar buff[33];
- QChar* p = &buff[32];
- const char* digitSet = "0123456789abcdef";
- int len = 0;
-
- // construct the string
- do
- {
- *--p = digitSet[((int)(num%16))];
- num = num >> 4; // divide by 16
- len++;
- } while ( num );
-
- // store it in a QString
- QString storage;
- storage.setUnicode(p, len);
-
- // set the value
- e.setAttribute("value", storage);
- }
- break;
-
#if 0
case QVariant::List:
case QVaraint::Map:
Modified: showeq/branches/cn187_devel/src/xmlpreferences.cpp
===================================================================
--- showeq/branches/cn187_devel/src/xmlpreferences.cpp 2022-11-30 03:49:18 UTC (rev 1315)
+++ showeq/branches/cn187_devel/src/xmlpreferences.cpp 2022-12-04 19:51:14 UTC (rev 1316)
@@ -750,31 +750,35 @@
switch(preference->type())
{
- case QVariant::String:
- // convert it to a int64_t (in base 16)
+ case QMetaType::QString:
+ // convert it to a uint64_t (in base 16)
+ //TODO ok
value = strtoll(preference->toString().toLatin1().data(), 0, 16);
break;
- case QVariant::Int:
- case QVariant::UInt:
- value = preference->toInt();
+ case QMetaType::UInt:
+ case QMetaType::Int:
+ case QMetaType::Long:
+ case QMetaType::ULong:
+ case QMetaType::ULongLong:
+ case QMetaType::LongLong:
+
+ value = preference->toLongLong();
break;
- case QVariant::Double:
+ case QMetaType::Double:
value = int64_t(preference->toDouble());
break;
- case QVariant::ByteArray:
- {
- QByteArray ba = preference->toByteArray();
- if (ba.size() == sizeof(int64_t))
- value = *(int64_t*)ba.data();
- break;
- }
+
default:
- qWarning("XMLPreferences::getPrefInt64(%s, %s, %lld): preference found,\n"
+ qWarning("XMLPreferences::getPrefInt64(%s, %s, %llu): preference found,\n"
"\tbut type %s is not convertable to type int64_t!",
- inName.toLatin1().data(), inSection.toLatin1().data(), (long long)def,
+ inName.toLatin1().data(), inSection.toLatin1().data(),
+ (unsigned long long)def,
preference->typeName());
- }
+ value=def;
+ break;
+ } //end switch
+
// return the key
return value;
}
@@ -798,24 +802,24 @@
switch(preference->type())
{
- case QVariant::String:
+ case QMetaType::QString:
// convert it to a uint64_t (in base 16)
+ // TODO ok
value = strtoull(preference->toString().toLatin1().data(), 0, 16);
break;
- case QVariant::Int:
- case QVariant::UInt:
- value = preference->toInt();
+ case QMetaType::UInt:
+ case QMetaType::Int:
+ case QMetaType::Long:
+ case QMetaType::ULong:
+ case QMetaType::ULongLong:
+ case QMetaType::LongLong:
+
+ value = preference->toULongLong();
break;
- case QVariant::Double:
+ case QMetaType::Double:
value = uint64_t(preference->toDouble());
break;
- case QVariant::ByteArray:
- {
- QByteArray ba = preference->toByteArray();
- if (ba.size() == sizeof(uint64_t))
- value = *(uint64_t*)ba.data();
- break;
- }
+
default:
qWarning("XMLPreferences::getPrefUInt64(%s, %s, %llu): preference found,\n"
"\tbut type %s is not convertable to type uint64_t!",
@@ -822,8 +826,11 @@
inName.toLatin1().data(), inSection.toLatin1().data(),
(unsigned long long)def,
preference->typeName());
- }
+ value=def;
+ break;
+ } //end switch
+
// return the key
return value;
}
@@ -895,9 +902,9 @@
int64_t inValue,
Persistence pers)
{
- QByteArray ba_ref = QByteArray::fromRawData((const char*)&inValue, sizeof(int64_t));
- QByteArray ba = ba_ref;
- setPref(inName, inSection, ba, pers);
+ QVariant tmp;
+ tmp.setValue(inValue);
+ setPref(inName, inSection, tmp, pers);
}
@@ -906,9 +913,9 @@
uint64_t inValue,
Persistence pers)
{
- QByteArray ba_ref = QByteArray::fromRawData((const char*)&inValue, sizeof(uint64_t));
- QByteArray ba = ba_ref;
- setPref(inName, inSection, ba, pers);
+ QVariant tmp;
+ tmp.setValue(inValue);
+ setPref(inName, inSection, tmp, pers);
}
void XMLPreferences::setPrefVariant(const QString& inName,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|