From bb10a83942cd6767811f32ec458609ea26769dd1 Mon Sep 17 00:00:00 2001 From: "royqh1979@gmail.com" Date: Sun, 31 Oct 2021 17:01:34 +0800 Subject: [PATCH] initial work for OJ Problems --- RedPandaIDE/RedPandaIDE.pro | 2 + RedPandaIDE/mainwindow.ui | 303 +++++++++++++++++++++- RedPandaIDE/widgets/ojproblemsetmodel.cpp | 26 ++ RedPandaIDE/widgets/ojproblemsetmodel.h | 52 ++++ 4 files changed, 378 insertions(+), 5 deletions(-) create mode 100644 RedPandaIDE/widgets/ojproblemsetmodel.cpp create mode 100644 RedPandaIDE/widgets/ojproblemsetmodel.h diff --git a/RedPandaIDE/RedPandaIDE.pro b/RedPandaIDE/RedPandaIDE.pro index 31a2daf9..d2781115 100644 --- a/RedPandaIDE/RedPandaIDE.pro +++ b/RedPandaIDE/RedPandaIDE.pro @@ -121,6 +121,7 @@ SOURCES += \ widgets/labelwithmenu.cpp \ widgets/macroinfomodel.cpp \ widgets/newprojectdialog.cpp \ + widgets/ojproblemsetmodel.cpp \ widgets/qconsole.cpp \ widgets/qpatchedcombobox.cpp \ widgets/searchdialog.cpp \ @@ -236,6 +237,7 @@ HEADERS += \ widgets/labelwithmenu.h \ widgets/macroinfomodel.h \ widgets/newprojectdialog.h \ + widgets/ojproblemsetmodel.h \ widgets/qconsole.h \ widgets/qpatchedcombobox.h \ widgets/searchdialog.h \ diff --git a/RedPandaIDE/mainwindow.ui b/RedPandaIDE/mainwindow.ui index 11353278..84ef4751 100644 --- a/RedPandaIDE/mainwindow.ui +++ b/RedPandaIDE/mainwindow.ui @@ -6,8 +6,8 @@ 0 0 - 946 - 657 + 1036 + 742 @@ -85,7 +85,7 @@ QTabWidget::West - 0 + 4 true @@ -262,6 +262,124 @@ + + + Problem Set + + + + 7 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Problem Set + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + ... + + + + :/icons/images/newlook24/050-newsrc.png:/icons/images/newlook24/050-newsrc.png + + + + + + + ... + + + + :/icons/images/newlook24/002-add.png:/icons/images/newlook24/002-add.png + + + + + + + ... + + + + :/icons/images/newlook24/008-close.png:/icons/images/newlook24/008-close.png + + + + + + + ... + + + + :/icons/images/newlook24/072-saveas.png:/icons/images/newlook24/072-saveas.png + + + + + + + ... + + + + :/icons/images/newlook24/053-open.png:/icons/images/newlook24/053-open.png + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + @@ -353,7 +471,7 @@ QTabWidget::South - 2 + 6 @@ -944,6 +1062,181 @@ + + + Problem + + + + 11 + + + 11 + + + 11 + + + 11 + + + + + Qt::Horizontal + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Problem + + + + + + + + 0 + 0 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + ... + + + + :/icons/images/newlook24/002-add.png:/icons/images/newlook24/002-add.png + + + + + + + ... + + + + :/icons/images/newlook24/008-close.png:/icons/images/newlook24/008-close.png + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + Output + + + + + + + Input + + + + + + + Expected + + + + + + + + + + + + + + + + + + @@ -954,7 +1247,7 @@ 0 0 - 946 + 1036 25 diff --git a/RedPandaIDE/widgets/ojproblemsetmodel.cpp b/RedPandaIDE/widgets/ojproblemsetmodel.cpp new file mode 100644 index 00000000..e4b37925 --- /dev/null +++ b/RedPandaIDE/widgets/ojproblemsetmodel.cpp @@ -0,0 +1,26 @@ +#include "ojproblemsetmodel.h" + +OJProblemSetModel::OJProblemSetModel(QObject *parent) : QAbstractListModel(parent) +{ + +} + +OJProblemCaseModel::OJProblemCaseModel(QObject *parent): QAbstractListModel(parent) +{ + +} + +const POJProbelm &OJProblemCaseModel::problem() const +{ + return mProblem; +} + +void OJProblemCaseModel::setProblem(const POJProbelm &newProblem) +{ + mProblem = newProblem; +} + +int OJProblemCaseModel::rowCount(const QModelIndex &parent) const +{ + +} diff --git a/RedPandaIDE/widgets/ojproblemsetmodel.h b/RedPandaIDE/widgets/ojproblemsetmodel.h new file mode 100644 index 00000000..74e1208f --- /dev/null +++ b/RedPandaIDE/widgets/ojproblemsetmodel.h @@ -0,0 +1,52 @@ +#ifndef OJPROBLEMSETMODEL_H +#define OJPROBLEMSETMODEL_H + +#include +#include + +enum class ProblemCaseTestState { + NoTested, + Passed, + Failed +}; + +struct OJProblemCase { + QString name; + QString input; + QString expected; + ProblemCaseTestState testState; +}; + +using POJProblemCase = std::shared_ptr; + +struct OJProblem { + QString name; + QVector cases; +}; + +using POJProbelm = std::shared_ptr; + +class OJProblemCaseModel: public QAbstractListModel { + Q_OBJECT +public: + explicit OJProblemCaseModel(QObject *parent = nullptr); + const POJProbelm &problem() const; + void setProblem(const POJProbelm &newProblem); + +private: + POJProbelm mProblem; + + // QAbstractItemModel interface +public: + int rowCount(const QModelIndex &parent) const override; + QVariant data(const QModelIndex &index, int role) const override; +}; + +class OJProblemSetModel : public QAbstractListModel +{ + Q_OBJECT +public: + explicit OJProblemSetModel(QObject *parent = nullptr); +}; + +#endif // OJPROBLEMSETMODEL_H