neither KMountPoint nor our own edit mount point dialog can handle more than

one mount point per partition, so don't pretend we could in the Partition class

svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1127763
This commit is contained in:
Volker Lanz 2010-05-17 15:17:15 +00:00
parent bc5d916cc6
commit 438a325f29
7 changed files with 24 additions and 30 deletions

View File

@ -42,12 +42,12 @@
@param sectorEnd the last sector of the Partition on its Device
@param number the Partition's device number, e.g. 7 for /dev/sdd7
@param availableFlags the flags available for this Partition
@param mountPoints string list of mount points found for this Partition
@param mountPoint mount point for this Partition
@param mounted true if the Partition is mounted
@param activeFlags active flags for this Partition
@param state the Partition's state
*/
Partition::Partition(PartitionNode* parent, const Device& device, const PartitionRole& role, FileSystem* fs, qint64 sectorStart, qint64 sectorEnd, qint32 number, PartitionTable::Flags availableFlags, const QStringList& mountPoints, bool mounted, PartitionTable::Flags activeFlags, State state) :
Partition::Partition(PartitionNode* parent, const Device& device, const PartitionRole& role, FileSystem* fs, qint64 sectorStart, qint64 sectorEnd, qint32 number, PartitionTable::Flags availableFlags, const QString& mountPoint, bool mounted, PartitionTable::Flags activeFlags, State state) :
PartitionNode(),
m_Number(number),
m_Children(),
@ -57,7 +57,7 @@ Partition::Partition(PartitionNode* parent, const Device& device, const Partitio
m_FirstSector(sectorStart),
m_LastSector(sectorEnd),
m_DevicePath(device.deviceNode()),
m_MountPoints(mountPoints),
m_MountPoint(mountPoint),
m_AvailableFlags(availableFlags),
m_ActiveFlags(activeFlags),
m_IsMounted(mounted),
@ -96,7 +96,7 @@ Partition::Partition(const Partition& other) :
m_FirstSector(other.m_FirstSector),
m_LastSector(other.m_LastSector),
m_DevicePath(other.m_DevicePath),
m_MountPoints(other.m_MountPoints),
m_MountPoint(other.m_MountPoint),
m_AvailableFlags(other.m_AvailableFlags),
m_ActiveFlags(other.m_ActiveFlags),
m_IsMounted(other.m_IsMounted),
@ -132,7 +132,7 @@ Partition& Partition::operator=(const Partition& other)
m_FirstSector = other.m_FirstSector;
m_LastSector = other.m_LastSector;
m_DevicePath = other.m_DevicePath;
m_MountPoints = other.m_MountPoints;
m_MountPoint = other.m_MountPoint;
m_AvailableFlags = other.m_AvailableFlags;
m_ActiveFlags = other.m_ActiveFlags;
m_IsMounted = other.m_IsMounted;
@ -265,7 +265,7 @@ bool Partition::canMount() const
return true;
// cannot mount if we have no mount points
return !mountPoints().isEmpty();
return !mountPoint().isEmpty();
}
/** @return true if this Partition can be unmounted */
@ -288,12 +288,9 @@ bool Partition::mount(Report& report)
success = fileSystem().mount(deviceNode());
else
{
foreach(const QString& mp, mountPoints())
{
ExternalCommand mountCmd(report, "mount", QStringList() << "-v" << deviceNode() << mp);
if (mountCmd.run() && mountCmd.exitCode() == 0)
success = true;
}
ExternalCommand mountCmd(report, "mount", QStringList() << "-v" << deviceNode() << mountPoint());
if (mountCmd.run() && mountCmd.exitCode() == 0)
success = true;
}
setMounted(success);
@ -315,12 +312,9 @@ bool Partition::unmount(Report& report)
success = fileSystem().unmount(deviceNode());
else
{
foreach(const QString& mp, mountPoints())
{
ExternalCommand umountCmd(report, "umount", QStringList() << "-v" << mp);
if (!umountCmd.run() || umountCmd.exitCode() != 0)
success = false;
}
ExternalCommand umountCmd(report, "umount", QStringList() << "-v" << mountPoint());
if (!umountCmd.run() || umountCmd.exitCode() != 0)
success = false;
}
setMounted(!success);

View File

