kalarm
eventlistview.h
Go to the documentation of this file.00001 /* 00002 * eventlistview.h - base class for widget showing list of alarms 00003 * Program: kalarm 00004 * Copyright © 2007,2008 by David Jarvie <djarvie@kde.org> 00005 * 00006 * This program 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 * This program 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 along 00017 * with this program; if not, write to the Free Software Foundation, Inc., 00018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef EVENTLISTVIEW_H 00022 #define EVENTLISTVIEW_H 00023 00024 #include "kalarm.h" 00025 00026 #include <QTreeView> 00027 #include <QItemDelegate> 00028 00029 #include <kcal/event.h> 00030 00031 #include "eventlistmodel.h" 00032 00033 class Find; 00034 00035 00036 class EventListView : public QTreeView 00037 { 00038 Q_OBJECT 00039 public: 00040 explicit EventListView(QWidget* parent = 0); 00041 EventListFilterModel* eventFilterModel() const { return static_cast<EventListFilterModel*>(model()); } 00042 EventListModel* eventModel() const { return static_cast<EventListModel*>(static_cast<QAbstractProxyModel*>(model())->sourceModel()); } 00043 KAEvent* event(int row) const; 00044 KAEvent* event(const QModelIndex&) const; 00045 void select(const QString& eventId); 00046 void select(const QModelIndex&); 00047 QModelIndex selectedIndex() const; 00048 KAEvent* selectedEvent() const; 00049 KAEvent::List selectedEvents() const; 00050 void setEditOnSingleClick(bool e) { mEditOnSingleClick = e; } 00051 bool editOnSingleClick() const { return mEditOnSingleClick; } 00052 00053 public slots: 00054 virtual void slotFind(); 00055 virtual void slotFindNext() { findNext(true); } 00056 virtual void slotFindPrev() { findNext(false); } 00057 00058 signals: 00059 void contextMenuRequested(const QPoint& globalPos); 00060 void findActive(bool); 00061 00062 protected: 00063 virtual bool viewportEvent(QEvent*); 00064 virtual void contextMenuEvent(QContextMenuEvent*); 00065 00066 private: 00067 void findNext(bool forward); 00068 00069 Find* mFind; 00070 bool mEditOnSingleClick; 00071 00072 using QObject::event; // prevent "hidden" warning 00073 }; 00074 00075 class EventListDelegate : public QItemDelegate 00076 { 00077 Q_OBJECT 00078 public: 00079 explicit EventListDelegate(EventListView* parent = 0) : QItemDelegate(parent) {} 00080 virtual QWidget* createEditor(QWidget*, const QStyleOptionViewItem&, const QModelIndex&) const { return 0; } 00081 virtual bool editorEvent(QEvent*, QAbstractItemModel*, const QStyleOptionViewItem&, const QModelIndex&); 00082 virtual void edit(KAEvent*, EventListView*) = 0; 00083 }; 00084 00085 #endif // EVENTLISTVIEW_H 00086
KDE 4.2 API Reference