diff --git a/src/gui/editmountpointdialog.cpp b/src/gui/editmountpointdialog.cpp --- a/src/gui/editmountpointdialog.cpp +++ b/src/gui/editmountpointdialog.cpp @@ -78,7 +78,7 @@ 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.h b/src/gui/editmountpointdialogwidget.h --- a/src/gui/editmountpointdialogwidget.h +++ b/src/gui/editmountpointdialogwidget.h @@ -32,7 +32,7 @@ class QFile; class QSpinBox; class QCheckBox; -class QLineEdit; +class QComboBox; class QPushButton; class QStringList; @@ -48,7 +48,7 @@ QLabel& labelName() { return *m_LabelNameValue; } - QLineEdit& editPath() { + QComboBox& editPath() { return *m_EditPath; } QSpinBox& spinDumpFreq() { @@ -84,6 +84,7 @@ private: void setupOptions(const QStringList& options); + void setupRadio(const FstabEntryType entryType); std::map& boxOptions() { return m_BoxOptions; } @@ -101,12 +102,14 @@ 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/editmountpointdialogwidget.cpp b/src/gui/editmountpointdialogwidget.cpp --- a/src/gui/editmountpointdialogwidget.cpp +++ b/src/gui/editmountpointdialogwidget.cpp @@ -50,12 +50,14 @@ 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,37 +77,12 @@ } m_fstabEntries.append(FstabEntry(m_deviceNode, QString(), fsName, QString())); - entry = &m_fstabEntries.last(); - } - - editPath().setText(entry->mountPoint()); - - spinDumpFreq().setValue(entry->dumpFreq()); - spinPassNumber().setValue(entry->passNumber()); - - switch (entry->entryType()) { - case FstabEntryType::uuid: - radioUUID().setChecked(true); - break; - - case FstabEntryType::label: - radioLabel().setChecked(true); - break; - - case FstabEntryType::partuuid: - radioUUID().setChecked(true); - break; - - case FstabEntryType::partlabel: - radioLabel().setChecked(true); - break; - - case FstabEntryType::deviceNode: - radioDeviceNode().setChecked(true); - break; - case FstabEntryType::comment: - break; + 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; @@ -116,22 +93,21 @@ 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); - } + 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() @@ -141,7 +117,6 @@ void EditMountPointDialogWidget::setupOptions(const QStringList& options) { QStringList optTmpList; - for (const auto &o : options) { if (boxOptions().find(o) != boxOptions().end()) boxOptions()[o]->setChecked(true); @@ -152,23 +127,69 @@ m_Options = optTmpList.join(QLatin1Char(',')); } +void EditMountPointDialogWidget::setupRadio(const FstabEntryType entryType) +{ + 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); + } + switch (entryType) { + case FstabEntryType::uuid: + radioUUID().setChecked(true); + break; + + case FstabEntryType::label: + radioLabel().setChecked(true); + break; + + case FstabEntryType::partuuid: + radioUUID().setChecked(true); + break; + + case FstabEntryType::partlabel: + radioLabel().setChecked(true); + break; + + case FstabEntryType::deviceNode: + radioDeviceNode().setChecked(true); + break; + case FstabEntryType::comment: + break; + } +} + 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 @@ 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/editmountpointdialogwidgetbase.ui b/src/gui/editmountpointdialogwidgetbase.ui --- 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,38 +56,79 @@ - - + + - Users can mount and unmount + Pass &Number: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + m_SpinPassNumber - - + + - No automatic mount + More... - - + + + + Qt::Horizontal + + + + 195 + 22 + + + + + + - No update of file access times + De&vice Node + + + true - - + + - Synchronous access + Options: + + + Qt::AlignRight|Qt::AlignTop|Qt::AlignTrailing - - + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 10 + + + + + + - No update of directory access times + &Label @@ -103,30 +139,59 @@ - - - - Update access times relative to modification - - + + - - + + Qt::Horizontal - 195 - 22 + 135 + 23 - - + + - More... + No automatic mount + + + + + + + + 1 + 0 + + + + Remove + + + + + + + + 1 + 0 + + + + Select... + + + + + + + No update of directory access times @@ -143,37 +208,41 @@ - - - - - + + - Qt::Horizontal + Qt::Vertical + + + QSizePolicy::Fixed - 70 - 23 + 20 + 10 - - + + - Pass &Number: + Type: Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - m_SpinPassNumber - - - + + + + Path: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + @@ -191,52 +260,6 @@ - - - - - - - - - - - Qt::Horizontal - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 10 - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 10 - - - - @@ -253,79 +276,46 @@ - - - - De&vice Node - - - true - - - - - - - UU&ID - - - - - + + - &Label + No update of file access times - - + + - Identify by: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Synchronous access - - + + Qt::Horizontal - 135 + 70 23 - - - - - 1 - 0 - - + + - Select... - - - - - - - - 1 - 0 - + Identify by: - - Remove + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + +