Clean up ListOperations.
svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1089102
This commit is contained in:
parent
7991de7fef
commit
eca8342e75
|
@ -19,8 +19,6 @@
|
|||
|
||||
#include "gui/listoperations.h"
|
||||
|
||||
#include "gui/partitionmanagerwidget.h"
|
||||
|
||||
#include "ops/operation.h"
|
||||
|
||||
#include "util/globallog.h"
|
||||
|
@ -35,17 +33,16 @@
|
|||
ListOperations::ListOperations(QWidget* parent) :
|
||||
QWidget(parent),
|
||||
Ui::ListOperationsBase(),
|
||||
m_ActionCollection(NULL),
|
||||
m_PartitionManagerWidget(NULL)
|
||||
m_ActionCollection(NULL)
|
||||
{
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
void ListOperations::updateOperations()
|
||||
void ListOperations::updateOperations(const OperationStack::Operations& ops)
|
||||
{
|
||||
listOperations().clear();
|
||||
|
||||
foreach (const Operation* op, pmWidget().operations())
|
||||
foreach (const Operation* op, ops)
|
||||
{
|
||||
QListWidgetItem* item = new QListWidgetItem(SmallIcon(op->iconName()), op->description());
|
||||
item->setToolTip(op->description());
|
||||
|
@ -57,14 +54,20 @@ void ListOperations::updateOperations()
|
|||
|
||||
void ListOperations::on_m_ListOperations_customContextMenuRequested(const QPoint& pos)
|
||||
{
|
||||
Q_ASSERT(actionCollection());
|
||||
if (actionCollection() != NULL)
|
||||
{
|
||||
KMenu opsMenu;
|
||||
|
||||
KMenu opsMenu;
|
||||
if (actionCollection()->action("undoOperation") != NULL)
|
||||
opsMenu.addAction(actionCollection()->action("undoOperation"));
|
||||
|
||||
opsMenu.addAction(actionCollection()->action("undoOperation"));
|
||||
opsMenu.addAction(actionCollection()->action("clearAllOperations"));
|
||||
opsMenu.addAction(actionCollection()->action("applyAllOperations"));
|
||||
if (actionCollection()->action("clearAllOperations") != NULL)
|
||||
opsMenu.addAction(actionCollection()->action("clearAllOperations"));
|
||||
|
||||
opsMenu.exec(listOperations().viewport()->mapToGlobal(pos));
|
||||
if (actionCollection()->action("applyAllOperations") != NULL)
|
||||
opsMenu.addAction(actionCollection()->action("applyAllOperations"));
|
||||
|
||||
opsMenu.exec(listOperations().viewport()->mapToGlobal(pos));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,17 +21,16 @@
|
|||
|
||||
#define LISTOPERATIONS__H
|
||||
|
||||
#include "core/operationstack.h"
|
||||
|
||||
#include "util/libpartitionmanagerexport.h"
|
||||
|
||||
#include "ui_listoperationsbase.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include <kdebug.h>
|
||||
|
||||
class Operation;
|
||||
class QPoint;
|
||||
class PartitionManagerWidget;
|
||||
class KActionCollection;
|
||||
|
||||
/** @brief A list of pending operations.
|
||||
|
@ -47,17 +46,14 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT ListOperations : public QWidget, public
|
|||
ListOperations(QWidget* parent);
|
||||
|
||||
public:
|
||||
void init(KActionCollection* coll, PartitionManagerWidget* pm_widget) { m_ActionCollection = coll; m_PartitionManagerWidget = pm_widget; }
|
||||
void setActionCollection(KActionCollection* coll) { m_ActionCollection = coll; }
|
||||
|
||||
public slots:
|
||||
void updateOperations();
|
||||
void updateOperations(const OperationStack::Operations& ops);
|
||||
|
||||
protected:
|
||||
KActionCollection* actionCollection() { return m_ActionCollection; }
|
||||
|
||||
PartitionManagerWidget& pmWidget() { Q_ASSERT(m_PartitionManagerWidget); return *m_PartitionManagerWidget; }
|
||||
const PartitionManagerWidget& pmWidget() const { Q_ASSERT(m_PartitionManagerWidget); return *m_PartitionManagerWidget; }
|
||||
|
||||
QListWidget& listOperations() { Q_ASSERT(m_ListOperations); return *m_ListOperations; }
|
||||
const QListWidget& listOperations() const { Q_ASSERT(m_ListOperations); return *m_ListOperations; }
|
||||
|
||||
|
@ -66,7 +62,6 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT ListOperations : public QWidget, public
|
|||
|
||||
private:
|
||||
KActionCollection* m_ActionCollection;
|
||||
PartitionManagerWidget* m_PartitionManagerWidget;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -63,7 +63,7 @@ void MainWindow::init()
|
|||
setupConnections();
|
||||
|
||||
listDevices().setActionCollection(actionCollection());
|
||||
listOperations().init(actionCollection(), &pmWidget());
|
||||
listOperations().setActionCollection(actionCollection());
|
||||
pmWidget().init(actionCollection(), "partitionmanagerrc");
|
||||
|
||||
// If we were called with an action collection we're supposed to be a KPart, so don't
|
||||
|
@ -169,7 +169,7 @@ void MainWindow::saveConfig() const
|
|||
|
||||
void MainWindow::on_m_PartitionManagerWidget_operationsChanged()
|
||||
{
|
||||
listOperations().updateOperations();
|
||||
listOperations().updateOperations(pmWidget().operations());
|
||||
|
||||
statusText().setText(i18ncp("@info:status", "One pending operation", "%1 pending operations", pmWidget().numPendingOperations()));
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ PartitionManagerKCM::PartitionManagerKCM(QWidget* parent, const QVariantList&) :
|
|||
setupConnections();
|
||||
|
||||
listDevices().setActionCollection(actionCollection());
|
||||
listOperations().init(actionCollection(), &pmWidget());
|
||||
listOperations().setActionCollection(actionCollection());
|
||||
pmWidget().init(actionCollection(), "kcm_partitionmanagerrc");
|
||||
|
||||
const char* actionNames[] =
|
||||
|
@ -109,7 +109,7 @@ void PartitionManagerKCM::setupConnections()
|
|||
|
||||
void PartitionManagerKCM::on_m_PartitionManagerWidget_operationsChanged()
|
||||
{
|
||||
listOperations().updateOperations();
|
||||
listOperations().updateOperations(pmWidget().operations());
|
||||
|
||||
emit changed(pmWidget().numPendingOperations() > 0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue