Warning, file /pim/kalarm/src/eventlistview.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002  *  eventlistview.h  -  base class for widget showing list of alarms
0003  *  Program:  kalarm
0004  *  SPDX-FileCopyrightText: 2007-2022 David Jarvie <djarvie@kde.org>
0005  *
0006  *  SPDX-License-Identifier: GPL-2.0-or-later
0007  */
0008 
0009 #pragma once
0010 
0011 #include "kalarmcalendar/kaevent.h"
0012 
0013 #include <QTreeView>
0014 #include <QItemDelegate>
0015 
0016 class EventListModel;
0017 class Find;
0018 
0019 using namespace KAlarmCal;
0020 
0021 class EventListView : public QTreeView
0022 {
0023     Q_OBJECT
0024 public:
0025     explicit EventListView(QWidget* parent = nullptr);
0026     void              setModel(QAbstractItemModel*) override;
0027     EventListModel*   itemModel() const;
0028     KAEvent           event(int row) const;
0029     KAEvent           event(const QModelIndex&) const;
0030     void              select(const QModelIndex&, bool scrollToIndex = false);
0031     QModelIndex       selectedIndex() const;
0032     KAEvent           selectedEvent() const;
0033     QList<KAEvent>    selectedEvents() const;
0034     void              setEditOnSingleClick(bool e) { mEditOnSingleClick = e; }
0035     bool              editOnSingleClick() const    { return mEditOnSingleClick; }
0036 
0037 public Q_SLOTS:
0038     virtual void      slotFind();
0039     virtual void      slotFindNext()       { findNext(true); }
0040     virtual void      slotFindPrev()       { findNext(false); }
0041 
0042 Q_SIGNALS:
0043     void              contextMenuRequested(const QPoint& globalPos);
0044     void              findActive(bool);
0045 
0046 protected:
0047     void              resizeEvent(QResizeEvent*) override;
0048     bool              viewportEvent(QEvent*) override;
0049     void              contextMenuEvent(QContextMenuEvent*) override;
0050     QStyleOptionViewItem listViewOptions() const;
0051 
0052 protected Q_SLOTS:
0053     virtual void      initSections() = 0;
0054     void              sortChanged(int column, Qt::SortOrder);
0055 
0056 private:
0057     void              findNext(bool forward);
0058 
0059     Find*             mFind {nullptr};
0060     bool              mEditOnSingleClick {false};
0061 
0062     using QObject::event;   // prevent "hidden" warning
0063 };
0064 
0065 class EventListDelegate : public QItemDelegate
0066 {
0067         Q_OBJECT
0068     public:
0069         explicit EventListDelegate(EventListView* parent = nullptr) : QItemDelegate(parent) {}
0070         QWidget*     createEditor(QWidget*, const QStyleOptionViewItem&, const QModelIndex&) const override  { return nullptr; }
0071         bool         editorEvent(QEvent*, QAbstractItemModel*, const QStyleOptionViewItem&, const QModelIndex&) override;
0072         virtual void edit(KAEvent&, EventListView*) = 0;
0073 };
0074 
0075 // vim: et sw=4: