- enhancement: "Convert HTML for - Input" / "Convert HTML for - Expected" in "Options" - "Executor" - "Problem Set"

- fix: Unit for memory limit is not correctly loaded when open problem properties dialog.
  - enhancement: Auto open the properties dialog, after add a new problem.
This commit is contained in:
Roy Qu 2022-12-24 12:08:13 +08:00
parent 0ce717841b
commit 84b09fe842
11 changed files with 328 additions and 186 deletions

View File

@ -24,6 +24,9 @@ Red Panda C++ Version 2.7
- enhancement: "Show whitespaces" in options / editor / font
- enhancement: Auto add "lib" to the output of static/dynamic library projects, if project name don't start with "lib".
- fix: Makefile error when "Use precompiled header" is enabled in the project option dialog.
- enhancement: "Convert HTML for - Input" / "Convert HTML for - Expected" in "Options" - "Executor" - "Problem Set"
- fix: Unit for memory limit is not correctly loaded when open problem properties dialog.
- enhancement: Auto open the properties dialog, after add a new problem.
Red Panda C++ Version 2.6

View File

@ -4022,8 +4022,18 @@ void MainWindow::onNewProblemConnection()
POJProblemCase problemCase = std::make_shared<OJProblemCase>();
problemCase->testState = ProblemCaseTestState::NotTested;
problemCase->name = tr("Problem Case %1").arg(problem->cases.count()+1);
problemCase->input = caseObj["input"].toString();
problemCase->expected = caseObj["output"].toString();
if (pSettings->executor().convertHTMLToTextForInput()) {
QTextDocument doc;
doc.setHtml(caseObj["input"].toString());
problemCase->input = doc.toPlainText();
} else
problemCase->input = caseObj["input"].toString();
if (pSettings->executor().convertHTMLToTextForExpected()) {
QTextDocument doc;
doc.setHtml(caseObj["output"].toString());
problemCase->expected = doc.toPlainText();
} else
problemCase->expected = caseObj["output"].toString();
problem->cases.append(problemCase);
}
mOJProblemSetModel.addProblem(problem);
@ -7956,6 +7966,7 @@ void MainWindow::onAddProblem()
problem->name = name;
mOJProblemSetModel.addProblem(problem);
ui->lstProblemSet->setCurrentIndex(mOJProblemSetModel.index(mOJProblemSetModel.count()-1));
mProblem_Properties->trigger();
}

View File

@ -58,7 +58,7 @@ size_t OJProblem::getMemoryLimit()
OJProblem::OJProblem() :
timeLimit(0),
memoryLimit(0),
timeLimitUnit(ProblemTimeLimitUnit::Milliseconds),
timeLimitUnit(ProblemTimeLimitUnit::Seconds),
memoryLimitUnit(ProblemMemoryLimitUnit::MB)
{

View File

@ -3634,6 +3634,26 @@ void Settings::Executor::setCaseMemoryLimit(size_t newCaseMemoryLimit)
mCaseMemoryLimit = newCaseMemoryLimit;
}
bool Settings::Executor::convertHTMLToTextForExpected() const
{
return mConvertHTMLToTextForExpected;
}
void Settings::Executor::setConvertHTMLToTextForExpected(bool newConvertHTMLToTextForExpected)
{
mConvertHTMLToTextForExpected = newConvertHTMLToTextForExpected;
}
bool Settings::Executor::convertHTMLToTextForInput() const
{
return mConvertHTMLToTextForInput;
}
void Settings::Executor::setConvertHTMLToTextForInput(bool newConvertHTMLToTextForInput)
{
mConvertHTMLToTextForInput = newConvertHTMLToTextForInput;
}
bool Settings::Executor::enableCaseLimit() const
{
return mEnableCaseLimit;
@ -3696,6 +3716,8 @@ void Settings::Executor::doSave()
saveValue("enable_proble_set", mEnableProblemSet);
saveValue("enable_competivie_companion", mEnableCompetitiveCompanion);
saveValue("competitive_companion_port", mCompetivieCompanionPort);
saveValue("input_convert_html", mConvertHTMLToTextForInput);
saveValue("expected_convert_html", mConvertHTMLToTextForExpected);
saveValue("ignore_spaces_when_validating_cases", mIgnoreSpacesWhenValidatingCases);
saveValue("case_editor_font_name",mCaseEditorFontName);
saveValue("case_editor_font_size",mCaseEditorFontSize);
@ -3728,6 +3750,8 @@ void Settings::Executor::doLoad()
mEnableProblemSet = boolValue("enable_proble_set",true);
mEnableCompetitiveCompanion = boolValue("enable_competivie_companion",true);
mCompetivieCompanionPort = intValue("competitive_companion_port",10045);
mConvertHTMLToTextForInput = boolValue("input_convert_html", false);
mConvertHTMLToTextForExpected = boolValue("expected_convert_html", false);
mIgnoreSpacesWhenValidatingCases = boolValue("ignore_spaces_when_validating_cases",false);
#ifdef Q_OS_WIN
mCaseEditorFontName = stringValue("case_editor_font_name","consolas");

View File

@ -915,6 +915,12 @@ public:
size_t caseMemoryLimit() const;
void setCaseMemoryLimit(size_t newCaseMemoryLimit);
bool convertHTMLToTextForInput() const;
void setConvertHTMLToTextForInput(bool newConvertHTMLToTextForInput);
bool convertHTMLToTextForExpected() const;
void setConvertHTMLToTextForExpected(bool newConvertHTMLToTextForExpected);
private:
// general
bool mPauseConsole;
@ -928,6 +934,8 @@ public:
bool mEnableProblemSet;
bool mEnableCompetitiveCompanion;
int mCompetivieCompanionPort;
bool mConvertHTMLToTextForInput;
bool mConvertHTMLToTextForExpected;
bool mIgnoreSpacesWhenValidatingCases;
QString mCaseEditorFontName;
int mCaseEditorFontSize;

View File

@ -36,6 +36,9 @@ void ExecutorProblemSetWidget::doLoad()
ui->grpProblemSet->setChecked(pSettings->executor().enableProblemSet());
ui->grpCompetitiveCompanion->setChecked(pSettings->executor().enableCompetitiveCompanion());
ui->spinPortNumber->setValue(pSettings->executor().competivieCompanionPort());
ui->chkConvertInputHTML->setChecked(pSettings->executor().convertHTMLToTextForInput());
ui->chkConvertExpectedHTML->setChecked(pSettings->executor().convertHTMLToTextForExpected());
ui->chkIgnoreSpacesWhenValidatingCases->setChecked(pSettings->executor().ignoreSpacesWhenValidatingCases());
ui->cbFont->setCurrentFont(QFont(pSettings->executor().caseEditorFontName()));
@ -52,6 +55,8 @@ void ExecutorProblemSetWidget::doSave()
pSettings->executor().setEnableProblemSet(ui->grpProblemSet->isChecked());
pSettings->executor().setEnableCompetitiveCompanion(ui->grpCompetitiveCompanion->isChecked());
pSettings->executor().setCompetivieCompanionPort(ui->spinPortNumber->value());
pSettings->executor().setConvertHTMLToTextForInput(ui->chkConvertInputHTML->isChecked());
pSettings->executor().setConvertHTMLToTextForExpected(ui->chkConvertExpectedHTML->isChecked());
pSettings->executor().setIgnoreSpacesWhenValidatingCases(ui->chkIgnoreSpacesWhenValidatingCases->isChecked());
pSettings->executor().setCaseEditorFontName(ui->cbFont->currentFont().family());
pSettings->executor().setCaseEditorFontOnlyMonospaced(ui->chkOnlyMonospaced->isChecked());

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>545</width>
<height>445</height>
<height>503</height>
</rect>
</property>
<property name="windowTitle">
@ -42,13 +42,6 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Port Number</string>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer">
<property name="orientation">
@ -62,6 +55,65 @@
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Port Number</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QWidget" name="widget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Convert HTML for</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkConvertInputHTML">
<property name="text">
<string>Input</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="chkConvertExpectedHTML">
<property name="text">
<string>Expected Output</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>

View File

@ -2001,6 +2001,18 @@
<source>kb</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Convert HTML for</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Input</source>
<translation type="unfinished">Entrada</translation>
</message>
<message>
<source>Expected Output</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FileAssociationModel</name>

File diff suppressed because it is too large Load Diff

View File

@ -1870,6 +1870,18 @@
<source>kb</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Convert HTML for</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Input</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Expected Output</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>FileAssociationModel</name>

View File

@ -58,13 +58,13 @@ void OJProblemPropertyWidget::loadFromProblem(POJProblem problem)
}
switch(problem->memoryLimitUnit) {
case ProblemMemoryLimitUnit::KB:
ui->cbTimeLimitUnit->setCurrentText(tr("KB"));
ui->cbMemoryLimitUnit->setCurrentText(tr("KB"));
break;
case ProblemMemoryLimitUnit::MB:
ui->cbTimeLimitUnit->setCurrentText(tr("MB"));
ui->cbMemoryLimitUnit->setCurrentText(tr("MB"));
break;
case ProblemMemoryLimitUnit::GB:
ui->cbTimeLimitUnit->setCurrentText(tr("GB"));
ui->cbMemoryLimitUnit->setCurrentText(tr("GB"));
break;
}
}