source: src-qt4/life-preserver/lp-gui/LPWizard.cpp @ f15ae5d

9.2-releasereleng/10.0releng/10.0.1releng/10.0.2
Last change on this file since f15ae5d was f15ae5d, checked in by Ken Moore <ken@…>, 9 months ago

Add the network scan button to the LpWizard? as well.

  • Property mode set to 100644
File size: 2.8 KB
Line 
1#include "LPWizard.h"
2#include "ui_LPWizard.h"
3
4LPWizard::LPWizard(QWidget *parent) : QWizard(parent), ui(new Ui::LPWizard){
5  //Initialize the graphical items
6  ui->setupUi(this);  //load the mainUI.ui file
7  cancelled = true; //Make sure this is always set by default
8  connect(this,SIGNAL(accepted()), this,SLOT(slotFinished()) );
9  connect(this,SIGNAL(rejected()),this,SLOT(slotCancelled()) );
10  connect(ui->push_scanNetwork, SIGNAL(clicked()), this, SLOT(scanNetwork()) );
11}
12
13LPWizard::~LPWizard(){
14       
15}
16
17void LPWizard::setDataset(QString ds){
18  ui->label_dataset->setText(ds);
19}
20       
21void LPWizard::slotFinished(){
22  qDebug() << "Wizard Finished";
23  cancelled = false; //use the values from the UI
24  //Now load the information from the UI
25  enableReplication = ui->groupReplicate->isChecked();
26  if(enableReplication){
27    remotePort = ui->spinPort->value();
28    if(ui->radioSYNC->isChecked()){ 
29      remoteTime = -1;
30    }else{
31      remoteTime = ui->time_replicate->time().hour();
32    }
33    remoteHost = ui->lineHostName->text();
34    remoteUser = ui->lineUserName->text();
35    remoteDataset = ui->lineRemoteDataset->text();
36    //Prompt for the SSH key generation
37    LPBackend::setupSSHKey(remoteHost, remoteUser, remotePort);
38  }
39  if(ui->radioDaily->isChecked()){ localTime = ui->timeEdit->time().hour(); }
40  else if( ui->radio10Min->isChecked()){ localTime = -10; }
41  else if( ui->radio30Min->isChecked()){ localTime = -30; }
42  else if( ui->radio5Min->isChecked()){ localTime = -5; }
43  else{ localTime = -60; } //hourly
44  if( ui->radioKeepTotal->isChecked() ){
45    totalSnapshots = ui->spin_keepTotal->value();
46  }else{
47    if(localTime >0){ totalSnapshots = ui->spin_keepDays->value(); }
48    else{ totalSnapshots = ui->spin_keepDays->value() * (1440/(-localTime)); } //convert to number of snapshots a day
49  }
50
51  //Now close the UI
52  this->close();
53}
54
55void LPWizard::slotCancelled(){
56  qDebug() << "Wizard Cancelled";
57  cancelled = true; //just to make sure
58  this->close();
59}
60
61void LPWizard::scanNetwork(){
62  QStringList targs = LPGUtils::scanNetworkSSH(); // <name>:::<address>:::<port>
63  if(targs.isEmpty()){
64    QMessageBox::warning(this,tr("No Network Targets"), tr("We could not find any systems on the local network with SSH availability (port 22)") );
65    return;
66  }
67  //Ask the user to select a target
68  QStringList targets;
69  for(int i=0; i<targs.length(); i++){
70    targets << targs[i].section(":::",0,0);
71  }
72  bool ok;
73  QString target = QInputDialog::getItem(this, tr("Select Replication Target"), tr("Hostname:"), targets, 0, false, &ok);
74  if(!ok || target.isEmpty() ){ return; } //cancelled
75  //Now look for that target in the list of info
76  for(int i=0; i<targs.length(); i++){
77    if(targs[i].startsWith(target+":::")){
78      ui->lineHostName->setText(targs[i].section(":::",1,1));
79      ui->spinPort->setValue( targs[i].section(":::",2,2).toInt() );
80      break;
81    }
82  }
83}
Note: See TracBrowser for help on using the repository browser.