Move QTreeWidget for the log output to its own class.
svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=957548
This commit is contained in:
parent
0ff681dd8d
commit
1fa99f0341
|
@ -94,7 +94,9 @@ MainWindow::MainWindow(QWidget* parent, KActionCollection* coll) :
|
|||
|
||||
void MainWindow::init()
|
||||
{
|
||||
connect(GlobalLog::instance(), SIGNAL(newMessage(log::Level, const QString&)), SLOT(onNewLogMessage(log::Level, const QString&)));
|
||||
treeLog().init(actionCollection(), &pmWidget());
|
||||
|
||||
connect(GlobalLog::instance(), SIGNAL(newMessage(log::Level, const QString&)), &treeLog(), SLOT(onNewLogMessage(log::Level, const QString&)));
|
||||
|
||||
setupActions();
|
||||
setupStatusBar();
|
||||
|
@ -245,28 +247,3 @@ void MainWindow::updateSelection(const Partition* p)
|
|||
updateWindowTitle();
|
||||
}
|
||||
|
||||
void MainWindow::onNewLogMessage(log::Level logLevel, const QString& s)
|
||||
{
|
||||
static const char* icons[] =
|
||||
{
|
||||
"tools-report-bug",
|
||||
"dialog-information",
|
||||
"dialog-warning",
|
||||
"dialog-error"
|
||||
};
|
||||
|
||||
kDebug() << s;
|
||||
|
||||
QTreeWidgetItem* item = new QTreeWidgetItem();
|
||||
|
||||
item->setIcon(0, SmallIcon(icons[logLevel]));
|
||||
item->setText(0, QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"));
|
||||
item->setText(1, s);
|
||||
|
||||
treeLog().addTopLevelItem(item);
|
||||
|
||||
for (int i = 0; i < treeLog().model()->columnCount(); i++)
|
||||
treeLog().resizeColumnToContents(i);
|
||||
|
||||
treeLog().scrollToBottom();
|
||||
}
|
||||
|
|
|
@ -70,6 +70,9 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT MainWindow : public KXmlGuiWindow, publi
|
|||
ListOperations& listOperations() { Q_ASSERT(m_ListOperations); return *m_ListOperations; }
|
||||
const ListOperations& listOperations() const { Q_ASSERT(m_ListOperations); return *m_ListOperations; }
|
||||
|
||||
TreeLog& treeLog() { Q_ASSERT(m_TreeLog); return *m_TreeLog; }
|
||||
const TreeLog& treeLog() const { Q_ASSERT(m_TreeLog); return *m_TreeLog; }
|
||||
|
||||
QDockWidget& dockInformation() { Q_ASSERT(m_DockInformation); return *m_DockInformation; }
|
||||
const QDockWidget& dockInformation() const { Q_ASSERT(m_DockInformation); return *m_DockInformation; }
|
||||
|
||||
|
@ -82,9 +85,6 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT MainWindow : public KXmlGuiWindow, publi
|
|||
QDockWidget& dockLog() { Q_ASSERT(m_DockLog); return *m_DockLog; }
|
||||
const QDockWidget& dockLog() const { Q_ASSERT(m_DockLog); return *m_DockLog; }
|
||||
|
||||
QTreeWidget& treeLog() { Q_ASSERT(m_TreeLog); return *m_TreeLog; }
|
||||
const QTreeWidget& treeLog() const { Q_ASSERT(m_TreeLog); return *m_TreeLog; }
|
||||
|
||||
QLabel& statusText() { Q_ASSERT(m_StatusText); return *m_StatusText; }
|
||||
const QLabel& statusText() const { Q_ASSERT(m_StatusText); return *m_StatusText; }
|
||||
|
||||
|
@ -94,11 +94,9 @@ class LIBPARTITIONMANAGERPRIVATE_EXPORT MainWindow : public KXmlGuiWindow, publi
|
|||
void closeEvent(QCloseEvent*);
|
||||
void changeEvent(QEvent* event);
|
||||
|
||||
void onNewLogMessage(log::Level logLevel, const QString& s);
|
||||
void init();
|
||||
void updateDevices();
|
||||
void updateStatusBar();
|
||||
// void updateOperations();
|
||||
void updateSelection(const Partition* p);
|
||||
|
||||
private:
|
||||
|
|
|
@ -82,45 +82,7 @@
|
|||
<widget class="QWidget" name="dockWidgetContents" >
|
||||
<layout class="QGridLayout" name="gridLayout" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QTreeWidget" name="m_TreeLog" >
|
||||
<property name="autoScroll" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="selectionMode" >
|
||||
<enum>QAbstractItemView::NoSelection</enum>
|
||||
</property>
|
||||
<property name="textElideMode" >
|
||||
<enum>Qt::ElideNone</enum>
|
||||
</property>
|
||||
<property name="indentation" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rootIsDecorated" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="itemsExpandable" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="wordWrap" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="headerHidden" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="expandsOnDoubleClick" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text" >
|
||||
<string>Time</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text" >
|
||||
<string>Message</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
<widget class="TreeLog" native="1" name="m_TreeLog" />
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -145,6 +107,12 @@
|
|||
<header>gui/listoperations.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>TreeLog</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>gui/treelog.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
/***************************************************************************
|
||||
* 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/treelog.h"
|
||||
|
||||
#include "gui/partitionmanagerwidget.h"
|
||||
|
||||
#include "util/globallog.h"
|
||||
|
||||
#include <kactioncollection.h>
|
||||
#include <kdebug.h>
|
||||
#include <kiconloader.h>
|
||||
|
||||
#include <QTreeWidget>
|
||||
#include <QDateTime>
|
||||
|
||||
/** Creates a new TreeLog instance.
|
||||
@param parent the parent widget
|
||||
*/
|
||||
TreeLog::TreeLog(QWidget* parent) :
|
||||
QWidget(parent),
|
||||
Ui::TreeLogBase(),
|
||||
m_ActionCollection(NULL),
|
||||
m_PartitionManagerWidget(NULL)
|
||||
{
|
||||
setupUi(this);
|
||||
}
|
||||
|
||||
void TreeLog::onNewLogMessage(log::Level logLevel, const QString& s)
|
||||
{
|
||||
static const char* icons[] =
|
||||
{
|
||||
"tools-report-bug",
|
||||
"dialog-information",
|
||||
"dialog-warning",
|
||||
"dialog-error"
|
||||
};
|
||||
|
||||
kDebug() << s;
|
||||
|
||||
QTreeWidgetItem* item = new QTreeWidgetItem();
|
||||
|
||||
item->setIcon(0, SmallIcon(icons[logLevel]));
|
||||
item->setText(0, QDateTime::currentDateTime().toString("yyyy-MM-dd hh:mm:ss"));
|
||||
item->setText(1, s);
|
||||
|
||||
treeLog().addTopLevelItem(item);
|
||||
|
||||
for (int i = 0; i < treeLog().model()->columnCount(); i++)
|
||||
treeLog().resizeColumnToContents(i);
|
||||
|
||||
treeLog().scrollToBottom();
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
/***************************************************************************
|
||||
* 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(TREELOG__H)
|
||||
|
||||
#define TREELOG__H
|
||||
|
||||
#include "util/libpartitionmanagerexport.h"
|
||||
|
||||
#include "ui_treelogbase.h"
|
||||
|
||||
#include "util/globallog.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include <kdebug.h>
|
||||
|
||||
class PartitionManagerWidget;
|
||||
class KActionCollection;
|
||||
class QTreeWidget;
|
||||
|
||||
/** @brief A tree for formatted log output.
|
||||
@author vl@fidra.de
|
||||
*/
|
||||
class LIBPARTITIONMANAGERPRIVATE_EXPORT TreeLog: public QWidget, public Ui::TreeLogBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
TreeLog(QWidget* parent);
|
||||
|
||||
public:
|
||||
void init(KActionCollection* coll, PartitionManagerWidget* pm_widget) { m_ActionCollection = coll; m_PartitionManagerWidget = pm_widget; }
|
||||
|
||||
public slots:
|
||||
void onNewLogMessage(log::Level logLevel, const QString& s);
|
||||
|
||||
protected:
|
||||
QTreeWidget& treeLog() { Q_ASSERT(m_TreeLog); return *m_TreeLog; }
|
||||
const QTreeWidget& treeLog() const { Q_ASSERT(m_TreeLog); return *m_TreeLog; }
|
||||
|
||||
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:
|
||||
|
||||
private:
|
||||
KActionCollection* m_ActionCollection;
|
||||
PartitionManagerWidget* m_PartitionManagerWidget;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
<ui version="4.0" >
|
||||
<class>TreeLogBase</class>
|
||||
<widget class="QWidget" name="TreeLogBase" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>565</width>
|
||||
<height>209</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" >
|
||||
<item>
|
||||
<widget class="QTreeWidget" name="m_TreeLog" >
|
||||
<property name="autoScroll" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="selectionMode" >
|
||||
<enum>QAbstractItemView::NoSelection</enum>
|
||||
</property>
|
||||
<property name="textElideMode" >
|
||||
<enum>Qt::ElideNone</enum>
|
||||
</property>
|
||||
<property name="indentation" >
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rootIsDecorated" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="itemsExpandable" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="wordWrap" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="headerHidden" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="expandsOnDoubleClick" >
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text" >
|
||||
<string>Time</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text" >
|
||||
<string>Message</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Reference in New Issue