ViewBase added and major changes to use the new architecture
authorMikko Siren <mikko.siren@ixonos.com>
Tue, 26 May 2009 07:43:41 +0000 (10:43 +0300)
committerMikko Siren <mikko.siren@ixonos.com>
Tue, 26 May 2009 07:43:41 +0000 (10:43 +0300)
19 files changed:
QtMeetings.pro
src/BusinessLogic/Engine.cpp
src/BusinessLogic/Engine.h
src/UserInterface/Components/MeetingRoomCombo.cpp
src/UserInterface/Components/MeetingRoomCombo.h
src/UserInterface/Components/TimeDisplayWidget.cpp
src/UserInterface/Components/TimeDisplayWidget.h
src/UserInterface/Views/MeetingInfoDialog.cpp
src/UserInterface/Views/MeetingInfoDialog.h
src/UserInterface/Views/RoomStatusIndicatorWidget.cpp
src/UserInterface/Views/RoomStatusIndicatorWidget.h
src/UserInterface/Views/SettingsView.cpp
src/UserInterface/Views/SettingsView.h
src/UserInterface/Views/ViewBase.cpp [new file with mode: 0644]
src/UserInterface/Views/ViewBase.h [new file with mode: 0644]
src/UserInterface/Views/WeeklyViewWidget.cpp
src/UserInterface/Views/WeeklyViewWidget.h
src/UserInterface/WindowManager.cpp
src/UserInterface/WindowManager.h

index f223557..85e43bd 100644 (file)
@@ -43,7 +43,8 @@ HEADERS += src/UserInterface/Utils/ProgressBar.h \
     src/UserInterface/Views/WeeklyViewWidget.h \
     src/UserInterface/Views/MeetingInfoDialog.h \
     src/UserInterface/Views/SettingsView.h \
-    src/UserInterface/WindowManager.h
+    src/UserInterface/WindowManager.h \
+    src/UserInterface/Views/ViewBase.h
 SOURCES += src/UserInterface/Utils/ProgressBar.cpp \
     src/Domain/Room.cpp \
     src/Domain/Meeting.cpp \
@@ -75,6 +76,7 @@ SOURCES += src/UserInterface/Utils/ProgressBar.cpp \
     src/UserInterface/Views/MeetingInfoDialog.cpp \
     src/UserInterface/Views/SettingsView.cpp \
     src/UserInterface/WindowManager.cpp \
+    src/UserInterface/Views/ViewBase.cpp \
     src/main.cpp
 RESOURCES += resources/BusinessLogic.qrc \
     resources/UserInterface.qrc
index 2f9d3cd..0b68a03 100644 (file)
@@ -5,10 +5,14 @@
 #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 "SettingsView.h"
+#include "RoomStatusIndicatorWidget.h"
+#include "PasswordDialog.h"
+#include "MeetingInfoDialog.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 )
 {
        qDebug() << "Engine::Engine()";
-       // 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->setInterval( 10000 );
        iIdleTimeCounter->start();
-       connect( iIdleTimeCounter, SIGNAL( timeout() ), iWindowManager, SLOT( showRoomStatus() ) );
+       // 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 ) ) );
+       // connect( iClock, SIGNAL( tick( QDateTime ) ), iWindowManager, SLOT( distributeDateTimeInfo( QDateTime ) ) );
 
        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();
+//     connect( iAutoRefresh, SIGNAL( timeout() ), this, SLOT( fetchMeetings() ) );
        
        if( iDevice->currentOperationMode() == DeviceManager::KioskMode )
-               iWindowManager->fullScreen();
+       {
+               iWindowManager->setFullscreen();
+       }
 
+       connectSignals();
+       
        QTimer::singleShot( 0, this, SLOT( fetchMeetings() ) );
 
        // TODO: continue implementation
@@ -87,15 +78,21 @@ Engine::~Engine()
        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( iRoomStatusIndicator );
+       QT_DELETE( iSettingsView );
+       QT_DELETE( iWeeklyView );
+       QT_DELETE( iPasswordDialog );
+       QT_DELETE( iWindowManager );
 }
 
 void Engine::closeApplication()
@@ -105,19 +102,6 @@ void Engine::closeApplication()
        QTimer::singleShot( 1000, QApplication::instance(), SLOT( quit() ) );
 }
 
