-rw-r--r-- | korganizer/koeventpopupmenu.cpp | 27 | ||||
-rw-r--r-- | korganizer/koeventpopupmenu.h | 3 | ||||
-rw-r--r-- | korganizer/kolistview.cpp | 12 | ||||
-rw-r--r-- | korganizer/kolistview.h | 1 |
4 files changed, 38 insertions, 5 deletions
diff --git a/korganizer/koeventpopupmenu.cpp b/korganizer/koeventpopupmenu.cpp index b274810..17ef81e 100644 --- a/korganizer/koeventpopupmenu.cpp +++ b/korganizer/koeventpopupmenu.cpp | |||
@@ -1,112 +1,129 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qcursor.h> | 24 | #include <qcursor.h> |
25 | 25 | ||
26 | #include <klocale.h> | 26 | #include <klocale.h> |
27 | #include <kdebug.h> | 27 | #include <kdebug.h> |
28 | #include <kiconloader.h> | 28 | #include <kiconloader.h> |
29 | 29 | ||
30 | #include <libkcal/event.h> | 30 | #include <libkcal/event.h> |
31 | 31 | ||
32 | #include "koeventpopupmenu.h" | 32 | #include "koeventpopupmenu.h" |
33 | 33 | ||
34 | KOEventPopupMenu::KOEventPopupMenu() | 34 | KOEventPopupMenu::KOEventPopupMenu() |
35 | { | 35 | { |
36 | mCurrentIncidence = 0; | 36 | mCurrentIncidence = 0; |
37 | mHasAdditionalItems = false; | 37 | mHasAdditionalItems = false; |
38 | 38 | ||
39 | insertItem (i18n("&Show"),this,SLOT(popupShow())); | 39 | |
40 | mSingleOnlyItems.append( insertItem (i18n("&Show"),this,SLOT(popupShow()))); | ||
40 | mEditOnlyItems.append(insertItem (i18n("&Edit..."),this,SLOT(popupEdit()))); | 41 | mEditOnlyItems.append(insertItem (i18n("&Edit..."),this,SLOT(popupEdit()))); |
41 | mEditOnlyItems.append(insertItem (i18n("&Delete"), | 42 | mEditOnlyItems.append(insertItem (i18n("&Delete"), |
42 | this,SLOT(popupDelete()))); | 43 | this,SLOT(popupDelete()))); |
43 | mEditOnlyItems.append(insertItem (i18n("&Clone..."), | 44 | mEditOnlyItems.append(insertItem (i18n("&Clone..."), |
44 | this,SLOT(popupClone()))); | 45 | this,SLOT(popupClone()))); |
45 | mEditOnlyItems.append(insertItem (i18n("&Move..."), | 46 | mEditOnlyItems.append(insertItem (i18n("&Move..."), |
46 | this,SLOT(popupMove()))); | 47 | this,SLOT(popupMove()))); |
47 | #ifndef DESKTOP_VERSION | 48 | #ifndef DESKTOP_VERSION |
48 | mEditOnlyItems.append(insertItem (i18n("&Beam..."), | 49 | mEditOnlyItems.append(insertItem (i18n("&Beam..."), |
49 | this,SLOT(popupBeam()))); | 50 | this,SLOT(popupBeam()))); |
50 | #endif | 51 | #endif |
51 | mEditOnlyItems.append(insertItem (i18n("&Toggle Cancel"), | 52 | mEditOnlyItems.append(insertItem (i18n("&Toggle Cancel"), |
52 | this,SLOT(popupCancel()))); | 53 | this,SLOT(popupCancel()))); |
54 | isDisabled = false; | ||
55 | QValueList<int>::Iterator it; | ||
56 | for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) { | ||
57 | mSingleOnlyItems.append(*it); | ||
58 | } | ||
59 | } | ||
60 | void KOEventPopupMenu::enableDefault( bool enable ) | ||
61 | { | ||
62 | isDisabled = !enable; | ||
63 | QValueList<int>::Iterator it; | ||
64 | for( it = mSingleOnlyItems.begin(); it != mSingleOnlyItems.end(); ++it ) { | ||
65 | setItemEnabled(*it,enable); | ||
66 | } | ||
67 | |||
53 | } | 68 | } |
54 | 69 | ||
55 | void KOEventPopupMenu::showIncidencePopup(Incidence *incidence) | 70 | void KOEventPopupMenu::showIncidencePopup(Incidence *incidence) |
56 | { | 71 | { |
57 | mCurrentIncidence = incidence; | 72 | mCurrentIncidence = incidence; |
58 | 73 | ||
59 | if (mCurrentIncidence) { | 74 | if (mCurrentIncidence) { |
60 | // Enable/Disabled menu items only valid for editable events. | 75 | // Enable/Disabled menu items only valid for editable events. |
61 | QValueList<int>::Iterator it; | 76 | if ( !isDisabled ) { |
62 | for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) { | 77 | QValueList<int>::Iterator it; |
63 | setItemEnabled(*it,!mCurrentIncidence->isReadOnly()); | 78 | for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) { |
64 | } | 79 | setItemEnabled(*it,!mCurrentIncidence->isReadOnly()); |
80 | } | ||
81 | } | ||
65 | popup(QCursor::pos()); | 82 | popup(QCursor::pos()); |
66 | } else { | 83 | } else { |
67 | kdDebug() << "KOEventPopupMenu::showEventPopup(): No event selected" << endl; | 84 | kdDebug() << "KOEventPopupMenu::showEventPopup(): No event selected" << endl; |
68 | } | 85 | } |
69 | } | 86 | } |
70 | 87 | ||
71 | void KOEventPopupMenu::addAdditionalItem(const QIconSet &icon,const QString &text, | 88 | void KOEventPopupMenu::addAdditionalItem(const QIconSet &icon,const QString &text, |
72 | const QObject *receiver, const char *member, | 89 | const QObject *receiver, const char *member, |
73 | bool editOnly) | 90 | bool editOnly) |
74 | { | 91 | { |
75 | if (!mHasAdditionalItems) { | 92 | if (!mHasAdditionalItems) { |
76 | mHasAdditionalItems = true; | 93 | mHasAdditionalItems = true; |
77 | insertSeparator(); | 94 | insertSeparator(); |
78 | } | 95 | } |
79 | int id = insertItem(icon,text,receiver,member); | 96 | int id = insertItem(icon,text,receiver,member); |
80 | if (editOnly) mEditOnlyItems.append(id); | 97 | if (editOnly) mEditOnlyItems.append(id); |
81 | } | 98 | } |
82 | 99 | ||
83 | void KOEventPopupMenu::popupShow() | 100 | void KOEventPopupMenu::popupShow() |
84 | { | 101 | { |
85 | if (mCurrentIncidence) emit showIncidenceSignal(mCurrentIncidence); | 102 | if (mCurrentIncidence) emit showIncidenceSignal(mCurrentIncidence); |
86 | } | 103 | } |
87 | 104 | ||
88 | void KOEventPopupMenu::popupEdit() | 105 | void KOEventPopupMenu::popupEdit() |
89 | { | 106 | { |
90 | if (mCurrentIncidence) emit editIncidenceSignal(mCurrentIncidence); | 107 | if (mCurrentIncidence) emit editIncidenceSignal(mCurrentIncidence); |
91 | } | 108 | } |
92 | 109 | ||
93 | void KOEventPopupMenu::popupDelete() | 110 | void KOEventPopupMenu::popupDelete() |
94 | { | 111 | { |
95 | if (mCurrentIncidence) emit deleteIncidenceSignal(mCurrentIncidence); | 112 | if (mCurrentIncidence) emit deleteIncidenceSignal(mCurrentIncidence); |
96 | } | 113 | } |
97 | void KOEventPopupMenu::popupClone() | 114 | void KOEventPopupMenu::popupClone() |
98 | { | 115 | { |
99 | if (mCurrentIncidence) emit cloneIncidenceSignal(mCurrentIncidence); | 116 | if (mCurrentIncidence) emit cloneIncidenceSignal(mCurrentIncidence); |
100 | } | 117 | } |
101 | void KOEventPopupMenu::popupCancel() | 118 | void KOEventPopupMenu::popupCancel() |
102 | { | 119 | { |
103 | if (mCurrentIncidence) emit cancelIncidenceSignal(mCurrentIncidence); | 120 | if (mCurrentIncidence) emit cancelIncidenceSignal(mCurrentIncidence); |
104 | } | 121 | } |
105 | void KOEventPopupMenu::popupMove() | 122 | void KOEventPopupMenu::popupMove() |
106 | { | 123 | { |
107 | if (mCurrentIncidence) emit moveIncidenceSignal(mCurrentIncidence); | 124 | if (mCurrentIncidence) emit moveIncidenceSignal(mCurrentIncidence); |
108 | } | 125 | } |
109 | 126 | ||
110 | void KOEventPopupMenu::popupBeam() | 127 | void KOEventPopupMenu::popupBeam() |
111 | { | 128 | { |
112 | if (mCurrentIncidence) emit beamIncidenceSignal(mCurrentIncidence); | 129 | if (mCurrentIncidence) emit beamIncidenceSignal(mCurrentIncidence); |
diff --git a/korganizer/koeventpopupmenu.h b/korganizer/koeventpopupmenu.h index 6993899..8fb51fa 100644 --- a/korganizer/koeventpopupmenu.h +++ b/korganizer/koeventpopupmenu.h | |||
@@ -1,73 +1,76 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | #ifndef KOEVENTPOPUPMENU_H | 23 | #ifndef KOEVENTPOPUPMENU_H |
24 | #define KOEVENTPOPUPMENU_H | 24 | #define KOEVENTPOPUPMENU_H |
25 | // | 25 | // |
26 | // Context menu for event views with standard event actions | 26 | // Context menu for event views with standard event actions |
27 | // | 27 | // |
28 | 28 | ||
29 | #include <qpopupmenu.h> | 29 | #include <qpopupmenu.h> |
30 | 30 | ||
31 | #include <libkcal/incidence.h> | 31 | #include <libkcal/incidence.h> |
32 | 32 | ||
33 | using namespace KCal; | 33 | using namespace KCal; |
34 | 34 | ||
35 | class KOEventPopupMenu : public QPopupMenu { | 35 | class KOEventPopupMenu : public QPopupMenu { |
36 | Q_OBJECT | 36 | Q_OBJECT |
37 | public: | 37 | public: |
38 | KOEventPopupMenu(); | 38 | KOEventPopupMenu(); |
39 | 39 | ||
40 | void addAdditionalItem(const QIconSet &icon,const QString &text, | 40 | void addAdditionalItem(const QIconSet &icon,const QString &text, |
41 | const QObject *receiver, const char *member, | 41 | const QObject *receiver, const char *member, |
42 | bool editOnly=false); | 42 | bool editOnly=false); |
43 | 43 | ||
44 | 44 | ||
45 | public slots: | 45 | public slots: |
46 | void showIncidencePopup(Incidence *); | 46 | void showIncidencePopup(Incidence *); |
47 | void enableDefault( bool ); | ||
47 | 48 | ||
48 | protected slots: | 49 | protected slots: |
49 | void popupShow(); | 50 | void popupShow(); |
50 | void popupEdit(); | 51 | void popupEdit(); |
51 | void popupDelete(); | 52 | void popupDelete(); |
52 | void popupClone(); | 53 | void popupClone(); |
53 | void popupCancel(); | 54 | void popupCancel(); |
54 | void popupMove(); | 55 | void popupMove(); |
55 | void popupBeam(); | 56 | void popupBeam(); |
56 | 57 | ||
57 | signals: | 58 | signals: |
58 | void editIncidenceSignal(Incidence *); | 59 | void editIncidenceSignal(Incidence *); |
59 | void showIncidenceSignal(Incidence *); | 60 | void showIncidenceSignal(Incidence *); |
60 | void deleteIncidenceSignal(Incidence *); | 61 | void deleteIncidenceSignal(Incidence *); |
61 | void cloneIncidenceSignal(Incidence *); | 62 | void cloneIncidenceSignal(Incidence *); |
62 | void cancelIncidenceSignal(Incidence *); | 63 | void cancelIncidenceSignal(Incidence *); |
63 | void moveIncidenceSignal(Incidence *); | 64 | void moveIncidenceSignal(Incidence *); |
64 | void beamIncidenceSignal(Incidence *); | 65 | void beamIncidenceSignal(Incidence *); |
65 | 66 | ||
66 | private: | 67 | private: |
67 | Incidence *mCurrentIncidence; | 68 | Incidence *mCurrentIncidence; |
68 | 69 | ||
69 | bool mHasAdditionalItems; | 70 | bool mHasAdditionalItems; |
70 | QValueList<int> mEditOnlyItems; | 71 | QValueList<int> mEditOnlyItems; |
72 | QValueList<int> mSingleOnlyItems; | ||
73 | bool isDisabled; | ||
71 | }; | 74 | }; |
72 | 75 | ||
73 | #endif | 76 | #endif |
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index b94916a..02247c8 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp | |||
@@ -958,96 +958,97 @@ void KOListView::changeEventDisplay(Event *event, int action) | |||
958 | KOListViewItem *item; | 958 | KOListViewItem *item; |
959 | 959 | ||
960 | switch(action) { | 960 | switch(action) { |
961 | case KOGlobals::EVENTADDED: | 961 | case KOGlobals::EVENTADDED: |
962 | addIncidence( event ); | 962 | addIncidence( event ); |
963 | break; | 963 | break; |
964 | case KOGlobals::EVENTEDITED: | 964 | case KOGlobals::EVENTEDITED: |
965 | item = getItemForEvent(event); | 965 | item = getItemForEvent(event); |
966 | if (item) { | 966 | if (item) { |
967 | mUidDict.remove( event->uid() ); | 967 | mUidDict.remove( event->uid() ); |
968 | delete item; | 968 | delete item; |
969 | addIncidence( event ); | 969 | addIncidence( event ); |
970 | } | 970 | } |
971 | break; | 971 | break; |
972 | case KOGlobals::EVENTDELETED: | 972 | case KOGlobals::EVENTDELETED: |
973 | item = getItemForEvent(event); | 973 | item = getItemForEvent(event); |
974 | if (item) { | 974 | if (item) { |
975 | mUidDict.remove( event->uid() ); | 975 | mUidDict.remove( event->uid() ); |
976 | delete item; | 976 | delete item; |
977 | } | 977 | } |
978 | break; | 978 | break; |
979 | default: | 979 | default: |
980 | ; | 980 | ; |
981 | } | 981 | } |
982 | } | 982 | } |
983 | 983 | ||
984 | KOListViewItem *KOListView::getItemForEvent(Event *event) | 984 | KOListViewItem *KOListView::getItemForEvent(Event *event) |
985 | { | 985 | { |
986 | KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); | 986 | KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); |
987 | while (item) { | 987 | while (item) { |
988 | if (item->data() == event) return item; | 988 | if (item->data() == event) return item; |
989 | item = (KOListViewItem *)item->nextSibling(); | 989 | item = (KOListViewItem *)item->nextSibling(); |
990 | } | 990 | } |
991 | return 0; | 991 | return 0; |
992 | } | 992 | } |
993 | 993 | ||
994 | void KOListView::defaultItemAction(QListViewItem *i) | 994 | void KOListView::defaultItemAction(QListViewItem *i) |
995 | { | 995 | { |
996 | KOListViewItem *item = static_cast<KOListViewItem *>( i ); | 996 | KOListViewItem *item = static_cast<KOListViewItem *>( i ); |
997 | if ( item ) defaultAction( item->data() ); | 997 | if ( item ) defaultAction( item->data() ); |
998 | 998 | ||
999 | } | 999 | } |
1000 | 1000 | ||
1001 | void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) | 1001 | void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) |
1002 | { | 1002 | { |
1003 | mActiveItem = (KOListViewItem *)item; | 1003 | mActiveItem = (KOListViewItem *)item; |
1004 | if (mActiveItem) { | 1004 | if (mActiveItem) { |
1005 | Incidence *incidence = mActiveItem->data(); | 1005 | Incidence *incidence = mActiveItem->data(); |
1006 | mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) ); | ||
1006 | mPopupMenu->showIncidencePopup(incidence); | 1007 | mPopupMenu->showIncidencePopup(incidence); |
1007 | 1008 | ||
1008 | /* | 1009 | /* |
1009 | if ( incidence && incidence->type() == "Event" ) { | 1010 | if ( incidence && incidence->type() == "Event" ) { |
1010 | Event *event = static_cast<Event *>( incidence ); | 1011 | Event *event = static_cast<Event *>( incidence ); |
1011 | mPopupMenu->showEventPopup(event); | 1012 | mPopupMenu->showEventPopup(event); |
1012 | } | 1013 | } |
1013 | */ | 1014 | */ |
1014 | } | 1015 | } |
1015 | } | 1016 | } |
1016 | 1017 | ||
1017 | void KOListView::readSettings(KConfig *config, QString setting) | 1018 | void KOListView::readSettings(KConfig *config, QString setting) |
1018 | { | 1019 | { |
1019 | // qDebug("KOListView::readSettings "); | 1020 | // qDebug("KOListView::readSettings "); |
1020 | mListView->restoreLayout(config,setting); | 1021 | mListView->restoreLayout(config,setting); |
1021 | } | 1022 | } |
1022 | 1023 | ||
1023 | void KOListView::writeSettings(KConfig *config, QString setting) | 1024 | void KOListView::writeSettings(KConfig *config, QString setting) |
1024 | { | 1025 | { |
1025 | // qDebug("KOListView::writeSettings "); | 1026 | // qDebug("KOListView::writeSettings "); |
1026 | mListView->saveLayout(config, setting); | 1027 | mListView->saveLayout(config, setting); |
1027 | } | 1028 | } |
1028 | 1029 | ||
1029 | void KOListView::processSelectionChange(QListViewItem *) | 1030 | void KOListView::processSelectionChange(QListViewItem *) |
1030 | { | 1031 | { |
1031 | 1032 | ||
1032 | KOListViewItem *item = | 1033 | KOListViewItem *item = |
1033 | static_cast<KOListViewItem *>( mListView->currentItem() ); | 1034 | static_cast<KOListViewItem *>( mListView->currentItem() ); |
1034 | 1035 | ||
1035 | if ( !item ) { | 1036 | if ( !item ) { |
1036 | emit incidenceSelected( 0 ); | 1037 | emit incidenceSelected( 0 ); |
1037 | } else { | 1038 | } else { |
1038 | emit incidenceSelected( item->data() ); | 1039 | emit incidenceSelected( item->data() ); |
1039 | } | 1040 | } |
1040 | } | 1041 | } |
1041 | 1042 | ||
1042 | void KOListView::clearSelection() | 1043 | void KOListView::clearSelection() |
1043 | { | 1044 | { |
1044 | mListView->selectAll( false ); | 1045 | mListView->selectAll( false ); |
1045 | } | 1046 | } |
1046 | void KOListView::allSelection() | 1047 | void KOListView::allSelection() |
1047 | { | 1048 | { |
1048 | mListView->selectAll( true ); | 1049 | mListView->selectAll( true ); |
1049 | } | 1050 | } |
1050 | 1051 | ||
1051 | void KOListView::clear() | 1052 | void KOListView::clear() |
1052 | { | 1053 | { |
1053 | mListView->clear(); | 1054 | mListView->clear(); |
@@ -1150,96 +1151,107 @@ void KOListViewListView::keyPressEvent ( QKeyEvent *e) | |||
1150 | if ( cn ) { | 1151 | if ( cn ) { |
1151 | setCurrentItem ( cn ); | 1152 | setCurrentItem ( cn ); |
1152 | ensureItemVisible ( cn ); | 1153 | ensureItemVisible ( cn ); |
1153 | } | 1154 | } |
1154 | emit showIncidence( ci->data()); | 1155 | emit showIncidence( ci->data()); |
1155 | } | 1156 | } |
1156 | } | 1157 | } |
1157 | e->accept(); | 1158 | e->accept(); |
1158 | } | 1159 | } |
1159 | break; | 1160 | break; |
1160 | case Qt::Key_Return: | 1161 | case Qt::Key_Return: |
1161 | case Qt::Key_Enter: | 1162 | case Qt::Key_Enter: |
1162 | { | 1163 | { |
1163 | QListViewItem* cn; | 1164 | QListViewItem* cn; |
1164 | cn = currentItem(); | 1165 | cn = currentItem(); |
1165 | if ( cn ) { | 1166 | if ( cn ) { |
1166 | KOListViewItem* ci = (KOListViewItem*)( cn ); | 1167 | KOListViewItem* ci = (KOListViewItem*)( cn ); |
1167 | if ( ci ){ | 1168 | if ( ci ){ |
1168 | if ( e->state() == ShiftButton ) | 1169 | if ( e->state() == ShiftButton ) |
1169 | ci->setSelected( false ); | 1170 | ci->setSelected( false ); |
1170 | else | 1171 | else |
1171 | ci->setSelected( true ); | 1172 | ci->setSelected( true ); |
1172 | cn = cn->nextSibling(); | 1173 | cn = cn->nextSibling(); |
1173 | if ( cn ) { | 1174 | if ( cn ) { |
1174 | setCurrentItem ( cn ); | 1175 | setCurrentItem ( cn ); |
1175 | ensureItemVisible ( cn ); | 1176 | ensureItemVisible ( cn ); |
1176 | } | 1177 | } |
1177 | } | 1178 | } |
1178 | } | 1179 | } |
1179 | e->accept(); | 1180 | e->accept(); |
1180 | } | 1181 | } |
1181 | break; | 1182 | break; |
1182 | default: | 1183 | default: |
1183 | e->ignore(); | 1184 | e->ignore(); |
1184 | } | 1185 | } |
1185 | } | 1186 | } |
1186 | KOListViewListView::KOListViewListView(KOListView * lv ) | 1187 | KOListViewListView::KOListViewListView(KOListView * lv ) |
1187 | : KListView( lv, "kolistlistview", false ) | 1188 | : KListView( lv, "kolistlistview", false ) |
1188 | { | 1189 | { |
1189 | mYMousePos = 0; | 1190 | mYMousePos = 0; |
1190 | mPopupTimer = new QTimer(this); | 1191 | mPopupTimer = new QTimer(this); |
1191 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); | 1192 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); |
1192 | #ifndef DESKTOP_VERSION | 1193 | #ifndef DESKTOP_VERSION |
1193 | //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); | 1194 | //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); |
1194 | #endif | 1195 | #endif |
1195 | setSelectionMode( QListView::Multi ); | 1196 | setSelectionMode( QListView::Multi ); |
1196 | setMultiSelection( true); | 1197 | setMultiSelection( true); |
1197 | } | 1198 | } |
1199 | bool KOListViewListView::hasMultiSelection(QListViewItem* item) | ||
1200 | { | ||
1201 | int selCount = 0; | ||
1202 | QListViewItem *qitem = firstChild (); | ||
1203 | while ( qitem ) { | ||
1204 | if ( qitem->isSelected() && item != qitem ) | ||
1205 | return true; | ||
1206 | qitem = qitem->nextSibling(); | ||
1207 | } | ||
1208 | return false; | ||
1209 | } | ||
1198 | void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 1210 | void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
1199 | { | 1211 | { |
1200 | if (!e) return; | 1212 | if (!e) return; |
1201 | QPoint vp = contentsToViewport(e->pos()); | 1213 | QPoint vp = contentsToViewport(e->pos()); |
1202 | QListViewItem *item = itemAt(vp); | 1214 | QListViewItem *item = itemAt(vp); |
1203 | if (!item) { | 1215 | if (!item) { |
1204 | emit newEvent(); | 1216 | emit newEvent(); |
1205 | return; | 1217 | return; |
1206 | } | 1218 | } |
1207 | KListView::contentsMouseDoubleClickEvent(e); | 1219 | KListView::contentsMouseDoubleClickEvent(e); |
1208 | } | 1220 | } |
1209 | #if 0 | 1221 | #if 0 |
1210 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) | 1222 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) |
1211 | { | 1223 | { |
1212 | //qDebug("contentsMousePressEvent++++ "); | 1224 | //qDebug("contentsMousePressEvent++++ "); |
1213 | KListView::contentsMousePressEvent( e ); | 1225 | KListView::contentsMousePressEvent( e ); |
1214 | if ( e->button() == RightButton ) { | 1226 | if ( e->button() == RightButton ) { |
1215 | QListViewItem* ci = currentItem(); | 1227 | QListViewItem* ci = currentItem(); |
1216 | clearSelection () ; | 1228 | clearSelection () ; |
1217 | if ( ci ) | 1229 | if ( ci ) |
1218 | ci->setSelected( true ); | 1230 | ci->setSelected( true ); |
1219 | } | 1231 | } |
1220 | } | 1232 | } |
1221 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) | 1233 | void KOListViewListView::contentsMouseReleaseEvent(QMouseEvent *e) |
1222 | { | 1234 | { |
1223 | KListView::contentsMouseReleaseEvent(e); | 1235 | KListView::contentsMouseReleaseEvent(e); |
1224 | } | 1236 | } |
1225 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) | 1237 | void KOListViewListView::contentsMouseMoveEvent(QMouseEvent *e) |
1226 | { | 1238 | { |
1227 | KListView::contentsMouseMoveEvent(e); | 1239 | KListView::contentsMouseMoveEvent(e); |
1228 | } | 1240 | } |
1229 | #endif | 1241 | #endif |
1230 | void KOListViewListView::popupMenu() | 1242 | void KOListViewListView::popupMenu() |
1231 | { | 1243 | { |
1232 | mPopupTimer->stop(); | 1244 | mPopupTimer->stop(); |
1233 | QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton ); | 1245 | QMouseEvent* e = new QMouseEvent( QEvent::MouseButtonPress, mEventPos ,mEventGlobalPos, RightButton , RightButton ); |
1234 | QApplication::postEvent( this->viewport(), e ); | 1246 | QApplication::postEvent( this->viewport(), e ); |
1235 | 1247 | ||
1236 | } | 1248 | } |
1237 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) | 1249 | void KOListViewListView::contentsMousePressEvent(QMouseEvent *e) |
1238 | { | 1250 | { |
1239 | //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y()); | 1251 | //qDebug("contentsMousePressEvent++++ %d %d", e->pos().y(), e->globalPos().y()); |
1240 | mYMousePos = mapToGlobal( (e->pos())).y(); | 1252 | mYMousePos = mapToGlobal( (e->pos())).y(); |
1241 | if ( e->button() == LeftButton ) { | 1253 | if ( e->button() == LeftButton ) { |
1242 | mPopupTimer->start( 600 ); | 1254 | mPopupTimer->start( 600 ); |
1243 | mEventPos = contentsToViewport(e->pos()); | 1255 | mEventPos = contentsToViewport(e->pos()); |
1244 | mEventGlobalPos = e->globalPos(); | 1256 | mEventGlobalPos = e->globalPos(); |
1245 | } | 1257 | } |
diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h index 2051d60..dee69f6 100644 --- a/korganizer/kolistview.h +++ b/korganizer/kolistview.h | |||
@@ -170,96 +170,97 @@ void pickAlarmProgram() | |||
170 | }; | 170 | }; |
171 | 171 | ||
172 | }; | 172 | }; |
173 | 173 | ||
174 | 174 | ||
175 | 175 | ||
176 | 176 | ||
177 | 177 | ||
178 | 178 | ||
179 | 179 | ||
180 | typedef CustomListViewItem<Incidence *> KOListViewItem; | 180 | typedef CustomListViewItem<Incidence *> KOListViewItem; |
181 | 181 | ||
182 | /** | 182 | /** |
183 | This class provides the initialisation of a KOListViewItem for calendar | 183 | This class provides the initialisation of a KOListViewItem for calendar |
184 | components using the Incidence::Visitor. | 184 | components using the Incidence::Visitor. |
185 | */ | 185 | */ |
186 | class ListItemVisitor : public Incidence::Visitor | 186 | class ListItemVisitor : public Incidence::Visitor |
187 | { | 187 | { |
188 | public: | 188 | public: |
189 | ListItemVisitor(KOListViewItem *, QDate d); | 189 | ListItemVisitor(KOListViewItem *, QDate d); |
190 | ~ListItemVisitor(); | 190 | ~ListItemVisitor(); |
191 | 191 | ||
192 | bool visit(Event *); | 192 | bool visit(Event *); |
193 | bool visit(Todo *); | 193 | bool visit(Todo *); |
194 | bool visit(Journal *); | 194 | bool visit(Journal *); |
195 | 195 | ||
196 | private: | 196 | private: |
197 | KOListViewItem *mItem; | 197 | KOListViewItem *mItem; |
198 | QDate mDate; | 198 | QDate mDate; |
199 | }; | 199 | }; |
200 | 200 | ||
201 | /** | 201 | /** |
202 | This class provides a multi-column list view of events. It can | 202 | This class provides a multi-column list view of events. It can |
203 | display events from one particular day or several days, it doesn't | 203 | display events from one particular day or several days, it doesn't |
204 | matter. To use a view that only handles one day at a time, use | 204 | matter. To use a view that only handles one day at a time, use |
205 | KODayListView. | 205 | KODayListView. |
206 | 206 | ||
207 | @short multi-column list view of various events. | 207 | @short multi-column list view of various events. |
208 | @author Preston Brown <pbrown@kde.org> | 208 | @author Preston Brown <pbrown@kde.org> |
209 | @see KOBaseView, KODayListView | 209 | @see KOBaseView, KODayListView |
210 | */ | 210 | */ |
211 | class KOListView; | 211 | class KOListView; |
212 | 212 | ||
213 | class KOListViewListView : public KListView | 213 | class KOListViewListView : public KListView |
214 | { | 214 | { |
215 | Q_OBJECT | 215 | Q_OBJECT |
216 | public: | 216 | public: |
217 | KOListViewListView(KOListView * lv ); | 217 | KOListViewListView(KOListView * lv ); |
218 | bool hasMultiSelection(QListViewItem*); | ||
218 | signals: | 219 | signals: |
219 | void newEvent(); | 220 | void newEvent(); |
220 | void showIncidence( Incidence* ); | 221 | void showIncidence( Incidence* ); |
221 | public slots: | 222 | public slots: |
222 | void popupMenu(); | 223 | void popupMenu(); |
223 | private: | 224 | private: |
224 | QPoint mEventPos; | 225 | QPoint mEventPos; |
225 | QPoint mEventGlobalPos; | 226 | QPoint mEventGlobalPos; |
226 | QTimer* mPopupTimer; | 227 | QTimer* mPopupTimer; |
227 | int mYMousePos; | 228 | int mYMousePos; |
228 | void keyPressEvent ( QKeyEvent * ) ; | 229 | void keyPressEvent ( QKeyEvent * ) ; |
229 | void contentsMouseDoubleClickEvent(QMouseEvent *e); | 230 | void contentsMouseDoubleClickEvent(QMouseEvent *e); |
230 | void contentsMousePressEvent(QMouseEvent *e); | 231 | void contentsMousePressEvent(QMouseEvent *e); |
231 | void contentsMouseReleaseEvent(QMouseEvent *e); | 232 | void contentsMouseReleaseEvent(QMouseEvent *e); |
232 | void contentsMouseMoveEvent(QMouseEvent *e); | 233 | void contentsMouseMoveEvent(QMouseEvent *e); |
233 | bool mMouseDown; | 234 | bool mMouseDown; |
234 | }; | 235 | }; |
235 | 236 | ||
236 | class KOListView : public KOEventView | 237 | class KOListView : public KOEventView |
237 | { | 238 | { |
238 | Q_OBJECT | 239 | Q_OBJECT |
239 | public: | 240 | public: |
240 | KOListView(Calendar *calendar, QWidget *parent = 0, | 241 | KOListView(Calendar *calendar, QWidget *parent = 0, |
241 | const char *name = 0); | 242 | const char *name = 0); |
242 | ~KOListView(); | 243 | ~KOListView(); |
243 | 244 | ||
244 | virtual int maxDatesHint(); | 245 | virtual int maxDatesHint(); |
245 | virtual int currentDateCount(); | 246 | virtual int currentDateCount(); |
246 | virtual QPtrList<Incidence> selectedIncidences(); | 247 | virtual QPtrList<Incidence> selectedIncidences(); |
247 | virtual DateList selectedDates(); | 248 | virtual DateList selectedDates(); |
248 | 249 | ||
249 | void showDates(bool show); | 250 | void showDates(bool show); |
250 | Incidence* currentItem(); | 251 | Incidence* currentItem(); |
251 | void addTodos(QPtrList<Todo> eventList); | 252 | void addTodos(QPtrList<Todo> eventList); |
252 | void addJournals(QPtrList<Journal> eventList); | 253 | void addJournals(QPtrList<Journal> eventList); |
253 | virtual void printPreview(CalPrinter *calPrinter, | 254 | virtual void printPreview(CalPrinter *calPrinter, |
254 | const QDate &, const QDate &); | 255 | const QDate &, const QDate &); |
255 | 256 | ||
256 | void readSettings(KConfig *config, QString setting = "KOListView Layout"); | 257 | void readSettings(KConfig *config, QString setting = "KOListView Layout"); |
257 | void writeSettings(KConfig *config, QString setting = "KOListView Layout"); | 258 | void writeSettings(KConfig *config, QString setting = "KOListView Layout"); |
258 | void updateList(); | 259 | void updateList(); |
259 | void setStartDate(const QDate &start); | 260 | void setStartDate(const QDate &start); |
260 | int count(); | 261 | int count(); |
261 | QString getWhatsThisText(QPoint p); | 262 | QString getWhatsThisText(QPoint p); |
262 | signals: | 263 | signals: |
263 | void signalNewEvent(); | 264 | void signalNewEvent(); |
264 | void beamIncidenceList(QPtrList<Incidence>); | 265 | void beamIncidenceList(QPtrList<Incidence>); |
265 | 266 | ||