Skip to content
This repository has been archived by the owner on Oct 8, 2019. It is now read-only.

Commit

Permalink
20120822
Browse files Browse the repository at this point in the history
  • Loading branch information
Crash committed Aug 22, 2012
1 parent 6ce64b0 commit 3a68a0f
Show file tree
Hide file tree
Showing 18 changed files with 250 additions and 128 deletions.
39 changes: 25 additions & 14 deletions addcompilerwizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,22 @@ bool AddCompilerWizard::validateCurrentPage()
text += tr("[Custom Compiler]") + "\n";
text += tr("Compiler Name: ") + ui->compilerName->text() + "\n";
text += tr("Compiler Type: ") + ui->typeSelect->currentText() + "\n";
if (ui->compilerLocation->isEnabled())
if (ui->compilerLocation->isEnabled()) {
text += tr("Compiler\'s Location: ") + ui->compilerLocation->text() + "\n";
if (ui->interpreterLocation->isEnabled())
}
if (ui->interpreterLocation->isEnabled()) {
text += tr("Interpreter\'s Location: ") + ui->interpreterLocation->text() + "\n";
}
text += tr("Source File Extensions: ") + ui->sourceFileExtensions->text() + "\n";
if (ui->bytecodeFileExtensions->isEnabled())
if (ui->bytecodeFileExtensions->isEnabled()) {
text += tr("Byte-code File Extensions: ") + ui->bytecodeFileExtensions->text() + "\n";
if (ui->defaultCompilerArguments->isEnabled())
}
if (ui->defaultCompilerArguments->isEnabled()) {
text += tr("Default Compiler\'s Arguments: ") + ui->defaultCompilerArguments->text() + "\n";
if (ui->defaultInterpreterArguments->isEnabled())
}
if (ui->defaultInterpreterArguments->isEnabled()) {
text += tr("Default Interpreter\'s Arguments: ") + ui->defaultInterpreterArguments->text() + "\n";
}
ui->logViewer->setPlainText(text);
}

Expand Down Expand Up @@ -160,22 +165,25 @@ bool AddCompilerWizard::validateCurrentPage()
if (ui->gccGroupBox->isEnabled()) {
text += tr("[gcc Compiler]") + "\n";
text += tr("gcc Path: ") + ui->gccPath->text() + "\n";
if (ui->gccO2Check->isChecked())
if (ui->gccO2Check->isChecked()) {
text += tr("Enable O2 Optimization") + "\n";
}
text += "\n";
}
if (ui->gppGroupBox->isEnabled()) {
text += tr("[g++ Compiler]") + "\n";
text += tr("g++ Path: ") + ui->gppPath->text() + "\n";
if (ui->gppO2Check->isChecked())
if (ui->gppO2Check->isChecked()) {
text += tr("Enable O2 Optimization") + "\n";
}
text += "\n";
}
if (ui->fpcGroupBox->isEnabled()) {
text += tr("[fpc Compiler]") + "\n";
text += tr("fpc Path: ") + ui->fpcPath->text() + "\n";
if (ui->fpcO2Check->isChecked())
if (ui->fpcO2Check->isChecked()) {
text += tr("Enable O2 Optimization") + "\n";
}
text += "\n";
}
if (ui->fbcGroupBox->isEnabled()) {
Expand Down Expand Up @@ -414,10 +422,11 @@ void AddCompilerWizard::accept()
compiler->setCompilerName("gcc");
compiler->setCompilerLocation(ui->gccPath->text());
compiler->setSourceExtensions("c");
if (ui->gccO2Check->isChecked())
if (ui->gccO2Check->isChecked()) {
compiler->addConfiguration("default", "-o %s %s.* -O2", "");
else
} else {
compiler->addConfiguration("default", "-o %s %s.*", "");
}
#ifdef Q_OS_WIN32
QProcessEnvironment environment;
QString path = QFileInfo(ui->gccPath->text()).absolutePath();
Expand All @@ -433,10 +442,11 @@ void AddCompilerWizard::accept()
compiler->setCompilerName("g++");
compiler->setCompilerLocation(ui->gppPath->text());
compiler->setSourceExtensions("cpp;cc;cxx");
if (ui->gppO2Check->isChecked())
if (ui->gppO2Check->isChecked()) {
compiler->addConfiguration("default", "-o %s %s.* -O2", "");
else
} else {
compiler->addConfiguration("default", "-o %s %s.*", "");
}
#ifdef Q_OS_WIN32
QProcessEnvironment environment;
QString path = QFileInfo(ui->gppPath->text()).absolutePath();
Expand All @@ -452,10 +462,11 @@ void AddCompilerWizard::accept()
compiler->setCompilerName("fpc");
compiler->setCompilerLocation(ui->fpcPath->text());
compiler->setSourceExtensions("pas;pp;inc");
if (ui->fpcO2Check->isChecked())
if (ui->fpcO2Check->isChecked()) {
compiler->addConfiguration("default", "%s.* -O2", "");
else
} else {
compiler->addConfiguration("default", "%s.*", "");
}
compilerList.append(compiler);
}

