summaryrefslogtreecommitdiffabout
path: root/korganizer/koagenda.cpp
authorzautrix <zautrix>2005-07-05 07:37:53 (UTC)
committer zautrix <zautrix>2005-07-05 07:37:53 (UTC)
commit28ca4c37fb0e131b2978584992840b3fdca21d3e (patch) (unidiff)
treefb4f7e51c0995b71e2a26a7300747b6b1b3acb23 /korganizer/koagenda.cpp
parent5992ea9025ebddde8be72322c90aac8edeaf4d1c (diff)
downloadkdepimpi-28ca4c37fb0e131b2978584992840b3fdca21d3e.zip
kdepimpi-28ca4c37fb0e131b2978584992840b3fdca21d3e.tar.gz
kdepimpi-28ca4c37fb0e131b2978584992840b3fdca21d3e.tar.bz2
fixesss
Diffstat (limited to 'korganizer/koagenda.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp30
1 files changed, 28 insertions, 2 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 0280c74..c339b57 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -15,96 +15,97 @@
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 49
50#include <libkcal/event.h> 50#include <libkcal/event.h>
51#include <libkcal/todo.h> 51#include <libkcal/todo.h>
52 52
53#ifndef DESKTOP_VERSION 53#ifndef DESKTOP_VERSION
54#include <qpe/qpeapplication.h> 54#include <qpe/qpeapplication.h>
55#endif 55#endif
56 56
57//extern bool globalFlagBlockPainting; 57//extern bool globalFlagBlockPainting;
58extern int globalFlagBlockAgenda; 58extern int globalFlagBlockAgenda;
59extern int globalFlagBlockAgendaItemPaint; 59extern int globalFlagBlockAgendaItemPaint;
60extern int globalFlagBlockAgendaItemUpdate; 60extern int globalFlagBlockAgendaItemUpdate;
61extern int globalFlagBlockStartup; 61extern int globalFlagBlockStartup;
62 62
63bool KOAgenda::mInvalidPixmap = false;
63//////////////////////////////////////////////////////////////////////////// 64////////////////////////////////////////////////////////////////////////////
64MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) 65MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name)
65 : QFrame(_agenda->viewport(),name), agenda(_agenda) 66 : QFrame(_agenda->viewport(),name), agenda(_agenda)
66{ 67{
67 setLineWidth(0); 68 setLineWidth(0);
68 setMargin(0); 69 setMargin(0);
69 setBackgroundColor(Qt::red); 70 setBackgroundColor(Qt::red);
70 minutes = new QTimer(this); 71 minutes = new QTimer(this);
71 connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); 72 connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc()));
72 minutes->start(0, true); 73 minutes->start(0, true);
73 mTimeBox = new QLabel(this); 74 mTimeBox = new QLabel(this);
74 mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); 75 mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom);
75 QPalette pal = mTimeBox->palette(); 76 QPalette pal = mTimeBox->palette();
76 pal.setColor(QColorGroup::Foreground, Qt::red); 77 pal.setColor(QColorGroup::Foreground, Qt::red);
77 mTimeBox->setPalette(pal); 78 mTimeBox->setPalette(pal);
78 //mTimeBox->setAutoMask(true); 79 //mTimeBox->setAutoMask(true);
79 80
80 agenda->addChild(mTimeBox); 81 agenda->addChild(mTimeBox);
81 82
82 oldToday = -1; 83 oldToday = -1;
83} 84}
84 85
85MarcusBains::~MarcusBains() 86MarcusBains::~MarcusBains()
86{ 87{
87 delete minutes; 88 delete minutes;
88} 89}
89 90
90int MarcusBains::todayColumn() 91int MarcusBains::todayColumn()
91{ 92{
92 QDate currentDate = QDate::currentDate(); 93 QDate currentDate = QDate::currentDate();
93 94
94 DateList dateList = agenda->dateList(); 95 DateList dateList = agenda->dateList();
95 DateList::ConstIterator it; 96 DateList::ConstIterator it;
96 int col = 0; 97 int col = 0;
97 for(it = dateList.begin(); it != dateList.end(); ++it) { 98 for(it = dateList.begin(); it != dateList.end(); ++it) {
98 if((*it) == currentDate) 99 if((*it) == currentDate)
99 return KOGlobals::self()->reverseLayout() ? 100 return KOGlobals::self()->reverseLayout() ?
100 agenda->columns() - 1 - col : col; 101 agenda->columns() - 1 - col : col;
101 ++col; 102 ++col;
102 } 103 }
103 104
104 return -1; 105 return -1;
105} 106}
106void MarcusBains::updateLoc() 107void MarcusBains::updateLoc()
107{ 108{
108 updateLocation(); 109 updateLocation();
109} 110}
110void MarcusBains::updateLocation(bool recalculate) 111void MarcusBains::updateLocation(bool recalculate)
@@ -133,96 +134,97 @@ void MarcusBains::updateLocation(bool recalculate)
133 } 134 }
134 135
135 if(recalculate) 136 if(recalculate)
136 setFixedSize(agenda->gridSpacingX(),1); 137 setFixedSize(agenda->gridSpacingX(),1);
137 agenda->moveChild(this, x, y); 138 agenda->moveChild(this, x, y);
138 raise(); 139 raise();
139 140
140 if(recalculate) 141 if(recalculate)
141 //mTimeBox->setFont(QFont("helvetica",10)); 142 //mTimeBox->setFont(QFont("helvetica",10));
142 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); 143 mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont);
143 144
144 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); 145 mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds));
145 mTimeBox->adjustSize(); 146 mTimeBox->adjustSize();
146 // the -2 below is there because there is a bug in this program 147 // the -2 below is there because there is a bug in this program
147 // somewhere, where the last column of this widget is a few pixels 148 // somewhere, where the last column of this widget is a few pixels
148 // narrower than the other columns. 149 // narrower than the other columns.
149 int offs = (today==agenda->columns()-1) ? -4 : 0; 150 int offs = (today==agenda->columns()-1) ? -4 : 0;
150 agenda->moveChild(mTimeBox, 151 agenda->moveChild(mTimeBox,
151 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, 152 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1,
152 y-mTimeBox->height()); 153 y-mTimeBox->height());
153 154
154 mTimeBox->raise(); 155 mTimeBox->raise();
155 //mTimeBox->setAutoMask(true); 156 //mTimeBox->setAutoMask(true);
156 minutes->start(5000,true); 157 minutes->start(5000,true);
157} 158}
158 159
159 160
160//////////////////////////////////////////////////////////////////////////// 161////////////////////////////////////////////////////////////////////////////
161 162
162 163
163/* 164/*
164 Create an agenda widget with rows rows and columns columns. 165 Create an agenda widget with rows rows and columns columns.
165*/ 166*/
166KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, 167KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent,
167 const char *name,WFlags f) : 168 const char *name,WFlags f) :
168 QScrollView(parent,name,f) 169 QScrollView(parent,name,f)
169{ 170{
170 171
171 mAllAgendaPopup = 0; 172 mAllAgendaPopup = 0;
172 mColumns = columns; 173 mColumns = columns;
173 mRows = rows; 174 mRows = rows;
174 mGridSpacingY = rowSize; 175 mGridSpacingY = rowSize;
175 mAllDayMode = false; 176 mAllDayMode = false;
176#ifndef DESKTOP_VERSION 177#ifndef DESKTOP_VERSION
177 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 178 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
178#endif 179#endif
179 mHolidayMask = 0; 180 mHolidayMask = 0;
180 init(); 181 init();
182 connect ( this, SIGNAL (contentsMoving ( int , int ) ), this, SLOT ( slotContentMove(int,int)) );
181} 183}
182 184
183/* 185/*
184 Create an agenda widget with columns columns and one row. This is used for 186 Create an agenda widget with columns columns and one row. This is used for
185 all-day events. 187 all-day events.
186*/ 188*/
187KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : 189KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) :
188 QScrollView(parent,name,f) 190 QScrollView(parent,name,f)
189{ 191{
190 mAllAgendaPopup = 0; 192 mAllAgendaPopup = 0;
191 blockResize = false; 193 blockResize = false;
192 mColumns = columns; 194 mColumns = columns;
193 mRows = 1; 195 mRows = 1;
194 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); 196 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize);
195 mGridSpacingY = KOPrefs::instance()->mAllDaySize; 197 mGridSpacingY = KOPrefs::instance()->mAllDaySize;
196 mAllDayMode = true; 198 mAllDayMode = true;
197#ifndef DESKTOP_VERSION 199#ifndef DESKTOP_VERSION
198 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 200 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
199#endif 201#endif
200 mHolidayMask = 0; 202 mHolidayMask = 0;
201 init(); 203 init();
202} 204}
203 205
204 206
205KOAgenda::~KOAgenda() 207KOAgenda::~KOAgenda()
206{ 208{
207 if(mMarcusBains) delete mMarcusBains; 209 if(mMarcusBains) delete mMarcusBains;
208 210
209} 211}
210 212
211Incidence *KOAgenda::selectedIncidence() const 213Incidence *KOAgenda::selectedIncidence() const
212{ 214{
213 return (mSelectedItem ? mSelectedItem->incidence() : 0); 215 return (mSelectedItem ? mSelectedItem->incidence() : 0);
214} 216}
215 217
216 218
217QDate KOAgenda::selectedIncidenceDate() const 219QDate KOAgenda::selectedIncidenceDate() const
218{ 220{
219 return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); 221 return (mSelectedItem ? mSelectedItem->itemDate() : QDate());
220} 222}
221 223
222 224
223void KOAgenda::init() 225void KOAgenda::init()
224{ 226{
225 mPopupTimer = new QTimer(this); 227 mPopupTimer = new QTimer(this);
226 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); 228 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu()));
227 229
228 mNewItemPopup = new QPopupMenu( this ); 230 mNewItemPopup = new QPopupMenu( this );
@@ -272,98 +274,114 @@ void KOAgenda::init()
272 mSelectionYTop = 0; 274 mSelectionYTop = 0;
273 mSelectionHeight = 0; 275 mSelectionHeight = 0;
274 276
275 mOldLowerScrollValue = -1; 277 mOldLowerScrollValue = -1;
276 mOldUpperScrollValue = -1; 278 mOldUpperScrollValue = -1;
277 279
278 mClickedItem = 0; 280 mClickedItem = 0;
279 281
280 mActionItem = 0; 282 mActionItem = 0;
281 mActionType = NOP; 283 mActionType = NOP;
282 mItemMoved = false; 284 mItemMoved = false;
283 285
284 mSelectedItem = 0; 286 mSelectedItem = 0;
285 287
286 // mItems.setAutoDelete(true); 288 // mItems.setAutoDelete(true);
287 289
288 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 290 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
289 291
290 viewport()->update(); 292 viewport()->update();
291 293
292 setMinimumSize(30, 1); 294 setMinimumSize(30, 1);
293// setMaximumHeight(mGridSpacingY * mRows + 5); 295// setMaximumHeight(mGridSpacingY * mRows + 5);
294 296
295 // Disable horizontal scrollbar. This is a hack. The geometry should be 297 // Disable horizontal scrollbar. This is a hack. The geometry should be
296 // controlled in a way that the contents horizontally always fits. Then it is 298 // controlled in a way that the contents horizontally always fits. Then it is
297 // not necessary to turn off the scrollbar. 299 // not necessary to turn off the scrollbar.
298 setHScrollBarMode(AlwaysOff); 300 setHScrollBarMode(AlwaysOff);
299 if ( ! mAllDayMode ) 301 if ( ! mAllDayMode )
300 setVScrollBarMode(AlwaysOn); 302 setVScrollBarMode(AlwaysOn);
301 else 303 else
302 setVScrollBarMode(AlwaysOff); 304 setVScrollBarMode(AlwaysOff);
303 305
304 setStartHour(KOPrefs::instance()->mDayBegins); 306 setStartHour(KOPrefs::instance()->mDayBegins);
305 307
306 calculateWorkingHours(); 308 calculateWorkingHours();
307 309
308 connect(verticalScrollBar(),SIGNAL(valueChanged(int)), 310 connect(verticalScrollBar(),SIGNAL(valueChanged(int)),
309 SLOT(checkScrollBoundaries(int))); 311 SLOT(checkScrollBoundaries(int)));
310 312
311 // Create the Marcus Bains line. 313 // Create the Marcus Bains line.
312 if(mAllDayMode) 314 if(mAllDayMode)
313 mMarcusBains = 0; 315 mMarcusBains = 0;
314 else { 316 else {
315 mMarcusBains = new MarcusBains(this); 317 mMarcusBains = new MarcusBains(this);
316 addChild(mMarcusBains); 318 addChild(mMarcusBains);
317 } 319 }
318 mPopupKind = 0; 320 mPopupKind = 0;
319 mPopupItem = 0; 321 mPopupItem = 0;
322 mInvalidPixmap = false;
323
320} 324}
321 325
326void KOAgenda::shrinkPixmap()
327{
328 mPaintPixmap.resize( 20,20);
329 mInvalidPixmap = true;
330}
331void KOAgenda::slotContentMove(int,int)
332{
333 if ( mActionType == NOP )
334 slotClearSelection();
335 if ( mSelectedItem && !mActionItem ) {
336 deselectItem();
337 emit incidenceSelected( 0 );
338 }
339}
322void KOAgenda::clear() 340void KOAgenda::clear()
323{ 341{
324 KOAgendaItem *item; 342 KOAgendaItem *item;
325 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 343 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
326 mUnusedItems.append( item ); 344 mUnusedItems.append( item );
327 //item->hide(); 345 //item->hide();
328 } 346 }
329 mItems.clear(); 347 mItems.clear();
330 mSelectedItem = 0; 348 mSelectedItem = 0;
331 clearSelection(); 349 clearSelection();
332} 350}
333 351
334void KOAgenda::clearSelection() 352void KOAgenda::clearSelection()
335{ 353{
336 mSelectionCellX = 0; 354 mSelectionCellX = 0;
337 mSelectionYTop = 0; 355 mSelectionYTop = 0;
338 mSelectionHeight = 0; 356 mSelectionHeight = 0;
339} 357}
340 358
341void KOAgenda::marcus_bains() 359void KOAgenda::marcus_bains()
342{ 360{
343 if(mMarcusBains) mMarcusBains->updateLocation(true); 361 if(mMarcusBains) mMarcusBains->updateLocation(true);
344} 362}
345 363
346 364
347void KOAgenda::changeColumns(int columns) 365void KOAgenda::changeColumns(int columns)
348{ 366{
349 if (columns == 0) { 367 if (columns == 0) {
350 qDebug("KOAgenda::changeColumns() called with argument 0 "); 368 qDebug("KOAgenda::changeColumns() called with argument 0 ");
351 return; 369 return;
352 } 370 }
353 clear(); 371 clear();
354 mColumns = columns; 372 mColumns = columns;
355 computeSizes(); 373 computeSizes();
356} 374}
357 375
358/* 376/*
359 This is the eventFilter function, which gets all events from the KOAgendaItems 377 This is the eventFilter function, which gets all events from the KOAgendaItems
360 contained in the agenda. It has to handle moving and resizing for all items. 378 contained in the agenda. It has to handle moving and resizing for all items.
361*/ 379*/
362bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) 380bool KOAgenda::eventFilter ( QObject *object, QEvent *event )
363{ 381{
364 // kdDebug() << "KOAgenda::eventFilter" << endl; 382 // kdDebug() << "KOAgenda::eventFilter" << endl;
365 switch(event->type()) { 383 switch(event->type()) {
366 case QEvent::MouseButtonPress: 384 case QEvent::MouseButtonPress:
367 case QEvent::MouseButtonDblClick: 385 case QEvent::MouseButtonDblClick:
368 case QEvent::MouseButtonRelease: 386 case QEvent::MouseButtonRelease:
369 case QEvent::MouseMove: 387 case QEvent::MouseMove:
@@ -877,96 +895,97 @@ void KOAgenda::performItemAction(QPoint viewportPos)
877 } 895 }
878 } else { 896 } else {
879 switch ( mActionType ) { 897 switch ( mActionType ) {
880 case MOVE: 898 case MOVE:
881 setCursor( sizeAllCursor ); 899 setCursor( sizeAllCursor );
882 break; 900 break;
883 case RESIZETOP: 901 case RESIZETOP:
884 case RESIZEBOTTOM: 902 case RESIZEBOTTOM:
885 setCursor( sizeVerCursor ); 903 setCursor( sizeVerCursor );
886 break; 904 break;
887 case RESIZELEFT: 905 case RESIZELEFT:
888 case RESIZERIGHT: 906 case RESIZERIGHT:
889 setCursor( sizeHorCursor ); 907 setCursor( sizeHorCursor );
890 break; 908 break;
891 default: 909 default:
892 setCursor( arrowCursor ); 910 setCursor( arrowCursor );
893 } 911 }
894 } 912 }
895 913
896 // Scroll if item was moved to upper or lower end of agenda. 914 // Scroll if item was moved to upper or lower end of agenda.
897 if (clipperPos.y() < mScrollBorderWidth) { 915 if (clipperPos.y() < mScrollBorderWidth) {
898 mScrollUpTimer.start(mScrollDelay); 916 mScrollUpTimer.start(mScrollDelay);
899 } else if (visibleHeight() - clipperPos.y() < 917 } else if (visibleHeight() - clipperPos.y() <
900 mScrollBorderWidth) { 918 mScrollBorderWidth) {
901 mScrollDownTimer.start(mScrollDelay); 919 mScrollDownTimer.start(mScrollDelay);
902 } else { 920 } else {
903 mScrollUpTimer.stop(); 921 mScrollUpTimer.stop();
904 mScrollDownTimer.stop(); 922 mScrollDownTimer.stop();
905 } 923 }
906 924
907 // Move or resize item if necessary 925 // Move or resize item if necessary
908 if (mCurrentCellX != gx || mCurrentCellY != gy) { 926 if (mCurrentCellX != gx || mCurrentCellY != gy) {
909 mItemMoved = true; 927 mItemMoved = true;
910 mActionItem->raise(); 928 mActionItem->raise();
911 if (mActionType == MOVE) { 929 if (mActionType == MOVE) {
912 // Move all items belonging to a multi item 930 // Move all items belonging to a multi item
913 KOAgendaItem *moveItem = mActionItem->firstMultiItem(); 931 KOAgendaItem *moveItem = mActionItem->firstMultiItem();
914 bool isMultiItem = (moveItem || mActionItem->lastMultiItem()); 932 bool isMultiItem = (moveItem || mActionItem->lastMultiItem());
915 if (!moveItem) moveItem = mActionItem; 933 if (!moveItem) moveItem = mActionItem;
916 while (moveItem) { 934 while (moveItem) {
917 int dy; 935 int dy;
918 if (isMultiItem) dy = 0; 936 if (isMultiItem) dy = 0;
919 else dy = gy - mCurrentCellY; 937 else dy = gy - mCurrentCellY;
920 moveItem->moveRelative(gx - mCurrentCellX,dy); 938 moveItem->moveRelative(gx - mCurrentCellX,dy);
921 int x,y; 939 int x,y;
922 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y); 940 gridToContents(moveItem->cellX(),moveItem->cellYTop(),x,y);
923 moveItem->resize(mGridSpacingX * moveItem->cellWidth(), 941 moveItem->resize(mGridSpacingX * moveItem->cellWidth(),
924 mGridSpacingY * moveItem->cellHeight()); 942 mGridSpacingY * moveItem->cellHeight());
943 moveItem->raise();
925 moveChild(moveItem,x,y); 944 moveChild(moveItem,x,y);
926 moveItem = moveItem->nextMultiItem(); 945 moveItem = moveItem->nextMultiItem();
927 } 946 }
928 } else if (mActionType == RESIZETOP) { 947 } else if (mActionType == RESIZETOP) {
929 if (mCurrentCellY <= mActionItem->cellYBottom()) { 948 if (mCurrentCellY <= mActionItem->cellYBottom()) {
930 mActionItem->expandTop(gy - mCurrentCellY); 949 mActionItem->expandTop(gy - mCurrentCellY);
931 mActionItem->resize(mActionItem->width(), 950 mActionItem->resize(mActionItem->width(),
932 mGridSpacingY * mActionItem->cellHeight()); 951 mGridSpacingY * mActionItem->cellHeight());
933 int x,y; 952 int x,y;
934 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y); 953 gridToContents(mCurrentCellX,mActionItem->cellYTop(),x,y);
935 //moveChild(mActionItem,childX(mActionItem),y); 954 //moveChild(mActionItem,childX(mActionItem),y);
936 QScrollView::moveChild( mActionItem,childX(mActionItem),y ); 955 QScrollView::moveChild( mActionItem,childX(mActionItem),y );
937 } 956 }
938 } else if (mActionType == RESIZEBOTTOM) { 957 } else if (mActionType == RESIZEBOTTOM) {
939 if (mCurrentCellY >= mActionItem->cellYTop()) { 958 if (mCurrentCellY >= mActionItem->cellYTop()) {
940 mActionItem->expandBottom(gy - mCurrentCellY); 959 mActionItem->expandBottom(gy - mCurrentCellY);
941 mActionItem->resize(mActionItem->width(), 960 mActionItem->resize(mActionItem->width(),
942 mGridSpacingY * mActionItem->cellHeight()); 961 mGridSpacingY * mActionItem->cellHeight());
943 } 962 }
944 } else if (mActionType == RESIZELEFT) { 963 } else if (mActionType == RESIZELEFT) {
945 if (mCurrentCellX <= mActionItem->cellXWidth()) { 964 if (mCurrentCellX <= mActionItem->cellXWidth()) {
946 mActionItem->expandLeft(gx - mCurrentCellX); 965 mActionItem->expandLeft(gx - mCurrentCellX);
947 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 966 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
948 mActionItem->height()); 967 mActionItem->height());
949 int x,y; 968 int x,y;
950 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y); 969 gridToContents(mActionItem->cellX(),mActionItem->cellYTop(),x,y);
951 moveChild(mActionItem,x,childY(mActionItem)); 970 moveChild(mActionItem,x,childY(mActionItem));
952 } 971 }
953 } else if (mActionType == RESIZERIGHT) { 972 } else if (mActionType == RESIZERIGHT) {
954 if (mCurrentCellX >= mActionItem->cellX()) { 973 if (mCurrentCellX >= mActionItem->cellX()) {
955 mActionItem->expandRight(gx - mCurrentCellX); 974 mActionItem->expandRight(gx - mCurrentCellX);
956 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(), 975 mActionItem->resize(mGridSpacingX * mActionItem->cellWidth(),
957 mActionItem->height()); 976 mActionItem->height());
958 } 977 }
959 } 978 }
960 mCurrentCellX = gx; 979 mCurrentCellX = gx;
961 mCurrentCellY = gy; 980 mCurrentCellY = gy;
962 } 981 }
963} 982}
964 983
965void KOAgenda::endItemAction() 984void KOAgenda::endItemAction()
966{ 985{
967 986
968 if ( mItemMoved ) { 987 if ( mItemMoved ) {
969 KOAgendaItem *placeItem = mActionItem->firstMultiItem(); 988 KOAgendaItem *placeItem = mActionItem->firstMultiItem();
970 if ( !placeItem ) { 989 if ( !placeItem ) {
971 placeItem = mActionItem; 990 placeItem = mActionItem;
972 } 991 }
@@ -1199,96 +1218,103 @@ void KOAgenda::placeSubCells(KOAgendaItem *placeItem)
1199 item=conflictItems.next() ) { 1218 item=conflictItems.next() ) {
1200 if ( placeItem != item ) { 1219 if ( placeItem != item ) {
1201 KOAgendaItem *item2; 1220 KOAgendaItem *item2;
1202 QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems(); 1221 QPtrList<KOAgendaItem> conflictItems2 = item->conflictItems();
1203 for ( item2=conflictItems2.first(); item2 != 0; 1222 for ( item2=conflictItems2.first(); item2 != 0;
1204 item2=conflictItems2.next() ) { 1223 item2=conflictItems2.next() ) {
1205 if ( item2->subCells() != maxSubCells) { 1224 if ( item2->subCells() != maxSubCells) {
1206 item2->setSubCells(maxSubCells); 1225 item2->setSubCells(maxSubCells);
1207 if (mAllDayMode) { 1226 if (mAllDayMode) {
1208 item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth); 1227 item2->resize(item2->cellWidth() * mGridSpacingX, newSubCellWidth);
1209 } else { 1228 } else {
1210 item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY); 1229 item2->resize(newSubCellWidth, item2->cellHeight() * mGridSpacingY);
1211 } 1230 }
1212 int x,y; 1231 int x,y;
1213 gridToContents(item2->cellX(),item2->cellYTop(),x,y); 1232 gridToContents(item2->cellX(),item2->cellYTop(),x,y);
1214 if (mAllDayMode) { 1233 if (mAllDayMode) {
1215 y += item2->subCell() * newSubCellWidth; 1234 y += item2->subCell() * newSubCellWidth;
1216 } else { 1235 } else {
1217 x += item2->subCell() * newSubCellWidth; 1236 x += item2->subCell() * newSubCellWidth;
1218 } 1237 }
1219 moveChild(item2,x,y); 1238 moveChild(item2,x,y);
1220 //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() ); 1239 //qDebug("setttttt %d %s",maxSubCells, item2->text().latin1() );
1221 } 1240 }
1222 } 1241 }
1223 } 1242 }
1224 } 1243 }
1225 } else { 1244 } else {
1226 placeItem->setSubCell(0); 1245 placeItem->setSubCell(0);
1227 placeItem->setSubCells(1); 1246 placeItem->setSubCells(1);
1228 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY); 1247 if (mAllDayMode) placeItem->resize(placeItem->width(),mGridSpacingY);
1229 else placeItem->resize(mGridSpacingX,placeItem->height()); 1248 else placeItem->resize(mGridSpacingX,placeItem->height());
1230 int x,y; 1249 int x,y;
1231 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y); 1250 gridToContents(placeItem->cellX(),placeItem->cellYTop(),x,y);
1232 moveChild(placeItem,x,y); 1251 moveChild(placeItem,x,y);
1233 } 1252 }
1234 placeItem->setConflictItems(conflictItems); 1253 placeItem->setConflictItems(conflictItems);
1235 // for ( item=conflictItems.first(); item != 0; 1254 // for ( item=conflictItems.first(); item != 0;
1236// item=conflictItems.next() ) { 1255// item=conflictItems.next() ) {
1237// //item->updateItem(); 1256// //item->updateItem();
1238// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() ); 1257// //qDebug("xxx item->updateItem() %s %d %d", item->incidence()->summary().latin1(),item->x(), item->y() );
1239// } 1258// }
1240// placeItem->updateItem(); 1259// placeItem->updateItem();
1241} 1260}
1242 1261
1243void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch) 1262void KOAgenda::drawContents(QPainter* p, int cx, int cy, int cw, int ch)
1244{ 1263{
1245 if ( globalFlagBlockAgenda ) 1264 if ( globalFlagBlockAgenda )
1246 return; 1265 return;
1266
1267 if ( mInvalidPixmap ) {
1268 mInvalidPixmap = false;
1269 qDebug("InvalidPixmap ");
1270 QTimer::singleShot( 0, this, SIGNAL( updateViewSignal() ));
1271 return;
1272 }
1247 if ( ! mAllDayMode ) { 1273 if ( ! mAllDayMode ) {
1248 // currently not working for 1274 // currently not working for
1249 1275
1250 //qDebug("KOAgenda::drawContents "); 1276 //qDebug("KOAgenda::drawContents ");
1251 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() ) 1277 if ( mCurPixWid != contentsWidth() || mCurPixHei != contentsHeight() )
1252 ;//drawContentsToPainter(); 1278 ;//drawContentsToPainter();
1253 1279
1254 QPaintDevice* pd = p->device(); 1280 QPaintDevice* pd = p->device();
1255 p->end(); 1281 p->end();
1256 int vx, vy; 1282 int vx, vy;
1257 int selectionX = KOGlobals::self()->reverseLayout() ? 1283 int selectionX = KOGlobals::self()->reverseLayout() ?
1258 (mColumns - 1 - mSelectionCellX) * mGridSpacingX : 1284 (mColumns - 1 - mSelectionCellX) * mGridSpacingX :
1259 mSelectionCellX * mGridSpacingX; 1285 mSelectionCellX * mGridSpacingX;
1260 contentsToViewport ( cx, cy, vx,vy); 1286 contentsToViewport ( cx, cy, vx,vy);
1261 //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ; 1287 //qDebug(" %d %d %d %d %d", cx, cy, cw,ch,mGridSpacingX-1) ;
1262 1288
1263 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) { 1289 if ( !(selectionX == cx && cy == mSelectionYTop && cw ==mGridSpacingX && ch == mSelectionHeight ) ) {
1264 if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1290 if ( mGridSpacingX == cw && mSelectionHeight > 0 && ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1265 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) { 1291 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) ) {
1266 1292
1267 int vxSel, vySel; 1293 int vxSel, vySel;
1268 contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel); 1294 contentsToViewport ( selectionX, mSelectionYTop, vxSel,vySel);
1269 int off = mSelectionHeight; 1295 int off = mSelectionHeight;
1270 if ( vySel < 0 ) 1296 if ( vySel < 0 )
1271 off += vySel; 1297 off += vySel;
1272 //qDebug("OFF %d %d %d", off,vySel, vy ); 1298 //qDebug("OFF %d %d %d", off,vySel, vy );
1273 bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP); 1299 bitBlt ( pd, vx, vy+off, &mPaintPixmap, cx, cy+off, cw , ch-off ,CopyROP);
1274 } else { 1300 } else {
1275 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP); 1301 bitBlt ( pd, vx, vy, &mPaintPixmap, cx, cy, cw, ch ,CopyROP);
1276 } 1302 }
1277 } 1303 }
1278 if ( mSelectionHeight > 0 ) { 1304 if ( mSelectionHeight > 0 ) {
1279 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight ); 1305 //qDebug("---- %d %d %d %d ", selectionX, mSelectionYTop, mGridSpacingX, mSelectionHeight );
1280 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) && 1306 if ( ( cx + cw ) >= selectionX && cx <= ( selectionX + mGridSpacingX ) &&
1281 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) { 1307 ( cy + ch ) >= mSelectionYTop && cy <= ( mSelectionYTop + mSelectionHeight ) ) {
1282 contentsToViewport ( selectionX, mSelectionYTop, vx,vy); 1308 contentsToViewport ( selectionX, mSelectionYTop, vx,vy);
1283 // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP); 1309 // bitBlt ( pd, vx+1, vy, &mHighlightPixmap, 0, mSelectionYTop, mGridSpacingX-1, mSelectionHeight ,CopyROP);
1284 int hei = mSelectionHeight; 1310 int hei = mSelectionHeight;
1285 int offset = 0; 1311 int offset = 0;
1286 while ( hei > 0 ) { 1312 while ( hei > 0 ) {
1287 int p_hei = 5; 1313 int p_hei = 5;
1288 if ( hei < 5 ) p_hei = hei; 1314 if ( hei < 5 ) p_hei = hei;
1289 hei -= 5; 1315 hei -= 5;
1290 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP); 1316 bitBlt ( pd, vx+1, vy+offset, &mHighlightPixmap, 0, 0, mGridSpacingX-1, p_hei ,CopyROP);
1291 offset += 5; 1317 offset += 5;
1292 } 1318 }
1293 } 1319 }
1294 } 1320 }
@@ -1871,103 +1897,103 @@ void KOAgenda::computeSizes()
1871{ 1897{
1872 if ( globalFlagBlockStartup ) 1898 if ( globalFlagBlockStartup )
1873 return; 1899 return;
1874 int frameOffset = frameWidth() * 2 +1; 1900 int frameOffset = frameWidth() * 2 +1;
1875 if (mAllDayMode) { 1901 if (mAllDayMode) {
1876 mGridSpacingX = (width()-frameOffset) / mColumns; 1902 mGridSpacingX = (width()-frameOffset) / mColumns;
1877 mGridSpacingY = height() - 2 * frameWidth() - 1; 1903 mGridSpacingY = height() - 2 * frameWidth() - 1;
1878 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1); 1904 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY + 1);
1879 // mGridSpacingY = height(); 1905 // mGridSpacingY = height();
1880 // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1906 // resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1881 1907
1882 KOAgendaItem *item; 1908 KOAgendaItem *item;
1883 int subCellWidth; 1909 int subCellWidth;
1884 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1910 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1885 subCellWidth = mGridSpacingY / item->subCells(); 1911 subCellWidth = mGridSpacingY / item->subCells();
1886 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth); 1912 item->resize(mGridSpacingX * item->cellWidth(),subCellWidth);
1887 moveChild(item,KOGlobals::self()->reverseLayout() ? 1913 moveChild(item,KOGlobals::self()->reverseLayout() ?
1888 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1914 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1889 item->cellX() * mGridSpacingX, 1915 item->cellX() * mGridSpacingX,
1890 item->subCell() * subCellWidth); 1916 item->subCell() * subCellWidth);
1891 } 1917 }
1892 KOPrefs::instance()->mAllDaySize = mGridSpacingY; 1918 KOPrefs::instance()->mAllDaySize = mGridSpacingY;
1893 } else { 1919 } else {
1894 mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns; 1920 mGridSpacingX = (width() - verticalScrollBar()->width()-frameOffset)/mColumns;
1895 if (height() > mGridSpacingY * mRows + 1 ) { 1921 if (height() > mGridSpacingY * mRows + 1 ) {
1896 KOPrefs::instance()->mHourSize = ((height())/mRows)+1; 1922 KOPrefs::instance()->mHourSize = ((height())/mRows)+1;
1897 mGridSpacingY = KOPrefs::instance()->mHourSize ; 1923 mGridSpacingY = KOPrefs::instance()->mHourSize ;
1898 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1924 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1899 emit resizedSignal(); 1925 emit resizedSignal();
1900 } else 1926 } else
1901 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 1927 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
1902 KOAgendaItem *item; 1928 KOAgendaItem *item;
1903 int subCellWidth; 1929 int subCellWidth;
1904 1930
1905 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 1931 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
1906 subCellWidth = mGridSpacingX / item->subCells(); 1932 subCellWidth = mGridSpacingX / item->subCells();
1907 item->resize(subCellWidth,item->height()); 1933 item->resize(subCellWidth,item->height());
1908 moveChild(item,(KOGlobals::self()->reverseLayout() ? 1934 moveChild(item,(KOGlobals::self()->reverseLayout() ?
1909 (mColumns - 1 - item->cellX()) * mGridSpacingX : 1935 (mColumns - 1 - item->cellX()) * mGridSpacingX :
1910 item->cellX() * mGridSpacingX) + 1936 item->cellX() * mGridSpacingX) +
1911 item->subCell() * subCellWidth,childY(item)); 1937 item->subCell() * subCellWidth,childY(item));
1912 } 1938 }
1913 } 1939 }
1914 int cw = contentsWidth(); 1940 int cw = contentsWidth();
1915 int ch = contentsHeight(); 1941 int ch = contentsHeight();
1916 if ( mAllDayMode ) { 1942 if ( mAllDayMode ) {
1917 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday(); 1943 QPixmap* paintPixAll = KOAgendaItem::paintPixAllday();
1918 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) { 1944 if ( (paintPixAll->width() < cw || paintPixAll->height() < ch) && cw > 0 && ch > 0 ) {
1919 //qDebug("paintPixAll->resize "); 1945 qDebug("paintPixAll->resize ");
1920 paintPixAll->resize( cw, ch ); 1946 paintPixAll->resize( cw, ch );
1921 } 1947 }
1922 } else { 1948 } else {
1923 QPixmap* paintPix = KOAgendaItem::paintPix(); 1949 QPixmap* paintPix = KOAgendaItem::paintPix();
1924 if ( paintPix->width() < cw || paintPix->height() < ch ) { 1950 if ( paintPix->width() < cw || paintPix->height() < ch ) {
1925 //qDebug("paintPix->resize "); 1951 qDebug("paintPix->resize ");
1926 paintPix->resize( cw , ch ); 1952 paintPix->resize( cw , ch );
1927 } 1953 }
1928 } 1954 }
1929 1955
1930 checkScrollBoundaries(); 1956 checkScrollBoundaries();
1931 marcus_bains(); 1957 marcus_bains();
1932 drawContentsToPainter(); 1958 drawContentsToPainter();
1933 viewport()->repaint(false); 1959 viewport()->repaint(false);
1934} 1960}
1935 1961
1936void KOAgenda::scrollUp() 1962void KOAgenda::scrollUp()
1937{ 1963{
1938 scrollBy(0,-mScrollOffset); 1964 scrollBy(0,-mScrollOffset);
1939} 1965}
1940 1966
1941 1967
1942void KOAgenda::scrollDown() 1968void KOAgenda::scrollDown()
1943{ 1969{
1944 scrollBy(0,mScrollOffset); 1970 scrollBy(0,mScrollOffset);
1945} 1971}
1946 1972
1947void KOAgenda::popupAlarm() 1973void KOAgenda::popupAlarm()
1948{ 1974{
1949 if (!mClickedItem) { 1975 if (!mClickedItem) {
1950 qDebug("KOAgenda::popupAlarm() called without having a clicked item "); 1976 qDebug("KOAgenda::popupAlarm() called without having a clicked item ");
1951 return; 1977 return;
1952 } 1978 }
1953 // TODO: deal correctly with multiple alarms 1979 // TODO: deal correctly with multiple alarms
1954 Alarm* alarm; 1980 Alarm* alarm;
1955 QPtrList<Alarm> list(mClickedItem->incidence()->alarms()); 1981 QPtrList<Alarm> list(mClickedItem->incidence()->alarms());
1956 for(alarm=list.first();alarm;alarm=list.next()) { 1982 for(alarm=list.first();alarm;alarm=list.next()) {
1957 alarm->toggleAlarm(); 1983 alarm->toggleAlarm();
1958 } 1984 }
1959 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED ); 1985 emit itemModified( mClickedItem , KOGlobals::EVENTEDITED );
1960 mClickedItem->paintMe( true ); 1986 mClickedItem->paintMe( true );
1961 mClickedItem->repaint( false ); 1987 mClickedItem->repaint( false );
1962} 1988}
1963 1989
1964/* 1990/*
1965 Calculates the minimum width 1991 Calculates the minimum width
1966*/ 1992*/
1967int KOAgenda::minimumWidth() const 1993int KOAgenda::minimumWidth() const
1968{ 1994{
1969 // TODO:: develop a way to dynamically determine the minimum width 1995 // TODO:: develop a way to dynamically determine the minimum width
1970 int min = 100; 1996 int min = 100;
1971 1997
1972 return min; 1998 return min;
1973} 1999}