Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add more work to the new UI for life-preserver

  • Loading branch information...
commit 4d597a9a84fad640781268aa2292175468c8851c 1 parent 77c0221
@beanpole135 beanpole135 authored
View
17 src-qt4/life-preserver/LPGUtils.h
@@ -0,0 +1,17 @@
+#ifndef _LP_GUTILS_H
+#define _LP_GUTILS_H
+
+#include <QMessageBox>
+#include <QDialog>
+#include <QStringList>
+#include <QString>
+
+#include "LPBackend.h"
+#include "LPContainers.h"
+
+class LPGUtils{
+public:
+
+}
+
+#endif
View
152 src-qt4/life-preserver/LPMain.cpp
@@ -0,0 +1,152 @@
+#include "LPMain.h"
+
+LPMain::LPMain(QWidget *parent) : QMainWindow(parent), ui(new Ui::LPMain){
+ ui->setupUi(); //load the Qt-designer UI file
+ //Create the basic/advanced view options
+ viewBasic = new QRadioButton(tr("Basic"), ui->menuView);
+ viewAdvanced = new QRadioButton(tr("Advanced"), ui->menuView);
+ ui->menuView->addWidget(viewBasic);
+ ui->menuView->addWidget(viewAdvanced);
+ connect(viewBasic, SIGNAL(toggled()), this, SLOT(viewChanged()) );
+ //Now set the default view type
+ viewBasic->setChecked(true); //will automatically call the "viewChanged" function
+
+ //Connect the UI to all the functions
+
+}
+
+LPMain::~LPMain(){
+
+}
+
+// ==============
+// PUBLIC SLOTS
+// ==============
+void LPMain::updateUI(){
+ //Get the currently selected pool (if there is one)
+ QString cPool;
+ if(ui->combo_pools->currentIndex != -1){ cPool = ui->combo_pools_currentText(); }
+ //Get the list of managed pools
+ QStringList pools = LPBackend::listDatasets();
+ //Now put that list into the UI
+ ui->combo_pools->clear();
+ for(int i=0; i<pools.length(); i++){
+
+ }
+ //Now set the currently selected pools
+ if(pools.length() > 0){
+ 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
+ ui->combo_pools->addItem("No Managed Pools!");
+ ui->combo_pools->setCurrentIndex(0);
+ poolSelected=false;
+ }
+ //Now update the interface appropriately
+ updateInterface();
+}
+
+// ==============
+// PRIVATE
+// ==============
+LPDataset LPMain::loadPoolData(QString pool){
+ //Load the current information for the given zpool
+ qDebug() << "New Dataset: " << ds;
+ LPDataset DSC;
+ //List all the mountpoints in this dataset
+ QStringList subsets = LPBackend::listDatasetSubsets(ds);
+ QStringList lpsnaps = LPBackend::listLPSnapshots(ds);
+ //populate the list of snapshots available for each mountpoint
+ for(int i=0; i<subsets.length(); i++){
+ //qDebug() << "Subset:" << subsets[i];
+ QStringList snaps = LPBackend::listSnapshots(subsets[i]);
+ //qDebug() << " - Snapshots:" << snaps;
+ if(snaps.isEmpty()){
+ //invalid subset - remove it from the list
+ subsets.removeAt(i);
+ i--;
+ }else{
+ QStringList subsnaps;
+ //only list the valid snapshots that life preserver created
+ for(int s=0; s<lpsnaps.length(); s++){
+ int index = snaps.indexOf(lpsnaps[s]);
+ if(index > -1){ subsnaps << lpsnaps[s]; snaps.removeAt(index); }
+ }
+ //Now list all the other available snapshots (no certain ordering)
+ if(!snaps.isEmpty()){
+ subsnaps << "--"; //so we know that this is a divider between the sections
+ subsnaps << snaps;
+ }
+ DSC.subsetHash.insert(subsets[i],subsnaps); //add it to the internal container hash
+ }
+ }
+ //Get the time for the latest life-preserver snapshot (and total number)
+ //Find the index for the current list
+ int ci = 0;
+ while(ci < CLIST.length()){
+ if(CLIST[ci].startsWith(ds+":::")){ break; }
+ else{ ci++; }
+ }
+ if(CLIST.isEmpty()){ ci = -1; } //catch for empty list
+ if(DSC.subsetHash.size() < 1){
+ DSC.numberOfSnapshots = "0";
+ DSC.latestSnapshot= "";
+ }else{
+ DSC.numberOfSnapshots = QString::number(lpsnaps.length());
+ if(lpsnaps.isEmpty()){ DSC.latestSnapshot=""; }
+ else if(ci > -1 && ci < CLIST.length()){
+ QString sna = CLIST[ci].section(":::",1,1);
+ if(sna != "-"){ DSC.latestSnapshot= sna; }
+ else{ DSC.latestSnapshot = ""; }
+ }else{ DSC.latestSnapshot=lpsnaps[0]; }
+ }
+ //List the replication status
+ if(RLIST.contains(ds) && (ci > -1)){
+ QString rep = CLIST[ci].section(":::",2,2);
+ if(rep != "-"){ DSC.latestReplication = rep; }
+ else{ DSC.latestReplication= tr("Enabled"); }
+ }else{
+ DSC.latestReplication= tr("Disabled");
+ }
+ //Return the dataset
+ return DSC;
+}
+
+
+// ==============
+// PRIVATE SLOTS
+// ==============
+void LPMain::viewChanged(){
+ if(viewBasic->isChecked()){
+ ui->menuDisks->setVisible(false);
+ ui->menuSnapshots->setVisible(false);
+ }else{
+ ui->menuDisks->setVisible(true);
+ ui->menuSnapshots->setVisible(true);
+ }
+}
+
+void updateInterface(){
+ viewChanged();
+ ui->tabWidget->setEnabled(poolSelected);
+ ui->menuView->setVisible(poolSelected);
+ ui->tool_configure->setVisible(poolSelected);
+ ui->tool_configBackups->setVisible(poolSelected);
+ ui->actionUnmanage_Pool->setEnabled(poolSelected);
+ ui->action_SaveKeyToUSB->setEnabled(poolSelected);
+ if(poolSelected){
+ POOLDATA = loadPoolData(ui->combo_pools->currentText());
+ //Now list the status information
+
+ //Now list the data restore options
+ QStringList
+ }else{
+ //No Pool selected
+ ui->menuDisks->setVisible(false); //make sure this is always invisible if nothing selected
+ ui->menuSnapshots->setVisible(false); //make sure this is always invisible if nothing selected
+ }
+
+}
View
21 src-qt4/life-preserver/LPMain.h
@@ -7,18 +7,35 @@
#include <QLabel>
#include <QString>
#include <QStringList>
+#include <QRadioButton>
-namespace UI{
+#include "LPBackend.h"
+#include "LPContainers.h"
+
+namespace Ui{
class LPMain;
};
class LPMain : public QMainWindow{
Q_OBJECT
public:
+ LPMain(QWidget *parent = 0);
+ ~LPMain();
+public slots:
+ void setupUI();
+
private:
-
+ Ui::LPMain *ui;
+ QRadioButton *viewBasic, *viewAdvanced;
+ bool poolSelected;
+ LPDataset POOLDATA;
+
+ void updateInterface(); //update interface based on selected pool
+ LPDataset loadPoolData(QString pool);
+
private slots:
+ void viewChanged();
protected:
View
22 src-qt4/life-preserver/LPMain.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>380</width>
- <height>231</height>
+ <height>235</height>
</rect>
</property>
<property name="windowTitle">
@@ -33,7 +33,7 @@
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
- <enum>QSizePolicy::Minimum</enum>
+ <enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -45,6 +45,9 @@
</item>
<item>
<widget class="QToolButton" name="tool_configure">
+ <property name="statusTip">
+ <string>Configure the local snapshot policies</string>
+ </property>
<property name="text">
<string>Configure</string>
</property>
@@ -56,6 +59,9 @@
</item>
<item>
<widget class="QToolButton" name="tool_configBackups">
+ <property name="statusTip">
+ <string>Configure additional data safety procedures</string>
+ </property>
<property name="text">
<string>...</string>
</property>
@@ -259,7 +265,7 @@
<addaction name="actionManage_Pool"/>
<addaction name="actionUnmanage_Pool"/>
<addaction name="separator"/>
- <addaction name="actionSave_Key_to_USB_2"/>
+ <addaction name="action_SaveKeyToUSB"/>
<addaction name="separator"/>
<addaction name="actionClose_WIndow"/>
</widget>
@@ -283,8 +289,8 @@
<property name="title">
<string>Snapshots</string>
</property>
- <addaction name="actionNew_Snapshot_2"/>
- <addaction name="actionDelete_Snapshot"/>
+ <addaction name="action_newSnapshot"/>
+ <addaction name="action_rmSnapshot"/>
</widget>
<addaction name="menuFile"/>
<addaction name="menuView"/>
@@ -376,7 +382,7 @@
<string>New Snapshot</string>
</property>
</action>
- <action name="actionNew_Snapshot_2">
+ <action name="action_newSnapshot">
<property name="icon">
<iconset resource="lPreserve.qrc">
<normaloff>:/images/camera_add.png</normaloff>:/images/camera_add.png</iconset>
@@ -385,7 +391,7 @@
<string>New Snapshot</string>
</property>
</action>
- <action name="actionDelete_Snapshot">
+ <action name="action_rmSnapshot">
<property name="icon">
<iconset resource="lPreserve.qrc">
<normaloff>:/images/list-remove.png</normaloff>:/images/list-remove.png</iconset>
@@ -394,7 +400,7 @@
<string>Delete Snapshot</string>
</property>
</action>
- <action name="actionSave_Key_to_USB_2">
+ <action name="action_SaveKeyToUSB">
<property name="icon">
<iconset resource="lPreserve.qrc">
<normaloff>:/images/key.png</normaloff>:/images/key.png</iconset>
Please sign in to comment.
Something went wrong with that request. Please try again.