2012-06-29 14:21:22 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2012 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef SKLISTWIDGET_H_
|
|
|
|
#define SKLISTWIDGET_H_
|
|
|
|
|
|
|
|
#include <QAbstractItemDelegate>
|
|
|
|
#include <QPainter>
|
|
|
|
|
|
|
|
/** \class SkListWidget
|
|
|
|
|
|
|
|
This widget contains the draw commands.
|
|
|
|
*/
|
|
|
|
class SkListWidget : public QAbstractItemDelegate {
|
|
|
|
public:
|
2014-03-25 23:31:33 +00:00
|
|
|
enum IndexStyle {
|
|
|
|
kIndex_IndexStyle,
|
|
|
|
kOffset_IndexStyle,
|
|
|
|
};
|
|
|
|
|
2012-06-29 14:21:22 +00:00
|
|
|
/**
|
|
|
|
Constructs the list widget with the specified parent for layout purposes.
|
|
|
|
@param parent The parent container of this widget
|
|
|
|
*/
|
2014-03-25 23:31:33 +00:00
|
|
|
SkListWidget(QObject* parent = NULL) : fIndexStyle(kIndex_IndexStyle) {}
|
2012-06-29 14:21:22 +00:00
|
|
|
|
2014-03-25 23:31:33 +00:00
|
|
|
virtual ~SkListWidget() {}
|
2012-06-29 14:21:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Draws the current state of the widget. Overriden from QWidget.
|
|
|
|
*/
|
2014-03-25 23:31:33 +00:00
|
|
|
void paint(QPainter* painter, const QStyleOptionViewItem& option,
|
|
|
|
const QModelIndex& index ) const;
|
2012-06-29 14:21:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the default size of the widget. Overriden from QWidget.
|
|
|
|
*/
|
2014-03-25 23:31:33 +00:00
|
|
|
QSize sizeHint(const QStyleOptionViewItem& option,
|
|
|
|
const QModelIndex& index) const;
|
|
|
|
|
|
|
|
|
|
|
|
void setIndexStyle(IndexStyle indexStyle) {
|
|
|
|
fIndexStyle = indexStyle;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
IndexStyle fIndexStyle;
|
2012-06-29 14:21:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|