-void Engine::observedEventDetected()
-{
-       qDebug() << "Engine::observedEventDetected()";
-       iWindowManager->showWeeklyView();
-       // prepare to restart idle counter
-       if ( iIdleTimeCounter->isActive() )
-       {
-               iIdleTimeCounter->stop();
-       }
-       // (re)start idle counter
-       iIdleTimeCounter->start();
-}
-
 Room* Engine::defaultRoom()
 {
        qDebug() << "Engine::defaultRoom()";
@@ -126,7 +110,7 @@ Room* 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++ )
        {
@@ -137,7 +121,7 @@ void Engine::checkStatusOfAllRooms()
 
 int Engine::indexOfMeetingAt( Room *aRoom, QDateTime aAt )
 {
-       qDebug() << "Engine::indexOfMeetingAt( Room *, QDateTime )";
+//     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
@@ -153,7 +137,7 @@ int Engine::indexOfMeetingAt( Room *aRoom, QDateTime 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++ )
@@ -176,7 +160,7 @@ int Engine::indexOfMeetingAfter( Room *aRoom, QDateTime aAfter )
 
 void Engine::roomStatusInfoNeeded( Room *aRoom )
 {
-       qDebug() << "Engine::roomStatusInfoNeeded( Room * )";
+//     qDebug() << "Engine::roomStatusInfoNeeded( Room * )";
        if ( aRoom == 0 )
        {
                return;
@@ -193,8 +177,8 @@ void Engine::roomStatusInfoNeeded( Room *aRoom )
                          (( 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()
@@ -236,7 +220,7 @@ void Engine::meetingsFetched( const QList<Meeting*> &aMeetings )
                        Meeting* m = new Meeting( *(aMeetings.at( i )) );
                        iMeetings.append( m );
                        // and signal the changes
-                       iWindowManager->insertMeeting( m );
+                       iWeeklyView->insertMeeting( m );
                }
        }
 
@@ -248,7 +232,7 @@ void Engine::meetingsFetched( const QList<Meeting*> &aMeetings )
                {
                        Meeting* m = iMeetings.takeAt( i );
                        // signal the changes
-                       iWindowManager->deleteMeeting( m );
+                       iWeeklyView->deleteMeeting( m );
                        // delete the meeting from the local list
                        delete m;
                }
@@ -261,7 +245,13 @@ void Engine::meetingsFetched( const QList<Meeting*> &aMeetings )
 void Engine::meetingDetailsFetched( Meeting &aDetailedMeeting )
 {
        qDebug() << "Engine::meetingDetailsFetched( Meeting & )";
-       iWindowManager->showMeetingInfo( &aDetailedMeeting );
+       
+       if ( iMeetingInfoDialog != 0 )
+       {
+               iMeetingInfoDialog->setMeeting( &aDetailedMeeting );
+               iWindowManager->showDialog( iMeetingInfoDialog );
+       }
+
 }
 
 void Engine::errorHandler( int aCode, const QString &aAddInfo )
@@ -270,15 +260,15 @@ void Engine::errorHandler( int aCode, const QString &aAddInfo )
        // inform UI about the problem
        if( aCode >= 100 && aCode <= 110 )
                qDebug() << "CommunicationManager signaled an error:" << aCode;
-       iWindowManager->error( ErrorMapper::codeToString( aCode, 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 );
+//     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 )
@@ -293,7 +283,7 @@ void Engine::shownWeekChanged( QDate aFrom )
        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() );
+//     fetchMeetings( from, to, iWindowManager->weeklyView()->currentRoom() );
 }
 
 void Engine::changeModeOrdered( DeviceManager::OperationMode aMode )
@@ -301,29 +291,30 @@ 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 ) );
-       
-       iWindowManager->showPasswordDialog( iConfiguration->adminPassword(), message );
+
+       // iPasswordDialog->update( message );
+       iWindowManager->showDialog( static_cast<QDialog *>( iPasswordDialog ) );
 }
 
 void Engine::passwordEntered( PasswordDialog::PasswordStatus aPasswordStatus )
 {
        qDebug() << "Engine::passwordEntered( PasswordDialog::PasswordStatus )";
-       iWindowManager->closePasswordDialog();
+//     iWindowManager->closePasswordDialog();
        
        switch ( 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 & ) ) );
+//                     iWindowManager->showProgressBar( "Changing current operation mode." );
+//                     connect( iWindowManager, SIGNAL( progressBarCancelled() ), this, SLOT( progressBarCancelled() ) );
+//                     connect( iDevice, SIGNAL( changingMode( const QString & ) ),
+//                                     iWindowManager, SLOT( updateProgressBar( const QString & ) ) );
                        iDevice->changeMode( true );
                        break;
                }
                case PasswordDialog::Incorrect :
                {
-                       iWindowManager->error( tr( "Incorrect password." ) );
+//                     iWindowManager->error( tr( "Incorrect password." ) );
                        iDevice->changeMode( false );
                        break;
                }
@@ -338,6 +329,142 @@ void Engine::progressBarCancelled()
 {
        qDebug() << "Engine::progressBarCancelled()";
        //TODO: cancel the on-going event
-       iWindowManager->closeProgressBar();
+//     iWindowManager->closeProgressBar();
        iDevice->changeMode( false );
 }
+
+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
index 457d6ba..4695738 100644 (file)
@@ -5,13 +5,20 @@
 #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 DeviceManager;
+class WeeklyViewWidget;
+class SettingsView;
+class RoomStatusIndicatorWidget;
+class PasswordDialog;
+class MeetingInfoDialog;
 
 //! BusinessLogic class. Contains all the business logic of the application.
 /*!
@@ -53,11 +60,6 @@ private slots:
         * \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.
@@ -126,6 +128,29 @@ private slots:
         */
        void progressBarCancelled();
        
