Browse Source

Perfectionism fix + kostylik

pull/106/head
nonlin-lin-chaos-order-etc-etal 1 month ago
parent
commit
5deca93d53
  1. 6
      src/mainwindow.cpp
  2. 22
      src/mainwindow.h

6
src/mainwindow.cpp

@ -306,7 +306,7 @@ MainWindow::MainWindow(std::shared_ptr<std::iostream> logStream_, QWidget *paren
initStringBox( OPTION("addressbook","defaulturl",[]{return "";}), uiSettings->addressbookDefaultURLLineEdit); initStringBox( OPTION("addressbook","defaulturl",[]{return "";}), uiSettings->addressbookDefaultURLLineEdit);
initStringBox( OPTION("addressbook","subscriptions",[]{return "";}), uiSettings->addressbookSubscriptionsURLslineEdit); 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")); initUInt16Box( OPTION("limits","openfiles",[]{return "0";}), uiSettings->maxNumOfOpenFilesLineEdit, tr("maxNumberOfOpenFiles"));
initUInt32Box( OPTION("limits","coresize",[]{return "0";}), uiSettings->coreFileMaxSizeNumberLineEdit, tr("coreFileMaxSize")); 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){ void MainWindow::initIntegerBox(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated){
configItems.append(new IntegerStringItem(option, numberLineEdit, fieldNameTranslated, this)); configItems.append(new IntegerStringItem(option, numberLineEdit, fieldNameTranslated, this));
} }
void MainWindow::initUIntBox(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated){ void MainWindow::initULongBox(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated){
configItems.append(new UIntStringItem(option, numberLineEdit, fieldNameTranslated, this)); configItems.append(new ULongStringItem(option, numberLineEdit, fieldNameTranslated, this));
} }
void MainWindow::initUInt32Box(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated){ void MainWindow::initUInt32Box(ConfigOption option, QLineEdit* numberLineEdit, QString fieldNameTranslated){
configItems.append(new UInt32StringItem(option, numberLineEdit, fieldNameTranslated, this)); configItems.append(new UInt32StringItem(option, numberLineEdit, fieldNameTranslated, this));

22
src/mainwindow.h

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

Loading…
Cancel
Save