X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2FBusinessLogic%2FEngine.cpp;h=5245702fe876140b4304311e919b5244995e844d;hb=4f5e48bd4a1e5ab05cd5f0d46c3e335731bb05ff;hp=0c7667994e48793776c0fbeafbef7aadcadee1f2;hpb=f51d61d96002d4b5ad5d52699c6d52a4dea07159;p=qtmeetings diff --git a/src/BusinessLogic/Engine.cpp b/src/BusinessLogic/Engine.cpp index 0c76679..5245702 100644 --- a/src/BusinessLogic/Engine.cpp +++ b/src/BusinessLogic/Engine.cpp @@ -8,11 +8,7 @@ // #include "DeviceManager.h" #include "Clock.h" #include "ErrorMapper.h" -#include "WeeklyViewWidget.h" -#include "SettingsView.h" -#include "RoomStatusIndicatorWidget.h" -#include "PasswordDialog.h" -#include "MeetingInfoDialog.h" +#include "UIManager.h" #include #include @@ -47,19 +43,18 @@ Engine::Engine() : // iIdleTimeCounter->setInterval( IDLE_TIME_MULTIPLIER * iConfiguration->displaySettings()->screensaver() ); iIdleTimeCounter->setInterval( 10000 ); iIdleTimeCounter->start(); - // connect( iIdleTimeCounter, SIGNAL( timeout() ), iWindowManager, SLOT( showRoomStatus() ) ); - connect( iIdleTimeCounter, SIGNAL( timeout() ), this, SLOT( idleTimerTimeout() ) ); // create application clock iClock = new Clock; connect( iClock, SIGNAL( tick( QDateTime ) ), this, SLOT( checkStatusOfAllRooms() ) ); // connect( iClock, SIGNAL( tick( QDateTime ) ), iWindowManager, SLOT( distributeDateTimeInfo( QDateTime ) ) ); + // Create auto refresh timer iAutoRefresh = new QTimer; iAutoRefresh->setInterval( iConfiguration->connectionSettings()->refreshInterval() * 1000 ); iAutoRefresh->start(); connect( iAutoRefresh, SIGNAL( timeout() ), iAutoRefresh, SLOT( start() ) ); -// connect( iAutoRefresh, SIGNAL( timeout() ), this, SLOT( fetchMeetings() ) ); + connect( iAutoRefresh, SIGNAL( timeout() ), this, SLOT( fetchMeetings() ) ); if( iDevice->currentOperationMode() == DeviceManager::KioskMode ) { @@ -87,11 +82,8 @@ Engine::~Engine() } QT_DELETE( iClock ); QT_DELETE( iDevice ); - - QT_DELETE( iRoomStatusIndicator ); - QT_DELETE( iSettingsView ); - QT_DELETE( iWeeklyView ); - QT_DELETE( iPasswordDialog ); + + QT_DELETE( iUIManager ); QT_DELETE( iWindowManager ); } @@ -191,13 +183,13 @@ void Engine::fetchMeetings() void Engine::fetchMeetingDetails( Meeting *aMeeting ) { qDebug() << "Engine::fetchMeetingDetails( Meeting* )"; - iWindowManager->showProgressBar( tr("Please Wait"), true ); - iWindowManager->updateProgressBar( tr("Fetching Meeting Details...") ); - connect( iWindowManager, +// iWindowManager->showProgressBar( tr("Please Wait"), true ); +// iWindowManager->updateProgressBar( tr("Fetching Meeting Details...") ); +/* connect( iWindowManager, SIGNAL( progressBarCancelled() ), this, SLOT( fetchMeetingDetailsCancelled() ) - ); + ); */ iCommunication->fetchMeetingDetails( *aMeeting ); } @@ -227,7 +219,7 @@ void Engine::meetingsFetched( const QList &aMeetings ) Meeting* m = new Meeting( *(aMeetings.at( i )) ); iMeetings.append( m ); // and signal the changes - iWeeklyView->insertMeeting( m ); +// iWeeklyView->insertMeeting( m ); } } @@ -239,7 +231,7 @@ void Engine::meetingsFetched( const QList &aMeetings ) { Meeting* m = iMeetings.takeAt( i ); // signal the changes - iWeeklyView->deleteMeeting( m ); +// iWeeklyView->deleteMeeting( m ); // delete the meeting from the local list delete m; } @@ -249,18 +241,6 @@ void Engine::meetingsFetched( const QList &aMeetings ) roomStatusInfoNeeded( defaultRoom() ); } -void Engine::meetingDetailsFetched( Meeting &aDetailedMeeting ) -{ - qDebug() << "Engine::meetingDetailsFetched( Meeting & )"; - - if ( iMeetingInfoDialog != 0 ) - { - iMeetingInfoDialog->setMeeting( &aDetailedMeeting ); - iWindowManager->showDialog( iMeetingInfoDialog ); - } - -} - void Engine::errorHandler( int aCode, const QString &aAddInfo ) { qDebug() << "Engine::ErrorHandler, aCode: " << aCode; @@ -271,14 +251,6 @@ void Engine::errorHandler( int aCode, const QString &aAddInfo ) // iWindowManager->error( ErrorMapper::codeToString( aCode, aAddInfo ) ); } -void Engine::currentRoomChanged( Room *aCurrentRoom ) -{ - qDebug() << "Engine::currentRoomChanged to " << aCurrentRoom->name(); -// QDateTime from( iWindowManager->weeklyView()->beginnigOfShownWeek() ); -// QDateTime to( from.addDays( 8 ) ); -// fetchMeetings( from, to, aCurrentRoom ); -} - void Engine::fetchMeetings( const QDateTime &aFrom, const QDateTime &aUntil, const Room *aIn ) { qDebug() << "Engine::fetchMeetings( const QDateTime &, const QDateTime &, const Room * )"; @@ -294,16 +266,6 @@ void Engine::shownWeekChanged( QDate aFrom ) // fetchMeetings( from, to, iWindowManager->weeklyView()->currentRoom() ); } -void Engine::changeModeOrdered( DeviceManager::OperationMode aMode ) -{ - qDebug() << "Engine::changeModeOrdered( DeviceManager::OperationMode )"; - QString message = tr( "You are about to change operation mode to %1." ) - .arg( iDevice->operationModeToString( aMode ) ); - - // iPasswordDialog->update( message ); - iWindowManager->showDialog( static_cast( iPasswordDialog ) ); -} - void Engine::passwordEntered( PasswordDialog::PasswordStatus aPasswordStatus ) { qDebug() << "Engine::passwordEntered( PasswordDialog::PasswordStatus )"; @@ -313,13 +275,6 @@ void Engine::passwordEntered( PasswordDialog::PasswordStatus aPasswordStatus ) { case PasswordDialog::Correct : { -// iWindowManager->showProgressBar( "Changing current operation mode." ); -// connect( iWindowManager, SIGNAL( progressBarCancelled() ), this, SLOT( progressBarCancelled() ) ); -// connect( iDevice, SIGNAL( changingMode( const QString & ) ), -// iWindowManager, SLOT( updateProgressBar( const QString & ) ) ); - // TODO : Connect the signal directory to progress bar dialog which should be instance in engine -// connect( iDevice, SIGNAL( changingMode( const QString & ) ), -// iWindowManager, SLOT( updateProgressBar( const QString & ) ) ); connect( iDevice, SIGNAL( changingModeFailed() ), this, SLOT( progressBarCancelled() ) ); iDevice->changeMode( true ); break; @@ -340,60 +295,33 @@ void Engine::passwordEntered( PasswordDialog::PasswordStatus aPasswordStatus ) void Engine::progressBarCancelled() { qDebug() << "Engine::progressBarCancelled()"; - //TODO: cancel the on-going event -// iWindowManager->closeProgressBar(); iDevice->changeMode( false ); } void Engine::initUserInterface() { qDebug() << "[Engine::initUserInterface] "; + // Initialize the window manager and connect what ever signals can be connected iWindowManager = new WindowManager; + // Create the UIManager which internally handles most of the UI actions + iUIManager = new UIManager( this, iWindowManager ); + connect( iWindowManager, SIGNAL( eventDetected() ), this, SLOT( handleViewEvent() ) ); - connect( iWindowManager, SIGNAL( previousViewRestored() ), this, SLOT( previousViewRestored() ) ); + connect( iWindowManager, SIGNAL( previousViewRestored() ), iUIManager, 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 ); + iUIManager->showMainView(); qDebug() << "[Engine::initUserInterface] "; } -void Engine::settingsViewRequested() -{ - if ( iSettingsView != 0 ) - { - iWindowManager->showView( static_cast( iSettingsView ) ); - // Room status indicator will not be shown when settings view is active - iIdleTimeCounter->stop(); - } -} - void Engine::handleViewEvent() { - qDebug() << "[Engine::handleViewEvent] "; if ( iIdleTimeCounter != 0 ) { // Restart the idle time counter when view event is received @@ -411,28 +339,14 @@ void Engine::initConfiguration() } } -void Engine::idleTimerTimeout() -{ - if ( iRoomStatusIndicator != 0 ) - { - iWindowManager->showView( static_cast( 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 ) ) ); + // Connect engine objects signals to UIManager + connect( iClock, SIGNAL( tick( QDateTime ) ), iUIManager, SLOT( updateTime( QDateTime ) ) ); + connect( iIdleTimeCounter, SIGNAL( timeout() ) , iUIManager, SLOT( roomStatusIndicatorRequested() ) ); + + iUIManager->connectDeviceManager( iDevice ); + iUIManager->connectCommunicationManager( iCommunication ); } void Engine::initCommunication() @@ -443,8 +357,6 @@ void Engine::initCommunication() this, SLOT( errorHandler( int ) ) ); connect( iCommunication, SIGNAL( meetingsFetched( const QList& ) ), this, SLOT( meetingsFetched( const QList& ) ) ); - connect( iCommunication, SIGNAL( meetingDetailsFetched( Meeting& ) ), - this, SLOT( meetingDetailsFetched( Meeting& ) ) ); } void Engine::initDevice() @@ -452,8 +364,6 @@ 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(); } @@ -484,5 +394,21 @@ void Engine::previousViewRestored() void Engine::fetchMeetingDetailsCancelled() { iCommunication->cancelFetchMeetingDetails(); - iWindowManager->closeProgressBar(); +// iWindowManager->closeProgressBar(); +} + +void Engine::stopIdleTimeCounter() +{ + if ( iIdleTimeCounter != 0 ) + { + iIdleTimeCounter->stop(); + } +} + +void Engine::startIdleTimeCounter() +{ + if ( iIdleTimeCounter != 0 ) + { + iIdleTimeCounter->start(); + } }