+       void handleViewEvent();
+       void previousViewRestored();
+       void settingsViewRequested();
+       
+       void idleTimerTimeout();
+       
+       void settingsOkClicked();
+       
+       //! 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();
+       
 private:
        //! Provides the index of the Meeting instance which is at the specified time.
        /*!
@@ -161,11 +186,50 @@ private:
         * \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();
 
 private:
        static QTime endOfTheDay;
 
        WindowManager *iWindowManager;
+       WeeklyViewWidget *iWeeklyView;
+       SettingsView *iSettingsView;
+       RoomStatusIndicatorWidget *iRoomStatusIndicator;
+       
+       PasswordDialog *iPasswordDialog;
+       MeetingInfoDialog *iMeetingInfoDialog;
+       
        QTimer *iIdleTimeCounter;
        Clock *iClock;
        Configuration *iConfiguration;
index 4b7a128..fad0493 100644 (file)
@@ -7,7 +7,7 @@
 #include <QtDebug>
 
 MeetingRoomCombo::MeetingRoomCombo( QList<Room*> aRooms, QWidget *aParent ) :
-               ObservedWidget( aParent )
+               QWidget( aParent )
 {
        iRooms = aRooms;
        qSort( iRooms.begin(), iRooms.end(), Room::caseInsensitiveLessThan );
index 5c7120a..01a858e 100644 (file)
@@ -1,7 +1,6 @@
 #ifndef MEETINGROOMCOMBO_H_\r
 #define MEETINGROOMCOMBO_H_\r
 \r
-#include "ObservedWidget.h"\r
 #include <QWidget>\r
 #include <QList>\r
 \r
@@ -13,7 +12,7 @@ class Room;
  * Userinterface class. Displays a list of selectable meeting rooms. Customized QComboBox which hides\r
  * all the not needed functionality of the "base" class.\r
  */\r
-class MeetingRoomCombo : public ObservedWidget\r
+class MeetingRoomCombo : public QWidget\r
 {\r
        Q_OBJECT\r
 \r
index 8267ca0..9fd2fab 100644 (file)
@@ -1,7 +1,7 @@
 #include "TimeDisplayWidget.h"\r
 \r
 TimeDisplayWidget::TimeDisplayWidget( QTime aNow, QWidget *aParent ) :\r
-               ObservedWidget( aParent )\r
+               QWidget( aParent )\r
 \r
 {\r
        iCurrentTime = aNow;\r
index a1bcfd4..5f4e3a4 100644 (file)
@@ -1,7 +1,6 @@
 #ifndef TIMEDISPLAYWIDGET_H_\r
 #define TIMEDISPLAYWIDGET_H_\r
 \r
-#include "ObservedWidget.h"\r
 #include <QWidget>\r
 #include <QColor>\r
 #include <QTime>\r
@@ -11,7 +10,7 @@
  * Abstact. UserInterface class. Offers  basic functionality to display time. Inherited by\r
  * DigitalTimeDisplayWidget.\r
  */\r
-class TimeDisplayWidget : public ObservedWidget\r
+class TimeDisplayWidget : public QWidget\r
 {\r
        Q_OBJECT\r
 \r
index 95e2cce..3250e82 100644 (file)
@@ -13,6 +13,26 @@ MeetingInfoDialog::MeetingInfoDialog( Meeting *aMeeting, QWidget *aParent ) :
 {
        setWindowTitle( tr( "Details" ) );
 
+       if ( aMeeting != 0 )
+       {
+               createDialogView( aMeeting );
+       }
+
+       setMinimumWidth( MeetingInfoDialog::width );
+       setMinimumHeight( MeetingInfoDialog::height );
+}
+
+MeetingInfoDialog::~MeetingInfoDialog()
+{
+}
+
+void MeetingInfoDialog::setMeeting(Meeting *aMeeting)
+{
+       createDialogView( aMeeting );
+}
+
+void MeetingInfoDialog::createDialogView(Meeting *aMeeting)
+{
        QFont normalFont;
        normalFont.setPointSize( 11 );
 
@@ -75,11 +95,4 @@ MeetingInfoDialog::MeetingInfoDialog( Meeting *aMeeting, QWidget *aParent ) :
        layout->addStretch();
        layout->addLayout( buttonLayout );
        setLayout( layout );
-
-       setMinimumWidth( MeetingInfoDialog::width );
-       setMinimumHeight( MeetingInfoDialog::height );
-}
-
-MeetingInfoDialog::~MeetingInfoDialog()
-{
 }
index a62cb32..86c33d1 100644 (file)
@@ -19,11 +19,14 @@ public:
         * \param aMeeting The Meeting instance which is needed to be presented in detail.\r
         * \param aParent Pointer to the parent widget. Optional.\r
         */\r
-       MeetingInfoDialog( Meeting *aMeeting, QWidget *aParent = 0 );\r
+       MeetingInfoDialog( Meeting *aMeeting = 0, QWidget *aParent = 0 );\r
        //! Destructor.\r
        virtual ~MeetingInfoDialog();\r
+       \r
+       void setMeeting( Meeting * aMeeting );\r
 \r
 private:\r
+       void createDialogView(Meeting *aMeeting);\r
 \r
        static const int width = 200;\r
        static const int height = 400;\r
index 7421a47..c903bc0 100644 (file)
@@ -11,7 +11,7 @@
 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
index 615051e..96c4235 100644 (file)
@@ -1,7 +1,7 @@
 #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
@@ -19,7 +19,7 @@ class TimeDisplayWidget;
  * 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
@@ -55,6 +55,8 @@ public slots:
         * \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 &size) { }\r
 \r
 private:\r
        //! Translates the status into human readable text.\r
index caa5cfe..863d84e 100644 (file)
@@ -24,7 +24,7 @@
 #include <QtDebug>
 
 SettingsView::SettingsView( QWidget *aParent ) :
-               ObservedWidget( aParent )
+               ViewBase( ViewBase::NormalView, aParent )
 {
        qDebug() << "SettingsView::ctor invoked";
        // Prepare the tabbed view
@@ -57,8 +57,8 @@ SettingsView::SettingsView( QWidget *aParent ) :
        setLayout( mainLayout );
 
        // Handle component connections
-       connect( iOkButton, SIGNAL( pressed() ), this, SLOT( okClicked() ) );
-       connect( iCancelButton, SIGNAL( pressed() ), this, SLOT( cancelClicked() ) );
+       connect( iOkButton, SIGNAL( clicked() ), this, SLOT( handleOkClicked() ) );
+       connect( iCancelButton, SIGNAL( clicked() ), this, SLOT( cancelClicked() ) );
 }
 
 SettingsView::~SettingsView()
@@ -389,7 +389,7 @@ QWidget *SettingsView::initKioskModeTab()
        return widget;
 }
 
-void SettingsView::okClicked()
+void SettingsView::handleOkClicked()
 {
        qDebug() << "[SettingsView::okClicked] <Invoked>";
 
@@ -409,8 +409,11 @@ void SettingsView::okClicked()
        bool powerSaveEnabled = iPowerSaveEnabled->isChecked();
 
        // TODO : Set the values to configuration and save it
+       
+       // Emit the signal to notify that ok is pressed and data is saved.
+       emit okClicked();
 
-       close();
+//     close();
 }
 
 void SettingsView::cancelClicked()
@@ -418,3 +421,10 @@ void SettingsView::cancelClicked()
        qDebug() << "[SettingsView::cancelClicked] <Invoked>";
        close();
 }
