source: src-qt4/pc-sysmanager/cmdDialog.cpp @ a2d9be0

releng/10.0releng/10.0.1releng/10.0.2releng/10.0.3releng/10.1releng/10.1.1
Last change on this file since a2d9be0 was a2d9be0, checked in by Ken Moore <ken@…>, 15 months ago

Get pc-sysmanager compiling successfully again

  • Property mode set to 100644
File size: 3.9 KB
Line 
1#include "cmdDialog.h"
2#include "ui_cmdDialog.h"
3
4CMDDialog::CMDDialog(QWidget *parent) : QDialog(parent), ui(new Ui::CMDDialog){
5  ui->setupUi(this); //load the designer UI file
6  //Setup the backend process class
7  PROC = new gitProc;
8    connect(PROC, SIGNAL(ProcMessage(QString)), this, SLOT(NewMessage(QString)) );
9    connect(PROC, SIGNAL(procFinished(bool)), this, SLOT(Finished(bool)) );
10  //Setup internal flags
11  initPorts = false; initSource = false; //make sure these are both initially disabled
12  connect(ui->push_close, SIGNAL(clicked()), this, SLOT(CloseUI()) );   
13}
14
15CMDDialog::~CMDDialog(){
16  delete PROC; 
17}
18
19void CMDDialog::start(QString cmdtype){
20  if(PROC->isRunning()){
21    qDebug() << "ERROR: Process is already working: please wait until it is finished";
22    return;
23  }
24  ui->push_close->setEnabled(false); //make sure they cannot close this while it is running
25  if(cmdtype.toLower() == "ports"){
26    //Check for if the port tree needs to be initialized first
27    qDebug() << "WARNING: Ports init check still needs to be implemented";
28    bool init = true;
29    if(init){
30      initPorts = true; //set the internal flag
31      ui->textEdit->setPlainText("Starting Ports Tree Initialization....");
32      bool ok = PROC->startInitPorts();
33      if(!ok){ 
34        ui->textEdit->appendPlainText("\nERROR: Could not clean and git init /usr/ports");
35        ui->push_close->setEnabled(true); //they can now close the window
36      }
37    }else{
38      ui->textEdit->setPlainText("Fetching the Ports Tree....");
39      bool ok = PROC->startPorts();
40      if(!ok){ 
41        ui->textEdit->appendPlainText("\nERROR: Could not setup git fetch within /usr/ports");
42        ui->push_close->setEnabled(true); //they can now close the window
43      }
44    }
45  }else if(cmdtype.toLower() == "source"){
46    //Check for if the source tree needs to be initialized first
47    qDebug() << "WARNING: Source init check still needs to be implemented";
48    bool init = true;
49    if(init){
50      initSource = true; //set the internal flag
51      ui->textEdit->setPlainText("Starting Source Tree Initialization....");
52      bool ok = PROC->startInitSource();
53      if(!ok){ 
54        ui->textEdit->appendPlainText("\nERROR: Could not clean and git init /usr/src");
55        ui->push_close->setEnabled(true); //they can now close the window
56      }
57    }else{
58      ui->textEdit->setPlainText("Fetching the Source Tree....");
59      bool ok = PROC->startSource();
60      if(!ok){ 
61        ui->textEdit->appendPlainText("\nERROR: Could not setup git fetch within /usr/src");
62        ui->push_close->setEnabled(true); //they can now close the window
63      }
64    }
65  }else{
66    ui->textEdit->setPlainText("Unknown CMD Type: "+cmdtype);
67    ui->push_close->setEnabled(true);
68  }
69}
70
71// =====================
72void CMDDialog::NewMessage(QString msg){
73  ui->textEdit->appendPlainText("\n"+msg); //make sure it is on the next line each time
74}
75
76void CMDDialog::Finished(bool ok){
77  if(!ok){
78    ui->textEdit->appendPlainText("\n=============\nProcess Completed Unsuccessfully");
79    ui->push_close->setEnabled(true); //enabled the close button
80  }else if(initPorts){
81    //ports tree initialized successfully - start the fetch process
82    ui->textEdit->appendPlainText("\n=============\nFetching the Ports Tree....");
83    bool ok = PROC->startPorts();
84    if(!ok){ 
85      ui->textEdit->appendPlainText("\nERROR: Could not setup git fetch within /usr/ports");
86      ui->push_close->setEnabled(true); //they can now close the window
87    }
88  }else if(initSource){
89    //Source tree initialized successfully - start the fetch process
90    ui->textEdit->appendPlainText("\n=============\nFetching the Source Tree....");
91    bool ok = PROC->startPorts();
92    if(!ok){ 
93      ui->textEdit->appendPlainText("\nERROR: Could not setup git fetch within /usr/src");
94      ui->push_close->setEnabled(true); //they can now close the window
95    }
96  }else{
97    ui->textEdit->appendPlainText("\n=============\nFinished Successfully");
98  }
99}
100
101void CMDDialog::CloseUI(){
102  this->close();
103}
Note: See TracBrowser for help on using the repository browser.