revert 1077129: re-add devices list. this is just not usable with >4 devices
svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1081529
This commit is contained in:
parent
4503707e9d
commit
16dae55d04
|
@ -0,0 +1,85 @@
|
|||
/***************************************************************************
|
||||
* 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));
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
/***************************************************************************
|
||||
* 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
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
<?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>
|
|
@ -61,6 +61,7 @@ void MainWindow::init()
|
|||
setupStatusBar();
|
||||
setupConnections();
|
||||
|
||||
listDevices().init(actionCollection(), &pmWidget());
|
||||
listOperations().init(actionCollection(), &pmWidget());
|
||||
pmWidget().init(actionCollection(), "partitionmanagerrc");
|
||||
|
||||
|
@ -123,6 +124,7 @@ 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());
|
||||
|
@ -166,6 +168,8 @@ void MainWindow::updateStatusBar()
|
|||
|
||||
void MainWindow::updateDevices()
|
||||
{
|
||||
listDevices().updateDevices();
|
||||
|
||||
if (pmWidget().selectedDevice())
|
||||
infoPane().showDevice(dockWidgetArea(&dockInformation()), *pmWidget().selectedDevice());
|
||||
else
|
||||
|
@ -174,6 +178,12 @@ 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());
|
||||
|
|
|
@ -62,6 +62,9 @@ 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; }
|
||||
|
||||
|
@ -71,6 +74,9 @@ 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; }
|
||||
|
||||
|
@ -81,6 +87,8 @@ 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*);
|
||||
|
|
|
@ -20,6 +20,24 @@
|
|||
</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>
|
||||
|
@ -75,6 +93,12 @@
|
|||
<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>
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "kcm/partitionmanagerkcm.h"
|
||||
|
||||
#include "gui/partitionmanagerwidget.h"
|
||||
#include "gui/listdevices.h"
|
||||
|
||||
#include "util/helpers.h"
|
||||
|
||||
|
@ -58,6 +59,7 @@ PartitionManagerKCM::PartitionManagerKCM(QWidget* parent, const QVariantList&) :
|
|||
setButtons(Apply);
|
||||
setupConnections();
|
||||
|
||||
listDevices().init(actionCollection(), &pmWidget());
|
||||
listOperations().init(actionCollection(), &pmWidget());
|
||||
pmWidget().init(actionCollection(), "kcm_partitionmanagerrc");
|
||||
|
||||
|
@ -102,7 +104,9 @@ 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()));
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <kdebug.h>
|
||||
|
||||
class PartitionManagerWidget;
|
||||
class ListDevices;
|
||||
class KActionCollection;
|
||||
class Device;
|
||||
class KToolBar;
|
||||
|
@ -51,6 +52,7 @@ 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; }
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0" >
|
||||
<class>PartitionManagerKCMBase</class>
|
||||
<widget class="QWidget" name="PartitionManagerKCMBase" >
|
||||
|
@ -6,30 +5,39 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>763</width>
|
||||
<height>712</height>
|
||||
<width>684</width>
|
||||
<height>684</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2" >
|
||||
<item>
|
||||
<widget class="QSplitter" name="m_SplitterVertical">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<widget class="KToolBar" name="m_ToolBar" native="true"/>
|
||||
<widget class="QSplitter" name="m_SplitterHorizontal" >
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<widget class="ListOperations" name="m_ListOperations" native="true">
|
||||
<widget class="QSplitter" name="m_SplitterVertical" >
|
||||
<property name="orientation" >
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<widget class="ListDevices" native="1" name="m_ListDevices" >
|
||||
<property name="minimumSize" >
|
||||
<size>
|
||||
<width>200</width>
|
||||
<width>170</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="PartitionManagerWidget" name="m_PartitionManagerWidget" native="true"/>
|
||||
<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>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -42,6 +50,12 @@
|
|||
<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>
|
||||
|
|
Loading…
Reference in New Issue