+
+void SettingsView::viewResized(const QSize &size)
+{
+       qDebug() << "[SettingsView::viewResized] <Invoked>";
+       
+       qDebug() << "[SettingsView::viewResized] <Finished>";
+}
\ No newline at end of file
index 8b9bbeb..3e04eee 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef SETTINGSVIEW_H_
 #define SETTINGSVIEW_H_
 
-#include "ObservedWidget.h"
+#include "ViewBase.h"
 
 class QTabWidget;
 class QPushButton;
@@ -9,9 +9,10 @@ class QLineEdit;
 class QTimeEdit;
 class QRadioButton;
 class QCheckBox;
+class QSize;
 
 //! User interface class. Shows the settings view and handles configuration changes.
-class SettingsView : public ObservedWidget
+class SettingsView : public ViewBase
 {
        Q_OBJECT
 
@@ -25,10 +26,16 @@ public:
        SettingsView( QWidget *aParent = 0 );
        //! Destructor.
        virtual ~SettingsView();
+       
+signals:
+       void okClicked();
+       
+public slots:
+       void viewResized(const QSize &size);
 
 private slots:
        //! Slot to handle the Ok button pressing.
-       void okClicked();
+       void handleOkClicked();
        //! Slot to handle the cancel button pressing.
        void cancelClicked();
 
diff --git a/src/UserInterface/Views/ViewBase.cpp b/src/UserInterface/Views/ViewBase.cpp
new file mode 100644 (file)
index 0000000..24d6461
--- /dev/null
@@ -0,0 +1,77 @@
+#include "ViewBase.h"
+
+#include <QEvent>
+#include <QKeyEvent>
+#include <QTabletEvent>
+#include <QMouseEvent>
+#include <QMouseEvent>
+#include <QMouseEvent>
+#include <QLayout>
+
+#include <QtDebug>
+
+ViewBase::ViewBase( ViewBase::ViewMode aMode, QWidget *aParent ) : QWidget( aParent ), iViewMode( aMode )
+{
+
+}
+
+ViewBase::~ViewBase()
+{
+       
+}
+
+ViewBase::ViewMode ViewBase::viewMode()
+{
+       return iViewMode;
+}
+
+bool ViewBase::event(QEvent *event)
+{
+       switch( event->type() )
+       {
+               // TODO : Add events as needed !!!
+               case QEvent::KeyPress:
+               case QEvent::KeyRelease:
+               case QEvent::TabletMove:
+               case QEvent::TabletPress:
+               case QEvent::MouseMove:
+               case QEvent::MouseButtonPress:
+               case QEvent::MouseButtonDblClick:
+                       emit eventDetected();
+                       break;
+               default:
+                       break;
+       }
+       
+       return QWidget::event( event );
+}
+
+bool ViewBase::eventFilter( QObject *watched, QEvent *event )
+{
+       if ( watched != this ) // We do not filter our own events
+       {
+               switch( event->type() )
+               {
+                       // TODO : Add events as needed !!!!
+                       case QEvent::KeyPress:
+                       case QEvent::KeyRelease:
+                       case QEvent::TabletMove:
+                       case QEvent::TabletPress:
+                       case QEvent::MouseMove:
+                       case QEvent::MouseButtonPress:
+                       case QEvent::MouseButtonDblClick:
+                               emit eventDetected();
+                               break;
+                       default:
+                               break;
+               }
+       }
+       
+       return QWidget::eventFilter( watched, event );
+}
+
+void ViewBase::observeChild(QWidget *aChild)
+{
+       aChild->setMouseTracking( true );
+       aChild->installEventFilter( this );
+}
diff --git a/src/UserInterface/Views/ViewBase.h b/src/UserInterface/Views/ViewBase.h
new file mode 100644 (file)
index 0000000..00bcf70
--- /dev/null
@@ -0,0 +1,69 @@
+#ifndef VIEWBASE_
+#define VIEWBASE_
+
+#include <QWidget>
+
+class QEvent;
+class QSize;
+
+class ViewBase : public QWidget
+{
+       Q_OBJECT
+       
+public:
+       enum ViewMode
+       {
+               NormalView, /*!< Indicates that the view is normal view that isn't hidden by events. */
+               ObservedView /*!< Indicates that the view will be hidden when event occurs. */
+       };
+       
+public:
+       ViewBase( ViewBase::ViewMode aMode, QWidget *aParent = 0 );
+       virtual ~ViewBase();
+       
+       //! Overwritten event handler.
+       /*!
+        * Listens for events and emits eventDetected signal when observed
+        * event is triggered.
+        */
+       virtual bool event(QEvent *event);
+       
+       //! Event filter.
+       /*!
+        * Event filter method that is used to listen for child widgets
+        * events.
+        */
+       virtual bool eventFilter(QObject *watched, QEvent *event);
+       
+       //! Returns view mode.
+       /*!
+        * Returns the views mode which is one of the ViewMode enumerations.
+        */
+       ViewBase::ViewMode viewMode();
+       
+public slots:
+       //! This slot is called when the view is resized.
+       /*!
+        * This slot will be called after the view is resized by the window manager
+        * to fit its client area. This method can be used to refine the view size
+        * after it has been resized, for example when the on screen keyboard is
+        * displayed.
+        */
+       virtual void viewResized(const QSize &size) = 0;
+       
+signals:
+       /*!
+        * This signal indicates that some user initiated event has occured.
+        * Event filter tracks for mouse, pointer and key events.
+        */
+       void eventDetected();
+       
+protected:
+       void observeChild(QWidget *aChild);
+       
+private:
+       ViewMode iViewMode;
+       
+};
+
+#endif /*VIEWBASE_*/
index b33e517..3f2fec4 100644 (file)
@@ -20,7 +20,7 @@
 #include <QtDebug>\r
 \r
 WeeklyViewWidget::WeeklyViewWidget( QDateTime aCurrentDateTime, Configuration *aConfiguration, QWidget *aParent ) :\r
-               ObservedWidget( aParent ), iConfiguration( aConfiguration )\r
+               ViewBase( ViewBase::NormalView, aParent ), iConfiguration( aConfiguration )\r
 {\r
 \r
        // *****************************************\r
@@ -36,23 +36,21 @@ WeeklyViewWidget::WeeklyViewWidget( QDateTime aCurrentDateTime, Configuration *a
        iSettingsButton = new QPushButton;\r
        iSettingsButton->setIcon( QPixmap( ":button_settings" ) );\r
        iSettingsButton->setFixedWidth( 36 );\r
-       connect( iSettingsButton, SIGNAL( clicked() ), this, SIGNAL( showSettingsView() ) );\r
+       connect( iSettingsButton, SIGNAL( clicked() ), this, SIGNAL( settingsButtonClicked() ) );\r
 \r
        iCurrentDayLabel = ToolBox::createLabel( aCurrentDateTime.toString( iConfiguration->displaySettings()->dateFormat() ), regularTextFont );\r
        iCurrentWeekLabel = ToolBox::createLabel( tr( "Wk %1" ).arg( aCurrentDateTime.date().weekNumber() ), regularTextFont );\r
 \r
        iRoomsCombo = new MeetingRoomCombo( iConfiguration->rooms(), this );\r
        iRoomsCombo->setCurrentRoom( iConfiguration->defaultRoom() );\r
-       connect( iRoomsCombo, SIGNAL( observedEventDetected() ), this, SIGNAL( observedEventDetected() ) );\r
+       connect( iRoomsCombo, SIGNAL( currentRoomChange( Room * ) ), this, SIGNAL( currentRoomChange( Room * ) ) );\r
 \r
        iTimeDisplay = new DigitalTimeDisplayWidget( aCurrentDateTime.time(), iConfiguration->displaySettings()->timeFormat(), this );\r
        iTimeDisplay->setFrameVisible( false );\r
        iTimeDisplay->setFont( regularTextFont );\r
-       connect( iTimeDisplay, SIGNAL( observedEventDetected() ), this, SIGNAL( observedEventDetected() ) );\r
 \r
        iSchedule = new ScheduleWidget( aCurrentDateTime, iConfiguration->displaySettings(), this );\r
        connect( iSchedule, SIGNAL( shownWeekChanged( QDate ) ), this, SIGNAL( shownWeekChanged( QDate ) ) );\r
-       connect( iSchedule, SIGNAL( observedEventDetected() ), this, SIGNAL( observedEventDetected() ) );\r
        connect( iSchedule, SIGNAL( meetingActivated( Meeting* ) ), this, SIGNAL( meetingActivated( Meeting* ) ) );\r
 \r
        iPreviousWeekButton = new QPushButton( this );\r
@@ -91,6 +89,16 @@ WeeklyViewWidget::WeeklyViewWidget( QDateTime aCurrentDateTime, Configuration *a
        mainLayout->addLayout( tableLayout );\r
        mainLayout->addLayout( bottomLayout );\r
        setLayout( mainLayout );\r
+       \r
+       // Set child observing\r
+       observeChild( iRoomsCombo );\r
+       observeChild( iTimeDisplay );\r
+       observeChild( iCurrentDayLabel );\r
+       observeChild( iCurrentWeekLabel );\r
+       observeChild( iPreviousWeekButton );\r
+       observeChild( iCurrentWeekButton );\r
+       observeChild( iNextWeekButton );\r
+       observeChild( iSettingsButton );\r
 \r
        QPalette palette;\r
        palette.setColor( QPalette::Window, Qt::white );\r
@@ -100,11 +108,11 @@ WeeklyViewWidget::WeeklyViewWidget( QDateTime aCurrentDateTime, Configuration *a
        // ******************************************\r
        //              Handle all the signal connections\r
        // TODO : this solution if interaction monitoring is not elegant enough\r
-       connect( iPreviousWeekButton, SIGNAL( clicked() ), this, SIGNAL( observedEventDetected() ) );\r
-       connect( iCurrentWeekButton, SIGNAL( clicked() ), this, SIGNAL( observedEventDetected() ) );\r
-       connect( iNextWeekButton, SIGNAL( clicked() ), this, SIGNAL( observedEventDetected() ) );\r
-       connect( iRoomsCombo, SIGNAL( currentRoomChanged( Room * ) ), this, SIGNAL( observedEventDetected() ) );\r
-       connect( iRoomsCombo, SIGNAL( currentIndexChanged( int ) ), this, SIGNAL( observedEventDetected() ) );\r
+//     connect( iPreviousWeekButton, SIGNAL( clicked() ), this, SIGNAL( observedEventDetected() ) );\r
+//     connect( iCurrentWeekButton, SIGNAL( clicked() ), this, SIGNAL( observedEventDetected() ) );\r
+//     connect( iNextWeekButton, SIGNAL( clicked() ), this, SIGNAL( observedEventDetected() ) );\r
+//     connect( iRoomsCombo, SIGNAL( currentRoomChanged( Room * ) ), this, SIGNAL( observedEventDetected() ) );\r
+//     connect( iRoomsCombo, SIGNAL( currentIndexChanged( int ) ), this, SIGNAL( observedEventDetected() ) );\r
        // TODO: connect RoomCombo signals to change meetings data.\r
        connect( iRoomsCombo, SIGNAL( currentRoomChanged( Room * ) ), iSchedule, SLOT( clear() ) );\r
        connect( iRoomsCombo, SIGNAL( currentRoomChanged( Room * ) ), this, SIGNAL( currentRoomChanged( Room * ) ) );\r
index f0da141..1eb1812 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef WEEKLYVIEWWIDGET_H_\r
 #define WEEKLYVIEWWIDGET_H_\r
 \r
-#include "ObservedWidget.h"\r
+#include "ViewBase.h"\r
 #include <QDateTime>\r
 \r
 class QLabel;\r
@@ -19,7 +19,7 @@ class Room;
  * selected meeting room. User can select meeting room, browse weeks back and forth, and can navigate\r
  * back to the current week.\r
  */\r
-class WeeklyViewWidget : public ObservedWidget\r
+class WeeklyViewWidget : public ViewBase\r
 {\r
        Q_OBJECT\r
 \r
@@ -103,14 +103,14 @@ signals:
        /*!\r
         * Signal is emited when settings button is clicked.\r
         */\r
-       void showSettingsView();\r
+       void settingsButtonClicked();\r
        \r
        //! Signal. Emitted if the shown week has been changed.\r
        /*!\r
         * Signal. Emitted if the shown week has been changed.
         * \param aDate The first date of the shown week.
         */
-       void shownWeekChanged( QDate aDate );
+       void shownWeekChanged( QDate aDate );\r
 \r
 public slots:\r
        //! Sets the date and time\r
@@ -137,6 +137,13 @@ public slots:
         * \param aMeeting Meeting to be updated.\r
         */\r
        void updateMeeting( Meeting *aMeeting );\r
+       \r
+       //! Handle resizing\r
+       /*!\r
+        * Handle possible resize changes after the view is resized\r
+        * to match the window managers client area.\r
+        */\r
+       void viewResized(const QSize &size) { }\r
 \r
 private:\r
        //! Displays the selectable meeting rooms.\r
index 45d8b72..8685e6b 100644 (file)
 #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 "PopUpMessageBox.h"
-#include "DeviceManager.h"
-#include "SettingsView.h"
-#include "ProgressBar.h"
+#include <QEvent>
+#include <QDialog>
+#include "ViewBase.h"
 
 #include <QtDebug>
 
-WindowManager::WindowManager( Configuration *aConfiguration ) :
-               QObject(),
+const int IDLE_TIME_MULTIPLIER = 60000; // Multiplies milliseconds to minutes
+
+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 )
-{
-       if ( iRoomStatusView != 0 && iRoomStatusView->isActiveWindow() )
-       {
-               iRoomStatusView->setCurrentTime( aCurrentDateTime.time() );
-       }
-
-       if ( iWeeklyView != 0 && iWeeklyView->isActiveWindow() )
-       {
-               iWeeklyView->setCurrentDateTime( aCurrentDateTime );
-       }
+       
 }
 
-void WindowManager::roomStatusChanged( Room *aRoom, Room::Status aStatus, QTime aTime )
+void WindowManager::showView( ViewBase *view )
 {
-       if ( iRoomStatusView == 0 )
+       // The views parent must be WindowManager when it is displayed trough this
+       QWidget *parent = static_cast<QWidget *>(view->parent());
+       if ( parent != this )
        {
-               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() ) );
+               view->setParent( this );
        }
-       else
+       
+       // 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 )
        {
-               iRoomStatusView->statusChanged( aStatus, aTime );
+               iViewList.push( iCurrentView );
        }
-       if ( !iWeeklyView->isVisible() && !iRoomStatusView->isVisible() )
+       
+       // Make the new view visible and handle connections
+       iCurrentView = view;
+       connect( iCurrentView, SIGNAL( eventDetected() ), this, SLOT( viewEventDetected() ) );
+       connect( this, SIGNAL( viewResized(const QSize &) ), iCurrentView, SLOT( viewResized( const QSize & ) ) );
+       view->resize( this->size() );
+       
+       view->show();
+       
+       // Disconnect old connections and hide the view
+       if ( oldView != 0 )
        {
-               showRoomStatus();
+               disconnect( oldView, SIGNAL( eventDetected() ), this, SLOT( viewEventDetected() ) );
+               disconnect( this, SIGNAL( viewResized(const QSize &) ), oldView, SLOT( viewResized(const QSize &) ) );
+               oldView->hide();
        }
+       
 }
 
-void WindowManager::showRoomStatus()
+void WindowManager::showDialog(QDialog *dialog)
 {
-       qDebug() << "WindowManager::showRoomStatus";
+       // Handle dialog displaying
+       emit dialogActivated();
+       dialog->exec();
+       emit dialogDeactivated();
+}
 
-       if ( iRoomStatusView == 0 )
-       {
-               emit roomStatusInfoNeeded( iWeeklyView->currentRoom() );
-       }
-       else
+void WindowManager::viewEventDetected()
+{
+       
+       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();
-       }
-
-       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() ) );
-}
-
-void WindowManager::closePasswordDialog()
-{
-       iPasswordDialog->close();
-       delete iPasswordDialog;
-       iPasswordDialog = 0;
-}
-
-void WindowManager::showProgressBar( const QString &aText )
-{
-       qDebug() << "WindowManager::showProgressBar( const QString & )";
-       if( iProgressBar == 0 ) {
-               iProgressBar = new ProgressBar( aText );
-               iProgressBar->show();
-               connect( iProgressBar, SIGNAL( cancel() ), this, SIGNAL( progressBarCancelled() ) );
+               if ( iCurrentView != 0 )
+               {
+                       iCurrentView->setFixedSize( this->size() );
+                       emit viewResized( this->size() );
+               }
        }
        
-       //TODO connect connect( iWeeklyView, SIGNAL( observedEventDetected() ), this, SIGNAL( observedEventDetected() ) );
-}
-
-void WindowManager::closeProgressBar()
-{
-       qDebug() << "WindowManager::closeProgressBar()";
-       iProgressBar->close();
-       delete iProgressBar;
-       iProgressBar = 0;
+       return QWidget::event( event );
 }
 
