- fix: mainwindow action's short cut doesn't work, if the action is not in menu or toolbar

- fix: when run all cases for a problem, processing of output is slow
This commit is contained in:
Roy Qu 2022-01-28 00:31:11 +08:00
parent f298cc7b47
commit 002f9d4805
7 changed files with 28 additions and 52 deletions

View File

@ -6,6 +6,7 @@ Red Panda C++ Version 0.14.0
- fix: code folding calcuation not correct when some codes are folded and editing after them
- enhancement: code completion ui redesigned
- fix: mainwindow action's short cut doesn't work, if the action is not in menu or toolbar
- fix: when run all cases for a problem, processing of output is slow
Red Panda C++ Version 0.13.4
- fix: when copy comments, don't auto indent

View File

@ -325,7 +325,7 @@ void CompilerManager::runProblem(const QString &filename, const QString &argumen
connect(mRunner, &Runner::runErrorOccurred, pMainWindow ,&MainWindow::onRunErrorOccured);
connect(execRunner, &OJProblemCasesRunner::caseStarted, pMainWindow, &MainWindow::onOJProblemCaseStarted);
connect(execRunner, &OJProblemCasesRunner::caseFinished, pMainWindow, &MainWindow::onOJProblemCaseFinished);
connect(execRunner, &OJProblemCasesRunner::newOutputLineGetted, pMainWindow, &MainWindow::onOJProblemCaseNewOutputLineGetted);
connect(execRunner, &OJProblemCasesRunner::newOutputGetted, pMainWindow, &MainWindow::onOJProblemCaseNewOutputGetted);
mRunner->start();
}

View File

@ -79,10 +79,10 @@ void OJProblemCasesRunner::runCase(int index,POJProblemCase problemCase)
}
QByteArray readed;
QByteArray buffer;
QStringList outputLines;
QByteArray output;
while (true) {
process.waitForFinished(100);
readed = process.readAll();
readed = process.read(5001);
buffer += readed;
if (process.state()!=QProcess::Running) {
break;
@ -97,30 +97,15 @@ void OJProblemCasesRunner::runCase(int index,POJProblemCase problemCase)
}
if (errorOccurred)
break;
QList<QByteArray> lines = splitByteArrayToLines(buffer);
// qDebug()<<"----do buffer----";
// qDebug()<<readed;
// qDebug()<<buffer;
// qDebug()<<lines.count();
if (lines.count()>=2) {
for (int i=0;i<lines.count()-1;i++) {
QString line = QString::fromLocal8Bit(lines[i]);
emit newOutputLineGetted(problemCase->getId(),line);
outputLines.append(line);
}
buffer = lines.last();
while (buffer.endsWith('\0')) {
buffer.remove(buffer.length()-1,1);
}
if (buffer.length()>5000) {
emit newOutputGetted(problemCase->getId(),QString::fromLocal8Bit(buffer));
output.append(buffer);
buffer.clear();
}
}
buffer += process.readAll();
QList<QByteArray> lines = splitByteArrayToLines(buffer);
for (int i=0;i<lines.count();i++) {
QString line = QString::fromLocal8Bit(lines[i]);
emit newOutputLineGetted(problemCase->getId(),line);
outputLines.append(line);
}
if (process.state() == QProcess::ProcessState::NotRunning)
buffer += process.readAll();
output.append(buffer);
if (errorOccurred) {
//qDebug()<<"process error:"<<process.error();
switch (process.error()) {
@ -144,7 +129,7 @@ void OJProblemCasesRunner::runCase(int index,POJProblemCase problemCase)
break;
}
}
problemCase->output = linesToText(outputLines);
problemCase->output = QString::fromLocal8Bit(output);
}
void OJProblemCasesRunner::run()

View File

@ -32,7 +32,7 @@ public:
signals:
void caseStarted(const QString& id, int current, int total);
void caseFinished(const QString& id, int current, int total);
void newOutputLineGetted(const QString&id, const QString& newOutputLine);
void newOutputGetted(const QString&id, const QString& newOutputLine);
private:
void runCase(int index, POJProblemCase problemCase);
private:

