|
|
|
@ -158,6 +158,8 @@ public:
@@ -158,6 +158,8 @@ public:
|
|
|
|
|
out << boost::any_cast<uint32_t>(optionValue); |
|
|
|
|
}else if(isType<int>(optionValue)) { |
|
|
|
|
out << boost::any_cast<int>(optionValue); |
|
|
|
|
}else if(isType<unsigned long>(optionValue)) { |
|
|
|
|
out << boost::any_cast<unsigned long>(optionValue); |
|
|
|
|
}else if(isType<unsigned short>(optionValue)) { |
|
|
|
|
out << boost::any_cast<unsigned short>(optionValue); |
|
|
|
|
}else out << boost::any_cast<std::string>(optionValue); //let it throw
|
|
|
|
@ -330,6 +332,24 @@ public:
@@ -330,6 +332,24 @@ public:
|
|
|
|
|
virtual QString toString(){return QString::number(boost::any_cast<int>(optionValue));} |
|
|
|
|
virtual boost::any fromString(QString s){return boost::any(std::stoi(s.toStdString()));} |
|
|
|
|
}; |
|
|
|
|
class UIntStringItem : public BaseFormattedStringItem { |
|
|
|
|
public: |
|
|
|
|
UIntStringItem(ConfigOption option_, QLineEdit* lineEdit_, QString fieldNameTranslated_, MainWindow* mw) : |
|
|
|
|
BaseFormattedStringItem(option_, lineEdit_, fieldNameTranslated_, |
|
|
|
|
QApplication::tr("Must be a valid integer."), mw) {} |
|
|
|
|
virtual ~UIntStringItem(){} |
|
|
|
|
virtual bool isValid(bool & alreadyDisplayedIfWrong){ |
|
|
|
|
bool correct = BaseFormattedStringItem::isValid(alreadyDisplayedIfWrong); |
|
|
|
|
if(!correct)return false; |
|
|
|
|
alreadyDisplayedIfWrong = false; |
|
|
|
|
auto str=lineEdit->text(); |
|
|
|
|
bool ok; |
|
|
|
|
str.toUInt(&ok); |
|
|
|
|
return ok; |
|
|
|
|
} |
|
|
|
|
virtual QString toString(){return QString::number(boost::any_cast<unsigned int>(optionValue));} |
|
|
|
|
virtual boost::any fromString(QString s){return boost::any(std::stoul(s.toStdString()));} |
|
|
|
|
}; |
|
|
|
|
class UShortStringItem : public BaseFormattedStringItem { |
|
|
|
|
public: |
|
|
|
|
UShortStringItem(ConfigOption option_, QLineEdit* lineEdit_, QString fieldNameTranslated_, MainWindow* mw) : |
|
|
|
@ -543,6 +563,7 @@ protected:
@@ -543,6 +563,7 @@ protected:
|
|
|
|
|
void initTCPPortBox(ConfigOption option, QLineEdit* portLineEdit, QString fieldNameTranslated); |
|
|
|
|
void initCheckBox(ConfigOption option, QCheckBox* checkBox); |
|
|
|
|
void initIntegerBox(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated); |
|
|
|
|
void initUIntBox(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated); |
|
|
|
|
void initUInt32Box(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated); |
|
|
|
|
void initUInt16Box(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated); |
|
|
|
|
void initStringBox(ConfigOption option, QLineEdit* lineEdit); |
|
|
|
|