-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.
 }
index 1e460c0..4fd592f 100644 (file)
@@ -1,30 +1,23 @@
 #ifndef WINDOWMANAGER_H_\r
 #define WINDOWMANAGER_H_\r
 \r
-#include <QObject>\r
-#include <QTime>\r
-#include "Room.h"\r
-#include "Meeting.h"\r
-#include "PasswordDialog.h"\r
-#include "DeviceManager.h"\r
+#include <QWidget>\r
+#include <QStack>\r
 \r
-class QTimer;\r
-class RoomStatusIndicatorWidget;\r
-class WeeklyViewWidget;\r
-class Engine;\r
-class MeetingInfoDialog;\r
-class SettingsView;\r
-class ProgressBar;\r
-class Configuration;\r
+// Forward declarations\r
+class ViewBase;\r
+class QEvent;\r
+class QSize;\r
+class QDialog;\r
 \r
-//! UserInterface class. Behaves as a proxy between the user interface and application's business logic.\r
+//! UserInterface class. Manages displayed views.\r
 /*!\r
- * UserInterface class. Controls the whole user interface, starting with displaying the appropriate\r
- * views. It behaves as a proxy between the user interface and application's business logic, it connects\r
- * the specified components together and forwards the data to the correct place. It also manages the correct\r
- * appearance of current views on the screen.\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 QObject\r
+class WindowManager : public QWidget\r
 {\r
        Q_OBJECT\r
 \r
@@ -32,72 +25,12 @@ public:
        //! Constructor.\r
        /*!\r
         * Constructor of WindowManager.\r
-        * \param aConfiguration The pointer to configuration.\r
         */\r
-       WindowManager( Configuration *aConfiguration );\r
+       WindowManager( QWidget *aParent = 0 );\r
        //! Destructor.\r
        virtual ~WindowManager();\r
-       /*!\r
-        * Displays an error message\r
-        * \param aErrorMessage Message to be displayd\r
-        */\r
-       void error( const QString &aErrorMessage );\r
-       //! Updates the rooms status.\r
-       /*! \r
-        * Forwards the signal of changed status to current view.\r
-        * \param aRoom Room which status is changed.\r
-        * \param aStatus Current status of room.\r
-        * \param aTime Time when status is changed.\r
-        */\r
-       void roomStatusChanged( Room *aRoom, Room::Status aStatus, QTime aTime );\r
-       //! Shows the password dialog.\r
-       /*!\r
-        * Shows the password dialog.\r
-        * \param aAdminPassword The correct password.\r
-        * \param aMessage The message to be shown in the password dialog.\r
-        */\r
-       void showPasswordDialog( QByteArray aAdminPassword, const QString &aMessage );\r
-       //! Closes the password dialog.\r
-       /*!\r
-        * Closes the password dialog.\r
-        */\r
-       void closePasswordDialog();\r
-       //! Displays the weekly view.\r
-       /*!\r
-        * Displays the weekly view.\r
-        */\r
-       void showWeeklyView();\r
-       //! Displays the meeting info dialog.\r
-       /*!\r
-        * Displays the meeting info dialog. \r
-        * \param aMeeting Meeting to be displayd\r
-        */\r
-       void showMeetingInfo( Meeting *aMeeting );\r
-       //! Returns the pointer to the weekly view. \r
-       /*!\r
-        * Returns the pointer to the weekly view.\r
-        */\r
-       WeeklyViewWidget * weeklyView();\r
-       //! Switches the views to full screen.\r
-       /*!\r
-        * Switches the views to full screen.\r
-        */\r
-       void fullScreen();\r
-       //! Shows the progress bar.\r
-       /*!\r
-        * Starts showing the progress bar.\r
-        * \param aText The text to be shown in progress bar.\r
-        */\r
-       void showProgressBar( const QString &aText );\r
-       //! Closes the progress bar.\r
-       /*!\r
-        * Closes the progress bar.\r
-        */\r
-       void closeProgressBar();\r
-       \r
-       void insertMeeting( Meeting *aMeeting );\r
        \r
