summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/datenavigatorcontainer.cpp6
-rw-r--r--korganizer/koagendaitem.cpp8
-rw-r--r--korganizer/koagendaview.cpp1
-rw-r--r--korganizer/komonthview.cpp26
-rw-r--r--korganizer/komonthview.h3
-rw-r--r--korganizer/koviewmanager.cpp1
6 files changed, 36 insertions, 9 deletions
diff --git a/korganizer/datenavigatorcontainer.cpp b/korganizer/datenavigatorcontainer.cpp
index 548c364..d1caff3 100644
--- a/korganizer/datenavigatorcontainer.cpp
+++ b/korganizer/datenavigatorcontainer.cpp
@@ -5,195 +5,197 @@
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) );
mLastDisplayedDN = 0;
mUpdateTimer;
mUpdateTimer = new QTimer( this );
connect (mUpdateTimer ,SIGNAL(timeout()), this, SLOT ( checkUpdateDayMatrixDates() ));
+ mFirstSelectedDate = QDate::currentDate();
+ mSelectedDateCount = 1;
}
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 ) ), SLOT( slotMonthSelected( int ) ) );
}
void DateNavigatorContainer::slotMonthSelected( int month )
{
//qDebug("slotMonthSelected %d ", month);
QDate baseDate = mNavigatorView->baseDate();
if ( baseDate.month() == month )
return;
//qDebug("month %d %d ",baseDate.month(),month);
QDate date = QDate ( baseDate.year(), baseDate.month() , 15 );
date = date.addDays( -(baseDate.month()-month ) *30 );
QDate newBase = QDate ( date.year(), date.month() , baseDate.day() );
#if 0
mFirstSelectedDate = dateList.first() ;
mSelectedDateCount = dateList.count() ;
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;
}
#endif
//qDebug("NEW BASE %s", newBase.toString().latin1());
mNavigatorView->setBaseDate( newBase );
QDate last = lastAvailableDate();
QDate first = firstAvailableDate();
QDate selFirst = mFirstSelectedDate;
QDate selLast = selFirst.addDays( mSelectedDateCount-1 );
if ( selFirst >= first && selLast <= last ) {
setBaseDates();
updateDayMatrixDates();
}
else {
setBaseDates();
updateDayMatrixDates();
emit monthSelected( month );
}
}
void DateNavigatorContainer::setCalendar( Calendar *cal )
{
mCalendar = cal;
mNavigatorView->setCalendar( cal );
for( uint i = 0; i < mLastDisplayedDN; ++i ) {
KDateNavigator *n = mExtraViews.at( i );
n->setCalendar( cal );
}
}
void DateNavigatorContainer::checkUpdateDayMatrixDates()
{
- qDebug("wid %d hei %d ", width(), height());
+ //qDebug("KODNC: wid %d hei %d ", width(), height());
mUpdateTimer->stop();
//return;
if ( width() < 3 || height() < 3 )
return;
static int lastWid = 0;
static int lastHei = 0;
if ( lastWid == width() && height() == lastHei ) {
- qDebug("no layout computing needed. ");
+ qDebug("KODNC: No layout computing needed. ");
} else {
lastWid = width();
lastHei = height();
QSize minSize = mNavigatorView->yourSizeHint();
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;
while ( count > ( mExtraViews.count() + 1 ) ) {
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index 7e6fa48..82d1eab 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -459,105 +459,105 @@ QPixmap * KOAgendaItem::paintPixSel()
}
void KOAgendaItem::paintEvent ( QPaintEvent *e )
{
if ( globalFlagBlockAgendaItemPaint )
return;
if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 )
return;
int yy;
if ( mAllDay )
yy = y();
else
yy = mCellYTop * ( height() / cellHeight() );
int xx = x();
if ( xPaintCoord != xx || yPaintCoord != yy ||
wPaintCoord != width() || hPaintCoord != height()) {
xPaintCoord= xx;
yPaintCoord = yy;
wPaintCoord = width();
hPaintCoord = height();
globalFlagBlockAgendaItemUpdate = 0;
paintMe( mSelected );
//qDebug("calling paintMe ");
globalFlagBlockAgendaItemUpdate = 1;
}
int rx, ry, rw, rh;
rx = e->rect().x();
ry = e->rect().y();
rw = e->rect().width();
rh = e->rect().height();
//qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height());
QPixmap* paintFrom ;
if ( mSelected ) {
paintFrom = paintPixSel();
} else {
if ( mAllDay )
paintFrom = paintPixAllday();
else
paintFrom = paintPix();
}
xx += rx;
if ( xx < 0 ) {
rw = rw + xx;
rx -= xx;
xx = 0;
- if ( rw < 0 ) {
- qDebug("KOAgendaItem::Width1 < 0. Returning ");
+ if ( rw <= 1 ) {
+ qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1());
return;
}
}
if ( paintFrom->width() < xx+rw ) {
rw = paintFrom->width() - xx;
- if ( rw < 0 ) {
- qDebug("KOAgendaItem::Width2 < 0. Returning ");
+ if ( rw <= 1 ) {
+ qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() );
return;
}
}
//qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh);
bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP);
}
void KOAgendaItem::computeText()
{
mDisplayedText = mIncidence->summary();
if ( (mIncidence->type() == "Todo") ) {
if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) {
if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() )
mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")";
else if ( !(mIncidence->doesFloat()))
mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")";
}
} else {
if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda)
mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ;
if ( mAllDay ) {
if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) {
mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ;
}
}
}
if ( !mIncidence->location().isEmpty() ) {
if ( mAllDay )
mDisplayedText += " (";
else
mDisplayedText += "\n(";
mDisplayedText += mIncidence->location() +")";
}
QString tipText = mIncidence->summary();
if ( !mIncidence->doesFloat() ) {
if ( mIncidence->type() == "Event" ) {
if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) {
tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr();
tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr();
}
else {
tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr();
tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr();
}
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index eb3a6cd..5508210 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -222,96 +222,97 @@ void TimeLabels::contentsMouseMoveEvent ( QMouseEvent * e )
tSize = 22;
tSize = (tSize-2)/2;
topLevelWidget()->setCaption(i18n("New Agendasize: %1").arg(tSize));
}
void TimeLabels::contentsMouseReleaseEvent ( QMouseEvent * e )
{
topLevelWidget()->setCaption( mOrgCap );
int diff = mMouseDownY - e->pos().y();
if ( diff < 10 && diff > -10 )
return;
int tSize = KOPrefs::instance()->mHourSize + (diff/10);
if ( tSize < 4 )
tSize = 4;
if ( tSize > 22 )
tSize = 22;
tSize = (tSize/2)*2;
if ( tSize == KOPrefs::instance()->mHourSize )
return;
KOPrefs::instance()->mHourSize = tSize;
emit scaleChanged();
}
/** This is called in response to repaint() */
void TimeLabels::paintEvent(QPaintEvent*)
{
// kdDebug() << "paintevent..." << endl;
// this is another hack!
// QPainter painter(this);
//QString c
repaintContents(contentsX(), contentsY(), visibleWidth(), visibleHeight());
}
////////////////////////////////////////////////////////////////////////////
EventIndicator::EventIndicator(Location loc,QWidget *parent,const char *name)
: QFrame(parent,name)
{
mColumns = 1;
mTopBox = 0;
mLocation = loc;
mTopLayout = 0;
mPaintWidget = 0;
mXOffset = 0;
if (mLocation == Top) mPixmap = SmallIcon("1uparrow");
else mPixmap = SmallIcon("1downarrow");
mEnabled.resize(mColumns);
+ mEnabled.fill( false );
setMinimumHeight(mPixmap.height());
}
EventIndicator::~EventIndicator()
{
}
void EventIndicator::drawContents(QPainter *p)
{
// kdDebug() << "======== top: " << contentsRect().top() << " bottom " << // contentsRect().bottom() << " left " << contentsRect().left() << " right " << contentsRect().right() << endl;
KDGanttSplitterHandle* han = 0;
if ( mPaintWidget )
han = mPaintWidget->firstHandle();
if ( ! han ) {
int i;
for(i=0;i<mColumns;++i) {
if (mEnabled[i]) {
int cellWidth = contentsRect().right()/mColumns;
int xOffset = KOGlobals::self()->reverseLayout() ?
(mColumns - 1 - i)*cellWidth + (cellWidth -mPixmap.width())/2 :
i*cellWidth + (cellWidth -mPixmap.width()) /2;
p->drawPixmap(QPoint(1+xOffset,0),mPixmap);
}
}
} else {
han->repaint();
//mPaintWidget->setBackgroundColor( red );
QPainter pa( han );
int i;
bool setColor = false;
for(i=0;i<mColumns;++i) {
if (mEnabled[i]) {
setColor = true;
int cellWidth = contentsRect().right()/mColumns;
int xOffset = KOGlobals::self()->reverseLayout() ?
(mColumns - 1 - i)*cellWidth + cellWidth/2 -mPixmap.width()/2 :
i*cellWidth + cellWidth/2 -mPixmap.width()/2;
pa.drawPixmap(QPoint(mXOffset + xOffset,0),mPixmap);
//qDebug("222draw pix %d ",xOffset );
}
}
pa.end();
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 9fd1f68..8ee5bc3 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -949,96 +949,101 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
for( row = 0; row < mNumWeeks; ++row ) {
for( col = 0; col < mDaysPerWeek; ++col ) {
MonthViewCell *cell = new MonthViewCell( this, mMonthView );
mCells.insert( row * mDaysPerWeek + col, cell );
connect( cell, SIGNAL( defaultAction( Incidence * ) ),
SLOT( defaultAction( Incidence * ) ) );
connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
SIGNAL( newEventSignal( QDateTime ) ) );
connect( cell, SIGNAL( showDaySignal( QDate ) ),
SIGNAL( showDaySignal( QDate ) ) );
}
}
mCellsW.resize( mDaysPerWeek );
for( col = 0; col < mDaysPerWeek; ++col ) {
MonthViewCell *cell = new MonthViewCell( this, mWeekView );
mCellsW.insert( col, cell );
connect( cell, SIGNAL( defaultAction( Incidence * ) ),
SLOT( defaultAction( Incidence * ) ) );
connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
SIGNAL( newEventSignal( QDateTime ) ) );
connect( cell, SIGNAL( showDaySignal( QDate ) ),
SIGNAL( showDaySignal( QDate ) ) );
cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont );
}
//connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) );
mContextMenu = eventPopup();
// updateConfig(); //useless here...
// ... but we need mWidthLongDayLabel computed
QFontMetrics fontmetric(mDayLabels[0]->font());
mWidthLongDayLabel = 0;
for (int i = 0; i < 7; i++) {
int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
}
//mWeekLabels[mNumWeeks]->setText( i18n("W"));
#if 0
if ( mShowWeekView )
mWidStack->raiseWidget( mWeekView );
else
mWidStack->raiseWidget( mMonthView );
#endif
emit incidenceSelected( 0 );
+
+ mComputeLayoutTimer = new QTimer( this );
+ connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout()));
+
+
#ifndef DESKTOP_VERSION
resize( QApplication::desktop()->size() );
#else
resize(640, 480 );
updatePossible = true;
#endif
computeLayout();
if ( mShowWeekView )
mWidStack->raiseWidget( mWeekView );
else
mWidStack->raiseWidget( mMonthView );
}
KOMonthView::~KOMonthView()
{
delete mContextMenu;
}
void KOMonthView::selectInternalWeekNum ( int n )
{
switchView();
if ( !KOPrefs::instance()->mMonthViewWeek )
emit selectMonth ();
else
emit selectWeekNum ( n );
}
int KOMonthView::currentWeek()
{
if ( mShowWeekView )
return mWeekLabelsW[0]->getWeekNum();
return mWeekLabels[0]->getWeekNum();
}
void KOMonthView::switchView()
{
if ( selectedCell( ) )
selectedCell()->deselect();
mShowWeekView = !mShowWeekView;
KOPrefs::instance()->mMonthViewWeek = mShowWeekView;
if ( clPending ) {
computeLayout();
updateConfig();
}
if ( mShowWeekView )
mWidStack->raiseWidget( mWeekView );
else
mWidStack->raiseWidget( mMonthView );
@@ -1306,125 +1311,139 @@ void KOMonthView::updateView()
if ( st < 0 ) st = 0;
if ( end > timeSpan ) end = timeSpan;
int iii;
for ( iii = st;iii<= end;++iii)
(*cells)[iii]->insertEvent( event );
}
}
}
}
// insert due todos
QPtrList<Todo> todos = calendar()->todos( );
Todo *todo;
for(todo = todos.first(); todo; todo = todos.next()) {
//insertTodo( todo );
if ( todo->hasDueDate() ) {
int day = mStartDate.daysTo( todo->dtDue().date() );
if ( day >= 0 && day < timeSpan + 1) {
(*cells)[day]->insertTodo( todo );
}
}
}
for( i = 0; i < timeSpan+1; ++i ) {
(*cells)[i]->finishUpdateCell();
}
processSelectionChange();
(*cells)[0]->setFocus();
#else
// old code
//qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
int i;
for( i = 0; i < (*cells).count(); ++i ) {
(*cells)[i]->updateCell();
}
//qDebug("KOMonthView::updateView() ");
processSelectionChange();
// qDebug("---------------------------------------------------------------------+ ");
(*cells)[0]->setFocus();
#endif
//qDebug("update time %d ", ti.elapsed());
}
void KOMonthView::resizeEvent(QResizeEvent * e)
{
- //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height());
+ qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height());
+ if ( isVisible() ) {
+ qDebug("KOMonthView::isVisible ");
+ slotComputeLayout();
+ } else
+ mComputeLayoutTimer->start( 100 );
+}
+
+void KOMonthView::slotComputeLayout()
+{
+ mComputeLayoutTimer->stop();
+ qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() );
computeLayout();
clPending = true;
if ( mShowWeekView )
mCellsW[0]->setFocus();
else
mCells[0]->setFocus();
+
}
void KOMonthView::computeLayoutWeek()
{
static int lastWid = 0;
static int lastHei = 0;
int daysToShow;
bool combinedSatSun = false;
if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
daysToShow = 6;
combinedSatSun = true;
}
int tWid = topLevelWidget()->size().width();
int tHei = topLevelWidget()->size().height();
int wid = width();//e
int hei = height()-1-mNavigatorBar->height();
if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
return;
- if ( lastWid == width() && lastHei == height() )
+ if ( lastWid == width() && lastHei == height() ) {
+ qDebug("KOListWeekView::No compute layout needed ");
return;
+ }
lastWid = width();
lastHei = height();
if ( wid < hei )
daysToShow = 2;
else
daysToShow = 3;
mShowSatSunComp = true;
combinedSatSun = true;
//qDebug("KOMonthView::computeLayout() WWW ------------------------------------ ");
QFontMetrics fm ( mWeekLabels[0]->font() );
int weeklabelwid = fm.width( "888" );
wid -= weeklabelwid;
int colWid = wid / daysToShow;
int lastCol = wid - ( colWid*6 );
int dayLabelHei = mDayLabelsW[0]->sizeHint().height();
int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow );
int colModulo = wid % daysToShow;
int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1;
//qDebug("rowmod %d ", rowModulo);
int i;
int x,y,w,h;
x= 0;
y= 0;
w = colWid;
h = dayLabelHei ;
for ( i = 0; i < 7; i++) {
if ( i && !( i % daysToShow) && i < 6) {
y += hei/(5-daysToShow);
x = 0;
w = colWid;
}
if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
++w;
}
if ( i >= 5 ) {
mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h);
x -= (w/2 );
}
else
mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h);
x += w;
}
x= 0;
y= dayLabelHei;
@@ -1460,102 +1479,103 @@ void KOMonthView::computeLayoutWeek()
x += w;
if ( x + w/2 > wid ) {
x = 0;
y += h+dayLabelHei ;
}
}
y= dayLabelHei;
h = cellHei ;
mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei);
mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
// qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height());
//qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height());
mShortDayLabelsW = mDayLabelsW[0]->width()-2 < mWidthLongDayLabel ;
updateDayLabels();
//bool forceUpdate = !updatePossible;
updatePossible = true;
//mWeekLabels[mNumWeeks]->setText( i18n("M"));
//if ( forceUpdate )
// updateView();
}
void KOMonthView::computeLayout()
{
static int lastWid = 0;
static int lastHei = 0;
if ( mShowWeekView ){
computeLayoutWeek();
return;
}
int daysToShow = 7;
bool combinedSatSun = false;
if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
daysToShow = 6;
combinedSatSun = true;
}
int tWid = topLevelWidget()->size().width();
int tHei = topLevelWidget()->size().height();
int wid = width();//e
int hei = height()-1-mNavigatorBar->height();
if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) {
return;
}
if ( lastWid == width() && lastHei == height() ){
+ qDebug("KOMonthview::No compute layout needed ");
return;
}
lastWid = width();
lastHei = height();
- //qDebug("KOMonthView::computeLayout() MMM ------------------------------------ ");
+ qDebug("KOMonthView::computeLayout() MMM ------------------- ");
QFontMetrics fm ( mWeekLabels[0]->font() );
int weeklabelwid = fm.width( "888" );
wid -= weeklabelwid;
int colWid = wid / daysToShow;
int lastCol = wid - ( colWid*6 );
int dayLabelHei = mDayLabels[0]->sizeHint().height();
int cellHei = (hei - dayLabelHei) /6;
int colModulo = wid % daysToShow;
int rowModulo = (hei- dayLabelHei) % 6;
//qDebug("rowmod %d ", rowModulo);
int i;
int x,y,w,h;
x= 0;
y= 0;
w = colWid;
h = dayLabelHei ;
for ( i = 0; i < 7; i++) {
if ( i == daysToShow-colModulo )
++w;
if ( combinedSatSun ) {
if ( i >= daysToShow-1 ) {
mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h);
x -= w/2 ;
}
else
mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
} else
mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
x += w;
}
x= 0;
y= dayLabelHei;
w = colWid;
h = cellHei ;
for ( i = 0; i < mCells.count(); ++i) {
//qDebug("iii %d ", i);
w = colWid;
if ( ((i) % 7) >= 7-colModulo ) {
++w;
}
if ( i == (6-rowModulo)*7)
++h;
if ( combinedSatSun ) {
if ( (i)%7 >= daysToShow-1 ) {
if ( (i)%7 == daysToShow-1 ) {
mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
x -= w ;y += h/2;
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index a92421b..89912e0 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -1,77 +1,78 @@
/*
This file is part of KOrganizer.
Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
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.
*/
#ifndef _KOMONTHVIEW_H
#define _KOMONTHVIEW_H
#include <qlabel.h>
#include <qframe.h>
#include <qdatetime.h>
#include <qlistbox.h>
#include <qpoint.h>
#include <qwidgetstack.h>
#include <qlayout.h>
+#include <qtimer.h>
#include <qintdict.h>
#include <qpushbutton.h>
#include <qvaluelist.h>
#include <qptrvector.h>
#include <libkcal/calendar.h>
#include <libkcal/event.h>
#include "koeventview.h"
#include "navigatorbar.h"
#ifdef DESKTOP_VERSION
class QToolTipGroup;
#endif
class KNOWhatsThis;
class KOWeekButton : public QPushButton
{
Q_OBJECT
public:
KOWeekButton( QWidget *parent=0, const char *name=0 ) :
QPushButton( parent, name)
{
connect( this, SIGNAL( clicked() ),
SLOT( bottonClicked() ));
mNumber = -1;
}
void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));}
int getWeekNum() { return mNumber;}
signals:
void selectWeekNum ( int );
private:
int mNumber;
private slots :
void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); }
};
class KNoScrollListBox: public QListBox
{
Q_OBJECT
public:
KNoScrollListBox(QWidget *parent=0, const char *name=0);
~KNoScrollListBox();
QString getWhatsThisText(QPoint p) ;
signals:
void shiftDown();
void shiftUp();
@@ -206,99 +207,101 @@ public slots:
void keyPressEvent ( QKeyEvent * ) ;
};
class KOMonthView: public KOEventView
{
Q_OBJECT
public:
KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
~KOMonthView();
/** Returns maximum number of days supported by the komonthview */
virtual int maxDatesHint();
/** Returns number of currently shown dates. */
virtual int currentDateCount();
/** returns the currently selected events */
virtual QPtrList<Incidence> selectedIncidences();
/** returns dates of the currently selected events */
virtual DateList selectedDates();
virtual void printPreview(CalPrinter *calPrinter,
const QDate &, const QDate &);
bool isMonthView() { return !mShowWeekView; }
bool isUpdatePossible() { return updatePossible; }
MonthViewCell * selectedCell();
bool skipResize;
NavigatorBar* navigatorBar() { return mNavigatorBar ;}
public slots:
virtual void updateView();
virtual void updateConfig();
virtual void showDates(const QDate &start, const QDate &end);
virtual void showEvents(QPtrList<Event> eventList);
void changeEventDisplay(Event *, int);
void clearSelection();
void showContextMenu( Incidence * );
void setSelectedCell( MonthViewCell * );
void switchView();
protected slots:
+ void slotComputeLayout();
void selectInternalWeekNum ( int );
void processSelectionChange();
signals:
void nextMonth();
void prevMonth();
void selectWeekNum ( int );
void selectMonth ();
void showDaySignal( QDate );
protected:
void resizeEvent(QResizeEvent *);
void viewChanged();
void updateDayLabels();
private:
+ QTimer* mComputeLayoutTimer;
NavigatorBar* mNavigatorBar;
int currentWeek();
bool clPending;
QWidgetStack * mWidStack;
QWidget* mMonthView;
QWidget* mWeekView;
bool mShowWeekView;
bool updatePossible;
int mDaysPerWeek;
int mNumWeeks;
int mNumCells;
bool mWeekStartsMonday;
bool mShowSatSunComp;
void computeLayout();
void computeLayoutWeek();
QPtrVector<MonthViewCell> mCells;
QPtrVector<QLabel> mDayLabels;
QPtrVector<KOWeekButton> mWeekLabels;
QPtrVector<MonthViewCell> mCellsW;
QPtrVector<QLabel> mDayLabelsW;
QPtrVector<KOWeekButton> mWeekLabelsW;
bool mShortDayLabelsM;
bool mShortDayLabelsW;
int mWidthLongDayLabel;
QDate mStartDate;
MonthViewCell *mSelectedCell;
KOEventPopupMenu *mContextMenu;
void keyPressEvent ( QKeyEvent * ) ;
};
#endif
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index cc0ce9b..94d74f1 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -196,96 +196,97 @@ void KOViewManager::writeSettings(KConfig *config)
if (mTodoView) {
mTodoView->saveLayout(config,"Todo View");
}
}
void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen )
{
//mFlagShowNextxDays = false;
//if(view == mCurrentView) return;
if ( view == 0 ) {
view = mCurrentView;
if ( view == 0 )
return;
}
bool full = fullScreen;
if(view == mCurrentView && view != mWhatsNextView ) {
if ( mCurrentAgendaView < 0 )
return;
if ( view != mMonthView )
full = mMainView->leftFrame()->isVisible();
} else {
if ( view == mMonthView && mMonthView)
;//mMonthView->skipResize = true ;
mCurrentView = view;
// bool full = fullScreen;
bool isFull = !mMainView->leftFrame()->isVisible();
if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen )
full = true;
if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen )
full = false;
}
if ( mAgendaView ) mAgendaView->deleteSelectedDateTime();
//raiseCurrentView( full );
mMainView->processIncidenceSelection( 0 );
//mMainView->updateView();
raiseCurrentView( full, true );
mMainView->adaptNavigationUnits();
}
void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView )
{
mCurrentAgendaView = 0;
if ( fullScreen ) {
mMainView->leftFrame()->hide();
} else {
mMainView->leftFrame()->show();
}
+ //if ( mCurrentView == mMonthView ) qApp->processEvents();
emit signalFullScreen( !fullScreen );
if ( callUpdateView )
mMainView->updateView();
if ( globalFlagBlockAgenda == 5 ) {
globalFlagBlockAgenda = 4;
globalFlagBlockAgendaItemPaint = 1;
}
mMainView->viewStack()->raiseWidget(mCurrentView);
if ( globalFlagBlockAgenda == 4 ) {
if ( mCurrentView == mAgendaView ) {
//globalFlagBlockAgenda =1 ;
if ( KOPrefs::instance()->mSetTimeToDayStartAt )
mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins );
else if ( KOPrefs::instance()->mCenterOnCurrentTime )
mAgendaView->setStartHour( QTime::currentTime ().hour() );
qApp->processEvents();
//qDebug("qApp->processEvents() ");
globalFlagBlockAgenda = 0;
mAgendaView->repaintAgenda();
}
globalFlagBlockAgenda = 0;
}
emit signalAgendaView( mCurrentView == mAgendaView );
//qDebug("raiseCurrentView ende ");
}
void KOViewManager::updateView()
{
// qDebug("KOViewManager::updateView() ");
// if we are updating mTodoView, we get endless recursion
if ( mTodoView == mCurrentView )
return;
if ( mCurrentView ) mCurrentView->updateView();
}
void KOViewManager::updateView(const QDate &start, const QDate &end)
{
// kdDebug() << "KOViewManager::updateView()" << endl;
if (mCurrentView) mCurrentView->showDates(start, end);
if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView();
}