Changeset 699d5b8 for src


Ignore:
Timestamp:
01/21/10 14:38:39 (12 years ago)
Author:
fortefr <fortefr@…>
Branches:
master, qt5
Children:
6a807e7
Parents:
06570e9
Message:

Time conflict warning

Location:
src/mvc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/mvc/delegate.cpp

    r06570e9 r699d5b8  
    3535
    3636    painter->save();
    37 
    3837    QColor bkgrColor = Qt::cyan;
     38
    3939    QPen borderPen(bkgrColor.darker());
    4040    //QColor bkgrColor = QColor(0,0,113);
     
    6464
    6565        //int spacer = (fmSmall.boundingRect("999").width() < SPACER) ? SPACER : fmSmall.boundingRect("999").width();
     66
     67        //Time conflicts are colored differently
     68        if ((static_cast<Event*>(index.internalPointer())->isFavourite())
     69            && (hasTimeConflict(index, index.parent())))
     70        {
     71            bkgrColor = Qt::yellow;
     72        }
    6673
    6774        if(isLast(index))
     
    127134        painter->drawImage(mControls[MapControl]->drawPoint(option.rect),*mControls[MapControl]->image());
    128135        // Time conflict
    129         if(static_cast<Event*>(index.internalPointer())->hasTimeConflict())
     136        //if(static_cast<Event*>(index.internalPointer())->hasTimeConflict())
     137        if(bkgrColor == Qt::yellow)
    130138            painter->drawImage(mControls[WarningControlOn]->drawPoint(option.rect),*mControls[WarningControlOn]->image());
    131139        else
     
    406414}
    407415
     416bool Delegate::hasTimeConflict(const QModelIndex &index, const QModelIndex &parent) const
     417{
     418    Event *event = static_cast<Event*>(index.internalPointer());
     419    QTime start = event->start().time();
     420    QTime end = start.addSecs(event->duration());
     421    for(int i=0; i<parent.model()->rowCount(parent); i++)
     422    {
     423        if((event->id()!=static_cast<Event*>(parent.child(i,0).internalPointer())->id())
     424        &&
     425        (static_cast<Event*>(parent.child(i,0).internalPointer())->isFavourite()))
     426        {
     427            if (((start >= static_cast<Event*>(parent.child(i,0).internalPointer())->start().time())
     428            &&
     429            (start <= static_cast<Event*>(parent.child(i,0).internalPointer())->start().time().addSecs(static_cast<Event*>(parent.child(i,0).internalPointer())->duration())))
     430            ||
     431            ((end >= static_cast<Event*>(parent.child(i,0).internalPointer())->start().time())
     432            &&
     433            (end <= static_cast<Event*>(parent.child(i,0).internalPointer())->start().time().addSecs(static_cast<Event*>(parent.child(i,0).internalPointer())->duration()))))
     434            {
     435                return true;
     436            }
     437        }
     438    }
     439    return false;
     440}
  • src/mvc/delegate.h

    r06570e9 r699d5b8  
    7272        int numberOfFavourities(const QModelIndex &index) const;
    7373        int numberOfAlarms(const QModelIndex &index) const;
     74        bool hasTimeConflict(const QModelIndex &index, const QModelIndex &parent) const;
    7475
    7576    private:
Note: See TracChangeset for help on using the changeset viewer.