summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--korganizer/komonthview.cpp116
-rw-r--r--korganizer/komonthview.h13
2 files changed, 122 insertions, 7 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index cba85fa..9b0389d 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -121,48 +121,49 @@ void KNoScrollListBox::focusInEvent ( QFocusEvent * e )
else
setVScrollBarMode(QScrollView::Auto);
if ( ihei *3 > height() ) {
setHScrollBarMode(QScrollView::AlwaysOff);
}
else {
setHScrollBarMode(QScrollView::Auto);
}
} else {
setVScrollBarMode(QScrollView::Auto);
setHScrollBarMode(QScrollView::Auto);
}
}
}
}
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);
}
void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
{
//qDebug("KNoScrollListBox::keyPressEvent ");
switch(e->key()) {
case Key_Right:
if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
{
e->ignore();
return;
}
scrollBy(10,0);
@@ -259,87 +260,113 @@ void KNoScrollListBox::oneDown()
}
void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
{
switch(e->key()) {
case Key_Shift:
emit shiftUp();
break;
default:
break;
}
}
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 ) {
p->fillRect ( x, y-2,size,size+4, KOPrefs::instance()->defaultColor( mIncidence->calID() ) );
p->drawRect ( x, y-2,size,size+4);
x += size + 1;
}
if ( KOPrefs::instance()->mMonthShowIcons ) {
if ( mInfo ) {
p->fillRect ( x, y,size,size, Qt::darkGreen );
x += size + 1;
}
if ( mRecur ) {
p->fillRect ( x, y,size,size, Qt::blue );
x += size + 1;
@@ -579,48 +606,49 @@ QPalette MonthViewCell::getPalette ()
return mNonPrimaryPalette;
}
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::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();
mAvailItemList.setAutoDelete( false );
clear();
}
setPrimary( mDate.month()%2 );
setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
if ( mDate == QDate::currentDate() ) {
setLineWidth( 3 );
} else {
setLineWidth( 1 );
}
MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem ();
@@ -1062,54 +1090,81 @@ void MonthViewCell::cellClicked( QListBoxItem *item )
{
mMonthView->setSelectedCell( this );
if ( item == 0 ) {
QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
emit newEventSignal( dt );
return;
}
}
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;
mShortDayLabelsW = false;
skipResize = false;
clPending = true;
mPopupCell = 0;
mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" );
mWidStack = new QWidgetStack( this );
QVBoxLayout* hb = new QVBoxLayout( this );
mMonthView = new QWidget( mWidStack );
mWeekView = new QWidget( mWidStack );
#if QT_VERSION >= 0x030000
mWidStack->addWidget(mMonthView );
mWidStack->addWidget(mWeekView );
@@ -1179,65 +1234,69 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
//label->setAlignment(AlignCenter);
mWeekLabelsW.insert( i, label );
}
mWeekLabelsW[1]->setText( i18n("W"));
mWeekLabelsW[1]->setFocusPolicy(WheelFocus);
int row, col;
mCells.resize( mNumCells );
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 ) ) );
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()),
i18n("Journal"),this,
SLOT(slotEditJournal()),false);
QString pathString = "";
if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
if ( QApplication::desktop()->width() < 480 )
pathString += "icons16/";
} else
pathString += "iconsmini/";
mNewItemMenu = new QPopupMenu( this );
@@ -1267,48 +1326,99 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
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::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 )
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();
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index 65b5e77..159af16 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -23,197 +23,201 @@
#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 MonthViewCell;
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:
void focusInEvent ( QFocusEvent * ){;}
int mNumber;
void keyPressEvent ( QKeyEvent * e )
{
e->ignore();
}
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();
void rightClick();
void nextCell();
void prevCell();
+ void highligtIncidence( Incidence * , MonthViewCell*, int );
protected slots:
void oneDown();
void keyPressEvent(QKeyEvent *);
void keyReleaseEvent(QKeyEvent *);
void mousePressEvent(QMouseEvent *);
void focusInEvent ( QFocusEvent * );
void focusOutEvent ( QFocusEvent * );
private:
bool resetOnFocusIn;
KNOWhatsThis * mWT;
};
class MonthViewItem: public QListBoxItem
{
public:
MonthViewItem( Incidence *, QDate qd, const QString & title );
void recycle( Incidence *incidence, QDate qd, const QString & s);
void setRecur(bool on) { mRecur = on; }
void setAlarm(bool on) { mAlarm = on; }
void setReply(bool on) { mReply = on; }
void setMoreInfo(bool on) { mInfo = on; }
void setMultiDay(int type) { mMultiday = type; }
+ int multiDay() { return mMultiday; }
void setMultiDayPos(int type) { mdayPos = type; }
int gettMultiDayPos() { return mdayPos; }
void setBlockRepaint(bool on) { mblockRepaint = on; }
-
+ bool setHighlighted( Incidence * );
void setPalette(const QPalette &p) { mPalette = p; }
QPalette palette() const { return mPalette; }
-
+ bool setHighlightedFalse();
Incidence *incidence() const { return mIncidence; }
QDate incidenceDate() { return mDate; }
protected:
virtual void paint(QPainter *);
virtual int height(const QListBox *) const;
virtual int width(const QListBox *) const;
private:
int mdayPos;
bool isWeekItem;
bool mblockRepaint;
int mMultiday;
bool mRecur;
bool mAlarm;
bool mReply;
bool mInfo;
+ bool mDisplayHightlighted;
QPalette mPalette;
QDate mDate;
Incidence *mIncidence;
};
class KOMonthView;
class MonthViewCell : public KNoScrollListBox
{
Q_OBJECT
public:
MonthViewCell(KOMonthView *,QWidget* );
~MonthViewCell() {mAvailItemList.setAutoDelete( true );}
void setDate( const QDate & );
QDate date() const;
void setPrimary( bool );
bool isPrimary() const;
void setHoliday( bool );
void setHoliday( const QString & );
void updateCell();
void startUpdateCell();
void finishUpdateCell();
void repaintfinishUpdateCell();
int insertEvent(Event *);
void insertTodo(Todo *);
void updateConfig( bool bigFont = false );
void enableScrollBars( bool );
Incidence *selectedIncidence();
QDate selectedIncidenceDate();
QPushButton * dateLabel() { return mLabel; }
-
+ void deHightLight();
+ bool doHightLight( Incidence *);
void deselect();
void select();
#ifdef DESKTOP_VERSION
static QToolTipGroup *toolTipGroup();
#endif
signals:
void defaultAction( Incidence * );
void newEventSignal( QDateTime );
void showDaySignal( QDate );
protected:
QStringList mToolTip;
void resizeEvent( QResizeEvent * );
public slots:
void showDay();
-
protected slots:
void defaultAction( QListBoxItem * );
void contextMenu( QListBoxItem * );
void selection( QListBoxItem * );
void cellClicked( QListBoxItem * );
void newEvent();
private:
int mdayCount;
QPtrList <MonthViewItem> mAvailItemList;
KOMonthView *mMonthView;
int currentPalette;
QDate mDate;
bool mPrimary;
bool mHoliday;
QString mHolidayString;
//QLabel *mLabel;
QPushButton *mLabel;
//QListBox *mItemList;
#ifdef DESKTOP_VERSION
static QToolTipGroup *mToolTipGroup;
#endif
@@ -237,48 +241,49 @@ class KOMonthView: public KOEventView
~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 ;}
void clearList();
public slots:
+ void incidenceHighlighted( Incidence *, MonthViewCell*, int );
void nextCell();
void prevCell();
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 setPopupCell( MonthViewCell * );
void switchView();
void setKeyBoardFocus();
void setKeyBFocus();
protected slots:
void slotNewTodo();
void slotNewEvent();
void slotEditJournal();
void slotComputeLayout();