Expand Down
39 changes: 26 additions & 13 deletions addtestcaseswizard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ AddTestCasesWizard::AddTestCasesWizard(QWidget *parent) :
this, SLOT(memoryLimitChanged(QString)));

QHeaderView *header = ui->argumentList->horizontalHeader();
for (int i = 0; i < 3; i ++)
for (int i = 0; i < 3; i ++) {
header->resizeSection(i, header->sectionSizeHint(i));
}

connect(ui->inputFilesPattern, SIGNAL(textChanged(QString)),
this, SLOT(inputFilesPatternChanged(QString)));
Expand Down Expand Up @@ -164,8 +165,9 @@ void AddTestCasesWizard::refreshButtonState()
void AddTestCasesWizard::getFiles(const QString &curDir, const QString &prefix, QStringList &files)
{
QStringList list = QDir(curDir).entryList(QDir::Files);
for (int i = 0; i < list.size(); i ++)
for (int i = 0; i < list.size(); i ++) {
list[i] = prefix + list[i];
}
files.append(list);
list = QDir(curDir).entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
for (int i = 0; i < list.size(); i ++) {
Expand Down Expand Up @@ -203,19 +205,22 @@ QStringList AddTestCasesWizard::getMatchedPart(const QString &str, const QString
for (int i = 0; i < ui->argumentList->rowCount(); i ++)
result.append("");
for (int pos = 0, i = 0; pos < pattern.length(); i ++, pos ++) {
if (pos + 2 < pattern.length())
if (pos + 2 < pattern.length()) {
if (pattern[pos] == '<' && pattern[pos+1].isDigit() && pattern[pos+1] != '0' && pattern[pos+2] == '>') {
int index = pattern[pos+1].toAscii() - 49;
QString regExp = ui->argumentList->item(index, 1)->text();
for (int j = i; j < str.length(); j ++)
if (QRegExp(regExp).exactMatch(str.mid(i, j - i + 1)))
for (int j = i; j < str.length(); j ++) {
if (QRegExp(regExp).exactMatch(str.mid(i, j - i + 1))) {
if (QRegExp(getFullRegExp(pattern.mid(pos + 3))).exactMatch(str.mid(j + 1))) {
result[index] = str.mid(i, j - i + 1);
i = j;
break;
}
}
}
pos += 2;
}
}
}
return result;
}
Expand All @@ -227,46 +232,54 @@ void AddTestCasesWizard::searchMatchedFiles()
getFiles(Settings::dataPath(), "", outputFiles);

QString regExp = getFullRegExp(inputFilesPattern);
for (int i = 0; i < inputFiles.size(); i ++)
for (int i = 0; i < inputFiles.size(); i ++) {
if (! QRegExp(regExp).exactMatch(inputFiles[i])) {
inputFiles.removeAt(i);
i --;
}
}
regExp = getFullRegExp(outputFilesPattern);
for (int i = 0; i < outputFiles.size(); i ++)
for (int i = 0; i < outputFiles.size(); i ++) {
if (! QRegExp(regExp).exactMatch(outputFiles[i])) {
outputFiles.removeAt(i);
i --;
}
}

qSort(inputFiles.begin(), inputFiles.end(), compareFileName);
qSort(outputFiles.begin(), outputFiles.end(), compareFileName);

QList<QStringList> inputFilesMatchedPart;
QList<QStringList> outputFilesMatchedPart;
for (int i = 0; i < inputFiles.size(); i ++)
for (int i = 0; i < inputFiles.size(); i ++) {
inputFilesMatchedPart.append(getMatchedPart(inputFiles[i], inputFilesPattern));
for (int i = 0; i < outputFiles.size(); i ++)
}
for (int i = 0; i < outputFiles.size(); i ++) {
outputFilesMatchedPart.append(getMatchedPart(outputFiles[i], outputFilesPattern));
}

QMap<QString, int> loc;
QList< QPair<QString, QString> > singleCases;
QList< QStringList > matchedPart;
for (int i = 0; i < inputFiles.size(); i ++)
for (int i = 0; i < inputFiles.size(); i ++) {
loc[inputFilesMatchedPart[i].join("*")] = i;
for (int i = 0; i < outputFiles.size(); i ++)
}
for (int i = 0; i < outputFiles.size(); i ++) {
if (loc.count(outputFilesMatchedPart[i].join("*")) > 0) {
int partner = loc[outputFilesMatchedPart[i].join("*")];
singleCases.append(qMakePair(inputFiles[partner], outputFiles[i]));
matchedPart.append(outputFilesMatchedPart[i]);
}
}

loc.clear();
for (int i = 0; i < singleCases.size(); i ++) {
QStringList key;
for (int j = 0; j < ui->argumentList->rowCount(); j ++)
if (ui->argumentList->item(j, 0)->checkState() == Qt::Checked)
for (int j = 0; j < ui->argumentList->rowCount(); j ++) {
if (ui->argumentList->item(j, 0)->checkState() == Qt::Checked) {
key.append(matchedPart[i][j]);
}
}
loc.insertMulti(key.join("*"), i);
}

Expand Down
6 changes: 4 additions & 2 deletions advancedcompilersettingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,9 @@ void AdvancedCompilerSettingsDialog::resetEditCompiler(Compiler *compiler)
ui->memoryLimitRatio->setEnabled(! editCompiler->getDisableMemoryLimitCheck());
QStringList configurationNames = editCompiler->getConfigurationNames();
ui->configurationSelect->setEnabled(false);
for (int i = 0; i < configurationNames.size(); i ++)
for (int i = 0; i < configurationNames.size(); i ++) {
ui->configurationSelect->addItem(configurationNames[i]);
}
ui->configurationSelect->addItem(tr("Add new ..."));
ui->configurationSelect->setEnabled(true);
ui->configurationSelect->setCurrentIndex(0);
Expand Down Expand Up @@ -314,7 +315,8 @@ void AdvancedCompilerSettingsDialog::environmentVariablesButtonClicked()
{
EnvironmentVariablesDialog *dialog = new EnvironmentVariablesDialog(this);
dialog->setProcessEnvironment(editCompiler->getEnvironment());
if (dialog->exec() == QDialog::Accepted)
if (dialog->exec() == QDialog::Accepted) {
editCompiler->setEnvironment(dialog->getProcessEnvironment());
}
delete dialog;
}
13 changes: 9 additions & 4 deletions assignmentthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ bool AssignmentThread::traditionalTaskPrepare()
for (int i = 0; i < compilerList.size(); i ++) {
if (task->getCompilerConfiguration(compilerList[i]->getCompilerName()) == "disable") continue;
QStringList filters = compilerList[i]->getSourceExtensions();
for (int j = 0; j < filters.size(); j ++)
for (int j = 0; j < filters.size(); j ++) {
filters[j] = task->getSourceFileName() + "." + filters[j];
}
QStringList files = contestantDir.entryList(filters, QDir::Files);
sourceFile = "";
for (int j = 0; j < files.size(); j ++) {
Expand All @@ -139,7 +140,7 @@ bool AssignmentThread::traditionalTaskPrepare()
QStringList compilerArguments = compilerList[i]->getCompilerArguments();
QStringList interpreterArguments = compilerList[i]->getInterpreterArguments();
QString currentConfiguration = task->getCompilerConfiguration(compilerList[i]->getCompilerName());
for (int j = 0; j < configurationNames.size(); j ++)
for (int j = 0; j < configurationNames.size(); j ++) {
if (configurationNames[j] == currentConfiguration) {
timeLimitRatio = compilerList[i]->getTimeLimitRatio();
memoryLimitRatio = compilerList[i]->getMemoryLimitRatio();
Expand Down Expand Up @@ -216,8 +217,9 @@ bool AssignmentThread::traditionalTaskPrepare()
}
} else {
QStringList filters = compilerList[i]->getBytecodeExtensions();
for (int k = 0; k < filters.size(); k ++)
for (int k = 0; k < filters.size(); k ++) {
filters[k] = QString("*.") + filters[k];
}
if (QDir(Settings::temporaryPath() + contestantName)
.entryList(filters, QDir::Files).size() == 0) {
compileState = InvalidCompiler;
Expand All @@ -234,6 +236,7 @@ bool AssignmentThread::traditionalTaskPrepare()

break;
}
}
break;
}
}
Expand Down Expand Up @@ -290,8 +293,10 @@ void AssignmentThread::assign()
TestCase *curTestCase = task->getTestCase(curTestCaseIndex);
if (curSingleCaseIndex == curTestCase->getInputFiles().size()) {
curTestCaseIndex ++;
for ( ; curTestCaseIndex < task->getTestCaseList().size(); curTestCaseIndex ++)
while (curTestCaseIndex < task->getTestCaseList().size()) {
if (task->getTestCase(curTestCaseIndex)->getInputFiles().size() > 0) break;
curTestCaseIndex ++;
}
curSingleCaseIndex = 0;
if (curTestCaseIndex == task->getTestCaseList().size()) {
if (countFinished == totalSingleCase) quit();
Expand Down
9 changes: 6 additions & 3 deletions compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,20 +151,23 @@ void Compiler::addConfiguration(const QString &name, const QString &arguments1,

void Compiler::setConfigName(int index, const QString &name)
{
if (0 <= index && index < configurationNames.size())
if (0 <= index && index < configurationNames.size()) {
configurationNames[index] = name;
}
}

void Compiler::setCompilerArguments(int index, const QString &arguments)
{
if (0 <= index && index < compilerArguments.size())
if (0 <= index && index < compilerArguments.size()) {
compilerArguments[index] = arguments;
}
}

void Compiler::setInterpreterArguments(int index, const QString &arguments)
{
if (0 <= index && index < interpreterArguments.size())
if (0 <= index && index < interpreterArguments.size()) {
interpreterArguments[index] = arguments;
}
}

void Compiler::deleteConfiguration(int index)
Expand Down
21 changes: 14 additions & 7 deletions compilersettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,23 +67,26 @@ void CompilerSettings::resetEditSettings(Settings *settings)

const QList<Compiler*> &compilerList = editSettings->getCompilerList();
ui->compilerList->clear();
for (int i = 0; i < compilerList.size(); i ++)
for (int i = 0; i < compilerList.size(); i ++) {
ui->compilerList->addItem(compilerList[i]->getCompilerName());
}
if (compilerList.size() > 0) {
ui->compilerList->setCurrentRow(0);
setCurrentCompiler(compilerList[0]);
} else
} else {
setCurrentCompiler(0);
}
refreshItemState();
}

bool CompilerSettings::checkValid()
{
const QList<Compiler*> &compilerList = editSettings->getCompilerList();
QStringList compilerNames;
for (int i = 0; i < compilerList.size(); i ++)
for (int i = 0; i < compilerList.size(); i ++) {
compilerNames.append(compilerList[i]->getCompilerName());
for (int i = 0; i < compilerList.size(); i ++)
}
for (int i = 0; i < compilerList.size(); i ++) {
if (compilerNames.count(compilerNames[i]) > 1) {
ui->compilerList->setFocus();
ui->compilerList->setCurrentRow(i);
Expand All @@ -92,6 +95,7 @@ bool CompilerSettings::checkValid()
QMessageBox::Close);
return false;
}
}
for (int i = 0; i < compilerList.size(); i ++) {
if (compilerList[i]->getCompilerName().isEmpty()) {
ui->compilerList->setCurrentRow(i);
Expand Down Expand Up @@ -137,15 +141,17 @@ void CompilerSettings::addCompiler()
if (wizard->exec() == QDialog::Accepted) {
QList<Compiler*> compilerList = editSettings->getCompilerList();
QStringList compilerNames;
for (int i = 0; i < compilerList.size(); i ++)
for (int i = 0; i < compilerList.size(); i ++) {
compilerNames.append(compilerList[i]->getCompilerName());
}
compilerList = wizard->getCompilerList();
for (int i = 0; i < compilerList.size(); i ++) {
if (compilerNames.contains(compilerList[i]->getCompilerName())) {
int cnt = 2;
QString name = compilerList[i]->getCompilerName();
while (compilerNames.contains(QString("%1 (%2)").arg(name).arg(cnt)))
while (compilerNames.contains(QString("%1 (%2)").arg(name).arg(cnt))) {
cnt ++;
}
compilerList[i]->setCompilerName(QString("%1 (%2)").arg(name).arg(cnt));
}
editSettings->addCompiler(compilerList[i]);
Expand Down Expand Up @@ -245,7 +251,8 @@ void CompilerSettings::advancedButtonClicked()
{
AdvancedCompilerSettingsDialog *dialog = new AdvancedCompilerSettingsDialog(this);
dialog->resetEditCompiler(curCompiler);
if (dialog->exec() == QDialog::Accepted)
if (dialog->exec() == QDialog::Accepted) {
curCompiler->copyFrom(dialog->getEditCompiler());
}
delete dialog;
}
Loading

0 comments on commit 3a68a0f

Please sign in to comment.