X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2FUserInterface%2FComponents%2FScheduleWidget.cpp;fp=src%2FUserInterface%2FComponents%2FScheduleWidget.cpp;h=181593e358ebc6500a5dc62a8c93cb0c4b0c77e7;hb=6a31f3484996e9b7e719954c3a64a56d3fa586aa;hp=0d68da6073c49085e179d8ecd33c9298505d7d47;hpb=59b4a9d85f3cd02e90c8efcecc66f9150f8a61f8;p=qtmeetings diff --git a/src/UserInterface/Components/ScheduleWidget.cpp b/src/UserInterface/Components/ScheduleWidget.cpp index 0d68da6..181593e 100644 --- a/src/UserInterface/Components/ScheduleWidget.cpp +++ b/src/UserInterface/Components/ScheduleWidget.cpp @@ -9,11 +9,14 @@ #include #include "Meeting.h" -const QColor ScheduleWidget::sFreeBackground = QColor( 192, 238, 189 ); +const QColor ScheduleWidget::sFreeBackground = QColor( Qt::white ); const QColor ScheduleWidget::sBusyBackground = QColor( 238, 147, 17 ); +const QColor ScheduleWidget::sBusyBackgroundStart = QColor( 254, 193, 104 ); +const QColor ScheduleWidget::sCurrentBackgroundStart = QColor( 237, 124, 125 ); +const QColor ScheduleWidget::sCurrentBackground = QColor( 161, 1, 1 ); const QColor ScheduleWidget::sHeaderBackground = QColor( Qt::white ); const QColor ScheduleWidget::sDayHighlightColor = QColor( 255, 235, 160 ); -const QColor ScheduleWidget::sTimeHighlightColor = QColor( Qt::blue ); +const QColor ScheduleWidget::sTimeHighlightColor = QColor( Qt::black ); const QColor ScheduleWidget::sMainGridColor = QColor( 140, 140, 140 ); const QColor ScheduleWidget::sHalfGridColor = QColor( 195, 195, 195 ); const QColor ScheduleWidget::sFrameColor = QColor( Qt::black ); @@ -94,8 +97,6 @@ void ScheduleTableWidget::paintEvent( QPaintEvent* aEvent ) } // draw meetings - QBrush brush( ScheduleWidget::sBusyBackground ); - painter.setBrush( brush ); painter.setRenderHint( QPainter::Antialiasing ); painter.setPen( ScheduleWidget::sFrameColor ); populateMeetingList(); @@ -104,6 +105,21 @@ void ScheduleTableWidget::paintEvent( QPaintEvent* aEvent ) { for ( int i = 0; i < iMeetingsByDay[day].size(); ++i ) { + QLinearGradient linearGrad( QPoint(iMeetingsByDay[day][i].rect.x(),iMeetingsByDay[day][i].rect.y()) , QPoint(iMeetingsByDay[day][i].rect.x(),iMeetingsByDay[day][i].rect.bottom()) ); + // draw meeting with red if it is ongoing + if ( iMeetingsByDay[day][i].meeting->startsAt() <= QDateTime::currentDateTime() && + iMeetingsByDay[day][i].meeting->endsAt() >= QDateTime::currentDateTime() ) + { + linearGrad.setColorAt(0, ScheduleWidget::sCurrentBackgroundStart); + linearGrad.setColorAt(1, ScheduleWidget::sCurrentBackground); + } + else + { + linearGrad.setColorAt(0, ScheduleWidget::sBusyBackgroundStart); + linearGrad.setColorAt(1, ScheduleWidget::sBusyBackground); + } + painter.setBrush(linearGrad); + painter.drawRoundRect( iMeetingsByDay[day][i].rect, 20, 20 ); } } @@ -295,7 +311,9 @@ ScheduleWidget::ScheduleWidget( QDateTime aCurrentDateTime, DisplaySettings *aSe iScheduleTable->setShowGrid( false ); QFont font; - font.setPointSize( 10 ); + font.setStyleHint( QFont::Helvetica ); + font.setBold( true ); + font.setPixelSize( 20 ); // add empty item to top-left corner, this will be updated in refresh() QTableWidgetItem *weekItem = new QTableWidgetItem(); @@ -346,7 +364,11 @@ ScheduleWidget::ScheduleWidget( QDateTime aCurrentDateTime, DisplaySettings *aSe ScheduleWidget::~ScheduleWidget() { - delete iScheduleTable; + if ( iScheduleTable ) + { + delete iScheduleTable; + iScheduleTable = 0; + } } QDate ScheduleWidget::beginningOfShownWeek() @@ -366,7 +388,7 @@ void ScheduleWidget::refresh() item->setText( tr( "Wk %1" ).arg( iShownDate.weekNumber() ) ); continue; } - item->setText( iShownDate.addDays( i - 1 ).toString( tr( "ddd d MMM" ) ) ); + item->setText( iShownDate.addDays( i - 1 ).toString( tr( "ddd d/M" ) ) ); if ( iCurrentDateTime.date() == iShownDate.addDays( i - 1 ) ) { @@ -446,10 +468,10 @@ int ScheduleWidget::weekLengthAsDays() void ScheduleWidget::resizeEvent( QResizeEvent* /* aEvent */ ) { QRect rect = iScheduleTable->contentsRect(); - int rowHeight = ( int )( rect.height() / ( float )iScheduleTable->rowCount() ); - int headerRowHeight = rowHeight; - int columnWidth = ( int )( rect.width() / ( iScheduleTable->columnCount() - 0.5f ) ); - int headerColumnWidth = columnWidth / 2; + int rowHeight = ( int )( rect.height() / ( float )( iScheduleTable->rowCount() + 1 ) ); + int headerRowHeight = ( int )rowHeight*2; + int headerColumnWidth = rect.width() * 0.15f; + int columnWidth = ( rect.width() - headerColumnWidth ) / ( iScheduleTable->columnCount() - 1 ); iScheduleTable->setRowHeight( 0, headerRowHeight ); for ( int i = 1; i < iScheduleTable->rowCount(); ++i ) @@ -466,6 +488,7 @@ void ScheduleWidget::resizeEvent( QResizeEvent* /* aEvent */ ) // resize table so that frame size matches exactly int leftMargin = 0, topMargin = 0, rightMargin = 0, bottomMargin = 0; iScheduleTable->getContentsMargins( &leftMargin, &topMargin, &rightMargin, &bottomMargin ); - iScheduleTable->resize( columnWidth * iScheduleTable->columnCount() - headerColumnWidth + leftMargin + rightMargin, - rowHeight * iScheduleTable->rowCount() + topMargin + bottomMargin ); + iScheduleTable->resize( columnWidth * ( iScheduleTable->columnCount() - 1 ) + + headerColumnWidth + leftMargin + rightMargin, + rowHeight * ( iScheduleTable->rowCount() + 1 ) + topMargin + bottomMargin ); }