superkaramba
kwidgetlistbox.h
Go to the documentation of this file.00001 /* 00002 * Copyright (C) 2005 Petri Damst� <petri.damsten@iki.fi> 00003 * 00004 * This file is part of SuperKaramba. 00005 * 00006 * SuperKaramba is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * SuperKaramba is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with SuperKaramba; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 ****************************************************************************/ 00020 #ifndef KWIDGETLISTBOX_H 00021 #define KWIDGETLISTBOX_H 00022 00023 #include "themewidget.h" 00024 00025 #include <QTableWidget> 00026 #include <QShowEvent> 00027 #include <QHeaderView> 00028 #include <QPoint> 00029 00034 typedef bool(*show_callback)(int index, QWidget* widget, void* data); 00035 00036 class KWidgetListbox : public QTableWidget 00037 { 00038 Q_OBJECT 00039 00040 public: 00041 explicit KWidgetListbox(QWidget *parent = 0); 00042 ~KWidgetListbox(); 00043 00044 int insertItem(QWidget* item, int index = -1); 00045 void setSelected(QWidget* item); 00046 void setSelected(int index); 00047 void removeItem(QWidget* item); 00048 void removeItem(int index); 00049 void clear(); 00050 int selected() const; 00051 QWidget* selectedItem() const; 00052 QWidget* item(int index) const; 00053 int index(QWidget* itm) const; 00054 uint count() const 00055 { 00056 return rowCount(); 00057 } 00058 00059 void showItems(show_callback func = 0, void* data = 0); 00060 00061 protected: 00062 virtual void showEvent(QShowEvent* e); 00063 virtual void mousePressEvent(QMouseEvent *event); 00064 virtual void mouseMoveEvent(QMouseEvent *event); 00065 00066 protected slots: 00067 void selectionChanged(int row, int col); 00068 00069 signals: 00070 void selected(int index); 00071 void itemDropped(QPoint, ThemeWidget*); 00072 00073 private: 00074 QPoint m_dragStartPosition; 00075 }; 00076 00077 #endif
KDE 4.0 API Reference