remove devices list

svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1077129
This commit is contained in:
Volker Lanz 2010-01-19 12:56:27 +00:00
parent f67ca33866
commit 4f5253e6a2
9 changed files with 19 additions and 279 deletions

View File

@ -1,85 +0,0 @@
/***************************************************************************
* Copyright (C) 2008,2009 by Volker Lanz <vl@fidra.de> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#include "gui/listdevices.h"
#include "gui/partitionmanagerwidget.h"
#include "core/device.h"
#include "util/globallog.h"
#include "util/capacity.h"
#include <kmenu.h>
#include <kactioncollection.h>
/** Creates a new ListDevices instance.
@param parent the parent widget
*/
ListDevices::ListDevices(QWidget* parent) :
QWidget(parent),
Ui::ListDevicesBase(),
m_ActionCollection(NULL),
m_PartitionManagerWidget(NULL)
{
setupUi(this);
}
void ListDevices::updateDevices()
{
int idx = listDevices().currentRow();
listDevices().clear();
foreach(const Device* d, pmWidget().previewDevices())
{
const QString shortText = d->deviceNode() + " (" + Capacity(*d).toString() + ')';
const QString longText = d->deviceNode() + " (" + Capacity(*d).toString() + ", " + d->name() + ')';
QListWidgetItem* item = new QListWidgetItem(DesktopIcon(d->iconName()), shortText);
item->setToolTip(longText);
item->setSizeHint(QSize(0, 32));
listDevices().addItem(item);
}
if (idx > -1 && idx < listDevices().count())
listDevices().setCurrentRow(idx);
}
void ListDevices::on_m_ListDevices_itemSelectionChanged()
{
int idx = -1;
if (listDevices().selectedItems().size() == 1)
idx = listDevices().row(listDevices().selectedItems()[0]);
Device* d = NULL;
if (idx >= 0 && idx < pmWidget().previewDevices().size())
d = pmWidget().previewDevices()[idx];
emit selectionChanged(d);
}
void ListDevices::on_m_ListDevices_customContextMenuRequested(const QPoint& pos)
{
Q_ASSERT(actionCollection());
KMenu deviceMenu;
deviceMenu.addAction(actionCollection()->action("createNewPartitionTable"));
deviceMenu.exec(listDevices().viewport()->mapToGlobal(pos));
}

View File

@ -1,76 +0,0 @@
/***************************************************************************
* Copyright (C) 2008,2009 by Volker Lanz <vl@fidra.de> *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#if !defined(LISTDEVICES__H)
#define LISTDEVICES__H
#include "util/libpartitionmanagerexport.h"
#include "ui_listdevicesbase.h"
#include <QWidget>
#include <kdebug.h>
class Device;
class QPoint;
class PartitionManagerWidget;
class KActionCollection;
/** @brief A list of devices.
@author vl@fidra.de
*/
class LIBPARTITIONMANAGERPRIVATE_EXPORT ListDevices : public QWidget, public Ui::ListDevicesBase
{
Q_OBJECT
Q_DISABLE_COPY(ListDevices)
public:
ListDevices(QWidget* parent);
signals:
void selectionChanged(Device*);
public:
void init(KActionCollection* coll, PartitionManagerWidget* pm_widget) { m_ActionCollection = coll; m_PartitionManagerWidget = pm_widget; }
public slots:
void updateDevices();
protected:
QListWidget& listDevices() { Q_ASSERT(m_ListDevices); return *m_ListDevices; }
const QListWidget& listDevices() const { Q_ASSERT(m_ListDevices); return *m_ListDevices; }
PartitionManagerWidget& pmWidget() { Q_ASSERT(m_PartitionManagerWidget); return *m_PartitionManagerWidget; }
const PartitionManagerWidget& pmWidget() const { Q_ASSERT(m_PartitionManagerWidget); return *m_PartitionManagerWidget; }
KActionCollection* actionCollection() { return m_ActionCollection; }
protected slots:
void on_m_ListDevices_itemSelectionChanged();
void on_m_ListDevices_customContextMenuRequested(const QPoint& pos);
private:
KActionCollection* m_ActionCollection;
PartitionManagerWidget* m_PartitionManagerWidget;
};
#endif

View File

