summaryrefslogtreecommitdiffabout
path: root/korganizer/komonthview.cpp
authorzautrix <zautrix>2005-02-07 10:32:40 (UTC)
committer zautrix <zautrix>2005-02-07 10:32:40 (UTC)
commitafc19166fcdc09d3d5b757a84abfeb0b2746f35f (patch) (side-by-side diff)
tree91b1de5d4154eace5ddb2c0dc5c3243a53ed8661 /korganizer/komonthview.cpp
parent363a0e27d630452762e76131b4606e14a3231f01 (diff)
downloadkdepimpi-afc19166fcdc09d3d5b757a84abfeb0b2746f35f.zip
kdepimpi-afc19166fcdc09d3d5b757a84abfeb0b2746f35f.tar.gz
kdepimpi-afc19166fcdc09d3d5b757a84abfeb0b2746f35f.tar.bz2
month fixes
Diffstat (limited to 'korganizer/komonthview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp216
1 files changed, 118 insertions, 98 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 70cbf96..234375b 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -1,49 +1,48 @@
/*
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.
*/
#include <qpopupmenu.h>
#include <qfont.h>
#include <qfontmetrics.h>
#include <qkeycode.h>
#include <qhbox.h>
-#include <qtimer.h>
#include <qvbox.h>
#include <qwidgetstack.h>
#include <qpushbutton.h>
#include <qtooltip.h>
#include <qpainter.h>
#include <qwhatsthis.h>
#ifndef DESKTOP_VERSION
#include <qpe/qpeapplication.h>
#else
#include <qapplication.h>
#endif
#include <kdebug.h>
#include <klocale.h>
#include <kglobal.h>
#include <kconfig.h>
#include <kiconloader.h>
#include <kcalendarsystem.h>
#ifndef KORG_NOPRINTER
#include "calprinter.h"
#endif
#include "koprefs.h"
@@ -53,67 +52,67 @@
#include "koglobals.h"
#include <libkcal/kincidenceformatter.h>
#include "komonthview.h"
#define PIXMAP_SIZE 5
#ifdef DESKTOP_VERSION
QToolTipGroup *MonthViewCell::mToolTipGroup = 0;
#endif
class KNOWhatsThis :public QWhatsThis
{
public:
KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { };
//~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); };
protected:
virtual QString text( const QPoint& p)
{
return _wid->getWhatsThisText(p) ;
};
private:
KNoScrollListBox* _wid;
};
-
+
KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name)
: QListBox(parent, name, WRepaintNoErase)
{
#ifndef DESKTOP_VERSION
QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
#endif
mWT = new KNOWhatsThis(this);
}
KNoScrollListBox::~KNoScrollListBox()
{
}
QString KNoScrollListBox::getWhatsThisText(QPoint p)
{
QListBoxItem* item = itemAt ( p );
if ( ! item ) {
- return i18n("Click in the cell\nto add an event!");
+ return i18n("Click in the cell\nto add an event!");
}
return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence());
}
void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
{
switch(e->key()) {
case Key_Right:
if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
{
e->ignore();
return;
}
scrollBy(10,0);
break;
case Key_Left:
if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
{
e->ignore();
return;
}
scrollBy(-10,0);
break;
case Key_Up:
@@ -298,49 +297,49 @@ MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
//mLabel->setLineWidth( 1 );
//mLabel->setAlignment( AlignCenter );
mLabel->setFlat( true );
mLabel->setFocusPolicy(NoFocus);
mItemList = new KNoScrollListBox( this );
mItemList->setMinimumSize( 10, 10 );
mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain );
mItemList->setLineWidth( 1 );
topLayout->addWidget( mItemList );
mLabel->raise();
// QColor( 0,0,255 ) QColor( 160,1600,255 )
mStandardPalette = palette();
mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
enableScrollBars( false );
updateConfig();
//connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() ));
connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() ));
connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ),
SLOT( defaultAction( QListBoxItem * ) ) );
connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *,
const QPoint &) ),
SLOT( contextMenu( QListBoxItem * ) ) );
connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ),
- SLOT( selection( QListBoxItem * ) ) );
+ SLOT( selection( QListBoxItem * ) ) );
connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
SLOT( cellClicked( QListBoxItem * ) ) );
connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
SLOT( selection( QListBoxItem * ) ) );
}
#ifdef DESKTOP_VERSION
QToolTipGroup *MonthViewCell::toolTipGroup()
{
if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
return mToolTipGroup;
}
#endif
void MonthViewCell::setDate( const QDate &date )
{
// kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
mDate = date;
//resizeEvent( 0 );
}
QDate MonthViewCell::date() const
@@ -386,55 +385,48 @@ bool MonthViewCell::isPrimary() const
{
return mPrimary;
}
void MonthViewCell::setHoliday( bool holiday )
{
mHoliday = holiday;
//setMyPalette();
}
void MonthViewCell::setHoliday( const QString &holiday )
{
mHolidayString = holiday;
if ( !holiday.isEmpty() ) {
setHoliday( true );
}
}
void MonthViewCell::keyPressEvent ( QKeyEvent * e )
{
e->ignore();
}
-void MonthViewCell::clear()
-{
- mItemList->clear();
- QApplication::removePostedEvents ( mItemList );
- QApplication::removePostedEvents ( mLabel );
- QApplication::removePostedEvents ( this );
-}
void MonthViewCell::startUpdateCell()
{
mItemList->setFocusPolicy(NoFocus);
if ( !mMonthView->isUpdatePossible() )
return;
/*
if ( !isVisible() ){
return;
}
*/
// qDebug("MonthViewCell::updateCell() ");
setPrimary( mDate.month()%2 );
setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
if ( mDate == QDate::currentDate() ) {
mItemList->setLineWidth( 3 );
} else {
mItemList->setLineWidth( 1 );
}
mItemList->clear();
#ifdef DESKTOP_VERSION
@@ -531,112 +523,113 @@ void MonthViewCell::insertEvent(Event *event)
} else {
pal = mStandardPalette ;
}
item->setPalette( pal );
item->setRecur( event->recurrence()->doesRecur() );
item->setAlarm( event->isAlarmEnabled() );
item->setMoreInfo( event->description().length() > 0 );
#ifdef DESKTOP_VERSION
Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
KOPrefs::instance()->email());
if ( me != 0 ) {
if ( me->status() == Attendee::NeedsAction && me->RSVP())
item->setReply(true);
else
item->setReply(false);
} else
item->setReply(false);
#endif
mItemList->insertItem( item );
mToolTip += "\n";
}
void MonthViewCell::insertTodo(Todo *todo)
{
- QString text;
mItemList->setFocusPolicy(WheelFocus);
- if (todo->hasDueDate()) {
- if (!todo->doesFloat()) {
- text += KGlobal::locale()->formatTime(todo->dtDue().time());
- text += " ";
+ QString text;
+ if (todo->hasDueDate()) {
+ if (!todo->doesFloat()) {
+ text += KGlobal::locale()->formatTime(todo->dtDue().time());
+ text += " ";
+ }
}
- }
- text += i18n("T: %1").arg(todo->summary());
-
- MonthViewItem *item = new MonthViewItem( todo, mDate, text );
- //item->setPalette( mStandardPalette );
- QPalette pal;
- if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
- QStringList categories = todo->categories();
- QString cat = categories.first();
- if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
- pal = getPalette();
- if (cat.isEmpty()) {
- pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
+ text += i18n("Td: %1").arg(todo->summary());
+
+ MonthViewItem *item = new MonthViewItem( todo, mDate, text );
+ //item->setPalette( mStandardPalette );
+ QPalette pal;
+ if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
+ QStringList categories = todo->categories();
+ QString cat = categories.first();
+ if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
+ pal = getPalette();
+ if (cat.isEmpty()) {
+ pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
+ } else {
+ pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
+ }
+
} else {
- pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
+ if (cat.isEmpty()) {
+ pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
+ } else {
+ pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
+ }
}
-
+
} else {
- if (cat.isEmpty()) {
- pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
- } else {
- pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
- }
+ pal = mStandardPalette ;
}
-
- } else {
- pal = mStandardPalette ;
- }
- item->setPalette( pal );
- mItemList->insertItem( item );
- mToolTip += text+"\n";
+ item->setPalette( pal );
+ mItemList->insertItem( item );
+ mToolTip += text+"\n";
}
void MonthViewCell::finishUpdateCell()
{
#ifdef DESKTOP_VERSION
if (mToolTip != "")
QToolTip::add(this,mToolTip,toolTipGroup(),"");
#endif
mItemList->sort();
//setMyPalette();
setMyPalette();
QString text;
bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
mLabel->resize( mLabelBigSize );
text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
} else {
mLabel->resize( mLabelSize );
text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
}
mLabel->setText( text );
resizeEvent( 0 );
}
void MonthViewCell::updateCell()
{
+ qDebug("MonthViewCell::updateCell() ");
if ( !mMonthView->isUpdatePossible() )
return;
startUpdateCell();
//mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
Event *event;
for( event = events.first(); event; event = events.next() ) { // for event
insertEvent(event);
}
// insert due todos
QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
Todo *todo;
for(todo = todos.first(); todo; todo = todos.next()) {
insertTodo( todo );
}
finishUpdateCell();
// if ( isVisible())
//qApp->processEvents();
}
void MonthViewCell::updateConfig( bool bigFont ) // = false
{
if ( bigFont ) {
@@ -762,84 +755,84 @@ void MonthViewCell::cellClicked( QListBoxItem *item )
if ( lastClicked )
if ( ! item ) {
if ( lastClicked->listBox() != item->listBox() )
lastClicked->listBox()->clearSelection();
}
*/
mMonthView->setSelectedCell( this );
if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true );
select();
}
void MonthViewCell::contextMenu( QListBoxItem *item )
{
if ( !item ) return;
MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
Incidence *incidence = eventItem->incidence();
if ( incidence ) mMonthView->showContextMenu( incidence );
}
void MonthViewCell::selection( QListBoxItem *item )
{
if ( !item ) return;
+
mMonthView->setSelectedCell( this );
}
// *******************************************************************************
// *******************************************************************************
// *******************************************************************************
KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
: KOEventView( calendar, parent, name ),
mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
- mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
+ mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
{
- ignoreResizeEvent = 0;
- mShortDayLabelsW = false;
- mShortDayLabelsM = false;
+ skipResize = false;
clPending = true;
mWidStack = new QWidgetStack( this );
QHBoxLayout* hb = new QHBoxLayout( this );
mMonthView = new QWidget( mWidStack );
mWeekView = new QWidget( mWidStack );
#if QT_VERSION >= 0x030000
mWidStack->addWidget(mMonthView );
mWidStack->addWidget(mWeekView );
#else
mWidStack->addWidget( mMonthView, 1 );
mWidStack->addWidget( mWeekView , 1 );
#endif
hb->addWidget( mWidStack );
mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
mShowWeekView = KOPrefs::instance()->mMonthViewWeek;
if ( mShowWeekView )
mWeekStartsMonday = true;
updatePossible = false;
mCells.setAutoDelete( true );
+ mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
mDayLabels.resize( mDaysPerWeek );
mDayLabelsW.resize( mDaysPerWeek );
QFont bfont = font();
if ( QApplication::desktop()->width() < 650 ) {
bfont.setPointSize( bfont.pointSize() - 2 );
}
bfont.setBold( true );
int i;
for( i = 0; i < mDaysPerWeek; i++ ) {
QLabel *label = new QLabel( mMonthView );
label->setFont(bfont);
label->setFrameStyle(QFrame::Panel|QFrame::Raised);
label->setLineWidth(1);
label->setAlignment(AlignCenter);
mDayLabels.insert( i, label );
label = new QLabel( mWeekView );
label->setFont(bfont);
label->setFrameStyle(QFrame::Panel|QFrame::Raised);
label->setLineWidth(1);
label->setAlignment(AlignCenter);
mDayLabelsW.insert( i, label );
}
@@ -886,49 +879,49 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
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 ...
+ // 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 ( mShowWeekView )
mWidStack->raiseWidget( mWeekView );
else
mWidStack->raiseWidget( mMonthView );
emit incidenceSelected( 0 );
}
KOMonthView::~KOMonthView()
{
delete mContextMenu;
}
void KOMonthView::selectInternalWeekNum ( int n )
@@ -993,100 +986,104 @@ DateList KOMonthView::selectedDates()
if ( qd.isValid() ) selected.append( qd );
}
return selected;
}
void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
const QDate &td)
{
#ifndef KORG_NOPRINTER
calPrinter->preview(CalPrinter::Month, fd, td);
#endif
}
void KOMonthView::updateConfig()
{
mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
if ( mShowWeekView ) {
mWeekStartsMonday = true;
}
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;
}
+ bool temp = mShowSatSunComp ;
+ mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
if ( ! mShowWeekView ) {
+ if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
computeLayout();
}
updateDayLabels();
//qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
//int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
//resizeEvent( 0 );
for (uint i = 0; i < mCells.count(); ++i) {
mCells[i]->updateConfig();
}
for (uint i = 0; i < mCellsW.count(); ++i) {
mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont);
}
#ifdef DESKTOP_VERSION
MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
#endif
updateView();
}
void KOMonthView::updateDayLabels()
{
QPtrVector<QLabel> *mDayLabelsT;
mDayLabelsT = &mDayLabelsW;
for (int i = 0; i < 7; i++) {
if (mWeekStartsMonday) {
- bool show = mShortDayLabelsW;
- if ( i > 4 && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
+ bool show = mShortDayLabels;
+ if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
show = true;
(*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
} else {
- if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsW));
- else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsW));
+ if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels));
+ else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels));
}
}
mDayLabelsT = &mDayLabels;
for (int i = 0; i < 7; i++) {
if (mWeekStartsMonday) {
- bool show = mShortDayLabelsM;
- if ( i > 4 && KOPrefs::instance()->mMonthViewSatSunTog && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
+ bool show = mShortDayLabels;
+ if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
show = true;
(*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
} else {
- if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM));
- else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM));
+ if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels));
+ else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels));
}
}
}
void KOMonthView::showDates(const QDate &start, const QDate &)
{
// kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
QPtrVector<MonthViewCell> *cells;
QPtrVector<QLabel> *dayLabels;
QPtrVector<KOWeekButton> *weekLabels;
int weekNum = 6;
if ( mShowWeekView ) {
weekNum = 1;
cells = &mCellsW;
dayLabels = &mDayLabelsW;
weekLabels = &mWeekLabelsW;
} else {
cells = &mCells;
dayLabels = &mDayLabels;
weekLabels = &mWeekLabels;
}
@@ -1242,81 +1239,95 @@ void KOMonthView::updateView()
}
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());
- if ( ignoreResizeEvent ) {
- //qDebug("KOMonthView::resizeEvent ignored ");
- --ignoreResizeEvent;
+ qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height());
+ if ( skipResize ) {
+ skipResize = false;
+ qDebug("skipResize ");
return;
}
- if ( e->size().width()+ e->size().height() < 240 )
- return;
computeLayout();
clPending = true;
if ( mShowWeekView )
mCellsW[0]->setFocus();
else
mCells[0]->setFocus();
}
void KOMonthView::computeLayoutWeek()
{
- static int widd = 0;
- static int heigg = 0;
- if ( widd == width() && heigg == height () ) {
- return;
- }
- widd = width() ;
- heigg = height ();
+ 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 = size().width();//e
int hei = size().height()-1;
+
+ if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
+ return;
+
+
+ if ( lastWid == width() && lastHei ==height() )
+ return;
+ lastWid =width();
+ lastHei = height();
+
+
if ( wid < hei )
daysToShow = 2;
else
daysToShow = 3;
- bool combinedSatSun = true;
+ 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 ) {
@@ -1351,226 +1362,235 @@ void KOMonthView::computeLayoutWeek()
if ( i ==5 ) {
mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 );
x -= w ;y += h/2;
} else {
if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) {
++w;
}
mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
y -= h/2;
}
} else
mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h );
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);
-
- mShortDayLabelsW = mDayLabelsW[0]->width() < mWidthLongDayLabel ;
+ // 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());
+ mShortDayLabels = mDayLabelsW[0]->width() < mWidthLongDayLabel ;
updateDayLabels();
bool forceUpdate = !updatePossible;
updatePossible = true;
//mWeekLabels[mNumWeeks]->setText( i18n("M"));
if ( forceUpdate )
updateView();
}
void KOMonthView::computeLayout()
{
- // select the appropriate heading string size. E.g. "Wednesday" or "Wed".
- // note this only changes the text if the requested size crosses the
- // threshold between big enough to support the full name and not big
- // enough.
-
- int tWid = topLevelWidget()->size().width();
- int tHei = topLevelWidget()->size().height();
-
- int wid = size().width();//e
- int hei = size().height()-1;
+
- if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
- return;
+ static int lastWid = 0;
+ static int lastHei = 0;
-
if ( mShowWeekView ){
computeLayoutWeek();
return;
}
- static int widd = 0;
- static int heigg = 0;
- if ( widd == width() && heigg == height () ) {
- return;
- }
- widd = width() ;
- heigg = height ();
-
int daysToShow = 7;
bool combinedSatSun = false;
- if (KOPrefs::instance()->mMonthViewSatSunTog ) {
+ if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
daysToShow = 6;
combinedSatSun = true;
}
+ int tWid = topLevelWidget()->size().width();
+ int tHei = topLevelWidget()->size().height();
+
+ int wid = size().width();//e
+ int hei = size().height()-1;
+
+ if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei )
+ return;
+ if ( lastWid == width() && lastHei ==height() )
+ return;
+ lastWid =width();
+ lastHei = height();
+ 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;
} else {
mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 );
y -= h/2;
}
} else
mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
}
else
mCells[i]->setGeometry ( x+weeklabelwid,y,w,h );
x += w;
if ( x + w/2 > wid ) {
x = 0;
y += h;
}
}
y= dayLabelHei;
h = cellHei ;
for ( i = 0; i < 6; i++) {
if ( i == (6-rowModulo))
++h;
mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h);
y += h;
}
mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei);
- mShortDayLabelsM = mDayLabels[0]->width() < mWidthLongDayLabel ;
- qDebug("dlwid %d %d ",mDayLabels[0]->width() , mWidthLongDayLabel);
+ // 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());
+ mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ;
updateDayLabels();
bool forceUpdate = !updatePossible;
updatePossible = true;
+ //mWeekLabels[mNumWeeks]->setText( i18n("W"));
if ( forceUpdate )
updateView();
}
void KOMonthView::showContextMenu( Incidence *incidence )
{
mContextMenu->showIncidencePopup(incidence);
-
+ /*
+ if( incidence && incidence->type() == "Event" ) {
+ Event *event = static_cast<Event *>(incidence);
+ mContextMenu->showEventPopup(event);
+ } else {
+ kdDebug() << "MonthView::showContextMenu(): cast failed." << endl;
+ }
+ */
}
MonthViewCell * KOMonthView::selectedCell( )
{
return mSelectedCell;
}
void KOMonthView::setSelectedCell( MonthViewCell *cell )
{
+ // qDebug("KOMonthView::setSelectedCell ");
if ( mSelectedCell && mSelectedCell != cell ) {
MonthViewCell * mvc = mSelectedCell;
mSelectedCell = cell;
mvc->deselect();
} else
mSelectedCell = cell;
+ // if ( mSelectedCell )
+ // mSelectedCell->select();
if ( !mSelectedCell )
emit incidenceSelected( 0 );
else
emit incidenceSelected( mSelectedCell->selectedIncidence() );
}
void KOMonthView::processSelectionChange()
{
QPtrList<Incidence> incidences = selectedIncidences();
if (incidences.count() > 0) {
emit incidenceSelected( incidences.first() );
} else {
emit incidenceSelected( 0 );
}
}
void KOMonthView::clearSelection()
{
if ( mSelectedCell ) {
mSelectedCell->deselect();
mSelectedCell = 0;
}
}
void KOMonthView::keyPressEvent ( QKeyEvent * e )
{
//qDebug("KOMonthView::keyPressEvent ");
switch(e->key()) {
case Key_Up:
{
emit prevMonth();
if ( mShowWeekView )
mCellsW[0]->setFocus();
else
mCells[0]->setFocus();
}
e->accept();
break;
case Key_Down:
{
emit nextMonth();
if ( mShowWeekView )
mCellsW[0]->setFocus();
else
mCells[0]->setFocus();
-
+
}
e->accept();
break;
case Key_Return:
case Key_Enter:
{
selectInternalWeekNum ( currentWeek() );
}
e->accept();
break;
default:
e->ignore();
break;
}
}