author | umopapisdn <umopapisdn> | 2003-03-28 11:58:29 (UTC) |
---|---|---|
committer | umopapisdn <umopapisdn> | 2003-03-28 11:58:29 (UTC) |
commit | 6cee1b34ffc7b3b8a0c8e1831fff0cc1af0e708a (patch) (side-by-side diff) | |
tree | 4b25e548986b560f2fbe5f91ce61491046dcc361 | |
parent | 469731b3a6cb94037330d1f40398bede57a7c0f2 (diff) | |
download | opie-6cee1b34ffc7b3b8a0c8e1831fff0cc1af0e708a.zip opie-6cee1b34ffc7b3b8a0c8e1831fff0cc1af0e708a.tar.gz opie-6cee1b34ffc7b3b8a0c8e1831fff0cc1af0e708a.tar.bz2 |
Bugfix: (Bug #000782) Display events with no duration, unless it's an "effective event" ending at 00:00 starting at a previous day. (i.e ending at midnight)
-rw-r--r-- | core/pim/datebook/datebookday.cpp | 2 | ||||
-rw-r--r-- | core/pim/datebook/datebookweek.cpp | 2 | ||||
-rw-r--r-- | core/pim/datebook/datebookweeklst.cpp | 2 |
3 files changed, 3 insertions, 3 deletions
diff --git a/core/pim/datebook/datebookday.cpp b/core/pim/datebook/datebookday.cpp index 5d472a6..af98e06 100644 --- a/core/pim/datebook/datebookday.cpp +++ b/core/pim/datebook/datebookday.cpp @@ -216,193 +216,193 @@ void DateBookDay::setRowStyle( int style ) rowStyle = style; } void DateBookDay::updateView( void ) { timeMarker->setTime( QTime::currentTime() ); //need to find a way to update all DateBookDayWidgets } void DateBookDay::setSelectedWidget( DateBookDayWidget *w ) { selectedWidget = w; } DateBookDayWidget * DateBookDay::getSelectedWidget( void ) { return selectedWidget; } void DateBookDay::selectedDates( QDateTime &start, QDateTime &end ) { start.setDate( currDate ); end.setDate( currDate ); int sh=99,eh=-1; int n = dayView()->numSelections(); for (int i=0; i<n; i++) { QTableSelection sel = dayView()->selection( i ); sh = QMIN(sh,sel.topRow()); eh = QMAX(sh,sel.bottomRow()+1); } if (sh > 23 || eh < 1) { sh=8; eh=9; } start.setTime( QTime( sh, 0, 0 ) ); end.setTime( QTime( eh, 0, 0 ) ); } void DateBookDay::setDate( int y, int m, int d ) { header->setDate( y, m, d ); selectedWidget = 0; } void DateBookDay::setDate( QDate d) { header->setDate( d.year(), d.month(), d.day() ); selectedWidget = 0; } void DateBookDay::dateChanged( int y, int m, int d ) { QDate date( y, m, d ); if ( currDate == date ) return; currDate.setYMD( y, m, d ); relayoutPage(); dayView()->clearSelection(); QTableSelection ts; if (jumpToCurTime && this->date() == QDate::currentDate()) { ts.init( QTime::currentTime().hour(), 0); ts.expandTo( QTime::currentTime().hour(), 0); } else { ts.init( startTime, 0 ); ts.expandTo( startTime, 0 ); } dayView()->addSelection( ts ); selectedWidget = 0; } void DateBookDay::redraw() { if ( isUpdatesEnabled() ) relayoutPage(); } void DateBookDay::getEvents() { widgetList.clear(); QValueList<EffectiveEvent> eventList = db->getEffectiveEvents( currDate, currDate ); QValueListIterator<EffectiveEvent> it; for ( it = eventList.begin(); it != eventList.end(); ++it ) { EffectiveEvent ev=*it; - if(!(ev.end().hour()==ev.start().hour() && ev.end().minute()==ev.start().minute())) { // Skip effective events with no duration. (i.e ending at 00:00) + if(!((ev.end().hour()==0) && (ev.end().minute()==0) && (ev.startDate()!=ev.date()))) { // Skip events ending at 00:00 starting at another day. DateBookDayWidget* w = new DateBookDayWidget( *it, this ); connect( w, SIGNAL( deleteMe( const Event & ) ), this, SIGNAL( removeEvent( const Event & ) ) ); connect( w, SIGNAL( duplicateMe( const Event & ) ), this, SIGNAL( duplicateEvent( const Event & ) ) ); connect( w, SIGNAL( editMe( const Event & ) ), this, SIGNAL( editEvent( const Event & ) ) ); connect( w, SIGNAL( beamMe( const Event & ) ), this, SIGNAL( beamEvent( const Event & ) ) ); widgetList.append( w ); } } } static int place( const DateBookDayWidget *item, bool *used, int maxn ) { int place = 0; int start = item->event().start().hour(); QTime e = item->event().end(); int end = e.hour(); if ( e.minute() < 5 ) end--; if ( end < start ) end = start; while ( place < maxn ) { bool free = TRUE; int s = start; while( s <= end ) { if ( used[10*s+place] ) { free = FALSE; break; } s++; } if ( free ) break; place++; } if ( place == maxn ) { return -1; } while( start <= end ) { used[10*start+place] = TRUE; start++; } return place; } void DateBookDay::relayoutPage( bool fromResize ) { setUpdatesEnabled( FALSE ); if ( !fromResize ) getEvents(); // no need we already have them! widgetList.sort(); //sorts the widgetList by the heights of the widget so that the tallest widgets are at the beginning //this is needed for the simple algo below to work correctly, otherwise some widgets would be drawn outside the view int wCount = widgetList.count(); int wid = view->columnWidth(0)-1; int wd; int n = 1; QArray<int> anzIntersect(wCount); //this stores the number of maximal intersections of each widget for (int i = 0; i<wCount; anzIntersect[i] = 1, i++); if ( wCount < 20 ) { QArray<QRect> geometries(wCount); for (int i = 0; i < wCount; geometries[i] = widgetList.at(i)->geometry(), i++); //stores geometry for each widget in vector for ( int i = 0; i < wCount; i++) { QValueList<int> intersectedWidgets; //find all widgets intersecting with widgetList.at(i) for ( int j = 0; j < wCount; j++) if (i != j) if (geometries[j].intersects(geometries[i])) intersectedWidgets.append(j); //for each of these intersecting widgets find out how many widgets are they intersecting with for ( uint j = 0; j < intersectedWidgets.count(); j++) { QArray<int> inter(wCount); inter[j]=1; if (intersectedWidgets[j] != -1) for ( uint k = j; k < intersectedWidgets.count(); k++) if (j != k && intersectedWidgets[k] != -1) if (geometries[intersectedWidgets[k]].intersects(geometries[intersectedWidgets[j]])) { inter[j]++; intersectedWidgets[k] = -1; diff --git a/core/pim/datebook/datebookweek.cpp b/core/pim/datebook/datebookweek.cpp index 5bbf86a..874cf24 100644 --- a/core/pim/datebook/datebookweek.cpp +++ b/core/pim/datebook/datebookweek.cpp @@ -46,193 +46,193 @@ DateBookWeekItem::DateBookWeekItem( const EffectiveEvent e ) if ( ev.event().type() == Event::AllDay && !ev.event().hasAlarm() ) { c = Qt::green; } else { c = ev.event().hasAlarm() ? Qt::red : Qt::blue; } } void DateBookWeekItem::setGeometry( int x, int y, int w, int h ) { r.setRect( x, y, w, h ); } //------------------=--------------------------------------------- DateBookWeekView::DateBookWeekView( bool ap, bool startOnMonday, QWidget *parent, const char *name ) : QScrollView( parent, name ), ampm( ap ), bOnMonday( startOnMonday ), showingEvent( false ) { items.setAutoDelete( true ); viewport()->setBackgroundMode( PaletteBase ); header = new QHeader( this ); header->addLabel( "" ); header->setMovingEnabled( false ); header->setResizeEnabled( false ); header->setClickEnabled( false, 0 ); initNames(); connect( header, SIGNAL(clicked(int)), this, SIGNAL(showDay(int)) ); QObject::connect(qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotChangeClock(bool))); QFontMetrics fm( font() ); rowHeight = fm.height()+2; resizeContents( width(), 24*rowHeight ); } void DateBookWeekView::initNames() { static bool bFirst = true; if ( bFirst ) { if ( bOnMonday ) { header->addLabel( tr("M", "Monday" ) ); header->addLabel( tr("T", "Tuesday") ); header->addLabel( tr("W", "Wednesday" ) ); header->addLabel( tr("T", "Thursday" ) ); header->addLabel( tr("F", "Friday" ) ); header->addLabel( tr("S", "Saturday" ) ); header->addLabel( tr("S", "Sunday" ) ); } else { header->addLabel( tr("S", "Sunday" ) ); header->addLabel( tr("M", "Monday") ); header->addLabel( tr("T", "Tuesday") ); header->addLabel( tr("W", "Wednesday" ) ); header->addLabel( tr("T", "Thursday" ) ); header->addLabel( tr("F", "Friday" ) ); header->addLabel( tr("S", "Saturday" ) ); } bFirst = false; } else { // we are change things... if ( bOnMonday ) { header->setLabel( 1, tr("M", "Monday") ); header->setLabel( 2, tr("T", "Tuesday") ); header->setLabel( 3, tr("W", "Wednesday" ) ); header->setLabel( 4, tr("T", "Thursday" ) ); header->setLabel( 5, tr("F", "Friday" ) ); header->setLabel( 6, tr("S", "Saturday" ) ); header->setLabel( 7, tr("S", "Sunday" ) ); } else { header->setLabel( 1, tr("S", "Sunday" ) ); header->setLabel( 2, tr("M", "Monday") ); header->setLabel( 3, tr("T", "Tuesday") ); header->setLabel( 4, tr("W", "Wednesday" ) ); header->setLabel( 5, tr("T", "Thursday" ) ); header->setLabel( 6, tr("F", "Friday" ) ); header->setLabel( 7, tr("S", "Saturday" ) ); } } } void DateBookWeekView::showEvents( QValueList<EffectiveEvent> &ev ) { items.clear(); QValueListIterator<EffectiveEvent> it; for ( it = ev.begin(); it != ev.end(); ++it ) { DateBookWeekItem *i = new DateBookWeekItem( *it ); - if(!(i->event().end().hour()==i->event().start().hour() && i->event().end().minute()==i->event().start().minute())) { // Skip effective events with no duration. (i.e ending at 00:00) + if(!((i->event().end().hour()==0) && (i->event().end().minute()==0) && (i->event().startDate()!=i->event().date()))) { // Skip events ending at 00:00 starting at another day. positionItem( i ); items.append( i ); } } viewport()->update(); } void DateBookWeekView::moveToHour( int h ) { int offset = h*rowHeight; setContentsPos( 0, offset ); } void DateBookWeekView::keyPressEvent( QKeyEvent *e ) { e->ignore(); } void DateBookWeekView::slotChangeClock( bool c ) { ampm = c; viewport()->update(); } static inline int db_round30min( int m ) { if ( m < 15 ) m = 0; else if ( m < 45 ) m = 1; else m = 2; return m; } void DateBookWeekView::alterDay( int day ) { if ( !bOnMonday ) { day--; } emit showDay( day ); } void DateBookWeekView::positionItem( DateBookWeekItem *i ) { const int Width = 8; const EffectiveEvent ev = i->event(); // 30 minute intervals int y = ev.start().hour() * 2; y += db_round30min( ev.start().minute() ); int y2 = ev.end().hour() * 2; y2 += db_round30min( ev.end().minute() ); if ( y > 47 ) y = 47; if ( y2 > 48 ) y2 = 48; y = y * rowHeight / 2; y2 = y2 * rowHeight / 2; int h; if ( ev.event().type() == Event::AllDay ) { h = 48 * rowHeight / 2; y = 0; } else { h=y2-y; if ( h < 1 ) h = 1; } int dow = ev.date().dayOfWeek(); if ( !bOnMonday ) { if ( dow == 7 ) dow = 1; else dow++; } int x = header->sectionPos( dow ) - 1; int xlim = header->sectionPos( dow ) + header->sectionSize( dow ); DateBookWeekItem *isect = 0; do { i->setGeometry( x, y, Width, h ); isect = intersects( i ); x += Width - 1; } while ( isect && x < xlim ); } DateBookWeekItem *DateBookWeekView::intersects( const DateBookWeekItem *item ) { QRect geom = item->geometry(); // We allow the edges to overlap geom.moveBy( 1, 1 ); geom.setSize( geom.size()-QSize(2,2) ); QListIterator<DateBookWeekItem> it(items); diff --git a/core/pim/datebook/datebookweeklst.cpp b/core/pim/datebook/datebookweeklst.cpp index 4ceb360..3d6a029 100644 --- a/core/pim/datebook/datebookweeklst.cpp +++ b/core/pim/datebook/datebookweeklst.cpp @@ -118,193 +118,193 @@ DateBookWeekLstDayHdr::DateBookWeekLstDayHdr(const QDate &d, bool /*onM*/, QFont f=label->font(); f.setItalic(true); label->setFont(f); label->setPalette(QPalette(QColor(0,0,255),label->backgroundColor())); */ } else if (d.dayOfWeek() == 7) { // FIXME: Match any holiday QPalette pal=label->palette(); pal.setColor(QColorGroup::Foreground, QColor(255,0,0)); label->setPalette(pal); } connect (label, SIGNAL(clicked()), this, SLOT(showDay())); connect (add, SIGNAL(clicked()), this, SLOT(newEvent())); } void DateBookWeekLstDayHdr::showDay() { emit showDate(date.year(), date.month(), date.day()); } void DateBookWeekLstDayHdr::newEvent() { QDateTime start, stop; start=stop=date; start.setTime(QTime(10,0)); stop.setTime(QTime(12,0)); emit addEvent(start,stop,"",0); } DateBookWeekLstEvent::DateBookWeekLstEvent(const EffectiveEvent &ev, QWidget* parent, const char* name, WFlags fl) : OClickableLabel(parent,name,fl), event(ev) { char s[10]; if ( ev.startDate() != ev.date() ) { // multiday event (not first day) if ( ev.endDate() == ev.date() ) { // last day strcpy(s, "__|__"); } else { strcpy(s, " |---"); } } else { if(ev.event().type() == Event::Normal ) sprintf(s,"%.2d:%.2d",ev.start().hour(),ev.start().minute()); else sprintf(s," "); } setText(QString(s) + " " + ev.description()); connect(this, SIGNAL(clicked()), this, SLOT(editMe())); setAlignment( int( QLabel::WordBreak | QLabel::AlignLeft ) ); } void DateBookWeekLstEvent::editMe() { emit editEvent(event.event()); } DateBookWeekLstView::DateBookWeekLstView(QValueList<EffectiveEvent> &ev, const QDate &d, bool onM, QWidget* parent, const char* name, WFlags fl) : QWidget( parent, name, fl ) { onMonday=onM; setPalette(white); setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); QVBoxLayout *layout = new QVBoxLayout( this ); qBubbleSort(ev); QValueListIterator<EffectiveEvent> it; it=ev.begin(); int dayOrder[7]; if (onMonday) for (int d=0; d<7; d++) dayOrder[d]=d+1; else { for (int d=0; d<7; d++) dayOrder[d]=d; dayOrder[0]=7; } for (int i=0; i<7; i++) { // Header DateBookWeekLstDayHdr *hdr=new DateBookWeekLstDayHdr(d.addDays(i), onMonday,this); connect(hdr, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); connect(hdr, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); layout->addWidget(hdr); // Events while ( (*it).date().dayOfWeek() == dayOrder[i] && it!=ev.end() ) { - if(!((*it).end().hour()==(*it).start().hour() && (*it).end().minute()==(*it).start().minute())) { // Skip effective events with no duration. (i.e ending at 00:00) + if(!(((*it).end().hour()==0) && ((*it).end().minute()==0) && ((*it).startDate()!=(*it).date()))) { // Skip events ending at 00:00 starting at another day. DateBookWeekLstEvent *l=new DateBookWeekLstEvent(*it,this); layout->addWidget(l); connect (l, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); } it++; } layout->addItem(new QSpacerItem(1,1, QSizePolicy::Minimum, QSizePolicy::Expanding)); } } DateBookWeekLstView::~DateBookWeekLstView(){} void DateBookWeekLstView::keyPressEvent(QKeyEvent *e) {e->ignore();} DateBookWeekLstDblView::DateBookWeekLstDblView(QValueList<EffectiveEvent> &ev1, QValueList<EffectiveEvent> &ev2, QDate &d, bool onM, QWidget* parent, const char* name, WFlags fl) : QWidget( parent, name, fl ) { QHBoxLayout *layout = new QHBoxLayout( this ); DateBookWeekLstView *w=new DateBookWeekLstView(ev1,d,onM,this); layout->addWidget(w); connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &,const QString &)), this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); w=new DateBookWeekLstView(ev2,d.addDays(7),onM,this); layout->addWidget(w); connect (w, SIGNAL(editEvent(const Event &)), this, SIGNAL(editEvent(const Event &))); connect (w, SIGNAL(showDate(int,int,int)), this, SIGNAL(showDate(int,int,int))); connect (w, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &)), this, SIGNAL(addEvent(const QDateTime &, const QDateTime &, const QString &, const QString &))); } DateBookWeekLst::DateBookWeekLst( bool ap, bool onM, DateBookDB *newDB, QWidget *parent, const char *name ) : QWidget( parent, name ), db( newDB ), startTime( 0 ), ampm( ap ), onMonday(onM) { setFocusPolicy(StrongFocus); layout = new QVBoxLayout( this ); layout->setMargin(0); header=new DateBookWeekLstHeader(onM, this); layout->addWidget( header ); connect(header, SIGNAL(dateChanged(int,int)), this, SLOT(dateChanged(int,int))); connect(header, SIGNAL(setDbl(bool)), this, SLOT(setDbl(bool))); scroll=new QScrollView(this); //scroll->setVScrollBarMode(QScrollView::AlwaysOn); //scroll->setHScrollBarMode(QScrollView::AlwaysOff); scroll->setResizePolicy(QScrollView::AutoOneFit); layout->addWidget(scroll); view=NULL; Config config("DateBook"); config.setGroup("Main"); dbl=config.readBoolEntry("weeklst_dbl", false); header->dbl->setOn(dbl); } DateBookWeekLst::~DateBookWeekLst(){ Config config("DateBook"); config.setGroup("Main"); config.writeEntry("weeklst_dbl", dbl); } void DateBookWeekLst::setDate(const QDate &d) { int w,y; calcWeek(d,w,y,onMonday); year=y; _week=w; header->setDate(date()); } void DateBookWeekLst::setDbl(bool on) { dbl=on; redraw(); } |