diff --git a/src/gui/editmountpointdialog.cpp b/src/gui/editmountpointdialog.cpp index f80b112..02b4f36 100644 --- a/src/gui/editmountpointdialog.cpp +++ b/src/gui/editmountpointdialog.cpp @@ -78,7 +78,7 @@ void EditMountPointDialog::accept_(MountPointAction action) widget().acceptChanges(); if (writeMountpoints(widget().fstabEntries())) { if (action == Edit) - partition().setMountPoint(widget().editPath().text()); + partition().setMountPoint(widget().editPath().currentText()); } else KMessageBox::sorry(this, diff --git a/src/gui/editmountpointdialogwidget.cpp b/src/gui/editmountpointdialogwidget.cpp index 624b599..8af681f 100644 --- a/src/gui/editmountpointdialogwidget.cpp +++ b/src/gui/editmountpointdialogwidget.cpp @@ -50,12 +50,14 @@ EditMountPointDialogWidget::EditMountPointDialogWidget(QWidget* parent, Partitio labelType().setText(partition().fileSystem().name()); bool entryFound = false; + editPath().setEditable(true); for (auto &e : m_fstabEntries) { QString canonicalEntryPath = QFileInfo(e.deviceNode()).canonicalFilePath(); QString canonicalDevicePath = QFileInfo(m_deviceNode).canonicalFilePath(); if (canonicalEntryPath == canonicalDevicePath) { // FIXME fix multiple mountpoints entryFound = true; - entry = &e; + entry.append(&e); + mountPointList = possibleMountPoints(e.deviceNode()); } } @@ -75,15 +77,70 @@ EditMountPointDialogWidget::EditMountPointDialogWidget(QWidget* parent, Partitio } m_fstabEntries.append(FstabEntry(m_deviceNode, QString(), fsName, QString())); - entry = &m_fstabEntries.last(); + entry.append(&m_fstabEntries.last()); + } + currentEntry = entry[0]; + editPath().addItems(mountPointList); + spinDumpFreq().setValue(currentEntry->dumpFreq()); + spinPassNumber().setValue(currentEntry->passNumber()); + + boxOptions()[QStringLiteral("ro")] = m_CheckReadOnly; + boxOptions()[QStringLiteral("users")] = m_CheckUsers; + boxOptions()[QStringLiteral("noauto")] = m_CheckNoAuto; + boxOptions()[QStringLiteral("noatime")] = m_CheckNoAtime; + boxOptions()[QStringLiteral("nodiratime")] = m_CheckNoDirAtime; + boxOptions()[QStringLiteral("sync")] = m_CheckSync; + boxOptions()[QStringLiteral("noexec")] = m_CheckNoExec; + boxOptions()[QStringLiteral("relatime")] = m_CheckRelAtime; + + setupRadio(currentEntry->entryType()); + setupOptions(currentEntry->options()); + + connect(m_ButtonMore, &QPushButton::clicked, this, &EditMountPointDialogWidget::buttonMoreClicked); + connect(m_ButtonSelect, &QPushButton::clicked, this, &EditMountPointDialogWidget::buttonSelectClicked); + connect(m_EditPath, QOverload::of(&QComboBox::currentIndexChanged), + [=](int index){ currentEntry = entry[index]; + spinDumpFreq().setValue(currentEntry->dumpFreq()); + spinPassNumber().setValue(currentEntry->passNumber()); + setupRadio(currentEntry->entryType()); + for (iterator_BoxOptions = boxOptions().begin(); iterator_BoxOptions != boxOptions().end(); ++iterator_BoxOptions){ + boxOptions()[iterator_BoxOptions->first]->setChecked(false); + } + setupOptions(currentEntry->options()); + }); +} + +EditMountPointDialogWidget::~EditMountPointDialogWidget() +{ +} + +void EditMountPointDialogWidget::setupOptions(const QStringList& options) +{ + QStringList optTmpList; + for (const auto &o : options) { + if (boxOptions().find(o) != boxOptions().end()) + boxOptions()[o]->setChecked(true); + else + optTmpList.append(o); } - editPath().setText(entry->mountPoint()); + m_Options = optTmpList.join(QLatin1Char(',')); +} - spinDumpFreq().setValue(entry->dumpFreq()); - spinPassNumber().setValue(entry->passNumber()); +void EditMountPointDialogWidget::setupRadio(const FstabEntryType entryType) +{ + if (partition().fileSystem().uuid().isEmpty()) { + radioUUID().setEnabled(false); + if (radioUUID().isChecked()) + radioDeviceNode().setChecked(true); + } - switch (entry->entryType()) { + if (partition().fileSystem().label().isEmpty()) { + radioLabel().setEnabled(false); + if (radioLabel().isChecked()) + radioDeviceNode().setChecked(true); + } + switch (entryType) { case FstabEntryType::uuid: radioUUID().setChecked(true); break; @@ -106,69 +163,33 @@ EditMountPointDialogWidget::EditMountPointDialogWidget(QWidget* parent, Partitio case FstabEntryType::comment: break; } - - boxOptions()[QStringLiteral("ro")] = m_CheckReadOnly; - boxOptions()[QStringLiteral("users")] = m_CheckUsers; - boxOptions()[QStringLiteral("noauto")] = m_CheckNoAuto; - boxOptions()[QStringLiteral("noatime")] = m_CheckNoAtime; - boxOptions()[QStringLiteral("nodiratime")] = m_CheckNoDirAtime; - boxOptions()[QStringLiteral("sync")] = m_CheckSync; - boxOptions()[QStringLiteral("noexec")] = m_CheckNoExec; - boxOptions()[QStringLiteral("relatime")] = m_CheckRelAtime; - - setupOptions(entry->options()); - - if (partition().fileSystem().uuid().isEmpty()) { - radioUUID().setEnabled(false); - if (radioUUID().isChecked()) - radioDeviceNode().setChecked(true); - } - - if (partition().fileSystem().label().isEmpty()) { - radioLabel().setEnabled(false); - if (radioLabel().isChecked()) - radioDeviceNode().setChecked(true); - } - - connect(m_ButtonMore, &QPushButton::clicked, this, &EditMountPointDialogWidget::buttonMoreClicked); - connect(m_ButtonSelect, &QPushButton::clicked, this, &EditMountPointDialogWidget::buttonSelectClicked); -} - -EditMountPointDialogWidget::~EditMountPointDialogWidget() -{ -} - -void EditMountPointDialogWidget::setupOptions(const QStringList& options) -{ - QStringList optTmpList; - - for (const auto &o : options) { - if (boxOptions().find(o) != boxOptions().end()) - boxOptions()[o]->setChecked(true); - else - optTmpList.append(o); - } - - m_Options = optTmpList.join(QLatin1Char(',')); } void EditMountPointDialogWidget::buttonSelectClicked(bool) { - const QString s = QFileDialog::getExistingDirectory(this, editPath().text()); + const QString s = QFileDialog::getExistingDirectory(this, editPath().currentText()); if (!s.isEmpty()) - editPath().setText(s); + editPath().setCurrentText(s); } void EditMountPointDialogWidget::removeMountPoint() { int i=0; for (const auto &e : fstabEntries()) { - if((e.fsSpec().contains(partition().deviceNode()) && !partition().deviceNode().isEmpty() ) || (e.fsSpec().contains(partition().fileSystem().uuid()) && !partition().fileSystem().uuid().isEmpty()) || - (e.fsSpec().contains(partition().fileSystem().label()) && !partition().fileSystem().label().isEmpty()) || (e.fsSpec().contains(partition().label()) && !partition().label().isEmpty() ) || (e.fsSpec().contains(partition().uuid()) && !partition().uuid().isEmpty() ) ) + if(editPath().count()<=1 && ((e.fsSpec().contains(partition().deviceNode()) && !partition().deviceNode().isEmpty() ) || (e.fsSpec().contains(partition().fileSystem().uuid()) && !partition().fileSystem().uuid().isEmpty()) || + (e.fsSpec().contains(partition().fileSystem().label()) && !partition().fileSystem().label().isEmpty()) || (e.fsSpec().contains(partition().label()) && !partition().label().isEmpty() ) || (e.fsSpec().contains(partition().uuid()) && !partition().uuid().isEmpty() ))) { fstabEntries().removeAt(i); partition().setMountPoint(QString()); i--; + } + else if(editPath().count()>1 && ((&e == currentEntry))) + { + fstabEntries().removeAt(i); + editPath().removeItem(editPath().currentIndex()); + partition().setMountPoint(editPath().itemText(editPath().currentIndex())); + i--; + break; } i++; } @@ -199,15 +220,15 @@ QStringList EditMountPointDialogWidget::options() const void EditMountPointDialogWidget::acceptChanges() { - entry->setDumpFreq(spinDumpFreq().value()); - entry->setPassNumber(spinPassNumber().value()); - entry->setMountPoint(editPath().text()); - entry->setOptions(options()); + currentEntry->setDumpFreq(spinDumpFreq().value()); + currentEntry->setPassNumber(spinPassNumber().value()); + currentEntry->setMountPoint(editPath().currentText()); + currentEntry->setOptions(options()); if (radioUUID().isChecked() && !partition().fileSystem().uuid().isEmpty()) - entry->setFsSpec(QStringLiteral("UUID=") + partition().fileSystem().uuid()); + currentEntry->setFsSpec(QStringLiteral("UUID=") + partition().fileSystem().uuid()); else if (radioLabel().isChecked() && !partition().fileSystem().label().isEmpty()) - entry->setFsSpec(QStringLiteral("LABEL=") + partition().fileSystem().label()); + currentEntry->setFsSpec(QStringLiteral("LABEL=") + partition().fileSystem().label()); else - entry->setFsSpec(m_deviceNode); + currentEntry->setFsSpec(m_deviceNode); } diff --git a/src/gui/editmountpointdialogwidget.h b/src/gui/editmountpointdialogwidget.h index da54790..56705bc 100644 --- a/src/gui/editmountpointdialogwidget.h +++ b/src/gui/editmountpointdialogwidget.h @@ -32,7 +32,7 @@ class Partition; class QFile; class QSpinBox; class QCheckBox; -class QLineEdit; +class QComboBox; class QPushButton; class QStringList; @@ -48,7 +48,7 @@ public: QLabel& labelName() { return *m_LabelNameValue; } - QLineEdit& editPath() { + QComboBox& editPath() { return *m_EditPath; } QSpinBox& spinDumpFreq() { @@ -84,6 +84,7 @@ protected: private: void setupOptions(const QStringList& options); + void setupRadio(const FstabEntryType entryType); std::map& boxOptions() { return m_BoxOptions; } @@ -101,12 +102,14 @@ private: private: FstabEntryList m_fstabEntries; - FstabEntry *entry; - + QList entry; + FstabEntry *currentEntry; Partition& m_Partition; QString m_Options; QString m_deviceNode; + QStringList mountPointList; std::map m_BoxOptions; + std::map::iterator iterator_BoxOptions; }; #endif diff --git a/src/gui/editmountpointdialogwidgetbase.ui b/src/gui/editmountpointdialogwidgetbase.ui index e83a459..0d95b5e 100644 --- a/src/gui/editmountpointdialogwidgetbase.ui +++ b/src/gui/editmountpointdialogwidgetbase.ui @@ -6,51 +6,46 @@ 0 0 - 600 + 613 374 - - - - - 3 - 0 - + + + + UU&ID - - + + + + + - Path: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - m_EditPath + Users can mount and unmount - - + + - Type: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Update access times relative to modification - - + + - Options: + - - Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing + + + + + + Qt::Horizontal @@ -61,52 +56,23 @@ - - + + - Users can mount and unmount + Pass &Number: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + m_SpinPassNumber - - + + - No automatic mount - - - - - - - No update of file access times - - - - - - - Synchronous access - - - - - - - No update of directory access times - - - - - - - No binary execution - - - - - - - Update access times relative to modification + More... @@ -123,85 +89,23 @@ - - + + - More... + De&vice Node + + + true - - + + - Dump &Frequency: + Options: - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - m_SpinDumpFreq - - - - - - - - - - Qt::Horizontal - - - - 70 - 23 - - - - - - - - Pass &Number: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - m_SpinPassNumber - - - - - - - - - - - 75 - true - - - - - - - Qt::AlignCenter - - - - - - - - - - - - - - Qt::Horizontal + Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing @@ -221,6 +125,89 @@ + + + + &Label + + + + + + + No binary execution + + + + + + + + + + Qt::Horizontal + + + + 135 + 23 + + + + + + + + No automatic mount + + + + + + + + 1 + 0 + + + + Remove + + + + + + + + 1 + 0 + + + + Select... + + + + + + + No update of directory access times + + + + + + + Dump &Frequency: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + m_SpinDumpFreq + + + @@ -237,6 +224,42 @@ + + + + Type: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Path: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 75 + true + + + + + + + Qt::AlignCenter + + + @@ -253,29 +276,32 @@ - - + + - De&vice Node - - - true + No update of file access times - - + + - UU&ID + Synchronous access - - - - &Label + + + + Qt::Horizontal - + + + 70 + 23 + + + @@ -287,44 +313,8 @@ - - - - Qt::Horizontal - - - - 135 - 23 - - - - - - - - - 1 - 0 - - - - Select... - - - - - - - - 1 - 0 - - - - Remove - - + +