Skip to content

Commit 758301b

Browse files
authored
Merge pull request #106 from nonlin-lin-chaos-order-etc-etal/nonl_patch
Perfectionism fix + kostylik
2 parents 183e320 + 5deca93 commit 758301b

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

src/mainwindow.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ MainWindow::MainWindow(std::shared_ptr<std::iostream> logStream_, QWidget *paren
306306
initStringBox( OPTION("addressbook","defaulturl",[]{return "";}), uiSettings->addressbookDefaultURLLineEdit);
307307
initStringBox( OPTION("addressbook","subscriptions",[]{return "";}), uiSettings->addressbookSubscriptionsURLslineEdit);
308308

309-
initUIntBox( OPTION("limits","transittunnels",[]{return "2500";}), uiSettings->maxNumOfTransitTunnelsLineEdit, tr("maxNumberOfTransitTunnels"));
309+
initULongBox( OPTION("limits","transittunnels",[]{return "2500";}), uiSettings->maxNumOfTransitTunnelsLineEdit, tr("maxNumberOfTransitTunnels"));
310310
initUInt16Box( OPTION("limits","openfiles",[]{return "0";}), uiSettings->maxNumOfOpenFilesLineEdit, tr("maxNumberOfOpenFiles"));
311311
initUInt32Box( OPTION("limits","coresize",[]{return "0";}), uiSettings->coreFileMaxSizeNumberLineEdit, tr("coreFileMaxSize"));
312312

@@ -709,8 +709,8 @@ void MainWindow::initCheckBox(ConfigOption option, QCheckBox* checkBox) {
709709
void MainWindow::initIntegerBox(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated){
710710
configItems.append(new IntegerStringItem(option, numberLineEdit, fieldNameTranslated, this));
711711
}
712-
void MainWindow::initUIntBox(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated){
713-
configItems.append(new UIntStringItem(option, numberLineEdit, fieldNameTranslated, this));
712+
void MainWindow::initULongBox(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated){
713+
configItems.append(new ULongStringItem(option, numberLineEdit, fieldNameTranslated, this));
714714
}
715715
void MainWindow::initUInt32Box(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated){
716716
configItems.append(new UInt32StringItem(option, numberLineEdit, fieldNameTranslated, this));

src/mainwindow.h

+15-7
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ class MainWindowItem : public QObject {
160160
out << boost::any_cast<int>(optionValue);
161161
}else if(isType<unsigned long>(optionValue)) {
162162
out << boost::any_cast<unsigned long>(optionValue);
163+
}if(isType<unsigned int>(optionValue)) {
164+
out << boost::any_cast<unsigned int>(optionValue);
163165
}else if(isType<unsigned short>(optionValue)) {
164166
out << boost::any_cast<unsigned short>(optionValue);
165167
}else out << boost::any_cast<std::string>(optionValue); //let it throw
@@ -332,22 +334,28 @@ class IntegerStringItem : public BaseFormattedStringItem {
332334
virtual QString toString(){return QString::number(boost::any_cast<int>(optionValue));}
333335
virtual boost::any fromString(QString s){return boost::any(std::stoi(s.toStdString()));}
334336
};
335-
class UIntStringItem : public BaseFormattedStringItem {
337+
class ULongStringItem : public BaseFormattedStringItem {
336338
public:
337-
UIntStringItem(ConfigOption option_, QLineEdit* lineEdit_, QString fieldNameTranslated_, MainWindow* mw) :
339+
ULongStringItem(ConfigOption option_, QLineEdit* lineEdit_, QString fieldNameTranslated_, MainWindow* mw) :
338340
BaseFormattedStringItem(option_, lineEdit_, fieldNameTranslated_,
339-
QApplication::tr("Must be a valid integer."), mw) {}
340-
virtual ~UIntStringItem(){}
341+
QApplication::tr("Must be a valid long integer."), mw) {}
342+
virtual ~ULongStringItem(){}
341343
virtual bool isValid(bool & alreadyDisplayedIfWrong){
342344
bool correct = BaseFormattedStringItem::isValid(alreadyDisplayedIfWrong);
343345
if(!correct)return false;
344346
alreadyDisplayedIfWrong = false;
345347
auto str=lineEdit->text();
346348
bool ok;
347-
str.toUInt(&ok);
349+
str.toULong(&ok);
348350
return ok;
349351
}
350-
virtual QString toString(){return QString::number(boost::any_cast<unsigned int>(optionValue));}
352+
virtual QString toString(){
353+
if(isType<unsigned int>(optionValue))
354+
return QString::number(boost::any_cast<unsigned int>(optionValue));
355+
else
356+
return QString::number(boost::any_cast<unsigned long>(optionValue));
357+
358+
}
351359
virtual boost::any fromString(QString s){return boost::any(std::stoul(s.toStdString()));}
352360
};
353361
class UShortStringItem : public BaseFormattedStringItem {
@@ -563,7 +571,7 @@ public slots:
563571
void initTCPPortBox(ConfigOption option, QLineEdit* portLineEdit, QString fieldNameTranslated);
564572
void initCheckBox(ConfigOption option, QCheckBox* checkBox);
565573
void initIntegerBox(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated);
566-
void initUIntBox(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated);
574+
void initULongBox(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated);
567575
void initUInt32Box(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated);
568576
void initUInt16Box(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated);
569577
void initStringBox(ConfigOption option, QLineEdit* lineEdit);

0 commit comments

Comments
 (0)