#include <QPainter>
#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 );
}
// draw meetings
- QBrush brush( ScheduleWidget::sBusyBackground );
- painter.setBrush( brush );
painter.setRenderHint( QPainter::Antialiasing );
painter.setPen( ScheduleWidget::sFrameColor );
populateMeetingList();
{
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 );
}
}
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();
ScheduleWidget::~ScheduleWidget()
{
- delete iScheduleTable;
+ if ( iScheduleTable )
+ {
+ delete iScheduleTable;
+ iScheduleTable = 0;
+ }
}
QDate ScheduleWidget::beginningOfShownWeek()
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 ) )
{
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 )
// 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 );
}