a tree view widget for now there is only this one that should be enough
also for simple lists to not overpopulate the widget list svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=850021
This commit is contained in:
parent
ddf2c2cf5d
commit
7fb9508d80
@ -82,6 +82,7 @@ set(plasma_LIB_SRCS
|
||||
widgets/signalplotter.cpp
|
||||
widgets/slider.cpp
|
||||
widgets/tabbar.cpp
|
||||
widgets/treeview.cpp
|
||||
widgets/textedit.cpp
|
||||
widgets/webcontent.cpp
|
||||
)
|
||||
@ -189,6 +190,7 @@ install(FILES
|
||||
widgets/signalplotter.h
|
||||
widgets/slider.h
|
||||
widgets/tabbar.h
|
||||
widgets/treeview.h
|
||||
widgets/textedit.h
|
||||
widgets/webcontent.h
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/plasma/widgets COMPONENT Devel)
|
||||
@ -252,6 +254,7 @@ includes/TabBar
|
||||
includes/TextEdit
|
||||
includes/ToolTipManager
|
||||
includes/Theme
|
||||
includes/TreeView
|
||||
includes/UiLoader
|
||||
includes/View
|
||||
includes/Version
|
||||
|
1
includes/TreeView
Normal file
1
includes/TreeView
Normal file
@ -0,0 +1 @@
|
||||
#include "../../plasma/widgets/treeview.h"
|
90
widgets/treeview.cpp
Normal file
90
widgets/treeview.cpp
Normal file
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright 2008 Marco Martin <notmart@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, 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 Library 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 "treeview.h"
|
||||
|
||||
#include <QTreeView>
|
||||
#include <QHeaderView>
|
||||
#include <QScrollBar>
|
||||
|
||||
#include <KIconLoader>
|
||||
|
||||
#include "private/style.h"
|
||||
|
||||
|
||||
class TreeViewPrivate
|
||||
{
|
||||
public:
|
||||
TreeViewPrivate()
|
||||
{
|
||||
}
|
||||
|
||||
~TreeViewPrivate()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
TreeView::TreeView(QGraphicsWidget *parent)
|
||||
: QGraphicsProxyWidget(parent),
|
||||
d(new TreeViewPrivate)
|
||||
{
|
||||
QTreeView* native = new QTreeView;
|
||||
setWidget(native);
|
||||
native->setAttribute(Qt::WA_NoSystemBackground);
|
||||
native->viewport()->setAutoFillBackground(false);
|
||||
native->setFrameStyle(QFrame::NoFrame);
|
||||
native->setIconSize(QSize(KIconLoader::SizeSmallMedium, KIconLoader::SizeSmallMedium));
|
||||
|
||||
Plasma::Style *style = new Plasma::Style();
|
||||
native->verticalScrollBar()->setStyle(style);
|
||||
native->horizontalScrollBar()->setStyle(style);
|
||||
}
|
||||
|
||||
TreeView::~TreeView()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void TreeView::setModel(QAbstractItemModel *model)
|
||||
{
|
||||
nativeWidget()->setModel(model);
|
||||
}
|
||||
|
||||
QAbstractItemModel *TreeView::model()
|
||||
{
|
||||
return nativeWidget()->model();
|
||||
}
|
||||
|
||||
void TreeView::setStyleSheet(const QString &stylesheet)
|
||||
{
|
||||
widget()->setStyleSheet(stylesheet);
|
||||
}
|
||||
|
||||
QString TreeView::styleSheet()
|
||||
{
|
||||
return widget()->styleSheet();
|
||||
}
|
||||
|
||||
QTreeView* TreeView::nativeWidget() const
|
||||
{
|
||||
return static_cast<QTreeView*>(widget());
|
||||
}
|
||||
|
||||
#include <treeview.moc>
|
||||
|
78
widgets/treeview.h
Normal file
78
widgets/treeview.h
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright 2008 Marco Martin <notmart@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as
|
||||
* published by the Free Software Foundation; either version 2, 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 Library 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.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef PLASMA_TREEVIEW_H
|
||||
#define PLASMA_TREEVIEW_H
|
||||
|
||||
#include <QtGui/QGraphicsProxyWidget>
|
||||
|
||||
class QTreeView;
|
||||
class QAbstractItemModel;
|
||||
|
||||
|
||||
class TreeViewPrivate;
|
||||
|
||||
class TreeView : public QGraphicsProxyWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QAbstractItemModel* model READ model WRITE setModel)
|
||||
Q_PROPERTY(QGraphicsWidget* parentWidget READ parentWidget)
|
||||
Q_PROPERTY(QString styleSheet READ styleSheet WRITE setStyleSheet)
|
||||
Q_PROPERTY(QTreeView* nativeWidget READ nativeWidget)
|
||||
|
||||
public:
|
||||
explicit TreeView(QGraphicsWidget *parent = 0);
|
||||
~TreeView();
|
||||
|
||||
/**
|
||||
* Sets a model for this weather view
|
||||
*
|
||||
* @arg model the model to display
|
||||
*/
|
||||
void setModel(QAbstractItemModel *model);
|
||||
|
||||
/**
|
||||
* @return the model shown by this view
|
||||
*/
|
||||
QAbstractItemModel *model();
|
||||
|
||||
/**
|
||||
* Sets the stylesheet used to control the visual display of this TreeView
|
||||
*
|
||||
* @arg stylesheet a CSS string
|
||||
*/
|
||||
void setStyleSheet(const QString &stylesheet);
|
||||
|
||||
/**
|
||||
* @return the stylesheet currently used with this widget
|
||||
*/
|
||||
QString styleSheet();
|
||||
|
||||
/**
|
||||
* @return the native widget wrapped by this TreeView
|
||||
*/
|
||||
QTreeView* nativeWidget() const;
|
||||
|
||||
private:
|
||||
TreeViewPrivate * const d;
|
||||
};
|
||||
|
||||
#endif // multiple inclusion guard
|
Loading…
x
Reference in New Issue
Block a user