[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdepim/kalarm
From: David Jarvie <software () astrojar ! org ! uk>
Date: 2008-07-11 23:28:23
Message-ID: 1215818903.708297.15459.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 831154 by djarvie:
Make single click/double click policy work for template list
M +2 -39 alarmlistdelegate.cpp
M +6 -8 alarmlistdelegate.h
M +37 -0 eventlistview.cpp
M +11 -0 eventlistview.h
M +1 -2 mainwindow.cpp
M +0 -1 mainwindow.h
M +1 -0 templatedlg.cpp
M +8 -1 templatelistview.cpp
M +13 -4 templatelistview.h
--- trunk/KDE/kdepim/kalarm/alarmlistdelegate.cpp #831153:831154
@@ -34,11 +34,6 @@
#include "alarmlistdelegate.moc"
-AlarmListDelegate::AlarmListDelegate(AlarmListView* parent)
- : QItemDelegate(parent)
-{
-}
-
void AlarmListDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, \
const QModelIndex& index) const {
if (index.isValid() && index.column() == EventListModel::TimeColumn)
@@ -100,39 +95,7 @@
return QItemDelegate::sizeHint(option, index);
}
-bool AlarmListDelegate::editorEvent(QEvent* e, QAbstractItemModel* model, const \
QStyleOptionViewItem&, const QModelIndex& index) +void \
AlarmListDelegate::edit(KAEvent* event, EventListView* view) {
- // Don't invoke the editor unless it's either a double click or,
- // if KDE is in single click mode and it's a left button release
- // with no other buttons pressed and no keyboard modifiers.
- switch (e->type())
- {
- case QEvent::MouseButtonPress:
- case QEvent::MouseMove:
- return false;
- case QEvent::MouseButtonDblClick:
- break;
- case QEvent::MouseButtonRelease:
- {
- if (!KGlobalSettings::singleClick())
- return false;
- QMouseEvent* me = static_cast<QMouseEvent*>(e);
- if (me->button() != Qt::LeftButton || me->buttons()
- || me->modifiers() != Qt::NoModifier)
- return false;
- break;
- }
- default:
- break;
- }
- kDebug();
- AlarmListView* view = static_cast<AlarmListView*>(parent());
- if (index.isValid())
- {
- QModelIndex source = static_cast<QAbstractProxyModel*>(model)->mapToSource(index);
- KAEvent* event = static_cast<KAEvent*>(source.internalPointer());
- KAlarm::editAlarm(event, view); // edit alarm (view-only mode if archived or \
read-only)
- return true;
- }
- return false; // indicate that the event has not been handled
+ KAlarm::editAlarm(event, static_cast<AlarmListView*>(view)); // edit alarm \
(view-only mode if archived or read-only) }
--- trunk/KDE/kdepim/kalarm/alarmlistdelegate.h #831153:831154
@@ -1,7 +1,7 @@
/*
* alarmlistdelegate.h - handles editing and display of alarm list
* Program: kalarm
- * Copyright © 2007 by David Jarvie <software@astrojar.org.uk>
+ * Copyright © 2007,2008 by David Jarvie <djarvie@kde.org>
*
* 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
@@ -23,20 +23,18 @@
#include "kalarm.h"
-#include <QItemDelegate>
+#include "alarmlistview.h"
-class AlarmListView;
-
-class AlarmListDelegate : public QItemDelegate
+class AlarmListDelegate : public EventListDelegate
{
Q_OBJECT
public:
- explicit AlarmListDelegate(AlarmListView* parent = 0);
- virtual QWidget* createEditor(QWidget*, const QStyleOptionViewItem&, const \
QModelIndex&) const { return 0; } + explicit AlarmListDelegate(AlarmListView* \
parent = 0) + : EventListDelegate(parent) {}
virtual void paint(QPainter*, const QStyleOptionViewItem&, const QModelIndex&) \
const; virtual QSize sizeHint(const QStyleOptionViewItem&, const QModelIndex&) \
const;
- virtual bool editorEvent(QEvent*, QAbstractItemModel*, const \
QStyleOptionViewItem&, const QModelIndex&); + virtual void edit(KAEvent*, \
EventListView*); };
#endif
--- trunk/KDE/kdepim/kalarm/eventlistview.cpp #831153:831154
@@ -185,3 +185,40 @@
{
emit contextMenuRequested(e->globalPos());
}
+
+
+bool EventListDelegate::editorEvent(QEvent* e, QAbstractItemModel* model, const \
QStyleOptionViewItem&, const QModelIndex& index) +{
+ // Don't invoke the editor unless it's either a double click or,
+ // if KDE is in single click mode and it's a left button release
+ // with no other buttons pressed and no keyboard modifiers.
+ switch (e->type())
+ {
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseMove:
+ return false;
+ case QEvent::MouseButtonDblClick:
+ break;
+ case QEvent::MouseButtonRelease:
+ {
+ if (!KGlobalSettings::singleClick())
+ return false;
+ QMouseEvent* me = static_cast<QMouseEvent*>(e);
+ if (me->button() != Qt::LeftButton || me->buttons()
+ || me->modifiers() != Qt::NoModifier)
+ return false;
+ break;
+ }
+ default:
+ break;
+ }
+ if (index.isValid())
+ {
+ kDebug();
+ QModelIndex source = static_cast<QAbstractProxyModel*>(model)->mapToSource(index);
+ KAEvent* event = static_cast<KAEvent*>(source.internalPointer());
+ edit(event, static_cast<EventListView*>(parent()));
+ return true;
+ }
+ return false; // indicate that the event has not been handled
+}
--- trunk/KDE/kdepim/kalarm/eventlistview.h #831153:831154
@@ -24,6 +24,7 @@
#include "kalarm.h"
#include <QTreeView>
+#include <QItemDelegate>
#include <kcal/event.h>
@@ -68,5 +69,15 @@
using QObject::event; // prevent "hidden" warning
};
+class EventListDelegate : public QItemDelegate
+{
+ Q_OBJECT
+ public:
+ explicit EventListDelegate(EventListView* parent = 0) : QItemDelegate(parent) {}
+ virtual QWidget* createEditor(QWidget*, const QStyleOptionViewItem&, const \
QModelIndex&) const { return 0; } + virtual bool editorEvent(QEvent*, \
QAbstractItemModel*, const QStyleOptionViewItem&, const QModelIndex&); + virtual \
void edit(KAEvent*, EventListView*) = 0; +};
+
#endif // EVENTLISTVIEW_H
--- trunk/KDE/kdepim/kalarm/mainwindow.cpp #831153:831154
@@ -173,8 +173,7 @@
mListView->setModel(mListFilterModel);
mListView->selectTimeColumns(mShowTime, mShowTimeTo);
mListView->sortByColumn(mShowTime ? EventListModel::TimeColumn : \
EventListModel::TimeToColumn, Qt::AscendingOrder);
- mListDelegate = new AlarmListDelegate(mListView);
- mListView->setItemDelegate(mListDelegate);
+ mListView->setItemDelegate(new AlarmListDelegate(mListView));
connect(mListView->selectionModel(), SIGNAL(selectionChanged(const \
QItemSelection&,const QItemSelection&)), SLOT(slotSelection())); connect(mListView, \
SIGNAL(contextMenuRequested(const QPoint&)), SLOT(slotContextMenuRequested(const \
QPoint&))); connect(resources, SIGNAL(resourceStatusChanged(AlarmResource*, \
AlarmResources::Change)),
--- trunk/KDE/kdepim/kalarm/mainwindow.h #831153:831154
@@ -157,7 +157,6 @@
AlarmListFilterModel* mListFilterModel;
AlarmListView* mListView;
- AlarmListDelegate* mListDelegate;
ResourceSelector* mResourceSelector; // resource selector widget
QSplitter* mSplitter; // splits window into list and resource \
selector AlarmResources* mAlarmResources; // calendar resources to use for \
this window
--- trunk/KDE/kdepim/kalarm/templatedlg.cpp #831153:831154
@@ -79,6 +79,7 @@
mListView->sortByColumn(TemplateListFilterModel::TemplateNameColumn, \
Qt::AscendingOrder); mListView->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, \
QSizePolicy::Expanding)); mListView->setWhatsThis(i18nc("@info:whatsthis", "The list \
of alarm templates")); + mListView->setItemDelegate(new \
TemplateListDelegate(mListView)); connect(mListView->selectionModel(), \
SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)), \
SLOT(slotSelectionChanged())); layout->addWidget(mListView);
--- trunk/KDE/kdepim/kalarm/templatelistview.cpp #831153:831154
@@ -1,7 +1,7 @@
/*
* templatelistview.cpp - widget showing list of alarm templates
* Program: kalarm
- * Copyright © 2007 by David Jarvie <software@astrojar.org.uk>
+ * Copyright © 2007,2008 by David Jarvie <djarvie@kde.org>
*
* 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
@@ -25,6 +25,7 @@
#include <QApplication>
#include "eventlistmodel.h"
+#include "functions.h"
#include "templatelistfiltermodel.h"
#include "templatelistview.moc"
@@ -53,3 +54,9 @@
resizeColumnToContents(col);
}*/
}
+
+
+void TemplateListDelegate::edit(KAEvent* event, EventListView* view)
+{
+ KAlarm::editTemplate(event, static_cast<TemplateListView*>(view));
+}
--- trunk/KDE/kdepim/kalarm/templatelistview.h #831153:831154
@@ -1,7 +1,7 @@
/*
* templatelistview.h - widget showing list of alarm templates
* Program: kalarm
- * Copyright © 2007 by David Jarvie <software@astrojar.org.uk>
+ * Copyright © 2007,2008 by David Jarvie <djarvie@kde.org>
*
* 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
@@ -23,21 +23,30 @@
#include "kalarm.h"
+#include "eventlistview.h"
+
#include <kcal/event.h>
-#include "eventlistview.h"
-
class TemplateListView : public EventListView
{
Q_OBJECT
public:
- TemplateListView(QWidget* parent = 0);
+ explicit TemplateListView(QWidget* parent = 0);
virtual void setModel(QAbstractItemModel*);
protected slots:
virtual void dataChanged(const QModelIndex& topLeft, const QModelIndex& \
bottomRight); };
+class TemplateListDelegate : public EventListDelegate
+{
+ Q_OBJECT
+ public:
+ explicit TemplateListDelegate(TemplateListView* parent = 0)
+ : EventListDelegate(parent) {}
+ virtual void edit(KAEvent*, EventListView*);
+};
+
#endif // TEMPLATELISTVIEW_H
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic