summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-03-25 02:15:46 (UTC)
committer zautrix <zautrix>2005-03-25 02:15:46 (UTC)
commit658354b7112aff72f0fadd924c82b977d803bc27 (patch) (side-by-side diff)
treeda728354015340c16466fbfb3c851d96d6d95196 /korganizer
parent7c2e130ddd194f1c4b5365af6999a27c08232f4b (diff)
downloadkdepimpi-658354b7112aff72f0fadd924c82b977d803bc27.zip
kdepimpi-658354b7112aff72f0fadd924c82b977d803bc27.tar.gz
kdepimpi-658354b7112aff72f0fadd924c82b977d803bc27.tar.bz2
fixes
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp88
1 files changed, 55 insertions, 33 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 8ee5bc3..050bfb9 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -291,100 +291,107 @@ void MonthViewItem::paint(QPainter *p)
p->fillRect ( x+1, y-1, val ,size+2,Qt::black );
p->drawRect ( x, y-1,7,size+2);
x += size + 3;
}
}
QFontMetrics fm = p->fontMetrics();
int yPos;
int pmheight = size;
if( pmheight < fm.height() )
yPos = fm.ascent() + fm.leading()/2;
else
yPos = pmheight/2 - fm.height()/2 + fm.ascent();
p->setPen( palette().color( QPalette::Normal, sel ? \
QColorGroup::HighlightedText : QColorGroup::Foreground ) );
p->drawText( x, yPos, text() );
if ( mIncidence->cancelled() ) {
int wid = fm.width( text() );
p->drawLine( x, heihei/2-1 ,x+wid, heihei/2-1 );
}
}
int MonthViewItem::height(const QListBox *lb) const
{
+ int ret = 10;
if ( lb )
- return lb->fontMetrics().lineSpacing()+1;
- return 10;
+ ret = lb->fontMetrics().lineSpacing()+1;
+ return ret;
}
int MonthViewItem::width(const QListBox *lb) const
{
- int size = PIXMAP_SIZE;
- if ( QApplication::desktop()->width() < 300 )
- size = 3;
- int x = 1;
- if ( KOPrefs::instance()->mMonthShowIcons ) {
- if ( mInfo ) {
- x += size + 1;
- }
- if( mRecur ) {
- x += size+1;
- }
- if( mAlarm ) {
- x += size+1;
+
+ if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) {
+ int size = PIXMAP_SIZE;
+ if ( QApplication::desktop()->width() < 300 )
+ size = 3;
+ int x = 1;
+ if ( KOPrefs::instance()->mMonthShowIcons ) {
+ if ( mInfo ) {
+ x += size + 1;
+ }
+ if( mRecur ) {
+ x += size+1;
+ }
+ if( mAlarm ) {
+ x += size+1;
+ }
+ if( mReply ) {
+ x += size+1;
+ }
}
- if( mReply ) {
- x += size+1;
+ if( mMultiday ) {
+ x += size+1+2+size/2;
}
+ return( x + lb->fontMetrics().width( text() ) + 1 );
}
- if( mMultiday ) {
- x += size+1+2+size/2;
- }
-
- return( x + lb->fontMetrics().width( text() ) + 1 );
+ if ( ! lb )
+ return 10;
+ //qDebug("ret wid %d ", lb->width());
+ return lb->width();
}
MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
: QWidget( par ),
mMonthView( parent )
{
- QVBoxLayout *topLayout = new QVBoxLayout( this );
+ //QVBoxLayout *topLayout = new QVBoxLayout( this );
// mLabel = new QLabel( this );QPushButton
mLabel = new QPushButton( this );
//mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
//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 );
+ //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 * ) ) );
connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
SLOT( cellClicked( QListBoxItem * ) ) );
connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
SLOT( selection( QListBoxItem * ) ) );
}
#ifdef DESKTOP_VERSION
QToolTipGroup *MonthViewCell::toolTipGroup()
{
@@ -396,59 +403,62 @@ QToolTipGroup *MonthViewCell::toolTipGroup()
void MonthViewCell::setDate( const QDate &date )
{
// kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
mDate = date;
//resizeEvent( 0 );
}
QDate MonthViewCell::date() const
{
return mDate;
}
void MonthViewCell::setPrimary( bool primary )
{
mPrimary = primary;
//setMyPalette();
}
void MonthViewCell::setMyPalette()
{
if ( mHoliday) {
- setPalette( mHolidayPalette );
+ mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) ));
+ mItemList->setPalette( mHolidayPalette );
} else {
if ( mPrimary ) {
- setPalette( mPrimaryPalette );
+ mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
+ mItemList->setPalette( mPrimaryPalette );
} else {
- setPalette( mNonPrimaryPalette );
+ mItemList->setPalette( mNonPrimaryPalette );
+ mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
}
}
- QPalette pal = palette();
+ //QPalette pal = palette();
- mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
+ //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
}
QPalette MonthViewCell::getPalette ()
{
if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
return mStandardPalette;
if ( mHoliday) {
return mHolidayPalette ;
} else {
if ( mPrimary ) {
return mPrimaryPalette ;
}
}
return mNonPrimaryPalette;
}
bool MonthViewCell::isPrimary() const
{
return mPrimary;
}
void MonthViewCell::setHoliday( bool holiday )
{
mHoliday = holiday;
//setMyPalette();
}
@@ -653,49 +663,50 @@ void MonthViewCell::insertTodo(Todo *todo)
}
void MonthViewCell::finishUpdateCell()
{
#ifdef DESKTOP_VERSION
if (mToolTip.count() > 0 ) {
mToolTip.sort();
QToolTip::add(this,mToolTip.join("\n"),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 );
+ 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();
}
@@ -714,107 +725,118 @@ void MonthViewCell::updateConfig( bool bigFont ) // = false
QFontMetrics fm( font() );
mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
mHolidayPalette = mStandardPalette;
mPrimaryPalette = mStandardPalette;
mNonPrimaryPalette = mStandardPalette;
if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
}
//updateCell();
}
void MonthViewCell::enableScrollBars( bool enabled )
{
if ( enabled ) {
- mItemList->setVScrollBarMode(QScrollView::Auto);
+ //mItemList->setVScrollBarMode(QScrollView::Auto);
mItemList->setHScrollBarMode(QScrollView::Auto);
+ QListBoxItem *fi = mItemList->firstItem ();
+ if (fi ) {
+ int hei = mItemList->numRows () * fi->height(mItemList);
+ if ( hei < height() - mItemList->horizontalScrollBar()->height () )
+ mItemList->setVScrollBarMode(QScrollView::AlwaysOff);
+ else
+ mItemList->setVScrollBarMode(QScrollView::Auto);
+ }
} else {
mItemList->setVScrollBarMode(QScrollView::AlwaysOff);
mItemList->setHScrollBarMode(QScrollView::AlwaysOff);
}
}
Incidence *MonthViewCell::selectedIncidence()
{
int index = mItemList->currentItem();
if ( index < 0 ) return 0;
MonthViewItem *item =
static_cast<MonthViewItem *>( mItemList->item( index ) );
if ( !item ) return 0;
return item->incidence();
}
QDate MonthViewCell::selectedIncidenceDate()
{
QDate qd;
int index = mItemList->currentItem();
if ( index < 0 ) return qd;
MonthViewItem *item =
static_cast<MonthViewItem *>( mItemList->item( index ) );
if ( !item ) return qd;
return item->incidenceDate();
}
void MonthViewCell::deselect()
{
mItemList->clearSelection();
enableScrollBars( false );
// updateCell();
}
void MonthViewCell::select()
{
;// updateCell();
}
-void MonthViewCell::resizeEvent ( QResizeEvent * )
+void MonthViewCell::resizeEvent ( QResizeEvent * e )
{
if ( !mMonthView->isUpdatePossible() )
return;
-
+ //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height());
+ deselect();
int size = height() - mLabel->height() - 2;
if ( size > 0 )
mItemList->verticalScrollBar()->setMaximumHeight( size );
size = width() - mLabel->width() -2;
if ( size > 0 )
mItemList->horizontalScrollBar()->setMaximumWidth( size );
mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() );
//mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
+ mItemList->resize ( width(), height () );
+
}
void MonthViewCell::defaultAction( QListBoxItem *item )
{
if ( !item ) return;
MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
Incidence *incidence = eventItem->incidence();
if ( incidence ) mMonthView->defaultAction( incidence );
}
void MonthViewCell::showDay()
{
emit showDaySignal( date() );
}
void MonthViewCell::newEvent()
{
QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
emit newEventSignal( dt );
}
void MonthViewCell::cellClicked( QListBoxItem *item )
{
static QListBoxItem * lastClicked = 0;
if ( item == 0 ) {
QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );