source: src-qt4/pc-zmanager/dialogfscreate.cpp @ 125dbc9

9.2-releasereleng/10.0releng/10.0.1
Last change on this file since 125dbc9 was 125dbc9, checked in by Kris Moore <kris@…>, 6 months ago

Welcome the new 'pc-zmanager' for ZFS & Disk Management

A HUGE Thank You to: Claudio L <claudio@…>

Update pkg-plist and add it to the control panel

  • Property mode set to 100644
File size: 4.1 KB
Line 
1#include "dialogfscreate.h"
2#include "ui_dialogfscreate.h"
3#include <QLineEdit>
4
5DialogfsCreate::DialogfsCreate(QWidget *parent) :
6    QDialog(parent),
7    ui(new Ui::DialogfsCreate)
8{
9    ui->setupUi(this);
10
11
12    ui->fsName->setFocus();
13
14}
15
16DialogfsCreate::~DialogfsCreate()
17{
18    delete ui;
19}
20
21void DialogfsCreate::setRootPath(QString path,QString text)
22{
23    this->fsRoot=path;
24    if(text.isEmpty()) ui->fsName->setText(fsRoot);
25    else ui->fsName->setText(text);
26    checkValidPath();
27
28}
29
30
31void DialogfsCreate::on_fsName_textEdited(const QString &arg1)
32{
33
34    if(arg1.startsWith(fsRoot)) { checkValidPath(); return; }
35    else {
36        if(arg1==fsRoot.left(fsRoot.size()-1)) ui->fsName->setText(fsRoot);
37        else ui->fsName->setText(fsRoot+arg1);
38        checkValidPath();
39    }
40return;
41}
42
43void DialogfsCreate::on_checkMountpt_stateChanged(int arg1)
44{
45    if(arg1) {
46        ui->comboMountpt->setEnabled(true);
47        if(ui->comboMountpt->currentText()==tr("[path]")) ui->mountPtEdit->setEnabled(true);
48        else ui->mountPtEdit->setEnabled(false);
49    }
50    else {
51        ui->comboMountpt->setEnabled(false);
52        ui->mountPtEdit->setEnabled(false);
53    }
54}
55
56void DialogfsCreate::on_comboMountpt_currentIndexChanged(int index)
57{
58    Q_UNUSED(index);
59
60    if(ui->comboMountpt->currentText()==tr("[path]")) ui->mountPtEdit->setEnabled(true);
61    else ui->mountPtEdit->setEnabled(false);
62
63}
64
65void DialogfsCreate::on_checkNormalization_stateChanged(int arg1)
66{
67    ui->comboNormalization->setEnabled(arg1);
68}
69
70void DialogfsCreate::on_checkCopies_stateChanged(int arg1)
71{
72    ui->spinCopies->setEnabled(arg1);
73}
74
75
76void DialogfsCreate::on_checkCompression_stateChanged(int arg1)
77{
78    ui->comboCompression->setEnabled(arg1);
79}
80
81
82QString DialogfsCreate::getPath()
83{
84    return ui->fsName->text();
85}
86
87QStringList DialogfsCreate::getOptions()
88{
89    QStringList opt;
90
91    if(ui->checkCanMount->checkState()==Qt::Checked) opt.append("canmount=noauto");
92    if(ui->checkMountpt->checkState()==Qt::Checked) {
93        QString tmp;
94        tmp="mountpoint=";
95        if(ui->comboMountpt->currentText()=="[path]") tmp+="\""+ui->mountPtEdit->text()+"\"";
96        else tmp+=ui->comboMountpt->currentText();
97        opt.append(tmp);
98    }
99    if(ui->checkUtf8Only->checkState()==Qt::Checked) opt.append("utf8only=on");
100
101    if(ui->checkNormalization->checkState()==Qt::Checked) {
102        opt.append("normalization="+ui->comboNormalization->currentText());
103    }
104
105
106    if(ui->checkDedup->checkState()==Qt::Checked) opt.append("dedup=on");
107
108    if(ui->checkCompression->checkState()==Qt::Checked) opt.append("compression="+ui->comboCompression->currentText());
109
110
111    return opt;
112}
113
114void DialogfsCreate::checkValidPath()
115{
116    isValid=true;
117    QString str=ui->fsName->text();
118
119    if(str==fsRoot) isValid=false;
120    if(str.size()<=fsRoot.size()) isValid=false;
121    if(str.size()>255) isValid=false;
122
123    int f;
124
125    for(f=fsRoot.size();f<str.size();++f)
126    {
127        // CHECK FOR VALID CHARACTERS (EXCLUDING THE GIVEN ROOT
128        if((str.at(f)>=QChar('0')) && (str.at(f)<=QChar('9'))) continue;
129        if((str.at(f)>=QChar('a')) && (str.at(f)<=QChar('z'))) continue;
130        if((str.at(f)>=QChar('A')) && (str.at(f)<=QChar('Z'))) continue;
131        if(str.at(f)==QChar(' ')) continue;
132        if(str.at(f)==QChar('-')) continue;
133        if(str.at(f)==QChar('_')) continue;
134        if(str.at(f)==QChar(':')) continue;
135        // '@' SHOULD BE INCLUDED IN THE ROOT, SO IT'S NOT ALLOWED HERE
136        // '/' IS NOT ALLOWED
137        isValid=false;
138        break;
139    }
140
141    if(isValid) ui->fsName->setStyleSheet("");
142    else ui->fsName->setStyleSheet("background-color: rgb(255, 188, 183);");
143}
144
145bool DialogfsCreate::hasValidPath()
146{
147    return isValid;
148}
149
150void DialogfsCreate::done(int result)
151{
152    if(result==QDialog::Accepted && !isValid) return;
153        QDialog::done(result);
154}
155
156void DialogfsCreate::setPropsVisible(bool p)
157{
158    Q_UNUSED(p);
159    ui->frameProps->setVisible(false);
160}
161
162
163void DialogfsCreate::nameOnlyMode()
164{
165    setPropsVisible(false);
166    resize(width(),height()-ui->frameProps->height());
167    adjustSize();
168}
169
170void DialogfsCreate::changeTitle(QString title)
171{
172    setWindowTitle(title);
173}
Note: See TracBrowser for help on using the repository browser.