-rw-r--r-- | korganizer/koagenda.cpp | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index 607c250..6532705 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -1,145 +1,144 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | Marcus Bains line. | 5 | Marcus Bains line. |
6 | Copyright (c) 2001 Ali Rahimi | 6 | Copyright (c) 2001 Ali Rahimi |
7 | 7 | ||
8 | This program is free software; you can redistribute it and/or modify | 8 | This program is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by | 9 | it under the terms of the GNU General Public License as published by |
10 | the Free Software Foundation; either version 2 of the License, or | 10 | the Free Software Foundation; either version 2 of the License, or |
11 | (at your option) any later version. | 11 | (at your option) any later version. |
12 | 12 | ||
13 | This program is distributed in the hope that it will be useful, | 13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. | 16 | GNU General Public License for more details. |
17 | 17 | ||
18 | You should have received a copy of the GNU General Public License | 18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software | 19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 | 21 | ||
22 | As a special exception, permission is given to link this program | 22 | As a special exception, permission is given to link this program |
23 | with any edition of Qt, and distribute the resulting executable, | 23 | with any edition of Qt, and distribute the resulting executable, |
24 | without including the source code for Qt in the source distribution. | 24 | without including the source code for Qt in the source distribution. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #ifndef _WIN32_ | 27 | #ifndef _WIN32_ |
28 | #define protected public | 28 | #define protected public |
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #undef protected | 30 | #undef protected |
31 | #endif | 31 | #endif |
32 | #include <qintdict.h> | 32 | #include <qintdict.h> |
33 | #include <qdatetime.h> | 33 | #include <qdatetime.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
36 | #include <qcursor.h> | 36 | #include <qcursor.h> |
37 | #include <qpainter.h> | 37 | #include <qpainter.h> |
38 | 38 | ||
39 | #include <kdebug.h> | 39 | #include <kdebug.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kiconloader.h> | 41 | #include <kiconloader.h> |
42 | #include <kglobal.h> | 42 | #include <kglobal.h> |
43 | 43 | ||
44 | #include "koagendaitem.h" | 44 | #include "koagendaitem.h" |
45 | #include "koprefs.h" | 45 | #include "koprefs.h" |
46 | #include "koglobals.h" | 46 | #include "koglobals.h" |
47 | 47 | ||
48 | #include "koagenda.h" | 48 | #include "koagenda.h" |
49 | #include "koagenda.moc" | ||
50 | 49 | ||
51 | #include <libkcal/event.h> | 50 | #include <libkcal/event.h> |
52 | #include <libkcal/todo.h> | 51 | #include <libkcal/todo.h> |
53 | 52 | ||
54 | #ifndef DESKTOP_VERSION | 53 | #ifndef DESKTOP_VERSION |
55 | #include <qpe/qpeapplication.h> | 54 | #include <qpe/qpeapplication.h> |
56 | #endif | 55 | #endif |
57 | 56 | ||
58 | //extern bool globalFlagBlockPainting; | 57 | //extern bool globalFlagBlockPainting; |
59 | extern int globalFlagBlockAgenda; | 58 | extern int globalFlagBlockAgenda; |
60 | extern int globalFlagBlockAgendaItemPaint; | 59 | extern int globalFlagBlockAgendaItemPaint; |
61 | extern int globalFlagBlockAgendaItemUpdate; | 60 | extern int globalFlagBlockAgendaItemUpdate; |
62 | extern int globalFlagBlockStartup; | 61 | extern int globalFlagBlockStartup; |
63 | 62 | ||
64 | //////////////////////////////////////////////////////////////////////////// | 63 | //////////////////////////////////////////////////////////////////////////// |
65 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) | 64 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) |
66 | : QFrame(_agenda->viewport(),name), agenda(_agenda) | 65 | : QFrame(_agenda->viewport(),name), agenda(_agenda) |
67 | { | 66 | { |
68 | setLineWidth(0); | 67 | setLineWidth(0); |
69 | setMargin(0); | 68 | setMargin(0); |
70 | setBackgroundColor(Qt::red); | 69 | setBackgroundColor(Qt::red); |
71 | minutes = new QTimer(this); | 70 | minutes = new QTimer(this); |
72 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); | 71 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); |
73 | minutes->start(0, true); | 72 | minutes->start(0, true); |
74 | 73 | ||
75 | mTimeBox = new QLabel(this); | 74 | mTimeBox = new QLabel(this); |
76 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); | 75 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); |
77 | QPalette pal = mTimeBox->palette(); | 76 | QPalette pal = mTimeBox->palette(); |
78 | pal.setColor(QColorGroup::Foreground, Qt::red); | 77 | pal.setColor(QColorGroup::Foreground, Qt::red); |
79 | mTimeBox->setPalette(pal); | 78 | mTimeBox->setPalette(pal); |
80 | //mTimeBox->setAutoMask(true); | 79 | //mTimeBox->setAutoMask(true); |
81 | 80 | ||
82 | agenda->addChild(mTimeBox); | 81 | agenda->addChild(mTimeBox); |
83 | 82 | ||
84 | oldToday = -1; | 83 | oldToday = -1; |
85 | } | 84 | } |
86 | 85 | ||
87 | MarcusBains::~MarcusBains() | 86 | MarcusBains::~MarcusBains() |
88 | { | 87 | { |
89 | delete minutes; | 88 | delete minutes; |
90 | } | 89 | } |
91 | 90 | ||
92 | int MarcusBains::todayColumn() | 91 | int MarcusBains::todayColumn() |
93 | { | 92 | { |
94 | QDate currentDate = QDate::currentDate(); | 93 | QDate currentDate = QDate::currentDate(); |
95 | 94 | ||
96 | DateList dateList = agenda->dateList(); | 95 | DateList dateList = agenda->dateList(); |
97 | DateList::ConstIterator it; | 96 | DateList::ConstIterator it; |
98 | int col = 0; | 97 | int col = 0; |
99 | for(it = dateList.begin(); it != dateList.end(); ++it) { | 98 | for(it = dateList.begin(); it != dateList.end(); ++it) { |
100 | if((*it) == currentDate) | 99 | if((*it) == currentDate) |
101 | return KOGlobals::self()->reverseLayout() ? | 100 | return KOGlobals::self()->reverseLayout() ? |
102 | agenda->columns() - 1 - col : col; | 101 | agenda->columns() - 1 - col : col; |
103 | ++col; | 102 | ++col; |
104 | } | 103 | } |
105 | 104 | ||
106 | return -1; | 105 | return -1; |
107 | } | 106 | } |
108 | void MarcusBains::updateLoc() | 107 | void MarcusBains::updateLoc() |
109 | { | 108 | { |
110 | updateLocation(); | 109 | updateLocation(); |
111 | } | 110 | } |
112 | void MarcusBains::updateLocation(bool recalculate) | 111 | void MarcusBains::updateLocation(bool recalculate) |
113 | { | 112 | { |
114 | 113 | ||
115 | QTime tim = QTime::currentTime(); | 114 | QTime tim = QTime::currentTime(); |
116 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); | 115 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); |
117 | if((tim.hour() == 0) && (oldTime.hour()==23)) | 116 | if((tim.hour() == 0) && (oldTime.hour()==23)) |
118 | recalculate = true; | 117 | recalculate = true; |
119 | 118 | ||
120 | int mins = tim.hour()*60 + tim.minute(); | 119 | int mins = tim.hour()*60 + tim.minute(); |
121 | int minutesPerCell = 24 * 60 / agenda->rows(); | 120 | int minutesPerCell = 24 * 60 / agenda->rows(); |
122 | int y = mins*agenda->gridSpacingY()/minutesPerCell; | 121 | int y = mins*agenda->gridSpacingY()/minutesPerCell; |
123 | int today = recalculate ? todayColumn() : oldToday; | 122 | int today = recalculate ? todayColumn() : oldToday; |
124 | int x = agenda->gridSpacingX()*today; | 123 | int x = agenda->gridSpacingX()*today; |
125 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); | 124 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); |
126 | 125 | ||
127 | oldTime = tim; | 126 | oldTime = tim; |
128 | oldToday = today; | 127 | oldToday = today; |
129 | 128 | ||
130 | if(disabled || (today<0)) { | 129 | if(disabled || (today<0)) { |
131 | hide(); mTimeBox->hide(); | 130 | hide(); mTimeBox->hide(); |
132 | return; | 131 | return; |
133 | } else { | 132 | } else { |
134 | show(); mTimeBox->show(); | 133 | show(); mTimeBox->show(); |
135 | } | 134 | } |
136 | 135 | ||
137 | if(recalculate) | 136 | if(recalculate) |
138 | setFixedSize(agenda->gridSpacingX(),1); | 137 | setFixedSize(agenda->gridSpacingX(),1); |
139 | agenda->moveChild(this, x, y); | 138 | agenda->moveChild(this, x, y); |
140 | raise(); | 139 | raise(); |
141 | 140 | ||
142 | if(recalculate) | 141 | if(recalculate) |
143 | //mTimeBox->setFont(QFont("helvetica",10)); | 142 | //mTimeBox->setFont(QFont("helvetica",10)); |
144 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); | 143 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); |
145 | 144 | ||