[793] | 1 | //----------------------------------------------------------------------------// |
---|
| 2 | // Current revisions: |
---|
| 3 | // ----------------- |
---|
| 4 | // |
---|
| 5 | // Former revisions: |
---|
| 6 | // ----------------- |
---|
| 7 | // $Id: mainwindow.cpp 810 2012-01-30 13:40:12Z maronga $ |
---|
| 8 | // |
---|
[810] | 9 | // 809 2012-01-30 13:32:58Z marong |
---|
| 10 | // Bugfix: waiting for 20 minutes does not suffice for local runs |
---|
| 11 | // |
---|
[794] | 12 | // 793 2011-12-12 15:15:24Z maronga |
---|
| 13 | // Initial revision |
---|
| 14 | // |
---|
[793] | 15 | // Description: |
---|
| 16 | // ------------ |
---|
| 17 | // All subroutines for mrungui |
---|
| 18 | //----------------------------------------------------------------------------// |
---|
| 19 | |
---|
| 20 | #include <QtGui/QApplication> |
---|
| 21 | #include "mainwindow.h" |
---|
| 22 | #include "ui_mainwindow.h" |
---|
| 23 | #include "ui_about.h" |
---|
| 24 | #include "ui_help.h" |
---|
| 25 | #include <QString> |
---|
| 26 | #include <QFileDialog> |
---|
| 27 | #include <QDateTime> |
---|
| 28 | #include "stdlib.h" |
---|
| 29 | #include <QProcess> |
---|
| 30 | #include <QTextStream> |
---|
| 31 | |
---|
| 32 | |
---|
| 33 | // Define username on host as global variable |
---|
| 34 | QString username = getenv("USER"); |
---|
| 35 | // Define variable branch (location of mrungui, e.g. |
---|
| 36 | // "/home/user/palm/current_version" |
---|
| 37 | QString branch; |
---|
| 38 | |
---|
| 39 | |
---|
| 40 | //****************************************************************************// |
---|
| 41 | // Initialization of the main window |
---|
| 42 | MainWindow::MainWindow(QWidget *parent) : |
---|
| 43 | QMainWindow(parent), |
---|
| 44 | ui(new Ui::MainWindow) |
---|
| 45 | { |
---|
| 46 | ui->setupUi(this); |
---|
| 47 | |
---|
| 48 | // Empty the mrun command line (hereafter mrunline) |
---|
| 49 | ui->commandline->setText(""); |
---|
| 50 | |
---|
| 51 | // Get path of the program and set default file |
---|
| 52 | branch = QCoreApplication::applicationDirPath(); |
---|
| 53 | branch = branch.left(branch.length() - 14); |
---|
| 54 | |
---|
| 55 | |
---|
| 56 | QFile file(branch+"/.mrun.gui.default"); |
---|
| 57 | |
---|
| 58 | // Read default settings |
---|
| 59 | if ( file.exists() == true && file.size() > 10) |
---|
| 60 | { |
---|
| 61 | |
---|
| 62 | QString mrunline; |
---|
| 63 | if ( file.open(QIODevice::ReadOnly | QIODevice::Text ) ) |
---|
| 64 | { |
---|
| 65 | |
---|
| 66 | // File opened successfully |
---|
| 67 | QTextStream in(&file); |
---|
| 68 | |
---|
| 69 | QString line = in.readLine(); |
---|
| 70 | while (!line.isNull()) |
---|
| 71 | { |
---|
| 72 | mrunline = line; |
---|
| 73 | line = in.readLine(); |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | file.close(); |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | mrunline = mrunline.right(mrunline.length() - 17); |
---|
| 80 | ui->commandline->setText(mrunline); |
---|
| 81 | |
---|
| 82 | setup_gui(mrunline); |
---|
| 83 | |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | // Load jobs into the recent jobs list |
---|
| 87 | recent_jobs(10); |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | |
---|
| 91 | //****************************************************************************// |
---|
| 92 | // Routine for listing jobs in the recent jobs list |
---|
| 93 | int MainWindow::recent_jobs(int noj) |
---|
| 94 | { |
---|
| 95 | branch = QCoreApplication::applicationDirPath(); |
---|
| 96 | branch = branch.left(branch.length() - 14); |
---|
| 97 | |
---|
| 98 | QFile file(branch+"/.mrun.history"); |
---|
| 99 | QString listitem, timestamp; |
---|
| 100 | |
---|
| 101 | // Read mrun history and select the last used jobs |
---|
| 102 | if ( file.exists() == true && file.size() > 10) |
---|
| 103 | { |
---|
| 104 | |
---|
| 105 | // Open history |
---|
| 106 | QStringList history, tmphistory; |
---|
| 107 | if ( file.open(QIODevice::ReadOnly | QIODevice::Text ) ) |
---|
| 108 | { |
---|
| 109 | |
---|
| 110 | // file opened successfully |
---|
| 111 | QTextStream in(&file); |
---|
| 112 | |
---|
| 113 | QString line = in.readLine(); |
---|
| 114 | while (!line.isNull()) |
---|
| 115 | { |
---|
| 116 | history.append(line); |
---|
| 117 | line = in.readLine(); |
---|
| 118 | } |
---|
| 119 | |
---|
| 120 | file.close(); |
---|
| 121 | } |
---|
| 122 | |
---|
| 123 | int j = 0; |
---|
| 124 | |
---|
| 125 | ui->list_jobname->clear(); |
---|
| 126 | |
---|
| 127 | // Read history entries and append to recent job list |
---|
| 128 | for (int i=history.count(); i>=1; i--) |
---|
| 129 | { |
---|
| 130 | timestamp = history[i-1].left(16); |
---|
| 131 | listitem = history[i-1].right(history[i-1].length() - 17); |
---|
| 132 | listitem = listitem.split("-d ", QString::SkipEmptyParts)[1]; |
---|
| 133 | listitem = listitem.split(" -", QString::SkipEmptyParts)[0]; |
---|
| 134 | listitem = listitem.replace(" ",""); |
---|
| 135 | |
---|
| 136 | QList<QListWidgetItem *> matchitems = \ |
---|
| 137 | ui->list_jobname->findItems(listitem, Qt::MatchExactly); |
---|
| 138 | |
---|
| 139 | if ( matchitems.count() == 0 ) |
---|
| 140 | { |
---|
| 141 | ui->list_jobname->addItem(listitem); |
---|
| 142 | tmphistory.append(listitem+" ("+timestamp+")"); |
---|
| 143 | j++; |
---|
| 144 | } |
---|
| 145 | if ( j == noj ) |
---|
| 146 | { |
---|
| 147 | break; |
---|
| 148 | } |
---|
| 149 | } |
---|
| 150 | |
---|
| 151 | // Send to list |
---|
| 152 | ui->list_jobname->clear(); |
---|
| 153 | for (int i=tmphistory.count(); i>=1; i--) |
---|
| 154 | { |
---|
| 155 | ui->list_jobname->addItem(tmphistory[i-1]); |
---|
| 156 | } |
---|
| 157 | |
---|
| 158 | } |
---|
| 159 | return 0; |
---|
| 160 | } |
---|
| 161 | |
---|
| 162 | //****************************************************************************// |
---|
| 163 | // Exit program |
---|
| 164 | MainWindow::~MainWindow() |
---|
| 165 | { |
---|
| 166 | |
---|
| 167 | delete ui; |
---|
| 168 | } |
---|
| 169 | |
---|
| 170 | |
---|
| 171 | //****************************************************************************// |
---|
| 172 | // Start the mrun command via xterm |
---|
| 173 | int MainWindow::startmrun() |
---|
| 174 | { |
---|
| 175 | |
---|
| 176 | QString xtermoutput; |
---|
| 177 | QString mrunline_save; |
---|
| 178 | QString history_line; |
---|
| 179 | QString mrunline = ui->commandline->text(); |
---|
| 180 | QString userline = ui->line_user->text(); |
---|
| 181 | |
---|
| 182 | // Check for empty line |
---|
| 183 | mrunline_save = mrunline; |
---|
| 184 | if (userline != "") |
---|
| 185 | { |
---|
| 186 | mrunline = mrunline + " " + userline; |
---|
| 187 | } |
---|
| 188 | history_line = mrunline; |
---|
| 189 | |
---|
| 190 | // Disable the main window |
---|
| 191 | ui->group_job->setEnabled(false); |
---|
| 192 | ui->group_execution->setEnabled(false); |
---|
| 193 | ui->group_runcontrol->setEnabled(false); |
---|
| 194 | ui->group_advanced->setEnabled(false); |
---|
| 195 | ui->check_advanced->setEnabled(false); |
---|
| 196 | ui->check_verbose->setEnabled(false); |
---|
| 197 | ui->button_start->setEnabled(false); |
---|
| 198 | ui->button_start->setText("wait..."); |
---|
| 199 | |
---|
| 200 | branch = QCoreApplication::applicationDirPath(); |
---|
| 201 | branch = branch.left(branch.length() - 14); |
---|
| 202 | |
---|
| 203 | ui->commandline->setText("Executing MRUN in xterm..."); |
---|
| 204 | |
---|
| 205 | // Wait until all commands have been executed (ugly) |
---|
| 206 | for(int i=0; i<20; i++) |
---|
| 207 | qApp->processEvents(); |
---|
| 208 | |
---|
| 209 | // Start xterm as QProcess |
---|
| 210 | QProcess mrun; |
---|
| 211 | mrun.setProcessChannelMode(QProcess::MergedChannels); |
---|
| 212 | mrun.setWorkingDirectory(branch); |
---|
| 213 | |
---|
| 214 | mrunline = " -title \"Executing MRUN...\" -geometry \"100x55+970+0\" -e \""\ |
---|
| 215 | +mrunline.replace("\"","\'")\ |
---|
| 216 | +";echo -n '--> Press Enter to continue...';read yesno\""; |
---|
| 217 | |
---|
| 218 | mrun.start("xterm"+mrunline); |
---|
| 219 | |
---|
| 220 | if(!mrun.waitForStarted()) |
---|
| 221 | return 0; |
---|
| 222 | |
---|
| 223 | // while(mrun.waitForReadyRead()) |
---|
| 224 | // xtermoutput = xtermoutput+mrun.readAllStandardOutput(); |
---|
| 225 | |
---|
[809] | 226 | // Wait until mrun has finished or wait for 2000 minutes |
---|
| 227 | mrun.waitForFinished(12000000000); |
---|
[793] | 228 | |
---|
| 229 | |
---|
| 230 | // Jobs has been submitted or aborted. Continuing... |
---|
| 231 | // Save the mrun command to history file |
---|
| 232 | QString filename = branch+"/.mrun.history"; |
---|
| 233 | |
---|
| 234 | QDateTime time = QDateTime::currentDateTime(); |
---|
| 235 | QString tmptime = time.toString("yyyy/MM/dd hh:mm"); |
---|
| 236 | |
---|
| 237 | QFile file(filename); |
---|
| 238 | file.open(QIODevice::Append | QIODevice::Text); |
---|
| 239 | QTextStream out(&file); |
---|
| 240 | out << tmptime + " " + history_line + "\n"; |
---|
| 241 | file.close(); |
---|
| 242 | |
---|
| 243 | // Enable main window again |
---|
| 244 | ui->group_job->setEnabled(true); |
---|
| 245 | ui->group_execution->setEnabled(true); |
---|
| 246 | ui->group_runcontrol->setEnabled(true); |
---|
| 247 | if ( ui->check_advanced->isChecked() == true) |
---|
| 248 | { |
---|
| 249 | ui->group_advanced->setEnabled(true); |
---|
| 250 | } |
---|
| 251 | ui->check_advanced->setEnabled(true); |
---|
| 252 | ui->check_verbose->setEnabled(true); |
---|
| 253 | ui->button_start->setEnabled(true); |
---|
| 254 | ui->action_save->setEnabled(true); |
---|
| 255 | ui->button_start->setText("MRUN Start"); |
---|
| 256 | ui->commandline->setText(mrunline_save); |
---|
| 257 | |
---|
| 258 | // Reload recent jobs |
---|
| 259 | recent_jobs(10); |
---|
| 260 | |
---|
| 261 | return 0; |
---|
| 262 | } |
---|
| 263 | |
---|
| 264 | |
---|
| 265 | //****************************************************************************// |
---|
| 266 | // Disable/Enable advanced settings dialog |
---|
| 267 | int MainWindow::enable_advanced() |
---|
| 268 | { |
---|
| 269 | bool status; |
---|
| 270 | |
---|
| 271 | status = ui->group_advanced->isEnabled(); |
---|
| 272 | if (status == true) |
---|
| 273 | { |
---|
| 274 | ui->group_advanced->setEnabled(false); |
---|
| 275 | } |
---|
| 276 | else |
---|
| 277 | { |
---|
| 278 | ui->group_advanced->setEnabled(true); |
---|
| 279 | } |
---|
| 280 | |
---|
| 281 | return 0; |
---|
| 282 | } |
---|
| 283 | |
---|
| 284 | |
---|
| 285 | //****************************************************************************// |
---|
| 286 | // Disable/enable dialog for coupled runs |
---|
| 287 | int MainWindow::enable_coupled() |
---|
| 288 | { |
---|
| 289 | QString status; |
---|
| 290 | |
---|
| 291 | status = ui->drop_job->currentText(); |
---|
| 292 | if (status == "Coupled restart") |
---|
| 293 | { |
---|
| 294 | ui->label_coupled1->setEnabled(true); |
---|
| 295 | ui->label_coupled2->setEnabled(true); |
---|
| 296 | ui->label_coupled3->setEnabled(true); |
---|
| 297 | ui->line_PE_atmos->setEnabled(true); |
---|
| 298 | ui->line_PE_ocean->setEnabled(true); |
---|
| 299 | |
---|
| 300 | QString pe_total = ui->line_pe->text(); |
---|
| 301 | QString pe_atmos = ui->line_PE_atmos->text(); |
---|
| 302 | QString pe_ocean = ui->line_PE_ocean->text(); |
---|
| 303 | if (pe_total != "") |
---|
| 304 | { |
---|
| 305 | int PE_split = pe_total.toInt()/2; |
---|
| 306 | ui->line_PE_atmos->setText(QString::number(PE_split)); |
---|
| 307 | ui->line_PE_ocean->setText(QString::number(PE_split)); |
---|
| 308 | } |
---|
| 309 | } |
---|
| 310 | else |
---|
| 311 | { |
---|
| 312 | ui->label_coupled1->setEnabled(false); |
---|
| 313 | ui->label_coupled2->setEnabled(false); |
---|
| 314 | ui->label_coupled3->setEnabled(false); |
---|
| 315 | ui->line_PE_atmos->setEnabled(false); |
---|
| 316 | ui->line_PE_ocean->setEnabled(false); |
---|
| 317 | } |
---|
| 318 | |
---|
| 319 | return 0; |
---|
| 320 | } |
---|
| 321 | |
---|
| 322 | |
---|
| 323 | //****************************************************************************// |
---|
| 324 | // Choose job from dialog |
---|
| 325 | int MainWindow::choosejob() |
---|
| 326 | { |
---|
| 327 | QString filename; |
---|
| 328 | branch = QCoreApplication::applicationDirPath(); |
---|
| 329 | branch = branch.left(branch.length() - 14); |
---|
| 330 | |
---|
| 331 | QString jobdir = branch+"/JOBS"; |
---|
| 332 | |
---|
| 333 | |
---|
| 334 | // Pick a job from dialog |
---|
| 335 | filename = QFileDialog::getExistingDirectory(this, \ |
---|
| 336 | tr("Choose a job directory"), branch+"/JOBS", \ |
---|
| 337 | QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks | \ |
---|
| 338 | QFileDialog::DontUseNativeDialog | QFileDialog::ReadOnly | \ |
---|
| 339 | QFileDialog::DontConfirmOverwrite); |
---|
| 340 | |
---|
| 341 | |
---|
| 342 | |
---|
| 343 | |
---|
| 344 | |
---|
| 345 | // If a file was selected, load it into mainwindow |
---|
| 346 | if ( filename != "") |
---|
| 347 | { |
---|
| 348 | filename = filename.right(filename.length() - jobdir.length() - 1); |
---|
| 349 | |
---|
| 350 | ui->line_jobname->setText(filename); |
---|
| 351 | ui->list_jobname->clearSelection(); |
---|
| 352 | |
---|
| 353 | // Change mrunline accordingly |
---|
| 354 | change_commandline("d",""); |
---|
| 355 | change_commandline("r",""); |
---|
| 356 | return 0; |
---|
| 357 | } |
---|
| 358 | else |
---|
| 359 | { |
---|
| 360 | return 1; |
---|
| 361 | } |
---|
| 362 | } |
---|
| 363 | |
---|
| 364 | |
---|
| 365 | //****************************************************************************// |
---|
| 366 | // Choose job from the recent job list and load all settings |
---|
| 367 | int MainWindow::choosejob_list() |
---|
| 368 | { |
---|
| 369 | QString filename, timestamp, jobname; |
---|
| 370 | |
---|
| 371 | // Get selected item from list |
---|
| 372 | filename = ui->list_jobname->currentItem()->text(); |
---|
| 373 | int itemint = ui->list_jobname->currentRow(); |
---|
| 374 | |
---|
| 375 | // Reload list |
---|
| 376 | ui->setupUi(this); |
---|
| 377 | recent_jobs(10); |
---|
| 378 | |
---|
| 379 | // Set selected item to jobname |
---|
| 380 | ui->list_jobname->item(itemint)->setSelected(true); |
---|
| 381 | |
---|
| 382 | timestamp = filename.right(17).left(16); |
---|
| 383 | jobname = filename.left(filename.length() - 19); |
---|
| 384 | |
---|
| 385 | branch = QCoreApplication::applicationDirPath(); |
---|
| 386 | branch = branch.left(branch.length() - 14); |
---|
| 387 | QFile file(branch+"/.mrun.history"); |
---|
| 388 | QString listitem; |
---|
| 389 | |
---|
| 390 | // Load history |
---|
| 391 | if ( file.exists() == true && file.size() > 10) |
---|
| 392 | { |
---|
| 393 | |
---|
| 394 | QStringList history; |
---|
| 395 | if ( file.open(QIODevice::ReadOnly | QIODevice::Text ) ) |
---|
| 396 | { |
---|
| 397 | |
---|
| 398 | // file opened successfully |
---|
| 399 | QTextStream in(&file); |
---|
| 400 | |
---|
| 401 | QString line = in.readLine(); |
---|
| 402 | while (!line.isNull()) |
---|
| 403 | { |
---|
| 404 | history.append(line); |
---|
| 405 | line = in.readLine(); |
---|
| 406 | } |
---|
| 407 | |
---|
| 408 | file.close(); |
---|
| 409 | } |
---|
| 410 | |
---|
| 411 | for (int i=history.count(); i>=1; i--) |
---|
| 412 | { |
---|
| 413 | listitem = history[i-1].right(history[i-1].length() - 17); |
---|
| 414 | listitem = listitem.split("-d ", QString::SkipEmptyParts)[1]; |
---|
| 415 | listitem = listitem.split(" -", QString::SkipEmptyParts)[0]; |
---|
| 416 | listitem = listitem.replace(" ",""); |
---|
| 417 | |
---|
| 418 | |
---|
| 419 | // Select command line with correct timestamp and jobname |
---|
| 420 | if (history[i-1].left(16) == timestamp && listitem == jobname) |
---|
| 421 | { |
---|
| 422 | QString mrunline = history[i-1]; |
---|
| 423 | mrunline = mrunline.right(mrunline.length() - 17); |
---|
| 424 | ui->commandline->setText(mrunline); |
---|
| 425 | |
---|
| 426 | setup_gui(mrunline); |
---|
| 427 | } |
---|
| 428 | } |
---|
| 429 | } |
---|
| 430 | |
---|
| 431 | return 0; |
---|
| 432 | } |
---|
| 433 | |
---|
| 434 | |
---|
| 435 | //****************************************************************************// |
---|
| 436 | // Change run identifer (initial, restart, coupled...) |
---|
| 437 | int MainWindow::change_rc_list() |
---|
| 438 | { |
---|
| 439 | |
---|
| 440 | |
---|
| 441 | QString drop_job = ui->drop_job->currentText(); |
---|
| 442 | |
---|
| 443 | change_commandline("r",""); |
---|
| 444 | |
---|
| 445 | // Enable PE distribution for atmosphere/ocean |
---|
| 446 | if ( drop_job == "Coupled restart") |
---|
| 447 | { |
---|
| 448 | QString drop_atmos = ui->line_PE_atmos->text(); |
---|
| 449 | QString drop_ocean = ui->line_PE_ocean->text(); |
---|
| 450 | |
---|
| 451 | change_commandline("Y",drop_atmos+" "+drop_ocean); |
---|
| 452 | } |
---|
| 453 | |
---|
| 454 | // Check of ocean runs |
---|
| 455 | else |
---|
| 456 | { |
---|
| 457 | delete_commandline("Y"); |
---|
| 458 | if (drop_job == "Precursor run (Ocean)") |
---|
| 459 | { |
---|
| 460 | activate_flag("y"); |
---|
| 461 | } |
---|
| 462 | else |
---|
| 463 | { |
---|
| 464 | deactivate_flag("y"); |
---|
| 465 | } |
---|
| 466 | } |
---|
| 467 | |
---|
| 468 | |
---|
| 469 | return 0; |
---|
| 470 | } |
---|
| 471 | |
---|
| 472 | |
---|
| 473 | //****************************************************************************// |
---|
| 474 | // Routine for processing any changes in the mainwindow settings |
---|
| 475 | int MainWindow::change_commandline(QString id,QString fwstring) |
---|
| 476 | { |
---|
| 477 | |
---|
| 478 | // First get the mrunline |
---|
| 479 | QString newmrunline; |
---|
| 480 | bool initialize=false; |
---|
| 481 | |
---|
| 482 | QString mrunline = ui->commandline->text(); |
---|
| 483 | |
---|
| 484 | QStringList splitline = mrunline.split(" -"+id+"", QString::SkipEmptyParts); |
---|
| 485 | if ( splitline.count() == 1) |
---|
| 486 | { |
---|
| 487 | splitline.append(" "); |
---|
| 488 | } |
---|
| 489 | else if ( splitline.count() == 0 ) |
---|
| 490 | { |
---|
| 491 | splitline.append("mrun"); |
---|
| 492 | splitline.append(" "); |
---|
| 493 | initialize = true; |
---|
| 494 | } |
---|
| 495 | |
---|
| 496 | QStringList param = splitline[1].split("-"); |
---|
| 497 | |
---|
| 498 | // Change in parameter "d" (jobname) |
---|
| 499 | if (id == "d") |
---|
| 500 | { |
---|
| 501 | QString filename = ui->line_jobname->text(); |
---|
| 502 | |
---|
| 503 | param[0] = filename.replace(" ",""); |
---|
| 504 | |
---|
| 505 | if ( initialize == true && ui->group_runcontrol->isEnabled() == true ) |
---|
| 506 | { |
---|
| 507 | ui->group_runcontrol->setEnabled(true); |
---|
| 508 | ui->group_execution->setEnabled(true); |
---|
| 509 | ui->drop_job->setEnabled(true); |
---|
| 510 | ui->check_advanced->setEnabled(true); |
---|
| 511 | ui->button_start->setEnabled(true); |
---|
| 512 | ui->action_save->setEnabled(true); |
---|
| 513 | } |
---|
| 514 | else if ( param[0] == "") |
---|
| 515 | { |
---|
| 516 | ui->group_runcontrol->setEnabled(false); |
---|
| 517 | ui->group_execution->setEnabled(false); |
---|
| 518 | ui->drop_job->setEnabled(false); |
---|
| 519 | ui->button_start->setEnabled(false); |
---|
| 520 | ui->action_save->setEnabled(false); |
---|
| 521 | ui->group_advanced->setEnabled(false); |
---|
| 522 | ui->check_advanced->setEnabled(false); |
---|
| 523 | delete_commandline("d"); |
---|
| 524 | change_commandline("r","remove"); |
---|
| 525 | ui->label_usercode->setText(""); |
---|
| 526 | return 1; |
---|
| 527 | } |
---|
| 528 | else |
---|
| 529 | { |
---|
| 530 | |
---|
| 531 | // Check if user code is available |
---|
| 532 | branch = QCoreApplication::applicationDirPath(); |
---|
| 533 | branch = branch.left(branch.length() - 14); |
---|
| 534 | QDir usercode = branch+"/USER_CODE/"+param[0]; |
---|
| 535 | if (usercode.exists() == true) |
---|
| 536 | { |
---|
| 537 | ui->label_usercode->setText("User code found."); |
---|
| 538 | } |
---|
| 539 | else |
---|
| 540 | { |
---|
| 541 | ui->label_usercode->setText("Warning: no user code found!"); |
---|
| 542 | } |
---|
| 543 | |
---|
| 544 | // Check if _pdf file is available, otherwise notice user |
---|
| 545 | if (ui->check_restarts->checkState() == 2) |
---|
| 546 | { |
---|
| 547 | QString jobname = ui->line_jobname->text(); |
---|
| 548 | QFile restartfile(branch+"/JOBS/"+jobname+"/INPUT/"+jobname+"_p3df"); |
---|
| 549 | if (restartfile.exists() == true) |
---|
| 550 | { |
---|
| 551 | ui->label_restart->setText(""); |
---|
| 552 | } |
---|
| 553 | else |
---|
| 554 | { |
---|
| 555 | ui->label_restart->setText("Warning: No p3df file found!"); |
---|
| 556 | } |
---|
| 557 | } |
---|
| 558 | |
---|
| 559 | ui->group_runcontrol->setEnabled(true); |
---|
| 560 | ui->group_execution->setEnabled(true); |
---|
| 561 | ui->drop_job->setEnabled(true); |
---|
| 562 | ui->check_advanced->setEnabled(true); |
---|
| 563 | |
---|
| 564 | if ( ui->check_advanced->isChecked() == true ) |
---|
| 565 | { |
---|
| 566 | ui->group_advanced->setEnabled(true); |
---|
| 567 | if ( ui->line_i->text() != "" || ui->line_o->text() != "") |
---|
| 568 | { |
---|
| 569 | change_commandline("r","remove"); |
---|
| 570 | ui->group_runcontrol->setEnabled(false); |
---|
| 571 | } |
---|
| 572 | } |
---|
| 573 | } |
---|
| 574 | |
---|
| 575 | } |
---|
| 576 | |
---|
| 577 | // Change in parameter "r" (run control list) |
---|
| 578 | else if (id == "r") |
---|
| 579 | { |
---|
| 580 | int status_ts = ui->check_ts->checkState(); |
---|
| 581 | int status_pr = ui->check_pr->checkState(); |
---|
| 582 | int status_xy = ui->check_xy->checkState(); |
---|
| 583 | int status_xz = ui->check_xz->checkState(); |
---|
| 584 | int status_yz = ui->check_yz->checkState(); |
---|
| 585 | int status_3d = ui->check_3d->checkState(); |
---|
| 586 | int status_ma = ui->check_ma->checkState(); |
---|
| 587 | int status_sp = ui->check_sp->checkState(); |
---|
| 588 | int status_pts = ui->check_pts->checkState(); |
---|
| 589 | int status_prt = ui->check_prt->checkState(); |
---|
| 590 | |
---|
| 591 | QString drop_job = ui->drop_job->currentText(); |
---|
| 592 | QString rc_flag = "#"; |
---|
| 593 | |
---|
| 594 | if (drop_job == "Initial run") |
---|
| 595 | { |
---|
| 596 | rc_flag = "#"; |
---|
| 597 | } |
---|
| 598 | else if (drop_job == "Restart run") |
---|
| 599 | { |
---|
| 600 | rc_flag = "f"; |
---|
| 601 | } |
---|
| 602 | else if (drop_job == "Precursor run (Atmosphere)") |
---|
| 603 | { |
---|
| 604 | rc_flag = "#"; |
---|
| 605 | } |
---|
| 606 | else if (drop_job == "Precursor run (Ocean)") |
---|
| 607 | { |
---|
| 608 | rc_flag = "o#"; |
---|
| 609 | } |
---|
| 610 | else if (drop_job == "Coupled restart") |
---|
| 611 | { |
---|
| 612 | rc_flag = "f"; |
---|
| 613 | } |
---|
| 614 | |
---|
| 615 | param[0] = "\"d3"+rc_flag; |
---|
| 616 | |
---|
| 617 | if (status_ts == 2) |
---|
| 618 | { |
---|
| 619 | param[0] = param[0]+" ts"+rc_flag; |
---|
| 620 | } |
---|
| 621 | if (status_pr == 2) |
---|
| 622 | { |
---|
| 623 | param[0] = param[0]+" pr"+rc_flag; |
---|
| 624 | } |
---|
| 625 | if (status_xy == 2) |
---|
| 626 | { |
---|
| 627 | param[0] = param[0]+" xy"+rc_flag; |
---|
| 628 | } |
---|
| 629 | if (status_xz == 2) |
---|
| 630 | { |
---|
| 631 | param[0] = param[0]+" xz"+rc_flag; |
---|
| 632 | } |
---|
| 633 | if (status_yz == 2) |
---|
| 634 | { |
---|
| 635 | param[0] = param[0]+" yz"+rc_flag; |
---|
| 636 | } |
---|
| 637 | if (status_3d == 2) |
---|
| 638 | { |
---|
| 639 | param[0] = param[0]+" 3d"+rc_flag; |
---|
| 640 | } |
---|
| 641 | if (status_ma == 2) |
---|
| 642 | { |
---|
| 643 | param[0] = param[0]+" ma"+rc_flag; |
---|
| 644 | } |
---|
| 645 | if (status_sp == 2) |
---|
| 646 | { |
---|
| 647 | param[0] = param[0]+" sp"+rc_flag; |
---|
| 648 | } |
---|
| 649 | if (status_prt == 2) |
---|
| 650 | { |
---|
| 651 | param[0] = param[0]+" prt"+rc_flag; |
---|
| 652 | } |
---|
| 653 | if (status_pts == 2) |
---|
| 654 | { |
---|
| 655 | param[0] = param[0]+" pts"+rc_flag; |
---|
| 656 | } |
---|
| 657 | |
---|
| 658 | if (drop_job == "Coupled restart") |
---|
| 659 | { |
---|
| 660 | rc_flag = "of"; |
---|
| 661 | param[0] = param[0]+" d3"+rc_flag; |
---|
| 662 | |
---|
| 663 | if (status_ts == 2) |
---|
| 664 | { |
---|
| 665 | param[0] = param[0]+" ts"+rc_flag; |
---|
| 666 | } |
---|
| 667 | if (status_pr == 2) |
---|
| 668 | { |
---|
| 669 | param[0] = param[0]+" pr"+rc_flag; |
---|
| 670 | } |
---|
| 671 | if (status_xy == 2) |
---|
| 672 | { |
---|
| 673 | param[0] = param[0]+" xy"+rc_flag; |
---|
| 674 | } |
---|
| 675 | if (status_xz == 2) |
---|
| 676 | { |
---|
| 677 | param[0] = param[0]+" xz"+rc_flag; |
---|
| 678 | } |
---|
| 679 | if (status_yz == 2) |
---|
| 680 | { |
---|
| 681 | param[0] = param[0]+" yz"+rc_flag; |
---|
| 682 | } |
---|
| 683 | if (status_3d == 2) |
---|
| 684 | { |
---|
| 685 | param[0] = param[0]+" 3d"+rc_flag; |
---|
| 686 | } |
---|
| 687 | if (status_ma == 2) |
---|
| 688 | { |
---|
| 689 | param[0] = param[0]+" ma"+rc_flag; |
---|
| 690 | } |
---|
| 691 | if (status_sp == 2) |
---|
| 692 | { |
---|
| 693 | param[0] = param[0]+" sp"+rc_flag; |
---|
| 694 | } |
---|
| 695 | if (status_prt == 2) |
---|
| 696 | { |
---|
| 697 | param[0] = param[0]+" prt"+rc_flag; |
---|
| 698 | } |
---|
| 699 | if (status_pts == 2) |
---|
| 700 | { |
---|
| 701 | param[0] = param[0]+" pts"+rc_flag; |
---|
| 702 | } |
---|
| 703 | } |
---|
| 704 | |
---|
| 705 | int status_restarts = ui->check_restarts->checkState(); |
---|
| 706 | |
---|
| 707 | |
---|
| 708 | |
---|
| 709 | if (status_restarts == 2) |
---|
| 710 | { |
---|
| 711 | param[0]=param[0]+" restart"; |
---|
| 712 | |
---|
| 713 | // Check if _pdf file is available, otherwise notice user |
---|
| 714 | if (ui->check_restarts->checkState() == 2) |
---|
| 715 | { |
---|
| 716 | QString jobname = ui->line_jobname->text(); |
---|
| 717 | branch = QCoreApplication::applicationDirPath(); |
---|
| 718 | branch = branch.left(branch.length() - 14); |
---|
| 719 | QFile restartfile(branch+"/JOBS/"+jobname+"/INPUT/"+jobname+ \ |
---|
| 720 | "_p3df"); |
---|
| 721 | if (restartfile.exists() == true) |
---|
| 722 | { |
---|
| 723 | ui->label_restart->setText(""); |
---|
| 724 | } |
---|
| 725 | else |
---|
| 726 | { |
---|
| 727 | ui->label_restart->setText("Warning: No p3df file found!"); |
---|
| 728 | } |
---|
| 729 | } |
---|
| 730 | |
---|
| 731 | } |
---|
| 732 | else { |
---|
| 733 | ui->label_restart->setText(""); |
---|
| 734 | } |
---|
| 735 | |
---|
| 736 | param[0]=param[0]+"\" "; |
---|
| 737 | |
---|
| 738 | if ( fwstring == "remove") |
---|
| 739 | { |
---|
| 740 | delete_commandline(id); |
---|
| 741 | return 1; |
---|
| 742 | } |
---|
| 743 | else |
---|
| 744 | { |
---|
| 745 | ui->button_start->setEnabled(true); |
---|
| 746 | ui->action_save->setEnabled(true); |
---|
| 747 | } |
---|
| 748 | } |
---|
| 749 | // Change in any other parameter |
---|
| 750 | else |
---|
| 751 | { |
---|
| 752 | if ( fwstring != "") |
---|
| 753 | { |
---|
| 754 | param[0] = "\""+fwstring+"\""; |
---|
| 755 | } |
---|
| 756 | else |
---|
| 757 | { |
---|
| 758 | delete_commandline(id); |
---|
| 759 | return 1; |
---|
| 760 | } |
---|
| 761 | |
---|
| 762 | } |
---|
| 763 | param[0] = param[0] + " "; |
---|
| 764 | |
---|
| 765 | // Join the new mrunline |
---|
| 766 | splitline[1]= param.join("-"); |
---|
| 767 | newmrunline = splitline.join(" -"+id+" "); |
---|
| 768 | |
---|
| 769 | // Print the new mrunline to mainwindow |
---|
| 770 | newmrunline.replace(" "," "); |
---|
| 771 | ui->commandline->setText(newmrunline); |
---|
| 772 | |
---|
| 773 | return 0; |
---|
| 774 | } |
---|
| 775 | |
---|
| 776 | |
---|
| 777 | //****************************************************************************// |
---|
| 778 | // Get all signals from mainwindow and perform change via change_commandline() |
---|
| 779 | int MainWindow::change_lineinput() |
---|
| 780 | { |
---|
| 781 | QString tmptext; |
---|
| 782 | |
---|
| 783 | if ( sender() == ui->line_host ) |
---|
| 784 | { |
---|
| 785 | tmptext = ui->line_host->text(); |
---|
| 786 | change_commandline("h",tmptext); |
---|
| 787 | } |
---|
| 788 | else if ( sender() == ui->line_jobname) |
---|
| 789 | { |
---|
| 790 | tmptext = ui->line_jobname->text(); |
---|
| 791 | change_commandline("d",tmptext); |
---|
| 792 | } |
---|
| 793 | else if ( sender() == ui->line_q) |
---|
| 794 | { |
---|
| 795 | tmptext = ui->line_q->text(); |
---|
| 796 | change_commandline("q",tmptext); |
---|
| 797 | } |
---|
| 798 | else if ( sender() == ui->line_account) |
---|
| 799 | { |
---|
| 800 | tmptext = ui->line_account->text(); |
---|
| 801 | change_commandline("u",tmptext); |
---|
| 802 | } |
---|
| 803 | else if ( sender() == ui->line_pe) |
---|
| 804 | { |
---|
| 805 | tmptext = ui->line_pe->text(); |
---|
| 806 | change_commandline("X",tmptext); |
---|
| 807 | } |
---|
| 808 | else if ( sender() == ui->line_tpn) |
---|
| 809 | { |
---|
| 810 | tmptext = ui->line_tpn->text(); |
---|
| 811 | change_commandline("T",tmptext); |
---|
| 812 | } |
---|
| 813 | else if ( sender() == ui->line_branch) |
---|
| 814 | { |
---|
| 815 | tmptext = ui->line_branch->text(); |
---|
| 816 | change_commandline("K",tmptext); |
---|
| 817 | } |
---|
| 818 | else if ( sender() == ui->line_time) |
---|
| 819 | { |
---|
| 820 | tmptext = ui->line_time->text(); |
---|
| 821 | change_commandline("t",tmptext); |
---|
| 822 | } |
---|
| 823 | else if ( sender() == ui->line_M) |
---|
| 824 | { |
---|
| 825 | tmptext = ui->line_M->text(); |
---|
| 826 | change_commandline("M",tmptext); |
---|
| 827 | } |
---|
| 828 | else if ( sender() == ui->line_m) |
---|
| 829 | { |
---|
| 830 | tmptext = ui->line_m->text(); |
---|
| 831 | change_commandline("m",tmptext); |
---|
| 832 | } |
---|
| 833 | else if ( sender() == ui->line_a) |
---|
| 834 | { |
---|
| 835 | tmptext = ui->line_a->text(); |
---|
| 836 | change_commandline("a",tmptext); |
---|
| 837 | } |
---|
| 838 | else if ( sender() == ui->line_D) |
---|
| 839 | { |
---|
| 840 | tmptext = ui->line_D->text(); |
---|
| 841 | change_commandline("D",tmptext); |
---|
| 842 | } |
---|
| 843 | else if ( sender() == ui->line_c) |
---|
| 844 | { |
---|
| 845 | tmptext = ui->line_c->text(); |
---|
| 846 | if ( tmptext == ".mrun.config") |
---|
| 847 | { |
---|
| 848 | tmptext = ""; |
---|
| 849 | } |
---|
| 850 | change_commandline("c",tmptext); |
---|
| 851 | } |
---|
| 852 | else if ( sender() == ui->line_p) |
---|
| 853 | { |
---|
| 854 | tmptext = ui->line_p->text(); |
---|
| 855 | change_commandline("p",tmptext); |
---|
| 856 | } |
---|
| 857 | else if ( sender() == ui->line_s) |
---|
| 858 | { |
---|
| 859 | tmptext = ui->line_s->text(); |
---|
| 860 | change_commandline("s",tmptext); |
---|
| 861 | } |
---|
| 862 | else if ( sender() == ui->line_i) |
---|
| 863 | { |
---|
| 864 | tmptext = ui->line_i->text(); |
---|
| 865 | if ( tmptext != "") |
---|
| 866 | { |
---|
| 867 | change_commandline("r","remove"); |
---|
| 868 | ui->group_runcontrol->setEnabled(false); |
---|
| 869 | |
---|
| 870 | ui->button_start->setEnabled(true); |
---|
| 871 | ui->action_save->setEnabled(true); |
---|
| 872 | } |
---|
| 873 | else if (ui->line_o->text() == "" ) |
---|
| 874 | { |
---|
| 875 | ui->group_runcontrol->setEnabled(true); |
---|
| 876 | change_commandline("r",""); |
---|
| 877 | } |
---|
| 878 | |
---|
| 879 | change_commandline("i",tmptext); |
---|
| 880 | } |
---|
| 881 | else if ( sender() == ui->line_o) |
---|
| 882 | { |
---|
| 883 | tmptext = ui->line_o->text(); |
---|
| 884 | if ( tmptext != "") |
---|
| 885 | { |
---|
| 886 | change_commandline("r","remove"); |
---|
| 887 | ui->button_start->setEnabled(true); |
---|
| 888 | ui->action_save->setEnabled(true); |
---|
| 889 | ui->group_runcontrol->setEnabled(false); |
---|
| 890 | } |
---|
| 891 | else if (ui->line_i->text() == "" ) |
---|
| 892 | { |
---|
| 893 | ui->group_runcontrol->setEnabled(true); |
---|
| 894 | change_commandline("r",""); |
---|
| 895 | } |
---|
| 896 | |
---|
| 897 | change_commandline("o",tmptext); |
---|
| 898 | |
---|
| 899 | } |
---|
| 900 | else if ( sender() == ui->line_w) |
---|
| 901 | { |
---|
| 902 | tmptext = ui->line_w->text(); |
---|
| 903 | change_commandline("w",tmptext); |
---|
| 904 | } |
---|
| 905 | else if ( sender() == ui->line_PE_atmos || sender() == ui->line_PE_ocean) |
---|
| 906 | { |
---|
| 907 | tmptext = ui->line_PE_atmos->text() + " " + ui->line_PE_ocean->text(); |
---|
| 908 | change_commandline("Y",tmptext); |
---|
| 909 | int PE_total = ui->line_PE_atmos->text().toInt() + \ |
---|
| 910 | ui->line_PE_ocean->text().toInt(); |
---|
| 911 | ui->line_pe->setText(QString::number(PE_total)); |
---|
| 912 | change_commandline("X",QString::number(PE_total)); |
---|
| 913 | } |
---|
| 914 | |
---|
| 915 | else if ( sender() == ui->combo_n) |
---|
| 916 | { |
---|
| 917 | tmptext = ui->combo_n->currentText(); |
---|
| 918 | if ( tmptext == "default") |
---|
| 919 | { |
---|
| 920 | tmptext = ""; |
---|
| 921 | } |
---|
| 922 | change_commandline("n",tmptext); |
---|
| 923 | } |
---|
| 924 | else if ( sender() == ui->line_user) |
---|
| 925 | { |
---|
| 926 | return 0; |
---|
| 927 | } |
---|
| 928 | |
---|
| 929 | return 0; |
---|
| 930 | } |
---|
| 931 | |
---|
| 932 | |
---|
| 933 | //****************************************************************************// |
---|
| 934 | // Delete a parameter from mrunline |
---|
| 935 | int MainWindow::delete_commandline(QString id) |
---|
| 936 | { |
---|
| 937 | |
---|
| 938 | // Read mrunline |
---|
| 939 | QString newmrunline; |
---|
| 940 | QString mrunline = ui->commandline->text(); |
---|
| 941 | QStringList splitline = mrunline.split(" -"+id, QString::SkipEmptyParts); |
---|
| 942 | if ( splitline.count() == 1) |
---|
| 943 | { |
---|
| 944 | return 0; |
---|
| 945 | } |
---|
| 946 | else |
---|
| 947 | { |
---|
| 948 | QStringList param = splitline[1].split("-"); |
---|
| 949 | param[0] = ""; |
---|
| 950 | splitline[1]= param.join(" -"); |
---|
| 951 | newmrunline = splitline.join(""); |
---|
| 952 | |
---|
| 953 | // Print new mrunline to screen |
---|
| 954 | ui->commandline->setText(newmrunline); |
---|
| 955 | |
---|
| 956 | return 0; |
---|
| 957 | } |
---|
| 958 | } |
---|
| 959 | |
---|
| 960 | |
---|
| 961 | //****************************************************************************// |
---|
| 962 | // Check routine for all flag parameters |
---|
| 963 | int MainWindow::check_flags() |
---|
| 964 | { |
---|
| 965 | |
---|
| 966 | int status = ui->check_delete_tmp_files->checkState(); |
---|
| 967 | |
---|
| 968 | if (status == 2) |
---|
| 969 | { |
---|
| 970 | activate_flag("B"); |
---|
| 971 | } |
---|
| 972 | else |
---|
| 973 | { |
---|
| 974 | deactivate_flag("B"); |
---|
| 975 | } |
---|
| 976 | |
---|
| 977 | status = ui->check_verbose->checkState(); |
---|
| 978 | |
---|
| 979 | if (status == 2) |
---|
| 980 | { |
---|
| 981 | activate_flag("v"); |
---|
| 982 | } |
---|
| 983 | else |
---|
| 984 | { |
---|
| 985 | deactivate_flag("v"); |
---|
| 986 | } |
---|
| 987 | |
---|
| 988 | status = ui->check_A->checkState(); |
---|
| 989 | |
---|
| 990 | if (status == 2) |
---|
| 991 | { |
---|
| 992 | activate_flag("A"); |
---|
| 993 | } |
---|
| 994 | else |
---|
| 995 | { |
---|
| 996 | deactivate_flag("A"); |
---|
| 997 | } |
---|
| 998 | |
---|
| 999 | status = ui->check_b->checkState(); |
---|
| 1000 | |
---|
| 1001 | if (status == 2) |
---|
| 1002 | { |
---|
| 1003 | activate_flag("b"); |
---|
| 1004 | } |
---|
| 1005 | else |
---|
| 1006 | { |
---|
| 1007 | deactivate_flag("b"); |
---|
| 1008 | } |
---|
| 1009 | |
---|
| 1010 | status = ui->check_F->checkState(); |
---|
| 1011 | |
---|
| 1012 | if (status == 2) |
---|
| 1013 | { |
---|
| 1014 | activate_flag("F"); |
---|
| 1015 | } |
---|
| 1016 | else |
---|
| 1017 | { |
---|
| 1018 | deactivate_flag("F"); |
---|
| 1019 | } |
---|
| 1020 | status = ui->check_I->checkState(); |
---|
| 1021 | |
---|
| 1022 | if (status == 2) |
---|
| 1023 | { |
---|
| 1024 | activate_flag("I"); |
---|
| 1025 | } |
---|
| 1026 | else |
---|
| 1027 | { |
---|
| 1028 | deactivate_flag("I"); |
---|
| 1029 | } |
---|
| 1030 | status = ui->check_k->checkState(); |
---|
| 1031 | |
---|
| 1032 | if (status == 2) |
---|
| 1033 | { |
---|
| 1034 | activate_flag("k"); |
---|
| 1035 | } |
---|
| 1036 | else |
---|
| 1037 | { |
---|
| 1038 | deactivate_flag("k"); |
---|
| 1039 | } |
---|
| 1040 | status = ui->check_O->checkState(); |
---|
| 1041 | |
---|
| 1042 | if (status == 2) |
---|
| 1043 | { |
---|
| 1044 | activate_flag("O"); |
---|
| 1045 | } |
---|
| 1046 | else |
---|
| 1047 | { |
---|
| 1048 | deactivate_flag("O"); |
---|
| 1049 | } |
---|
| 1050 | status = ui->check_S->checkState(); |
---|
| 1051 | |
---|
| 1052 | if (status == 2) |
---|
| 1053 | { |
---|
| 1054 | activate_flag("S"); |
---|
| 1055 | } |
---|
| 1056 | else |
---|
| 1057 | { |
---|
| 1058 | deactivate_flag("S"); |
---|
| 1059 | } |
---|
| 1060 | status = ui->check_x->checkState(); |
---|
| 1061 | |
---|
| 1062 | if (status == 2) |
---|
| 1063 | { |
---|
| 1064 | activate_flag("x"); |
---|
| 1065 | } |
---|
| 1066 | else |
---|
| 1067 | { |
---|
| 1068 | deactivate_flag("x"); |
---|
| 1069 | } |
---|
| 1070 | return 0; |
---|
| 1071 | |
---|
| 1072 | } |
---|
| 1073 | |
---|
| 1074 | |
---|
| 1075 | //****************************************************************************// |
---|
| 1076 | // Activate flag |
---|
| 1077 | int MainWindow::activate_flag(QString id) |
---|
| 1078 | { |
---|
| 1079 | QString newmrunline; |
---|
| 1080 | |
---|
| 1081 | QString mrunline = ui->commandline->text(); |
---|
| 1082 | |
---|
| 1083 | QStringList splitline = mrunline.split(" -"+id, QString::SkipEmptyParts); |
---|
| 1084 | if ( splitline.count() == 1) |
---|
| 1085 | { |
---|
| 1086 | splitline.append(""); |
---|
| 1087 | newmrunline = splitline.join(" -"+id); |
---|
| 1088 | |
---|
| 1089 | // print new commandline to screen |
---|
| 1090 | newmrunline.replace(" "," "); |
---|
| 1091 | ui->commandline->setText(newmrunline); |
---|
| 1092 | |
---|
| 1093 | return 0; |
---|
| 1094 | } |
---|
| 1095 | else |
---|
| 1096 | { |
---|
| 1097 | return 0; |
---|
| 1098 | } |
---|
| 1099 | } |
---|
| 1100 | |
---|
| 1101 | |
---|
| 1102 | //****************************************************************************// |
---|
| 1103 | // Deactivate flag |
---|
| 1104 | int MainWindow::deactivate_flag(QString id) |
---|
| 1105 | { |
---|
| 1106 | QString newmrunline; |
---|
| 1107 | |
---|
| 1108 | QString mrunline = ui->commandline->text(); |
---|
| 1109 | |
---|
| 1110 | QStringList splitline = mrunline.split(" -"+id, QString::SkipEmptyParts); |
---|
| 1111 | |
---|
| 1112 | newmrunline = splitline.join(""); |
---|
| 1113 | // print new commandline to screen |
---|
| 1114 | newmrunline.replace(" "," "); |
---|
| 1115 | ui->commandline->setText(newmrunline); |
---|
| 1116 | |
---|
| 1117 | return 0; |
---|
| 1118 | } |
---|
| 1119 | |
---|
| 1120 | |
---|
| 1121 | //****************************************************************************// |
---|
| 1122 | // Mainwindow reset |
---|
| 1123 | int MainWindow::reset_window() |
---|
| 1124 | { |
---|
| 1125 | ui->setupUi(this); |
---|
| 1126 | recent_jobs(10); |
---|
| 1127 | return 0; |
---|
| 1128 | } |
---|
| 1129 | |
---|
| 1130 | |
---|
| 1131 | //****************************************************************************// |
---|
| 1132 | // Save current setting as default |
---|
| 1133 | int MainWindow::save_default() |
---|
| 1134 | { |
---|
| 1135 | |
---|
| 1136 | // Get mrunline |
---|
| 1137 | QString mrunline_save; |
---|
| 1138 | QString mrunline = ui->commandline->text(); |
---|
| 1139 | QString userline = ui->line_user->text(); |
---|
| 1140 | |
---|
| 1141 | mrunline_save = mrunline; |
---|
| 1142 | if (userline != "") |
---|
| 1143 | { |
---|
| 1144 | mrunline = mrunline + " " + userline; |
---|
| 1145 | } |
---|
| 1146 | |
---|
| 1147 | |
---|
| 1148 | // Define filename |
---|
| 1149 | branch = QCoreApplication::applicationDirPath(); |
---|
| 1150 | branch = branch.left(branch.length() - 14); |
---|
| 1151 | |
---|
| 1152 | QString filename = branch+"/.mrun.gui.default"; |
---|
| 1153 | |
---|
| 1154 | // Prepare data output |
---|
| 1155 | QDateTime time = QDateTime::currentDateTime(); |
---|
| 1156 | QString tmptime = time.toString("yyyy/MM/dd hh:mm"); |
---|
| 1157 | |
---|
| 1158 | // Write to file |
---|
| 1159 | QFile file(filename); |
---|
| 1160 | file.open(QIODevice::WriteOnly | QIODevice::Text); |
---|
| 1161 | QTextStream out(&file); |
---|
| 1162 | if ( mrunline == "" || mrunline == " ") |
---|
| 1163 | { |
---|
| 1164 | out << ""; |
---|
| 1165 | } |
---|
| 1166 | else |
---|
| 1167 | { |
---|
| 1168 | out << tmptime + " " + mrunline; |
---|
| 1169 | } |
---|
| 1170 | |
---|
| 1171 | file.close(); |
---|
| 1172 | |
---|
| 1173 | return 0; |
---|
| 1174 | } |
---|
| 1175 | |
---|
| 1176 | |
---|
| 1177 | //****************************************************************************// |
---|
| 1178 | // Save current settings to a file of choice |
---|
| 1179 | int MainWindow::save_to_file() |
---|
| 1180 | { |
---|
| 1181 | |
---|
| 1182 | // Get mrunline |
---|
| 1183 | QString mrunline_save; |
---|
| 1184 | QString mrunline = ui->commandline->text(); |
---|
| 1185 | QString userline = ui->line_user->text(); |
---|
| 1186 | |
---|
| 1187 | mrunline_save = mrunline; |
---|
| 1188 | if (userline != "") |
---|
| 1189 | { |
---|
| 1190 | mrunline = mrunline + " " + userline; |
---|
| 1191 | } |
---|
| 1192 | |
---|
| 1193 | // Define a filename |
---|
| 1194 | QString filename = QFileDialog::getSaveFileName(this, tr("Save to file"), \ |
---|
| 1195 | "", tr("Save files (*.sav)")); |
---|
| 1196 | QString extension = filename.right(4); |
---|
| 1197 | |
---|
| 1198 | if ( extension != ".sav" ) |
---|
| 1199 | { |
---|
| 1200 | filename = filename + ".sav"; |
---|
| 1201 | } |
---|
| 1202 | |
---|
| 1203 | // Prepare data output |
---|
| 1204 | QDateTime time = QDateTime::currentDateTime(); |
---|
| 1205 | QString tmptime = time.toString("yyyy/MM/dd hh:mm"); |
---|
| 1206 | |
---|
| 1207 | // Write to file |
---|
| 1208 | QFile file(filename); |
---|
| 1209 | file.open(QIODevice::WriteOnly | QIODevice::Text); |
---|
| 1210 | QTextStream out(&file); |
---|
| 1211 | out << tmptime + " " + mrunline; |
---|
| 1212 | file.close(); |
---|
| 1213 | |
---|
| 1214 | return 0; |
---|
| 1215 | } |
---|
| 1216 | |
---|
| 1217 | |
---|
| 1218 | //****************************************************************************// |
---|
| 1219 | // Open job from file (previously saved by the user) |
---|
| 1220 | int MainWindow::open_from_file() |
---|
| 1221 | { |
---|
| 1222 | |
---|
| 1223 | // Select filename and open it |
---|
| 1224 | QString filename = QFileDialog::getOpenFileName(this, tr("Open File"), \ |
---|
| 1225 | "", tr("Save files (*.sav)")); |
---|
| 1226 | |
---|
| 1227 | QFile file(filename); |
---|
| 1228 | QString mrunline; |
---|
| 1229 | if ( filename != "") |
---|
| 1230 | { |
---|
| 1231 | if ( file.open(QIODevice::ReadOnly | QIODevice::Text ) ) |
---|
| 1232 | { |
---|
| 1233 | |
---|
| 1234 | // File opened successfully |
---|
| 1235 | QTextStream in(&file); |
---|
| 1236 | |
---|
| 1237 | QString line = in.readLine(); |
---|
| 1238 | while (!line.isNull()) |
---|
| 1239 | { |
---|
| 1240 | mrunline = line; |
---|
| 1241 | line = in.readLine(); |
---|
| 1242 | } |
---|
| 1243 | file.close(); |
---|
| 1244 | } |
---|
| 1245 | |
---|
| 1246 | // In case a mrunline was found, load it to mainwindow |
---|
| 1247 | if ( mrunline != "") |
---|
| 1248 | { |
---|
| 1249 | |
---|
| 1250 | mrunline = mrunline.right(mrunline.length() - 17); |
---|
| 1251 | ui->commandline->setText(mrunline); |
---|
| 1252 | |
---|
| 1253 | setup_gui(mrunline); |
---|
| 1254 | } |
---|
| 1255 | } |
---|
| 1256 | return 0; |
---|
| 1257 | } |
---|
| 1258 | |
---|
| 1259 | |
---|
| 1260 | //****************************************************************************// |
---|
| 1261 | // Open the last submitted job |
---|
| 1262 | int MainWindow::open_last() |
---|
| 1263 | { |
---|
| 1264 | branch = QCoreApplication::applicationDirPath(); |
---|
| 1265 | branch = branch.left(branch.length() - 14); |
---|
| 1266 | |
---|
| 1267 | QFile file(branch+"/.mrun.history"); |
---|
| 1268 | |
---|
| 1269 | // Load mrun history |
---|
| 1270 | QString mrunline; |
---|
| 1271 | if ( file.open(QIODevice::ReadOnly | QIODevice::Text ) ) |
---|
| 1272 | { |
---|
| 1273 | |
---|
| 1274 | // file opened successfully |
---|
| 1275 | QTextStream in(&file); |
---|
| 1276 | |
---|
| 1277 | QString line = in.readLine(); |
---|
| 1278 | while (!line.isNull()) |
---|
| 1279 | { |
---|
| 1280 | mrunline = line; |
---|
| 1281 | line = in.readLine(); |
---|
| 1282 | } |
---|
| 1283 | |
---|
| 1284 | file.close(); |
---|
| 1285 | } |
---|
| 1286 | |
---|
| 1287 | // Select the last submitted job and print it to mainwindow |
---|
| 1288 | if ( mrunline != "" ) |
---|
| 1289 | { |
---|
| 1290 | mrunline = mrunline.right(mrunline.length() - 17); |
---|
| 1291 | ui->commandline->setText(mrunline); |
---|
| 1292 | |
---|
| 1293 | setup_gui(mrunline); |
---|
| 1294 | } |
---|
| 1295 | return 0; |
---|
| 1296 | } |
---|
| 1297 | |
---|
| 1298 | //****************************************************************************// |
---|
| 1299 | // Display help window |
---|
| 1300 | int MainWindow::help() |
---|
| 1301 | { |
---|
| 1302 | |
---|
| 1303 | QDialog *child_help = new QDialog; |
---|
| 1304 | Ui::child_help ui; |
---|
| 1305 | ui.setupUi(child_help); |
---|
| 1306 | child_help->show(); |
---|
| 1307 | |
---|
| 1308 | |
---|
| 1309 | return 0; |
---|
| 1310 | } |
---|
| 1311 | |
---|
| 1312 | //****************************************************************************// |
---|
| 1313 | // Display about window |
---|
| 1314 | int MainWindow::about_gui() |
---|
| 1315 | { |
---|
| 1316 | |
---|
| 1317 | QDialog *about = new QDialog; |
---|
| 1318 | Ui::about ui; |
---|
| 1319 | ui.setupUi(about); |
---|
| 1320 | about->show(); |
---|
| 1321 | |
---|
| 1322 | return 0; |
---|
| 1323 | } |
---|
| 1324 | |
---|
| 1325 | //****************************************************************************// |
---|
| 1326 | // Setup mainwindow according to a given mrunline |
---|
| 1327 | int MainWindow::setup_gui(QString mrunline) |
---|
| 1328 | { |
---|
| 1329 | |
---|
| 1330 | // Some initial settings |
---|
| 1331 | QString user = ""; |
---|
| 1332 | |
---|
| 1333 | bool coupled_run = false; |
---|
| 1334 | bool ocean_run = false; |
---|
| 1335 | bool advanced = false; |
---|
| 1336 | bool nojob = false; |
---|
| 1337 | bool rc_manual = false; |
---|
| 1338 | |
---|
| 1339 | // Split parameters in mrunline |
---|
| 1340 | QStringList splitline = mrunline.split(" -", QString::SkipEmptyParts); |
---|
| 1341 | |
---|
| 1342 | if ( splitline[0] != "mrun") |
---|
| 1343 | { |
---|
| 1344 | return 1; |
---|
| 1345 | |
---|
| 1346 | } |
---|
| 1347 | else |
---|
| 1348 | { |
---|
| 1349 | ui->group_job->setEnabled(true); |
---|
| 1350 | |
---|
| 1351 | // Loop for all parameters in mrunline |
---|
| 1352 | for(int i=splitline.count()-1; i>=1; i--) |
---|
| 1353 | { |
---|
| 1354 | |
---|
| 1355 | // Determine parameter |
---|
| 1356 | QStringList splitparameter = splitline[i].split(" ", \ |
---|
| 1357 | QString::SkipEmptyParts); |
---|
| 1358 | |
---|
| 1359 | QString parameter = splitparameter[0]; |
---|
| 1360 | splitparameter.removeFirst(); |
---|
| 1361 | QString options = splitparameter.join(" "); |
---|
| 1362 | options = options.replace("\"",""); |
---|
| 1363 | |
---|
| 1364 | // Check for suitable switch |
---|
| 1365 | if ( parameter == "d") |
---|
| 1366 | { |
---|
| 1367 | if ( options != "") |
---|
| 1368 | { |
---|
| 1369 | ui->line_jobname->setText(options); |
---|
| 1370 | nojob = false; |
---|
| 1371 | } |
---|
| 1372 | else |
---|
| 1373 | { |
---|
| 1374 | nojob = true; |
---|
| 1375 | } |
---|
| 1376 | } |
---|
| 1377 | else if ( parameter == "h") |
---|
| 1378 | { |
---|
| 1379 | ui->line_host->setText(options); |
---|
| 1380 | } |
---|
| 1381 | else if ( parameter == "q") |
---|
| 1382 | { |
---|
| 1383 | ui->line_q->setText(options); |
---|
| 1384 | } |
---|
| 1385 | else if ( parameter == "K") |
---|
| 1386 | { |
---|
| 1387 | ui->line_branch->setText(options); |
---|
| 1388 | } |
---|
| 1389 | else if ( parameter == "u") |
---|
| 1390 | { |
---|
| 1391 | ui->line_account->setText(options); |
---|
| 1392 | } |
---|
| 1393 | else if ( parameter == "X") |
---|
| 1394 | { |
---|
| 1395 | ui->line_pe->setText(options); |
---|
| 1396 | } |
---|
| 1397 | else if ( parameter == "T") |
---|
| 1398 | { |
---|
| 1399 | ui->line_tpn->setText(options); |
---|
| 1400 | } |
---|
| 1401 | else if ( parameter == "t") |
---|
| 1402 | { |
---|
| 1403 | ui->line_time->setText(options); |
---|
| 1404 | } |
---|
| 1405 | else if ( parameter == "B") |
---|
| 1406 | { |
---|
| 1407 | ui->check_delete_tmp_files->setChecked(true); |
---|
| 1408 | } |
---|
| 1409 | else if ( parameter == "v") |
---|
| 1410 | { |
---|
| 1411 | ui->check_verbose->setChecked(true); |
---|
| 1412 | } |
---|
| 1413 | else if ( parameter == "A") |
---|
| 1414 | { |
---|
| 1415 | ui->check_A->setChecked(true); |
---|
| 1416 | |
---|
| 1417 | } |
---|
| 1418 | else if ( parameter == "b") |
---|
| 1419 | { |
---|
| 1420 | ui->check_b->setChecked(true); |
---|
| 1421 | advanced = true; |
---|
| 1422 | } |
---|
| 1423 | else if ( parameter == "F") |
---|
| 1424 | { |
---|
| 1425 | ui->check_F->setChecked(true); |
---|
| 1426 | advanced = true; |
---|
| 1427 | } |
---|
| 1428 | else if ( parameter == "I") |
---|
| 1429 | { |
---|
| 1430 | ui->check_I->setChecked(true); |
---|
| 1431 | advanced = true; |
---|
| 1432 | } |
---|
| 1433 | else if ( parameter == "k") |
---|
| 1434 | { |
---|
| 1435 | ui->check_k->setChecked(true); |
---|
| 1436 | advanced = true; |
---|
| 1437 | } |
---|
| 1438 | else if ( parameter == "O") |
---|
| 1439 | { |
---|
| 1440 | ui->check_O->setChecked(true); |
---|
| 1441 | advanced = true; |
---|
| 1442 | } |
---|
| 1443 | else if ( parameter == "S") |
---|
| 1444 | { |
---|
| 1445 | ui->check_S->setChecked(true); |
---|
| 1446 | advanced = true; |
---|
| 1447 | } |
---|
| 1448 | else if ( parameter == "x") |
---|
| 1449 | { |
---|
| 1450 | ui->check_x->setChecked(true); |
---|
| 1451 | advanced = true; |
---|
| 1452 | } |
---|
| 1453 | else if ( parameter == "m") |
---|
| 1454 | { |
---|
| 1455 | ui->line_m->setText(options); |
---|
| 1456 | advanced = true; |
---|
| 1457 | } |
---|
| 1458 | else if ( parameter == "M") |
---|
| 1459 | { |
---|
| 1460 | ui->line_M->setText(options); |
---|
| 1461 | advanced = true; |
---|
| 1462 | } |
---|
| 1463 | else if ( parameter == "a") |
---|
| 1464 | { |
---|
| 1465 | ui->line_a->setText(options); |
---|
| 1466 | advanced = true; |
---|
| 1467 | } |
---|
| 1468 | else if ( parameter == "D") |
---|
| 1469 | { |
---|
| 1470 | ui->line_D->setText(options); |
---|
| 1471 | advanced = true; |
---|
| 1472 | } |
---|
| 1473 | else if ( parameter == "c") |
---|
| 1474 | { |
---|
| 1475 | ui->line_c->setText(options); |
---|
| 1476 | advanced = true; |
---|
| 1477 | } |
---|
| 1478 | else if ( parameter == "p") |
---|
| 1479 | { |
---|
| 1480 | ui->line_p->setText(options); |
---|
| 1481 | advanced = true; |
---|
| 1482 | } |
---|
| 1483 | else if ( parameter == "s") |
---|
| 1484 | { |
---|
| 1485 | ui->line_s->setText(options); |
---|
| 1486 | advanced = true; |
---|
| 1487 | } |
---|
| 1488 | else if ( parameter == "i") |
---|
| 1489 | { |
---|
| 1490 | ui->line_i->setText(options); |
---|
| 1491 | advanced = true; |
---|
| 1492 | rc_manual = true; |
---|
| 1493 | } |
---|
| 1494 | else if ( parameter == "o") |
---|
| 1495 | { |
---|
| 1496 | ui->line_o->setText(options); |
---|
| 1497 | advanced = true; |
---|
| 1498 | rc_manual = true; |
---|
| 1499 | } |
---|
| 1500 | else if ( parameter == "w") |
---|
| 1501 | { |
---|
| 1502 | ui->line_w->setText(options); |
---|
| 1503 | advanced = true; |
---|
| 1504 | } |
---|
| 1505 | |
---|
| 1506 | // Determine settings for coupled restart runs |
---|
| 1507 | else if ( parameter == "Y") |
---|
| 1508 | { |
---|
| 1509 | QStringList optionssplit = options.split(" ", \ |
---|
| 1510 | QString::SkipEmptyParts); |
---|
| 1511 | |
---|
| 1512 | ui->line_PE_atmos->setEnabled(true); |
---|
| 1513 | ui->line_PE_ocean->setEnabled(true); |
---|
| 1514 | ui->label_coupled1->setEnabled(true); |
---|
| 1515 | ui->label_coupled2->setEnabled(true); |
---|
| 1516 | ui->label_coupled3->setEnabled(true); |
---|
| 1517 | ui->label_coupling->setEnabled(true); |
---|
| 1518 | |
---|
| 1519 | if (optionssplit.count() == 2) |
---|
| 1520 | { |
---|
| 1521 | ui->line_PE_atmos->setText(optionssplit[0]); |
---|
| 1522 | ui->line_PE_ocean->setText(optionssplit[1]); |
---|
| 1523 | } |
---|
| 1524 | else |
---|
| 1525 | { |
---|
| 1526 | ui->line_PE_atmos->setText(""); |
---|
| 1527 | ui->line_PE_ocean->setText(""); |
---|
| 1528 | } |
---|
| 1529 | coupled_run = true; |
---|
| 1530 | } |
---|
| 1531 | else if ( parameter == "n") |
---|
| 1532 | { |
---|
| 1533 | if ( options == "shared") |
---|
| 1534 | { |
---|
| 1535 | ui->combo_n->setCurrentIndex(1); |
---|
| 1536 | } |
---|
| 1537 | else if ( options == "non_shared") |
---|
| 1538 | { |
---|
| 1539 | ui->combo_n->setCurrentIndex(2); |
---|
| 1540 | } |
---|
| 1541 | else |
---|
| 1542 | { |
---|
| 1543 | ui->combo_n->setCurrentIndex(0); |
---|
| 1544 | } |
---|
| 1545 | } |
---|
| 1546 | else if ( parameter == "y") |
---|
| 1547 | { |
---|
| 1548 | ui->drop_job->setCurrentIndex(3); |
---|
| 1549 | } |
---|
| 1550 | |
---|
| 1551 | // Determine settings for the run control list |
---|
| 1552 | else if ( parameter == "r") |
---|
| 1553 | { |
---|
| 1554 | QStringList optionssplit = options.split(" ", \ |
---|
| 1555 | QString::SkipEmptyParts); |
---|
| 1556 | |
---|
| 1557 | QString options_2; |
---|
| 1558 | QString options_all; |
---|
| 1559 | for (int j=0; j<optionssplit.count(); j++) |
---|
| 1560 | { |
---|
| 1561 | options_all = optionssplit[j]; |
---|
| 1562 | options_2 = optionssplit[j].left(2); |
---|
| 1563 | if (options_2 == "ts") |
---|
| 1564 | { |
---|
| 1565 | ui->check_ts->setChecked(true); |
---|
| 1566 | } |
---|
| 1567 | if (options_2 == "pr" && options_all.left(3) != "prt") |
---|
| 1568 | { |
---|
| 1569 | ui->check_pr->setChecked(true); |
---|
| 1570 | } |
---|
| 1571 | if (options_2 == "xy") |
---|
| 1572 | { |
---|
| 1573 | ui->check_xy->setChecked(true); |
---|
| 1574 | } |
---|
| 1575 | if (options_2 == "xz") |
---|
| 1576 | { |
---|
| 1577 | ui->check_xz->setChecked(true); |
---|
| 1578 | } |
---|
| 1579 | if (options_2 == "yz") |
---|
| 1580 | { |
---|
| 1581 | ui->check_yz->setChecked(true); |
---|
| 1582 | } |
---|
| 1583 | if (options_2 == "3d") |
---|
| 1584 | { |
---|
| 1585 | ui->check_3d->setChecked(true); |
---|
| 1586 | } |
---|
| 1587 | if (options_2 == "ma") |
---|
| 1588 | { |
---|
| 1589 | ui->check_ma->setChecked(true); |
---|
| 1590 | } |
---|
| 1591 | if (options_2 == "sp") |
---|
| 1592 | { |
---|
| 1593 | ui->check_sp->setChecked(true); |
---|
| 1594 | } |
---|
| 1595 | if (options_all.left(3) == "prt") |
---|
| 1596 | { |
---|
| 1597 | ui->check_prt->setChecked(true); |
---|
| 1598 | } |
---|
| 1599 | if (options_all.left(3) == "pts") |
---|
| 1600 | { |
---|
| 1601 | ui->check_pts->setChecked(true); |
---|
| 1602 | } |
---|
| 1603 | if (options_2 == "d3") |
---|
| 1604 | { |
---|
| 1605 | if (options_all.left(3).right(1) == "#") |
---|
| 1606 | { |
---|
| 1607 | ui->drop_job->setCurrentIndex(0); |
---|
| 1608 | } |
---|
| 1609 | else if (options_all.left(3).right(1) == "f") |
---|
| 1610 | { |
---|
| 1611 | ui->drop_job->setCurrentIndex(1); |
---|
| 1612 | } |
---|
| 1613 | else if (options_all.left(3).right(1) == "o") |
---|
| 1614 | { |
---|
| 1615 | ocean_run = true; |
---|
| 1616 | } |
---|
| 1617 | } |
---|
| 1618 | if (options_all == "restart") |
---|
| 1619 | { |
---|
| 1620 | ui->check_restarts->setChecked(true); |
---|
| 1621 | // Check if _pdf file is available, otherwise notice user |
---|
| 1622 | QString jobname = ui->line_jobname->text(); |
---|
| 1623 | branch = QCoreApplication::applicationDirPath(); |
---|
| 1624 | branch = branch.left(branch.length() - 14); |
---|
| 1625 | |
---|
| 1626 | QFile restartfile(branch+"/JOBS/"+jobname+"/INPUT/"+ \ |
---|
| 1627 | jobname+"_p3df"); |
---|
| 1628 | if (restartfile.exists() == true) |
---|
| 1629 | { |
---|
| 1630 | ui->label_restart->setText(""); |
---|
| 1631 | } |
---|
| 1632 | else |
---|
| 1633 | { |
---|
| 1634 | ui->label_restart->setText("Warning: No p3df file \ |
---|
| 1635 | found!"); |
---|
| 1636 | } |
---|
| 1637 | } |
---|
| 1638 | |
---|
| 1639 | } |
---|
| 1640 | |
---|
| 1641 | } |
---|
| 1642 | |
---|
| 1643 | // All unknown parameters are set as extra user parameters |
---|
| 1644 | else |
---|
| 1645 | { |
---|
| 1646 | user = user + "-" + parameter + " \"" + options + "\" "; |
---|
| 1647 | splitline.removeAt(i); |
---|
| 1648 | } |
---|
| 1649 | } |
---|
| 1650 | |
---|
| 1651 | // Change drop box state in case of ocean precursor or coupled restart runs |
---|
| 1652 | if ( ocean_run == true ) |
---|
| 1653 | { |
---|
| 1654 | if ( coupled_run == true ) |
---|
| 1655 | { |
---|
| 1656 | ui->drop_job->setCurrentIndex(4); |
---|
| 1657 | } |
---|
| 1658 | else |
---|
| 1659 | { |
---|
| 1660 | ui->drop_job->setCurrentIndex(3); |
---|
| 1661 | } |
---|
| 1662 | } |
---|
| 1663 | |
---|
| 1664 | if ( user != "") |
---|
| 1665 | { |
---|
| 1666 | ui->line_user->setText(user); |
---|
| 1667 | } |
---|
| 1668 | |
---|
| 1669 | // Join mrunline and post it to mainwindow |
---|
| 1670 | mrunline = splitline.join(" -"); |
---|
| 1671 | ui->commandline->setText(mrunline); |
---|
| 1672 | |
---|
| 1673 | // Check if advanced settings are used and enable advanced dialog |
---|
| 1674 | if ( advanced == true ) |
---|
| 1675 | { |
---|
| 1676 | ui->check_advanced->setChecked(true); |
---|
| 1677 | } |
---|
| 1678 | |
---|
| 1679 | // Disable mainwindow if no job was found, otherwise enable |
---|
| 1680 | if ( nojob == true ) |
---|
| 1681 | { |
---|
| 1682 | ui->group_execution->setEnabled(false); |
---|
| 1683 | ui->group_runcontrol->setEnabled(false); |
---|
| 1684 | ui->button_start->setEnabled(false); |
---|
| 1685 | ui->action_save->setEnabled(false); |
---|
| 1686 | ui->drop_job->setEnabled(false); |
---|
| 1687 | ui->group_advanced->setEnabled(false); |
---|
| 1688 | ui->check_advanced->setEnabled(false); |
---|
| 1689 | } |
---|
| 1690 | else |
---|
| 1691 | { |
---|
| 1692 | ui->group_execution->setEnabled(true); |
---|
| 1693 | ui->group_runcontrol->setEnabled(true); |
---|
| 1694 | ui->button_start->setEnabled(true); |
---|
| 1695 | ui->action_save->setEnabled(true); |
---|
| 1696 | ui->check_advanced->setEnabled(true); |
---|
| 1697 | ui->drop_job->setEnabled(true); |
---|
| 1698 | if ( advanced == true ) |
---|
| 1699 | { |
---|
| 1700 | ui->group_advanced->setEnabled(true); |
---|
| 1701 | } |
---|
| 1702 | else |
---|
| 1703 | { |
---|
| 1704 | ui->group_advanced->setEnabled(false); |
---|
| 1705 | } |
---|
| 1706 | } |
---|
| 1707 | |
---|
| 1708 | // Disable run control box, if manual settings of -i and -o are used |
---|
| 1709 | if ( rc_manual == true ) |
---|
| 1710 | { |
---|
| 1711 | ui->group_runcontrol->setEnabled(false); |
---|
| 1712 | change_commandline("r","remove"); |
---|
| 1713 | ui->button_start->setEnabled(true); |
---|
| 1714 | ui->action_save->setEnabled(true); |
---|
| 1715 | } |
---|
| 1716 | |
---|
| 1717 | } |
---|
| 1718 | |
---|
| 1719 | return 0; |
---|
| 1720 | } |
---|