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