Skip to content

Commit

Permalink
Merge pull request #106 from nonlin-lin-chaos-order-etc-etal/nonl_patch
Browse files Browse the repository at this point in the history
Perfectionism fix + kostylik
  • Loading branch information
orignal authored Nov 21, 2024
2 parents 183e320 + 5deca93 commit 758301b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ MainWindow::MainWindow(std::shared_ptr<std::iostream> 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"));

Expand Down Expand Up @@ -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));
Expand Down
22 changes: 15 additions & 7 deletions src/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ class MainWindowItem : public QObject {
out << boost::any_cast<int>(optionValue);
}else if(isType<unsigned long>(optionValue)) {
out << boost::any_cast<unsigned long>(optionValue);
}if(isType<unsigned int>(optionValue)) {
out << boost::any_cast<unsigned int>(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
Expand Down Expand Up @@ -332,22 +334,28 @@ class IntegerStringItem : public BaseFormattedStringItem {
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 {
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<unsigned int>(optionValue));}
virtual QString toString(){
if(isType<unsigned int>(optionValue))
return QString::number(boost::any_cast<unsigned int>(optionValue));
else
return QString::number(boost::any_cast<unsigned long>(optionValue));

}
virtual boost::any fromString(QString s){return boost::any(std::stoul(s.toStdString()));}
};
class UShortStringItem : public BaseFormattedStringItem {
Expand Down Expand Up @@ -563,7 +571,7 @@ public slots:
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);
Expand Down

0 comments on commit 758301b

Please sign in to comment.