@ -114,7 +114,7 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT Partition : public PartitionNode
};
public:
Partition(PartitionNode* parent, const Device& device, const PartitionRole& role, FileSystem* fs, qint64 sectorStart, qint64 sectorEnd, qint32 number, PartitionTable::Flags availableFlags = PartitionTable::FlagNone, const QStringList& mountPoints = QStringList(), bool mounted = false, PartitionTable::Flags activeFlags = PartitionTable::FlagNone, State state = StateNone);
Partition(PartitionNode* parent, const Device& device, const PartitionRole& role, FileSystem* fs, qint64 sectorStart, qint64 sectorEnd, qint32 number, PartitionTable::Flags availableFlags = PartitionTable::FlagNone, const QString& mountPoint = QString(), bool mounted = false, PartitionTable::Flags activeFlags = PartitionTable::FlagNone, State state = StateNone);
~Partition();
public:
@ -151,7 +151,7 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT Partition : public PartitionNode
const PartitionRole& roles() const { return m_Roles; } /**< @return the Partition's role(s) */
const QStringList& mountPoints() const { return m_MountPoints; } /**< @return the Partition's mount points */
const QString& mountPoint() const { return m_MountPoint; } /**< @return the Partition's mount point */
PartitionTable::Flags activeFlags() const { return m_ActiveFlags; } /**< @return the flags currently set for this Partition */
PartitionTable::Flags availableFlags() const { return m_AvailableFlags; } /**< @return the flags available for this Partition */
@ -177,7 +177,7 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT Partition : public PartitionNode
void append(Partition* p) { m_Children.append(p); }
void setDevicePath(const QString& s) { m_DevicePath = s; }
void setRoles(const PartitionRole& r) { m_Roles = r; }
void setMountPoints(const QStringList& sl) { m_MountPoints = sl; }
void setMountPoint(const QString& s) { m_MountPoint = s; }
void setFlags(PartitionTable::Flags f) { m_ActiveFlags = f; }
void setSectorSize(qint32 s) { m_SectorSize = s; }
void setFirstSector(qint64 s) { m_FirstSector = s; }
@ -201,7 +201,7 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT Partition : public PartitionNode
qint64 m_FirstSector;
qint64 m_LastSector;
QString m_DevicePath;
QStringList m_MountPoints;
QString m_MountPoint;
PartitionTable::Flags m_AvailableFlags;
PartitionTable::Flags m_ActiveFlags;
bool m_IsMounted;

View File

@ -57,7 +57,7 @@ void EditMountPointDialog::accept()
return;
if (widget().acceptChanges() && widget().writeMountpoints("/etc/fstab"))
partition().setMountPoints(QStringList() << widget().editPath().text());
partition().setMountPoint(widget().editPath().text());
KDialog::accept();
}

View File

@ -434,7 +434,7 @@ void MainWindow::enableActions()
actionCollection()->action("pastePartition")->setEnabled(!readOnly && CopyOperation::canPaste(part, pmWidget().clipboardPartition()));
actionCollection()->action("propertiesPartition")->setEnabled(part != NULL);
actionCollection()->action("editMountPoint")->setEnabled(part && part->canMount());
actionCollection()->action("editMountPoint")->setEnabled(part);
actionCollection()->action("mountPartition")->setEnabled(part && (part->canMount() || part->canUnmount()));
if (part != NULL)
@ -876,7 +876,7 @@ void MainWindow::onImportPartitionTable()
if (fs->supportSetLabel() != FileSystem::cmdSupportNone && !volumeLabel.isEmpty())
fs->setLabel(volumeLabel);
Partition* p = new Partition(parent, device, role, fs, firstSector, lastSector, -1, PartitionTable::FlagNone, QStringList(), false, PartitionTable::FlagNone, Partition::StateNew);
Partition* p = new Partition(parent, device, role, fs, firstSector, lastSector, -1, PartitionTable::FlagNone, QString(), false, PartitionTable::FlagNone, Partition::StateNew);
operationStack().push(new NewOperation(device, p));
}

View File

@ -214,7 +214,7 @@ static QTreeWidgetItem* createTreeWidgetItem(const Partition& p)
item->setIcon(i, createFileSystemColor(p.fileSystem().type(), 14));
i++;
item->setText(i, p.mountPoints().join(", "));
item->setText(i, p.mountPoint());
if (p.isMounted())
item->setIcon(i, SmallIcon("object-locked"));
i++;

View File

@ -98,9 +98,9 @@ void PartPropsDialog::setupDialog()
dialogWidget().partResizerWidget().init(device(), partition(), partition().firstSector(), partition().lastSector(), true, false);
const QString mp = (partition().mountPoints().size() == 0 || partition().mountPoints()[0].length() == 0)
const QString mp = partition().mountPoint().isEmpty()
? i18nc("@item mountpoint", "(none found)")
: partition().mountPoints().join(", ");
: partition().mountPoint();
dialogWidget().mountPoint().setText(mp);
dialogWidget().role().setText(partition().roles().toString());
@ -110,7 +110,7 @@ void PartPropsDialog::setupDialog()
{
if (partition().roles().has(PartitionRole::Extended))
statusText = i18nc("@label partition state", "At least one logical partition is mounted.");
else if (partition().mountPoints().size() > 0)
else if (!partition().mountPoint().isEmpty())
statusText = i18nc("@label partition state", "mounted on <filename>%1</filename>", mp);
else
statusText = i18nc("@label partition state", "mounted");

View File

@ -350,7 +350,7 @@ void LibPartedBackend::scanDevicePartitions(PedDevice* pedDevice, Device& d, Ped
const QString mountPoint = mountPoints.findByDevice(node) ? mountPoints.findByDevice(node)->mountPoint() : QString();
Partition* part = new Partition(parent, d, PartitionRole(r), fs, pedPartition->geom.start, pedPartition->geom.end, pedPartition->num, availableFlags(pedPartition), QStringList() << mountPoint, ped_partition_is_busy(pedPartition), activeFlags(pedPartition));
Partition* part = new Partition(parent, d, PartitionRole(r), fs, pedPartition->geom.start, pedPartition->geom.end, pedPartition->num, availableFlags(pedPartition), mountPoint, ped_partition_is_busy(pedPartition), activeFlags(pedPartition));
readSectorsUsed(pedDisk, *part, mountPoint);