Show an info message if no device is selected or the selected device has no
valid partition table. No need to overwrite paintEvent(). svn path=/trunk/playground/sysadmin/partitionmanager/; revision=868394
This commit is contained in:
parent
f2e2bbdfe3
commit
f10ffb5001
|
@ -25,13 +25,7 @@
|
|||
#include <QMouseEvent>
|
||||
|
||||
#include <kdebug.h>
|
||||
|
||||
/** @class PartTableWidget
|
||||
|
||||
@todo If there's no disk label on a device, we currently don't show anything at all.
|
||||
That's not particularly helpful, we should print something like "you need to create
|
||||
a partition table on this device to use it".
|
||||
*/
|
||||
#include <klocale.h>
|
||||
|
||||
/** Creates a new PartTableWidget.
|
||||
@param parent pointer to the parent widget
|
||||
|
@ -40,8 +34,10 @@ PartTableWidget::PartTableWidget(QWidget* parent) :
|
|||
QWidget(parent),
|
||||
m_PartitionTable(NULL),
|
||||
m_Widgets(),
|
||||
m_ActiveWidget(NULL)
|
||||
m_ActiveWidget(NULL),
|
||||
m_LabelEmpty(i18nc("@info", "Please select a device."), this)
|
||||
{
|
||||
labelEmpty().setAlignment(Qt::AlignVCenter | Qt::AlignHCenter);
|
||||
}
|
||||
|
||||
/** Sets the PartitionTable this widget shows.
|
||||
|
@ -67,7 +63,18 @@ void PartTableWidget::setPartitionTable(const PartitionTable* ptable)
|
|||
widgets().last()->show();
|
||||
}
|
||||
|
||||
positionChildren(this, partitionTable()->children(), widgets());
|
||||
if (widgets().isEmpty())
|
||||
{
|
||||
labelEmpty().setVisible(true);
|
||||
labelEmpty().setText(i18nc("@info", "No valid partition table was found on this device."));
|
||||
labelEmpty().resize(size());
|
||||
}
|
||||
else
|
||||
{
|
||||
labelEmpty().setVisible(false);
|
||||
positionChildren(this, partitionTable()->children(), widgets());
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
|
@ -125,13 +132,9 @@ void PartTableWidget::clear()
|
|||
|
||||
void PartTableWidget::resizeEvent(QResizeEvent*)
|
||||
{
|
||||
if (partitionTable())
|
||||
positionChildren(this, partitionTable()->children(), widgets());
|
||||
}
|
||||
|
||||
void PartTableWidget::paintEvent(QPaintEvent*)
|
||||
{
|
||||
if (partitionTable())
|
||||
if (partitionTable() == NULL || widgets().isEmpty())
|
||||
labelEmpty().resize(size());
|
||||
else
|
||||
positionChildren(this, partitionTable()->children(), widgets());
|
||||
}
|
||||
|
||||
|
|
|
@ -25,11 +25,11 @@
|
|||
|
||||
#include <QWidget>
|
||||
#include <QList>
|
||||
#include <QLabel>
|
||||
|
||||
class PartWidget;
|
||||
class PartitionTable;
|
||||
|
||||
class QPaintEvent;
|
||||
class QResizeEvent;
|
||||
class QMouseEvent;
|
||||
|
||||
|
@ -59,7 +59,6 @@ class PartTableWidget : public QWidget, public PartWidgetBase
|
|||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent* event);
|
||||
void paintEvent(QPaintEvent* event);
|
||||
void mousePressEvent(QMouseEvent* event);
|
||||
void mouseDoubleClickEvent(QMouseEvent* event);
|
||||
|
||||
|
@ -70,10 +69,14 @@ class PartTableWidget : public QWidget, public PartWidgetBase
|
|||
|
||||
const PartitionTable* partitionTable() const { return m_PartitionTable; }
|
||||
|
||||
QLabel& labelEmpty() { return m_LabelEmpty; }
|
||||
const QLabel& labelEmpty() const { return m_LabelEmpty; }
|
||||
|
||||
private:
|
||||
const PartitionTable* m_PartitionTable;
|
||||
QList<PartWidget*> m_Widgets;
|
||||
PartWidget* m_ActiveWidget;
|
||||
QLabel m_LabelEmpty;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue