summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-03-22 12:05:42 (UTC)
committer zautrix <zautrix>2005-03-22 12:05:42 (UTC)
commit345c70e057e730850493689185b5c358607566f9 (patch) (side-by-side diff)
tree5081ceed28a61012c1c4d2c7200205fdbedc6435 /korganizer
parentdfd7d8d53c7ab916dee820c2371195a5dce134a4 (diff)
downloadkdepimpi-345c70e057e730850493689185b5c358607566f9.zip
kdepimpi-345c70e057e730850493689185b5c358607566f9.tar.gz
kdepimpi-345c70e057e730850493689185b5c358607566f9.tar.bz2
more layout fixes
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/datenavigatorcontainer.cpp83
-rw-r--r--korganizer/datenavigatorcontainer.h2
-rw-r--r--korganizer/kdatenavigator.h3
-rw-r--r--korganizer/kodaymatrix.cpp16
-rw-r--r--korganizer/kodaymatrix.h2
5 files changed, 82 insertions, 24 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp
index 18756f0..bb27bce 100644
--- a/korganizer/datenavigatorcontainer.cpp
+++ b/korganizer/datenavigatorcontainer.cpp
@@ -1,276 +1,319 @@
/*
This file is part of KOrganizer.
Copyright (c) 2001,2002,2003 Cornelius Schumacher <schumacher@kde.org>
Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#include <kdebug.h>
#include <klocale.h>
//#include "koglobals.h"
#include "navigatorbar.h"
#include "kdatenavigator.h"
#include <kcalendarsystem.h>
#include "datenavigatorcontainer.h"
#include "koprefs.h"
DateNavigatorContainer::DateNavigatorContainer( QWidget *parent,
const char *name )
: QWidget( parent, name ), mCalendar( 0 ),
mHorizontalCount( 1 ), mVerticalCount( 1 )
{
mExtraViews.setAutoDelete( true );
mNavigatorView = new KDateNavigator( this, name );
connectNavigatorView( mNavigatorView );
//setSizePolicy( QSizePolicy (QSizePolicy::Expanding,QSizePolicy::Expanding) );
+ mDisplayedEndDate = QDate::currentDate();
+ mLastDisplayedDN = 0;
}
DateNavigatorContainer::~DateNavigatorContainer()
{
}
void DateNavigatorContainer::connectNavigatorView( KDateNavigator *v )
{
connect( v, SIGNAL( datesSelected( const KCal::DateList & ) ),
SIGNAL( datesSelected( const KCal::DateList & ) ) );
#if 0
connect( v, SIGNAL( incidenceDropped( Incidence *, const QDate & ) ),
SIGNAL( incidenceDropped( Incidence *, const QDate & ) ) );
connect( v, SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ),
SIGNAL( incidenceDroppedMove( Incidence *, const QDate & ) ) );
#endif
connect( v, SIGNAL( weekClicked( const QDate & ) ),
SIGNAL( weekClicked( const QDate & ) ) );
connect( v, SIGNAL( goPrevious() ), SIGNAL( goPrevious() ) );
connect( v, SIGNAL( goNext() ), SIGNAL( goNext() ) );
connect( v, SIGNAL( goNextMonth() ), SIGNAL( goNextMonth() ) );
connect( v, SIGNAL( goPrevMonth() ), SIGNAL( goPrevMonth() ) );
connect( v, SIGNAL( goNextYear() ), SIGNAL( goNextYear() ) );
connect( v, SIGNAL( goPrevYear() ), SIGNAL( goPrevYear() ) );
connect( v, SIGNAL( monthSelected( int ) ), SIGNAL( monthSelected( int ) ) );
}
void DateNavigatorContainer::setCalendar( Calendar *cal )
{
mCalendar = cal;
mNavigatorView->setCalendar( cal );
- KDateNavigator *n;
- for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
- n->setCalendar( cal );
+ for( uint i = 0; i < mLastDisplayedDN; ++i ) {
+ KDateNavigator *n = mExtraViews.at( i );
+ n->setCalendar( cal );
}
}
void DateNavigatorContainer::updateDayMatrix()
{
mNavigatorView->updateDayMatrix();
- KDateNavigator *n;
- for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
- n->updateDayMatrix();
+ for( uint i = 0; i < mLastDisplayedDN; ++i ) {
+ KDateNavigator *n = mExtraViews.at( i );
+ n->updateDayMatrix();
}
}
void DateNavigatorContainer::updateToday()
{
qDebug("DateNavigatorContainer::updateToday() NOT IMPL ");
#if 0
mNavigatorView->updateToday();
KDateNavigator *n;
for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
n->updateToday();
}
#endif
}
void DateNavigatorContainer::updateView()
{
mNavigatorView->updateView();
- KDateNavigator *n;
- for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
- n->updateView();
+ for( uint i = 0; i < mLastDisplayedDN; ++i ) {
+ KDateNavigator *n = mExtraViews.at( i );
+ n->updateView();
}
}
void DateNavigatorContainer::updateConfig()
{
mNavigatorView->updateConfig();
- KDateNavigator *n;
- for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
- n->updateConfig();
+ for( uint i = 0; i < mLastDisplayedDN; ++i ) {
+ KDateNavigator *n = mExtraViews.at( i );
+ n->updateConfig();
}
}
void DateNavigatorContainer::selectDates( const DateList &dateList )
{
- mNavigatorView->selectDates( dateList );
- setBaseDates();
- if ( mExtraViews.count() ) {
+ if ( !mLastDisplayedDN ) {
+ mNavigatorView->selectDates( dateList );
+ return;
+ }
+ QDate fDate = dateList.first();
+ QDate lDate = dateList.last();
+ if ( mLastDisplayedDN <= 2 ) {
+ mNavigatorView->selectDates( dateList );
+ KDateNavigator *view = mExtraViews.at( 0 );
+ QDate bDate = fDate.addDays( fDate.daysInMonth () - fDate.day() +1 );
+ view->setBaseDate( bDate, false );
+ view->dayMatrix()->setSelectedDaysFrom(fDate , lDate);
+ if ( mLastDisplayedDN == 2 ) {
+ view = mExtraViews.at( 1 );
+ bDate = bDate.addDays( bDate.daysInMonth () - bDate.day() +1 );
+ view->setBaseDate( bDate, false );
+ view->dayMatrix()->setSelectedDaysFrom(fDate , lDate);
+ }
+ return;
+ }
+ KDateNavigator *view = mExtraViews.at( 0 );
+ QDate date = view->baseDate();
+
+ QDate curEnd = date.addDays( (mLastDisplayedDN)*30 +7);
+ //qDebug("End %s %s ",lDate.toString().latin1(),curEnd.toString().latin1() );
+ if ( lDate < curEnd && date.addDays( -30 ) < fDate) {
+ mNavigatorView->dayMatrix()->setSelectedDaysFrom( fDate , lDate );
+ mNavigatorView->dayMatrix()->repaint( false );
+ for( uint i = 0; i < mLastDisplayedDN; ++i ) {
+ KDateNavigator *n = mExtraViews.at( i );
+ if ( n->dayMatrix()->setSelectedDaysFrom( fDate , lDate ) ) {
+ n->dayMatrix()->repaint( false );
+ }
+ }
+ return;
+ }
+ mNavigatorView->selectDates( dateList );
+ setBaseDates();
+ if ( mLastDisplayedDN ) {
KDateNavigator *view = mExtraViews.at( 0 );
view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
view->dayMatrix()->repaint( false );
- if ( mExtraViews.count() > 1 ) {
+ if ( mLastDisplayedDN > 1 ) {
KDateNavigator *view = mExtraViews.at( 1 );
view->dayMatrix()->setSelectedDaysFrom(*(dateList.begin()), *(--dateList.end()));
view->dayMatrix()->repaint( false );
}
}
}
void DateNavigatorContainer::setBaseDates()
{
KCal::DateList dateList = mNavigatorView->selectedDates();
if ( dateList.isEmpty() ) {
kdError() << "DateNavigatorContainer::selectDates() empty list." << endl;
}
QDate baseDate = dateList.first();
- KDateNavigator *n;
bool doRepaint = false; // skip first repaint
- for( n = mExtraViews.first(); n; n = mExtraViews.next() ) {
+ for( uint i = 0; i < mLastDisplayedDN; ++i ) {
+ KDateNavigator *n = mExtraViews.at( i );
baseDate = baseDate.addDays( baseDate.daysInMonth () - baseDate.day() +1 );
n->setBaseDate( baseDate, doRepaint );
doRepaint = true;
}
}
void DateNavigatorContainer::resizeEvent( QResizeEvent * e )
{
#if 0
kdDebug(5850) << "DateNavigatorContainer::resizeEvent()" << endl;
kdDebug(5850) << " CURRENT SIZE: " << size() << endl;
kdDebug(5850) << " MINIMUM SIZEHINT: " << minimumSizeHint() << endl;
kdDebug(5850) << " SIZEHINT: " << sizeHint() << endl;
kdDebug(5850) << " MINIMUM SIZE: " << minimumSize() << endl;
#endif
//QSize minSize = mNavigatorView->sizeHintTwoButtons();
QSize minSize = mNavigatorView->yourSizeHint();
// kdDebug(5850) << " NAVIGATORVIEW minimumSizeHint: " << minSize << endl;
int verticalCount = size().height() / minSize.height();
int horizontalCount = size().width() / minSize.width();
//qDebug(" wattdatt %d new %d %d ", size().width() ,e->size().width() , minSize.width() );
//qDebug("COUNT %d %d %d %d ", verticalCount, horizontalCount , mVerticalCount, mHorizontalCount );
bool fontchange = false;
if ( horizontalCount == 1)
horizontalCount = size().width() / mNavigatorView->yourFullSizeHint().width();
QFont fo;
if ( horizontalCount != mHorizontalCount ||
verticalCount != mVerticalCount ) {
uint count = horizontalCount * verticalCount;
if ( count == 0 ) {
bool ok;
fo = mNavigatorView->yourFontHint( size() , &ok );
//mNavigatorView->resize( size() );
//if ( ! ok )
// return;
int butt = 2;
horizontalCount = size().width() / mNavigatorView->sizeHintTwoButtons( ).width();
if ( horizontalCount <= 1 )
minSize = mNavigatorView->sizeHintTwoButtons( 4 );
else
minSize = mNavigatorView->sizeHintTwoButtons();
verticalCount = size().height() / minSize.height();
horizontalCount = size().width() / minSize.width();
if ( horizontalCount == 0 )
horizontalCount = 1;
if ( verticalCount == 0 )
verticalCount = 1;
fontchange = true;
count = horizontalCount * verticalCount;
} else {
if ( mNavigatorView->fontChanged() ) {
fontchange = true;
fo = KOPrefs::instance()->mDateNavigatorFont;
mNavigatorView->changeFont( fo );
mNavigatorView->unsetFontChanged();
}
}
+ mLastDisplayedDN = horizontalCount*verticalCount-1;
+ bool setBaseD = false;
while ( count > ( mExtraViews.count() + 1 ) ) {
KDateNavigator *n = new KDateNavigator( this );
n->setMonthSignalOffset ( mExtraViews.count()+1 );
mExtraViews.append( n );
n->setCalendar( mCalendar );
- setBaseDates();
+ setBaseD = true;
connectNavigatorView( n );
n->show();
}
int iii = 0;
while ( iii < ( mExtraViews.count() ) ) {
if ( iii < count-1 )
mExtraViews.at( iii )->show();
else
mExtraViews.at( iii )->hide();
++iii;
}
+ if ( setBaseD )
+ setBaseDates();
if ( fontchange ) {
//mNavigatorView->changeFont( fo );
uint i;
for( i = 0; i < mExtraViews.count(); ++i ) {
KDateNavigator *view = mExtraViews.at( i );
view->changeFont( fo );
}
}
mHorizontalCount = horizontalCount;
mVerticalCount = verticalCount;
+
}
//qDebug("COUNT %d ", mExtraViews.count());
int height = size().height() / verticalCount;
int width = size().width() / horizontalCount;
NavigatorBar *bar = mNavigatorView->navigatorBar();
if ( horizontalCount > 1 ) bar->showButtons( true, false );
else bar->showButtons( true, true );
mNavigatorView->setGeometry(0,
0, width, height );
- for( uint i = 0; i < mExtraViews.count(); ++i ) {
+ for( uint i = 0; i < mLastDisplayedDN; ++i ) {
int x = ( i + 1 ) % horizontalCount;
int y = ( i + 1 ) / horizontalCount;
KDateNavigator *view = mExtraViews.at( i );
bar = view->navigatorBar();
if ( y > 0 ) bar->showButtons( false, false );
else {
if ( x + 1 == horizontalCount ) bar->showButtons( false, true );
else bar->showButtons( false, false );
}
view->setGeometry( x * width,
y * height, width, height );
}
}
QSize DateNavigatorContainer::minimumSizeHint() const
{
return mNavigatorView->minimumSizeHint();
}
QSize DateNavigatorContainer::sizeHint() const
{
return mNavigatorView->yourSizeHint();
}
diff --git a/korganizer/datenavigatorcontainer.h b/korganizer/datenavigatorcontainer.h
index affa8e1..f45af20 100644
--- a/korganizer/datenavigatorcontainer.h
+++ b/korganizer/datenavigatorcontainer.h
@@ -32,59 +32,61 @@ class KDateNavigator;
using namespace KCal;
class DateNavigatorContainer: public QWidget
{
Q_OBJECT
public:
DateNavigatorContainer( QWidget *parent = 0, const char *name = 0 );
~DateNavigatorContainer();
/**
Associate date navigator with a calendar. It is used by KODayMatrix.
*/
void setCalendar( Calendar * );
QSize minimumSizeHint() const;
QSize sizeHint() const;
KDateNavigator * navigatorView() { return mNavigatorView;}
public slots:
void selectDates( const KCal::DateList & );
void updateView();
void updateConfig();
void updateDayMatrix();
void updateToday();
signals:
void datesSelected( const KCal::DateList & );
void incidenceDropped( Incidence *, const QDate & );
void incidenceDroppedMove( Incidence *, const QDate & );
void weekClicked( const QDate &);
void goPrevious();
void goNext();
void goNextMonth();
void goPrevMonth();
void goNextYear();
void goPrevYear();
void monthSelected( int month );
protected:
void resizeEvent( QResizeEvent * );
void setBaseDates();
void connectNavigatorView( KDateNavigator *v );
private:
+ int mLastDisplayedDN;
+ QDate mDisplayedEndDate;
KDateNavigator *mNavigatorView;
KCal::Calendar *mCalendar;
QPtrList<KDateNavigator> mExtraViews;
int mHorizontalCount;
int mVerticalCount;
};
#endif
diff --git a/korganizer/kdatenavigator.h b/korganizer/kdatenavigator.h
index 10bc1be..93bbceb 100644
--- a/korganizer/kdatenavigator.h
+++ b/korganizer/kdatenavigator.h
@@ -16,96 +16,99 @@
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#ifndef KDATENAVIGATOR_H
#define KDATENAVIGATOR_H
#include <qframe.h>
#include <qdatetime.h>
#include <qlabel.h>
#include <libkcal/calendar.h>
#include "kodaymatrix.h"
class QPushButton;
class QTimer;
class KCalendarSystem;
class NavigatorBar;
class KDateNavigator: public QFrame
{
Q_OBJECT
public:
KDateNavigator( QWidget *parent = 0,const char *name = 0 );
~KDateNavigator();
/** The DateNavigator automatically checks for
* the passage of midnight. If rollover type is
* set to None, no signals are emitted and no
* processing is done. With rollover set to
* FollowDay, the day highlighter changes at
* midnight and dayPassed() is emitted.
* With FollowMonth, it has the same effect
* as FollowDay but also adjusts the month that is
* visible and emits monthPassed() when the month changes.
*/
enum RolloverType { None, FollowDay, FollowMonth } ;
void enableRollover( RolloverType );
void setShowWeekNums( bool enabled );
void setCalendar( Calendar * );
void setBaseDate( const QDate & , bool doRepaint = true );
+
+ QDate baseDate() const { return m_MthYr;}
+
KCal::DateList selectedDates() const { return mSelectedDates; }
NavigatorBar *navigatorBar() const { return mNavigatorBar; }
void setMonthSignalOffset ( int off ) { mMonthSignalOffset = off%12;}
QSize yourSizeHint()const { return mySizeHint; };
QSize yourFullSizeHint() const { return myFullSizeHint;};
QFont yourFontHint( QSize , bool * b);
bool fontChanged() {return mFontChanged; }
void unsetFontChanged() { mFontChanged = false; }
KODayMatrix *dayMatrix() { return daymatrix ;}
QSize sizeHint() const;
QSize sizeHintTwoButtons( int butnum = 2 ) const;
void changeFont ( QFont fo );
public slots:
void selectDates( const KCal::DateList & );
void updateView();
void updateConfig();
void updateDayMatrix();
signals:
void datesSelected( const KCal::DateList & );
void eventDropped( Event * );
void weekClicked( const QDate &);
void goPrevious();
void goNext();
void goNextMonth();
void goPrevMonth();
void goNextYear();
void goPrevYear();
void monthSelected( int );
// Signals emitted at midnight carrying the new date.
void dayPassed( QDate );
void monthPassed( QDate );
protected slots:
/**
* Called regularly to see if we need to update the view
* wrt. the today box and the month box. Only important
* if you leave KOrganizer idle for long periods of time.
*
* Until we have a reliable way of setting QTimers to go
* off at a particular wall-clock time, we need this,
* which calls passedMidnight() at the right moments.
*/
void possiblyPastMidnight();
diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp
index a2e0ae0..3ee1fa7 100644
--- a/korganizer/kodaymatrix.cpp
+++ b/korganizer/kodaymatrix.cpp
@@ -239,105 +239,112 @@ KODayMatrix::~KODayMatrix()
{
// delete mKODaymatrixWhatsThis;
delete [] days;
delete [] daylbls;
delete [] events;
delete mToolTip;
}
/*
void KODayMatrix::setStartDate(QDate start)
{
updateView(start);
}
*/
void KODayMatrix::addSelectedDaysTo(DateList& selDays)
{
if (mSelStart == NOSELECTION) {
return;
}
//cope with selection being out of matrix limits at top (< 0)
int i0 = mSelStart;
if (i0 < 0) {
for (int i = i0; i < 0; i++) {
selDays.append(days[0].addDays(i));
}
i0 = 0;
}
//cope with selection being out of matrix limits at bottom (> NUMDAYS-1)
if (mSelEnd > NUMDAYS-1) {
for (int i = i0; i <= NUMDAYS-1; i++) {
selDays.append(days[i]);
}
for (int i = NUMDAYS; i < mSelEnd; i++) {
selDays.append(days[0].addDays(i));
}
// apply normal routine to selection being entirely within matrix limits
} else {
for (int i = i0; i <= mSelEnd; i++) {
selDays.append(days[i]);
}
}
}
-void KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end)
+bool KODayMatrix::setSelectedDaysFrom(const QDate& start, const QDate& end)
{
+ bool noSel = (mSelEnd == NOSELECTION && mSelStart == NOSELECTION );
mSelStart = startdate.daysTo(start);
if ( mSelStart < 0 )
mSelStart = 0;
mSelEnd = startdate.daysTo(end);
- //qDebug("SELECTION %d %d ", mSelStart ,mSelEnd );
- if ( mSelEnd < 0 )
+ if ( mSelEnd > NUMDAYS-1 )
+ mSelEnd = NUMDAYS-1;
+ if ( mSelEnd < 0 || mSelStart > NUMDAYS-1 ) {
clearSelection();
+ if ( noSel )
+ return false;
+ }
+
+ return true;
}
void KODayMatrix::clearSelection()
{
mSelEnd = mSelStart = NOSELECTION;
}
void KODayMatrix::recalculateToday()
{
today = -1;
for (int i=0; i<NUMDAYS; i++) {
events[i] = 0;
days[i] = startdate.addDays(i);
daylbls[i] = QString::number( KOGlobals::self()->calendarSystem()->day( days[i] ));
// if today is in the currently displayed month, hilight today
if (days[i].year() == QDate::currentDate().year() &&
days[i].month() == QDate::currentDate().month() &&
days[i].day() == QDate::currentDate().day()) {
today = i;
}
}
// qDebug(QString("Today is visible at %1.").arg(today));
}
void KODayMatrix::updateView()
{
updateView(startdate);
}
void KODayMatrix::repaintViewTimed()
{
mRepaintTimer->stop();
repaint(false);
}
void KODayMatrix::updateViewTimed()
{
mUpdateTimer->stop();
if ( !mCalendar ) {
qDebug("NOT CAL ");
return;
}
//qDebug("KODayMatrix::updateViewTimed ");
for(int i = 0; i < NUMDAYS; i++) {
// if events are set for the day then remember to draw it bold
QPtrList<Event> eventlist = mCalendar->events(days[i]);
Event *event;
int numEvents = eventlist.count();
QString holiStr = "";
@@ -654,109 +661,112 @@ void KODayMatrix::dropEvent(QDropEvent *e)
void KODayMatrix::paintEvent(QPaintEvent * pevent)
{
QRect sz = frameRect();
if ( sz.width() <= 0 || sz.height() <= 0 )
return;
if ( mPendingUpdateBeforeRepaint ) {
updateViewTimed();
mPendingUpdateBeforeRepaint = false;
}
if ( myPix.width() != sz.width() || myPix.height()!=sz.height() ) {
myPix.resize(sz.size() );
}
QPainter p(&myPix);
p.setFont(font());
int dheight = daysize.height();
int dwidth = daysize.width();
int row,col;
int selw, selh;
int xyOff = frameWidth();
int colModulo = sz.width() % 7;
int rowModulo = sz.height() % 6;
//qDebug("col %d row %d ",colModulo,rowModulo );
bool isRTL = KOGlobals::self()->reverseLayout();
// draw background and topleft frame
p.fillRect(pevent->rect(), mDefaultBackColor);
p.setPen(mDefaultTextColor);
p.drawRect(0, 0, sz.width()+1, sz.height()+1);
int mSelStartT = mSelStart;
int mSelEndT = mSelEnd;
if ( mSelEndT >= NUMDAYS )
mSelEndT = NUMDAYS-1;
// draw selected days with highlighted background color
if (mSelStart != NOSELECTION) {
bool skip = false;
if ( ! mouseDown ) {
int mo = days[20].month();
//qDebug("-- %d %d ", mSelStartT, mSelEndT);
//qDebug("%d %d %d - d %d", mo, days[mSelStartT].month() , days[mSelEndT].month(), days[mSelEndT].day() );
int startMo = days[mSelStartT].month();
int endMo = days[mSelEndT].month();
if ( startMo == 12 && mo == 1 && endMo <= 2 )
startMo = 1;
if ( endMo == 1 && mo == 12 )
endMo = 12;
+ if ( mo == 12 && startMo == 1 )
+ startMo = 13;
if ( (startMo > mo || endMo < mo) ) {
skip = true;
} else {
if ( days[mSelStartT].month() != mo ) {
int add = days[mSelStartT].daysInMonth ()-days[mSelStartT].day();
mSelStartT += add +1;
}
if ( days[mSelEndT].month() != mo ) {
int sub = days[mSelEndT].day();
mSelEndT -= sub ;
}
}
}
+ //qDebug("SKIP %d ", skip);
if ( ! skip ) {
row = mSelStartT/7;
col = mSelStartT -row*7;
QColor selcol = KOPrefs::instance()->mHighlightColor;
int addCol = 0;
int addRow = 0;
int addRow2 = 0;
int addCol2 = 0;
if (row == mSelEndT/7) {
if ( rowModulo ) {
if ( row >= 6 - rowModulo )
addRow = row - 5 + rowModulo;
}
if ( colModulo ) {
int colt1 = mSelEndT%7;
//qDebug("colt1 %d ", colt1 );
if ( colt1 >= 7 - colModulo )
addCol = colt1 - 7 + colModulo+1;
int colt = mSelStartT%7;
if ( colt >= 7 - colModulo )
addCol2 = colt - 7 + colModulo;
addCol -= addCol2;
//qDebug("COL %d %d %d %d ",col , colt1 ,addCol ,addCol2 );
}
// Single row selection
if ( row == 0)
addRow = 1;
p.fillRect(isRTL ? (7 - (mSelEndT-mSelStartT+1) - col)*dwidth : col*dwidth+1+addCol2,
row*dheight+addRow, (mSelEndT-mSelStartT+1)*dwidth+addCol, dheight+1, selcol);
} else {
// draw first row to the right
if ( colModulo ) {
if ( col >= 7 - colModulo )
addCol2 = col - 7 + colModulo;
}
if ( rowModulo ) {
if ( row >= 6 - rowModulo )
addRow = row - 5 + rowModulo;
}
if ( row == 0)
addRow = 1;
p.fillRect(isRTL ? 0 : col*dwidth+1+addCol2, row*dheight+addRow, (7-col)*dwidth+colModulo,
dheight+1, selcol);
// draw full block till last line
selh = mSelEndT/7-row;
addRow = 0;
if ( rowModulo ) {
if ( mSelEndT/7 >= 6 - rowModulo )
diff --git a/korganizer/kodaymatrix.h b/korganizer/kodaymatrix.h
index 10f4b05..2a1959c 100644
--- a/korganizer/kodaymatrix.h
+++ b/korganizer/kodaymatrix.h
@@ -109,97 +109,97 @@ class KODayMatrix: public QFrame {
public:
/** constructor to create a day matrix widget.
*
* @param parent widget that is the parent of the day matrix. Normally this should
* be a KDateNavigator
* @param calendar instance of a calendar on which all calculations are based
* @param date start date of the matrix (is expected to be already fixed). It is
* assumed that this date is the first week day to be shown in the matrix.
* @param name name of the widget
*/
KODayMatrix( QWidget *parent, const char *name );
//KODayMatrix(QWidget *parent, Calendar* calendar, QDate date, const char *name );
/** destructor that deallocates all dynamically allocated private members.
*/
~KODayMatrix();
/** updates the day matrix to start with the given date. Does all the necessary
* checks for holidays or events on a day and stores them for display later on.
* Does NOT update the view visually. Call repaint() for this.
*
* @param actdate recalculates the day matrix to show NUMDAYS starting from this
* date.
*/
void updateView(QDate actdate);
void updateEvents();
/** returns the QDate object associated with day indexed by the
* supplied offset.
*/
const QDate& getDate(int offset);
void setCalendar( Calendar * );
/** returns the official name of this holy day or 0 if there is no label
* for this day.
*/
QString getHolidayLabel(int offset);
/** adds all actual selected days from mSelStart to mSelEnd to the supplied
* DateList.
*/
void addSelectedDaysTo(DateList&);
/** sets the actual to be displayed selection in the day matrix starting from
* start and ending with end. Theview must be manually updated by calling
* repaint. (?)
*/
- void setSelectedDaysFrom(const QDate& start, const QDate& end);
+ bool setSelectedDaysFrom(const QDate& start, const QDate& end);
void clearSelection();
/** Is today visible in the view? Keep this in sync with
* the values today (below) can take.
*/
bool isTodayVisible() const { return today>=0; } ;
/** If today is visible, then we can find out if today is
* near the beginning or the end of the month.
* This is dependent on today remaining the index
* in the array of visible dates and going from
* top left (0) to bottom right (41).
*/
bool isBeginningOfMonth() const { return today<=8; } ;
bool isEndOfMonth() const { return today>=27; } ;
QString getWhatsThisText( QPoint ) ;
QSize sizeHint() const;
QRect frameRect () const { int wid = frameWidth(); return QRect(0+wid,0+wid,width()-wid-wid,height()-wid-wid);}
public slots:
/** Recalculates all the flags of the days in the matrix like holidays or events
* on a day (Actually calls above method with the actual startdate).
*/
void updateView();
void updateViewTimed();
void repaintViewTimed();
/**
* Calculate which square in the matrix should be
* hilighted to indicate it's today.
*/
void recalculateToday();
/*
void setStartDate(QDate);
*/
signals:
/** emitted if the user selects a block of days with the mouse by dragging a rectangle
* inside the matrix
*
* @param daylist list of days that have been selected by the user
*/
void selected( const KCal::DateList &daylist );
/** emitted if the user has dropped an event inside the matrix
*
* @param event the dropped calendar event