// create application clock
iClock = new Clock;
- connect( iClock, SIGNAL( tick( QDateTime ) ), this, SLOT( checkStatusOfAllRooms() ) );
+ connect( iClock, SIGNAL( tick( QDateTime ) ), this, SLOT( tick( QDateTime )/*checkStatusOfAllRooms()*/ ) );
// connect( iClock, SIGNAL( tick( QDateTime ) ), iWindowManager, SLOT( distributeDateTimeInfo( QDateTime ) ) );
// Create auto refresh timer
void Engine::checkStatusOfAllRooms()
{
-// qDebug() << "Engine::checkStatusOfAllRooms()";
+ // TODO: Check if date has changed
+ // qDebug() << "Engine::checkStatusOfAllRooms()";
// iterate trough on the rooms
for (int i = 0; i < iConfiguration->rooms().count(); i++)
{
// and check the status
- roomStatusInfoNeeded(iConfiguration->rooms().at(i) );
+ roomStatusInfoNeeded( iConfiguration->rooms().at(i) );
}
}
// ...if there is meeting following on the same day then check end time, otherwise end is the of the working day
( ( indexOfNextMeeting != -1 ) ? iMeetings.at( indexOfNextMeeting )->startsAt().time() : Engine::endOfTheDay );
- //currently works only for deafult room
+ //currently works only for default room
if ( aRoom->equals( *(iCurrentRoom) ) )
{
emit roomStatusChanged( status, until );
for ( int i = 0; i < iMeetings.count(); ++i )
{
+ // TODO: Check if these are current week's meetings and do not overwrite those
Meeting* m = iMeetings.takeAt( i );
delete m;
}
}
}
-void Engine::fetchMeetings( const QDateTime &aFrom, const QDateTime &aUntil, const Room *aIn )
+void Engine::fetchMeetings( const int aWeek, const int aYear, const Room *aIn )
{
qDebug()
- << "Engine::fetchMeetings( const QDateTime &, const QDateTime &, const Room * )";
- iCommunication->fetchMeetings(aFrom, aUntil, *aIn);
+ << "Engine::fetchMeetings( const int aWeek, const int aYear, const Room * )";
+ iCommunication->fetchMeetings(aWeek, aYear, *aIn);
}
void Engine::cancelFetchMeetingDetails()
void Engine::shownWeekChanged( QDate aFrom )
{
qDebug() << "[Engine::shownWeekChanged] <Invoked>";
- QDateTime from( aFrom );
- QDateTime to( aFrom.addDays( 7 ), QTime( 23, 59 ) );
- qDebug() << "[Engine::shownWeekChanged] <From " << aFrom.toString( "d.m. h:mm" ) << " to " << to.toString( "d.m. h:mm" ) << ">";
- iCommunication->fetchMeetings( from, to, *iCurrentRoom/*defaultRoom()*/ );
+ iCommunication->fetchMeetings( aFrom.weekNumber(), aFrom.year(), *iCurrentRoom/*defaultRoom()*/ );
}
void Engine::changeDeviceMode()
qDebug() << "[Engine::currentRoomChanged] <invoked>";
iCurrentRoom = aRoom;
roomStatusInfoNeeded( iCurrentRoom );
+}
+
+void Engine::tick( QDateTime aCurrentDateTime )
+{
+ // Called once every second
+ checkStatusOfAllRooms();
+ if( aCurrentDateTime.date() != iCurrentDate)
+ {
+ // Check if week has changed and fetch meetings for this week
+ if( aCurrentDateTime.date().weekNumber() != iCurrentDate.weekNumber()
+ || aCurrentDateTime.date().year() != iCurrentDate.year() )
+ {
+ qDebug() << "[Engine::tick] detected week change, fetching meetings";
+ fetchMeetings( aCurrentDateTime.date().weekNumber(), aCurrentDateTime.date().year(), iCurrentRoom );
+ }
+ }
+ iCurrentDate = aCurrentDateTime.date();
}
\ No newline at end of file