Replace QMaps for mount point entries with std::multimap.
This allows to retain multiple fstab entries for given block device. At the moment there is no UI to access more than one mount point entry but at least we will not be corrupting user's fstabs when we edit unrelated entries.
This commit is contained in:
parent
42fc14cad1
commit
6889a3b17c
|
@ -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<QString, MountEntry*>(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<QString, MountEntry*>(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();
|
||||
|
||||
|
|
|
@ -21,7 +21,8 @@
|
|||
|
||||
#include "ui_editmountpointdialogwidgetbase.h"
|
||||
|
||||
#include <QMap>
|
||||
#include <map>
|
||||
|
||||
#include <QString>
|
||||
#include <QWidget>
|
||||
|
||||
|
@ -80,14 +81,14 @@ protected:
|
|||
|
||||
private:
|
||||
void setupOptions(const QStringList& options);
|
||||
QMap<QString, QCheckBox*>& boxOptions() {
|
||||
std::map<QString, QCheckBox*>& boxOptions() {
|
||||
return m_BoxOptions;
|
||||
}
|
||||
const QMap<QString, QCheckBox*>& boxOptions() const {
|
||||
const std::map<QString, QCheckBox*>& boxOptions() const {
|
||||
return m_BoxOptions;
|
||||
}
|
||||
bool readMountpoints(const QString& filename);
|
||||
QMap<QString, MountEntry*>& mountPoints() {
|
||||
std::multimap<QString, MountEntry*>& mountPoints() {
|
||||
return m_MountPoints;
|
||||
}
|
||||
const Partition& partition() const {
|
||||
|
@ -96,10 +97,10 @@ private:
|
|||
|
||||
private:
|
||||
const Partition& m_Partition;
|
||||
QMap<QString, MountEntry*> m_MountPoints;
|
||||
std::multimap<QString, MountEntry*> m_MountPoints;
|
||||
QString m_Options;
|
||||
QString m_deviceNode;
|
||||
QMap<QString, QCheckBox*> m_BoxOptions;
|
||||
std::map<QString, QCheckBox*> m_BoxOptions;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue