mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2024-11-15 10:05:47 +08:00
moved some functions
This commit is contained in:
parent
f01a198b7b
commit
231ee02087
@ -20,6 +20,7 @@
|
||||
|
||||
#include "jkqtcommon/jkqtpstringtools.h"
|
||||
#include "jkqtcommon/jkqtpmathtools.h"
|
||||
#include <QDateTime>
|
||||
#include <cmath>
|
||||
#include <QDebug>
|
||||
#include <QSet>
|
||||
@ -649,3 +650,190 @@ QString jkqtp_floattohtmlqstr(double data, int past_comma, bool remove_trail0, d
|
||||
{
|
||||
return QString::fromStdString(jkqtp_floattohtmlstr(data, past_comma, remove_trail0, belowIsZero, minNoExponent, maxNoExponent));
|
||||
}
|
||||
|
||||
|
||||
QString jkVariantListToString(const QList<QVariant>& data, const QString& separator) {
|
||||
QString r="";
|
||||
QLocale loc=QLocale::c();
|
||||
loc.setNumberOptions(QLocale::OmitGroupSeparator);
|
||||
for (int i=0; i<data.size(); i++) {
|
||||
if (i>0) r=r+separator;
|
||||
QVariant v=data[i];
|
||||
#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0))
|
||||
if (v.typeId()==QMetaType::Bool) r=r+loc.toString(v.toBool());
|
||||
else if (v.typeId()==QMetaType::Char) r=r+loc.toString(v.toInt());
|
||||
else if (v.typeId()==QMetaType::QDate) r=r+loc.toString(v.toDate());
|
||||
else if (v.typeId()==QMetaType::QDateTime) r=r+loc.toString(v.toDateTime());
|
||||
else if (v.typeId()==QMetaType::Double) r=r+loc.toString(v.toDouble());
|
||||
else if (v.typeId()==QMetaType::Int) r=r+loc.toString(v.toInt());
|
||||
else if (v.typeId()==QMetaType::LongLong) r=r+loc.toString(v.toLongLong());
|
||||
else if (v.typeId()==QMetaType::QString) r=r+QString("\"%1\"").arg(v.toString().replace("\"", "_").replace("\t", " ").replace("\r", "").replace("\n", " ").replace(",", " ").replace(";", " "));
|
||||
else if (v.typeId()==QMetaType::QTime) r=r+loc.toString(v.toTime());
|
||||
else if (v.typeId()==QMetaType::UInt) r=r+loc.toString(v.toUInt());
|
||||
else if (v.typeId()==QMetaType::ULongLong) r=r+loc.toString(v.toULongLong());
|
||||
else r=r+v.toString();
|
||||
|
||||
#else
|
||||
switch (v.type()) {
|
||||
|
||||
case QVariant::Bool: r=r+loc.toString(v.toBool()); break;
|
||||
case QVariant::Char: r=r+loc.toString(v.toInt()); break;
|
||||
case QVariant::Date: r=r+loc.toString(v.toDate()); break;
|
||||
case QVariant::DateTime: r=r+loc.toString(v.toDateTime()); break;
|
||||
case QVariant::Double: r=r+loc.toString(v.toDouble()); break;
|
||||
case QVariant::Int: r=r+loc.toString(v.toInt()); break;
|
||||
case QVariant::LongLong: r=r+loc.toString(v.toLongLong()); break;
|
||||
case QVariant::String: r=r+QString("\"%1\"").arg(v.toString().replace("\"", "_").replace("\t", " ").replace("\r", "").replace("\n", " ").replace(",", " ").replace(";", " ")); break;
|
||||
case QVariant::Time: r=r+loc.toString(v.toTime()); break;
|
||||
case QVariant::UInt: r=r+loc.toString(v.toUInt()); break;
|
||||
case QVariant::ULongLong: r=r+loc.toString(v.toULongLong()); break;
|
||||
//case : r=r+loc.toString(v.); break;
|
||||
default: r=r+v.toString(); break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
JKQTCOMMON_LIB_EXPORT QString jkqtp_filenameize(const QString& data) {
|
||||
QString r;
|
||||
QString data1=data.simplified();
|
||||
for (int i=0; i<data1.size(); i++) {
|
||||
#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0))
|
||||
const auto c=data1[i];
|
||||
#else
|
||||
QCharRef c=data1[i];
|
||||
#endif
|
||||
if (c.isLetterOrNumber() || (c=='-') || (c=='_') || (c=='.')) {
|
||||
r+=c;
|
||||
} else {
|
||||
r+='_';
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
QString jkqtp_toValidVariableName(const QString& input) {
|
||||
QString out="";
|
||||
for (int i=0; i<input.size(); i++) {
|
||||
if (input[i].isLetter()) out=out+input[i];
|
||||
if (input[i].isDigit()&&(out.size()>0)) out=out+input[i];
|
||||
if ((input[i]=='_')&&(out.size()>0)) out=out+input[i];
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
QString jkqtp_KeyboardModifiers2String(Qt::KeyboardModifiers modifiers, bool useNONE)
|
||||
{
|
||||
if (modifiers==Qt::NoModifier) {
|
||||
if (useNONE) return "NONE";
|
||||
else return "";
|
||||
}
|
||||
QString ret="";
|
||||
auto append=[](QString& ret, const QString & appending, const QString& separator="+") {
|
||||
if (appending.size()<=0) return;
|
||||
if (ret.size()>0) ret+=separator;
|
||||
ret+=appending;
|
||||
};
|
||||
if ((modifiers&Qt::ShiftModifier)==Qt::ShiftModifier) append(ret, "SHIFT", "+");
|
||||
if ((modifiers&Qt::ControlModifier)==Qt::ControlModifier) append(ret, "CTRL", "+");
|
||||
if ((modifiers&Qt::AltModifier)==Qt::AltModifier) append(ret, "ALT", "+");
|
||||
if ((modifiers&Qt::MetaModifier)==Qt::MetaModifier) append(ret, "META", "+");
|
||||
if ((modifiers&Qt::KeypadModifier)==Qt::KeypadModifier) append(ret, "KEYPAD", "+");
|
||||
if ((modifiers&Qt::GroupSwitchModifier)==Qt::GroupSwitchModifier) append(ret, "GROUP", "+");
|
||||
return ret;
|
||||
}
|
||||
|
||||
Qt::KeyboardModifiers jkqtp_String2KeyboardModifiers(const QString &modifiers)
|
||||
{
|
||||
auto mods=modifiers.toUpper().split("+");
|
||||
Qt::KeyboardModifiers ret=Qt::NoModifier;
|
||||
|
||||
for (const auto& m: mods) {
|
||||
if (m.trimmed()=="SHIFT") ret |= Qt::ShiftModifier;
|
||||
else if (m.trimmed()=="CTRL") ret |= Qt::ControlModifier;
|
||||
else if (m.trimmed()=="ALT") ret |= Qt::AltModifier;
|
||||
else if (m.trimmed()=="META") ret |= Qt::MetaModifier;
|
||||
else if (m.trimmed()=="KEYPAD") ret |= Qt::KeypadModifier;
|
||||
else if (m.trimmed()=="GROUP") ret |= Qt::GroupSwitchModifier;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
QString jkqtp_MouseButton2String(Qt::MouseButton button, bool useNONE)
|
||||
{
|
||||
if (button==Qt::NoButton) {
|
||||
if (useNONE) return "NONE";
|
||||
else return "";
|
||||
}
|
||||
if (button==Qt::LeftButton) return "LEFT";
|
||||
if (button==Qt::RightButton) return "RIGHT";
|
||||
#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0))
|
||||
if (button==Qt::MiddleButton) return "MIDDLE";
|
||||
#else
|
||||
if (button==Qt::MidButton) return "MIDDLE";
|
||||
#endif
|
||||
if (button==Qt::BackButton) return "BACK";
|
||||
if (button==Qt::ForwardButton) return "FORWARD";
|
||||
if (button==Qt::TaskButton) return "TASK";
|
||||
if (button==Qt::ExtraButton4) return "EXTRA4";
|
||||
if (button==Qt::ExtraButton5) return "EXTRA5";
|
||||
if (button==Qt::ExtraButton6) return "EXTRA6";
|
||||
if (button==Qt::ExtraButton7) return "EXTRA7";
|
||||
if (button==Qt::ExtraButton8) return "EXTRA8";
|
||||
if (button==Qt::ExtraButton9) return "EXTRA9";
|
||||
if (button==Qt::ExtraButton10) return "EXTRA10";
|
||||
if (button==Qt::ExtraButton11) return "EXTRA11";
|
||||
if (button==Qt::ExtraButton12) return "EXTRA12";
|
||||
if (button==Qt::ExtraButton13) return "EXTRA13";
|
||||
if (button==Qt::ExtraButton14) return "EXTRA14";
|
||||
if (button==Qt::ExtraButton15) return "EXTRA15";
|
||||
if (button==Qt::ExtraButton16) return "EXTRA16";
|
||||
if (button==Qt::ExtraButton17) return "EXTRA17";
|
||||
if (button==Qt::ExtraButton18) return "EXTRA18";
|
||||
if (button==Qt::ExtraButton19) return "EXTRA19";
|
||||
if (button==Qt::ExtraButton20) return "EXTRA20";
|
||||
if (button==Qt::ExtraButton21) return "EXTRA21";
|
||||
if (button==Qt::ExtraButton22) return "EXTRA22";
|
||||
if (button==Qt::ExtraButton23) return "EXTRA23";
|
||||
if (button==Qt::ExtraButton24) return "EXTRA24";
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
Qt::MouseButton jkqtp_String2MouseButton(const QString &button)
|
||||
{
|
||||
auto but=button.toUpper().trimmed();
|
||||
if (but=="LEFT") return Qt::LeftButton;
|
||||
if (but=="RIGHT") return Qt::RightButton;
|
||||
#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0))
|
||||
if (but=="MIDDLE") return Qt::MiddleButton;
|
||||
#else
|
||||
if (but=="MIDDLE") return Qt::MidButton;
|
||||
#endif
|
||||
if (but=="BACK") return Qt::BackButton;
|
||||
if (but=="FORWARD") return Qt::ForwardButton;
|
||||
if (but=="TASK") return Qt::TaskButton;
|
||||
if (but=="EXTRA4") return Qt::ExtraButton4;
|
||||
if (but=="EXTRA5") return Qt::ExtraButton5;
|
||||
if (but=="EXTRA6") return Qt::ExtraButton6;
|
||||
if (but=="EXTRA7") return Qt::ExtraButton7;
|
||||
if (but=="EXTRA8") return Qt::ExtraButton8;
|
||||
if (but=="EXTRA9") return Qt::ExtraButton9;
|
||||
if (but=="EXTRA10") return Qt::ExtraButton10;
|
||||
if (but=="EXTRA11") return Qt::ExtraButton11;
|
||||
if (but=="EXTRA12") return Qt::ExtraButton12;
|
||||
if (but=="EXTRA13") return Qt::ExtraButton13;
|
||||
if (but=="EXTRA14") return Qt::ExtraButton14;
|
||||
if (but=="EXTRA15") return Qt::ExtraButton15;
|
||||
if (but=="EXTRA16") return Qt::ExtraButton16;
|
||||
if (but=="EXTRA17") return Qt::ExtraButton17;
|
||||
if (but=="EXTRA18") return Qt::ExtraButton18;
|
||||
if (but=="EXTRA19") return Qt::ExtraButton19;
|
||||
if (but=="EXTRA20") return Qt::ExtraButton20;
|
||||
if (but=="EXTRA21") return Qt::ExtraButton21;
|
||||
if (but=="EXTRA22") return Qt::ExtraButton22;
|
||||
if (but=="EXTRA23") return Qt::ExtraButton23;
|
||||
if (but=="EXTRA24") return Qt::ExtraButton24;
|
||||
return Qt::NoButton;
|
||||
}
|
||||
|
@ -239,6 +239,52 @@ JKQTCOMMON_LIB_EXPORT QString jkqtp_floattohtmlqstr(double data, int past_comma=
|
||||
JKQTCOMMON_LIB_EXPORT std::string jkqtp_chartostr(char data);
|
||||
|
||||
|
||||
/*! \brief convert a QList<QVariant> to a string
|
||||
\ingroup jkqtptools_string
|
||||
|
||||
*/
|
||||
JKQTCOMMON_LIB_EXPORT QString jkVariantListToString(const QList<QVariant>& data, const QString& separator=QString(", "));
|
||||
|
||||
|
||||
/*! \brief filename-ize a string, i.e. replace every non-number and non-character (and also not <code> _ -</code>) character to \c _
|
||||
\ingroup jkqtptools_string */
|
||||
JKQTCOMMON_LIB_EXPORT QString jkqtp_filenameize(const QString& data);
|
||||
|
||||
/** \brief create a valid variable name from the string, i.e. a string with only characters and digits and \c '_'. ALso the first character has to be a charcter.
|
||||
* \ingroup jkqtptools_string */
|
||||
JKQTCOMMON_LIB_EXPORT QString jkqtp_toValidVariableName(const QString& input);
|
||||
|
||||
/** \brief convert a <a href="http://doc.qt.io/qt-5/qt.html#KeyboardModifier-enum">Qt::KeyboardModifiers</a> to a <a href="http://doc.qt.io/qt-5/qstring.html">QString</a>
|
||||
* \ingroup jkqtptools_string
|
||||
*
|
||||
* \param modifiers the object to convert
|
||||
* \param useNONE if \c true the function will return \c "NONE" if \c modifiers==Qt::NoMofifiers. Otherwise the function will return an empty string ( jkqtp_String2KeyboardModifiers() can cope with both variants)
|
||||
*
|
||||
* \see jkqtp_String2KeyboardModifiers()
|
||||
*/
|
||||
JKQTCOMMON_LIB_EXPORT QString jkqtp_KeyboardModifiers2String(Qt::KeyboardModifiers modifiers, bool useNONE=true);
|
||||
|
||||
/** \brief convert a <a href="http://doc.qt.io/qt-5/qstring.html">QString</a> (created by jkqtp_KeyboardModifiers2String() ) to <a href="http://doc.qt.io/qt-5/qt.html#KeyboardModifier-enum">Qt::KeyboardModifiers</a>
|
||||
* \ingroup jkqtptools_string
|
||||
*
|
||||
* \see jkqtp_KeyboardModifiers2String()
|
||||
*/
|
||||
JKQTCOMMON_LIB_EXPORT Qt::KeyboardModifiers jkqtp_String2KeyboardModifiers(const QString& modifiers);
|
||||
/** \brief convert a <a href="http://doc.qt.io/qt-5/qt.html#MouseButton-enum">Qt::MouseButton</a> to a <a href="http://doc.qt.io/qt-5/qstring.html">QString</a>
|
||||
* \ingroup jkqtptools_string
|
||||
*
|
||||
* \param button the object to convert
|
||||
* \param useNONE if \c true the function will return \c "NONE" if \c button==Qt::NoButton. Otherwise the function will return an empty string ( jkqtp_String2MouseButton() can cope with both variants)
|
||||
*
|
||||
* \see jkqtp_MouseButton2String()
|
||||
*/
|
||||
JKQTCOMMON_LIB_EXPORT QString jkqtp_MouseButton2String(Qt::MouseButton button, bool useNONE=true);
|
||||
/** \brief convert a <a href="http://doc.qt.io/qt-5/qstring.html">QString</a> (created by jkqtp_MouseButton2String() ) to <a href="http://doc.qt.io/qt-5/qt.html#MouseButton-enum">Qt::MouseButton</a>
|
||||
* \ingroup jkqtptools_string
|
||||
*
|
||||
* \see jkqtp_MouseButton2String()
|
||||
*/
|
||||
JKQTCOMMON_LIB_EXPORT Qt::MouseButton jkqtp_String2MouseButton(const QString &button);
|
||||
|
||||
|
||||
#endif // JKQTPSTRINGTOOLS_H_INCLUDED
|
||||
|
@ -83,192 +83,6 @@ void jkloadSplitter(QSettings& settings, QSplitter* splitter, const QString& pre
|
||||
splitter->restoreState(settings.value(prefix+"splitter_sizes").toByteArray());
|
||||
}
|
||||
|
||||
QString jkVariantListToString(const QList<QVariant>& data, const QString& separator) {
|
||||
QString r="";
|
||||
QLocale loc=QLocale::c();
|
||||
loc.setNumberOptions(QLocale::OmitGroupSeparator);
|
||||
for (int i=0; i<data.size(); i++) {
|
||||
if (i>0) r=r+separator;
|
||||
QVariant v=data[i];
|
||||
#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0))
|
||||
if (v.typeId()==QMetaType::Bool) r=r+loc.toString(v.toBool());
|
||||
else if (v.typeId()==QMetaType::Char) r=r+loc.toString(v.toInt());
|
||||
else if (v.typeId()==QMetaType::QDate) r=r+loc.toString(v.toDate());
|
||||
else if (v.typeId()==QMetaType::QDateTime) r=r+loc.toString(v.toDateTime());
|
||||
else if (v.typeId()==QMetaType::Double) r=r+loc.toString(v.toDouble());
|
||||
else if (v.typeId()==QMetaType::Int) r=r+loc.toString(v.toInt());
|
||||
else if (v.typeId()==QMetaType::LongLong) r=r+loc.toString(v.toLongLong());
|
||||
else if (v.typeId()==QMetaType::QString) r=r+QString("\"%1\"").arg(v.toString().replace("\"", "_").replace("\t", " ").replace("\r", "").replace("\n", " ").replace(",", " ").replace(";", " "));
|
||||
else if (v.typeId()==QMetaType::QTime) r=r+loc.toString(v.toTime());
|
||||
else if (v.typeId()==QMetaType::UInt) r=r+loc.toString(v.toUInt());
|
||||
else if (v.typeId()==QMetaType::ULongLong) r=r+loc.toString(v.toULongLong());
|
||||
else r=r+v.toString();
|
||||
|
||||
#else
|
||||
switch (v.type()) {
|
||||
|
||||
case QVariant::Bool: r=r+loc.toString(v.toBool()); break;
|
||||
case QVariant::Char: r=r+loc.toString(v.toInt()); break;
|
||||
case QVariant::Date: r=r+loc.toString(v.toDate()); break;
|
||||
case QVariant::DateTime: r=r+loc.toString(v.toDateTime()); break;
|
||||
case QVariant::Double: r=r+loc.toString(v.toDouble()); break;
|
||||
case QVariant::Int: r=r+loc.toString(v.toInt()); break;
|
||||
case QVariant::LongLong: r=r+loc.toString(v.toLongLong()); break;
|
||||
case QVariant::String: r=r+QString("\"%1\"").arg(v.toString().replace("\"", "_").replace("\t", " ").replace("\r", "").replace("\n", " ").replace(",", " ").replace(";", " ")); break;
|
||||
case QVariant::Time: r=r+loc.toString(v.toTime()); break;
|
||||
case QVariant::UInt: r=r+loc.toString(v.toUInt()); break;
|
||||
case QVariant::ULongLong: r=r+loc.toString(v.toULongLong()); break;
|
||||
//case : r=r+loc.toString(v.); break;
|
||||
default: r=r+v.toString(); break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
JKQTCOMMON_LIB_EXPORT QString jkqtp_filenameize(const QString& data) {
|
||||
QString r;
|
||||
QString data1=data.simplified();
|
||||
for (int i=0; i<data1.size(); i++) {
|
||||
#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0))
|
||||
const auto c=data1[i];
|
||||
#else
|
||||
QCharRef c=data1[i];
|
||||
#endif
|
||||
if (c.isLetterOrNumber() || (c=='-') || (c=='_') || (c=='.')) {
|
||||
r+=c;
|
||||
} else {
|
||||
r+='_';
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
QString jkqtp_toValidVariableName(const QString& input) {
|
||||
QString out="";
|
||||
for (int i=0; i<input.size(); i++) {
|
||||
if (input[i].isLetter()) out=out+input[i];
|
||||
if (input[i].isDigit()&&(out.size()>0)) out=out+input[i];
|
||||
if ((input[i]=='_')&&(out.size()>0)) out=out+input[i];
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
QString jkqtp_KeyboardModifiers2String(Qt::KeyboardModifiers modifiers, bool useNONE)
|
||||
{
|
||||
if (modifiers==Qt::NoModifier) {
|
||||
if (useNONE) return "NONE";
|
||||
else return "";
|
||||
}
|
||||
QString ret="";
|
||||
auto append=[](QString& ret, const QString & appending, const QString& separator="+") {
|
||||
if (appending.size()<=0) return;
|
||||
if (ret.size()>0) ret+=separator;
|
||||
ret+=appending;
|
||||
};
|
||||
if ((modifiers&Qt::ShiftModifier)==Qt::ShiftModifier) append(ret, "SHIFT", "+");
|
||||
if ((modifiers&Qt::ControlModifier)==Qt::ControlModifier) append(ret, "CTRL", "+");
|
||||
if ((modifiers&Qt::AltModifier)==Qt::AltModifier) append(ret, "ALT", "+");
|
||||
if ((modifiers&Qt::MetaModifier)==Qt::MetaModifier) append(ret, "META", "+");
|
||||
if ((modifiers&Qt::KeypadModifier)==Qt::KeypadModifier) append(ret, "KEYPAD", "+");
|
||||
if ((modifiers&Qt::GroupSwitchModifier)==Qt::GroupSwitchModifier) append(ret, "GROUP", "+");
|
||||
return ret;
|
||||
}
|
||||
|
||||
Qt::KeyboardModifiers jkqtp_String2KeyboardModifiers(const QString &modifiers)
|
||||
{
|
||||
auto mods=modifiers.toUpper().split("+");
|
||||
Qt::KeyboardModifiers ret=Qt::NoModifier;
|
||||
|
||||
for (const auto& m: mods) {
|
||||
if (m.trimmed()=="SHIFT") ret |= Qt::ShiftModifier;
|
||||
else if (m.trimmed()=="CTRL") ret |= Qt::ControlModifier;
|
||||
else if (m.trimmed()=="ALT") ret |= Qt::AltModifier;
|
||||
else if (m.trimmed()=="META") ret |= Qt::MetaModifier;
|
||||
else if (m.trimmed()=="KEYPAD") ret |= Qt::KeypadModifier;
|
||||
else if (m.trimmed()=="GROUP") ret |= Qt::GroupSwitchModifier;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
QString jkqtp_MouseButton2String(Qt::MouseButton button, bool useNONE)
|
||||
{
|
||||
if (button==Qt::NoButton) {
|
||||
if (useNONE) return "NONE";
|
||||
else return "";
|
||||
}
|
||||
if (button==Qt::LeftButton) return "LEFT";
|
||||
if (button==Qt::RightButton) return "RIGHT";
|
||||
#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0))
|
||||
if (button==Qt::MiddleButton) return "MIDDLE";
|
||||
#else
|
||||
if (button==Qt::MidButton) return "MIDDLE";
|
||||
#endif
|
||||
if (button==Qt::BackButton) return "BACK";
|
||||
if (button==Qt::ForwardButton) return "FORWARD";
|
||||
if (button==Qt::TaskButton) return "TASK";
|
||||
if (button==Qt::ExtraButton4) return "EXTRA4";
|
||||
if (button==Qt::ExtraButton5) return "EXTRA5";
|
||||
if (button==Qt::ExtraButton6) return "EXTRA6";
|
||||
if (button==Qt::ExtraButton7) return "EXTRA7";
|
||||
if (button==Qt::ExtraButton8) return "EXTRA8";
|
||||
if (button==Qt::ExtraButton9) return "EXTRA9";
|
||||
if (button==Qt::ExtraButton10) return "EXTRA10";
|
||||
if (button==Qt::ExtraButton11) return "EXTRA11";
|
||||
if (button==Qt::ExtraButton12) return "EXTRA12";
|
||||
if (button==Qt::ExtraButton13) return "EXTRA13";
|
||||
if (button==Qt::ExtraButton14) return "EXTRA14";
|
||||
if (button==Qt::ExtraButton15) return "EXTRA15";
|
||||
if (button==Qt::ExtraButton16) return "EXTRA16";
|
||||
if (button==Qt::ExtraButton17) return "EXTRA17";
|
||||
if (button==Qt::ExtraButton18) return "EXTRA18";
|
||||
if (button==Qt::ExtraButton19) return "EXTRA19";
|
||||
if (button==Qt::ExtraButton20) return "EXTRA20";
|
||||
if (button==Qt::ExtraButton21) return "EXTRA21";
|
||||
if (button==Qt::ExtraButton22) return "EXTRA22";
|
||||
if (button==Qt::ExtraButton23) return "EXTRA23";
|
||||
if (button==Qt::ExtraButton24) return "EXTRA24";
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
Qt::MouseButton jkqtp_String2MouseButton(const QString &button)
|
||||
{
|
||||
auto but=button.toUpper().trimmed();
|
||||
if (but=="LEFT") return Qt::LeftButton;
|
||||
if (but=="RIGHT") return Qt::RightButton;
|
||||
#if (QT_VERSION>=QT_VERSION_CHECK(6, 0, 0))
|
||||
if (but=="MIDDLE") return Qt::MiddleButton;
|
||||
#else
|
||||
if (but=="MIDDLE") return Qt::MidButton;
|
||||
#endif
|
||||
if (but=="BACK") return Qt::BackButton;
|
||||
if (but=="FORWARD") return Qt::ForwardButton;
|
||||
if (but=="TASK") return Qt::TaskButton;
|
||||
if (but=="EXTRA4") return Qt::ExtraButton4;
|
||||
if (but=="EXTRA5") return Qt::ExtraButton5;
|
||||
if (but=="EXTRA6") return Qt::ExtraButton6;
|
||||
if (but=="EXTRA7") return Qt::ExtraButton7;
|
||||
if (but=="EXTRA8") return Qt::ExtraButton8;
|
||||
if (but=="EXTRA9") return Qt::ExtraButton9;
|
||||
if (but=="EXTRA10") return Qt::ExtraButton10;
|
||||
if (but=="EXTRA11") return Qt::ExtraButton11;
|
||||
if (but=="EXTRA12") return Qt::ExtraButton12;
|
||||
if (but=="EXTRA13") return Qt::ExtraButton13;
|
||||
if (but=="EXTRA14") return Qt::ExtraButton14;
|
||||
if (but=="EXTRA15") return Qt::ExtraButton15;
|
||||
if (but=="EXTRA16") return Qt::ExtraButton16;
|
||||
if (but=="EXTRA17") return Qt::ExtraButton17;
|
||||
if (but=="EXTRA18") return Qt::ExtraButton18;
|
||||
if (but=="EXTRA19") return Qt::ExtraButton19;
|
||||
if (but=="EXTRA20") return Qt::ExtraButton20;
|
||||
if (but=="EXTRA21") return Qt::ExtraButton21;
|
||||
if (but=="EXTRA22") return Qt::ExtraButton22;
|
||||
if (but=="EXTRA23") return Qt::ExtraButton23;
|
||||
if (but=="EXTRA24") return Qt::ExtraButton24;
|
||||
return Qt::NoButton;
|
||||
}
|
||||
|
||||
quint16 jkqtp_checksum(const void *data, size_t len)
|
||||
{
|
||||
#if QT_VERSION>=QT_VERSION_CHECK(6,0,0)
|
||||
|
@ -88,54 +88,8 @@ JKQTCOMMON_LIB_EXPORT void jksaveSplitter(QSettings& settings, QSplitter* splitt
|
||||
JKQTCOMMON_LIB_EXPORT void jkloadSplitter(QSettings& settings, QSplitter* splitter, const QString& prefix=QString(""));
|
||||
|
||||
|
||||
/*! \brief convert a QList<QVariant> to a string
|
||||
\ingroup jkqtpjkqtptools_qt
|
||||
|
||||
*/
|
||||
JKQTCOMMON_LIB_EXPORT QString jkVariantListToString(const QList<QVariant>& data, const QString& separator=QString(", "));
|
||||
|
||||
|
||||
/*! \brief filename-ize a string, i.e. replace every non-number and non-character (and also not <code> _ -</code>) character to \c _
|
||||
\ingroup tools */
|
||||
JKQTCOMMON_LIB_EXPORT QString jkqtp_filenameize(const QString& data);
|
||||
|
||||
/** \brief create a valid variable name from the string, i.e. a string with only characters and digits and \c '_'. ALso the first character has to be a charcter.
|
||||
* \ingroup tools */
|
||||
JKQTCOMMON_LIB_EXPORT QString jkqtp_toValidVariableName(const QString& input);
|
||||
|
||||
/** \brief convert a <a href="http://doc.qt.io/qt-5/qt.html#KeyboardModifier-enum">Qt::KeyboardModifiers</a> to a <a href="http://doc.qt.io/qt-5/qstring.html">QString</a>
|
||||
* \ingroup tools
|
||||
*
|
||||
* \param modifiers the object to convert
|
||||
* \param useNONE if \c true the function will return \C "NONE" if \c modifiers==Qt::NoMofifiers. Otherwise the function will return an empty string ( jkqtp_String2KeyboardModifiers() can cope with both variants)
|
||||
*
|
||||
* \see jkqtp_String2KeyboardModifiers()
|
||||
*/
|
||||
JKQTCOMMON_LIB_EXPORT QString jkqtp_KeyboardModifiers2String(Qt::KeyboardModifiers modifiers, bool useNONE=true);
|
||||
|
||||
/** \brief convert a <a href="http://doc.qt.io/qt-5/qstring.html">QString</a> (created by jkqtp_KeyboardModifiers2String() ) to <a href="http://doc.qt.io/qt-5/qt.html#KeyboardModifier-enum">Qt::KeyboardModifiers</a>
|
||||
* \ingroup tools
|
||||
*
|
||||
* \see jkqtp_KeyboardModifiers2String()
|
||||
*/
|
||||
JKQTCOMMON_LIB_EXPORT Qt::KeyboardModifiers jkqtp_String2KeyboardModifiers(const QString& modifiers);
|
||||
/** \brief convert a <a href="http://doc.qt.io/qt-5/qt.html#MouseButton-enum">Qt::MouseButton</a> to a <a href="http://doc.qt.io/qt-5/qstring.html">QString</a>
|
||||
* \ingroup tools
|
||||
*
|
||||
* \param button the object to convert
|
||||
* \param useNONE if \c true the function will return \C "NONE" if \c button==Qt::NoButton. Otherwise the function will return an empty string ( jkqtp_String2MouseButton() can cope with both variants)
|
||||
*
|
||||
* \see jkqtp_MouseButton2String()
|
||||
*/
|
||||
JKQTCOMMON_LIB_EXPORT QString jkqtp_MouseButton2String(Qt::MouseButton button, bool useNONE=true);
|
||||
/** \brief convert a <a href="http://doc.qt.io/qt-5/qstring.html">QString</a> (created by jkqtp_MouseButton2String() ) to <a href="http://doc.qt.io/qt-5/qt.html#MouseButton-enum">Qt::MouseButton</a>
|
||||
* \ingroup tools
|
||||
*
|
||||
* \see jkqtp_MouseButton2String()
|
||||
*/
|
||||
JKQTCOMMON_LIB_EXPORT Qt::MouseButton jkqtp_String2MouseButton(const QString &button);
|
||||
/** \brief convert a <a href="http://doc.qt.io/qt-5/qstring.html">QString</a> (created by jkqtp_MouseButton2String() ) to <a href="http://doc.qt.io/qt-5/qt.html#MouseButton-enum">Qt::MouseButton</a>
|
||||
* \ingroup tools
|
||||
* \ingroup jkqtptools_general
|
||||
*
|
||||
* \see jkqtp_MouseButton2String()
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user