/*******************************************************
**
** Definition of QpuListView
**
** Copyright (C) 2004 Prashanth N Udupa
**
** QpuListView is an enhanced list view for providing
** XP look and feel left pane widget
** you and distribute and modify is under terms of GNU
** Library General Public License as published by the
** Free Software Foundation; either version 2, or (at
** your option) any later version.
**
********************************************************/
/***************************************************************************
QpuListView.h
-------------------
begin : Thu 03 June 2004
copyright : (C) 2004 by Prashanth Udupa
email : udupaprashanth@yahoo.com
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
/**
With contributions from Volker Götz
*/
#ifndef Qpu_LIST_VIEW_H
#define Qpu_LIST_VIEW_H
#include <q3listview.h>
//Added by qt3to4:
#include <QPixmap>
#include <QResizeEvent>
/**
Some notes
1. This list view should only be used for tree
structured single column data.
2. By default the first column is created.
3. Header is stretchable and is hidden
*/
class QpuListView;
class QpuListViewItem;
class QpuListViewItem : public Q3ListViewItem
{
public:
QpuListViewItem
(QpuListView
* parent,
const QString &text1
);
QpuListViewItem
(QpuListViewItem
* parent,
const QString &text2
);
~QpuListViewItem();
void setMinimumHeight(int height) { _MinHeight = height; }
int minimumHeight() const { return _MinHeight; }
int height() const;
void setup();
void paintCell
(QPainter* p,
const QColorGroup
&cg,
int column,
int width,
int align
);
void paintBranches
(QPainter* p,
const QColorGroup
&cg,
int w,
int y,
int h
);
void paintFocus
(QPainter *p,
const QColorGroup
&cg,
const QRect &r
);
virtual bool isWidgetItem() const { return false; }
QpuListViewItem
* findItem
(const QString &text
);
void setOpen(bool o);
friend class QpuListView;
friend class QpuPainter;
protected:
void invalidateChildrenHeight();
void setHeight(int height); // reimplemented from QListView
QpuListView* qpuListView() const {
return (QpuListView*)(listView());
}
protected:
enum ItemType {
TopLevelItem = 0,
ChildItem,
LastTopLevelItem
} _ItemType;
void setItemType(QpuListViewItem::ItemType type);
const QpuListViewItem* getItemBelow() const;
int belowDepthDiff();
int belowDepthDiff() const;
public:
QpuListViewItem* _ItemBelow;
private:
int _MinHeight;
};
class QpuWidgetItem : public QpuListViewItem
{
public:
// It would not look good if the top level list view item
// was a widget.
// QpuWidgetItem(QpuListView* parent, const QString &text1);
QpuWidgetItem
(QpuListViewItem
* parent,
QWidget* widget
=0);
~QpuWidgetItem();
void setAutoDelete(bool del);
bool autoDelete() const;
bool isWidgetItem() const { return true; }
void paintCell
(QPainter* p,
const QColorGroup
&cg,
int column,
int width,
int align
);
friend class QpuListView;
friend class QpuPainter;
protected:
virtual QWidget *createWidget
() { return 0;
}
public:
bool _AutoDelete;
};
class QpuListView : public Q3ListView
{
Q_OBJECT
public:
QpuListView
(QWidget* parent
=0,
const char *name
=0);
~QpuListView();
QpuListViewItem
* findItem
(const QString &text
) const;
void setLastItem(QpuListViewItem* item) { _LastItem = item; }
QpuListViewItem* lastItem() const { return _LastItem; }
void setXpLook(bool val);
bool getXpLook() const;
void clear();
protected slots:
void mouseOverItem(Q3ListViewItem* item);
void itemClicked(Q3ListViewItem *item);
void itemExpanded(Q3ListViewItem*);
protected:
protected:
bool _XpLook;
QpuListViewItem* _LastItem;
};
#endif
/*******************************************************
**
** Definition of QpuListView
**
** Copyright (C) 2004 Prashanth N Udupa
**
** QpuListView is an enhanced list view for providing
** XP look and feel left pane widget
** you and distribute and modify is under terms of GNU
** Library General Public License as published by the
** Free Software Foundation; either version 2, or (at
** your option) any later version.
**
********************************************************/
/***************************************************************************
QpuListView.h
-------------------
begin : Thu 03 June 2004
copyright : (C) 2004 by Prashanth Udupa
email : udupaprashanth@yahoo.com
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
/**
With contributions from Volker Götz
*/
#ifndef Qpu_LIST_VIEW_H
#define Qpu_LIST_VIEW_H
#include <q3listview.h>
//Added by qt3to4:
#include <QPixmap>
#include <QResizeEvent>
/**
Some notes
1. This list view should only be used for tree
structured single column data.
2. By default the first column is created.
3. Header is stretchable and is hidden
*/
class QpuListView;
class QpuListViewItem;
class QpuListViewItem : public Q3ListViewItem
{
public:
QpuListViewItem(QpuListView* parent, const QString &text1);
QpuListViewItem(QpuListViewItem* parent, const QString &text2);
~QpuListViewItem();
void setMinimumHeight(int height) { _MinHeight = height; }
int minimumHeight() const { return _MinHeight; }
int height() const;
void setup();
void paintCell(QPainter* p, const QColorGroup &cg, int column, int width, int align);
void paintBranches(QPainter* p, const QColorGroup &cg, int w, int y, int h);
void paintFocus(QPainter *p, const QColorGroup &cg, const QRect &r);
virtual bool isWidgetItem() const { return false; }
QpuListViewItem* findItem(const QString &text);
void setOpen(bool o);
friend class QpuListView;
friend class QpuPainter;
protected:
void invalidateChildrenHeight();
void setHeight(int height); // reimplemented from QListView
QRect itemRect() const;
QpuListView* qpuListView() const {
return (QpuListView*)(listView());
}
protected:
enum ItemType {
TopLevelItem = 0,
ChildItem,
LastTopLevelItem
} _ItemType;
void setItemType(QpuListViewItem::ItemType type);
const QpuListViewItem* getItemBelow() const;
int belowDepthDiff();
int belowDepthDiff() const;
public:
static QPixmap* DownArrow;
static QPixmap* UpArrow;
QpuListViewItem* _ItemBelow;
private:
int _MinHeight;
};
class QpuWidgetItem : public QpuListViewItem
{
public:
// It would not look good if the top level list view item
// was a widget.
// QpuWidgetItem(QpuListView* parent, const QString &text1);
QpuWidgetItem(QpuListViewItem* parent, QWidget* widget=0);
~QpuWidgetItem();
void setWidget(QWidget *widget);
QWidget* widget() const;
void setAutoDelete(bool del);
bool autoDelete() const;
bool isWidgetItem() const { return true; }
void paintCell(QPainter* p, const QColorGroup &cg, int column, int width, int align);
friend class QpuListView;
friend class QpuPainter;
protected:
virtual QWidget *createWidget() { return 0; }
public:
QWidget* _Widget;
bool _AutoDelete;
};
class QpuListView : public Q3ListView
{
Q_OBJECT
public:
QpuListView(QWidget* parent=0, const char *name=0);
~QpuListView();
QpuListViewItem* findItem(const QString &text) const;
void setLastItem(QpuListViewItem* item) { _LastItem = item; }
QpuListViewItem* lastItem() const { return _LastItem; }
void setXpLook(bool val);
bool getXpLook() const;
void clear();
protected slots:
void mouseOverItem(Q3ListViewItem* item);
void itemClicked(Q3ListViewItem *item);
void itemExpanded(Q3ListViewItem*);
protected:
void viewportResizeEvent ( QResizeEvent *e );
protected:
bool _XpLook;
QpuListViewItem* _LastItem;
};
#endif
To copy to clipboard, switch view to plain text mode
Bookmarks