+
+void Engine::initUserInterface()
+{
+ qDebug() << "[Engine::initUserInterface] <Invoked>";
+ // Initialize the window manager and connect what ever signals can be connected
+ iWindowManager = new WindowManager;
+ connect( iWindowManager, SIGNAL( eventDetected() ), this, SLOT( handleViewEvent() ) );
+ connect( iWindowManager, SIGNAL( previousViewRestored() ), this, SLOT( previousViewRestored() ) );
+ connect( iWindowManager, SIGNAL( dialogActivated() ), this, SLOT( dialogActivated() ) );
+ connect( iWindowManager, SIGNAL( dialogDeactivated() ), this, SLOT( dialogDeactivated() ) );
+
+ // Initialize the weekly view and connect what ever signals can be connected at this stage
+ iWeeklyView = new WeeklyViewWidget(QDateTime::currentDateTime(), iConfiguration);
+ connect( iWeeklyView, SIGNAL( settingsButtonClicked() ), this, SLOT( settingsViewRequested() ) );
+ connect( iWeeklyView, SIGNAL( currentRoomChange( Room * ) ) , this, SLOT( currentRoomChange( Room * ) ) );
+ connect( iWeeklyView, SIGNAL( meetingActivated( Meeting * ) ), this, SLOT( fetchMeetingDetails( Meeting * ) ) ) ;
+ connect( iWeeklyView, SIGNAL( shownWeekChanged( QDate ) ) , this, SLOT( shownWeekChanged( QDate ) ) );
+
+ // Initialize the settings view
+ iSettingsView = new SettingsView;
+ connect( iSettingsView, SIGNAL( okClicked() ) , this, SLOT( settingsOkClicked() ) );
+
+ // Initialize the room status indicator
+ iRoomStatusIndicator = new RoomStatusIndicatorWidget( defaultRoom(), Room::FreeStatus, QTime::currentTime(), iConfiguration->displaySettings()->dateFormat() );
+
+ // Create password dialog
+ iPasswordDialog = new PasswordDialog( iConfiguration->adminPassword(), tr("No Text Set"), tr("Title") );
+ connect( iPasswordDialog, SIGNAL( passwordEntered( PasswordDialog::PasswordStatus ) ), this, SLOT( passwordEntered( PasswordDialog::PasswordStatus ) ) );
+
+ // Show the UI
+ iWindowManager->setWindowState( Qt::WindowMaximized );
+ iWindowManager->show();
+ iWindowManager->showView( iWeeklyView );
+
+ qDebug() << "[Engine::initUserInterface] <Finished>";
+}
+
+void Engine::settingsViewRequested()
+{
+ if ( iSettingsView != 0 )
+ {
+ iWindowManager->showView( static_cast<ViewBase *>( iSettingsView ) );
+ // Room status indicator will not be shown when settings view is active
+ iIdleTimeCounter->stop();
+ }
+}
+
+void Engine::handleViewEvent()
+{
+ qDebug() << "[Engine::handleViewEvent] <Invoked>";
+ if ( iIdleTimeCounter != 0 )
+ {
+ // Restart the idle time counter when view event is received
+ iIdleTimeCounter->stop();
+ iIdleTimeCounter->start();
+ }
+}
+
+void Engine::initConfiguration()
+{
+ iConfiguration = Configuration::instance();
+ if ( iConfiguration == 0 )
+ {
+ QTimer::singleShot( 0, this, SLOT( closeApplication() ) );
+ }
+}
+
+void Engine::idleTimerTimeout()
+{
+ if ( iRoomStatusIndicator != 0 )
+ {
+ iWindowManager->showView( static_cast<ViewBase *>( iRoomStatusIndicator ) );
+ }
+}
+
+void Engine::settingsOkClicked()
+{
+ if ( iWeeklyView != 0 )
+ {
+ iWindowManager->showView( iWeeklyView );
+ // Start the idle time counter when we return to the main view
+ iIdleTimeCounter->start();
+ }
+}
+
+void Engine::connectSignals()
+{
+ // Handle weekly view signal connections
+ connect( iClock, SIGNAL( tick( QDateTime ) ), iWeeklyView, SLOT( setCurrentDateTime( QDateTime ) ) );
+}
+
+void Engine::initCommunication()
+{
+ // initialize communication
+ iCommunication = new CommunicationManager( *(iConfiguration->connectionSettings()) );
+ connect( iCommunication, SIGNAL( error( int, CommunicationManager::CommunicationType ) ),
+ this, SLOT( errorHandler( int ) ) );
+ connect( iCommunication, SIGNAL( meetingsFetched( const QList<Meeting*>& ) ),
+ this, SLOT( meetingsFetched( const QList<Meeting*>& ) ) );
+ connect( iCommunication, SIGNAL( meetingDetailsFetched( Meeting& ) ),
+ this, SLOT( meetingDetailsFetched( Meeting& ) ) );
+}
+
+void Engine::initDevice()
+{
+ // create device manager
+ iDevice = new DeviceManager( iConfiguration->startupSettings() );
+ connect( iDevice, SIGNAL( error( int, const QString& ) ), this, SLOT( errorHandler( int, const QString& ) ) );
+ connect( iDevice, SIGNAL( changeModeOrdered( DeviceManager::OperationMode ) ),
+ this, SLOT( changeModeOrdered( DeviceManager::OperationMode ) ) );
+ iDevice->initDeviceManager();
+}
+
+void Engine::dialogActivated()
+{
+ if ( iIdleTimeCounter != 0 )
+ {
+ iIdleTimeCounter->stop();
+ }
+}
+
+void Engine::dialogDeactivated()
+{
+ if ( iIdleTimeCounter != 0 )
+ {
+ iIdleTimeCounter->start();
+ }
+}
+
+void Engine::previousViewRestored()
+{
+ if ( iIdleTimeCounter != 0 )
+ {
+ iIdleTimeCounter->start();
+ }
+}
\ No newline at end of file