#include "Configuration.h"
#include "DisplaySettings.h"
#include "CommunicationManager.h"
- #include "DeviceManager.h"
+ // #include "DeviceManager.h"
#include "Clock.h"
#include "ErrorMapper.h"
- #include "WeeklyViewWidget.h"
+ #include "UIManager.h"
#include <QApplication>
#include <QTimer>
QTime Engine::endOfTheDay = QTime( 23, 59, 0, 0); // end of the day is 11:59pm
const int IDLE_TIME_MULTIPLIER = 60000; // Multiplies milliseconds to minutes
+ // Macro to help deleting objects. This could be global.
+ #define QT_DELETE(X) \
+ if ( X != 0 ) \
+ { \
+ delete X; \
+ X = 0; \
+ }
+
+
Engine::Engine() :
- iClock( 0), iConfiguration(Configuration::instance() ), iCommunication( 0)
+ iClock( 0 ), iConfiguration( 0 ), iCommunication( 0 ),
+ iWindowManager( 0 ), iUIManager( 0 )
{
qDebug() << "Engine::Engine()";
+ iCommunicationFailed = false;
- // if reading of configuration fails, signal that initialization failed
- if (iConfiguration == 0)
- {
- QTimer::singleShot( 0, this, SLOT( closeApplication() ));
- return;
- }
-
- //initialize window manager
- iWindowManager = new WindowManager( iConfiguration );
- connect(iWindowManager, SIGNAL( roomStatusInfoNeeded( Room * ) ), this, SLOT( roomStatusInfoNeeded( Room * ) ));
- connect(iWindowManager, SIGNAL( observedEventDetected() ), this, SLOT( observedEventDetected() ));
- connect(iWindowManager, SIGNAL( meetingActivated( Meeting * ) ), this, SLOT( fetchMeetingDetails( Meeting * ) ));
- connect(iWindowManager, SIGNAL( currentRoomChanged( Room * ) ), this, SLOT( currentRoomChanged( Room * ) ));
- connect(iWindowManager, SIGNAL( shownWeekChanged( QDate ) ), this, SLOT( shownWeekChanged( QDate ) ));
- connect(iWindowManager, SIGNAL( passwordEntered( PasswordDialog::PasswordStatus ) ), this, SLOT( passwordEntered( PasswordDialog::PasswordStatus ) ));
-
- // 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& ) ));
-
+
+ initConfiguration();
+ initDevice();
+ initCommunication();
+ initUserInterface();
+
//initialize idle time counter
iIdleTimeCounter = new QTimer();
iIdleTimeCounter->setSingleShot( true);
- iIdleTimeCounter->setInterval(IDLE_TIME_MULTIPLIER
- * iConfiguration->displaySettings()->screensaver() );
+ iIdleTimeCounter->setInterval(IDLE_TIME_MULTIPLIER * iConfiguration->displaySettings()->screensaver() );
iIdleTimeCounter->start();
// create application clock
iClock = new Clock;
- connect(iClock, SIGNAL( tick( QDateTime ) ), this, SLOT( checkStatusOfAllRooms() ));
- connect(iClock, SIGNAL( tick( QDateTime ) ), iWindowManager, SLOT( distributeDateTimeInfo( QDateTime ) ));
+ 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() ));
-
- // 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();
-
- if (iDevice->currentOperationMode() == DeviceManager::KioskMode)
- iWindowManager->fullScreen();
+ connect( iAutoRefresh, SIGNAL( timeout() ), iAutoRefresh, SLOT( start() ) );
+ // connect( iAutoRefresh, SIGNAL( timeout() ), this, SLOT( fetchMeetings() ) );
+
+ if( iDevice->currentOperationMode() == DeviceManager::KioskMode )
+ {
+ iWindowManager->setFullscreen();
+ }
- QTimer::singleShot( 0, this, SLOT( fetchMeetings() ));
+ connectSignals();
+
+ // QTimer::singleShot( 0, this, SLOT( fetchMeetings() ) );
// TODO: continue implementation
}
qDebug() << "Engine::~Engine()";
while ( !iMeetings.isEmpty() )
delete iMeetings.takeFirst();
- iIdleTimeCounter->stop();
- delete iIdleTimeCounter;
- iIdleTimeCounter = 0;
- delete iWindowManager;
- iWindowManager = 0;
- delete iClock;
- iClock = 0;
- delete iDevice;
- iDevice = 0;
+
+ if ( iIdleTimeCounter != 0 )
+ {
+ iIdleTimeCounter->stop();
+ delete iIdleTimeCounter;
+ iIdleTimeCounter = 0;
+ }
+ QT_DELETE( iClock );
+ QT_DELETE( iDevice );
+
+ QT_DELETE( iUIManager );
+ QT_DELETE( iWindowManager );
}
void Engine::closeApplication()
QTimer::singleShot( 1000, QApplication::instance(), SLOT( quit() ));
}
- void Engine::observedEventDetected()
- {
- qDebug() << "Engine::observedEventDetected()";
- if ( !iIdleTimeCounter->isActive() )
- {
- iWindowManager->weeklyView()->showCurrentWeek();
- }
- iWindowManager->showWeeklyView();
- // prepare to restart idle counter
- if (iIdleTimeCounter->isActive() )
- {
- iIdleTimeCounter->stop();
- }
- // (re)start idle counter
- iIdleTimeCounter->start();
- }
-
Room* Engine::defaultRoom()
{
qDebug() << "Engine::defaultRoom()";
void Engine::checkStatusOfAllRooms()
{
- qDebug() << "Engine::checkStatusOfAllRooms()";
+ // qDebug() << "Engine::checkStatusOfAllRooms()";
// iterate trough on the rooms
for (int i = 0; i < iConfiguration->rooms().count(); i++)
{
int Engine::indexOfMeetingAt(Room *aRoom, QDateTime aAt)
{
- qDebug() << "Engine::indexOfMeetingAt( Room *, QDateTime )";
- for (int i = 0; i < iMeetings.count(); i++)
+ // qDebug() << "Engine::indexOfMeetingAt( Room *, QDateTime )";
+ for ( int i = 0; i < iMeetings.count(); i++ )
{
// exchange server ensures that there is only one meeting in a room at a specified time
if (aRoom->equals(iMeetings.at( i )->room() ) && iMeetings.at( i )->startsAt() <= aAt && iMeetings.at( i )->endsAt() >= aAt)
int Engine::indexOfMeetingAfter(Room *aRoom, QDateTime aAfter)
{
- qDebug() << "Engine::indexOfMeetingAfter( Room *, QDateTime )";
+ // qDebug() << "Engine::indexOfMeetingAfter( Room *, QDateTime )";
// seeks for the next meeting on the SAME DAY
int min = -1;
for (int i = 0; i < iMeetings.count(); i++)
void Engine::roomStatusInfoNeeded(Room *aRoom)
{
- qDebug() << "Engine::roomStatusInfoNeeded( Room * )";
- if (aRoom == 0)
+ // qDebug() << "Engine::roomStatusInfoNeeded( Room * )";
+ if ( aRoom == 0 )
{
return;
}
int indexOfNextMeeting = indexOfMeetingAfter(aRoom, iClock->datetime() );
// if there is no meeting, then status is Free; otherwise Busy
- Room::Status
- status =
- (indexOfCurrentMeeting == -1 ) ? Room::FreeStatus : Room::BusyStatus;
+ Room::Status status = (indexOfCurrentMeeting == -1 ) ? Room::FreeStatus : Room::BusyStatus;
// if room is Busy, then check end time, otherwise...
QTime until = (status == Room::BusyStatus ) ? iMeetings.at( indexOfCurrentMeeting )->endsAt().time() :
// ...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 );
+ ( ( indexOfNextMeeting != -1 ) ? iMeetings.at( indexOfNextMeeting )->startsAt().time() : Engine::endOfTheDay );
//currently works only for deafult room
- if (aRoom->equals( *(defaultRoom() )) )
- iWindowManager->roomStatusChanged(aRoom, status, until);
+ // if( aRoom->equals( *(defaultRoom() ) ) )
+ // iWindowManager->roomStatusChanged( aRoom, status, until );
}
+ /*
void Engine::fetchMeetings()
{
- Room *room = defaultRoom();
- qDebug() << "Engine::fetchMeetings for " << room->name();
- fetchMeetings(iClock->datetime(), iClock->datetime().addDays( 7), room);
+ qDebug() << "Engine::fetchMeetings for " << iCurrentRoom;
+ QDateTime from( iWindowManager->weeklyView()->beginnigOfShownWeek() );
+ QDateTime to( from.addDays( 7 ) );
+ // fetchMeetings( from, to, iWindowManager->weeklyView()->currentRoom() );
+ // Signal is connected to the currentRoomChanged slot which keeps the iCurrentRoom up to date
+ fetchMeetings( from, to, iCurrentRoom );
}
+ */
- void Engine::fetchMeetingDetails(Meeting *aMeeting)
+ void Engine::fetchMeetingDetails( Meeting *aMeeting )
{
qDebug() << "Engine::fetchMeetingDetails( Meeting* )";
- iWindowManager->showProgressBar(tr("Please Wait"), true);
+ /* iWindowManager->showProgressBar(tr("Please Wait"), true);
iWindowManager->updateProgressBar(tr("Fetching Meeting Details...") );
connect(iWindowManager,
SIGNAL( progressBarCancelled() ), this,
SLOT( fetchMeetingDetailsCancelled() ));
- iCommunication->fetchMeetingDetails( *aMeeting);
+ iCommunication->fetchMeetingDetails( *aMeeting); */
+ iCommunication->fetchMeetingDetails( *aMeeting );
}
- bool Engine::isMeetingInList(const QList<Meeting*> &aList, const Meeting *aMeeting)
- {
- qDebug()
- << "Engine::isMeetingInList( const QList<Meeting*> &, const Meeting * )";
- for (int i = 0; i < aList.count(); i++)
- {
- if (aMeeting->equals( *(aList.at(i))) )
- {
- return true;
- }
- }
- return false;
- }
-
- void Engine::meetingsFetched(const QList<Meeting*> &aMeetings)
+ void Engine::meetingsFetched( const QList<Meeting*> &aMeetings )
{
qDebug() << "Engine::meetingsFetched( const QList<Meeting*> & )";
-
- for ( int i = 0; i < iMeetings.count(); ++i ) {
+ if( iCommunicationFailed )
+ {
+ iCommunicationFailed = false;
- //iWindowManager->connectionEstablished();
++ iWindowManager->connectionEstablished();
+ }
+
- // check if there is any new meeting in the list came from the server -> added
- for (int i = 0; i < aMeetings.count(); i++)
++ for ( int i = 0; i < iMeetings.count(); ++i )
+ {
- // if the (i)th meeting is not in the local meeting list
- if ( !isMeetingInList(iMeetings, aMeetings.at(i) ) )
- {
- // add to the local database =)
- Meeting* m = new Meeting( *(aMeetings.at( i )) );
- iMeetings.append(m);
- // and signal the changes
- iWindowManager->insertMeeting(m);
- }
+ Meeting* m = iMeetings.takeAt( i );
+ delete m;
+ }
+ iMeetings.clear();
+ for ( int i = 0; i < aMeetings.count(); ++i ) {
+ Meeting* m = new Meeting( *( aMeetings.at( i ) ) );
+ iMeetings.append( m );
}
- // check if there is any meeting NOT in the list came from the server -> deleted
- for (int i = 0; i < iMeetings.count(); i++)
+ // refresh room status info
+ roomStatusInfoNeeded( defaultRoom() );
+ }
+
+ void Engine::errorHandler( int aCode, const QString &aAddInfo )
+ {
++ if( aCode >= 100 && aCode < 150 )
+ {
- // if the (i)th meeting is in the local but NOT in the server's meeting list
- if ( !isMeetingInList(aMeetings, iMeetings.at(i) ) )
- {
- Meeting* m = iMeetings.takeAt(i);
- // signal the changes
- iWindowManager->deleteMeeting(m);
- // delete the meeting from the local list
- delete m;
- }
++ iCommunicationFailed = true;
++ //TODO: Call window manager
++ //if ( iWindowManager != 0 ) iWindowManager->connectionLost();
++ }
+ if ( iWindowManager != 0 )
+ {
+ iWindowManager->error( ErrorMapper::codeToString( aCode, aAddInfo ) );
}
+ }
- // refresh room status info
- roomStatusInfoNeeded(defaultRoom() );
+ void Engine::fetchMeetings( const QDateTime &aFrom, const QDateTime &aUntil, const Room *aIn )
+ {
+ qDebug()
+ << "Engine::fetchMeetings( const QDateTime &, const QDateTime &, const Room * )";
+ iCommunication->fetchMeetings(aFrom, aUntil, *aIn);
}
- void Engine::meetingDetailsFetched(Meeting &aDetailedMeeting)
+ void Engine::cancelFetchMeetingDetails()
{
- qDebug() << "Engine::meetingDetailsFetched( Meeting & )";
- iWindowManager->closeProgressBar();
- if( iCommunicationFailed )
+ iCommunication->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, *defaultRoom() );
+ // fetchMeetings( from, to, iWindowManager->weeklyView()->currentRoom() );
+ }
+
+ void Engine::changeDeviceMode( bool aChange )
+ {
+ if ( aChange )
++ }
{
- iCommunicationFailed = false;
- iWindowManager->connectionEstablished();
+ connect( iDevice, SIGNAL( changingModeFailed() ), this, SLOT( changeModeFailed() ) );
+ iAutoRefresh->stop(); // Stop the meeting update
}
- iWindowManager->showMeetingInfo( &aDetailedMeeting);
+ iDevice->changeMode( aChange );
}
- void Engine::errorHandler(int aCode, const QString &aAddInfo)
+ void Engine::changeModeFailed()
{
- qDebug() << "Engine::ErrorHandler, aCode: " << aCode;
- // inform UI about the problem
- if( aCode >= 100 && aCode <= 150 ) { //communication errors
+ qDebug() << "Engine::progressBarCancelled()";
+ iDevice->changeMode( false );
+ iAutoRefresh->start(); //we start the metting updating
+ }
+
+ void Engine::initUserInterface()
+ {
+ qDebug() << "[Engine::initUserInterface] <Invoked>";
+
+ // 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() ), iUIManager, SLOT( previousViewRestored() ) );
+ connect( iWindowManager, SIGNAL( dialogActivated() ), this, SLOT( dialogActivated() ) );
+ connect( iWindowManager, SIGNAL( dialogDeactivated() ), this, SLOT( dialogDeactivated() ) );
+
+ // Show the UI
+ iWindowManager->setWindowState( Qt::WindowMaximized );
+ iWindowManager->show();
+ iUIManager->showMainView();
+
+ qDebug() << "[Engine::initUserInterface] <Finished>";
+ }
+
+ void Engine::handleViewEvent()
+ {
+ if ( iIdleTimeCounter != 0 )
{
- //we don't want these to close operation changing
- qDebug() << "CommunicationManager signaled an error:" << aCode;
- if( !iCommunicationFailed )
- {
- // Only inform window manager when first error appears
- iCommunicationFailed = true;
- //iWindowManager->connectionLost();
- }
- }
- iWindowManager->closeProgressBar();
+ // Restart the idle time counter when view event is received
+ iIdleTimeCounter->stop();
+ iIdleTimeCounter->start();
}
- iWindowManager->error(ErrorMapper::codeToString(aCode, aAddInfo) );
}
- void Engine::currentRoomChanged(Room *aCurrentRoom)
+ void Engine::initConfiguration()
{
- qDebug() << "Engine::currentRoomChanged to " << aCurrentRoom->name();
- QDateTime from(iWindowManager->weeklyView()->beginnigOfShownWeek() );
- QDateTime to(from.addDays( 8) );
- fetchMeetings(from, to, aCurrentRoom);
+ iConfiguration = Configuration::instance();
+ if ( iConfiguration == 0 )
+ {
+ QTimer::singleShot( 0, this, SLOT( closeApplication() ) );
+ }
+ iCurrentRoom = iConfiguration->defaultRoom();
}
- void Engine::fetchMeetings(const QDateTime &aFrom, const QDateTime &aUntil, const Room *aIn)
+ void Engine::connectSignals()
{
- qDebug()
- << "Engine::fetchMeetings( const QDateTime &, const QDateTime &, const Room * )";
- iCommunication->fetchMeetings(aFrom, aUntil, *aIn);
+ // 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::shownWeekChanged(QDate aFrom)
+ void Engine::initCommunication()
{
- qDebug() << "Engine::shownWeekChanged( QDate )";
- QDateTime from(aFrom);
- QDateTime to(aFrom.addDays( 7), QTime( 23, 59) );
- qDebug() << "Engine::shownWeekChanged " << aFrom.toString("d.m. h:mm")
- << " to " << to.toString("d.m. h:mm");
- fetchMeetings(from, to, iWindowManager->weeklyView()->currentRoom() );
+ // 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*>& ) ) );
}
- void Engine::changeModeOrdered(DeviceManager::OperationMode aMode)
+ void Engine::initDevice()
{
- qDebug() << "Engine::changeModeOrdered( DeviceManager::OperationMode )";
- QString message = tr( "You are about to change operation mode to %1." )
- .arg(iDevice->operationModeToString(aMode) );
+ // create device manager
+ iDevice = new DeviceManager( iConfiguration->startupSettings() );
+ connect( iDevice, SIGNAL( error( int, const QString& ) ), this, SLOT( errorHandler( int, const QString& ) ) );
+ iDevice->initDeviceManager();
+ }
- iWindowManager->showPasswordDialog(iConfiguration->adminPassword(), message);
+ void Engine::dialogActivated()
+ {
+ if ( iIdleTimeCounter != 0 )
+ {
+ iIdleTimeCounter->stop();
+ }
}
- void Engine::passwordEntered(PasswordDialog::PasswordStatus aPasswordStatus)
+ void Engine::dialogDeactivated()
{
- qDebug() << "Engine::passwordEntered( PasswordDialog::PasswordStatus )";
- iWindowManager->closePasswordDialog();
+ if ( iIdleTimeCounter != 0 )
+ {
+ iIdleTimeCounter->start();
+ }
+ }
- switch (aPasswordStatus)
+ void Engine::previousViewRestored()
+ {
+ if ( iIdleTimeCounter != 0 )
{
- case PasswordDialog::Correct:
- {
- iAutoRefresh->stop(); //we stop the metting updating
- iWindowManager->showProgressBar( "Changing current operation mode." );
- connect(iDevice, SIGNAL( changingMode( const QString & ) ), iWindowManager, SLOT( updateProgressBar( const QString & ) ));
- connect( iDevice, SIGNAL( changingMode( const QString & ) ),
- iWindowManager, SLOT( updateProgressBar( const QString & ) ) );
- connect( iDevice, SIGNAL( changeModeFailed() ), this, SLOT( changeModeFailed() ) );
- iDevice->changeMode( true);
- break;
- }
- case PasswordDialog::Incorrect:
- {
- iWindowManager->error(tr("Incorrect password.") );
- iDevice->changeMode( false);
- break;
- }
- default: //case PasswordDialog::Canceled
- {
- iDevice->changeMode( false);
- }
+ iIdleTimeCounter->start();
}
}
- void Engine::changeModeFailed()
+ void Engine::stopIdleTimeCounter()
{
- qDebug() << "Engine::changeModeFailed()";
- iWindowManager->closeProgressBar();
- iAutoRefresh->start(); //we start the metting updating
+ if ( iIdleTimeCounter != 0 )
+ {
+ iIdleTimeCounter->stop();
+ }
}
- void Engine::fetchMeetingDetailsCancelled()
+ void Engine::startIdleTimeCounter()
{
- iCommunication->cancelFetchMeetingDetails();
- iWindowManager->closeProgressBar();
+ if ( iIdleTimeCounter != 0 )
+ {
+ iIdleTimeCounter->start();
+ }
}
+
+ void Engine::currentRoomChanged(Room *aRoom)
+ {
+ iCurrentRoom = aRoom;
+ }
#include <QDateTime>
#include "Room.h"
#include "WindowManager.h"
+ #include "DeviceManager.h"
+ #include "PasswordDialog.h"
class QTimer;
class Clock;
class Configuration;
class CommunicationManager;
class Meeting;
- class DeviceManager;
+ class UIManager;
//! BusinessLogic class. Contains all the business logic of the application.
/*!
signals:
- void meetingDetailsFetched( Meeting *aDetailedMeeting );
-
private slots:
//! Slot. Closes the application.
/*!
* \param aRoom The room which availability information is needed.
*/
void roomStatusInfoNeeded( Room *aRoom );
- //! Slot. Indicates that some user event has happened.
- /*!
- * Slot. Indicates that some user event has happened.
- */
- void observedEventDetected();
- //! Slot. Asks the communication to fetch new meeting data.
- /*!
- * Slot. Asks the communication to fetch new meeting data.
- * \param aCurrentRoom The current room.
- */
- void currentRoomChanged( Room *aCurrentRoom );
//! Slot. Asks the communication to fetch new meeting data.
/*!
* Slot. Asks the communication to fetch new meeting data.
* Slot. Fetches meetings from the server. Parameters are hard coded: the meetings of the default
* room from current and +/- 2 weeks are fetched.
*/
- void fetchMeetings();
+ // void fetchMeetings();
//! Slot. Saves fetched meetings to the current instance's local storage.
/*!
* Slot. Saves fetched meetings to the current instance's local storage. Meetings are soted in a
* \param aMeetings The list of freshly fetched meetings.
*/
void meetingsFetched( const QList<Meeting*>& );
-
- void meetingDetailsFetched( Meeting &aDetailedMeeting );
-
//! Slot. Checks the availability of all the rooms.
/*!
* Slot. Checks the availability of all the rooms by iterating through the current object's local
* room storage and calling the roomStatusInfoNeeded() separately on each of them.
*/
void checkStatusOfAllRooms();
- //! Slot for popping up the confirmation dialog to change the current operation mode
- /*!
- * Slot. Asks Window manager to pop up a confirmation dialog.
- * \param aMode The operation mode to be changed to
- */
- void changeModeOrdered( DeviceManager::OperationMode aMode );
- //! Slot. Fetches meeting details from the server.
- /*!
- * Slot. Fetches meeting details from the server.
- * \param aMeeting The meeting.
- */
- void fetchMeetingDetails( Meeting *aMeeting );
- //! Slot for receiving the status of the entered password
- /*!
- * Slot. Receives the status of the entered password and makes the DeviceManager to change the
- * operation mode if the password is correct.
- * \param aPasswordStatus The status of the password.
- */
- void passwordEntered( PasswordDialog::PasswordStatus aPasswordStatus );
//! Slot for receiving the failure event of operation mode changing.
/*!
* Slot. Receives the failure event of operation mode changing.
/*!
* Receives the cancel event of the progress bar when meeting details requested.
*/
- void fetchMeetingDetailsCancelled();
+ void fetchMeetingDetails( Meeting *aMeeting );
+ void cancelFetchMeetingDetails();
+
+ void handleViewEvent();
+ void previousViewRestored();
+
+ //! Slot for dialog activation signal.
+ /*!
+ * This slot is used to inform that dialog is activated. It stops
+ * the idle time counter so screensaver is not activated while the
+ * dialog is displayed.
+ */
+ void dialogActivated();
+ //! Slot for dialog deactivation signal.
+ /*!
+ * This slot is used to inform that dialog is deactivated. It restarts
+ * the idle time counter so that the screensaver is being activated again
+ * as needed.
+ */
+ void dialogDeactivated();
+
+ void stopIdleTimeCounter();
+ void startIdleTimeCounter();
+ void changeDeviceMode( bool aChange );
+
+ void currentRoomChanged( Room *aRoom );
+
private:
+ // Make the UIManager as friendly class so it can connect to private slots.
+ friend class UIManager;
+
//! Provides the index of the Meeting instance which is at the specified time.
/*!
* Provides the index of the Meeting instance which is at the specified time. If there are
* \return Index of the meeting if found; otherwise, -1.
*/
int indexOfMeetingAfter( Room *aRoom, QDateTime aAfter );
- //! Indicates if the QList contains the Meeting or not.
- /*!
- * Indicates if the QList contains the Meeting or not.
- * \param aList List of meetings.
- * \param aMeeting The meeting which is seeked in the list for.
- * \return True if contains; otherwise, false.
- */
- static bool isMeetingInList( const QList<Meeting*> &aList, const Meeting *aMeeting );
//! Slot. Fetches meetings from the server.
/*!
* Slot. Fetches meetings from the server, exact parameters are specified in the parameter list.
* \param aIn The room which meetings need to be fetched.
*/
void fetchMeetings( const QDateTime &aFrom, const QDateTime &aUntil, const Room *aIn );
+ //! Initialize configuration package.
+ /*!
+ * This method initializes configuration classes and
+ * connects signals from and to the engine.
+ */
+ void initConfiguration();
+ //! Initialize device package.
+ /*!
+ * This method initializes device manager and
+ * connects signals from and to the engine.
+ */
+ void initDevice();
+ //! Initialize communication package.
+ /*!
+ * This method initializes the communication manager and
+ * connects signals from and to the engine.
+ */
+ void initCommunication();
+ //! Initialize user interface package.
+ /*!
+ * This method initializes the user interface and
+ * connects signals from and to the engine. This method
+ * makes the window manager visible and shows weekly
+ * view as the first view.
+ */
+ void initUserInterface();
+ //! Connects signal between objects.
+ /*!
+ * Signals that could not be connected while initializing different
+ * packages are connected here.
+ */
+ void connectSignals();
+ bool isMeetingInList(const QList<Meeting*> &aList, const Meeting *aMeeting);
+
private:
static QTime endOfTheDay;
WindowManager *iWindowManager;
+
QTimer *iIdleTimeCounter;
Clock *iClock;
Configuration *iConfiguration;
CommunicationManager *iCommunication;
DeviceManager *iDevice;
+ UIManager *iUIManager;
QTimer *iAutoRefresh;
QList<Meeting*> iMeetings;
+ Room *iCurrentRoom;
+ bool iCommunicationFailed;
};
#endif /*ENGINE_H_*/
QTime RoomStatusIndicatorWidget::endOfTheDay = QTime( 23, 59, 0, 0 );\r
\r
RoomStatusIndicatorWidget::RoomStatusIndicatorWidget( Room *aDefaultRoom, Room::Status aStatus, QTime aUntil, QString aTimeFormat, QWidget *aParent ) :\r
- ObservedWidget( aParent ), iTimeFormat( aTimeFormat )\r
+ ViewBase( ViewBase::ObservedView, aParent ), iTimeFormat( aTimeFormat )\r
{\r
QFont importantTextFont;\r
//importantTextFont.setBold( true );\r
iUntilTextLabel = ToolBox::createLabel( tr( "until %1" ).arg( aUntil.toString( iTimeFormat ) ), importantTextFont );\r
iUntilTextLabel->setAlignment( Qt::AlignHCenter );\r
iUntilTextLabel->setStyleSheet( "background-color: transparent" );\r
+ \r
+ // No connection to server note\r
+ qDebug() << "RoomStatusIndicatorWidget::RoomStatusIndicatorWidget() creating connection label";\r
+ QFrame* connectionLabelFrame = new QFrame( this );\r
+ iConnectionLabel = new QLabel( tr( "No connection to server" ), connectionLabelFrame );\r
+ iConnectionLabel->setFont( importantTextFont ); \r
+ iConnectionLabel->setAlignment( Qt::AlignHCenter );\r
+ iConnectionLabel->setWordWrap( true );\r
+ iConnectionLabel->setStyleSheet( "background-color: transparent; color: red; text-decoration:blink; max-width: 250px" );\r
+ connectionLabelFrame->setFixedSize( iConnectionLabel->sizeHint() );\r
+ //iConnectionLabel->setHidden( true );\r
\r
QVBoxLayout *topLayout = new QVBoxLayout;\r
topLayout->addStretch();\r
topLayout->addWidget( iTimeDisplay );\r
+ topLayout->addSpacing( 28 );\r
topLayout->addWidget( iDefaultRoomLabel );\r
topLayout->addWidget( iStatusLabel );\r
topLayout->addWidget( iUntilTextLabel );\r
+ topLayout->addSpacing( 28 );\r
+ topLayout->addWidget( connectionLabelFrame );\r
topLayout->addStretch();\r
\r
QHBoxLayout *mainLayout = new QHBoxLayout;\r
mainLayout->addLayout( topLayout );\r
mainLayout->addStretch();\r
- mainLayout->setMargin( 65 );\r
+ //mainLayout->setMargin( 65 );\r
+ mainLayout->setContentsMargins( 65, 65, 65, 0 );\r
setLayout( mainLayout );\r
\r
statusChanged( aStatus, aUntil );\r
#ifndef ROOMSTATUSINDICATORWIDGET_H_\r
#define ROOMSTATUSINDICATORWIDGET_H_\r
\r
- #include "ObservedWidget.h"\r
+ #include "ViewBase.h"\r
#include <QTime>\r
#include <QKeyEvent>\r
#include <QTabletEvent>\r
* and disappears if there is any. Its function is to behave like a screen saver on one hand, and\r
* to provide details about the current availability on the other hand.\r
*/\r
- class RoomStatusIndicatorWidget : public ObservedWidget\r
+ class RoomStatusIndicatorWidget : public ViewBase\r
{\r
Q_OBJECT\r
\r
* \param aUntil The new time until the specified status is valid.\r
*/\r
void statusChanged( const Room::Status aStatus, const QTime aUntil );\r
+ \r
+ void viewResized(const QSize &newSize, const QSize &oldSize) { }\r
\r
private:\r
//! Translates the status into human readable text.\r
QLabel *iDefaultRoomLabel;\r
QLabel *iStatusLabel;\r
QLabel *iUntilTextLabel;\r
+ QLabel *iConnectionLabel;\r
TimeDisplayWidget *iTimeDisplay;\r
QString iTimeFormat;\r
\r
#include "WindowManager.h"
- #include <QTimer>
- #include "Configuration.h"
- #include "DisplaySettings.h"
- #include "Meeting.h"
- #include "Room.h"
- #include "Clock.h"
- #include "WeeklyViewWidget.h"
- #include "RoomStatusIndicatorWidget.h"
- #include "MeetingInfoDialog.h"
+ #include <QEvent>
+ #include <QDialog>
+ #include "ViewBase.h"
#include "PopUpMessageBox.h"
#include <QtDebug>
- WindowManager::WindowManager( Configuration *aConfiguration ) :
- QObject(),
+ WindowManager::WindowManager( QWidget *aParent ) :
+ QWidget( aParent ),
iApplicationName( tr( "Qt Meetings" ) ),
- iFullScreen( false ),
- iConfiguration( aConfiguration ),
- iWeeklyView( 0 ),
- iRoomStatusView( 0 ),
- iMeetingInfo( 0 ),
- iProgressBar( 0 ),
- iPasswordDialog( 0 )
+ iCurrentView( 0 )
{
- iWeeklyView = new WeeklyViewWidget( QDateTime::currentDateTime(), aConfiguration );
- iWeeklyView->setWindowTitle( iApplicationName );
- connect( iWeeklyView, SIGNAL( observedEventDetected() ), this, SIGNAL( observedEventDetected() ) );
- connect( iWeeklyView, SIGNAL( meetingActivated( Meeting * ) ), this, SIGNAL( meetingActivated( Meeting * ) ) );
- connect( iWeeklyView, SIGNAL( currentRoomChanged( Room * ) ), this, SIGNAL( currentRoomChanged( Room * ) ) );
- connect( iWeeklyView, SIGNAL( shownWeekChanged( QDate ) ), this, SIGNAL( shownWeekChanged( QDate ) ) );
-
- showWeeklyView();
-
+ this->setWindowTitle( iApplicationName );
}
WindowManager::~WindowManager()
{
- delete iWeeklyView;
- iWeeklyView = 0;
- delete iRoomStatusView;
- iRoomStatusView = 0;
- delete iMeetingInfo;
- iMeetingInfo = 0;
- delete iProgressBar;
- iProgressBar = 0;
- delete iPasswordDialog;
- iPasswordDialog = 0;
+
}
- void WindowManager::distributeDateTimeInfo( QDateTime aCurrentDateTime )
+ void WindowManager::showView( ViewBase *view )
{
- if ( iRoomStatusView != 0 && iRoomStatusView->isActiveWindow() )
+ // The views parent must be WindowManager when it is displayed trough this
+ QWidget *parent = static_cast<QWidget *>(view->parent());
+ if ( parent != this )
{
- iRoomStatusView->setCurrentTime( aCurrentDateTime.time() );
+ view->setParent( this );
}
-
- if ( iWeeklyView != 0 && iWeeklyView->isActiveWindow() )
+
+ // Store the current view because it is hidden after the new view is shown
+ QWidget *oldView = iCurrentView;
+
+ // If the new view is observed view we store the current into stack
+ // from which it is restored when the new view receives event we are
+ // listening to.
+ if ( view->viewMode() == ViewBase::ObservedView )
{
- iWeeklyView->setCurrentDateTime( aCurrentDateTime );
+ iViewList.push( iCurrentView );
}
+
+ // Make the new view visible and handle connections
+ iCurrentView = view;
+ connect( iCurrentView, SIGNAL( eventDetected() ), this, SLOT( viewEventDetected() ) );
+ connect( this, SIGNAL( viewResized(const QSize &, const QSize &) ), iCurrentView, SLOT( viewResized( const QSize &, const QSize & ) ) );
+ view->resize( this->size() );
+
+ view->show();
+
+ // Disconnect old connections and hide the view
+ if ( oldView != 0 )
+ {
+ disconnect( oldView, SIGNAL( eventDetected() ), this, SLOT( viewEventDetected() ) );
+ disconnect( this, SIGNAL( viewResized(const QSize &, const QSize &) ), oldView, SLOT( viewResized(const QSize &, const QSize &) ) );
+ oldView->hide();
+ }
+
}
- void WindowManager::roomStatusChanged( Room *aRoom, Room::Status aStatus, QTime aTime )
+ void WindowManager::showDialog(QDialog *aDialog, bool blocking, bool aSendSignal)
{
- if ( iRoomStatusView == 0 )
+ // Handle dialog displaying
+ if ( aSendSignal ) emit dialogActivated();
+ if ( blocking )
{
- iRoomStatusView = new RoomStatusIndicatorWidget( aRoom, aStatus, aTime, iConfiguration->displaySettings()->timeFormat() );
- iRoomStatusView->setWindowTitle( iApplicationName );
- if( iFullScreen )
- iRoomStatusView->setWindowState( Qt::WindowFullScreen );
- connect( iRoomStatusView, SIGNAL( observedEventDetected() ), this, SIGNAL( observedEventDetected() ) );
+ aDialog->exec();
}
else
{
- iRoomStatusView->statusChanged( aStatus, aTime );
- }
- if ( !iWeeklyView->isVisible() && !iRoomStatusView->isVisible() )
- {
- showRoomStatus();
+ aDialog->show();
}
+ if ( aSendSignal ) emit dialogDeactivated();
}
- void WindowManager::showRoomStatus()
+ void WindowManager::viewEventDetected()
{
- qDebug() << "WindowManager::showRoomStatus";
- iWeeklyView->setDefaultRoom();
- if ( iRoomStatusView == 0 )
- {
- emit roomStatusInfoNeeded( iWeeklyView->currentRoom() );
- }
- else
+
+ if ( iCurrentView != 0 )
{
- iRoomStatusView->show();
- if ( iWeeklyView->isVisible() )
+ if ( iCurrentView->viewMode() == ViewBase::NormalView )
+ {
+ emit eventDetected();
+ }
+ else if ( iCurrentView->viewMode() == ViewBase::ObservedView )
{
- iWeeklyView->hide();
+ if ( !iViewList.isEmpty() )
+ {
+ ViewBase *previousView = static_cast<ViewBase *>( iViewList.pop() );
+ this->showView( previousView );
+ emit previousViewRestored();
+ }
}
}
- // closing/deleting meeting info dialog
- if ( iMeetingInfo != 0 )
- {
- iMeetingInfo->hide();
- }
}
- void WindowManager::showWeeklyView()
+ bool WindowManager::event(QEvent *event)
{
- qDebug() << "WindowManager::showWeeklyView";
- if ( iRoomStatusView != 0 && iRoomStatusView->isVisible() )
+ if ( event->type() == QEvent::Resize )
{
- iRoomStatusView->hide();
+ if ( iCurrentView != 0 )
+ {
+ QSize currentSize = iCurrentView->size();
+ iCurrentView->setFixedSize( this->size() );
+ emit viewResized( this->size(), currentSize );
+ }
}
-
- iWeeklyView->show();
- }
-
- void WindowManager::fullScreen()
- {
- if ( iRoomStatusView != 0 )
- iRoomStatusView->setWindowState( Qt::WindowFullScreen );
- if ( iWeeklyView != 0 )
- iWeeklyView->setWindowState( Qt::WindowFullScreen );
- iFullScreen = true;
- }
-
- void WindowManager::insertMeeting( Meeting *aMeeting )
- {
- iWeeklyView->insertMeeting( aMeeting );
- }
-
- void WindowManager::deleteMeeting( Meeting *aMeeting )
- {
- iWeeklyView->deleteMeeting( aMeeting );
- }
-
- void WindowManager::showMeetingInfo( Meeting *aMeeting )
- {
- iMeetingInfo = new MeetingInfoDialog( aMeeting );
- // Display modal dialog
- iMeetingInfo->exec();
-
- delete iMeetingInfo;
- iMeetingInfo = 0;
- }
-
- void WindowManager::showSettingsView()
- {
- // TODO : give the Torspo for the person who was responsible to write this method
- }
-
- WeeklyViewWidget * WindowManager::weeklyView()
- {
- return iWeeklyView;
- }
-
- void WindowManager::error( const QString &aErrorMessage )
- {
- qDebug() << "WindowManager::showErrorPopup";
-
- PopUpMessageBox::error( 0, aErrorMessage );
- }
-
- void WindowManager::showPasswordDialog( QByteArray aAdminPassword, const QString &aMessage )
- {
- iPasswordDialog = new PasswordDialog( aAdminPassword, aMessage );
- connect( iPasswordDialog, SIGNAL( passwordEntered( PasswordDialog::PasswordStatus ) ),
- this, SIGNAL( passwordEntered( PasswordDialog::PasswordStatus ) ) );
- iPasswordDialog->show();
- //TODO connect connect( iWeeklyView, SIGNAL( observedEventDetected() ), this, SIGNAL( observedEventDetected() ) );
+ return QWidget::event( event );
}
- void WindowManager::closePasswordDialog()
- {
- iPasswordDialog->close();
- delete iPasswordDialog;
- iPasswordDialog = 0;
- }
-
- void WindowManager::showProgressBar( const QString &aText, bool aCancellable )
+ void WindowManager::error( const QString &aErrorMessage )
{
- qDebug() << "WindowManager::showProgressBar( const QString & )";
- if( iProgressBar == 0 ) {
- iProgressBar = new ProgressBar( aText, aCancellable );
- iProgressBar->setFixedSize( 600, 125 );
- iProgressBar->show();
- if( aCancellable )
- connect( iProgressBar, SIGNAL( cancel() ), this, SIGNAL( progressBarCancelled() ) );
- }
-
- //TODO connect connect( iWeeklyView, SIGNAL( observedEventDetected() ), this, SIGNAL( observedEventDetected() ) );
- }
+ qDebug() << "WindowManager::error ";
- void WindowManager::closeProgressBar()
- {
- qDebug() << "WindowManager::closeProgressBar()";
- if( iProgressBar )
+ PopUpMessageBox *popup = PopUpMessageBox::error( 0, aErrorMessage );
+ if ( popup != 0 )
{
- iProgressBar->close();
- delete iProgressBar;
- iProgressBar = 0;
+ showDialog( static_cast<QDialog *>( popup ), false );
}
}
- void WindowManager::updateProgressBar( const QString &aMessage )
+ void WindowManager::setFullscreen()
{
- qDebug() << "WindowManager::updateProgressBar( const QString & )";
- if( iProgressBar != 0 )
- iProgressBar->update( aMessage );
+ this->setWindowState( Qt::WindowFullScreen );
+ // Resize event handles the rest.
}
+
+void WindowManager::connectionLost()
+{
+ //TODO: Inform all views
+ qDebug() << "WindowManager::connectionLost()";
+}
+
+void WindowManager::connectionEstablished()
+{
+ //TODO: Inform all views
+ qDebug() << "WindowManager::connectionEstablished()";
+}
+
-#ifndef WINDOWMANAGER_H_\r
-#define WINDOWMANAGER_H_\r
-\r
-#include <QWidget>\r
-#include <QStack>\r
-\r
-// Forward declarations\r
-class ViewBase;\r
-class QEvent;\r
-class QSize;\r
-class QDialog;\r
-class QString;\r
-\r
-//! UserInterface class. Manages displayed views.\r
-/*!\r
- * UserInterface class. WindowManager class is responsible for displaying views that inherit the\r
- * ViewBase class. It also handles dialog showing. Depending on the views type the WindowManager\r
- * can track the views events and restore previous view if the current on is ObservedView. This\r
- * is a handy mechanism for screensaver etc.\r
- */\r
-class WindowManager : public QWidget\r
-{\r
- Q_OBJECT\r
-\r
-public:\r
- //! Constructor.\r
- /*!\r
- * Constructor of WindowManager.\r
- */\r
- WindowManager( QWidget *aParent = 0 );\r
- //! Destructor.\r
- virtual ~WindowManager();\r
- \r
- virtual bool event(QEvent *event);\r
-\r
-signals:\r
- //! Request current status of the room.\r
- /*!\r
- * Signal is emitted when there is need to check current status of room aRoom.\r
- * \param aRoom Meetingroom which status is requested.\r
- */\r
- void eventDetected();\r
- \r
- //! The view size is changed.\r
- /*!\r
- * This signal is emitted when the window managers view changes,\r
- * i.e. it received resized QEvent.\r
- * \param The new view size.\r
- */\r
- void viewResized(const QSize &newSize, const QSize &oldSize);\r
- \r
- //! Previous view is restored.\r
- /*!\r
- * This signal is emitted when previously stored view is\r
- * restored. This happens when view with type ViewMode::ObservedView\r
- * is shown and it receives an event that initiates the view\r
- * restoring chain.\r
- */\r
- void previousViewRestored();\r
- \r
- void dialogActivated();\r
- void dialogDeactivated();\r
-\r
-public slots:\r
- //! Shows the view.\r
- /*!\r
- * Show view that inherits ViewBase class. If the views parent is not\r
- * the WindowManager it will changed within this method. Depeding on the\r
- * views type the currently active view might be stored and restored\r
- * when specific event occurs in the view to be displayed.\r
- */\r
- void showView( ViewBase *view );\r
- \r
- //! Shows modal dialog.\r
- /*!\r
- * Shows modal dialog. Emits dialogActivated() signal prior calling\r
- * QDialog's exec() method and emits dialogDeactivated signal when\r
- * the exec() method returns.\r
- */\r
- void showDialog( QDialog *aDialog, bool blocking = true, bool aSendSignal = true );\r
- \r
- //! View event is detected.\r
- /*!\r
- * WindowManager connects this slot to ViewBase classes eventDetected()\r
- * signal and either emits eventDetected() signal if the current views\r
- * type is ViewMode::NormalView or restores possible previous view\r
- * if the current views type is ViewMode::ObservedView.\r
- */\r
- void viewEventDetected();\r
- \r
- void setFullscreen();\r
- \r
- void error( const QString &aErrorMessage );\r
-\r
-private:\r
- //! Name of the application.\r
- QString iApplicationName;\r
- \r
- //! Currently active view.\r
- ViewBase *iCurrentView;\r
- \r
- //! Stack of views previously displayed.\r
- QStack<ViewBase *> iViewList;\r
-\r
-};\r
-\r
-#endif /*WINDOWMANAGER_H_*/\r
+#ifndef WINDOWMANAGER_H_
+#define WINDOWMANAGER_H_
+
- #include <QObject>
- #include <QTime>
- #include "Room.h"
- #include "Meeting.h"
- #include "PasswordDialog.h"
- #include "DeviceManager.h"
++#include <QWidget>
++#include <QStack>
+
- class QTimer;
- class RoomStatusIndicatorWidget;
- class WeeklyViewWidget;
- class Engine;
- class MeetingInfoDialog;
- class SettingsView;
- class ProgressBar;
- class Configuration;
++// Forward declarations
++class ViewBase;
++class QEvent;
++class QSize;
++class QDialog;
++class QString;
+
- //! UserInterface class. Behaves as a proxy between the user interface and application's business logic.
++//! UserInterface class. Manages displayed views.
+/*!
- * UserInterface class. Controls the whole user interface, starting with displaying the appropriate
- * views. It behaves as a proxy between the user interface and application's business logic, it connects
- * the specified components together and forwards the data to the correct place. It also manages the correct
- * appearance of current views on the screen.
++ * UserInterface class. WindowManager class is responsible for displaying views that inherit the
++ * ViewBase class. It also handles dialog showing. Depending on the views type the WindowManager
++ * can track the views events and restore previous view if the current on is ObservedView. This
++ * is a handy mechanism for screensaver etc.
+ */
- class WindowManager : public QObject
++class WindowManager : public QWidget
+{
+ Q_OBJECT
+
+public:
+ //! Constructor.
+ /*!
+ * Constructor of WindowManager.
- * \param aConfiguration The pointer to configuration.
+ */
- WindowManager( Configuration *aConfiguration );
++ WindowManager( QWidget *aParent = 0 );
+ //! Destructor.
+ virtual ~WindowManager();
- /*!
- * Displays an error message
- * \param aErrorMessage Message to be displayd
- */
- void error( const QString &aErrorMessage );
- //! Updates the rooms status.
- /*!
- * Forwards the signal of changed status to current view.
- * \param aRoom Room which status is changed.
- * \param aStatus Current status of room.
- * \param aTime Time when status is changed.
- */
- void roomStatusChanged( Room *aRoom, Room::Status aStatus, QTime aTime );
- //! Shows the password dialog.
- /*!
- * Shows the password dialog.
- * \param aAdminPassword The correct password.
- * \param aMessage The message to be shown in the password dialog.
- */
- void showPasswordDialog( QByteArray aAdminPassword, const QString &aMessage );
- //! Closes the password dialog.
- /*!
- * Closes the password dialog.
- */
- void closePasswordDialog();
- //! Displays the weekly view.
- /*!
- * Displays the weekly view.
- */
- void showWeeklyView();
- //! Displays the meeting info dialog.
- /*!
- * Displays the meeting info dialog.
- * \param aMeeting Meeting to be displayd
- */
- void showMeetingInfo( Meeting *aMeeting );
- //! Returns the pointer to the weekly view.
- /*!
- * Returns the pointer to the weekly view.
- */
- WeeklyViewWidget * weeklyView();
- //! Switches the views to full screen.
- /*!
- * Switches the views to full screen.
- */
- void fullScreen();
- //! Shows the progress bar.
- /*!
- * Starts showing the progress bar.
- * \param aText The text to be shown in progress bar.
- * \param aCancellable Is the Cancel button visible. By default not visible.
- */
- void showProgressBar( const QString &aText, bool aCancellable = false );
- //! Closes the progress bar.
- /*!
- * Closes the progress bar.
- */
- void closeProgressBar();
-
- void insertMeeting( Meeting *aMeeting );
+
- void deleteMeeting( Meeting *aMeeting );
++ virtual bool event(QEvent *event);
++
+
+ //! Shows any view specific indicators for connection error
+ void connectionLost();
+
+ //! Removes any view specific indicators for connection error
+ void connectionEstablished();
+
+signals:
+ //! Request current status of the room.
+ /*!
+ * Signal is emitted when there is need to check current status of room aRoom.
+ * \param aRoom Meetingroom which status is requested.
+ */
- void roomStatusInfoNeeded( Room *aRoom );
- //! Indicate that some user event has happened.
- /*!
- * Signal is emitted if some user event has happened.
- */
- void observedEventDetected();
- //! Meeting activated.
- /*!
- * Signal is emitted when a meeting is clicked by the user.
- * \param aMeeting actived meeting.
- */
- void meetingActivated( Meeting *aMeeting );
- //! Signals if the shown week has been changed.
- /*!
- * Signal. Emitted if the shown week has been changed.
- * \param aDate The first date of the shown week.
- */
- void shownWeekChanged( QDate aDate );
- //! Signals change of the meeting room.
++ void eventDetected();
++
++ //! The view size is changed.
+ /*!
- * Signal is emitted when meeting room is changed.
- * \param aRoom Selected meeting room.
++ * This signal is emitted when the window managers view changes,
++ * i.e. it received resized QEvent.
++ * \param The new view size.
+ */
- void currentRoomChanged( Room *aRoom );
- //! Signals when the password dialog buttons are clicked.
++ void viewResized(const QSize &newSize, const QSize &oldSize);
++
++ //! Previous view is restored.
+ /*!
- * Signal is emitted when the password dialog buttons are clicked.
- * \param aPasswordStatus The status of the password.
++ * This signal is emitted when previously stored view is
++ * restored. This happens when view with type ViewMode::ObservedView
++ * is shown and it receives an event that initiates the view
++ * restoring chain.
+ */
- void passwordEntered( PasswordDialog::PasswordStatus aPasswordStatus );
- //! Signals when the cancel button in the progress bar is clicked.
++ void previousViewRestored();
++
++ void dialogActivated();
++ void dialogDeactivated();
++
++public slots:
++ //! Shows the view.
+ /*!
- * Signal is emitted when the cancel button in the progress bar is clicked.
++ * Show view that inherits ViewBase class. If the views parent is not
++ * the WindowManager it will changed within this method. Depeding on the
++ * views type the currently active view might be stored and restored
++ * when specific event occurs in the view to be displayed.
+ */
- void progressBarCancelled();
++ void showView( ViewBase *view );
+
- public slots:
- //! Slot for displaying the screensaver (room status view).
++ //! Shows modal dialog.
+ /*!
- * Slot. Displays the screensaver.
++ * Shows modal dialog. Emits dialogActivated() signal prior calling
++ * QDialog's exec() method and emits dialogDeactivated signal when
++ * the exec() method returns.
+ */
- void showRoomStatus();
- //! Slot for updating the time.
++ void showDialog( QDialog *aDialog, bool blocking = true, bool aSendSignal = true );
++
++ //! View event is detected.
+ /*!
- * Slot. Forwards the signal of changed time to current view.
- * \param aCurrentDateTime Current date and time.
++ * WindowManager connects this slot to ViewBase classes eventDetected()
++ * signal and either emits eventDetected() signal if the current views
++ * type is ViewMode::NormalView or restores possible previous view
++ * if the current views type is ViewMode::ObservedView.
+ */
- void distributeDateTimeInfo( QDateTime aCurrentDateTime );
++ void viewEventDetected();
+
- void updateProgressBar( const QString &aMessage );
++ void setFullscreen();
+
- private slots:
- //! Displays the settings view
- void showSettingsView();
++ void error( const QString &aErrorMessage );
+
+private:
+ //! Name of the application.
+ QString iApplicationName;
- //! Defines whether the views should be shown as full screen
- bool iFullScreen;
- //! Pointer to the configuration.
- Configuration *iConfiguration;
- //! Pointer to the weekly view.
- WeeklyViewWidget *iWeeklyView;
- //! Pointer to the screensaver (room status view).
- RoomStatusIndicatorWidget *iRoomStatusView;
- //! Pointer to the meeting info dialog
- MeetingInfoDialog *iMeetingInfo;
- //! Pointer to the settings view
- SettingsView *iSettingsView;
- //! Pointer to the progress bar
- ProgressBar *iProgressBar;
- //! Pointer to the password dialog.
- PasswordDialog *iPasswordDialog;
++
++ //! Currently active view.
++ ViewBase *iCurrentView;
++
++ //! Stack of views previously displayed.
++ QStack<ViewBase *> iViewList;
+
+};
+
+#endif /*WINDOWMANAGER_H_*/