@ -1,37 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ListDevicesBase</class>
<widget class="QWidget" name="ListDevicesBase">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>255</width>
<height>396</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QListWidget" name="m_ListDevices">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="iconSize">
<size>
<width>32</width>
<height>32</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -61,7 +61,6 @@ void MainWindow::init()
setupStatusBar();
setupConnections();
listDevices().init(actionCollection(), &pmWidget());
listOperations().init(actionCollection(), &pmWidget());
pmWidget().init(actionCollection(), "partitionmanagerrc");
@ -124,7 +123,6 @@ void MainWindow::setupActions()
KStandardAction::quit(this, SLOT(close()), actionCollection());
// View actions
actionCollection()->addAction("toggleDockDevices", dockDevices().toggleViewAction());
actionCollection()->addAction("toggleDockOperations", dockOperations().toggleViewAction());
actionCollection()->addAction("toggleDockInformation", dockInformation().toggleViewAction());
actionCollection()->addAction("toggleDockLog", dockLog().toggleViewAction());
@ -168,8 +166,6 @@ void MainWindow::updateStatusBar()
void MainWindow::updateDevices()
{
listDevices().updateDevices();
if (pmWidget().selectedDevice())
infoPane().showDevice(dockWidgetArea(&dockInformation()), *pmWidget().selectedDevice());
else
@ -178,12 +174,6 @@ void MainWindow::updateDevices()
updateWindowTitle();
}
void MainWindow::on_m_ListDevices_selectionChanged(Device* d)
{
pmWidget().setSelectedDevice(d);
updateSelection(NULL);
}
void MainWindow::onDockLocationChanged(Qt::DockWidgetArea)
{
updateSelection(pmWidget().selectedPartition());

View File

@ -62,9 +62,6 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT MainWindow : public KXmlGuiWindow, publi
PartitionManagerWidget& pmWidget() { Q_ASSERT(m_PartitionManagerWidget); return *m_PartitionManagerWidget; }
const PartitionManagerWidget& pmWidget() const { Q_ASSERT(m_PartitionManagerWidget); return *m_PartitionManagerWidget; }
ListDevices& listDevices() { Q_ASSERT(m_ListDevices); return *m_ListDevices; }
const ListDevices& listDevices() const { Q_ASSERT(m_ListDevices); return *m_ListDevices; }
ListOperations& listOperations() { Q_ASSERT(m_ListOperations); return *m_ListOperations; }
const ListOperations& listOperations() const { Q_ASSERT(m_ListOperations); return *m_ListOperations; }
@ -74,9 +71,6 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT MainWindow : public KXmlGuiWindow, publi
QDockWidget& dockInformation() { Q_ASSERT(m_DockInformation); return *m_DockInformation; }
const QDockWidget& dockInformation() const { Q_ASSERT(m_DockInformation); return *m_DockInformation; }
QDockWidget& dockDevices() { Q_ASSERT(m_DockDevices); return *m_DockDevices; }
const QDockWidget& dockDevices() const { Q_ASSERT(m_DockDevices); return *m_DockDevices; }
QDockWidget& dockOperations() { Q_ASSERT(m_DockOperations); return *m_DockOperations; }
const QDockWidget& dockOperations() const { Q_ASSERT(m_DockOperations); return *m_DockOperations; }
@ -87,8 +81,6 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT MainWindow : public KXmlGuiWindow, publi
const QLabel& statusText() const { Q_ASSERT(m_StatusText); return *m_StatusText; }
protected slots:
void on_m_ListDevices_selectionChanged(Device* d);
void onDockLocationChanged(Qt::DockWidgetArea area);
void closeEvent(QCloseEvent*);

View File

@ -20,24 +20,6 @@
</item>
</layout>
</widget>
<widget class="QDockWidget" name="m_DockDevices">
<property name="allowedAreas">
<set>Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea</set>
</property>
<property name="windowTitle">
<string comment="@title:window">Devices</string>
</property>
<attribute name="dockWidgetArea">
<number>1</number>
</attribute>
<widget class="QWidget" name="m_DockDevicesContents">
<layout class="QVBoxLayout">
<item>
<widget class="ListDevices" name="m_ListDevices" native="true"/>
</item>
</layout>
</widget>
</widget>
<widget class="QDockWidget" name="m_DockOperations">
<property name="allowedAreas">
<set>Qt::BottomDockWidgetArea|Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea</set>
@ -93,12 +75,6 @@
<header>gui/partitionmanagerwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ListDevices</class>
<extends>QWidget</extends>
<header>gui/listdevices.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ListOperations</class>
<extends>QWidget</extends>

View File

@ -20,7 +20,6 @@
#include "kcm/partitionmanagerkcm.h"
#include "gui/partitionmanagerwidget.h"
#include "gui/listdevices.h"
#include "util/helpers.h"
@ -59,7 +58,6 @@ PartitionManagerKCM::PartitionManagerKCM(QWidget* parent, const QVariantList&) :
setButtons(Apply);
setupConnections();
listDevices().init(actionCollection(), &pmWidget());
listOperations().init(actionCollection(), &pmWidget());
pmWidget().init(actionCollection(), "kcm_partitionmanagerrc");
@ -104,9 +102,7 @@ void PartitionManagerKCM::onNewLogMessage(log::Level, const QString& s)
void PartitionManagerKCM::setupConnections()
{
connect(&pmWidget(), SIGNAL(devicesChanged()), &listDevices(), SLOT(updateDevices()));
connect(&pmWidget(), SIGNAL(operationsChanged()), &listOperations(), SLOT(updateOperations()));
connect(&listDevices(), SIGNAL(selectionChanged(Device*)), &pmWidget(), SLOT(setSelectedDevice(Device*)));
connect(&pmWidget(), SIGNAL(statusChanged()), SLOT(onStatusChanged()));
}

View File

@ -29,7 +29,6 @@
#include <kdebug.h>
class PartitionManagerWidget;
class ListDevices;
class KActionCollection;
class Device;
class KToolBar;
@ -52,7 +51,6 @@ class PartitionManagerKCM : public KCModule, public Ui::PartitionManagerKCMBase
void setupKCMWorkaround();
PartitionManagerWidget& pmWidget() { Q_ASSERT(m_PartitionManagerWidget); return *m_PartitionManagerWidget; }
ListDevices& listDevices() { Q_ASSERT(m_ListDevices); return *m_ListDevices; }
ListOperations& listOperations() { Q_ASSERT(m_ListOperations); return *m_ListOperations; }
QSplitter& splitterHorizontal() { Q_ASSERT(m_SplitterHorizontal); return *m_SplitterHorizontal; }
QSplitter& splitterVertical() { Q_ASSERT(m_SplitterVertical); return *m_SplitterVertical; }

View File

@ -1,43 +1,35 @@
<ui version="4.0" >
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PartitionManagerKCMBase</class>
<widget class="QWidget" name="PartitionManagerKCMBase" >
<property name="geometry" >
<widget class="QWidget" name="PartitionManagerKCMBase">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>684</width>
<height>684</height>
<width>763</width>
<height>712</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" >
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QSplitter" name="m_SplitterHorizontal" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
<widget class="QSplitter" name="m_SplitterVertical">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QSplitter" name="m_SplitterVertical" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
<widget class="KToolBar" name="m_ToolBar" native="true"/>
<widget class="QSplitter" name="m_SplitterHorizontal">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="ListDevices" native="1" name="m_ListDevices" >
<property name="minimumSize" >
<widget class="ListOperations" name="m_ListOperations" native="true">
<property name="minimumSize">
<size>
<width>170</width>
<width>200</width>
<height>0</height>
</size>
</property>
</widget>
<widget class="ListOperations" native="1" name="m_ListOperations" />
</widget>
<widget class="QWidget" name="layoutWidget" >
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
<widget class="KToolBar" native="1" name="m_ToolBar" />
</item>
<item>
<widget class="PartitionManagerWidget" native="1" name="m_PartitionManagerWidget" />
</item>
</layout>
<widget class="PartitionManagerWidget" name="m_PartitionManagerWidget" native="true"/>
</widget>
</widget>
</item>
@ -50,12 +42,6 @@
<header>gui/partitionmanagerwidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ListDevices</class>
<extends>QWidget</extends>
<header>gui/listdevices.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ListOperations</class>
<extends>QWidget</extends>
@ -65,7 +51,7 @@
<customwidget>
<class>KToolBar</class>
<extends>QWidget</extends>
<header location="global" >ktoolbar.h</header>
<header location="global">ktoolbar.h</header>
<container>1</container>
</customwidget>
</customwidgets>