summaryrefslogtreecommitdiffabout
path: root/korganizer/komonthview.cpp
authorzautrix <zautrix>2005-06-27 17:25:27 (UTC)
committer zautrix <zautrix>2005-06-27 17:25:27 (UTC)
commit2a6c47afc7688923f427f4a38e3353e3503ab09a (patch) (side-by-side diff)
treef314e7062e60f8e0302714bcc6149f2e83c96e30 /korganizer/komonthview.cpp
parent58ad1402f6415de889e7a0dc98be29e9ae56d86c (diff)
downloadkdepimpi-2a6c47afc7688923f427f4a38e3353e3503ab09a.zip
kdepimpi-2a6c47afc7688923f427f4a38e3353e3503ab09a.tar.gz
kdepimpi-2a6c47afc7688923f427f4a38e3353e3503ab09a.tar.bz2
monthview enh
Diffstat (limited to 'korganizer/komonthview.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/komonthview.cpp116
1 files changed, 113 insertions, 3 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index cba85fa..9b0389d 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -133,24 +133,25 @@ void KNoScrollListBox::focusInEvent ( QFocusEvent * e )
}
}
}
void KNoScrollListBox::focusOutEvent ( QFocusEvent * e )
{
int i = currentItem ();
if ( i >= 0 ) {
setSelected ( i, false );
}
QListBox::focusOutEvent ( e );
setVScrollBarMode(QScrollView::AlwaysOff);
setHScrollBarMode(QScrollView::AlwaysOff);
+ emit highligtIncidence( 0, (MonthViewCell*)this, 0 );
}
QString KNoScrollListBox::getWhatsThisText(QPoint p)
{
QListBoxItem* item = itemAt ( p );
if ( ! item ) {
return i18n("Click in the cell\nto add an event!");
}
return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(),
KOPrefs::instance()->mWTshowDetails,
KOPrefs::instance()->mWTshowCreated,
KOPrefs::instance()->mWTshowChanged);
@@ -271,63 +272,89 @@ void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
{
QListBox::mousePressEvent(e);
if(e->button() == RightButton) {
emit rightClick();
}
}
MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
: QListBoxItem()
{
+ mDisplayHightlighted = false;
mblockRepaint = true;
setText( s );
mMultiday = 0;
mIncidence = incidence;
mDate = qd;
mRecur = false;
mAlarm = false;
mReply = false;
mInfo = false;
mdayPos = 0;
isWeekItem = KOPrefs::instance()->mMonthViewWeek;
}
void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s)
{
+ mDisplayHightlighted = false;
setText( s );
mMultiday = 0;
mIncidence = incidence;
mDate = qd;
mRecur = false;
mAlarm = false;
mReply = false;
mInfo = false;
mdayPos = 0;
}
+bool MonthViewItem::setHighlightedFalse()
+{
+ if ( !mDisplayHightlighted )
+ return false;
+ mDisplayHightlighted = false;
+ return true;
+}
+bool MonthViewItem::setHighlighted( Incidence * inc )
+{
+ if ( inc == mIncidence ) {
+ if ( mDisplayHightlighted )
+ return false;
+ mDisplayHightlighted = true;
+ return true;
+ } else {
+ if ( !mDisplayHightlighted )
+ return false;
+ mDisplayHightlighted = false;
+ return true;
+ }
+ return false;
+}
void MonthViewItem::paint(QPainter *p)
{
if ( mblockRepaint ) {
return;
}
#if QT_VERSION >= 0x030000
bool sel = isSelected();
#else
bool sel = selected();
#endif
int heihei = height( listBox () );
int x = 1;
- if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
+ if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHightlighted )
{
+ if ( mDisplayHightlighted )
+ sel = true;
p->setBackgroundColor( palette().color( QPalette::Normal, \
sel ? QColorGroup::Highlight : QColorGroup::Background ) );
p->eraseRect( 0, 0, listBox()->maxItemWidth(), heihei );
}
//int y = 3;//(height() - mRecurPixmap.height()) /2;
int size = PIXMAP_SIZE;
if ( QApplication::desktop()->width() < 300 )
size = 3;
int y = (heihei - size -1 ) /2;
if ( mIncidence->calID() > 1 ) {
@@ -591,24 +618,25 @@ void MonthViewCell::setHoliday( bool holiday )
void MonthViewCell::setHoliday( const QString &holiday )
{
mHolidayString = holiday;
if ( !holiday.isEmpty() ) {
setHoliday( true );
}
}
void MonthViewCell::startUpdateCell()
{
+
mdayCount = 0;
setFocusPolicy(NoFocus);
if ( !mMonthView->isUpdatePossible() )
return;
MonthViewItem *mitem = (MonthViewItem*) firstItem ();
while ( mitem ) {
mitem->setBlockRepaint( true );
mitem = (MonthViewItem *)mitem->next();
}
if ( mAvailItemList.count() > 20 ) {
mAvailItemList.setAutoDelete( true );
mAvailItemList.clear();
@@ -1074,30 +1102,57 @@ void MonthViewCell::contextMenu( QListBoxItem *item )
mMonthView->setPopupCell( this );
if ( !item ) {
mMonthView->showContextMenu( 0 );
return;
}
MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
Incidence *incidence = eventItem->incidence();
if ( incidence ) mMonthView->showContextMenu( incidence );
}
void MonthViewCell::selection( QListBoxItem *item )
{
- if ( !item ) return;
-
+ if ( !item ) {
+ emit highligtIncidence( 0 , this, 0 );
+ return;
+ }
+ MonthViewItem * it = (static_cast<MonthViewItem *>( item ));
+ emit highligtIncidence( it->incidence(), this, it->multiDay() );
mMonthView->setSelectedCell( this );
}
+void MonthViewCell::deHightLight()
+{
+ MonthViewItem *mitem = (MonthViewItem*) firstItem ();
+ while ( mitem ) {
+ if ( mitem->setHighlightedFalse() )
+ updateItem ( mitem );
+ mitem = (MonthViewItem *)mitem->next();
+ }
+}
+// returns true if no inc found
+bool MonthViewCell::doHightLight( Incidence * inc )
+{
+ MonthViewItem *mitem = (MonthViewItem*) firstItem ();
+ while ( mitem ) {
+ if ( mitem->incidence() == inc ) {
+ if ( mitem->setHighlighted( inc ) )
+ updateItem ( mitem );
+ return false;
+ }
+ mitem = (MonthViewItem *)mitem->next();
+ }
+ return true;
+}
// *******************************************************************************
// *******************************************************************************
// *******************************************************************************
KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
: KOEventView( calendar, parent, name ),
mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
{
mFlagKeyPressed = false;
mShortDayLabelsM = false;
@@ -1191,41 +1246,45 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
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 ) ) );
connect( cell, SIGNAL( nextCell() ),
SLOT( nextCell() ) );
connect( cell, SIGNAL( prevCell() ),
SLOT( prevCell() ) );
+ connect( cell, SIGNAL( highligtIncidence( Incidence * , MonthViewCell *, int ) ),
+ SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) ));
}
}
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 ) ) );
connect( cell, SIGNAL( nextCell() ),
SLOT( nextCell() ) );
connect( cell, SIGNAL( prevCell() ),
SLOT( prevCell() ) );
+ connect( cell, SIGNAL( highligtIncidence( Incidence * , MonthViewCell *, int ) ),
+ SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) ));
cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont );
}
//connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) );
mContextMenu = eventPopup();
mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
i18n("New Event..."),this,
SLOT(slotNewEvent()),false);
mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
i18n("New Todo..."),this,
SLOT(slotNewTodo()),false);
mContextMenu->addAdditionalItem(QIconSet(QPixmap()),
@@ -1279,24 +1338,75 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
if ( mShowWeekView )
mWidStack->raiseWidget( mWeekView );
else
mWidStack->raiseWidget( mMonthView );
}
KOMonthView::~KOMonthView()
{
delete mContextMenu;
}
+void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday )
+{
+ //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday );
+ static Incidence * lastInc = 0;
+ static MonthViewCell * lastCell = 0;
+
+ if ( lastInc == inc && lastCell == mc )
+ return;
+ lastInc = inc;
+ lastCell = mc;
+ //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday );
+
+ bool weekview = false;
+ int index = 0;
+ for (uint i = 0; i < mCellsW.count(); ++i) {
+ if ( mCellsW[i] == mc ) {
+ weekview = true;
+ index = i;
+ break;
+ }
+ }
+ QPtrVector<MonthViewCell> *cells;
+ if ( weekview )
+ cells = &mCellsW;
+ else {
+ for (uint i = 0; i < mCells.count(); ++i) {
+ if ( mCells[i] == mc ) {
+ index = i;
+ break;
+ }
+ }
+ cells = &mCells;
+ }
+ for (uint i = 0; i < (*cells).count(); ++i) {
+ (*cells)[i]->deHightLight();
+ }
+ if ( ! inc )
+ return;
+ if ( mday > 1 && index > 0 )
+ for (int i = index-1; i >= 0; --i) {
+ //qDebug("index %d iii %d ", index, i);
+ if ( (*cells)[(uint)i]->doHightLight(inc) )
+ break;
+ }
+ if ( mday < 3 && mday > 0 && index < (*cells).count()-1)
+ for (uint i = index+1; i < (*cells).count(); ++i) {
+ if ( (*cells)[i]->doHightLight(inc) )
+ break;
+ }
+
+}
void KOMonthView::selectInternalWeekNum ( int n )
{
switchView();
if ( !KOPrefs::instance()->mMonthViewWeek )
emit selectMonth ();
else
emit selectWeekNum ( n );
}
int KOMonthView::currentWeek()
{
if ( mShowWeekView )