View File

@ -3117,9 +3117,9 @@ void MainWindow::onProblemCaseIndexChanged(const QModelIndex &current, const QMo
POJProblemCase problemCase = mOJProblemModel.getCase(idx.row());
if (problemCase) {
ui->btnRemoveProblemCase->setEnabled(true);
ui->txtProblemCaseInput->setText(problemCase->input);
ui->txtProblemCaseInput->setPlainText(problemCase->input);
ui->txtProblemCaseInput->setReadOnly(false);
ui->txtProblemCaseExpected->setText(problemCase->expected);
ui->txtProblemCaseExpected->setPlainText(problemCase->expected);
ui->txtProblemCaseExpected->setReadOnly(false);
updateProblemCaseOutput(problemCase);
return;
@ -4081,9 +4081,9 @@ void MainWindow::onOJProblemCaseFinished(const QString& id, int current, int tot
updateProblemTitle();
}
void MainWindow::onOJProblemCaseNewOutputLineGetted(const QString &, const QString &line)
void MainWindow::onOJProblemCaseNewOutputGetted(const QString &, const QString &line)
{
ui->txtProblemCaseOutput->append(line);
ui->txtProblemCaseOutput->appendPlainText(line);
}
void MainWindow::cleanUpCPUDialog()
@ -5519,7 +5519,7 @@ void MainWindow::doCompileRun(RunType runType)
void MainWindow::updateProblemCaseOutput(POJProblemCase problemCase)
{
ui->txtProblemCaseOutput->clear();
ui->txtProblemCaseOutput->setText(problemCase->output);
ui->txtProblemCaseOutput->setPlainText(problemCase->output);
if (problemCase->testState == ProblemCaseTestState::Failed) {
QStringList output = textToLines(problemCase->output);
QStringList expected = textToLines(problemCase->expected);
@ -5666,7 +5666,6 @@ void MainWindow::on_actionExport_As_HTML_triggered()
void MainWindow::on_actionMove_To_Other_View_triggered()
{
qDebug()<<"test";
Editor * editor = mEditorList->getEditor();
if (editor) {
mEditorList->swapEditor(editor);

View File

@ -194,7 +194,7 @@ public slots:
void onRunProblemFinished();
void onOJProblemCaseStarted(const QString& id, int current, int total);
void onOJProblemCaseFinished(const QString& id, int current, int total);
void onOJProblemCaseNewOutputLineGetted(const QString& id, const QString& line);
void onOJProblemCaseNewOutputGetted(const QString& id, const QString& line);
void cleanUpCPUDialog();
void onDebugCommandInput(const QString& command);
void onDebugEvaluateInput();

View File

@ -506,7 +506,7 @@
<enum>QTabWidget::South</enum>
</property>
<property name="currentIndex">
<number>5</number>
<number>6</number>
</property>
<property name="iconSize">
<size>
@ -1348,33 +1348,24 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QTextEdit" name="txtProblemCaseInput">
<item row="1" column="1">
<widget class="QPlainTextEdit" name="txtProblemCaseOutput">
<property name="lineWrapMode">
<enum>QTextEdit::NoWrap</enum>
</property>
<property name="acceptRichText">
<bool>false</bool>
<enum>QPlainTextEdit::NoWrap</enum>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QTextEdit" name="txtProblemCaseOutput">
<item row="1" column="0">
<widget class="QPlainTextEdit" name="txtProblemCaseInput">
<property name="lineWrapMode">
<enum>QTextEdit::NoWrap</enum>
</property>
<property name="readOnly">
<bool>true</bool>
<enum>QPlainTextEdit::NoWrap</enum>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QTextEdit" name="txtProblemCaseExpected">
<widget class="QPlainTextEdit" name="txtProblemCaseExpected">
<property name="lineWrapMode">
<enum>QTextEdit::NoWrap</enum>
</property>
<property name="acceptRichText">
<bool>false</bool>
<enum>QPlainTextEdit::NoWrap</enum>
</property>
</widget>
</item>