Skip to content

Commit

Permalink
Another checkpoint with the new LP gui. Now you can browse the snapsh…
Browse files Browse the repository at this point in the history
…ots and cycle between them easily.
  • Loading branch information
Ken Moore committed Oct 11, 2013
1 parent e24c61d commit b05f511
Show file tree
Hide file tree
Showing 69 changed files with 29,068 additions and 104 deletions.
54 changes: 38 additions & 16 deletions lp-gui/LPMain.cpp
Expand Up @@ -6,19 +6,24 @@ LPMain::LPMain(QWidget *parent) : QMainWindow(parent), ui(new Ui::LPMain){
//Create the basic/advanced view options
viewBasic = new QRadioButton(tr("Basic"), ui->menuView);
QWidgetAction *WABasic = new QWidgetAction(this); WABasic->setDefaultWidget(viewBasic);
ui->menuView->addAction(WABasic);
viewAdvanced = new QRadioButton(tr("Advanced"), ui->menuView);
QWidgetAction *WAAdv = new QWidgetAction(this); WAAdv->setDefaultWidget(viewAdvanced);

ui->menuView->addAction(WABasic);
ui->menuView->addAction(WAAdv);
ui->menuView->addAction(WAAdv);
connect(viewBasic, SIGNAL(toggled(bool)), this, SLOT(viewChanged()) );
//Now set the default view type
viewBasic->setChecked(true); //will automatically call the "viewChanged" function

//Create the filesystem model and tie it to the treewidget
fsModel = new QFileSystemModel(this);
fsModel->setReadOnly(true);
ui->treeView->setModel(fsModel);
//Connect the UI to all the functions
connect(ui->combo_pools, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTabs()) );
connect(ui->combo_datasets, SIGNAL(currentIndexChanged(int)), this, SLOT(updateDataset()) );
connect(ui->slider_snapshots, SIGNAL(valueChanged(int)), this, SLOT(updateSnapshot()) );
connect(ui->push_prevsnap, SIGNAL(clicked()), this, SLOT(prevSnapshot()) );
connect(ui->push_nextsnap, SIGNAL(clicked()), this, SLOT(nextSnapshot()) );
connect(ui->push_restore, SIGNAL(clicked()), this, SLOT(restoreFiles()) );
//Update the interface
updatePoolList();
//Make sure the status tab is shown initially
Expand Down Expand Up @@ -46,6 +51,7 @@ void LPMain::slotSingleInstance(){
// ==============
void LPMain::updatePoolList(){
//Get the currently selected pool (if there is one)
qDebug() << "Update Pool List";
QString cPool;
if(ui->combo_pools->currentIndex() != -1){ cPool = ui->combo_pools->currentText(); }
//Get the list of managed pools
Expand All @@ -55,15 +61,15 @@ void LPMain::updatePoolList(){
if(!pools.isEmpty()){ ui->combo_pools->addItems(pools); }
//Now set the currently selected pools
if(pools.length() > 0){
poolSelected=true;
int index = pools.indexOf(cPool);
if(index < 0){ ui->combo_pools->setCurrentIndex(0); }
else{ ui->combo_pools->setCurrentIndex(index); }
poolSelected=true;
}else{
//No managed pools
poolSelected=false;
ui->combo_pools->addItem("No Managed Pools!");
ui->combo_pools->setCurrentIndex(0);
poolSelected=false;
}
//Now update the interface appropriately
ui->combo_pools->setEnabled(poolSelected);
Expand All @@ -84,6 +90,7 @@ void LPMain::viewChanged(){
}

void LPMain::updateTabs(){
qDebug() << "Update Tabs" << poolSelected;
viewChanged();
ui->tabWidget->setEnabled(poolSelected);
ui->menuView->setEnabled(poolSelected);
Expand Down Expand Up @@ -116,7 +123,6 @@ void LPMain::updateTabs(){
QString cds = ui->combo_datasets->currentText();
ui->combo_datasets->clear();
QStringList dslist = POOLDATA.subsets();
qDebug() << "Datasets:" << dslist;
ui->combo_datasets->addItems(dslist);
int dsin = dslist.indexOf(cds);
if(dsin >= 0){ ui->combo_datasets->setCurrentIndex(dsin); }
Expand All @@ -142,7 +148,7 @@ void LPMain::updateDataset(){
QString cds = ui->combo_datasets->currentText();
if(POOLDATA.subsets().indexOf(cds) >= 0){
QStringList snaps = POOLDATA.snapshots(cds);
qDebug() << "dataset:" << cds << "snapshots:" << snaps;
qDebug() << "Update Dataset";
ui->slider_snapshots->setEnabled(true);
ui->slider_snapshots->setMinimum(0);
int max = snaps.length() -1;
Expand All @@ -153,27 +159,43 @@ void LPMain::updateDataset(){
}else{
ui->slider_snapshots->setEnabled(false);
ui->label_snapshot->clear();
ui->tool_nextsnap->setEnabled(false);
ui->tool_prevsnap->setEnabled(false);
ui->push_nextsnap->setEnabled(false);
ui->push_prevsnap->setEnabled(false);
}

}

void LPMain::updateSnapshot(){
int sval = ui->slider_snapshots->value();
QStringList snaps = POOLDATA.snapshots(ui->combo_datasets->currentText());
qDebug() << "Snapshots:" << snaps;
qDebug() << "Update Snapshot";
//Update the previous/next buttons
if(sval == ui->slider_snapshots->minimum() ){ ui->tool_prevsnap->setEnabled(false); }
else{ ui->tool_prevsnap->setEnabled(true); }
if(sval == ui->slider_snapshots->maximum() ){ ui->tool_nextsnap->setEnabled(false); }
else{ ui->tool_nextsnap->setEnabled(true); }
if(sval == ui->slider_snapshots->minimum() ){ ui->push_prevsnap->setEnabled(false); }
else{ ui->push_prevsnap->setEnabled(true); }
if(sval == ui->slider_snapshots->maximum() ){ ui->push_nextsnap->setEnabled(false); }
else{ ui->push_nextsnap->setEnabled(true); }
//Now update the snapshot viewer
if(snaps.isEmpty()){ ui->label_snapshot->clear(); ui->slider_snapshots->setEnabled(false); }
else{
QString snap = snaps.at(sval);
QString path = ui->combo_datasets->currentText() + "/.zfs/snapshot/"+snap;
//qDebug() << "Snapshot path:" << path;
ui->label_snapshot->setText(snap);
//Now update the snapshot view
qDebug() << "Snapshot viewer not implemented yet";
ui->treeView->setRootIndex( fsModel->setRootPath(path) );

}
}

void LPMain::nextSnapshot(){
ui->slider_snapshots->setValue( ui->slider_snapshots->value()+1 );
}

void LPMain::prevSnapshot(){
ui->slider_snapshots->setValue( ui->slider_snapshots->value()-1 );
}

void LPMain::restoreFiles(){
qDebug() << "Restore file(s)";

}
5 changes: 5 additions & 0 deletions lp-gui/LPMain.h
Expand Up @@ -9,6 +9,7 @@
#include <QStringList>
#include <QRadioButton>
#include <QWidgetAction>
#include <QFileSystemModel>

#include "LPBackend.h"
#include "LPContainers.h"
Expand All @@ -30,6 +31,7 @@ public slots:
private:
Ui::LPMain *ui;
QRadioButton *viewBasic, *viewAdvanced;
QFileSystemModel *fsModel;
bool poolSelected;
LPDataset POOLDATA;

Expand All @@ -39,6 +41,9 @@ private slots:
void updateTabs(); //load current pool info and update tabs
void updateDataset(); //restore dataset changed
void updateSnapshot(); //selected snapshot changed
void nextSnapshot();
void prevSnapshot();
void restoreFiles();

protected:

Expand Down

0 comments on commit b05f511

Please sign in to comment.