├── .gitignore ├── Psapi.Lib ├── README.md ├── add.png ├── addcompilerwizard.cpp ├── addcompilerwizard.h ├── addtaskdialog.cpp ├── addtaskdialog.h ├── addtestcaseswizard.cpp ├── addtestcaseswizard.h ├── advancedcompilersettingsdialog.cpp ├── advancedcompilersettingsdialog.h ├── assignmentthread.cpp ├── assignmentthread.h ├── compiler.cpp ├── compiler.h ├── compilersettings.cpp ├── compilersettings.h ├── contest.cpp ├── contest.h ├── contestant.cpp ├── contestant.h ├── cross.png ├── detaildialog.cpp ├── detaildialog.h ├── downarrow.png ├── editvariabledialog.cpp ├── editvariabledialog.h ├── environmentvariablesdialog.cpp ├── environmentvariablesdialog.h ├── exportutil.cpp ├── exportutil.h ├── filelineedit.cpp ├── filelineedit.h ├── forms_unix ├── addcompilerwizard.ui ├── addtaskdialog.ui ├── addtestcaseswizard.ui ├── advancedcompilersettingsdialog.ui ├── compilersettings.ui ├── detaildialog.ui ├── editvariabledialog.ui ├── environmentvariablesdialog.ui ├── generalsettings.ui ├── judgingdialog.ui ├── lemon.ui ├── newcontestdialog.ui ├── newcontestwidget.ui ├── opencontestdialog.ui ├── opencontestwidget.ui ├── optionsdialog.ui ├── taskeditwidget.ui ├── testcaseeditwidget.ui └── welcomedialog.ui ├── forms_win32 ├── addcompilerwizard.ui ├── addtaskdialog.ui ├── addtestcaseswizard.ui ├── advancedcompilersettingsdialog.ui ├── compilersettings.ui ├── detaildialog.ui ├── editvariabledialog.ui ├── environmentvariablesdialog.ui ├── generalsettings.ui ├── judgingdialog.ui ├── lemon.ui ├── newcontestdialog.ui ├── newcontestwidget.ui ├── opencontestdialog.ui ├── opencontestwidget.ui ├── optionsdialog.ui ├── taskeditwidget.ui ├── testcaseeditwidget.ui └── welcomedialog.ui ├── generalsettings.cpp ├── generalsettings.h ├── globaltype.h ├── icon.ico ├── icon.png ├── judgingdialog.cpp ├── judgingdialog.h ├── judgingthread.cpp ├── judgingthread.h ├── lemon.cpp ├── lemon.h ├── lemon.pro ├── lemon.rc ├── lemon_zh_CN.qm ├── lemon_zh_CN.ts ├── main.cpp ├── newcontestdialog.cpp ├── newcontestdialog.h ├── newcontestwidget.cpp ├── newcontestwidget.h ├── opencontestdialog.cpp ├── opencontestdialog.h ├── opencontestwidget.cpp ├── opencontestwidget.h ├── optionsdialog.cpp ├── optionsdialog.h ├── qt_zh_CN.qm ├── qtlockedfile ├── qtlockedfile.cpp ├── qtlockedfile.h ├── qtlockedfile_unix.cpp └── qtlockedfile_win.cpp ├── qtsingleapplication ├── qtlocalpeer.cpp ├── qtlocalpeer.h ├── qtsingleapplication.cpp ├── qtsingleapplication.h ├── qtsinglecoreapplication.cpp └── qtsinglecoreapplication.h ├── realjudge.c ├── realjudge_linux ├── realjudge_win32.exe ├── release_build ├── Project_lemon_i386_NOILinux.tar.gz └── lemon_v1.1_release_mingw.7z ├── resource.qrc ├── resultviewer.cpp ├── resultviewer.h ├── rod.png ├── selftestutil.cpp ├── selftestutil.h ├── settings.cpp ├── settings.h ├── summarytree.cpp ├── summarytree.h ├── task.cpp ├── task.h ├── taskeditwidget.cpp ├── taskeditwidget.h ├── testcase.cpp ├── testcase.h ├── testcaseeditwidget.cpp ├── testcaseeditwidget.h ├── uparrow.png ├── watcher_unix ├── watcher_unix.c ├── welcomedialog.cpp └── welcomedialog.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | 6 | # Compiled Dynamic libraries 7 | *.so 8 | *.dylib 9 | 10 | # Compiled Static libraries 11 | *.lai 12 | *.la 13 | *.a 14 | -------------------------------------------------------------------------------- /Psapi.Lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sojiv/Project_lemon/29a39be26b7f2980b6b4568a41d171c6596ca41a/Psapi.Lib -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Project_lemon 2 | ============= 3 | 4 | A clone of Project-Lemon on Google code (https://code.google.com/p/project-lemon/) 5 | 6 | 请用git clone源代码,或使用右方的Download ZIP功能。 7 | 8 | ```sh 9 | sudo apt-get install qt4-dev-tools 10 | ``` 11 | 12 | 进入源代码目录编译: 13 | ```sh 14 | qmake lemon.pro 15 | make 16 | ``` 17 | Fedora16下的安装注意事项(By litimetal): 1、安装 qt-devel 2、不要输入qmake, 而是qmake-qt4 18 | 19 | - argv[1]: 标准输入文件 20 | - argv[2]: 选手输出文件 21 | - argv[3]: 标准输出文件 22 | - argv[4]: 本测试点满分 23 | - argv[5]: 分数输出文件(必须创建),仅一行,包含一个非负整数,表示得分。 24 | - argv[6]: 额外信息文件(可以不创建) 25 | -------------------------------------------------------------------------------- /add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sojiv/Project_lemon/29a39be26b7f2980b6b4568a41d171c6596ca41a/add.png -------------------------------------------------------------------------------- /addcompilerwizard.h: -------------------------------------------------------------------------------- 1 | #ifndef ADDCOMPILERWIZARD_H 2 | #define ADDCOMPILERWIZARD_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace Ui { 9 | class AddCompilerWizard; 10 | } 11 | 12 | class Compiler; 13 | 14 | class AddCompilerWizard : public QWizard 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | explicit AddCompilerWizard(QWidget *parent = 0); 20 | ~AddCompilerWizard(); 21 | void accept(); 22 | const QList& getCompilerList() const; 23 | 24 | private: 25 | Ui::AddCompilerWizard *ui; 26 | QList compilerList; 27 | int nextId() const; 28 | bool validateCurrentPage(); 29 | 30 | private slots: 31 | void compilerTypeChanged(); 32 | void selectCompilerLocation(); 33 | void selectInterpreterLocation(); 34 | void selectGccPath(); 35 | void selectGppPath(); 36 | void selectFpcPath(); 37 | void selectFbcPath(); 38 | void selectJavacPath(); 39 | void selectJavaPath(); 40 | void selectPythonPath(); 41 | }; 42 | 43 | #endif // ADDCOMPILERWIZARD_H 44 | -------------------------------------------------------------------------------- /addtaskdialog.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #include "addtaskdialog.h" 20 | #include "ui_addtaskdialog.h" 21 | #include "settings.h" 22 | 23 | AddTaskDialog::AddTaskDialog(QWidget *parent) : 24 | QDialog(parent), 25 | ui(new Ui::AddTaskDialog) 26 | { 27 | ui->setupUi(this); 28 | 29 | ui->fullScore->setValidator(new QIntValidator(1, Settings::upperBoundForFullScore() * 100, this)); 30 | ui->timeLimit->setValidator(new QIntValidator(1, Settings::upperBoundForTimeLimit(), this)); 31 | ui->memoryLimit->setValidator(new QIntValidator(1, Settings::upperBoundForMemoryLimit(), this)); 32 | 33 | connect(ui->taskBox, SIGNAL(currentIndexChanged(int)), 34 | this, SLOT(taskBoxIndexChanged())); 35 | connect(ui->fullScore, SIGNAL(textChanged(QString)), 36 | this, SLOT(fullScoreChanged())); 37 | connect(ui->timeLimit, SIGNAL(textChanged(QString)), 38 | this, SLOT(timeLimitChanged())); 39 | connect(ui->memoryLimit, SIGNAL(textChanged(QString)), 40 | this, SLOT(memoryLimitChanged())); 41 | } 42 | 43 | AddTaskDialog::~AddTaskDialog() 44 | { 45 | delete ui; 46 | } 47 | 48 | void AddTaskDialog::addTask(const QString &title, int _fullScore, int _timeLimit, int _memoryLimit) 49 | { 50 | fullScore.append(_fullScore); 51 | timeLimit.append(_timeLimit); 52 | memoryLimit.append(_memoryLimit); 53 | ui->taskBox->addItem(title); 54 | ui->taskBox->setCurrentIndex(0); 55 | } 56 | 57 | int AddTaskDialog::getFullScore(int index) const 58 | { 59 | if (0 <= index && index < fullScore.size()) { 60 | return fullScore[index]; 61 | } else { 62 | return 0; 63 | } 64 | } 65 | 66 | int AddTaskDialog::getTimeLimit(int index) const 67 | { 68 | if (0 <= index && index < timeLimit.size()) { 69 | return timeLimit[index]; 70 | } else { 71 | return 0; 72 | } 73 | } 74 | 75 | int AddTaskDialog::getMemoryLimit(int index) const 76 | { 77 | if (0 <= index && index < memoryLimit.size()) { 78 | return memoryLimit[index]; 79 | } else { 80 | return 0; 81 | } 82 | } 83 | 84 | void AddTaskDialog::taskBoxIndexChanged() 85 | { 86 | int index = ui->taskBox->currentIndex(); 87 | ui->fullScore->setText(QString("%1").arg(fullScore[index])); 88 | ui->timeLimit->setText(QString("%1").arg(timeLimit[index])); 89 | ui->memoryLimit->setText(QString("%1").arg(memoryLimit[index])); 90 | } 91 | 92 | void AddTaskDialog::fullScoreChanged() 93 | { 94 | int index = ui->taskBox->currentIndex(); 95 | fullScore[index] = ui->fullScore->text().toInt(); 96 | } 97 | 98 | void AddTaskDialog::timeLimitChanged() 99 | { 100 | int index = ui->taskBox->currentIndex(); 101 | timeLimit[index] = ui->timeLimit->text().toInt(); 102 | } 103 | 104 | void AddTaskDialog::memoryLimitChanged() 105 | { 106 | int index = ui->taskBox->currentIndex(); 107 | memoryLimit[index] = ui->memoryLimit->text().toInt(); 108 | } 109 | -------------------------------------------------------------------------------- /addtaskdialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef ADDTASKDIALOG_H 20 | #define ADDTASKDIALOG_H 21 | 22 | #include 23 | 24 | namespace Ui { 25 | class AddTaskDialog; 26 | } 27 | 28 | class AddTaskDialog : public QDialog 29 | { 30 | Q_OBJECT 31 | 32 | public: 33 | explicit AddTaskDialog(QWidget *parent = 0); 34 | ~AddTaskDialog(); 35 | void addTask(const QString&, int, int, int); 36 | int getFullScore(int) const; 37 | int getTimeLimit(int) const; 38 | int getMemoryLimit(int) const; 39 | 40 | private: 41 | Ui::AddTaskDialog *ui; 42 | QList fullScore; 43 | QList timeLimit; 44 | QList memoryLimit; 45 | 46 | private slots: 47 | void taskBoxIndexChanged(); 48 | void fullScoreChanged(); 49 | void timeLimitChanged(); 50 | void memoryLimitChanged(); 51 | }; 52 | 53 | #endif // ADDTASKDIALOG_H 54 | -------------------------------------------------------------------------------- /addtestcaseswizard.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef ADDTESTCASESWIZARD_H 20 | #define ADDTESTCASESWIZARD_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace Ui { 27 | class AddTestCasesWizard; 28 | } 29 | 30 | class Settings; 31 | 32 | class AddTestCasesWizard : public QWizard 33 | { 34 | Q_OBJECT 35 | 36 | public: 37 | explicit AddTestCasesWizard(QWidget *parent = 0); 38 | ~AddTestCasesWizard(); 39 | void setSettings(Settings*, bool); 40 | int getFullScore() const; 41 | int getTimeLimit() const; 42 | int getMemoryLimit() const; 43 | const QList& getMatchedInputFiles() const; 44 | const QList& getMatchedOutputFiles() const; 45 | 46 | private: 47 | Ui::AddTestCasesWizard *ui; 48 | Settings *settings; 49 | int fullScore; 50 | int timeLimit; 51 | int memoryLimit; 52 | QString inputFilesPattern; 53 | QString outputFilesPattern; 54 | QList matchedInputFiles; 55 | QList matchedOutputFiles; 56 | void refreshButtonState(); 57 | void getFiles(const QString&, const QString&, QStringList&); 58 | QString getFullRegExp(const QString&); 59 | QStringList getMatchedPart(const QString&, const QString&); 60 | void searchMatchedFiles(); 61 | bool validateCurrentPage(); 62 | static bool compareFileName(const QString&, const QString&); 63 | 64 | private slots: 65 | void fullScoreChanged(const QString&); 66 | void timeLimitChanged(const QString&); 67 | void memoryLimitChanged(const QString&); 68 | void inputFilesPatternChanged(const QString&); 69 | void outputFilesPatternChanged(const QString&); 70 | void addArgument(); 71 | void deleteArgument(); 72 | }; 73 | 74 | #endif // ADDTESTCASESWIZARD_H 75 | -------------------------------------------------------------------------------- /advancedcompilersettingsdialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef ADVANCEDCOMPILERSETTINGSDIALOG_H 20 | #define ADVANCEDCOMPILERSETTINGSDIALOG_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | class Compiler; 27 | 28 | namespace Ui { 29 | class AdvancedCompilerSettingsDialog; 30 | } 31 | 32 | class AdvancedCompilerSettingsDialog : public QDialog 33 | { 34 | Q_OBJECT 35 | 36 | public: 37 | explicit AdvancedCompilerSettingsDialog(QWidget *parent = 0); 38 | ~AdvancedCompilerSettingsDialog(); 39 | void resetEditCompiler(Compiler*); 40 | Compiler* getEditCompiler() const; 41 | 42 | private: 43 | Ui::AdvancedCompilerSettingsDialog *ui; 44 | Compiler *editCompiler; 45 | int configCount; 46 | 47 | private slots: 48 | void okayButtonClicked(); 49 | void compilerTypeChanged(); 50 | void compilerLocationChanged(); 51 | void interpreterLocationChanged(); 52 | void selectCompilerLocation(); 53 | void selectInterpreterLocation(); 54 | void bytecodeExtensionsChanged(); 55 | void timeLimitRatioChanged(); 56 | void memoryLimitRatioChanged(); 57 | void disableMemoryLimitCheckChanged(); 58 | void configurationIndexChanged(); 59 | void configurationTextChanged(); 60 | void deleteConfiguration(); 61 | void compilerArgumentsChanged(); 62 | void interpreterArgumentsChanged(); 63 | void environmentVariablesButtonClicked(); 64 | }; 65 | 66 | #endif // ADVANCEDCOMPILERSETTINGSDIALOG_H 67 | -------------------------------------------------------------------------------- /assignmentthread.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef ASSIGNMENTTHREAD_H 20 | #define ASSIGNMENTTHREAD_H 21 | 22 | #include 23 | #include 24 | #include "globaltype.h" 25 | 26 | class Settings; 27 | class Task; 28 | class JudgingThread; 29 | 30 | class AssignmentThread : public QThread 31 | { 32 | Q_OBJECT 33 | public: 34 | explicit AssignmentThread(QObject *parent = 0); 35 | void setCheckRejudgeMode(bool); 36 | void setNeedRejudge(const QList< QPair >&); 37 | void setSettings(Settings*); 38 | void setTask(Task*); 39 | void setContestantName(const QString&); 40 | CompileState getCompileState() const; 41 | const QString& getCompileMessage() const; 42 | const QString& getSourceFile() const; 43 | const QList< QList >& getScore() const; 44 | const QList< QList >& getTimeUsed() const; 45 | const QList< QList >& getMemoryUsed() const; 46 | const QList< QList >& getResult() const; 47 | const QList& getMessage() const; 48 | const QList& getInputFiles() const; 49 | const QList< QPair >& getNeedRejudge() const; 50 | void run(); 51 | 52 | private: 53 | bool checkRejudgeMode; 54 | bool interpreterFlag; 55 | Settings *settings; 56 | Task* task; 57 | QString contestantName; 58 | CompileState compileState; 59 | QString compileMessage; 60 | QString sourceFile; 61 | QString executableFile; 62 | QString arguments; 63 | QString diffPath; 64 | double timeLimitRatio; 65 | double memoryLimitRatio; 66 | bool disableMemoryLimitCheck; 67 | QProcessEnvironment environment; 68 | QList< QList > timeUsed; 69 | QList< QList > memoryUsed; 70 | QList< QList > score; 71 | QList< QList > result; 72 | QList message; 73 | QList inputFiles; 74 | QList< QPair > needRejudge; 75 | int curTestCaseIndex; 76 | int curSingleCaseIndex; 77 | int countFinished; 78 | int totalSingleCase; 79 | QMap< JudgingThread*, QPair > running; 80 | bool stopJudging; 81 | bool traditionalTaskPrepare(); 82 | void assign(); 83 | 84 | private slots: 85 | void threadFinished(); 86 | 87 | public slots: 88 | void stopJudgingSlot(); 89 | 90 | signals: 91 | void singleCaseFinished(int, int, int, int); 92 | void compileError(int, int); 93 | void stopJudgingSignal(); 94 | }; 95 | 96 | #endif // ASSIGNMENTTHREAD_H 97 | -------------------------------------------------------------------------------- /compiler.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #include "compiler.h" 20 | 21 | Compiler::Compiler(QObject *parent) : 22 | QObject(parent) 23 | { 24 | compilerType = Typical; 25 | timeLimitRatio = 1; 26 | memoryLimitRatio = 1; 27 | disableMemoryLimitCheck = false; 28 | } 29 | 30 | Compiler::CompilerType Compiler::getCompilerType() const 31 | { 32 | return compilerType; 33 | } 34 | 35 | const QString& Compiler::getCompilerName() const 36 | { 37 | return compilerName; 38 | } 39 | 40 | const QStringList& Compiler::getSourceExtensions() const 41 | { 42 | return sourceExtensions; 43 | } 44 | 45 | const QString& Compiler::getCompilerLocation() const 46 | { 47 | return compilerLocation; 48 | } 49 | 50 | const QString& Compiler::getInterpreterLocation() const 51 | { 52 | return interpreterLocation; 53 | } 54 | 55 | const QStringList& Compiler::getBytecodeExtensions() const 56 | { 57 | return bytecodeExtensions; 58 | } 59 | 60 | const QStringList& Compiler::getConfigurationNames() const 61 | { 62 | return configurationNames; 63 | } 64 | 65 | const QStringList& Compiler::getCompilerArguments() const 66 | { 67 | return compilerArguments; 68 | } 69 | 70 | const QStringList& Compiler::getInterpreterArguments() const 71 | { 72 | return interpreterArguments; 73 | } 74 | 75 | const QProcessEnvironment& Compiler::getEnvironment() const 76 | { 77 | return environment; 78 | } 79 | 80 | double Compiler::getTimeLimitRatio() const 81 | { 82 | return timeLimitRatio; 83 | } 84 | 85 | double Compiler::getMemoryLimitRatio() const 86 | { 87 | return memoryLimitRatio; 88 | } 89 | 90 | bool Compiler::getDisableMemoryLimitCheck() const 91 | { 92 | return disableMemoryLimitCheck; 93 | } 94 | 95 | void Compiler::setCompilerType(Compiler::CompilerType type) 96 | { 97 | compilerType = type; 98 | } 99 | 100 | void Compiler::setCompilerName(const QString &name) 101 | { 102 | compilerName = name; 103 | } 104 | 105 | void Compiler::setSourceExtensions(const QString &extensions) 106 | { 107 | sourceExtensions = extensions.split(";", QString::SkipEmptyParts); 108 | } 109 | 110 | void Compiler::setCompilerLocation(const QString &location) 111 | { 112 | compilerLocation = location; 113 | } 114 | 115 | void Compiler::setInterpreterLocation(const QString &location) 116 | { 117 | interpreterLocation = location; 118 | } 119 | 120 | void Compiler::setBytecodeExtensions(const QString &extensions) 121 | { 122 | bytecodeExtensions = extensions.split(";", QString::SkipEmptyParts); 123 | } 124 | 125 | void Compiler::setEnvironment(const QProcessEnvironment &env) 126 | { 127 | environment = env; 128 | } 129 | 130 | void Compiler::setTimeLimitRatio(double ratio) 131 | { 132 | timeLimitRatio = ratio; 133 | } 134 | 135 | void Compiler::setMemoryLimitRatio(double ratio) 136 | { 137 | memoryLimitRatio = ratio; 138 | } 139 | 140 | void Compiler::setDisableMemoryLimitCheck(bool check) 141 | { 142 | disableMemoryLimitCheck = check; 143 | } 144 | 145 | void Compiler::addConfiguration(const QString &name, const QString &arguments1, const QString &arguments2) 146 | { 147 | configurationNames.append(name); 148 | compilerArguments.append(arguments1); 149 | interpreterArguments.append(arguments2); 150 | } 151 | 152 | void Compiler::setConfigName(int index, const QString &name) 153 | { 154 | if (0 <= index && index < configurationNames.size()) { 155 | configurationNames[index] = name; 156 | } 157 | } 158 | 159 | void Compiler::setCompilerArguments(int index, const QString &arguments) 160 | { 161 | if (0 <= index && index < compilerArguments.size()) { 162 | compilerArguments[index] = arguments; 163 | } 164 | } 165 | 166 | void Compiler::setInterpreterArguments(int index, const QString &arguments) 167 | { 168 | if (0 <= index && index < interpreterArguments.size()) { 169 | interpreterArguments[index] = arguments; 170 | } 171 | } 172 | 173 | void Compiler::deleteConfiguration(int index) 174 | { 175 | if (0 <= index && index < configurationNames.size()) { 176 | configurationNames.removeAt(index); 177 | compilerArguments.removeAt(index); 178 | interpreterArguments.removeAt(index); 179 | } 180 | } 181 | 182 | void Compiler::copyFrom(Compiler *other) 183 | { 184 | compilerType = other->getCompilerType(); 185 | compilerName = other->getCompilerName(); 186 | sourceExtensions = other->getSourceExtensions(); 187 | compilerLocation = other->getCompilerLocation(); 188 | interpreterLocation = other->getInterpreterLocation(); 189 | bytecodeExtensions = other->getBytecodeExtensions(); 190 | configurationNames = other->getConfigurationNames(); 191 | compilerArguments = other->getCompilerArguments(); 192 | interpreterArguments = other->getInterpreterArguments(); 193 | environment = other->getEnvironment(); 194 | timeLimitRatio = other->getTimeLimitRatio(); 195 | memoryLimitRatio = other->getMemoryLimitRatio(); 196 | disableMemoryLimitCheck = other->getDisableMemoryLimitCheck(); 197 | } 198 | -------------------------------------------------------------------------------- /compiler.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef COMPILER_H 20 | #define COMPILER_H 21 | 22 | #include 23 | #include 24 | 25 | class Compiler : public QObject 26 | { 27 | Q_OBJECT 28 | public: 29 | enum CompilerType { Typical, InterpretiveWithByteCode, InterpretiveWithoutByteCode }; 30 | 31 | explicit Compiler(QObject *parent = 0); 32 | 33 | CompilerType getCompilerType() const; 34 | const QString& getCompilerName() const; 35 | const QStringList& getSourceExtensions() const; 36 | const QString& getCompilerLocation() const; 37 | const QString& getInterpreterLocation() const; 38 | const QStringList& getBytecodeExtensions() const; 39 | const QStringList& getConfigurationNames() const; 40 | const QStringList& getCompilerArguments() const; 41 | const QStringList& getInterpreterArguments() const; 42 | const QProcessEnvironment& getEnvironment() const; 43 | double getTimeLimitRatio() const; 44 | double getMemoryLimitRatio() const; 45 | bool getDisableMemoryLimitCheck() const; 46 | 47 | void setCompilerType(CompilerType); 48 | void setCompilerName(const QString&); 49 | void setSourceExtensions(const QString&); 50 | void setCompilerLocation(const QString&); 51 | void setInterpreterLocation(const QString&); 52 | void setBytecodeExtensions(const QString&); 53 | void setEnvironment(const QProcessEnvironment&); 54 | void setTimeLimitRatio(double); 55 | void setMemoryLimitRatio(double); 56 | void setDisableMemoryLimitCheck(bool); 57 | 58 | void addConfiguration(const QString&, const QString&, const QString&); 59 | void setConfigName(int, const QString&); 60 | void setCompilerArguments(int, const QString&); 61 | void setInterpreterArguments(int, const QString&); 62 | void deleteConfiguration(int); 63 | 64 | void copyFrom(Compiler*); 65 | 66 | private: 67 | CompilerType compilerType; 68 | QString compilerName; 69 | QStringList sourceExtensions; 70 | QString compilerLocation; 71 | QString interpreterLocation; 72 | QStringList bytecodeExtensions; 73 | QStringList configurationNames; 74 | QStringList compilerArguments; 75 | QStringList interpreterArguments; 76 | QProcessEnvironment environment; 77 | double timeLimitRatio; 78 | double memoryLimitRatio; 79 | bool disableMemoryLimitCheck; 80 | }; 81 | 82 | #endif // COMPILER_H 83 | -------------------------------------------------------------------------------- /compilersettings.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef COMPILERSETTINGS_H 20 | #define COMPILERSETTINGS_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace Ui { 27 | class CompilerSettings; 28 | } 29 | 30 | class Settings; 31 | class Compiler; 32 | 33 | class CompilerSettings : public QWidget 34 | { 35 | Q_OBJECT 36 | 37 | public: 38 | explicit CompilerSettings(QWidget *parent = 0); 39 | ~CompilerSettings(); 40 | void resetEditSettings(Settings*); 41 | bool checkValid(); 42 | 43 | private: 44 | Ui::CompilerSettings *ui; 45 | Settings *editSettings; 46 | Compiler *curCompiler; 47 | QAction *deleteCompilerKeyAction; 48 | void setCurrentCompiler(Compiler*); 49 | void refreshItemState(); 50 | 51 | private slots: 52 | void moveUpCompiler(); 53 | void moveDownCompiler(); 54 | void addCompiler(); 55 | void deleteCompiler(); 56 | void compilerNameChanged(const QString&); 57 | void sourceExtensionsChanged(const QString&); 58 | void compilerListCurrentRowChanged(); 59 | void advancedButtonClicked(); 60 | }; 61 | 62 | #endif // COMPILERSETTINGS_H 63 | -------------------------------------------------------------------------------- /contest.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef CONTEST_H 20 | #define CONTEST_H 21 | 22 | #include 23 | #include 24 | #include "globaltype.h" 25 | #define MagicNumber 0x20111127 26 | 27 | class Task; 28 | class Settings; 29 | class Contestant; 30 | 31 | class Contest : public QObject 32 | { 33 | Q_OBJECT 34 | public: 35 | explicit Contest(QObject *parent = 0); 36 | void setSettings(Settings*); 37 | void setContestTitle(const QString&); 38 | const QString& getContestTitle() const; 39 | Task* getTask(int) const; 40 | const QList& getTaskList() const; 41 | Contestant* getContestant(const QString&) const; 42 | QList getContestantList() const; 43 | int getTotalTimeLimit() const; 44 | void addTask(Task*); 45 | void deleteTask(int); 46 | void refreshContestantList(); 47 | void deleteContestant(const QString&); 48 | void writeToStream(QDataStream&); 49 | void readFromStream(QDataStream&); 50 | 51 | private: 52 | QString contestTitle; 53 | Settings *settings; 54 | QList taskList; 55 | QMap contestantList; 56 | bool stopJudging; 57 | void judge(Contestant*); 58 | void judge(Contestant*, int); 59 | void clearPath(const QString&); 60 | 61 | public slots: 62 | void judge(const QString&); 63 | void judge(const QString&, int); 64 | void judgeAll(); 65 | void stopJudgingSlot(); 66 | 67 | signals: 68 | void taskAddedForContestant(); 69 | void taskDeletedForContestant(int); 70 | void taskAddedForViewer(); 71 | void taskDeletedForViewer(int); 72 | void problemTitleChanged(); 73 | void singleCaseFinished(int, int, int, int); 74 | void taskJudgingStarted(QString); 75 | void taskJudgingFinished(); 76 | void contestantJudgingStart(QString); 77 | void contestantJudgingFinished(); 78 | void compileError(int, int); 79 | void stopJudgingSignal(); 80 | }; 81 | 82 | #endif // CONTEST_H 83 | -------------------------------------------------------------------------------- /contestant.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef CONTESTANT_H 20 | #define CONTESTANT_H 21 | 22 | #include 23 | #include 24 | #include "globaltype.h" 25 | 26 | class Contestant : public QObject 27 | { 28 | Q_OBJECT 29 | public: 30 | explicit Contestant(QObject *parent = 0); 31 | 32 | const QString& getContestantName() const; 33 | bool getCheckJudged(int) const; 34 | CompileState getCompileState(int) const; 35 | const QString& getSourceFile(int) const; 36 | const QString& getCompileMessage(int) const; 37 | const QList& getInputFiles(int) const; 38 | const QList< QList >& getResult(int) const; 39 | const QList& getMessage(int) const; 40 | const QList< QList >& getSocre(int) const; 41 | const QList< QList >& getTimeUsed(int) const; 42 | const QList< QList >& getMemoryUsed(int) const; 43 | QDateTime getJudingTime() const; 44 | int getTaskScore(int) const; 45 | int getTotalScore() const; 46 | int getTotalUsedTime() const; 47 | 48 | void setContestantName(const QString&); 49 | void setCheckJudged(int, bool); 50 | void setCompileState(int, CompileState); 51 | void setSourceFile(int, const QString&); 52 | void setCompileMessage(int, const QString&); 53 | void setInputFiles(int, const QList&); 54 | void setResult(int, const QList< QList >&); 55 | void setMessage(int, const QList&); 56 | void setScore(int, const QList< QList >&); 57 | void setTimeUsed(int, const QList< QList >&); 58 | void setMemoryUsed(int, const QList< QList >&); 59 | void setJudgingTime(QDateTime); 60 | 61 | void writeToStream(QDataStream&); 62 | void readFromStream(QDataStream&); 63 | 64 | private: 65 | QString contestantName; 66 | QList checkJudged; 67 | QList compileState; 68 | QStringList sourceFile; 69 | QStringList compileMesaage; 70 | QList< QList > inputFiles; 71 | QList< QList< QList > > result; 72 | QList< QList > message; 73 | QList< QList< QList > > score; 74 | QList< QList< QList > > timeUsed; 75 | QList< QList< QList > > memoryUsed; 76 | QDateTime judgingTime; 77 | 78 | signals: 79 | 80 | public slots: 81 | void addTask(); 82 | void deleteTask(int); 83 | }; 84 | 85 | #endif // CONTESTANT_H 86 | -------------------------------------------------------------------------------- /cross.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sojiv/Project_lemon/29a39be26b7f2980b6b4568a41d171c6596ca41a/cross.png -------------------------------------------------------------------------------- /detaildialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef DETAILDIALOG_H 20 | #define DETAILDIALOG_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | class Contestant; 27 | class Contest; 28 | 29 | namespace Ui { 30 | class DetailDialog; 31 | } 32 | 33 | class DetailDialog : public QDialog 34 | { 35 | Q_OBJECT 36 | 37 | public: 38 | explicit DetailDialog(QWidget *parent = 0); 39 | ~DetailDialog(); 40 | void refreshViewer(Contest*, Contestant*); 41 | void showDialog(); 42 | 43 | private: 44 | Ui::DetailDialog *ui; 45 | Contest *contest; 46 | Contestant *contestant; 47 | 48 | private slots: 49 | void anchorClicked(const QUrl&); 50 | 51 | signals: 52 | void rejudgeSignal(); 53 | }; 54 | 55 | #endif // DETAILDIALOG_H 56 | -------------------------------------------------------------------------------- /downarrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sojiv/Project_lemon/29a39be26b7f2980b6b4568a41d171c6596ca41a/downarrow.png -------------------------------------------------------------------------------- /editvariabledialog.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #include "editvariabledialog.h" 20 | #include "ui_editvariabledialog.h" 21 | 22 | EditVariableDialog::EditVariableDialog(QWidget *parent) : 23 | QDialog(parent), 24 | ui(new Ui::EditVariableDialog) 25 | { 26 | ui->setupUi(this); 27 | ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); 28 | 29 | connect(ui->variableName, SIGNAL(textChanged(QString)), 30 | this, SLOT(textChanged())); 31 | connect(ui->variableValue, SIGNAL(textChanged(QString)), 32 | this, SLOT(textChanged())); 33 | } 34 | 35 | EditVariableDialog::~EditVariableDialog() 36 | { 37 | delete ui; 38 | } 39 | 40 | void EditVariableDialog::setVariableName(const QString &variable) 41 | { 42 | ui->variableName->setText(variable); 43 | } 44 | 45 | void EditVariableDialog::setVariableValue(const QString &value) 46 | { 47 | ui->variableValue->setText(value); 48 | } 49 | 50 | QString EditVariableDialog::getVariableName() const 51 | { 52 | return ui->variableName->text(); 53 | } 54 | 55 | QString EditVariableDialog::getVariableValue() const 56 | { 57 | return ui->variableValue->text(); 58 | } 59 | 60 | void EditVariableDialog::textChanged() 61 | { 62 | if (! ui->variableName->text().isEmpty() && ! ui->variableValue->text().isEmpty()) { 63 | ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); 64 | } else { 65 | ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /editvariabledialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef EDITVARIABLEDIALOG_H 20 | #define EDITVARIABLEDIALOG_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace Ui { 27 | class EditVariableDialog; 28 | } 29 | 30 | class EditVariableDialog : public QDialog 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | explicit EditVariableDialog(QWidget *parent = 0); 36 | ~EditVariableDialog(); 37 | void setVariableName(const QString&); 38 | void setVariableValue(const QString&); 39 | QString getVariableName() const; 40 | QString getVariableValue() const; 41 | 42 | private: 43 | Ui::EditVariableDialog *ui; 44 | 45 | private slots: 46 | void textChanged(); 47 | }; 48 | 49 | #endif // EDITVARIABLEDIALOG_H 50 | -------------------------------------------------------------------------------- /environmentvariablesdialog.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #include "environmentvariablesdialog.h" 20 | #include "ui_environmentvariablesdialog.h" 21 | #include "editvariabledialog.h" 22 | 23 | EnvironmentVariablesDialog::EnvironmentVariablesDialog(QWidget *parent) : 24 | QDialog(parent), 25 | ui(new Ui::EnvironmentVariablesDialog) 26 | { 27 | ui->setupUi(this); 28 | 29 | connect(ui->addButton, SIGNAL(clicked()), 30 | this, SLOT(addButtonClicked())); 31 | connect(ui->editButton, SIGNAL(clicked()), 32 | this, SLOT(editButtonClicked())); 33 | connect(ui->deleteButton, SIGNAL(clicked()), 34 | this, SLOT(deleteButtonClicked())); 35 | connect(ui->valueViewer, SIGNAL(itemSelectionChanged()), 36 | this, SLOT(viewerSelectionChanged())); 37 | } 38 | 39 | EnvironmentVariablesDialog::~EnvironmentVariablesDialog() 40 | { 41 | delete ui; 42 | } 43 | 44 | void EnvironmentVariablesDialog::setProcessEnvironment(const QProcessEnvironment &environment) 45 | { 46 | QStringList values = environment.toStringList(); 47 | ui->valueViewer->setRowCount(values.size()); 48 | for (int i = 0; i < values.size(); i ++) { 49 | int tmp = values[i].indexOf('='); 50 | QString variable = values[i].mid(0, tmp); 51 | QString value = values[i].mid(tmp + 1); 52 | ui->valueViewer->setItem(i, 0, new QTableWidgetItem(variable)); 53 | ui->valueViewer->setItem(i, 1, new QTableWidgetItem(value)); 54 | } 55 | } 56 | 57 | QProcessEnvironment EnvironmentVariablesDialog::getProcessEnvironment() const 58 | { 59 | QProcessEnvironment environment; 60 | for (int i = 0; i < ui->valueViewer->rowCount(); i ++) { 61 | QString variable = ui->valueViewer->item(i, 0)->text(); 62 | QString value = ui->valueViewer->item(i, 1)->text(); 63 | environment.insert(variable, value); 64 | } 65 | return environment; 66 | } 67 | 68 | void EnvironmentVariablesDialog::addButtonClicked() 69 | { 70 | EditVariableDialog *dialog = new EditVariableDialog(this); 71 | dialog->setWindowTitle(tr("Add New Variable")); 72 | if (dialog->exec() == QDialog::Accepted) { 73 | ui->valueViewer->setRowCount(ui->valueViewer->rowCount() + 1); 74 | ui->valueViewer->setItem(ui->valueViewer->rowCount() - 1, 0, 75 | new QTableWidgetItem(dialog->getVariableName())); 76 | ui->valueViewer->setItem(ui->valueViewer->rowCount() - 1, 1, 77 | new QTableWidgetItem(dialog->getVariableValue())); 78 | } 79 | delete dialog; 80 | } 81 | 82 | void EnvironmentVariablesDialog::editButtonClicked() 83 | { 84 | int index = ui->valueViewer->currentRow(); 85 | EditVariableDialog *dialog = new EditVariableDialog(this); 86 | dialog->setWindowTitle(tr("Edit Variable")); 87 | dialog->setVariableName(ui->valueViewer->item(index, 0)->text()); 88 | dialog->setVariableValue(ui->valueViewer->item(index, 1)->text()); 89 | if (dialog->exec() == QDialog::Accepted) { 90 | ui->valueViewer->setItem(index, 0, new QTableWidgetItem(dialog->getVariableName())); 91 | ui->valueViewer->setItem(index, 1, new QTableWidgetItem(dialog->getVariableValue())); 92 | } 93 | delete dialog; 94 | } 95 | 96 | void EnvironmentVariablesDialog::deleteButtonClicked() 97 | { 98 | int index = ui->valueViewer->currentRow(); 99 | QString variable = ui->valueViewer->item(index, 0)->text(); 100 | 101 | if (QMessageBox::question(this, tr("Lemon"), tr("Are you sure to delete variable %1?").arg(variable), 102 | QMessageBox::Ok | QMessageBox::Cancel) != QMessageBox::Ok) { 103 | return; 104 | } 105 | 106 | for (int i = index + 1; i < ui->valueViewer->rowCount(); i ++) { 107 | ui->valueViewer->setItem(i - 1, 0, new QTableWidgetItem(ui->valueViewer->item(i, 0)->text())); 108 | ui->valueViewer->setItem(i - 1, 1, new QTableWidgetItem(ui->valueViewer->item(i, 1)->text())); 109 | } 110 | ui->valueViewer->setRowCount(ui->valueViewer->rowCount() - 1); 111 | } 112 | 113 | void EnvironmentVariablesDialog::viewerSelectionChanged() 114 | { 115 | QList range = ui->valueViewer->selectedRanges(); 116 | if (range.size() > 0) { 117 | ui->editButton->setEnabled(true); 118 | ui->deleteButton->setEnabled(true); 119 | } else { 120 | ui->editButton->setEnabled(false); 121 | ui->deleteButton->setEnabled(false); 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /environmentvariablesdialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef ENVIRONMENTVARIABLESDIALOG_H 20 | #define ENVIRONMENTVARIABLESDIALOG_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace Ui { 27 | class EnvironmentVariablesDialog; 28 | } 29 | 30 | class EnvironmentVariablesDialog : public QDialog 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | explicit EnvironmentVariablesDialog(QWidget *parent = 0); 36 | ~EnvironmentVariablesDialog(); 37 | void setProcessEnvironment(const QProcessEnvironment&); 38 | QProcessEnvironment getProcessEnvironment() const; 39 | 40 | private: 41 | Ui::EnvironmentVariablesDialog *ui; 42 | 43 | private slots: 44 | void addButtonClicked(); 45 | void editButtonClicked(); 46 | void deleteButtonClicked(); 47 | void viewerSelectionChanged(); 48 | }; 49 | 50 | #endif // ENVIRONMENTVARIABLESDIALOG_H 51 | -------------------------------------------------------------------------------- /exportutil.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef EXPORTUTIL_H 20 | #define EXPORTUTIL_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #ifdef Q_OS_WIN32 27 | #include 28 | #endif 29 | 30 | class Contest; 31 | class Contestant; 32 | 33 | class ExportUtil : public QObject 34 | { 35 | Q_OBJECT 36 | public: 37 | explicit ExportUtil(QObject *parent = 0); 38 | static void exportResult(QWidget*, Contest*); 39 | 40 | private: 41 | static QString getContestantHtmlCode(Contest*, Contestant*); 42 | static void exportHtml(QWidget*, Contest*, const QString&); 43 | static void exportCsv(QWidget*, Contest*, const QString&); 44 | static void exportXls(QWidget*, Contest*, const QString&); 45 | 46 | signals: 47 | 48 | public slots: 49 | 50 | }; 51 | 52 | #endif // EXPORTUTIL_H 53 | -------------------------------------------------------------------------------- /filelineedit.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #include "filelineedit.h" 20 | #include "settings.h" 21 | 22 | FileLineEdit::FileLineEdit(QWidget *parent) : 23 | QLineEdit(parent) 24 | { 25 | completer = 0; 26 | } 27 | 28 | void FileLineEdit::getFiles(const QString &curDir, const QString &prefix, QStringList &files) 29 | { 30 | QDir dir(curDir); 31 | if (! nameFilters.isEmpty()) { 32 | dir.setNameFilters(nameFilters); 33 | } 34 | QStringList list = dir.entryList(filters); 35 | for (int i = 0; i < list.size(); i ++) { 36 | list[i] = prefix + list[i]; 37 | } 38 | files.append(list); 39 | list = dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot); 40 | for (int i = 0; i < list.size(); i ++) { 41 | getFiles(curDir + list[i] + QDir::separator(), 42 | prefix + list[i] + QDir::separator(), files); 43 | } 44 | } 45 | 46 | void FileLineEdit::setFilters(QDir::Filters _filters) 47 | { 48 | filters = _filters; 49 | } 50 | 51 | void FileLineEdit::setFileExtensions(const QStringList &extensions) 52 | { 53 | nameFilters.clear(); 54 | for (int i = 0; i < extensions.size(); i ++) { 55 | nameFilters.append("*." + extensions[i]); 56 | } 57 | refreshFileList(); 58 | } 59 | 60 | void FileLineEdit::refreshFileList() 61 | { 62 | QStringList files; 63 | getFiles(Settings::dataPath(), "", files); 64 | if (completer) delete completer; 65 | completer = new QCompleter(files, this); 66 | setCompleter(completer); 67 | } 68 | -------------------------------------------------------------------------------- /filelineedit.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef FILELINEEDIT_H 20 | #define FILELINEEDIT_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | class FileLineEdit : public QLineEdit 27 | { 28 | Q_OBJECT 29 | public: 30 | explicit FileLineEdit(QWidget *parent = 0); 31 | void setFilters(QDir::Filters); 32 | void setFileExtensions(const QStringList&); 33 | void getFiles(const QString&, const QString&, QStringList&); 34 | 35 | private: 36 | QCompleter *completer; 37 | QStringList nameFilters; 38 | QDir::Filters filters; 39 | 40 | public slots: 41 | void refreshFileList(); 42 | }; 43 | 44 | #endif // FILELINEEDIT_H 45 | -------------------------------------------------------------------------------- /forms_unix/detaildialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | DetailDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 709 10 | 520 11 | 12 | 13 | 14 | Details 15 | 16 | 17 | 18 | 19 | 20 | Qt::LinksAccessibleByMouse 21 | 22 | 23 | false 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | Qt::Horizontal 33 | 34 | 35 | 36 | 40 37 | 20 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | &Close 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | closeButton 57 | clicked() 58 | DetailDialog 59 | accept() 60 | 61 | 62 | 650 63 | 493 64 | 65 | 66 | 354 67 | 259 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /forms_unix/editvariabledialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | EditVariableDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 325 10 | 128 11 | 12 | 13 | 14 | 15 | 325 16 | 128 17 | 18 | 19 | 20 | 21 | 325 22 | 128 23 | 24 | 25 | 26 | Dialog 27 | 28 | 29 | 30 | 8 31 | 32 | 33 | 34 | 35 | 10 36 | 37 | 38 | 8 39 | 40 | 41 | 42 | 43 | font-size:11pt; 44 | 45 | 46 | Variable Name 47 | 48 | 49 | 50 | 51 | 52 | 53 | font-size:11pt; 54 | 55 | 56 | 57 | 58 | 59 | 60 | font-size:11pt; 61 | 62 | 63 | Variable Value 64 | 65 | 66 | 67 | 68 | 69 | 70 | font-size:11pt; 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | font-size:10pt; 80 | 81 | 82 | Qt::Horizontal 83 | 84 | 85 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | buttonBox 95 | accepted() 96 | EditVariableDialog 97 | accept() 98 | 99 | 100 | 248 101 | 254 102 | 103 | 104 | 157 105 | 274 106 | 107 | 108 | 109 | 110 | buttonBox 111 | rejected() 112 | EditVariableDialog 113 | reject() 114 | 115 | 116 | 316 117 | 260 118 | 119 | 120 | 286 121 | 274 122 | 123 | 124 | 125 | 126 | 127 | -------------------------------------------------------------------------------- /forms_unix/environmentvariablesdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | EnvironmentVariablesDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 298 10 | 196 11 | 12 | 13 | 14 | 15 | 298 16 | 196 17 | 18 | 19 | 20 | Extra Environment Variables 21 | 22 | 23 | 24 | 8 25 | 26 | 27 | 28 | 29 | font-size: 11pt; 30 | 31 | 32 | QAbstractItemView::NoEditTriggers 33 | 34 | 35 | QAbstractItemView::SingleSelection 36 | 37 | 38 | QAbstractItemView::SelectRows 39 | 40 | 41 | 80 42 | 43 | 44 | false 45 | 46 | 47 | true 48 | 49 | 50 | false 51 | 52 | 53 | 25 54 | 55 | 56 | 25 57 | 58 | 59 | 60 | Variable 61 | 62 | 63 | 64 | 65 | Value 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | Qt::Horizontal 76 | 77 | 78 | 79 | 40 80 | 20 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | &Add 89 | 90 | 91 | 92 | 93 | 94 | 95 | false 96 | 97 | 98 | &Edit 99 | 100 | 101 | 102 | 103 | 104 | 105 | false 106 | 107 | 108 | &Delete 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | font-size:10pt; 118 | 119 | 120 | Qt::Horizontal 121 | 122 | 123 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | buttonBox 133 | accepted() 134 | EnvironmentVariablesDialog 135 | accept() 136 | 137 | 138 | 248 139 | 254 140 | 141 | 142 | 157 143 | 274 144 | 145 | 146 | 147 | 148 | buttonBox 149 | rejected() 150 | EnvironmentVariablesDialog 151 | reject() 152 | 153 | 154 | 316 155 | 260 156 | 157 | 158 | 286 159 | 274 160 | 161 | 162 | 163 | 164 | 165 | -------------------------------------------------------------------------------- /forms_unix/judgingdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | JudgingDialog 4 | 5 | 6 | Qt::WindowModal 7 | 8 | 9 | 10 | 0 11 | 0 12 | 448 13 | 263 14 | 15 | 16 | 17 | 18 | 448 19 | 263 20 | 21 | 22 | 23 | Judging 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | false 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | Qt::Horizontal 42 | 43 | 44 | 45 | 40 46 | 20 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | Cancel 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /forms_unix/newcontestdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | NewContestDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 450 10 | 320 11 | 12 | 13 | 14 | 15 | 450 16 | 320 17 | 18 | 19 | 20 | New Contest 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | font-size:10pt; 30 | 31 | 32 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | NewContestWidget 41 | QWidget 42 |
newcontestwidget.h
43 | 1 44 |
45 |
46 | 47 | 48 | 49 | buttonBox 50 | accepted() 51 | NewContestDialog 52 | accept() 53 | 54 | 55 | 224 56 | 294 57 | 58 | 59 | 224 60 | 159 61 | 62 | 63 | 64 | 65 | buttonBox 66 | rejected() 67 | NewContestDialog 68 | reject() 69 | 70 | 71 | 224 72 | 294 73 | 74 | 75 | 224 76 | 159 77 | 78 | 79 | 80 | 81 |
82 | -------------------------------------------------------------------------------- /forms_unix/newcontestwidget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | NewContestWidget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 392 10 | 290 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | 12 21 | 22 | 23 | 15 24 | 25 | 26 | 27 | 28 | font-size:11pt;font-weight:bold; 29 | 30 | 31 | Contest Title 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | font-size:11pt;font-weight:bold; 42 | 43 | 44 | Saving Name 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | font-size:11pt;font-weight:bold; 55 | 56 | 57 | Contest Path 58 | 59 | 60 | 61 | 62 | 63 | 64 | 10 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | ... 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | Qt::Vertical 84 | 85 | 86 | 87 | 20 88 | 168 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /forms_unix/opencontestdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | OpenContestDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 450 10 | 320 11 | 12 | 13 | 14 | 15 | 450 16 | 320 17 | 18 | 19 | 20 | Open an Existing Contest 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | font-size:10pt; 30 | 31 | 32 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | OpenContestWidget 41 | QWidget 42 |
opencontestwidget.h
43 | 1 44 |
45 |
46 | 47 | 48 | 49 | buttonBox 50 | accepted() 51 | OpenContestDialog 52 | accept() 53 | 54 | 55 | 224 56 | 294 57 | 58 | 59 | 224 60 | 159 61 | 62 | 63 | 64 | 65 | buttonBox 66 | rejected() 67 | OpenContestDialog 68 | reject() 69 | 70 | 71 | 224 72 | 294 73 | 74 | 75 | 224 76 | 159 77 | 78 | 79 | 80 | 81 |
82 | -------------------------------------------------------------------------------- /forms_unix/opencontestwidget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | OpenContestWidget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | font-size: 11pt; 21 | 22 | 23 | QAbstractItemView::NoEditTriggers 24 | 25 | 26 | QAbstractItemView::SingleSelection 27 | 28 | 29 | QAbstractItemView::SelectRows 30 | 31 | 32 | false 33 | 34 | 35 | 80 36 | 37 | 38 | true 39 | 40 | 41 | false 42 | 43 | 44 | 25 45 | 46 | 47 | 25 48 | 49 | 50 | 51 | Title 52 | 53 | 54 | 55 | 11 56 | 75 57 | true 58 | 59 | 60 | 61 | 62 | 63 | Location 64 | 65 | 66 | 67 | 11 68 | 75 69 | true 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | Qt::Vertical 81 | 82 | 83 | 84 | 20 85 | 40 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 32 95 | 32 96 | 97 | 98 | 99 | 100 | :/icon/add.png:/icon/add.png 101 | 102 | 103 | 104 | 105 | 106 | 107 | false 108 | 109 | 110 | 111 | 32 112 | 32 113 | 114 | 115 | 116 | 117 | :/icon/rod.png:/icon/rod.png 118 | 119 | 120 | 121 | 122 | 123 | 124 | Qt::Vertical 125 | 126 | 127 | 128 | 20 129 | 40 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | -------------------------------------------------------------------------------- /forms_unix/optionsdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | OptionsDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 362 10 | 437 11 | 12 | 13 | 14 | 15 | 362 16 | 437 17 | 18 | 19 | 20 | Options 21 | 22 | 23 | 24 | 25 | 26 | font-size: 11pt; 27 | 28 | 29 | 0 30 | 31 | 32 | 33 | General 34 | 35 | 36 | 37 | 38 | Compiler 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | font-size:10pt; 47 | 48 | 49 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | GeneralSettings 58 | QWidget 59 |
generalsettings.h
60 | 1 61 |
62 | 63 | CompilerSettings 64 | QWidget 65 |
compilersettings.h
66 | 1 67 |
68 |
69 | 70 | tabWidget 71 | 72 | 73 | 74 | 75 | buttonBox 76 | rejected() 77 | OptionsDialog 78 | reject() 79 | 80 | 81 | 176 82 | 414 83 | 84 | 85 | 176 86 | 219 87 | 88 | 89 | 90 | 91 |
92 | -------------------------------------------------------------------------------- /forms_unix/welcomedialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | WelcomeDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 470 10 | 350 11 | 12 | 13 | 14 | Welcome 15 | 16 | 17 | 18 | 19 | 20 | font-size: 11pt; 21 | 22 | 23 | 0 24 | 25 | 26 | 27 | Open 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | New 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | font-size:10pt; 51 | 52 | 53 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | OpenContestWidget 62 | QWidget 63 |
opencontestwidget.h
64 | 1 65 |
66 | 67 | NewContestWidget 68 | QWidget 69 |
newcontestwidget.h
70 | 1 71 |
72 |
73 | 74 | 75 | 76 | buttonBox 77 | accepted() 78 | WelcomeDialog 79 | accept() 80 | 81 | 82 | 234 83 | 324 84 | 85 | 86 | 234 87 | 174 88 | 89 | 90 | 91 | 92 | buttonBox 93 | rejected() 94 | WelcomeDialog 95 | reject() 96 | 97 | 98 | 234 99 | 324 100 | 101 | 102 | 234 103 | 174 104 | 105 | 106 | 107 | 108 |
109 | -------------------------------------------------------------------------------- /forms_win32/detaildialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | DetailDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 709 10 | 520 11 | 12 | 13 | 14 | Details 15 | 16 | 17 | 18 | 19 | 20 | Qt::LinksAccessibleByMouse 21 | 22 | 23 | false 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | Qt::Horizontal 33 | 34 | 35 | 36 | 40 37 | 20 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | &Close 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | closeButton 57 | clicked() 58 | DetailDialog 59 | accept() 60 | 61 | 62 | 650 63 | 493 64 | 65 | 66 | 354 67 | 259 68 | 69 | 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /forms_win32/editvariabledialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | EditVariableDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 321 10 | 106 11 | 12 | 13 | 14 | 15 | 321 16 | 106 17 | 18 | 19 | 20 | 21 | 321 22 | 106 23 | 24 | 25 | 26 | Dialog 27 | 28 | 29 | 30 | 8 31 | 32 | 33 | 34 | 35 | 10 36 | 37 | 38 | 8 39 | 40 | 41 | 42 | 43 | font-size:9pt; 44 | 45 | 46 | Variable Name 47 | 48 | 49 | 50 | 51 | 52 | 53 | font-size:9pt; 54 | 55 | 56 | 57 | 58 | 59 | 60 | font-size:9pt; 61 | 62 | 63 | Variable Value 64 | 65 | 66 | 67 | 68 | 69 | 70 | font-size:9pt; 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | font-size:9pt; 80 | 81 | 82 | Qt::Horizontal 83 | 84 | 85 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | buttonBox 95 | accepted() 96 | EditVariableDialog 97 | accept() 98 | 99 | 100 | 248 101 | 254 102 | 103 | 104 | 157 105 | 274 106 | 107 | 108 | 109 | 110 | buttonBox 111 | rejected() 112 | EditVariableDialog 113 | reject() 114 | 115 | 116 | 316 117 | 260 118 | 119 | 120 | 286 121 | 274 122 | 123 | 124 | 125 | 126 | 127 | -------------------------------------------------------------------------------- /forms_win32/environmentvariablesdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | EnvironmentVariablesDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 298 10 | 196 11 | 12 | 13 | 14 | 15 | 298 16 | 196 17 | 18 | 19 | 20 | Extra Environment Variables 21 | 22 | 23 | 24 | 8 25 | 26 | 27 | 28 | 29 | font-size: 9pt; 30 | 31 | 32 | QAbstractItemView::NoEditTriggers 33 | 34 | 35 | QAbstractItemView::SingleSelection 36 | 37 | 38 | QAbstractItemView::SelectRows 39 | 40 | 41 | 80 42 | 43 | 44 | false 45 | 46 | 47 | true 48 | 49 | 50 | false 51 | 52 | 53 | 25 54 | 55 | 56 | 25 57 | 58 | 59 | 60 | Variable 61 | 62 | 63 | 64 | 65 | Value 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | Qt::Horizontal 76 | 77 | 78 | 79 | 40 80 | 20 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | &Add 89 | 90 | 91 | 92 | 93 | 94 | 95 | false 96 | 97 | 98 | &Edit 99 | 100 | 101 | 102 | 103 | 104 | 105 | false 106 | 107 | 108 | &Delete 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | font-size:9pt; 118 | 119 | 120 | Qt::Horizontal 121 | 122 | 123 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | buttonBox 133 | accepted() 134 | EnvironmentVariablesDialog 135 | accept() 136 | 137 | 138 | 248 139 | 254 140 | 141 | 142 | 157 143 | 274 144 | 145 | 146 | 147 | 148 | buttonBox 149 | rejected() 150 | EnvironmentVariablesDialog 151 | reject() 152 | 153 | 154 | 316 155 | 260 156 | 157 | 158 | 286 159 | 274 160 | 161 | 162 | 163 | 164 | 165 | -------------------------------------------------------------------------------- /forms_win32/judgingdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | JudgingDialog 4 | 5 | 6 | Qt::WindowModal 7 | 8 | 9 | 10 | 0 11 | 0 12 | 448 13 | 263 14 | 15 | 16 | 17 | 18 | 448 19 | 263 20 | 21 | 22 | 23 | Judging 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | false 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | Qt::Horizontal 42 | 43 | 44 | 45 | 40 46 | 20 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | Cancel 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /forms_win32/newcontestdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | NewContestDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 450 10 | 320 11 | 12 | 13 | 14 | 15 | 450 16 | 320 17 | 18 | 19 | 20 | New Contest 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | font-size:9pt; 30 | 31 | 32 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | NewContestWidget 41 | QWidget 42 |
newcontestwidget.h
43 | 1 44 |
45 |
46 | 47 | 48 | 49 | buttonBox 50 | accepted() 51 | NewContestDialog 52 | accept() 53 | 54 | 55 | 224 56 | 294 57 | 58 | 59 | 224 60 | 159 61 | 62 | 63 | 64 | 65 | buttonBox 66 | rejected() 67 | NewContestDialog 68 | reject() 69 | 70 | 71 | 224 72 | 294 73 | 74 | 75 | 224 76 | 159 77 | 78 | 79 | 80 | 81 |
82 | -------------------------------------------------------------------------------- /forms_win32/newcontestwidget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | NewContestWidget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 392 10 | 290 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | 12 21 | 22 | 23 | 15 24 | 25 | 26 | 27 | 28 | font-size:10pt;font-weight:bold; 29 | 30 | 31 | Contest Title 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | font-size:10pt;font-weight:bold; 42 | 43 | 44 | Saving Name 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | font-size:10pt;font-weight:bold; 55 | 56 | 57 | Contest Path 58 | 59 | 60 | 61 | 62 | 63 | 64 | 10 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | ... 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | Qt::Vertical 84 | 85 | 86 | 87 | 20 88 | 168 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /forms_win32/opencontestdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | OpenContestDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 450 10 | 320 11 | 12 | 13 | 14 | 15 | 450 16 | 320 17 | 18 | 19 | 20 | Open an Existing Contest 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | font-size:9pt; 30 | 31 | 32 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | OpenContestWidget 41 | QWidget 42 |
opencontestwidget.h
43 | 1 44 |
45 |
46 | 47 | 48 | 49 | buttonBox 50 | accepted() 51 | OpenContestDialog 52 | accept() 53 | 54 | 55 | 224 56 | 294 57 | 58 | 59 | 224 60 | 159 61 | 62 | 63 | 64 | 65 | buttonBox 66 | rejected() 67 | OpenContestDialog 68 | reject() 69 | 70 | 71 | 224 72 | 294 73 | 74 | 75 | 224 76 | 159 77 | 78 | 79 | 80 | 81 |
82 | -------------------------------------------------------------------------------- /forms_win32/opencontestwidget.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | OpenContestWidget 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Form 15 | 16 | 17 | 18 | 19 | 20 | font-size: 9pt; 21 | 22 | 23 | QAbstractItemView::NoEditTriggers 24 | 25 | 26 | QAbstractItemView::SingleSelection 27 | 28 | 29 | QAbstractItemView::SelectRows 30 | 31 | 32 | false 33 | 34 | 35 | 80 36 | 37 | 38 | true 39 | 40 | 41 | false 42 | 43 | 44 | 25 45 | 46 | 47 | 25 48 | 49 | 50 | 51 | Title 52 | 53 | 54 | 55 | 9 56 | 75 57 | true 58 | 59 | 60 | 61 | 62 | 63 | Location 64 | 65 | 66 | 67 | 9 68 | 75 69 | true 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | Qt::Vertical 81 | 82 | 83 | 84 | 20 85 | 40 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 27 95 | 27 96 | 97 | 98 | 99 | 100 | :/icon/add.png:/icon/add.png 101 | 102 | 103 | 104 | 105 | 106 | 107 | false 108 | 109 | 110 | 111 | 27 112 | 27 113 | 114 | 115 | 116 | 117 | :/icon/rod.png:/icon/rod.png 118 | 119 | 120 | 121 | 122 | 123 | 124 | Qt::Vertical 125 | 126 | 127 | 128 | 20 129 | 40 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | -------------------------------------------------------------------------------- /forms_win32/optionsdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | OptionsDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 291 10 | 377 11 | 12 | 13 | 14 | 15 | 291 16 | 377 17 | 18 | 19 | 20 | Options 21 | 22 | 23 | 24 | 25 | 26 | font-size: 9pt; 27 | 28 | 29 | 0 30 | 31 | 32 | 33 | General 34 | 35 | 36 | 37 | 38 | Compiler 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | font-size:9pt; 47 | 48 | 49 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | GeneralSettings 58 | QWidget 59 |
generalsettings.h
60 | 1 61 |
62 | 63 | CompilerSettings 64 | QWidget 65 |
compilersettings.h
66 | 1 67 |
68 |
69 | 70 | tabWidget 71 | 72 | 73 | 74 | 75 | buttonBox 76 | rejected() 77 | OptionsDialog 78 | reject() 79 | 80 | 81 | 176 82 | 414 83 | 84 | 85 | 176 86 | 219 87 | 88 | 89 | 90 | 91 |
92 | -------------------------------------------------------------------------------- /forms_win32/welcomedialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | WelcomeDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 470 10 | 350 11 | 12 | 13 | 14 | Welcome 15 | 16 | 17 | 18 | 19 | 20 | font-size: 9pt; 21 | 22 | 23 | 0 24 | 25 | 26 | 27 | Open 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | New 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | font-size:9pt; 51 | 52 | 53 | QDialogButtonBox::Cancel|QDialogButtonBox::Ok 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | OpenContestWidget 62 | QWidget 63 |
opencontestwidget.h
64 | 1 65 |
66 | 67 | NewContestWidget 68 | QWidget 69 |
newcontestwidget.h
70 | 1 71 |
72 |
73 | 74 | 75 | 76 | buttonBox 77 | accepted() 78 | WelcomeDialog 79 | accept() 80 | 81 | 82 | 234 83 | 324 84 | 85 | 86 | 234 87 | 174 88 | 89 | 90 | 91 | 92 | buttonBox 93 | rejected() 94 | WelcomeDialog 95 | reject() 96 | 97 | 98 | 234 99 | 324 100 | 101 | 102 | 234 103 | 174 104 | 105 | 106 | 107 | 108 |
109 | -------------------------------------------------------------------------------- /generalsettings.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef GENERALSETTINGS_H 20 | #define GENERALSETTINGS_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace Ui { 27 | class GeneralSettings; 28 | } 29 | 30 | class Settings; 31 | 32 | class GeneralSettings : public QWidget 33 | { 34 | Q_OBJECT 35 | 36 | public: 37 | explicit GeneralSettings(QWidget *parent = 0); 38 | ~GeneralSettings(); 39 | void resetEditSettings(Settings*); 40 | bool checkValid(); 41 | 42 | private: 43 | Ui::GeneralSettings *ui; 44 | Settings *editSettings; 45 | 46 | private slots: 47 | void defaultFullScoreChanged(const QString&); 48 | void defaultTimeLimitChanged(const QString&); 49 | void defaultMemoryLimitChanged(const QString&); 50 | void compileTimeLimitChanged(const QString&); 51 | void specialJudgeTimeLimitChanged(const QString&); 52 | void fileSizeLimitChanged(const QString&); 53 | void numberOfThreadsChanged(const QString&); 54 | void inputFileExtensionsChanged(const QString&); 55 | void outputFileExtensionsChanged(const QString&); 56 | }; 57 | 58 | #endif // GENERALSETTINGS_H 59 | -------------------------------------------------------------------------------- /globaltype.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef GLOBALTYPE_H 20 | #define GLOBALTYPE_H 21 | 22 | enum CompileState { CompileSuccessfully, NoValidSourceFile, CompileError, 23 | CompileTimeLimitExceeded, InvalidCompiler }; 24 | 25 | enum ResultState { CorrectAnswer, WrongAnswer, PartlyCorrect, 26 | TimeLimitExceeded, MemoryLimitExceeded, 27 | CannotStartProgram, FileError, RunTimeError, 28 | InvalidSpecialJudge, SpecialJudgeTimeLimitExceeded, 29 | SpecialJudgeRunTimeError }; 30 | 31 | #endif // GLOBALTYPE_H 32 | -------------------------------------------------------------------------------- /icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sojiv/Project_lemon/29a39be26b7f2980b6b4568a41d171c6596ca41a/icon.ico -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sojiv/Project_lemon/29a39be26b7f2980b6b4568a41d171c6596ca41a/icon.png -------------------------------------------------------------------------------- /judgingdialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef JUDGINGDIALOG_H 20 | #define JUDGINGDIALOG_H 21 | 22 | #include 23 | #include 24 | #include 25 | #include "globaltype.h" 26 | 27 | class Contest; 28 | 29 | namespace Ui { 30 | class JudgingDialog; 31 | } 32 | 33 | class JudgingDialog : public QDialog 34 | { 35 | Q_OBJECT 36 | 37 | public: 38 | explicit JudgingDialog(QWidget *parent = 0); 39 | ~JudgingDialog(); 40 | void setContest(Contest*); 41 | void judge(const QStringList&); 42 | void judge(const QString&, int); 43 | void judgeAll(); 44 | void reject(); 45 | 46 | private slots: 47 | void stopJudgingSlot(); 48 | 49 | private: 50 | Ui::JudgingDialog *ui; 51 | Contest *curContest; 52 | QTextCursor *cursor; 53 | bool stopJudging; 54 | 55 | public slots: 56 | void singleCaseFinished(int, int, int, int); 57 | void taskJudgingStarted(const QString&); 58 | void contestantJudgingStart(const QString&); 59 | void contestantJudgingFinished(); 60 | void compileError(int, int); 61 | 62 | signals: 63 | void stopJudgingSignal(); 64 | }; 65 | 66 | #endif // JUDGINGDIALOG_H 67 | -------------------------------------------------------------------------------- /judgingthread.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef JUDGINGTHREAD_H 20 | #define JUDGINGTHREAD_H 21 | 22 | #include 23 | #include 24 | #include "globaltype.h" 25 | 26 | class Task; 27 | 28 | class JudgingThread : public QThread 29 | { 30 | Q_OBJECT 31 | public: 32 | explicit JudgingThread(QObject *parent = 0); 33 | void setCheckRejudgeMode(bool); 34 | void setExtraTimeRatio(double); 35 | void setEnvironment(const QProcessEnvironment&); 36 | void setWorkingDirectory(const QString&); 37 | void setSpecialJudgeTimeLimit(int); 38 | void setExecutableFile(const QString&); 39 | void setArguments(const QString&); 40 | void setAnswerFile(const QString&); 41 | void setInputFile(const QString&); 42 | void setOutputFile(const QString&); 43 | void setDiffPath(const QString&); 44 | void setTask(Task*); 45 | void setFullScore(int); 46 | void setTimeLimit(int); 47 | void setMemoryLimit(int); 48 | int getTimeUsed() const; 49 | int getMemoryUsed() const; 50 | int getScore() const; 51 | ResultState getResult() const; 52 | const QString& getMessage() const; 53 | bool getNeedRejudge() const; 54 | void run(); 55 | 56 | private: 57 | bool checkRejudgeMode; 58 | bool needRejudge; 59 | double extraTimeRatio; 60 | QProcessEnvironment environment; 61 | QString workingDirectory; 62 | QString executableFile; 63 | QString arguments; 64 | QString answerFile; 65 | QString inputFile; 66 | QString outputFile; 67 | QString diffPath; 68 | Task *task; 69 | int specialJudgeTimeLimit; 70 | int fullScore; 71 | int timeLimit; 72 | int memoryLimit; 73 | int timeUsed; 74 | int memoryUsed; 75 | int score; 76 | ResultState result; 77 | QString message; 78 | bool stopJudging; 79 | void compareLineByLine(const QString&); 80 | void compareIgnoreSpaces(const QString&); 81 | void compareWithDiff(const QString&); 82 | void compareRealNumbers(const QString&); 83 | void specialJudge(const QString&); 84 | void runProgram(); 85 | void judgeOutput(); 86 | void judgeTraditionalTask(); 87 | void judgeAnswersOnlyTask(); 88 | 89 | public slots: 90 | void stopJudgingSlot(); 91 | }; 92 | 93 | #endif // JUDGINGTHREAD_H 94 | -------------------------------------------------------------------------------- /lemon.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef LEMON_H 20 | #define LEMON_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace Ui { 27 | class Lemon; 28 | } 29 | 30 | class Contest; 31 | class Settings; 32 | class OptionsDialog; 33 | 34 | class Lemon : public QMainWindow 35 | { 36 | Q_OBJECT 37 | 38 | public: 39 | explicit Lemon(QWidget *parent = 0); 40 | ~Lemon(); 41 | void changeEvent(QEvent*); 42 | void closeEvent(QCloseEvent*); 43 | void welcome(); 44 | 45 | private: 46 | Ui::Lemon *ui; 47 | Contest *curContest; 48 | Settings *settings; 49 | QFileSystemWatcher *dataDirWatcher; 50 | QString curFile; 51 | QList languageActions; 52 | QTranslator *appTranslator; 53 | QTranslator *qtTranslator; 54 | void loadUiLanguage(); 55 | void insertWatchPath(const QString&, QFileSystemWatcher*); 56 | void newContest(const QString&, const QString&, const QString&); 57 | void saveContest(const QString&); 58 | void loadContest(const QString&); 59 | void getFiles(const QString&, const QStringList&, QMap&); 60 | void addTask(const QString&, const QList< QPair >&, int, int, int); 61 | static bool compareFileName(const QPair&, const QPair&); 62 | 63 | private slots: 64 | void summarySelectionChanged(); 65 | void resetDataWatcher(); 66 | void showOptionsDialog(); 67 | void refreshButtonClicked(); 68 | void tabIndexChanged(int); 69 | void viewerSelectionChanged(); 70 | void contestantDeleted(); 71 | void newAction(); 72 | void closeAction(); 73 | void loadAction(); 74 | void addTasksAction(); 75 | void makeSelfTest(); 76 | void exportResult(); 77 | void aboutLemon(); 78 | void setUiLanguage(); 79 | 80 | signals: 81 | void dataPathChanged(); 82 | }; 83 | 84 | #endif // LEMON_H 85 | -------------------------------------------------------------------------------- /lemon.pro: -------------------------------------------------------------------------------- 1 | # 2 | # Project Lemon - A tiny judging environment for OI contest 3 | # Copyright (C) 2011 Zhipeng Jia 4 | # 5 | # This program is free software: you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation, either version 3 of the License, or 8 | # (at your option) any later version. 9 | # 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | # 18 | 19 | QT += core gui network 20 | 21 | TARGET = lemon 22 | TEMPLATE = app 23 | 24 | SOURCES += main.cpp \ 25 | lemon.cpp \ 26 | contest.cpp \ 27 | task.cpp \ 28 | testcase.cpp \ 29 | settings.cpp \ 30 | compiler.cpp \ 31 | filelineedit.cpp \ 32 | summarytree.cpp \ 33 | taskeditwidget.cpp \ 34 | testcaseeditwidget.cpp \ 35 | generalsettings.cpp \ 36 | compilersettings.cpp \ 37 | addtestcaseswizard.cpp \ 38 | contestant.cpp \ 39 | judgingdialog.cpp \ 40 | judgingthread.cpp \ 41 | optionsdialog.cpp \ 42 | resultviewer.cpp \ 43 | assignmentthread.cpp \ 44 | detaildialog.cpp \ 45 | newcontestwidget.cpp \ 46 | opencontestwidget.cpp \ 47 | newcontestdialog.cpp \ 48 | opencontestdialog.cpp \ 49 | welcomedialog.cpp \ 50 | addtaskdialog.cpp \ 51 | qtlockedfile/qtlockedfile.cpp \ 52 | qtsingleapplication/qtsinglecoreapplication.cpp \ 53 | qtsingleapplication/qtsingleapplication.cpp \ 54 | qtsingleapplication/qtlocalpeer.cpp \ 55 | advancedcompilersettingsdialog.cpp \ 56 | environmentvariablesdialog.cpp \ 57 | editvariabledialog.cpp \ 58 | addcompilerwizard.cpp \ 59 | selftestutil.cpp \ 60 | exportutil.cpp 61 | 62 | win32:SOURCES += qtlockedfile/qtlockedfile_win.cpp 63 | unix:SOURCES += qtlockedfile/qtlockedfile_unix.cpp 64 | 65 | HEADERS += lemon.h \ 66 | contest.h \ 67 | task.h \ 68 | testcase.h \ 69 | settings.h \ 70 | compiler.h \ 71 | filelineedit.h \ 72 | summarytree.h \ 73 | taskeditwidget.h \ 74 | testcaseeditwidget.h \ 75 | generalsettings.h \ 76 | compilersettings.h \ 77 | addtestcaseswizard.h \ 78 | contestant.h \ 79 | judgingdialog.h \ 80 | judgingthread.h \ 81 | optionsdialog.h \ 82 | resultviewer.h \ 83 | assignmentthread.h \ 84 | globaltype.h \ 85 | detaildialog.h \ 86 | newcontestwidget.h \ 87 | opencontestwidget.h \ 88 | newcontestdialog.h \ 89 | opencontestdialog.h \ 90 | welcomedialog.h \ 91 | addtaskdialog.h \ 92 | qtlockedfile/qtlockedfile.h \ 93 | qtsingleapplication/qtsinglecoreapplication.h \ 94 | qtsingleapplication/qtsingleapplication.h \ 95 | qtsingleapplication/qtlocalpeer.h \ 96 | advancedcompilersettingsdialog.h \ 97 | environmentvariablesdialog.h \ 98 | editvariabledialog.h \ 99 | addcompilerwizard.h \ 100 | selftestutil.h \ 101 | exportutil.h 102 | 103 | win32:FORMS += forms_win32/lemon.ui \ 104 | forms_win32/taskeditwidget.ui \ 105 | forms_win32/testcaseeditwidget.ui \ 106 | forms_win32/generalsettings.ui \ 107 | forms_win32/compilersettings.ui \ 108 | forms_win32/addtestcaseswizard.ui \ 109 | forms_win32/judgingdialog.ui \ 110 | forms_win32/optionsdialog.ui \ 111 | forms_win32/detaildialog.ui \ 112 | forms_win32/newcontestwidget.ui \ 113 | forms_win32/opencontestwidget.ui \ 114 | forms_win32/newcontestdialog.ui \ 115 | forms_win32/opencontestdialog.ui \ 116 | forms_win32/welcomedialog.ui \ 117 | forms_win32/addtaskdialog.ui \ 118 | forms_win32/advancedcompilersettingsdialog.ui \ 119 | forms_win32/environmentvariablesdialog.ui \ 120 | forms_win32/editvariabledialog.ui \ 121 | forms_win32/addcompilerwizard.ui 122 | 123 | unix:FORMS += forms_unix/lemon.ui \ 124 | forms_unix/taskeditwidget.ui \ 125 | forms_unix/testcaseeditwidget.ui \ 126 | forms_unix/generalsettings.ui \ 127 | forms_unix/compilersettings.ui \ 128 | forms_unix/addtestcaseswizard.ui \ 129 | forms_unix/judgingdialog.ui \ 130 | forms_unix/optionsdialog.ui \ 131 | forms_unix/detaildialog.ui \ 132 | forms_unix/newcontestwidget.ui \ 133 | forms_unix/opencontestwidget.ui \ 134 | forms_unix/newcontestdialog.ui \ 135 | forms_unix/opencontestdialog.ui \ 136 | forms_unix/welcomedialog.ui \ 137 | forms_unix/addtaskdialog.ui \ 138 | forms_unix/advancedcompilersettingsdialog.ui \ 139 | forms_unix/environmentvariablesdialog.ui \ 140 | forms_unix/editvariabledialog.ui \ 141 | forms_unix/addcompilerwizard.ui 142 | 143 | TRANSLATIONS += lemon_zh_CN.ts 144 | 145 | win32:RC_FILE = lemon.rc 146 | 147 | win32:LIBS += -lpsapi 148 | 149 | win32:CONFIG += qaxcontainer 150 | 151 | RESOURCES += resource.qrc 152 | -------------------------------------------------------------------------------- /lemon.rc: -------------------------------------------------------------------------------- 1 | IDI_ICON1 ICON DISCARDABLE "icon.ico" 2 | -------------------------------------------------------------------------------- /lemon_zh_CN.qm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sojiv/Project_lemon/29a39be26b7f2980b6b4568a41d171c6596ca41a/lemon_zh_CN.qm -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #include 20 | #include "qtsingleapplication/qtsingleapplication.h" 21 | #include "lemon.h" 22 | 23 | int main(int argc, char *argv[]) 24 | { 25 | QtSingleApplication a(argc, argv); 26 | 27 | if (a.sendMessage("")) { 28 | a.activateWindow(); 29 | return 0; 30 | } 31 | 32 | Lemon w; 33 | a.setActivationWindow(&w); 34 | 35 | w.show(); 36 | w.welcome(); 37 | 38 | return a.exec(); 39 | } 40 | -------------------------------------------------------------------------------- /newcontestdialog.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #include "newcontestdialog.h" 20 | #include "ui_newcontestdialog.h" 21 | 22 | NewContestDialog::NewContestDialog(QWidget *parent) : 23 | QDialog(parent), 24 | ui(new Ui::NewContestDialog) 25 | { 26 | ui->setupUi(this); 27 | ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); 28 | connect(ui->newContestWidget, SIGNAL(informationChanged()), 29 | this, SLOT(informationChanged())); 30 | } 31 | 32 | NewContestDialog::~NewContestDialog() 33 | { 34 | delete ui; 35 | } 36 | 37 | QString NewContestDialog::getContestTitle() 38 | { 39 | return ui->newContestWidget->getContestTitle(); 40 | } 41 | 42 | QString NewContestDialog::getSavingName() 43 | { 44 | return ui->newContestWidget->getSavingName(); 45 | } 46 | 47 | QString NewContestDialog::getContestPath() 48 | { 49 | return ui->newContestWidget->getContestPath(); 50 | } 51 | 52 | void NewContestDialog::informationChanged() 53 | { 54 | ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(ui->newContestWidget->checkReady()); 55 | } 56 | -------------------------------------------------------------------------------- /newcontestdialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef NEWCONTESTDIALOG_H 20 | #define NEWCONTESTDIALOG_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace Ui { 27 | class NewContestDialog; 28 | } 29 | 30 | class NewContestDialog : public QDialog 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | explicit NewContestDialog(QWidget *parent = 0); 36 | ~NewContestDialog(); 37 | QString getContestTitle(); 38 | QString getSavingName(); 39 | QString getContestPath(); 40 | 41 | private: 42 | Ui::NewContestDialog *ui; 43 | 44 | private slots: 45 | void informationChanged(); 46 | }; 47 | 48 | #endif // NEWCONTESTDIALOG_H 49 | -------------------------------------------------------------------------------- /newcontestwidget.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #include "newcontestwidget.h" 20 | #include "ui_newcontestwidget.h" 21 | 22 | NewContestWidget::NewContestWidget(QWidget *parent) : 23 | QWidget(parent), 24 | ui(new Ui::NewContestWidget) 25 | { 26 | ui->setupUi(this); 27 | connect(ui->selectButton, SIGNAL(clicked()), 28 | this, SLOT(selectContestPath())); 29 | connect(ui->savingName, SIGNAL(textChanged(QString)), 30 | this, SLOT(savingNameChanged())); 31 | connect(ui->contestTitle, SIGNAL(textChanged(QString)), 32 | this, SIGNAL(informationChanged())); 33 | connect(ui->savingName, SIGNAL(textChanged(QString)), 34 | this, SIGNAL(informationChanged())); 35 | connect(ui->contestPath, SIGNAL(textChanged(QString)), 36 | this, SIGNAL(informationChanged())); 37 | } 38 | 39 | NewContestWidget::~NewContestWidget() 40 | { 41 | delete ui; 42 | } 43 | 44 | QString NewContestWidget::getContestTitle() 45 | { 46 | return ui->contestTitle->text(); 47 | } 48 | 49 | QString NewContestWidget::getSavingName() 50 | { 51 | return ui->savingName->text(); 52 | } 53 | 54 | QString NewContestWidget::getContestPath() 55 | { 56 | return ui->contestPath->text(); 57 | } 58 | 59 | bool NewContestWidget::checkReady() const 60 | { 61 | return ! ui->contestTitle->text().isEmpty() && ! ui->contestPath->text().isEmpty() && ! ui->savingName->text().isEmpty(); 62 | } 63 | 64 | void NewContestWidget::selectContestPath() 65 | { 66 | QString path = QFileDialog::getExistingDirectory(this, tr("Select Contest Path"), QDir::homePath()); 67 | if (! path.isEmpty()) ui->contestPath->setText(QDir::toNativeSeparators(path)); 68 | } 69 | 70 | void NewContestWidget::savingNameChanged() 71 | { 72 | QString path = QDir::homePath(); 73 | path = QDir::toNativeSeparators(path); 74 | path += QDir::separator(); 75 | path += ui->savingName->text(); 76 | ui->contestPath->setText(path); 77 | } 78 | -------------------------------------------------------------------------------- /newcontestwidget.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef NEWCONTESTWIDGET_H 20 | #define NEWCONTESTWIDGET_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace Ui { 27 | class NewContestWidget; 28 | } 29 | 30 | class NewContestWidget : public QWidget 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | explicit NewContestWidget(QWidget *parent = 0); 36 | ~NewContestWidget(); 37 | QString getContestTitle(); 38 | QString getSavingName(); 39 | QString getContestPath(); 40 | bool checkReady() const; 41 | 42 | private: 43 | Ui::NewContestWidget *ui; 44 | 45 | signals: 46 | void informationChanged(); 47 | 48 | private slots: 49 | void selectContestPath(); 50 | void savingNameChanged(); 51 | }; 52 | 53 | #endif // NEWCONTESTWIDGET_H 54 | -------------------------------------------------------------------------------- /opencontestdialog.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #include "opencontestdialog.h" 20 | #include "ui_opencontestdialog.h" 21 | 22 | OpenContestDialog::OpenContestDialog(QWidget *parent) : 23 | QDialog(parent), 24 | ui(new Ui::OpenContestDialog) 25 | { 26 | ui->setupUi(this); 27 | ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); 28 | connect(ui->openContestWidget, SIGNAL(selectionChanged()), 29 | this, SLOT(selectionChanged())); 30 | connect(ui->openContestWidget, SIGNAL(rowDoubleClicked()), 31 | this, SLOT(accept())); 32 | } 33 | 34 | OpenContestDialog::~OpenContestDialog() 35 | { 36 | delete ui; 37 | } 38 | 39 | void OpenContestDialog::setRecentContest(const QStringList &list) 40 | { 41 | ui->openContestWidget->setRecentContest(list); 42 | } 43 | 44 | void OpenContestDialog::selectionChanged() 45 | { 46 | if (ui->openContestWidget->getCurrentRow() != -1) { 47 | ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); 48 | } else { 49 | ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); 50 | } 51 | } 52 | 53 | const QStringList& OpenContestDialog::getRecentContest() const 54 | { 55 | return ui->openContestWidget->getRecentContest(); 56 | } 57 | 58 | QString OpenContestDialog::getSelectedContest() 59 | { 60 | return ui->openContestWidget->getRecentContest().at(ui->openContestWidget->getCurrentRow()); 61 | } 62 | -------------------------------------------------------------------------------- /opencontestdialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef OPENCONTESTDIALOG_H 20 | #define OPENCONTESTDIALOG_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace Ui { 27 | class OpenContestDialog; 28 | } 29 | 30 | class OpenContestDialog : public QDialog 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | explicit OpenContestDialog(QWidget *parent = 0); 36 | ~OpenContestDialog(); 37 | void setRecentContest(const QStringList&); 38 | const QStringList& getRecentContest() const; 39 | QString getSelectedContest(); 40 | 41 | private: 42 | Ui::OpenContestDialog *ui; 43 | 44 | private slots: 45 | void selectionChanged(); 46 | }; 47 | 48 | #endif // OPENCONTESTDIALOG_H 49 | -------------------------------------------------------------------------------- /opencontestwidget.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #include "opencontestwidget.h" 20 | #include "ui_opencontestwidget.h" 21 | #include "contest.h" 22 | 23 | OpenContestWidget::OpenContestWidget(QWidget *parent) : 24 | QWidget(parent), 25 | ui(new Ui::OpenContestWidget) 26 | { 27 | ui->setupUi(this); 28 | connect(ui->recentContest, SIGNAL(itemSelectionChanged()), 29 | this, SIGNAL(selectionChanged())); 30 | connect(ui->recentContest, SIGNAL(cellDoubleClicked(int, int)), 31 | this, SIGNAL(rowDoubleClicked())); 32 | connect(ui->addButton, SIGNAL(clicked()), 33 | this, SLOT(addContest())); 34 | connect(ui->deleteButton, SIGNAL(clicked()), 35 | this, SLOT(deleteContest())); 36 | connect(ui->recentContest, SIGNAL(currentCellChanged(int,int,int,int)), 37 | this, SLOT(currentRowChanged())); 38 | } 39 | 40 | OpenContestWidget::~OpenContestWidget() 41 | { 42 | delete ui; 43 | } 44 | 45 | void OpenContestWidget::setRecentContest(const QStringList &list) 46 | { 47 | recentContest = list; 48 | refreshContestList(); 49 | } 50 | 51 | void OpenContestWidget::refreshContestList() 52 | { 53 | ui->recentContest->setRowCount(0); 54 | for (int i = 0; i < recentContest.size(); ) { 55 | QFile file(recentContest[i]); 56 | if (! file.open(QFile::ReadOnly)) { 57 | recentContest.removeAt(i); 58 | continue; 59 | } 60 | QDataStream _in(&file); 61 | unsigned checkNumber; 62 | _in >> checkNumber; 63 | if (checkNumber != unsigned(MagicNumber)) { 64 | recentContest.removeAt(i); 65 | continue; 66 | } 67 | quint16 checksum; 68 | int len; 69 | _in >> checksum >> len; 70 | char *raw = new char[len]; 71 | _in.readRawData(raw, len); 72 | if (qChecksum(raw, len) != checksum) { 73 | delete[] raw; 74 | recentContest.removeAt(i); 75 | continue; 76 | } 77 | QByteArray data(raw, len); 78 | delete[] raw; 79 | data = qUncompress(data); 80 | QDataStream in(data); 81 | QString title; 82 | in >> title; 83 | ui->recentContest->setRowCount(i + 1); 84 | ui->recentContest->setItem(i, 0, new QTableWidgetItem(title)); 85 | ui->recentContest->setItem(i, 1, new QTableWidgetItem(recentContest[i])); 86 | ui->recentContest->item(i, 0)->setTextAlignment(Qt::AlignCenter); 87 | i ++; 88 | } 89 | QHeaderView *header = ui->recentContest->horizontalHeader(); 90 | header->setResizeMode(QHeaderView::ResizeToContents); 91 | } 92 | 93 | void OpenContestWidget::addContest() 94 | { 95 | QString fileName = QFileDialog::getOpenFileName(this, tr("Add Contest"), QDir::homePath(), 96 | tr("Lemon contest data file (*.cdf)")); 97 | if (fileName.isEmpty()) return; 98 | fileName = fileName.replace('/', QDir::separator()); 99 | QFile file(fileName); 100 | if (! file.open(QFile::ReadOnly)) { 101 | QMessageBox::warning(this, tr("Error"), tr("Cannot open selected file"), QMessageBox::Close); 102 | return; 103 | } 104 | QDataStream in(&file); 105 | unsigned checkNumber; 106 | in >> checkNumber; 107 | if (checkNumber != unsigned(MagicNumber)) { 108 | QMessageBox::warning(this, tr("Error"), tr("Broken contest data file"), QMessageBox::Close); 109 | return; 110 | } 111 | quint16 checksum; 112 | int len; 113 | in >> checksum >> len; 114 | char *raw = new char[len]; 115 | in.readRawData(raw, len); 116 | if (qChecksum(raw, len) != checksum) { 117 | QMessageBox::warning(this, tr("Error"), tr("Broken contest data file"), QMessageBox::Close); 118 | delete[] raw; 119 | return; 120 | } 121 | delete[] raw; 122 | recentContest.prepend(fileName); 123 | refreshContestList(); 124 | } 125 | 126 | void OpenContestWidget::deleteContest() 127 | { 128 | int index = ui->recentContest->currentRow(); 129 | recentContest.removeAt(index); 130 | refreshContestList(); 131 | } 132 | 133 | void OpenContestWidget::currentRowChanged() 134 | { 135 | int index = ui->recentContest->currentRow(); 136 | if (index != -1) { 137 | ui->deleteButton->setEnabled(true); 138 | } else { 139 | ui->deleteButton->setEnabled(false); 140 | } 141 | } 142 | 143 | const QStringList& OpenContestWidget::getRecentContest() const 144 | { 145 | return recentContest; 146 | } 147 | 148 | int OpenContestWidget::getCurrentRow() const 149 | { 150 | return ui->recentContest->currentRow(); 151 | } 152 | -------------------------------------------------------------------------------- /opencontestwidget.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef OPENCONTESTWIDGET_H 20 | #define OPENCONTESTWIDGET_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace Ui { 27 | class OpenContestWidget; 28 | } 29 | 30 | class OpenContestWidget : public QWidget 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | explicit OpenContestWidget(QWidget *parent = 0); 36 | ~OpenContestWidget(); 37 | void setRecentContest(const QStringList&); 38 | const QStringList& getRecentContest() const; 39 | int getCurrentRow() const; 40 | 41 | private: 42 | Ui::OpenContestWidget *ui; 43 | QStringList recentContest; 44 | void refreshContestList(); 45 | 46 | private slots: 47 | void addContest(); 48 | void deleteContest(); 49 | void currentRowChanged(); 50 | 51 | signals: 52 | void selectionChanged(); 53 | void rowDoubleClicked(); 54 | }; 55 | 56 | #endif // OPENCONTESTWIDGET_H 57 | -------------------------------------------------------------------------------- /optionsdialog.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #include "optionsdialog.h" 20 | #include "ui_optionsdialog.h" 21 | #include "settings.h" 22 | 23 | OptionsDialog::OptionsDialog(QWidget *parent) : 24 | QDialog(parent), 25 | ui(new Ui::OptionsDialog) 26 | { 27 | ui->setupUi(this); 28 | editSettings = new Settings(this); 29 | connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked()), 30 | this, SLOT(okayButtonClicked())); 31 | } 32 | 33 | OptionsDialog::~OptionsDialog() 34 | { 35 | delete ui; 36 | } 37 | 38 | Settings* OptionsDialog::getEditSettings() 39 | { 40 | return editSettings; 41 | } 42 | 43 | void OptionsDialog::resetEditSettings(Settings *settings) 44 | { 45 | editSettings->copyFrom(settings); 46 | ui->generalSettings->resetEditSettings(editSettings); 47 | ui->compilerSettings->resetEditSettings(editSettings); 48 | ui->tabWidget->setCurrentIndex(0); 49 | } 50 | 51 | void OptionsDialog::okayButtonClicked() 52 | { 53 | ui->tabWidget->setCurrentIndex(0); 54 | if (! ui->generalSettings->checkValid()) return; 55 | ui->tabWidget->setCurrentIndex(1); 56 | if (! ui->compilerSettings->checkValid()) return; 57 | accept(); 58 | } 59 | -------------------------------------------------------------------------------- /optionsdialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef OPTIONSDIALOG_H 20 | #define OPTIONSDIALOG_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace Ui { 27 | class OptionsDialog; 28 | } 29 | 30 | class Settings; 31 | 32 | class OptionsDialog : public QDialog 33 | { 34 | Q_OBJECT 35 | 36 | public: 37 | explicit OptionsDialog(QWidget *parent = 0); 38 | ~OptionsDialog(); 39 | void resetEditSettings(Settings*); 40 | Settings* getEditSettings(); 41 | 42 | private: 43 | Ui::OptionsDialog *ui; 44 | Settings *editSettings; 45 | 46 | private slots: 47 | void okayButtonClicked(); 48 | }; 49 | 50 | #endif // OPTIONSDIALOG_H 51 | -------------------------------------------------------------------------------- /qt_zh_CN.qm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sojiv/Project_lemon/29a39be26b7f2980b6b4568a41d171c6596ca41a/qt_zh_CN.qm -------------------------------------------------------------------------------- /qtlockedfile/qtlockedfile.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 | ** All rights reserved. 5 | ** 6 | ** Contact: Nokia Corporation (qt-info@nokia.com) 7 | ** 8 | ** This file is part of a Qt Solutions component. 9 | ** 10 | ** You may use this file under the terms of the BSD license as follows: 11 | ** 12 | ** "Redistribution and use in source and binary forms, with or without 13 | ** modification, are permitted provided that the following conditions are 14 | ** met: 15 | ** * Redistributions of source code must retain the above copyright 16 | ** notice, this list of conditions and the following disclaimer. 17 | ** * Redistributions in binary form must reproduce the above copyright 18 | ** notice, this list of conditions and the following disclaimer in 19 | ** the documentation and/or other materials provided with the 20 | ** distribution. 21 | ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor 22 | ** the names of its contributors may be used to endorse or promote 23 | ** products derived from this software without specific prior written 24 | ** permission. 25 | ** 26 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 37 | ** 38 | ****************************************************************************/ 39 | 40 | #ifndef QTLOCKEDFILE_H 41 | #define QTLOCKEDFILE_H 42 | 43 | #include 44 | #ifdef Q_OS_WIN 45 | #include 46 | #endif 47 | 48 | #if defined(Q_WS_WIN) 49 | # if !defined(QT_QTLOCKEDFILE_EXPORT) && !defined(QT_QTLOCKEDFILE_IMPORT) 50 | # define QT_QTLOCKEDFILE_EXPORT 51 | # elif defined(QT_QTLOCKEDFILE_IMPORT) 52 | # if defined(QT_QTLOCKEDFILE_EXPORT) 53 | # undef QT_QTLOCKEDFILE_EXPORT 54 | # endif 55 | # define QT_QTLOCKEDFILE_EXPORT __declspec(dllimport) 56 | # elif defined(QT_QTLOCKEDFILE_EXPORT) 57 | # undef QT_QTLOCKEDFILE_EXPORT 58 | # define QT_QTLOCKEDFILE_EXPORT __declspec(dllexport) 59 | # endif 60 | #else 61 | # define QT_QTLOCKEDFILE_EXPORT 62 | #endif 63 | 64 | namespace QtLP_Private { 65 | 66 | class QT_QTLOCKEDFILE_EXPORT QtLockedFile : public QFile 67 | { 68 | public: 69 | enum LockMode { NoLock = 0, ReadLock, WriteLock }; 70 | 71 | QtLockedFile(); 72 | QtLockedFile(const QString &name); 73 | ~QtLockedFile(); 74 | 75 | bool open(OpenMode mode); 76 | 77 | bool lock(LockMode mode, bool block = true); 78 | bool unlock(); 79 | bool isLocked() const; 80 | LockMode lockMode() const; 81 | 82 | private: 83 | #ifdef Q_OS_WIN 84 | Qt::HANDLE wmutex; 85 | Qt::HANDLE rmutex; 86 | QVector rmutexes; 87 | QString mutexname; 88 | 89 | Qt::HANDLE getMutexHandle(int idx, bool doCreate); 90 | bool waitMutex(Qt::HANDLE mutex, bool doBlock); 91 | 92 | #endif 93 | LockMode m_lock_mode; 94 | }; 95 | } 96 | #endif 97 | -------------------------------------------------------------------------------- /qtlockedfile/qtlockedfile_unix.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 | ** All rights reserved. 5 | ** 6 | ** Contact: Nokia Corporation (qt-info@nokia.com) 7 | ** 8 | ** This file is part of a Qt Solutions component. 9 | ** 10 | ** You may use this file under the terms of the BSD license as follows: 11 | ** 12 | ** "Redistribution and use in source and binary forms, with or without 13 | ** modification, are permitted provided that the following conditions are 14 | ** met: 15 | ** * Redistributions of source code must retain the above copyright 16 | ** notice, this list of conditions and the following disclaimer. 17 | ** * Redistributions in binary form must reproduce the above copyright 18 | ** notice, this list of conditions and the following disclaimer in 19 | ** the documentation and/or other materials provided with the 20 | ** distribution. 21 | ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor 22 | ** the names of its contributors may be used to endorse or promote 23 | ** products derived from this software without specific prior written 24 | ** permission. 25 | ** 26 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 37 | ** 38 | ****************************************************************************/ 39 | 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | #include "qtlockedfile.h" 46 | 47 | bool QtLockedFile::lock(LockMode mode, bool block) 48 | { 49 | if (!isOpen()) { 50 | qWarning("QtLockedFile::lock(): file is not opened"); 51 | return false; 52 | } 53 | 54 | if (mode == NoLock) 55 | return unlock(); 56 | 57 | if (mode == m_lock_mode) 58 | return true; 59 | 60 | if (m_lock_mode != NoLock) 61 | unlock(); 62 | 63 | struct flock fl; 64 | fl.l_whence = SEEK_SET; 65 | fl.l_start = 0; 66 | fl.l_len = 0; 67 | fl.l_type = (mode == ReadLock) ? F_RDLCK : F_WRLCK; 68 | int cmd = block ? F_SETLKW : F_SETLK; 69 | int ret = fcntl(handle(), cmd, &fl); 70 | 71 | if (ret == -1) { 72 | if (errno != EINTR && errno != EAGAIN) 73 | qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno)); 74 | return false; 75 | } 76 | 77 | 78 | m_lock_mode = mode; 79 | return true; 80 | } 81 | 82 | 83 | bool QtLockedFile::unlock() 84 | { 85 | if (!isOpen()) { 86 | qWarning("QtLockedFile::unlock(): file is not opened"); 87 | return false; 88 | } 89 | 90 | if (!isLocked()) 91 | return true; 92 | 93 | struct flock fl; 94 | fl.l_whence = SEEK_SET; 95 | fl.l_start = 0; 96 | fl.l_len = 0; 97 | fl.l_type = F_UNLCK; 98 | int ret = fcntl(handle(), F_SETLKW, &fl); 99 | 100 | if (ret == -1) { 101 | qWarning("QtLockedFile::lock(): fcntl: %s", strerror(errno)); 102 | return false; 103 | } 104 | 105 | m_lock_mode = NoLock; 106 | return true; 107 | } 108 | 109 | QtLockedFile::~QtLockedFile() 110 | { 111 | if (isOpen()) 112 | unlock(); 113 | } 114 | 115 | -------------------------------------------------------------------------------- /qtsingleapplication/qtlocalpeer.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 | ** All rights reserved. 5 | ** 6 | ** Contact: Nokia Corporation (qt-info@nokia.com) 7 | ** 8 | ** This file is part of a Qt Solutions component. 9 | ** 10 | ** You may use this file under the terms of the BSD license as follows: 11 | ** 12 | ** "Redistribution and use in source and binary forms, with or without 13 | ** modification, are permitted provided that the following conditions are 14 | ** met: 15 | ** * Redistributions of source code must retain the above copyright 16 | ** notice, this list of conditions and the following disclaimer. 17 | ** * Redistributions in binary form must reproduce the above copyright 18 | ** notice, this list of conditions and the following disclaimer in 19 | ** the documentation and/or other materials provided with the 20 | ** distribution. 21 | ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor 22 | ** the names of its contributors may be used to endorse or promote 23 | ** products derived from this software without specific prior written 24 | ** permission. 25 | ** 26 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 37 | ** 38 | ****************************************************************************/ 39 | 40 | #ifndef QTLOCALPEER_H 41 | #define QTLOCALPEER_H 42 | 43 | #include 44 | #include 45 | #include 46 | 47 | #include "qtlockedfile/qtlockedfile.h" 48 | 49 | #if defined(Q_OS_UNIX) 50 | #include 51 | #endif 52 | 53 | class QtLocalPeer : public QObject 54 | { 55 | Q_OBJECT 56 | 57 | public: 58 | QtLocalPeer(QObject *parent = 0, const QString &appId = QString()); 59 | bool isClient(); 60 | bool sendMessage(const QString &message, int timeout); 61 | QString applicationId() const 62 | { return id; } 63 | 64 | Q_SIGNALS: 65 | void messageReceived(const QString &message); 66 | 67 | protected Q_SLOTS: 68 | void receiveConnection(); 69 | 70 | protected: 71 | QString id; 72 | QString socketName; 73 | QLocalServer* server; 74 | QtLP_Private::QtLockedFile lockFile; 75 | 76 | private: 77 | static const char* ack; 78 | }; 79 | 80 | #endif // QTLOCALPEER_H 81 | -------------------------------------------------------------------------------- /qtsingleapplication/qtsingleapplication.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 | ** All rights reserved. 5 | ** 6 | ** Contact: Nokia Corporation (qt-info@nokia.com) 7 | ** 8 | ** This file is part of a Qt Solutions component. 9 | ** 10 | ** You may use this file under the terms of the BSD license as follows: 11 | ** 12 | ** "Redistribution and use in source and binary forms, with or without 13 | ** modification, are permitted provided that the following conditions are 14 | ** met: 15 | ** * Redistributions of source code must retain the above copyright 16 | ** notice, this list of conditions and the following disclaimer. 17 | ** * Redistributions in binary form must reproduce the above copyright 18 | ** notice, this list of conditions and the following disclaimer in 19 | ** the documentation and/or other materials provided with the 20 | ** distribution. 21 | ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor 22 | ** the names of its contributors may be used to endorse or promote 23 | ** products derived from this software without specific prior written 24 | ** permission. 25 | ** 26 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 37 | ** 38 | ****************************************************************************/ 39 | 40 | #ifndef QTSINGLEAPPLICATION_H 41 | #define QTSINGLEAPPLICATION_H 42 | 43 | #include 44 | 45 | class QtLocalPeer; 46 | 47 | #if defined(Q_WS_WIN) 48 | # if !defined(QT_QTSINGLEAPPLICATION_EXPORT) && !defined(QT_QTSINGLEAPPLICATION_IMPORT) 49 | # define QT_QTSINGLEAPPLICATION_EXPORT 50 | # elif defined(QT_QTSINGLEAPPLICATION_IMPORT) 51 | # if defined(QT_QTSINGLEAPPLICATION_EXPORT) 52 | # undef QT_QTSINGLEAPPLICATION_EXPORT 53 | # endif 54 | # define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllimport) 55 | # elif defined(QT_QTSINGLEAPPLICATION_EXPORT) 56 | # undef QT_QTSINGLEAPPLICATION_EXPORT 57 | # define QT_QTSINGLEAPPLICATION_EXPORT __declspec(dllexport) 58 | # endif 59 | #else 60 | # define QT_QTSINGLEAPPLICATION_EXPORT 61 | #endif 62 | 63 | class QT_QTSINGLEAPPLICATION_EXPORT QtSingleApplication : public QApplication 64 | { 65 | Q_OBJECT 66 | 67 | public: 68 | QtSingleApplication(int &argc, char **argv, bool GUIenabled = true); 69 | QtSingleApplication(const QString &id, int &argc, char **argv); 70 | QtSingleApplication(int &argc, char **argv, Type type); 71 | #if defined(Q_WS_X11) 72 | QtSingleApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0); 73 | QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0); 74 | QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0); 75 | #endif 76 | 77 | bool isRunning(); 78 | QString id() const; 79 | 80 | void setActivationWindow(QWidget* aw, bool activateOnMessage = true); 81 | QWidget* activationWindow() const; 82 | 83 | // Obsolete: 84 | void initialize(bool dummy = true) 85 | { isRunning(); Q_UNUSED(dummy) } 86 | 87 | public Q_SLOTS: 88 | bool sendMessage(const QString &message, int timeout = 5000); 89 | void activateWindow(); 90 | 91 | 92 | Q_SIGNALS: 93 | void messageReceived(const QString &message); 94 | 95 | 96 | private: 97 | void sysInit(const QString &appId = QString()); 98 | QtLocalPeer *peer; 99 | QWidget *actWin; 100 | }; 101 | 102 | #endif // QTSINGLEAPPLICATION_H 103 | -------------------------------------------------------------------------------- /qtsingleapplication/qtsinglecoreapplication.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 | ** All rights reserved. 5 | ** 6 | ** Contact: Nokia Corporation (qt-info@nokia.com) 7 | ** 8 | ** This file is part of a Qt Solutions component. 9 | ** 10 | ** You may use this file under the terms of the BSD license as follows: 11 | ** 12 | ** "Redistribution and use in source and binary forms, with or without 13 | ** modification, are permitted provided that the following conditions are 14 | ** met: 15 | ** * Redistributions of source code must retain the above copyright 16 | ** notice, this list of conditions and the following disclaimer. 17 | ** * Redistributions in binary form must reproduce the above copyright 18 | ** notice, this list of conditions and the following disclaimer in 19 | ** the documentation and/or other materials provided with the 20 | ** distribution. 21 | ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor 22 | ** the names of its contributors may be used to endorse or promote 23 | ** products derived from this software without specific prior written 24 | ** permission. 25 | ** 26 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 37 | ** 38 | ****************************************************************************/ 39 | 40 | 41 | #include "qtsinglecoreapplication.h" 42 | #include "qtlocalpeer.h" 43 | 44 | /*! 45 | \class QtSingleCoreApplication qtsinglecoreapplication.h 46 | \brief A variant of the QtSingleApplication class for non-GUI applications. 47 | 48 | This class is a variant of QtSingleApplication suited for use in 49 | console (non-GUI) applications. It is an extension of 50 | QCoreApplication (instead of QApplication). It does not require 51 | the QtGui library. 52 | 53 | The API and usage is identical to QtSingleApplication, except that 54 | functions relating to the "activation window" are not present, for 55 | obvious reasons. Please refer to the QtSingleApplication 56 | documentation for explanation of the usage. 57 | 58 | A QtSingleCoreApplication instance can communicate to a 59 | QtSingleApplication instance if they share the same application 60 | id. Hence, this class can be used to create a light-weight 61 | command-line tool that sends commands to a GUI application. 62 | 63 | \sa QtSingleApplication 64 | */ 65 | 66 | /*! 67 | Creates a QtSingleCoreApplication object. The application identifier 68 | will be QCoreApplication::applicationFilePath(). \a argc and \a 69 | argv are passed on to the QCoreAppliation constructor. 70 | */ 71 | 72 | QtSingleCoreApplication::QtSingleCoreApplication(int &argc, char **argv) 73 | : QCoreApplication(argc, argv) 74 | { 75 | peer = new QtLocalPeer(this); 76 | connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); 77 | } 78 | 79 | 80 | /*! 81 | Creates a QtSingleCoreApplication object with the application 82 | identifier \a appId. \a argc and \a argv are passed on to the 83 | QCoreAppliation constructor. 84 | */ 85 | QtSingleCoreApplication::QtSingleCoreApplication(const QString &appId, int &argc, char **argv) 86 | : QCoreApplication(argc, argv) 87 | { 88 | peer = new QtLocalPeer(this, appId); 89 | connect(peer, SIGNAL(messageReceived(const QString&)), SIGNAL(messageReceived(const QString&))); 90 | } 91 | 92 | 93 | /*! 94 | Returns true if another instance of this application is running; 95 | otherwise false. 96 | 97 | This function does not find instances of this application that are 98 | being run by a different user (on Windows: that are running in 99 | another session). 100 | 101 | \sa sendMessage() 102 | */ 103 | 104 | bool QtSingleCoreApplication::isRunning() 105 | { 106 | return peer->isClient(); 107 | } 108 | 109 | 110 | /*! 111 | Tries to send the text \a message to the currently running 112 | instance. The QtSingleCoreApplication object in the running instance 113 | will emit the messageReceived() signal when it receives the 114 | message. 115 | 116 | This function returns true if the message has been sent to, and 117 | processed by, the current instance. If there is no instance 118 | currently running, or if the running instance fails to process the 119 | message within \a timeout milliseconds, this function return false. 120 | 121 | \sa isRunning(), messageReceived() 122 | */ 123 | 124 | bool QtSingleCoreApplication::sendMessage(const QString &message, int timeout) 125 | { 126 | return peer->sendMessage(message, timeout); 127 | } 128 | 129 | 130 | /*! 131 | Returns the application identifier. Two processes with the same 132 | identifier will be regarded as instances of the same application. 133 | */ 134 | 135 | QString QtSingleCoreApplication::id() const 136 | { 137 | return peer->applicationId(); 138 | } 139 | 140 | 141 | /*! 142 | \fn void QtSingleCoreApplication::messageReceived(const QString& message) 143 | 144 | This signal is emitted when the current instance receives a \a 145 | message from another instance of this application. 146 | 147 | \sa sendMessage() 148 | */ 149 | -------------------------------------------------------------------------------- /qtsingleapplication/qtsinglecoreapplication.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** 3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 4 | ** All rights reserved. 5 | ** 6 | ** Contact: Nokia Corporation (qt-info@nokia.com) 7 | ** 8 | ** This file is part of a Qt Solutions component. 9 | ** 10 | ** You may use this file under the terms of the BSD license as follows: 11 | ** 12 | ** "Redistribution and use in source and binary forms, with or without 13 | ** modification, are permitted provided that the following conditions are 14 | ** met: 15 | ** * Redistributions of source code must retain the above copyright 16 | ** notice, this list of conditions and the following disclaimer. 17 | ** * Redistributions in binary form must reproduce the above copyright 18 | ** notice, this list of conditions and the following disclaimer in 19 | ** the documentation and/or other materials provided with the 20 | ** distribution. 21 | ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor 22 | ** the names of its contributors may be used to endorse or promote 23 | ** products derived from this software without specific prior written 24 | ** permission. 25 | ** 26 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 | ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 | ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 | ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 | ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 | ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 | ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 | ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 | ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 | ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 37 | ** 38 | ****************************************************************************/ 39 | 40 | #ifndef QTSINGLECOREAPPLICATION_H 41 | #define QTSINGLECOREAPPLICATION_H 42 | 43 | #include 44 | 45 | class QtLocalPeer; 46 | 47 | class QtSingleCoreApplication : public QCoreApplication 48 | { 49 | Q_OBJECT 50 | 51 | public: 52 | QtSingleCoreApplication(int &argc, char **argv); 53 | QtSingleCoreApplication(const QString &id, int &argc, char **argv); 54 | 55 | bool isRunning(); 56 | QString id() const; 57 | 58 | public Q_SLOTS: 59 | bool sendMessage(const QString &message, int timeout = 5000); 60 | 61 | 62 | Q_SIGNALS: 63 | void messageReceived(const QString &message); 64 | 65 | 66 | private: 67 | QtLocalPeer* peer; 68 | }; 69 | 70 | #endif // QTSINGLECOREAPPLICATION_H 71 | -------------------------------------------------------------------------------- /realjudge.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #include 20 | #include 21 | 22 | int main(int argc, char *argv[]) { 23 | FILE *contestantOutputFile = fopen(argv[1], "r"); 24 | if (contestantOutputFile == NULL) { 25 | printf("Cannot open contestant\'s output file\n"); 26 | return 0; 27 | } 28 | FILE *standardOutputFile = fopen(argv[2], "r"); 29 | if (standardOutputFile == NULL) { 30 | printf("Cannot open standard output file\n"); 31 | fclose(contestantOutputFile); 32 | return 0; 33 | } 34 | 35 | int realPrecision, i; 36 | sscanf(argv[3], "%d", &realPrecision); 37 | double eps = 1; 38 | for (i = 0; i < realPrecision; i ++) 39 | eps *= 0.1; 40 | 41 | double a, b; 42 | while (1) { 43 | int cnt1 = fscanf(contestantOutputFile, "%lf", &a); 44 | int cnt2 = fscanf(standardOutputFile, "%lf", &b); 45 | if (cnt1 == 0) { 46 | printf("Wrong answer\nInvalid characters found\n"); 47 | fclose(contestantOutputFile); 48 | fclose(standardOutputFile); 49 | return 0; 50 | } 51 | if (cnt2 == 0) { 52 | printf("Invalid characters in standard output file\n"); 53 | fclose(contestantOutputFile); 54 | fclose(standardOutputFile); 55 | return 0; 56 | } 57 | if (cnt1 == EOF && cnt2 == EOF) break; 58 | if (cnt1 == EOF && cnt2 == 1) { 59 | printf("Wrong answer\nShorter than standard output\n"); 60 | fclose(contestantOutputFile); 61 | fclose(standardOutputFile); 62 | return 0; 63 | } 64 | if (cnt1 == 1 && cnt2 == EOF) { 65 | printf("Wrong answer\nLonger than standard output\n"); 66 | fclose(contestantOutputFile); 67 | fclose(standardOutputFile); 68 | return 0; 69 | } 70 | if (fabs(a - b) > eps) { 71 | printf("Wrong answer\nRead %.10lf but expect %.10lf\n", a, b); 72 | fclose(contestantOutputFile); 73 | fclose(standardOutputFile); 74 | return 0; 75 | } 76 | } 77 | 78 | printf("Correct answer\n"); 79 | fclose(contestantOutputFile); 80 | fclose(standardOutputFile); 81 | return 0; 82 | } 83 | -------------------------------------------------------------------------------- /realjudge_linux: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sojiv/Project_lemon/29a39be26b7f2980b6b4568a41d171c6596ca41a/realjudge_linux -------------------------------------------------------------------------------- /realjudge_win32.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sojiv/Project_lemon/29a39be26b7f2980b6b4568a41d171c6596ca41a/realjudge_win32.exe -------------------------------------------------------------------------------- /release_build/Project_lemon_i386_NOILinux.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sojiv/Project_lemon/29a39be26b7f2980b6b4568a41d171c6596ca41a/release_build/Project_lemon_i386_NOILinux.tar.gz -------------------------------------------------------------------------------- /release_build/lemon_v1.1_release_mingw.7z: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sojiv/Project_lemon/29a39be26b7f2980b6b4568a41d171c6596ca41a/release_build/lemon_v1.1_release_mingw.7z -------------------------------------------------------------------------------- /resource.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | rod.png 4 | downarrow.png 5 | uparrow.png 6 | add.png 7 | cross.png 8 | icon.png 9 | 10 | 11 | lemon_zh_CN.qm 12 | qt_zh_CN.qm 13 | 14 | 15 | realjudge_win32.exe 16 | realjudge_linux 17 | 18 | 19 | watcher_unix 20 | 21 | 22 | -------------------------------------------------------------------------------- /resultviewer.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef RESULTVIEWER_H 20 | #define RESULTVIEWER_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | class Contest; 27 | 28 | class ResultViewer : public QTableWidget 29 | { 30 | Q_OBJECT 31 | public: 32 | explicit ResultViewer(QWidget *parent = 0); 33 | void changeEvent(QEvent*); 34 | void contextMenuEvent(QContextMenuEvent*); 35 | void setContest(Contest*); 36 | 37 | public slots: 38 | void refreshViewer(); 39 | void judgeSelected(); 40 | void judgeAll(); 41 | 42 | private: 43 | Contest *curContest; 44 | QAction *deleteContestantAction; 45 | QAction *detailInformationAction; 46 | QAction *judgeSelectedAction; 47 | QAction *deleteContestantKeyAction; 48 | void clearPath(const QString&); 49 | 50 | private slots: 51 | void deleteContestant(); 52 | void detailInformation(); 53 | 54 | signals: 55 | void contestantDeleted(); 56 | }; 57 | 58 | #endif // RESULTVIEWER_H 59 | -------------------------------------------------------------------------------- /rod.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sojiv/Project_lemon/29a39be26b7f2980b6b4568a41d171c6596ca41a/rod.png -------------------------------------------------------------------------------- /selftestutil.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef SELFTESTUTIL_H 20 | #define SELFTESTUTIL_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | class Contest; 27 | 28 | class SelfTestUtil : public QObject 29 | { 30 | Q_OBJECT 31 | public: 32 | explicit SelfTestUtil(QObject *parent = 0); 33 | static void clearPath(const QString&); 34 | static void makeSelfTest(QWidget*, Contest*); 35 | 36 | signals: 37 | 38 | public slots: 39 | 40 | }; 41 | 42 | #endif // SELFTESTUTIL_H 43 | -------------------------------------------------------------------------------- /settings.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef SETTINGS_H 20 | #define SETTINGS_H 21 | 22 | #include 23 | #include 24 | 25 | class Compiler; 26 | 27 | class Settings : public QObject 28 | { 29 | Q_OBJECT 30 | public: 31 | explicit Settings(QObject *parent = 0); 32 | 33 | int getDefaultFullScore() const; 34 | int getDefaultTimeLimit() const; 35 | int getDefaultMemoryLimit() const; 36 | int getCompileTimeLimit() const; 37 | int getSpecialJudgeTimeLimit() const; 38 | int getFileSizeLimit() const; 39 | int getNumberOfThreads() const; 40 | const QString& getDefaultInputFileExtension() const; 41 | const QString& getDefaultOutputFileExtension() const; 42 | const QStringList& getInputFileExtensions() const; 43 | const QStringList& getOutputFileExtensions() const; 44 | const QStringList& getRecentContest() const; 45 | const QList& getCompilerList() const; 46 | const QString& getUiLanguage() const; 47 | const QString& getDiffPath() const; 48 | 49 | void setDefaultFullScore(int); 50 | void setDefaultTimeLimit(int); 51 | void setDefaultMemoryLimit(int); 52 | void setCompileTimeLimit(int); 53 | void setSpecialJudgeTimeLimit(int); 54 | void setFileSizeLimit(int); 55 | void setNumberOfThreads(int); 56 | void setDefaultInputFileExtension(const QString&); 57 | void setDefaultOutputFileExtension(const QString&); 58 | void setInputFileExtensions(const QString&); 59 | void setOutputFileExtensions(const QString&); 60 | void setRecentContest(const QStringList&); 61 | void setUiLanguage(const QString&); 62 | 63 | void addCompiler(Compiler*); 64 | void deleteCompiler(int); 65 | Compiler* getCompiler(int); 66 | void swapCompiler(int, int); 67 | void copyFrom(Settings*); 68 | void saveSettings(); 69 | void loadSettings(); 70 | 71 | static int upperBoundForFullScore(); 72 | static int upperBoundForTimeLimit(); 73 | static int upperBoundForMemoryLimit(); 74 | static int upperBoundForFileSizeLimit(); 75 | static int upperBoundForNumberOfThreads(); 76 | static QString dataPath(); 77 | static QString sourcePath(); 78 | static QString temporaryPath(); 79 | static QString selfTestPath(); 80 | 81 | private: 82 | QList compilerList; 83 | int defaultFullScore; 84 | int defaultTimeLimit; 85 | int defaultMemoryLimit; 86 | int compileTimeLimit; 87 | int specialJudgeTimeLimit; 88 | int fileSizeLimit; 89 | int numberOfThreads; 90 | QString defaultInputFileExtension; 91 | QString defaultOutputFileExtension; 92 | QStringList inputFileExtensions; 93 | QStringList outputFileExtensions; 94 | QStringList recentContest; 95 | QString uiLanguage; 96 | QString diffPath; 97 | }; 98 | 99 | #endif // SETTINGS_H 100 | -------------------------------------------------------------------------------- /summarytree.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef SUMMARYTREE_H 20 | #define SUMMARYTREE_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | class Settings; 27 | class Contest; 28 | 29 | class SummaryTree : public QTreeWidget 30 | { 31 | Q_OBJECT 32 | public: 33 | explicit SummaryTree(QWidget *parent = 0); 34 | void changeEvent(QEvent*); 35 | void setContest(Contest*); 36 | void setSettings(Settings*); 37 | void contextMenuEvent(QContextMenuEvent*); 38 | 39 | private: 40 | int addCount; 41 | Contest *curContest; 42 | Settings *settings; 43 | QAction *addTaskAction; 44 | QAction *addTestCaseAction; 45 | QAction *addTestCasesAction; 46 | QAction *addTaskKeyAction; 47 | QAction *addTestCaseKeyAction; 48 | QAction *deleteTaskAction; 49 | QAction *deleteTestCaseAction; 50 | QAction *deleteTaskKeyAction; 51 | QAction *deleteTestCaseKeyAction; 52 | 53 | private slots: 54 | void addTask(); 55 | void addTestCase(); 56 | void addTestCases(); 57 | void deleteTask(); 58 | void deleteTestCase(); 59 | void selectionChanged(); 60 | void itemChanged(QTreeWidgetItem*); 61 | void titleChanged(const QString&); 62 | }; 63 | 64 | #endif // SUMMARYTREE_H 65 | -------------------------------------------------------------------------------- /task.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef TASK_H 20 | #define TASK_H 21 | 22 | #include 23 | #include 24 | 25 | class TestCase; 26 | class Settings; 27 | 28 | class Task : public QObject 29 | { 30 | Q_OBJECT 31 | public: 32 | enum TaskType { Traditional, AnswersOnly }; 33 | enum ComparisonMode { LineByLineMode, IgnoreSpacesMode, ExternalToolMode, RealNumberMode, SpecialJudgeMode }; 34 | 35 | explicit Task(QObject *parent = 0); 36 | 37 | const QList& getTestCaseList() const; 38 | const QString& getProblemTile() const; 39 | const QString& getSourceFileName() const; 40 | const QString& getInputFileName() const; 41 | const QString& getOutputFileName() const; 42 | bool getStandardInputCheck() const; 43 | bool getStandardOutputCheck() const; 44 | TaskType getTaskType() const; 45 | ComparisonMode getComparisonMode() const; 46 | const QString& getDiffArguments() const; 47 | int getRealPrecision() const; 48 | const QString& getSpecialJudge() const; 49 | QString getCompilerConfiguration(const QString&) const; 50 | const QString& getAnswerFileExtension() const; 51 | 52 | void setProblemTitle(const QString&); 53 | void setSourceFileName(const QString&); 54 | void setInputFileName(const QString&); 55 | void setOutputFileName(const QString&); 56 | void setStandardInputCheck(bool); 57 | void setStandardOutputCheck(bool); 58 | void setTaskType(TaskType); 59 | void setComparisonMode(ComparisonMode); 60 | void setDiffArguments(const QString&); 61 | void setRealPrecision(int); 62 | void setSpecialJudge(const QString&); 63 | void setCompilerConfiguration(const QString&, const QString&); 64 | void setAnswerFileExtension(const QString&); 65 | 66 | void addTestCase(TestCase*); 67 | TestCase* getTestCase(int) const; 68 | void deleteTestCase(int); 69 | void refreshCompilerConfiguration(Settings*); 70 | int getTotalTimeLimit() const; 71 | void writeToStream(QDataStream&); 72 | void readFromStream(QDataStream&); 73 | 74 | private: 75 | QList testCaseList; 76 | QString problemTitle; 77 | QString sourceFileName; 78 | QString inputFileName; 79 | QString outputFileName; 80 | bool standardInputCheck; 81 | bool standardOutputCheck; 82 | TaskType taskType; 83 | ComparisonMode comparisonMode; 84 | QString diffArguments; 85 | int realPrecision; 86 | QString specialJudge; 87 | QMap compilerConfiguration; 88 | QString answerFileExtension; 89 | 90 | signals: 91 | void problemTitleChanged(const QString&); 92 | void compilerConfigurationRefreshed(); 93 | }; 94 | 95 | #endif // TASK_H 96 | -------------------------------------------------------------------------------- /taskeditwidget.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef TASKEDITWIDGET_H 20 | #define TASKEDITWIDGET_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace Ui { 27 | class TaskEditWidget; 28 | } 29 | 30 | class Settings; 31 | class Task; 32 | 33 | class TaskEditWidget : public QWidget 34 | { 35 | Q_OBJECT 36 | 37 | public: 38 | explicit TaskEditWidget(QWidget *parent = 0); 39 | ~TaskEditWidget(); 40 | void changeEvent(QEvent*); 41 | void setEditTask(Task*); 42 | void setSettings(Settings*); 43 | 44 | private: 45 | Ui::TaskEditWidget *ui; 46 | Settings *settings; 47 | Task *editTask; 48 | void refreshWidgetState(); 49 | 50 | private slots: 51 | void problemTitleChanged(const QString&); 52 | void setToTraditional(bool); 53 | void setToAnswersOnly(bool); 54 | void sourceFileNameChanged(const QString&); 55 | void inputFileNameChanged(const QString&); 56 | void outputFileNameChanged(const QString&); 57 | void standardInputCheckChanged(); 58 | void standardOutputCheckChanged(); 59 | void comparisonModeChanged(); 60 | void diffArgumentsChanged(const QString&); 61 | void realPrecisionChanged(int); 62 | void specialJudgeChanged(const QString&); 63 | void refreshProblemTitle(const QString&); 64 | void refreshCompilerConfiguration(); 65 | void compilerSelectionChanged(); 66 | void configurationSelectionChanged(); 67 | void answerFileExtensionChanged(const QString&); 68 | 69 | signals: 70 | void dataPathChanged(); 71 | }; 72 | 73 | #endif // TASKEDITWIDGET_H 74 | -------------------------------------------------------------------------------- /testcase.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #include "testcase.h" 20 | #include "settings.h" 21 | 22 | TestCase::TestCase(QObject *parent) : 23 | QObject(parent) 24 | { 25 | } 26 | 27 | int TestCase::getFullScore() const 28 | { 29 | return fullScore; 30 | } 31 | 32 | int TestCase::getTimeLimit() const 33 | { 34 | return timeLimit; 35 | } 36 | 37 | int TestCase::getMemoryLimit() const 38 | { 39 | return memoryLimit; 40 | } 41 | 42 | const QStringList& TestCase::getInputFiles() const 43 | { 44 | return inputFiles; 45 | } 46 | 47 | const QStringList& TestCase::getOutputFiles() const 48 | { 49 | return outputFiles; 50 | } 51 | 52 | void TestCase::setFullScore(int score) 53 | { 54 | fullScore = score; 55 | } 56 | 57 | void TestCase::setTimeLimit(int limit) 58 | { 59 | timeLimit = limit; 60 | } 61 | 62 | void TestCase::setMemoryLimit(int limit) 63 | { 64 | memoryLimit = limit; 65 | } 66 | 67 | void TestCase::setInputFiles(int index, const QString &fileName) 68 | { 69 | if (0 <= index && index < inputFiles.size()) { 70 | inputFiles[index] = fileName; 71 | } 72 | } 73 | 74 | void TestCase::setOutputFiles(int index, const QString &fileName) 75 | { 76 | if (0 <= index && index < outputFiles.size()) { 77 | outputFiles[index] = fileName; 78 | } 79 | } 80 | 81 | void TestCase::addSingleCase(const QString &inputFile, const QString &outputFile) 82 | { 83 | inputFiles.append(inputFile); 84 | outputFiles.append(outputFile); 85 | } 86 | 87 | void TestCase::deleteSingleCase(int index) 88 | { 89 | inputFiles.removeAt(index); 90 | outputFiles.removeAt(index); 91 | } 92 | 93 | void TestCase::writeToStream(QDataStream &out) 94 | { 95 | out << fullScore; 96 | out << timeLimit; 97 | out << memoryLimit; 98 | QStringList _inputFiles(inputFiles); 99 | for (int i = 0; i < _inputFiles.size(); i ++) { 100 | _inputFiles[i].replace(QDir::separator(), '/'); 101 | } 102 | QStringList _outputFiles(outputFiles); 103 | for (int i = 0; i < _outputFiles.size(); i ++) { 104 | _outputFiles[i].replace(QDir::separator(), '/'); 105 | } 106 | out << _inputFiles; 107 | out << _outputFiles; 108 | } 109 | 110 | void TestCase::readFromStream(QDataStream &in) 111 | { 112 | in >> fullScore; 113 | in >> timeLimit; 114 | in >> memoryLimit; 115 | in >> inputFiles; 116 | in >> outputFiles; 117 | for (int i = 0; i < inputFiles.size(); i ++) { 118 | inputFiles[i].replace('/', QDir::separator()); 119 | } 120 | for (int i = 0; i < outputFiles.size(); i ++) { 121 | outputFiles[i].replace('/', QDir::separator()); 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /testcase.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef TESTCASE_H 20 | #define TESTCASE_H 21 | 22 | #include 23 | #include 24 | 25 | class TestCase : public QObject 26 | { 27 | Q_OBJECT 28 | public: 29 | explicit TestCase(QObject *parent = 0); 30 | int getFullScore() const; 31 | int getTimeLimit() const; 32 | int getMemoryLimit() const; 33 | const QStringList& getInputFiles() const; 34 | const QStringList& getOutputFiles() const; 35 | void setFullScore(int); 36 | void setTimeLimit(int); 37 | void setMemoryLimit(int); 38 | void setInputFiles(int, const QString&); 39 | void setOutputFiles(int, const QString&); 40 | void addSingleCase(const QString&, const QString&); 41 | void deleteSingleCase(int); 42 | void writeToStream(QDataStream&); 43 | void readFromStream(QDataStream&); 44 | 45 | private: 46 | QStringList inputFiles; 47 | QStringList outputFiles; 48 | int fullScore; 49 | int timeLimit; 50 | int memoryLimit; 51 | }; 52 | 53 | #endif // TESTCASE_H 54 | -------------------------------------------------------------------------------- /testcaseeditwidget.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef TESTCASEEDITWIDGET_H 20 | #define TESTCASEEDITWIDGET_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace Ui { 27 | class TestCaseEditWidget; 28 | } 29 | 30 | class Settings; 31 | class TestCase; 32 | 33 | class TestCaseEditWidget : public QWidget 34 | { 35 | Q_OBJECT 36 | 37 | public: 38 | explicit TestCaseEditWidget(QWidget *parent = 0); 39 | ~TestCaseEditWidget(); 40 | void changeEvent(QEvent*); 41 | void setEditTestCase(TestCase*, bool); 42 | void setSettings(Settings*); 43 | 44 | private: 45 | Ui::TestCaseEditWidget *ui; 46 | TestCase *editTestCase; 47 | Settings *settings; 48 | QAction *deleteAction; 49 | void refreshFileList(); 50 | 51 | private slots: 52 | void addSingleCase(); 53 | void deleteSingleCase(); 54 | void fullScoreChanged(const QString&); 55 | void timeLimitChanged(const QString&); 56 | void memoryLimitChanged(const QString&); 57 | void fileListSelectionChanged(); 58 | void fileListItemChanged(QTableWidgetItem*); 59 | 60 | signals: 61 | void dataPathChanged(); 62 | }; 63 | 64 | #endif // TESTCASEEDITWIDGET_H 65 | -------------------------------------------------------------------------------- /uparrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sojiv/Project_lemon/29a39be26b7f2980b6b4568a41d171c6596ca41a/uparrow.png -------------------------------------------------------------------------------- /watcher_unix: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sojiv/Project_lemon/29a39be26b7f2980b6b4568a41d171c6596ca41a/watcher_unix -------------------------------------------------------------------------------- /watcher_unix.c: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | int pid; 30 | 31 | void cleanUp() { 32 | kill(pid, SIGKILL); 33 | exit(0); 34 | } 35 | 36 | int main(int argc, char *argv[]) { 37 | int timeLimit, memoryLimit; 38 | sscanf(argv[5], "%d", &timeLimit); 39 | timeLimit = (timeLimit - 1) / 1000 + 1; 40 | sscanf(argv[6], "%d", &memoryLimit); 41 | memoryLimit *= 1024 * 1024; 42 | 43 | pid = fork(); 44 | if (pid > 0) { 45 | signal(SIGINT, cleanUp); 46 | signal(SIGABRT, cleanUp); 47 | signal(SIGTERM, cleanUp); 48 | struct rusage usage; 49 | int status; 50 | if (wait4(pid, &status, 0, &usage) == -1) 51 | return 1; 52 | if (WIFEXITED(status)) { 53 | if (WEXITSTATUS(status) == 1) return 1; 54 | printf("%d\n", (int)(usage.ru_utime.tv_sec * 1000 + usage.ru_utime.tv_usec / 1000)); 55 | printf("%d\n", (int)(usage.ru_maxrss) * 1024); 56 | if (WEXITSTATUS(status) != 0) return 2; 57 | return 0; 58 | } 59 | if (WIFSIGNALED(status)) { 60 | printf("%d\n", (int)(usage.ru_utime.tv_sec * 1000 + usage.ru_utime.tv_usec / 1000)); 61 | printf("%d\n", (int)(usage.ru_maxrss) * 1024); 62 | if (WTERMSIG(status) == SIGXCPU) return 3; 63 | if (WTERMSIG(status) == SIGKILL) return 4; 64 | if (WTERMSIG(status) == SIGABRT) return 4; 65 | return 2; 66 | } 67 | } else { 68 | if (strlen(argv[2]) > 0) freopen(argv[2], "r", stdin); 69 | if (strlen(argv[3]) > 0) freopen(argv[3], "w", stdout); 70 | if (strlen(argv[4]) > 0) freopen(argv[4], "w", stderr); 71 | if (memoryLimit != -1) 72 | setrlimit(RLIMIT_AS, &(struct rlimit){memoryLimit, memoryLimit}); 73 | setrlimit(RLIMIT_CPU, &(struct rlimit){timeLimit, timeLimit + 1}); 74 | if (execlp("bash", "bash", "-c", argv[1], NULL) == -1) return 1; 75 | } 76 | 77 | return 0; 78 | } 79 | -------------------------------------------------------------------------------- /welcomedialog.cpp: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #include "welcomedialog.h" 20 | #include "ui_welcomedialog.h" 21 | 22 | WelcomeDialog::WelcomeDialog(QWidget *parent) : 23 | QDialog(parent), 24 | ui(new Ui::WelcomeDialog) 25 | { 26 | ui->setupUi(this); 27 | ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); 28 | connect(ui->openContestWidget, SIGNAL(selectionChanged()), 29 | this, SLOT(selectionChanged())); 30 | connect(ui->newContestWidget, SIGNAL(informationChanged()), 31 | this, SLOT(informationChanged())); 32 | connect(ui->tabWidget, SIGNAL(currentChanged(int)), 33 | this, SLOT(tabIndexChanged(int))); 34 | connect(ui->openContestWidget, SIGNAL(rowDoubleClicked()), 35 | this, SLOT(accept())); 36 | } 37 | 38 | WelcomeDialog::~WelcomeDialog() 39 | { 40 | delete ui; 41 | } 42 | 43 | void WelcomeDialog::setRecentContest(const QStringList &list) 44 | { 45 | ui->openContestWidget->setRecentContest(list); 46 | } 47 | 48 | QString WelcomeDialog::getContestTitle() 49 | { 50 | return ui->newContestWidget->getContestTitle(); 51 | } 52 | 53 | QString WelcomeDialog::getSavingName() 54 | { 55 | return ui->newContestWidget->getSavingName(); 56 | } 57 | 58 | QString WelcomeDialog::getContestPath() 59 | { 60 | return ui->newContestWidget->getContestPath(); 61 | } 62 | 63 | const QStringList& WelcomeDialog::getRecentContest() const 64 | { 65 | return ui->openContestWidget->getRecentContest(); 66 | } 67 | 68 | QString WelcomeDialog::getSelectedContest() 69 | { 70 | return ui->openContestWidget->getRecentContest().at(ui->openContestWidget->getCurrentRow()); 71 | } 72 | 73 | int WelcomeDialog::getCurrentTab() const 74 | { 75 | return ui->tabWidget->currentIndex(); 76 | } 77 | 78 | void WelcomeDialog::selectionChanged() 79 | { 80 | if (ui->openContestWidget->getCurrentRow() != -1) { 81 | ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); 82 | } else { 83 | ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); 84 | } 85 | } 86 | 87 | void WelcomeDialog::informationChanged() 88 | { 89 | ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(ui->newContestWidget->checkReady()); 90 | } 91 | 92 | void WelcomeDialog::tabIndexChanged(int index) 93 | { 94 | if (index == 0) { 95 | if (ui->openContestWidget->getCurrentRow() != -1) { 96 | ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); 97 | } else { 98 | ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); 99 | } 100 | } else { 101 | ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(ui->newContestWidget->checkReady()); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /welcomedialog.h: -------------------------------------------------------------------------------- 1 | /*************************************************************************** 2 | This file is part of Project Lemon 3 | Copyright (C) 2011 Zhipeng Jia 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation, either version 3 of the License, or 8 | (at your option) any later version. 9 | 10 | This program is distributed in the hope that it will be useful, 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . 17 | ***************************************************************************/ 18 | 19 | #ifndef WELCOMEDIALOG_H 20 | #define WELCOMEDIALOG_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace Ui { 27 | class WelcomeDialog; 28 | } 29 | 30 | class WelcomeDialog : public QDialog 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | explicit WelcomeDialog(QWidget *parent = 0); 36 | ~WelcomeDialog(); 37 | void setRecentContest(const QStringList&); 38 | QString getContestTitle(); 39 | QString getSavingName(); 40 | QString getContestPath(); 41 | const QStringList& getRecentContest() const; 42 | QString getSelectedContest(); 43 | int getCurrentTab() const; 44 | 45 | private: 46 | Ui::WelcomeDialog *ui; 47 | 48 | private slots: 49 | void selectionChanged(); 50 | void informationChanged(); 51 | void tabIndexChanged(int); 52 | }; 53 | 54 | #endif // WELCOMEDIALOG_H 55 | --------------------------------------------------------------------------------