diff --git a/src/gui/editmountpointdialogwidget.cpp b/src/gui/editmountpointdialogwidget.cpp index e21ee08..c175b51 100644 --- a/src/gui/editmountpointdialogwidget.cpp +++ b/src/gui/editmountpointdialogwidget.cpp @@ -72,9 +72,10 @@ EditMountPointDialogWidget::EditMountPointDialogWidget(QWidget* parent, const Pa labelType().setText(partition().fileSystem().name()); if (mountPoints().find(m_deviceNode) == mountPoints().end()) - mountPoints()[m_deviceNode] = new MountEntry(m_deviceNode, QString(), partition().fileSystem().name(), QStringList(), 0, 0, MountEntry::deviceNode); + mountPoints().insert(std::pair(m_deviceNode, new MountEntry(m_deviceNode, QString(), partition().fileSystem().name(), QStringList(), 0, 0, MountEntry::deviceNode))); - MountEntry* entry = mountPoints()[m_deviceNode]; + auto search = mountPoints().find(m_deviceNode); // FIXME: Only one mountpoint entry corresponding to given device is shown + MountEntry* entry = search->second; Q_ASSERT(entry); @@ -127,7 +128,8 @@ EditMountPointDialogWidget::EditMountPointDialogWidget(QWidget* parent, const Pa EditMountPointDialogWidget::~EditMountPointDialogWidget() { - qDeleteAll(mountPoints().values()); + for (const auto &mp : mountPoints()) + delete mp.second; } void EditMountPointDialogWidget::setupOptions(const QStringList& options) @@ -165,10 +167,10 @@ QStringList EditMountPointDialogWidget::options() const { QStringList optList = m_Options.split(QStringLiteral(","), QString::SkipEmptyParts); - const auto keys = boxOptions().keys(); + const auto keys = boxOptions(); for (const auto &s : keys) - if (boxOptions()[s]->isChecked()) - optList.append(s); + if (s.second->isChecked()) + optList.append(s.first); return optList; } @@ -201,7 +203,7 @@ bool EditMountPointDialogWidget::readMountpoints(const QString& filename) if (!device.isEmpty()) { QString mountPoint = QString::fromUtf8(mnt->mnt_dir); - mountPoints()[device] = new MountEntry(mnt, type); + mountPoints().insert(std::pair(device, new MountEntry(mnt, type))); } } @@ -239,7 +241,8 @@ bool EditMountPointDialogWidget::acceptChanges() return false; } - entry = mountPoints()[labelName().text()]; + auto search = mountPoints().find(labelName().text()); + entry = search->second; entry->dumpFreq = spinDumpFreq().value(); entry->passNumber = spinPassNumber().value(); @@ -268,7 +271,7 @@ bool EditMountPointDialogWidget::writeMountpoints(const QString& filename) } else { const auto mp = mountPoints(); for (const auto &me : mp) - writeEntry(out, me); + writeEntry(out, me.second); out.close(); diff --git a/src/gui/editmountpointdialogwidget.h b/src/gui/editmountpointdialogwidget.h index 8fe1e42..03a5e87 100644 --- a/src/gui/editmountpointdialogwidget.h +++ b/src/gui/editmountpointdialogwidget.h @@ -21,7 +21,8 @@ #include "ui_editmountpointdialogwidgetbase.h" -#include +#include + #include #include @@ -80,14 +81,14 @@ protected: private: void setupOptions(const QStringList& options); - QMap& boxOptions() { + std::map& boxOptions() { return m_BoxOptions; } - const QMap& boxOptions() const { + const std::map& boxOptions() const { return m_BoxOptions; } bool readMountpoints(const QString& filename); - QMap& mountPoints() { + std::multimap& mountPoints() { return m_MountPoints; } const Partition& partition() const { @@ -96,10 +97,10 @@ private: private: const Partition& m_Partition; - QMap m_MountPoints; + std::multimap m_MountPoints; QString m_Options; QString m_deviceNode; - QMap m_BoxOptions; + std::map m_BoxOptions; }; #endif