mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 10:22:48 +00:00
plasma: proxy QTreeWidget instead of QTreeView
much more convenient, already testing it via experimental lsof applet Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
c72478ab01
commit
50a9aa403b
6 changed files with 26 additions and 50 deletions
|
@ -466,7 +466,7 @@ install(
|
|||
Plasma/ToolButton
|
||||
Plasma/ToolTipContent
|
||||
Plasma/ToolTipManager
|
||||
Plasma/TreeView
|
||||
Plasma/TreeWidget
|
||||
Plasma/CalendarWidget
|
||||
Plasma/View
|
||||
Plasma/Wallpaper
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
#include "../../plasma/widgets/treeview.h"
|
1
includes/Plasma/TreeWidget
Normal file
1
includes/Plasma/TreeWidget
Normal file
|
@ -0,0 +1 @@
|
|||
#include "../../plasma/widgets/treewidget.h"
|
|
@ -92,7 +92,7 @@ set(plasma_LIB_SRCS
|
|||
widgets/svgwidget.cpp
|
||||
widgets/tabbar.cpp
|
||||
widgets/textbrowser.cpp
|
||||
widgets/treeview.cpp
|
||||
widgets/treewidget.cpp
|
||||
widgets/textedit.cpp
|
||||
widgets/calendarwidget.cpp
|
||||
)
|
||||
|
@ -198,7 +198,7 @@ install(
|
|||
widgets/scrollwidget.h
|
||||
widgets/tabbar.h
|
||||
widgets/textbrowser.h
|
||||
widgets/treeview.h
|
||||
widgets/treewidget.h
|
||||
widgets/textedit.h
|
||||
widgets/calendarwidget.h
|
||||
DESTINATION ${KDE4_INCLUDE_INSTALL_DIR}/plasma/widgets
|
||||
|
|
|
@ -17,10 +17,9 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "treeview.h"
|
||||
#include "treewidget.h"
|
||||
|
||||
#include <QTreeView>
|
||||
#include <QHeaderView>
|
||||
#include <QTreeWidget>
|
||||
#include <QScrollBar>
|
||||
|
||||
#include <kiconloader.h>
|
||||
|
@ -30,17 +29,17 @@
|
|||
namespace Plasma
|
||||
{
|
||||
|
||||
class TreeViewPrivate
|
||||
class TreeWidgetPrivate
|
||||
{
|
||||
public:
|
||||
Plasma::Style::Ptr style;
|
||||
};
|
||||
|
||||
TreeView::TreeView(QGraphicsWidget *parent)
|
||||
TreeWidget::TreeWidget(QGraphicsWidget *parent)
|
||||
: QGraphicsProxyWidget(parent),
|
||||
d(new TreeViewPrivate)
|
||||
d(new TreeWidgetPrivate)
|
||||
{
|
||||
QTreeView *native = new QTreeView();
|
||||
QTreeWidget *native = new QTreeWidget();
|
||||
setWidget(native);
|
||||
native->setWindowIcon(QIcon());
|
||||
native->setAttribute(Qt::WA_NoSystemBackground);
|
||||
|
@ -51,28 +50,18 @@ TreeView::TreeView(QGraphicsWidget *parent)
|
|||
native->horizontalScrollBar()->setStyle(d->style.data());
|
||||
}
|
||||
|
||||
TreeView::~TreeView()
|
||||
TreeWidget::~TreeWidget()
|
||||
{
|
||||
delete d;
|
||||
Plasma::Style::doneWithSharedStyle();
|
||||
}
|
||||
|
||||
void TreeView::setModel(QAbstractItemModel *model)
|
||||
QTreeWidget *TreeWidget::nativeWidget() const
|
||||
{
|
||||
nativeWidget()->setModel(model);
|
||||
}
|
||||
|
||||
QAbstractItemModel *TreeView::model()
|
||||
{
|
||||
return nativeWidget()->model();
|
||||
}
|
||||
|
||||
QTreeView *TreeView::nativeWidget() const
|
||||
{
|
||||
return static_cast<QTreeView*>(widget());
|
||||
return static_cast<QTreeWidget*>(widget());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#include "moc_treeview.cpp"
|
||||
#include "moc_treewidget.cpp"
|
||||
|
|
@ -17,54 +17,41 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef PLASMA_TREEVIEW_H
|
||||
#define PLASMA_TREEVIEW_H
|
||||
#ifndef PLASMA_TREEWIDGET_H
|
||||
#define PLASMA_TREEWIDGET_H
|
||||
|
||||
#include <QtGui/QGraphicsProxyWidget>
|
||||
|
||||
#include <plasma/plasma_export.h>
|
||||
|
||||
#include <QTreeView>
|
||||
#include <QTreeWidget>
|
||||
#include <QAbstractItemModel>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class TreeViewPrivate;
|
||||
class TreeWidgetPrivate;
|
||||
|
||||
/**
|
||||
* @class TreeView plasma/widgets/treeview.h <Plasma/Widgets/TreeView>
|
||||
* @class TreeWidget plasma/widgets/treewidget.h <Plasma/Widgets/TreeWidget>
|
||||
*
|
||||
* @short Provides a plasma-themed QTreeView.
|
||||
* @short Provides a plasma-themed QTreeWidget.
|
||||
*/
|
||||
class PLASMA_EXPORT TreeView : public QGraphicsProxyWidget
|
||||
class PLASMA_EXPORT TreeWidget : public QGraphicsProxyWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QAbstractItemModel *model READ model WRITE setModel)
|
||||
|
||||
public:
|
||||
explicit TreeView(QGraphicsWidget *parent = 0);
|
||||
~TreeView();
|
||||
explicit TreeWidget(QGraphicsWidget *parent = 0);
|
||||
~TreeWidget();
|
||||
|
||||
/**
|
||||
* Sets a model for this weather view
|
||||
*
|
||||
* @param model the model to display
|
||||
* @return the native widget wrapped by this TreeWidget
|
||||
*/
|
||||
void setModel(QAbstractItemModel *model);
|
||||
|
||||
/**
|
||||
* @return the model shown by this view
|
||||
*/
|
||||
QAbstractItemModel *model();
|
||||
|
||||
/**
|
||||
* @return the native widget wrapped by this TreeView
|
||||
*/
|
||||
QTreeView *nativeWidget() const;
|
||||
QTreeWidget *nativeWidget() const;
|
||||
|
||||
private:
|
||||
TreeViewPrivate *const d;
|
||||
TreeWidgetPrivate *const d;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue