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

releng/10.0.1releng/10.0.2
Last change on this file since 194a5d3 was 194a5d3, checked in by Ken Moore <ken@…>, 6 months ago

Finish updating the main Life preserver GUI to reflect the new scheduling options in lpreserver.

  • Property mode set to 100644
File size: 3.6 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    int remoteTime = ui->combo_remote_freq->currentIndex();
29    if(remoteTime==0){ remoteTime = -999; } //Sync
30    else if(remoteTime==1){ remoteTime =  ui->time_replicate->time().hour(); } //Daily @
31    else if(remoteTime==2){ remoteTime = -60; } //hourly
32    else if(remoteTime==3){ remoteTime = -30; } //30min
33    else{ remoteTime = -10; } //10min
34    remoteHost = ui->lineHostName->text();
35    remoteUser = ui->lineUserName->text();
36    remoteDataset = ui->lineRemoteDataset->text();
37    //Prompt for the SSH key generation
38    LPBackend::setupSSHKey(remoteHost, remoteUser, remotePort);
39  }
40  if(ui->radio_automatic->isChecked()){ localTime = -999; }
41  if(ui->radioDaily->isChecked()){ localTime = ui->timeEdit->time().hour(); }
42  else if( ui->radio10Min->isChecked()){ localTime = -10; }
43  else if( ui->radio30Min->isChecked()){ localTime = -30; }
44  else if( ui->radio5Min->isChecked()){ localTime = -5; }
45  else{ localTime = -60; } //hourly
46  if( ui->radioKeepTotal->isChecked() ){
47    totalSnapshots = ui->spin_keepTotal->value();
48  }else{
49    if(localTime >0){ totalSnapshots = ui->spin_keepDays->value(); }
50    else{ totalSnapshots = ui->spin_keepDays->value() * (1440/(-localTime)); } //convert to number of snapshots a day
51  }
52
53  //Now close the UI
54  this->close();
55}
56
57void LPWizard::slotCancelled(){
58  qDebug() << "Wizard Cancelled";
59  cancelled = true; //just to make sure
60  this->close();
61}
62
63void LPWizard::scanNetwork(){
64  QStringList targs = LPGUtils::scanNetworkSSH(); // <name>:::<address>:::<port>
65  if(targs.isEmpty()){
66    QMessageBox::warning(this,tr("No Network Targets"), tr("We could not find any systems on the local network with SSH availability (port 22)") );
67    return;
68  }
69  //Ask the user to select a target
70  QStringList targets;
71  for(int i=0; i<targs.length(); i++){
72    targets << targs[i].section(":::",0,0);
73  }
74  bool ok;
75  QString target = QInputDialog::getItem(this, tr("Select Replication Target"), tr("Hostname:"), targets, 0, false, &ok);
76  if(!ok || target.isEmpty() ){ return; } //cancelled
77  //Now look for that target in the list of info
78  for(int i=0; i<targs.length(); i++){
79    if(targs[i].startsWith(target+":::")){
80      ui->lineHostName->setText(targs[i].section(":::",1,1));
81      ui->spinPort->setValue( targs[i].section(":::",2,2).toInt() );
82      break;
83    }
84  }
85}
86
87void LPWizard::on_combo_remote_freq_itemChanged(int index){
88  //Adjust the visibility of the replication time selector
89  ui->time_replicate->setVisible( (index == 1) );
90}
91
92int LPWizard::nextId() const{
93        int cpg = currentId();
94        if(cpg == 1 && ui->radio_automatic->isChecked() ){
95          //Automatic snapshot schedule - skip the snapshot pruning page (not needed)
96          return 3;
97        }else if(cpg==4){ //last page
98          return -1;
99        }else{
100          return (cpg+1); //go to the next page
101        }
102}
Note: See TracBrowser for help on using the repository browser.