- enhancement: display problem case running time
- enhancement: set problem case input/expected output file - enhancement: auto position cursor in expected with output's cursor
This commit is contained in:
parent
facdb59c66
commit
a1614cef68
3
NEWS.md
3
NEWS.md
|
@ -8,6 +8,9 @@ Red Panda C++ Version 1.0.2
|
||||||
- enhancement: timeout for problem case test
|
- enhancement: timeout for problem case test
|
||||||
- enhancement: slightly reduce start up time
|
- enhancement: slightly reduce start up time
|
||||||
- enhancement: use icon to indicate missing project files in the project view
|
- enhancement: use icon to indicate missing project files in the project view
|
||||||
|
- enhancement: display problem case running time
|
||||||
|
- enhancement: set problem case input/expected output file
|
||||||
|
- enhancement: auto position cursor in expected with output's cursor
|
||||||
|
|
||||||
Red Panda C++ Version 1.0.1
|
Red Panda C++ Version 1.0.1
|
||||||
- fix: only convert project icon file when it's filename doesn't end with ".ico"
|
- fix: only convert project icon file when it's filename doesn't end with ".ico"
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -54,7 +54,11 @@ void OJProblemCasesRunner::runCase(int index,POJProblemCase problemCase)
|
||||||
});
|
});
|
||||||
QProcess process;
|
QProcess process;
|
||||||
bool errorOccurred = false;
|
bool errorOccurred = false;
|
||||||
|
QByteArray readed;
|
||||||
|
QByteArray buffer;
|
||||||
|
QByteArray output;
|
||||||
|
int noOutputTime = 0;
|
||||||
|
QElapsedTimer elapsedTimer;
|
||||||
process.setProgram(mFilename);
|
process.setProgram(mFilename);
|
||||||
process.setArguments(splitProcessCommand(mArguments));
|
process.setArguments(splitProcessCommand(mArguments));
|
||||||
process.setWorkingDirectory(mWorkDir);
|
process.setWorkingDirectory(mWorkDir);
|
||||||
|
@ -84,14 +88,13 @@ void OJProblemCasesRunner::runCase(int index,POJProblemCase problemCase)
|
||||||
process.start();
|
process.start();
|
||||||
process.waitForStarted(5000);
|
process.waitForStarted(5000);
|
||||||
if (process.state()==QProcess::Running) {
|
if (process.state()==QProcess::Running) {
|
||||||
process.write(problemCase->input.toUtf8());
|
if (fileExists(problemCase->inputFileName))
|
||||||
|
process.write(readFileToByteArray(problemCase->inputFileName));
|
||||||
|
else
|
||||||
|
process.write(problemCase->input.toUtf8());
|
||||||
process.closeWriteChannel();
|
process.closeWriteChannel();
|
||||||
}
|
}
|
||||||
QByteArray readed;
|
|
||||||
QByteArray buffer;
|
|
||||||
QByteArray output;
|
|
||||||
int noOutputTime = 0;
|
|
||||||
QElapsedTimer elapsedTimer;
|
|
||||||
elapsedTimer.start();
|
elapsedTimer.start();
|
||||||
while (true) {
|
while (true) {
|
||||||
process.waitForFinished(mWaitForFinishTime);
|
process.waitForFinished(mWaitForFinishTime);
|
||||||
|
@ -127,6 +130,7 @@ void OJProblemCasesRunner::runCase(int index,POJProblemCase problemCase)
|
||||||
noOutputTime += mWaitForFinishTime;
|
noOutputTime += mWaitForFinishTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
problemCase->runningTime=elapsedTimer.elapsed();
|
||||||
if (mExecTimeouted) {
|
if (mExecTimeouted) {
|
||||||
problemCase->output = tr("Case Timeout");
|
problemCase->output = tr("Case Timeout");
|
||||||
emit resetOutput(problemCase->getId(), problemCase->output);
|
emit resetOutput(problemCase->getId(), problemCase->output);
|
||||||
|
|
|
@ -249,7 +249,6 @@ int main(int argc, char *argv[])
|
||||||
// qputenv("QT_DEVICE_PIXEL_RATIO ","auto");
|
// qputenv("QT_DEVICE_PIXEL_RATIO ","auto");
|
||||||
// qputenv("QT_AUTO_SCREEN_SCALE_FACTOR","false");
|
// qputenv("QT_AUTO_SCREEN_SCALE_FACTOR","false");
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
QFile tempFile(QDir::tempPath()+QDir::separator()+"RedPandaDevCppStartUp.lock");
|
QFile tempFile(QDir::tempPath()+QDir::separator()+"RedPandaDevCppStartUp.lock");
|
||||||
{
|
{
|
||||||
|
@ -389,6 +388,7 @@ int main(int argc, char *argv[])
|
||||||
tempFile.close();
|
tempFile.close();
|
||||||
tempFile.remove();
|
tempFile.remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
int retCode = app.exec();
|
int retCode = app.exec();
|
||||||
QString configDir = pSettings->dirs().config();
|
QString configDir = pSettings->dirs().config();
|
||||||
// save settings
|
// save settings
|
||||||
|
|
|
@ -67,7 +67,8 @@
|
||||||
#include <QTextBlock>
|
#include <QTextBlock>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
#include <QFileIconProvider>
|
#include <QFileIconProvider>
|
||||||
#include <MainWindow.h>
|
#include "MainWindow.h"
|
||||||
|
#include <QScrollBar>
|
||||||
|
|
||||||
#include "settingsdialog/settingsdialog.h"
|
#include "settingsdialog/settingsdialog.h"
|
||||||
#include "compiler/compilermanager.h"
|
#include "compiler/compilermanager.h"
|
||||||
|
@ -277,11 +278,11 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
mOJProblemSetNameCounter=1;
|
mOJProblemSetNameCounter=1;
|
||||||
mOJProblemSetModel.rename(tr("Problem Set %1").arg(mOJProblemSetNameCounter));
|
mOJProblemSetModel.rename(tr("Problem Set %1").arg(mOJProblemSetNameCounter));
|
||||||
ui->lstProblemSet->setModel(&mOJProblemSetModel);
|
ui->lstProblemSet->setModel(&mOJProblemSetModel);
|
||||||
ui->lstProblemCases->setModel(&mOJProblemModel);
|
ui->tblProblemCases->setModel(&mOJProblemModel);
|
||||||
connect(ui->lstProblemSet->selectionModel(),
|
connect(ui->lstProblemSet->selectionModel(),
|
||||||
&QItemSelectionModel::currentRowChanged,
|
&QItemSelectionModel::currentRowChanged,
|
||||||
this, &MainWindow::onProblemSetIndexChanged);
|
this, &MainWindow::onProblemSetIndexChanged);
|
||||||
connect(ui->lstProblemCases->selectionModel(),
|
connect(ui->tblProblemCases->selectionModel(),
|
||||||
&QItemSelectionModel::currentRowChanged,
|
&QItemSelectionModel::currentRowChanged,
|
||||||
this, &MainWindow::onProblemCaseIndexChanged);
|
this, &MainWindow::onProblemCaseIndexChanged);
|
||||||
connect(&mOJProblemSetModel, &OJProblemSetModel::problemNameChanged,
|
connect(&mOJProblemSetModel, &OJProblemSetModel::problemNameChanged,
|
||||||
|
@ -1382,6 +1383,11 @@ void MainWindow::updateActionIcons()
|
||||||
pIconsManager->setIcon(ui->btnRunAllProblemCases, IconsManager::ACTION_PROBLEM_RUN_CASES);
|
pIconsManager->setIcon(ui->btnRunAllProblemCases, IconsManager::ACTION_PROBLEM_RUN_CASES);
|
||||||
pIconsManager->setIcon(ui->btnCaseValidateOptions, IconsManager::ACTION_MISC_GEAR);
|
pIconsManager->setIcon(ui->btnCaseValidateOptions, IconsManager::ACTION_MISC_GEAR);
|
||||||
|
|
||||||
|
pIconsManager->setIcon(ui->btnProblemCaseClearInputFileName, IconsManager::ACTION_MISC_CLEAN);
|
||||||
|
pIconsManager->setIcon(ui->btnProblemCaseInputFileName, IconsManager::ACTION_MISC_FOLDER);
|
||||||
|
pIconsManager->setIcon(ui->btnProblemCaseClearExpectedOutputFileName, IconsManager::ACTION_MISC_CLEAN);
|
||||||
|
pIconsManager->setIcon(ui->btnProblemCaseExpectedOutputFileName, IconsManager::ACTION_MISC_FOLDER);
|
||||||
|
|
||||||
mProblem_Properties->setIcon(pIconsManager->getIcon(IconsManager::ACTION_PROBLEM_PROPERTIES));
|
mProblem_Properties->setIcon(pIconsManager->getIcon(IconsManager::ACTION_PROBLEM_PROPERTIES));
|
||||||
|
|
||||||
|
|
||||||
|
@ -1559,7 +1565,7 @@ void MainWindow::runExecutable(const QString &exeName,const QString &filename,Ru
|
||||||
ui->tabMessages->setCurrentWidget(ui->tabProblem);
|
ui->tabMessages->setCurrentWidget(ui->tabProblem);
|
||||||
}
|
}
|
||||||
} else if (runType == RunType::CurrentProblemCase) {
|
} else if (runType == RunType::CurrentProblemCase) {
|
||||||
QModelIndex index = ui->lstProblemCases->currentIndex();
|
QModelIndex index = ui->tblProblemCases->currentIndex();
|
||||||
if (index.isValid()) {
|
if (index.isValid()) {
|
||||||
POJProblemCase problemCase =mOJProblemModel.getCase(index.row());
|
POJProblemCase problemCase =mOJProblemModel.getCase(index.row());
|
||||||
mCompilerManager->runProblem(exeName,params,QFileInfo(exeName).absolutePath(),
|
mCompilerManager->runProblem(exeName,params,QFileInfo(exeName).absolutePath(),
|
||||||
|
@ -3141,7 +3147,7 @@ void MainWindow::onProblemSetIndexChanged(const QModelIndex ¤t, const QMod
|
||||||
mOJProblemModel.setProblem(problem);
|
mOJProblemModel.setProblem(problem);
|
||||||
updateProblemTitle();
|
updateProblemTitle();
|
||||||
if (mOJProblemModel.count()>0) {
|
if (mOJProblemModel.count()>0) {
|
||||||
ui->lstProblemCases->setCurrentIndex(mOJProblemModel.index(0,0));
|
ui->tblProblemCases->setCurrentIndex(mOJProblemModel.index(0,0));
|
||||||
} else {
|
} else {
|
||||||
onProblemCaseIndexChanged(QModelIndex(),QModelIndex());
|
onProblemCaseIndexChanged(QModelIndex(),QModelIndex());
|
||||||
}
|
}
|
||||||
|
@ -3163,18 +3169,32 @@ void MainWindow::onProblemCaseIndexChanged(const QModelIndex ¤t, const QMo
|
||||||
if (idx.isValid()) {
|
if (idx.isValid()) {
|
||||||
POJProblemCase problemCase = mOJProblemModel.getCase(idx.row());
|
POJProblemCase problemCase = mOJProblemModel.getCase(idx.row());
|
||||||
if (problemCase) {
|
if (problemCase) {
|
||||||
|
ui->btnProblemCaseInputFileName->setEnabled(false);
|
||||||
|
ui->txtProblemCaseInputFileName->setEnabled(false);
|
||||||
ui->btnRemoveProblemCase->setEnabled(true);
|
ui->btnRemoveProblemCase->setEnabled(true);
|
||||||
ui->txtProblemCaseInput->setPlainText(problemCase->input);
|
ui->btnProblemCaseInputFileName->setEnabled(true);
|
||||||
ui->txtProblemCaseInput->setReadOnly(false);
|
fillProblemCaseInputAndExpected(problemCase);
|
||||||
ui->txtProblemCaseExpected->setPlainText(problemCase->expected);
|
|
||||||
ui->txtProblemCaseExpected->setReadOnly(false);
|
|
||||||
ui->txtProblemCaseOutput->clear();
|
ui->txtProblemCaseOutput->clear();
|
||||||
ui->txtProblemCaseOutput->setPlainText(problemCase->output);
|
ui->txtProblemCaseOutput->setPlainText(problemCase->output);
|
||||||
updateProblemCaseOutput(problemCase);
|
updateProblemCaseOutput(problemCase);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ui->btnProblemCaseClearInputFileName->setVisible(false);
|
||||||
|
ui->btnProblemCaseInputFileName->setEnabled(false);
|
||||||
|
ui->txtProblemCaseInputFileName->setEnabled(false);
|
||||||
|
ui->txtProblemCaseInputFileName->clear();
|
||||||
|
ui->txtProblemCaseInputFileName->setToolTip("");
|
||||||
|
|
||||||
|
ui->btnProblemCaseClearExpectedOutputFileName->setVisible(false);
|
||||||
|
ui->btnProblemCaseExpectedOutputFileName->setEnabled(false);
|
||||||
|
ui->txtProblemCaseExpectedOutputFileName->setEnabled(false);
|
||||||
|
ui->txtProblemCaseExpectedOutputFileName->clear();
|
||||||
|
ui->txtProblemCaseExpectedOutputFileName->setToolTip("");
|
||||||
|
|
||||||
ui->btnRemoveProblemCase->setEnabled(false);
|
ui->btnRemoveProblemCase->setEnabled(false);
|
||||||
|
ui->txtProblemCaseInputFileName->clear();
|
||||||
|
ui->btnProblemCaseInputFileName->setEnabled(false);
|
||||||
ui->txtProblemCaseInput->clear();
|
ui->txtProblemCaseInput->clear();
|
||||||
ui->txtProblemCaseInput->setReadOnly(true);
|
ui->txtProblemCaseInput->setReadOnly(true);
|
||||||
ui->txtProblemCaseExpected->clear();
|
ui->txtProblemCaseExpected->clear();
|
||||||
|
@ -4606,9 +4626,9 @@ void MainWindow::onOJProblemCaseStarted(const QString& id,int current, int total
|
||||||
POJProblemCase problemCase = mOJProblemModel.getCase(row);
|
POJProblemCase problemCase = mOJProblemModel.getCase(row);
|
||||||
problemCase->testState = ProblemCaseTestState::Testing;
|
problemCase->testState = ProblemCaseTestState::Testing;
|
||||||
mOJProblemModel.update(row);
|
mOJProblemModel.update(row);
|
||||||
QModelIndex idx = ui->lstProblemCases->currentIndex();
|
QModelIndex idx = ui->tblProblemCases->currentIndex();
|
||||||
if (!idx.isValid() || row != idx.row()) {
|
if (!idx.isValid() || row != idx.row()) {
|
||||||
ui->lstProblemCases->setCurrentIndex(mOJProblemModel.index(row,0));
|
ui->tblProblemCases->setCurrentIndex(mOJProblemModel.index(row,0));
|
||||||
}
|
}
|
||||||
ui->txtProblemCaseOutput->clear();
|
ui->txtProblemCaseOutput->clear();
|
||||||
}
|
}
|
||||||
|
@ -5922,6 +5942,38 @@ void MainWindow::newProjectUnitFile()
|
||||||
updateProjectView();
|
updateProjectView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::fillProblemCaseInputAndExpected(const POJProblemCase &problemCase)
|
||||||
|
{
|
||||||
|
ui->btnProblemCaseInputFileName->setEnabled(true);
|
||||||
|
if (fileExists(problemCase->inputFileName)) {
|
||||||
|
ui->txtProblemCaseInput->setReadOnly(true);
|
||||||
|
ui->txtProblemCaseInput->setPlainText(readFileToByteArray(problemCase->inputFileName));
|
||||||
|
ui->btnProblemCaseClearInputFileName->setVisible(true);
|
||||||
|
ui->txtProblemCaseInputFileName->setText(extractFileName(problemCase->inputFileName));
|
||||||
|
ui->txtProblemCaseInputFileName->setToolTip(problemCase->inputFileName);
|
||||||
|
} else {
|
||||||
|
ui->txtProblemCaseInput->setReadOnly(false);
|
||||||
|
ui->txtProblemCaseInput->setPlainText(problemCase->input);
|
||||||
|
ui->btnProblemCaseClearInputFileName->setVisible(false);
|
||||||
|
ui->txtProblemCaseInputFileName->clear();
|
||||||
|
ui->txtProblemCaseInputFileName->setToolTip("");
|
||||||
|
}
|
||||||
|
ui->btnProblemCaseExpectedOutputFileName->setEnabled(true);
|
||||||
|
if (fileExists(problemCase->expectedOutputFileName)) {
|
||||||
|
ui->txtProblemCaseExpected->setReadOnly(true);
|
||||||
|
ui->txtProblemCaseExpected->setPlainText(readFileToByteArray(problemCase->expectedOutputFileName));
|
||||||
|
ui->btnProblemCaseClearExpectedOutputFileName->setVisible(true);
|
||||||
|
ui->txtProblemCaseExpectedOutputFileName->setText(extractFileName(problemCase->expectedOutputFileName));
|
||||||
|
ui->txtProblemCaseExpectedOutputFileName->setToolTip(problemCase->inputFileName);
|
||||||
|
} else {
|
||||||
|
ui->txtProblemCaseExpected->setReadOnly(false);
|
||||||
|
ui->txtProblemCaseExpected->setPlainText(problemCase->expected);
|
||||||
|
ui->btnProblemCaseClearExpectedOutputFileName->setVisible(false);
|
||||||
|
ui->txtProblemCaseExpectedOutputFileName->clear();
|
||||||
|
ui->txtProblemCaseExpectedOutputFileName->setToolTip("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::doFilesViewRemoveFile(const QModelIndex &index)
|
void MainWindow::doFilesViewRemoveFile(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
|
@ -6166,7 +6218,11 @@ void MainWindow::updateProblemCaseOutput(POJProblemCase problemCase)
|
||||||
{
|
{
|
||||||
if (problemCase->testState == ProblemCaseTestState::Failed) {
|
if (problemCase->testState == ProblemCaseTestState::Failed) {
|
||||||
QStringList output = textToLines(problemCase->output);
|
QStringList output = textToLines(problemCase->output);
|
||||||
QStringList expected = textToLines(problemCase->expected);
|
QStringList expected;
|
||||||
|
if (fileExists(problemCase->expectedOutputFileName))
|
||||||
|
expected = readFileToLines(problemCase->expectedOutputFileName);
|
||||||
|
else
|
||||||
|
expected = textToLines(problemCase->expected);
|
||||||
for (int i=0;i<output.count();i++) {
|
for (int i=0;i<output.count();i++) {
|
||||||
if (i>=expected.count() || output[i]!=expected[i]) {
|
if (i>=expected.count() || output[i]!=expected[i]) {
|
||||||
QTextBlock block = ui->txtProblemCaseOutput->document()->findBlockByLineNumber(i);
|
QTextBlock block = ui->txtProblemCaseOutput->document()->findBlockByLineNumber(i);
|
||||||
|
@ -6192,11 +6248,12 @@ void MainWindow::updateProblemCaseOutput(POJProblemCase problemCase)
|
||||||
|
|
||||||
void MainWindow::applyCurrentProblemCaseChanges()
|
void MainWindow::applyCurrentProblemCaseChanges()
|
||||||
{
|
{
|
||||||
QModelIndex idx = ui->lstProblemCases->currentIndex();
|
QModelIndex idx = ui->tblProblemCases->currentIndex();
|
||||||
if (idx.isValid()) {
|
if (idx.isValid()) {
|
||||||
POJProblemCase problemCase = mOJProblemModel.getCase(idx.row());
|
POJProblemCase problemCase = mOJProblemModel.getCase(idx.row());
|
||||||
if (problemCase) {
|
if (problemCase) {
|
||||||
problemCase->input = ui->txtProblemCaseInput->toPlainText();
|
if (!fileExists(problemCase->inputFileName))
|
||||||
|
problemCase->input = ui->txtProblemCaseInput->toPlainText();
|
||||||
problemCase->expected = ui->txtProblemCaseExpected->toPlainText();
|
problemCase->expected = ui->txtProblemCaseExpected->toPlainText();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6495,7 +6552,7 @@ void MainWindow::on_btnAddProblem_clicked()
|
||||||
int startCount = mOJProblemSetModel.count();
|
int startCount = mOJProblemSetModel.count();
|
||||||
QString name;
|
QString name;
|
||||||
while (true) {
|
while (true) {
|
||||||
name = tr("Problem %1").arg(startCount);
|
name = tr("Problem %1").arg(startCount+1);
|
||||||
if (!mOJProblemSetModel.problemNameUsed(name))
|
if (!mOJProblemSetModel.problemNameUsed(name))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -6565,7 +6622,7 @@ void MainWindow::on_btnAddProblemCase_clicked()
|
||||||
int startCount = mOJProblemModel.count();
|
int startCount = mOJProblemModel.count();
|
||||||
QString name;
|
QString name;
|
||||||
while (true) {
|
while (true) {
|
||||||
name = tr("Problem Case %1").arg(startCount);
|
name = tr("Problem Case %1").arg(startCount+1);
|
||||||
if (!mOJProblemSetModel.problemNameUsed(name))
|
if (!mOJProblemSetModel.problemNameUsed(name))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -6573,7 +6630,7 @@ void MainWindow::on_btnAddProblemCase_clicked()
|
||||||
problemCase->name = name;
|
problemCase->name = name;
|
||||||
problemCase->testState = ProblemCaseTestState::NotTested;
|
problemCase->testState = ProblemCaseTestState::NotTested;
|
||||||
mOJProblemModel.addCase(problemCase);
|
mOJProblemModel.addCase(problemCase);
|
||||||
ui->lstProblemCases->setCurrentIndex(mOJProblemModel.index(mOJProblemModel.count()-1));
|
ui->tblProblemCases->setCurrentIndex(mOJProblemModel.index(mOJProblemModel.count()-1,0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_btnRunAllProblemCases_clicked()
|
void MainWindow::on_btnRunAllProblemCases_clicked()
|
||||||
|
@ -6595,7 +6652,7 @@ void MainWindow::on_actionC_Reference_triggered()
|
||||||
|
|
||||||
void MainWindow::on_btnRemoveProblemCase_clicked()
|
void MainWindow::on_btnRemoveProblemCase_clicked()
|
||||||
{
|
{
|
||||||
QModelIndex idx = ui->lstProblemCases->currentIndex();
|
QModelIndex idx = ui->tblProblemCases->currentIndex();
|
||||||
if (idx.isValid()) {
|
if (idx.isValid()) {
|
||||||
mOJProblemModel.removeCase(idx.row());
|
mOJProblemModel.removeCase(idx.row());
|
||||||
}
|
}
|
||||||
|
@ -7322,3 +7379,74 @@ void MainWindow::on_actionMatch_Bracket_triggered()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::on_btnProblemCaseInputFileName_clicked()
|
||||||
|
{
|
||||||
|
QString fileName = QFileDialog::getOpenFileName(
|
||||||
|
this,
|
||||||
|
tr("Choose Input Data File"),
|
||||||
|
QString(),
|
||||||
|
tr("All files (*.*)"));
|
||||||
|
if (!fileName.isEmpty()) {
|
||||||
|
QModelIndex idx = ui->tblProblemCases->currentIndex();
|
||||||
|
POJProblemCase problemCase = mOJProblemModel.getCase(idx.row());
|
||||||
|
if (!problemCase)
|
||||||
|
return;
|
||||||
|
if (problemCase->inputFileName == fileName)
|
||||||
|
return;
|
||||||
|
problemCase->inputFileName = fileName;
|
||||||
|
fillProblemCaseInputAndExpected(problemCase);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::on_btnProblemCaseClearExpectedOutputFileName_clicked()
|
||||||
|
{
|
||||||
|
QModelIndex idx = ui->tblProblemCases->currentIndex();
|
||||||
|
POJProblemCase problemCase = mOJProblemModel.getCase(idx.row());
|
||||||
|
if (!problemCase)
|
||||||
|
return;
|
||||||
|
problemCase->expectedOutputFileName = "";
|
||||||
|
fillProblemCaseInputAndExpected(problemCase);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::on_btnProblemCaseClearInputFileName_clicked()
|
||||||
|
{
|
||||||
|
QModelIndex idx = ui->tblProblemCases->currentIndex();
|
||||||
|
POJProblemCase problemCase = mOJProblemModel.getCase(idx.row());
|
||||||
|
if (!problemCase)
|
||||||
|
return;
|
||||||
|
problemCase->inputFileName = "";
|
||||||
|
fillProblemCaseInputAndExpected(problemCase);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::on_btnProblemCaseExpectedOutputFileName_clicked()
|
||||||
|
{
|
||||||
|
QString fileName = QFileDialog::getOpenFileName(
|
||||||
|
this,
|
||||||
|
tr("Choose Expected Output Data File"),
|
||||||
|
QString(),
|
||||||
|
tr("All files (*.*)"));
|
||||||
|
if (!fileName.isEmpty()) {
|
||||||
|
QModelIndex idx = ui->tblProblemCases->currentIndex();
|
||||||
|
POJProblemCase problemCase = mOJProblemModel.getCase(idx.row());
|
||||||
|
if (!problemCase)
|
||||||
|
return;
|
||||||
|
if (problemCase->expectedOutputFileName == fileName)
|
||||||
|
return;
|
||||||
|
problemCase->expectedOutputFileName = fileName;
|
||||||
|
fillProblemCaseInputAndExpected(problemCase);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainWindow::on_txtProblemCaseOutput_cursorPositionChanged()
|
||||||
|
{
|
||||||
|
QTextCursor cursor = ui->txtProblemCaseOutput->textCursor();
|
||||||
|
int val = ui->txtProblemCaseOutput->verticalScrollBar()->value();
|
||||||
|
ui->txtProblemCaseExpected->setTextCursor(cursor);
|
||||||
|
ui->txtProblemCaseExpected->verticalScrollBar()->setValue(val);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -254,6 +254,7 @@ private:
|
||||||
void prepareTabInfosData();
|
void prepareTabInfosData();
|
||||||
void prepareTabMessagesData();
|
void prepareTabMessagesData();
|
||||||
void newProjectUnitFile();
|
void newProjectUnitFile();
|
||||||
|
void fillProblemCaseInputAndExpected(const POJProblemCase &problemCase);
|
||||||
|
|
||||||
void doFilesViewRemoveFile(const QModelIndex& index);
|
void doFilesViewRemoveFile(const QModelIndex& index);
|
||||||
|
|
||||||
|
@ -646,6 +647,16 @@ private slots:
|
||||||
|
|
||||||
void on_actionMatch_Bracket_triggered();
|
void on_actionMatch_Bracket_triggered();
|
||||||
|
|
||||||
|
void on_btnProblemCaseInputFileName_clicked();
|
||||||
|
|
||||||
|
void on_btnProblemCaseClearExpectedOutputFileName_clicked();
|
||||||
|
|
||||||
|
void on_btnProblemCaseClearInputFileName_clicked();
|
||||||
|
|
||||||
|
void on_btnProblemCaseExpectedOutputFileName_clicked();
|
||||||
|
|
||||||
|
void on_txtProblemCaseOutput_cursorPositionChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainWindow *ui;
|
Ui::MainWindow *ui;
|
||||||
EditorList *mEditorList;
|
EditorList *mEditorList;
|
||||||
|
|
|
@ -1338,13 +1338,22 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QListView" name="lstProblemCases">
|
<widget class="QTableView" name="tblProblemCases">
|
||||||
<property name="alternatingRowColors">
|
<property name="alternatingRowColors">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="selectionMode">
|
||||||
|
<enum>QAbstractItemView::SingleSelection</enum>
|
||||||
|
</property>
|
||||||
<property name="selectionBehavior">
|
<property name="selectionBehavior">
|
||||||
<enum>QAbstractItemView::SelectRows</enum>
|
<enum>QAbstractItemView::SelectRows</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<attribute name="horizontalHeaderDefaultSectionSize">
|
||||||
|
<number>200</number>
|
||||||
|
</attribute>
|
||||||
|
<attribute name="horizontalHeaderStretchLastSection">
|
||||||
|
<bool>true</bool>
|
||||||
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -1363,6 +1372,80 @@
|
||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QPlainTextEdit" name="txtProblemCaseOutput">
|
||||||
|
<property name="lineWrapMode">
|
||||||
|
<enum>QPlainTextEdit::NoWrap</enum>
|
||||||
|
</property>
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="2">
|
||||||
|
<widget class="QPlainTextEdit" name="txtProblemCaseExpected">
|
||||||
|
<property name="lineWrapMode">
|
||||||
|
<enum>QPlainTextEdit::NoWrap</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QWidget" name="widget_7" native="true">
|
||||||
|
<layout class="QGridLayout" name="gridLayout_4">
|
||||||
|
<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 row="0" column="1">
|
||||||
|
<widget class="QLineEdit" name="txtProblemCaseInputFileName">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>Input</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="3">
|
||||||
|
<widget class="QToolButton" name="btnProblemCaseInputFileName">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Choose Input File</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Choose Input File</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="icons.qrc">
|
||||||
|
<normaloff>:/icons/images/newlook24/053-open.png</normaloff>:/icons/images/newlook24/053-open.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QToolButton" name="btnProblemCaseClearInputFileName">
|
||||||
|
<property name="text">
|
||||||
|
<string>Clear</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="icons.qrc">
|
||||||
|
<normaloff>:/icons/images/newlook24/008-close.png</normaloff>:/icons/images/newlook24/008-close.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QLabel" name="label_6">
|
<widget class="QLabel" name="label_6">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -1370,39 +1453,68 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="label_5">
|
|
||||||
<property name="text">
|
|
||||||
<string>Input</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="2">
|
|
||||||
<widget class="QLabel" name="label_7">
|
|
||||||
<property name="text">
|
|
||||||
<string>Expected</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QPlainTextEdit" name="txtProblemCaseOutput">
|
|
||||||
<property name="lineWrapMode">
|
|
||||||
<enum>QPlainTextEdit::NoWrap</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QPlainTextEdit" name="txtProblemCaseInput">
|
<widget class="QPlainTextEdit" name="txtProblemCaseInput">
|
||||||
<property name="lineWrapMode">
|
<property name="lineWrapMode">
|
||||||
<enum>QPlainTextEdit::NoWrap</enum>
|
<enum>QPlainTextEdit::NoWrap</enum>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="2">
|
<item row="0" column="2">
|
||||||
<widget class="QPlainTextEdit" name="txtProblemCaseExpected">
|
<widget class="QWidget" name="widget_8" native="true">
|
||||||
<property name="lineWrapMode">
|
<layout class="QHBoxLayout" name="horizontalLayout_18">
|
||||||
<enum>QPlainTextEdit::NoWrap</enum>
|
<property name="leftMargin">
|
||||||
</property>
|
<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_5">
|
||||||
|
<property name="text">
|
||||||
|
<string>Expected</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="txtProblemCaseExpectedOutputFileName">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="btnProblemCaseClearExpectedOutputFileName">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Clear</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Clear</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="icons.qrc">
|
||||||
|
<normaloff>:/icons/images/newlook24/008-close.png</normaloff>:/icons/images/newlook24/008-close.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="btnProblemCaseExpectedOutputFileName">
|
||||||
|
<property name="text">
|
||||||
|
<string>...</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="icons.qrc">
|
||||||
|
<normaloff>:/icons/images/newlook24/053-open.png</normaloff>:/icons/images/newlook24/053-open.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
@ -1422,7 +1534,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1114</width>
|
<width>1114</width>
|
||||||
<height>25</height>
|
<height>26</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuFile">
|
<widget class="QMenu" name="menuFile">
|
||||||
|
|
|
@ -31,8 +31,11 @@ struct OJProblemCase {
|
||||||
QString name;
|
QString name;
|
||||||
QString input;
|
QString input;
|
||||||
QString expected;
|
QString expected;
|
||||||
|
QString inputFileName;
|
||||||
|
QString expectedOutputFileName;
|
||||||
ProblemCaseTestState testState; // no persistence
|
ProblemCaseTestState testState; // no persistence
|
||||||
QString output; // no persistence
|
QString output; // no persistence
|
||||||
|
int runningTime;
|
||||||
OJProblemCase();
|
OJProblemCase();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -556,6 +556,13 @@ QStringList readFileToLines(const QString &fileName)
|
||||||
ok=false;
|
ok=false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (s.endsWith("\r\n")) {
|
||||||
|
s.remove(s.length()-2,2);
|
||||||
|
} else if (s.endsWith("\r")) {
|
||||||
|
s.remove(s.length()-1,1);
|
||||||
|
} else if (s.endsWith("\n")){
|
||||||
|
s.remove(s.length()-1,1);
|
||||||
|
}
|
||||||
result.append(s);
|
result.append(s);
|
||||||
}
|
}
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
|
@ -569,6 +576,13 @@ QStringList readFileToLines(const QString &fileName)
|
||||||
result.clear();
|
result.clear();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (s.endsWith("\r\n")) {
|
||||||
|
s.remove(s.length()-2,2);
|
||||||
|
} else if (s.endsWith("\r")) {
|
||||||
|
s.remove(s.length()-1,1);
|
||||||
|
} else if (s.endsWith("\n")){
|
||||||
|
s.remove(s.length()-1,1);
|
||||||
|
}
|
||||||
result.append(s);
|
result.append(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,6 +112,17 @@ void OJProblemSetModel::saveToFile(const QString &fileName)
|
||||||
QJsonObject caseObj;
|
QJsonObject caseObj;
|
||||||
caseObj["name"]=problemCase->name;
|
caseObj["name"]=problemCase->name;
|
||||||
caseObj["input"]=problemCase->input;
|
caseObj["input"]=problemCase->input;
|
||||||
|
QString path = problemCase->inputFileName;
|
||||||
|
QString prefix = includeTrailingPathDelimiter(extractFileDir(fileName));
|
||||||
|
if (path.startsWith(prefix, PATH_SENSITIVITY)) {
|
||||||
|
path = "%ProblemSetPath%/"+ path.mid(prefix.length());
|
||||||
|
}
|
||||||
|
caseObj["input_filename"]=path;
|
||||||
|
path = problemCase->expectedOutputFileName;
|
||||||
|
if (path.startsWith(prefix, PATH_SENSITIVITY)) {
|
||||||
|
path = "%ProblemSetPath%/"+ path.mid(prefix.length());
|
||||||
|
}
|
||||||
|
caseObj["expected_output_filename"]=path;
|
||||||
caseObj["expected"]=problemCase->expected;
|
caseObj["expected"]=problemCase->expected;
|
||||||
cases.append(caseObj);
|
cases.append(caseObj);
|
||||||
}
|
}
|
||||||
|
@ -160,6 +171,18 @@ void OJProblemSetModel::loadFromFile(const QString &fileName)
|
||||||
problemCase->name = caseObj["name"].toString();
|
problemCase->name = caseObj["name"].toString();
|
||||||
problemCase->input = caseObj["input"].toString();
|
problemCase->input = caseObj["input"].toString();
|
||||||
problemCase->expected = caseObj["expected"].toString();
|
problemCase->expected = caseObj["expected"].toString();
|
||||||
|
QString path = caseObj["input_filename"].toString();
|
||||||
|
if (path.startsWith("%ProblemSetPath%/")) {
|
||||||
|
path = includeTrailingPathDelimiter(extractFileDir(fileName))+
|
||||||
|
path.mid(QLatin1String("%ProblemSetPath%/").size());
|
||||||
|
}
|
||||||
|
problemCase->inputFileName=path;
|
||||||
|
path = caseObj["expected_output_filename"].toString();
|
||||||
|
if (path.startsWith("%ProblemSetPath%/")) {
|
||||||
|
path = includeTrailingPathDelimiter(extractFileDir(fileName))+
|
||||||
|
path.mid(QLatin1String("%ProblemSetPath%/").size());
|
||||||
|
}
|
||||||
|
problemCase->expectedOutputFileName=path;
|
||||||
problemCase->testState = ProblemCaseTestState::NotTested;
|
problemCase->testState = ProblemCaseTestState::NotTested;
|
||||||
problem->cases.append(problemCase);
|
problem->cases.append(problemCase);
|
||||||
}
|
}
|
||||||
|
@ -216,7 +239,7 @@ Qt::ItemFlags OJProblemSetModel::flags(const QModelIndex &) const
|
||||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;
|
return Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsEditable;
|
||||||
}
|
}
|
||||||
|
|
||||||
OJProblemModel::OJProblemModel(QObject *parent): QAbstractListModel(parent)
|
OJProblemModel::OJProblemModel(QObject *parent): QAbstractTableModel(parent)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -348,20 +371,36 @@ QVariant OJProblemModel::data(const QModelIndex &index, int role) const
|
||||||
return QVariant();
|
return QVariant();
|
||||||
if (mProblem==nullptr)
|
if (mProblem==nullptr)
|
||||||
return QVariant();
|
return QVariant();
|
||||||
if (role == Qt::DisplayRole || role == Qt::EditRole) {
|
switch (index.column()) {
|
||||||
return mProblem->cases[index.row()]->name;
|
case 0:
|
||||||
} else if (role == Qt::DecorationRole) {
|
if (role == Qt::DisplayRole || role == Qt::EditRole) {
|
||||||
switch (mProblem->cases[index.row()]->testState) {
|
POJProblemCase problemCase = mProblem->cases[index.row()];
|
||||||
case ProblemCaseTestState::Failed:
|
return problemCase->name;
|
||||||
return pIconsManager->getIcon(IconsManager::ACTION_PROBLEM_FALIED);
|
} else if (role == Qt::DecorationRole) {
|
||||||
case ProblemCaseTestState::Passed:
|
switch (mProblem->cases[index.row()]->testState) {
|
||||||
return pIconsManager->getIcon(IconsManager::ACTION_PROBLEM_PASSED);
|
case ProblemCaseTestState::Failed:
|
||||||
case ProblemCaseTestState::Testing:
|
return pIconsManager->getIcon(IconsManager::ACTION_PROBLEM_FALIED);
|
||||||
return pIconsManager->getIcon(IconsManager::ACTION_PROBLEM_TESTING);
|
case ProblemCaseTestState::Passed:
|
||||||
default:
|
return pIconsManager->getIcon(IconsManager::ACTION_PROBLEM_PASSED);
|
||||||
return QVariant();
|
case ProblemCaseTestState::Testing:
|
||||||
|
return pIconsManager->getIcon(IconsManager::ACTION_PROBLEM_TESTING);
|
||||||
|
default:
|
||||||
|
return QVariant();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
if (role == Qt::DisplayRole) {
|
||||||
|
POJProblemCase problemCase = mProblem->cases[index.row()];
|
||||||
|
if (problemCase->testState == ProblemCaseTestState::Passed
|
||||||
|
|| problemCase->testState == ProblemCaseTestState::Failed)
|
||||||
|
return problemCase->runningTime/1000.0;
|
||||||
|
else
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,9 +408,11 @@ bool OJProblemModel::setData(const QModelIndex &index, const QVariant &value, in
|
||||||
{
|
{
|
||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return false;
|
return false;
|
||||||
|
if (index.column()!=0)
|
||||||
|
return false;
|
||||||
if (mProblem==nullptr)
|
if (mProblem==nullptr)
|
||||||
return false;
|
return false;
|
||||||
if (role == Qt::DisplayRole || role == Qt::EditRole) {
|
if (role == Qt::EditRole ) {
|
||||||
QString s = value.toString();
|
QString s = value.toString();
|
||||||
if (!s.isEmpty()) {
|
if (!s.isEmpty()) {
|
||||||
mProblem->cases[index.row()]->name = s;
|
mProblem->cases[index.row()]->name = s;
|
||||||
|
@ -381,7 +422,28 @@ bool OJProblemModel::setData(const QModelIndex &index, const QVariant &value, in
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Qt::ItemFlags OJProblemModel::flags(const QModelIndex &) const
|
Qt::ItemFlags OJProblemModel::flags(const QModelIndex &idx) const
|
||||||
{
|
{
|
||||||
return Qt::ItemIsEnabled | Qt::ItemIsEditable | Qt::ItemIsSelectable;
|
Qt::ItemFlags flags=Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||||
|
if (idx.column()==0)
|
||||||
|
flags |= Qt::ItemIsEditable ;
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
int OJProblemModel::columnCount(const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant OJProblemModel::headerData(int section, Qt::Orientation orientation, int role) const
|
||||||
|
{
|
||||||
|
if (orientation == Qt::Horizontal && role == Qt::DisplayRole) {
|
||||||
|
switch (section) {
|
||||||
|
case 0:
|
||||||
|
return tr("Name");
|
||||||
|
case 1:
|
||||||
|
return tr("Time(sec)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,11 +17,11 @@
|
||||||
#ifndef OJPROBLEMSETMODEL_H
|
#ifndef OJPROBLEMSETMODEL_H
|
||||||
#define OJPROBLEMSETMODEL_H
|
#define OJPROBLEMSETMODEL_H
|
||||||
|
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractTableModel>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "../problems/ojproblemset.h"
|
#include "../problems/ojproblemset.h"
|
||||||
|
|
||||||
class OJProblemModel: public QAbstractListModel {
|
class OJProblemModel: public QAbstractTableModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit OJProblemModel(QObject *parent = nullptr);
|
explicit OJProblemModel(QObject *parent = nullptr);
|
||||||
|
@ -47,6 +47,11 @@ public:
|
||||||
QVariant data(const QModelIndex &index, int role) const override;
|
QVariant data(const QModelIndex &index, int role) const override;
|
||||||
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
||||||
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
||||||
|
|
||||||
|
// QAbstractItemModel interface
|
||||||
|
public:
|
||||||
|
int columnCount(const QModelIndex &parent) const override;
|
||||||
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class OJProblemSetModel : public QAbstractListModel
|
class OJProblemSetModel : public QAbstractListModel
|
||||||
|
|
|
@ -1,14 +1,18 @@
|
||||||
win32-msvc{
|
#win32-msvc{
|
||||||
CONFIG += c++11
|
# CONFIG += c++11
|
||||||
CONFIG -= app_bundle
|
# CONFIG -= app_bundle
|
||||||
DEFINES -= UNICODE
|
#} else {
|
||||||
} else {
|
# TEMPLATE = app
|
||||||
TEMPLATE = app
|
|
||||||
|
# CONFIG += windows
|
||||||
|
# CONFIG -= app_bundle
|
||||||
|
# CONFIG -= qt
|
||||||
|
#}
|
||||||
|
CONFIG += c++11
|
||||||
|
CONFIG -= app_bundle
|
||||||
|
|
||||||
|
DEFINES -= UNICODE
|
||||||
|
|
||||||
CONFIG += windows
|
|
||||||
CONFIG -= app_bundle
|
|
||||||
CONFIG -= qt
|
|
||||||
}
|
|
||||||
isEmpty(APP_NAME) {
|
isEmpty(APP_NAME) {
|
||||||
APP_NAME = RedPandaCPP
|
APP_NAME = RedPandaCPP
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue