diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index f88bf0c..46652a2 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -306,7 +306,7 @@ MainWindow::MainWindow(std::shared_ptr logStream_, QWidget *paren initStringBox( OPTION("addressbook","defaulturl",[]{return "";}), uiSettings->addressbookDefaultURLLineEdit); initStringBox( OPTION("addressbook","subscriptions",[]{return "";}), uiSettings->addressbookSubscriptionsURLslineEdit); - initUIntBox( OPTION("limits","transittunnels",[]{return "2500";}), uiSettings->maxNumOfTransitTunnelsLineEdit, tr("maxNumberOfTransitTunnels")); + initULongBox( OPTION("limits","transittunnels",[]{return "2500";}), uiSettings->maxNumOfTransitTunnelsLineEdit, tr("maxNumberOfTransitTunnels")); initUInt16Box( OPTION("limits","openfiles",[]{return "0";}), uiSettings->maxNumOfOpenFilesLineEdit, tr("maxNumberOfOpenFiles")); initUInt32Box( OPTION("limits","coresize",[]{return "0";}), uiSettings->coreFileMaxSizeNumberLineEdit, tr("coreFileMaxSize")); @@ -709,8 +709,8 @@ void MainWindow::initCheckBox(ConfigOption option, QCheckBox* checkBox) { void MainWindow::initIntegerBox(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated){ configItems.append(new IntegerStringItem(option, numberLineEdit, fieldNameTranslated, this)); } -void MainWindow::initUIntBox(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated){ - configItems.append(new UIntStringItem(option, numberLineEdit, fieldNameTranslated, this)); +void MainWindow::initULongBox(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated){ + configItems.append(new ULongStringItem(option, numberLineEdit, fieldNameTranslated, this)); } void MainWindow::initUInt32Box(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated){ configItems.append(new UInt32StringItem(option, numberLineEdit, fieldNameTranslated, this)); diff --git a/src/mainwindow.h b/src/mainwindow.h index 2f7b2c2..b40fddc 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -160,6 +160,8 @@ public: out << boost::any_cast(optionValue); }else if(isType(optionValue)) { out << boost::any_cast(optionValue); + }if(isType(optionValue)) { + out << boost::any_cast(optionValue); }else if(isType(optionValue)) { out << boost::any_cast(optionValue); }else out << boost::any_cast(optionValue); //let it throw @@ -332,22 +334,28 @@ public: virtual QString toString(){return QString::number(boost::any_cast(optionValue));} virtual boost::any fromString(QString s){return boost::any(std::stoi(s.toStdString()));} }; -class UIntStringItem : public BaseFormattedStringItem { +class ULongStringItem : public BaseFormattedStringItem { public: - UIntStringItem(ConfigOption option_, QLineEdit* lineEdit_, QString fieldNameTranslated_, MainWindow* mw) : + ULongStringItem(ConfigOption option_, QLineEdit* lineEdit_, QString fieldNameTranslated_, MainWindow* mw) : BaseFormattedStringItem(option_, lineEdit_, fieldNameTranslated_, - QApplication::tr("Must be a valid integer."), mw) {} - virtual ~UIntStringItem(){} + QApplication::tr("Must be a valid long integer."), mw) {} + virtual ~ULongStringItem(){} 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); + str.toULong(&ok); return ok; } - virtual QString toString(){return QString::number(boost::any_cast(optionValue));} + virtual QString toString(){ + if(isType(optionValue)) + return QString::number(boost::any_cast(optionValue)); + else + return QString::number(boost::any_cast(optionValue)); + + } virtual boost::any fromString(QString s){return boost::any(std::stoul(s.toStdString()));} }; class UShortStringItem : public BaseFormattedStringItem { @@ -563,7 +571,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 initULongBox(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);