-       void deleteMeeting( Meeting *aMeeting );\r
+       virtual bool event(QEvent *event);\r
 \r
 signals:\r
        //! Request current status of the room.\r
@@ -105,80 +38,66 @@ signals:
         * 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 roomStatusInfoNeeded( Room *aRoom );\r
-       //! Indicate that some user event has happened.\r
-       /*!\r
-        * Signal is emitted if some user event has happened.\r
-        */\r
-       void observedEventDetected();\r
-       //! Meeting activated.\r
-       /*!\r
-        * Signal is emitted when a meeting is clicked by the user.\r
-        * \param aMeeting actived meeting.\r
-        */\r
-       void meetingActivated( Meeting *aMeeting );\r
-       //! Signals if the shown week has been changed.\r
-       /*!\r
-        * Signal. Emitted if the shown week has been changed.\r
-        * \param aDate The first date of the shown week.\r
-        */\r
-       void shownWeekChanged( QDate aDate );\r
-       //! Signals change of the meeting room.\r
-       /*!\r
-        * Signal is emitted when meeting room is changed.\r
-        * \param aRoom Selected meeting room.\r
-        */\r
-       void currentRoomChanged( Room *aRoom );\r
-       //! Signals when the password dialog buttons are clicked.\r
+       void eventDetected();\r
+       \r
+       //! The view size is changed.\r
        /*!\r
-        * Signal is emitted when the password dialog buttons are clicked.\r
-        * \param aPasswordStatus The status of the password.\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 passwordEntered( PasswordDialog::PasswordStatus aPasswordStatus );\r
-       //! Signals when the cancel button in the progress bar is clicked.\r
+       void viewResized(const QSize &);\r
+       \r
+       //! Previous view is restored.\r
        /*!\r
-        * Signal is emitted when the cancel button in the progress bar is clicked.\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 progressBarCancelled();\r
+       void previousViewRestored();\r
        \r
+       void dialogActivated();\r
+       void dialogDeactivated();\r
+\r
 public slots:\r
-       //! Slot for displaying the screensaver (room status view).\r
+       //! Shows the view.\r
        /*!\r
-        * Slot. Displays the screensaver.\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 showRoomStatus();\r
-       //! Slot for updating the time.\r
+       void showView( ViewBase *view );\r
+       \r
+       //! Shows modal dialog.\r
        /*!\r
-        * Slot. Forwards the signal of changed time to current view.\r
-        * \param aCurrentDateTime Current date and time.\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 distributeDateTimeInfo( QDateTime aCurrentDateTime );\r
+       void showDialog( QDialog *dialog );\r
        \r
-       void updateProgressBar( const QString &aMessage );\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
-private slots:\r
-       //! Displays the settings view\r
-       void showSettingsView();\r
+       void setFullscreen();\r
 \r
 private:\r
        //! Name of the application.\r
        QString iApplicationName;\r
-       //! Defines whether the views should be shown as full screen \r
-       bool iFullScreen;\r
-       //! Pointer to the configuration.\r
-       Configuration *iConfiguration;\r
-       //! Pointer to the weekly view.\r
-       WeeklyViewWidget *iWeeklyView;\r
-       //! Pointer to the screensaver (room status view).\r
-       RoomStatusIndicatorWidget *iRoomStatusView;\r
-       //! Pointer to the meeting info dialog\r
-       MeetingInfoDialog *iMeetingInfo;\r
-       //! Pointer to the settings view\r
-       SettingsView *iSettingsView;\r
-       //! Pointer to the progress bar\r
-       ProgressBar *iProgressBar;\r
-       //! Pointer to the password dialog.\r
-       PasswordDialog *iPasswordDialog;\r
+       \r
+       //! Currently active view.\r
+       ViewBase *iCurrentView;\r
+       \r
+       //! Stack of views previously displayed.\r
+       QStack<ViewBase *> iViewList;\r
 \r
 };\r
 \r