Merge branch 'dev_itkonma'
authoritkonma <marko.itkonen@ixonos.com>
Mon, 1 Jun 2009 08:50:08 +0000 (11:50 +0300)
committeritkonma <marko.itkonen@ixonos.com>
Mon, 1 Jun 2009 08:50:08 +0000 (11:50 +0300)
Conflicts:
src/BusinessLogic/UIManager.cpp
src/BusinessLogic/UIManager.h
src/Domain/Configuration/Configuration.cpp

21 files changed:
resources/xml/errortable.xml
src/BusinessLogic/Engine.cpp
src/BusinessLogic/Engine.h
src/BusinessLogic/UIManager.cpp
src/BusinessLogic/UIManager.h
src/Domain/Configuration/Configuration.cpp
src/IO/Communication/CommunicationManager.cpp
src/IO/DeviceControl/DeviceConfigurator.cpp
src/IO/DeviceControl/DeviceManager.cpp
src/IO/DeviceControl/DeviceManager.h
src/IO/DeviceControl/HWKeyListener.cpp
src/IO/DeviceControl/OperationModeToggler.cpp
src/UserInterface/Utils/PasswordDialog.cpp
src/UserInterface/Utils/PasswordDialog.h
src/UserInterface/Utils/ProgressBar.cpp
src/UserInterface/Utils/ProgressBar.h
src/UserInterface/Views/RoomStatusIndicatorWidget.cpp
src/UserInterface/Views/RoomStatusIndicatorWidget.h
src/UserInterface/Views/ViewBase.cpp
src/UserInterface/Views/ViewBase.h
src/UserInterface/WindowManager.h

index 4706fce..841228a 100644 (file)
     <error code="110">Communication error</error>
     <error code="111">Communication: Invalid username or password</error>
     <error code="200">Device Control: Error creating internal file storage.</error>
-    <error code="201">Failed to change the operation mode. Error removing old alarm events.</error>
-       <error code="202">Failed to change the operation mode. Error sending alarm events. %1</error>
-       <error code="203">Failed to change the operation mode. Error storing data about sent alarm events. Removing the already sent alarm events.</error>
-       <error code="204">Error storing data of original automatic screen switching-off and dimming parameter values. Using the default values instead.</error>
-       <error code="205">Error fetching data of original automatic screen switching-off and dimming parameter values. Using the default values instead.</error>
-       <error code="206">Failed to change the operation mode. Error changing automatic screen switching-off and dimming parameter values.</error>
-       <error code="207">Failed to change the operation mode. Error fetching data of original hardware key settings.</error>
-       <error code="208">Failed to change the operation mode. Error storing data of original hardware key settings.</error>
-       <error code="209">Failed to change the operation mode. Error changing hardware key settings.</error>
-       <error code="210">Failed to change the operation mode. Init script to auto launch the application was not installed/removed.</error>
-       <error code="211">Failed to change the operation mode. The application failed to know the current mode of itself.</error>
-       <error code="212">Failed to change the operation mode. The application failed to store the current mode of itself.</error>
-       <error code="213">Failed to change the operation mode. Error restarting the device. Restart device manually.</error>
+    <error code="201">Device Control: Error removing old alarm events.</error>
+       <error code="202">Device Control: Error sending alarm events. %1</error>
+       <error code="203">Device Control: Error storing data about sent alarm events. Removing the already sent alarm events.</error>
+       <error code="204">Device Control: Error storing data of original automatic screen switching-off and dimming parameter values. Used the default values instead.</error>
+       <error code="205">Device Control: Error fetching data of original automatic screen switching-off and dimming parameter values. Used the default values instead.</error>
+       <error code="206">Device Control: Error changing automatic screen switching-off and dimming parameter values.</error>
+       <error code="207">Device Control: Error fetching data of original hardware key settings.</error>
+       <error code="208">Device Control: Error storing data of original hardware key settings.</error>
+       <error code="209">Device Control: Error changing hardware key settings.</error>
+       <error code="210">Device Control: Init script to auto launch the application was not installed/removed.</error>
+       <error code="211">Device Control: The application failed to know the current mode of itself.</error>
+       <error code="212">Device Control: The application failed to store the current mode of itself.</error>
+       <error code="213">Device Control: Error restarting the device. Restart device manually to activate operation mode change.</error>
 </errors>
index 009dbdd..aac84d4 100644 (file)
@@ -32,6 +32,8 @@ Engine::Engine() :
                iWindowManager( 0 ), iUIManager( 0 )
 {
        qDebug() << "Engine::Engine()";
+       iCommunicationFailed = false;
+       iCurrentWeekFetched = false;
        
        initConfiguration();
        initDevice();
@@ -107,7 +109,7 @@ void Engine::checkStatusOfAllRooms()
        for (int i = 0; i < iConfiguration->rooms().count(); i++)
        {
                // and check the status
-               roomStatusInfoNeeded(iConfiguration->rooms().at(i) );
+               roomStatusInfoNeeded( iConfiguration->rooms().at(i) );
        }
 }
 
@@ -164,39 +166,31 @@ 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 );
-}
-
-/*
-void Engine::fetchMeetings()
-{
-       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 );
+       if ( aRoom->equals( *(iCurrentRoom) ) )
+       {
+               emit roomStatusChanged( status, until );
+       }
 }
-*/
 
 void Engine::fetchMeetingDetails( Meeting *aMeeting )
 {
        qDebug() << "Engine::fetchMeetingDetails( Meeting* )";
-/*     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 );
 }
 
 void Engine::meetingsFetched( const QList<Meeting*> &aMeetings )
 {
        qDebug() << "Engine::meetingsFetched( const QList<Meeting*> & )";
-       
-       for ( int i = 0; i < iMeetings.count(); ++i ) {
+       // TODO: should check if this week's meetings were fetched
+       if( iCommunicationFailed || !iCurrentWeekFetched )
+       {
+               iCurrentWeekFetched = true;
+               iCommunicationFailed = false;
+               iUIManager->connectionEstablished();
+       }
+
+       for ( int i = 0; i < iMeetings.count(); ++i ) 
+       {
                Meeting* m = iMeetings.takeAt( i );
                delete m;
        }
@@ -207,11 +201,16 @@ void Engine::meetingsFetched( const QList<Meeting*> &aMeetings )
        }
 
        // refresh room status info
-       roomStatusInfoNeeded( defaultRoom() );
+       roomStatusInfoNeeded( iCurrentRoom /*defaultRoom()*/ );
 }
 
 void Engine::errorHandler( int aCode, const QString &aAddInfo )
 {      
+       if( aCode >= 100 && aCode < 150 )
+       {
+               iCommunicationFailed = true;
+               if ( iUIManager != 0 ) iUIManager->connectionLost();
+       }
        if ( iWindowManager != 0 )
        {
                iWindowManager->error( ErrorMapper::codeToString( aCode, aAddInfo ) );
@@ -236,24 +235,19 @@ void Engine::shownWeekChanged( QDate aFrom )
        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() );
+       iCommunication->fetchMeetings( from, to, *iCurrentRoom/*defaultRoom()*/ );
 }
 
-void Engine::changeDeviceMode( bool aChange )
+void Engine::changeDeviceMode()
 {
-       if ( aChange )
-       {
-               connect( iDevice, SIGNAL( changingModeFailed() ), this, SLOT( changeModeFailed() ) );
-               iAutoRefresh->stop(); // Stop the meeting update
-       }
-       iDevice->changeMode( aChange );
+       connect( iDevice, SIGNAL( changeModeFailed() ), this, SLOT( changeModeFailed() ) );
+       iAutoRefresh->stop(); // Stop the meeting update
+       iDevice->changeMode();
 }
 
 void Engine::changeModeFailed()
 {
        qDebug() << "Engine::progressBarCancelled()";
-       iDevice->changeMode( false );
        iAutoRefresh->start(); //we start the metting updating
 }
 
@@ -276,12 +270,15 @@ void Engine::initUserInterface()
        iWindowManager->show();
        iUIManager->showMainView();
        
+       // This triggers the meeting fetching
+       iUIManager->currentRoomChanged( this->iCurrentRoom );
+       
        qDebug() << "[Engine::initUserInterface] <Finished>";
 }
 
 void Engine::handleViewEvent()
 {
-       if ( iIdleTimeCounter != 0 )
+       if ( iIdleTimeCounter != 0 && iIdleTimeCounter->isActive())
        {
                // Restart the idle time counter when view event is received
                iIdleTimeCounter->stop();
@@ -369,5 +366,7 @@ void Engine::startIdleTimeCounter()
 
 void Engine::currentRoomChanged(Room *aRoom)
 {
+       qDebug() << "[Engine::currentRoomChanged] <invoked>";
        iCurrentRoom = aRoom;
-}
\ No newline at end of file
+       roomStatusInfoNeeded( iCurrentRoom );
+}
index 99992dd..6bacdd8 100644 (file)
@@ -41,6 +41,8 @@ public:
 
 signals:
 
+       void roomStatusChanged( Room::Status aStatus, QTime aUntil );
+
 private slots:
        //! Slot. Closes the application.
        /*!
@@ -67,12 +69,6 @@ private slots:
         * \param aAddInfo Possible addition info.
         */
        void errorHandler( int aCode, const QString &aAddInfo = "" );
-       //! Slot. Fetches meetings from the server.
-       /*!
-        * 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();
        //! 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
@@ -120,7 +116,7 @@ private slots:
        void stopIdleTimeCounter();
        void startIdleTimeCounter();
 
-       void changeDeviceMode( bool aChange );
+       void changeDeviceMode();
        
        void currentRoomChanged( Room *aRoom );
        
@@ -206,6 +202,8 @@ private:
        QList<Meeting*> iMeetings;
        
        Room *iCurrentRoom;
+       bool iCommunicationFailed;
+       bool iCurrentWeekFetched;
 };
 
 #endif /*ENGINE_H_*/
index e4cdc67..59db6d7 100644 (file)
@@ -37,16 +37,12 @@ UIManager::UIManager( Engine *aEngine, WindowManager *aWindowManager ) :
        if ( iEngine == 0 ) return;
        if ( iWindowManager == 0 ) return;
        
-       qDebug() << "[UIManager::ctor] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";
-       
        createWeeklyView();
        createSettingsView();
        createRoomStatusIndicator();
        createPasswordDialog();
        createProgressBar();
        createMeetingInfoDialog();
-       
-       qDebug() << "[UIManager::ctor] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";
 }
 
 UIManager::~UIManager()
@@ -67,15 +63,6 @@ void UIManager::showMainView()
        iWindowManager->showView( iWeeklyView );
 }
 
-void UIManager::showProgressBar( QString aText )
-{
-       if ( iProgressBar != 0 )
-       {
-               iProgressBar->update( aText );
-               iWindowManager->showDialog( iProgressBar );
-       }
-}
-
 // ===============================================
 //             INITIALIZE THE UIMANAGER
 void UIManager::createWeeklyView()
@@ -103,20 +90,20 @@ void UIManager::createSettingsView()
 
 void UIManager::createRoomStatusIndicator()
 {
-       iRoomStatusIndicator = new RoomStatusIndicatorWidget( iEngine->defaultRoom(), Room::FreeStatus, QTime::currentTime(), iEngine->iConfiguration->displaySettings()->dateFormat() );
+       iRoomStatusIndicator = new RoomStatusIndicatorWidget( iEngine->defaultRoom(), Room::FreeStatus, QTime::currentTime(), iEngine->iConfiguration->displaySettings()->timeFormat() );
+       connect( iEngine, SIGNAL( roomStatusChanged( Room::Status, QTime ) ), iRoomStatusIndicator, SLOT( statusChanged( Room::Status, QTime ) ) );
+       connect( iWeeklyView, SIGNAL( currentRoomChanged( Room * ) ), iRoomStatusIndicator, SLOT( currentRoomChanged( Room * ) ) );
 }
 
 void UIManager::createPasswordDialog()
 {
-       iPasswordDialog = new PasswordDialog( iEngine->iConfiguration->adminPassword(), tr("UIManager::createPasswordDialog"), tr("UIManager::createPasswordDialog") );
-       
+       iPasswordDialog = new PasswordDialog( iEngine->iConfiguration->adminPassword(), "", tr("Enter password") );
        connect( iPasswordDialog, SIGNAL( passwordEntered( PasswordDialog::PasswordStatus ) ), this, SLOT( passwordEntered( PasswordDialog::PasswordStatus ) ) );
 }
 
 void UIManager::createProgressBar()
 {
        iProgressBar = new ProgressBar( tr("CHANGE THIS"), true );
-       
        // Connect to UIManager
        connect( iProgressBar, SIGNAL( cancel() ), this, SLOT( progressBarCancelled() ) );
        // Connect to Engine
@@ -178,9 +165,9 @@ void UIManager::showMeetingProgressBar( Meeting *aMeeting )
 {
        if ( iProgressBar != 0 )
        {
-               iProgressBar->update( tr("Fetching meeting info...") );
+               iProgressBar->update( tr( "Fetching meeting info..." ), tr( "Please wait" ) );
+               iProgressBar->toggleCancellable( true );
                iWindowManager->showDialog( static_cast<QDialog *>( iProgressBar ), false, false );
-               iEngine->stopIdleTimeCounter();
        }
 }
 
@@ -220,26 +207,41 @@ void UIManager::progressBarCancelled()
        if ( iProgressBar != 0 )
        {
                iProgressBar->close();
-               iEngine->startIdleTimeCounter();
        }
 }
 
 void UIManager::changeModeOrdered( DeviceManager::OperationMode aMode )
 {
        qDebug() << "[UIManager::changeModeOrdered] <Invoked>";
-       
-       QString message = tr( "You are about to change operation mode to %1." )
-                               .arg( iEngine->iDevice->operationModeToString( aMode ) );
 
        if ( iPasswordDialog != 0 )
        {
-               // TODO : Set the new text for password dialog
+               QString text = tr( "You are about to change operation mode to %1." )
+                                               .arg( iEngine->iDevice->operationModeToString( aMode ) );
+               iPasswordDialog->update( text );
                iWindowManager->showDialog( static_cast<QDialog *>( iPasswordDialog ) );
        }
 }
 
+void UIManager::connectionLost()
+{
+       qDebug() << "UIManager::connectionLost()";
+       iWeeklyView->connectionLost();
+       iSettingsView->connectionLost();
+       iRoomStatusIndicator->connectionLost();
+}
+
+void UIManager::connectionEstablished()
+{
+       qDebug() << "UIManager::connectionEstablished()";
+       iWeeklyView->connectionEstablished();
+       iSettingsView->connectionEstablished();
+       iRoomStatusIndicator->connectionEstablished();
+}
+
 void UIManager::currentRoomChanged(Room *aRoom)
 {
+       qDebug() << "[UIManager::currentRoomChanged] <Invoked>";
        if ( iWeeklyView != 0 )
        {
                QDateTime from = QDateTime( iWeeklyView->beginnigOfShownWeek() );
@@ -254,6 +256,10 @@ void UIManager::updateTime(QDateTime aDateTime)
        {
                iWeeklyView->setCurrentDateTime( aDateTime );
        }
+       if ( iRoomStatusIndicator != 0 )
+       {
+               iRoomStatusIndicator->setCurrentTime( aDateTime.time() );
+       }
 }
 
 void UIManager::passwordEntered( PasswordDialog::PasswordStatus aStatus )
@@ -264,15 +270,17 @@ void UIManager::passwordEntered( PasswordDialog::PasswordStatus aStatus )
                        // Show the progress bar..
                        if ( iProgressBar != 0 )
                        {
-                               iWindowManager->showDialog( static_cast<QDialog *>( iProgressBar ), false );
+                               iProgressBar->update( tr( "" ), tr( "Changing operation mode" ) );
+                               iProgressBar->toggleCancellable( false );
+                               iWindowManager->showDialog( static_cast<QDialog *>( iProgressBar ), false, false );
                        }
                        // ... and initiate the mode changing
-                       iEngine->changeDeviceMode( true );
+                       iEngine->changeDeviceMode();
                        break;
                case PasswordDialog::Incorrect:
                        iWindowManager->error( tr("Incorrect Password") );
+                       break;
                case PasswordDialog::Canceled:
-                       iEngine->changeDeviceMode( false );
                        break;
        }
        
@@ -308,4 +316,4 @@ void UIManager::settingsCancelClicked()
                iWindowManager->showView( static_cast<ViewBase *>( iWeeklyView ) );
                iEngine->startIdleTimeCounter();
        }
-}
+}
\ No newline at end of file
index 0c40c2b..3a17d45 100644 (file)
@@ -18,6 +18,15 @@ class MeetingInfoDialog;
 class CommunicationManager;
 class QDateTime;
 
+//! User Interface manager class.
+/*!
+ * User Interface manager class that is responsible for handling
+ * UI actions. It creates the needed views and connects signals
+ * accordingly. All interactions with the UI is handled by this
+ * class. The Engine class handles the basic logic and does not
+ * know or care about the UI and this class does not know or care
+ * about the basic logic only UI related actions (signals, events etc.).
+ */
 class UIManager : public QObject
 {
        Q_OBJECT
@@ -26,27 +35,87 @@ public:
        UIManager( Engine *aEngine, WindowManager *aWindowManager );
        virtual ~UIManager();
        
+       //! Connects Device Managers signals.
+       /*!
+        * This method connects Device Managers signals directly to UI
+        * components or to it selft.
+        */
        void connectDeviceManager( DeviceManager *aDeviceManager );
+       //! Connects Communication Managers signals.
+       /*!
+        * This method connects Communication Managers signals directly to UI
+        * components or to it selft.
+        */
        void connectCommunicationManager( CommunicationManager *aCommunicationManager );
+       //! Shows the main view.
+       /*!
+        * Makes the main view visible trough WindowManager.
+        */
        void showMainView();
-       void showProgressBar( QString aText );
 
 signals:
        
 public slots:
 
+       //! Handles setting view request.
+       /*!
+        * Handles request to show settings view. Makes the
+        * view visible and stops the idle time counter.
+        */
        void settingsViewRequest();
+       //! Handles setting views ok clicked.
+       /*!
+        * Handles the setting views Ok button clicked
+        * signal. Sets the weekly view visible and starts
+        * the idle time counter.
+        */
        void settingsOkClicked();
+       //! Handles setting views cancel clicked.
+       /*!
+        * Handles the setting views Cancel button clicked
+        * signal. Sets the weekly view visible and starts
+        * the idle time counter.
+        */
        void settingsCancelClicked();
+       //! Handles room status indicator view request.
+       /*!
+        * Handles the request to show room status indicator
+        * view. Sets the view visible and stops the idle
+        * time counter. The WindowManager handles restoring
+        * what ever view was previously visible.
+        */
        void roomStatusIndicatorRequested();
+       //! Handles previousViewRestored signal.
+       /*!
+        * Handles the restoring of previous view. This is usually
+        * signaled by WindowManager when room status indicator
+        * view is being hidden.
+        */
        void previousViewRestored();
+       //! Handle change mode order.
+       /*!
+        * Handles change mode order. Displays the password query dialog
+        * and waits for its response.
+        */
        void changeModeOrdered( DeviceManager::OperationMode aMode );
+       //! Handles select room change.
+       /*!
+        * Handles the changing of currently select room. Engine is requested
+        * to start fetching new meetings for currently shown week.
+        */
+       void currentRoomChanged( Room *aRoom );
+
+       //! Shows any view specific indicators for connection error
+       void connectionLost();
+       
+       //! Removes any view specific indicators for connection error
+       void connectionEstablished();
+       
        
 private slots:
 
        void meetingsFetched( const QList<Meeting*> &aMeetings );
        void meetingDetailsFetched( Meeting &aDetailedMeeting );
-       void currentRoomChanged( Room *aRoom );
        void progressBarCancelled();
        void updateTime( QDateTime aDateTime );
        void passwordEntered( PasswordDialog::PasswordStatus aStatus );
index 54648ca..2a33998 100644 (file)
@@ -155,7 +155,6 @@ void Configuration::saveConnectionSettings( const QDomNode &aXML )
        {
                QDomElement e = node.toElement();
                QString tagName = e.tagName().toLower();
-
                if ( tagName == QString( "serverurl" ) )
                {
                        QDomText t = node.ownerDocument().createTextNode( iConnectionSettings->serverUrl().toString() );
@@ -211,7 +210,7 @@ void Configuration::saveRooms( const QDomNode &aXML )
        int count = root.childNodes().count();
        QDomNode node = root.firstChild();
        QDomNode next;
-       for (int i=0; i<count; i++)
+       for (int i = 0; i < count; i++)
        {
                qDebug() << "remove " << node.toElement().text();
                next = node.nextSibling();
index 8174ef7..c941c7d 100644 (file)
@@ -93,12 +93,10 @@ void CommunicationManager::fetchMeetingDetails( Meeting& aMeeting )
 
 void CommunicationManager::cancelFetchMeetingDetails()
 {
-       const RequestData *rd = NULL;
-       for( rd = findRequest( GetCalendarItem );rd != NULL; )
-       {
-               int id =  rd->requestId;
+       const RequestData *rd = findRequest( GetCalendarItem );
+       if( rd != NULL ) {
+               int id = rd->requestId;
                iCancelledRequests.append( id );
-               rd = findRequest( GetCalendarItem );
        }
 }
 
index 76e17ce..4ac495e 100644 (file)
@@ -19,6 +19,8 @@ DeviceConfigurator::~DeviceConfigurator()
 bool DeviceConfigurator::toggleScreenSwitchOff( bool aEnable )
 {      
        qDebug() << "DeviceConfigurator::toggleScreenSwitchOff( bool )";
+       emit configuringError( DeviceManager::ScreenSettingsNotChanged );
+       return false;
        QString command = "gconftool-2";
        QStringList args;
        QByteArray result;
index 3db5db7..518a7d3 100644 (file)
@@ -9,7 +9,13 @@
 #include <QtDebug>
 #include <QStringList>
 
-DeviceManager::DeviceManager( StartupSettings *aSettings )
+DeviceManager::DeviceManager( StartupSettings *aSettings ) :
+       iAlarmSender( 0 ),
+       iHWKeyListener( 0 ),
+       iSettings( 0 ),
+       iDataStorage( 0 ),
+       iConfigurator( 0 ),
+       iModeToggler( 0 )
 {
        qDebug() << "DeviceManager::DeviceManager( StartupSettings * )";
 
@@ -35,6 +41,9 @@ DeviceManager::~DeviceManager()
 void DeviceManager::initDeviceManager()
 {
        qDebug() << "DeviceManager::init()";
+       
+       qRegisterMetaType<DeviceManager::ErrorCode>("DeviceManager::ErrorCode");
+       
        iDataStorage = new DeviceDataStorage();
        connect( iDataStorage, SIGNAL( dataStorageInitFailed( DeviceManager::ErrorCode ) ),
                        this, SLOT( errorSender( DeviceManager::ErrorCode ) ) );
@@ -51,7 +60,7 @@ void DeviceManager::initDeviceManager()
                iMode = EmptyMode;
 
        iHWKeyListener = new HWKeyListener();
-       handleKeyPresses( true );
+       handleHWKeyPresses( true );
 }
 
 DeviceManager::OperationMode DeviceManager::currentOperationMode()
@@ -72,20 +81,18 @@ QString DeviceManager::operationModeToString( OperationMode aMode )
        }
 }
 
-void DeviceManager::changeMode( bool aChange )
+void DeviceManager::changeMode()
 {
        qDebug() << "void DeviceManager::changeMode()";
-       if( !aChange ) {
-               handleKeyPresses( true );
-               return;
+       if( iModeToggler == 0 ) {
+               iModeToggler = new OperationModeToggler( iMode, iSettings, iAlarmSender, iConfigurator, iDataStorage );
+               connect( iModeToggler, SIGNAL( finished() ), this, SLOT( modeChanged() ) );
+               connect( iModeToggler, SIGNAL( error( DeviceManager::ErrorCode, const QString & ) ),
+                               this, SLOT( errorSender( DeviceManager::ErrorCode, const QString & ) ) );
+               connect( iModeToggler, SIGNAL( changingMode( const QString & ) ), this, SIGNAL( changingMode( const QString & ) ) );
+               connect( iModeToggler, SIGNAL( toggleErrorSending( bool ) ), this, SLOT( toggleErrorSending( bool ) ) );
+               iModeToggler->start();
        }
-       iModeToggler = new OperationModeToggler( iMode, iSettings, iAlarmSender, iConfigurator, iDataStorage );
-       connect( iModeToggler, SIGNAL( finished() ), this, SLOT( modeChanged() ) );
-       connect( iModeToggler, SIGNAL( error( DeviceManager::ErrorCode, const QString & ) ),
-                       this, SLOT( errorSender( DeviceManager::ErrorCode, const QString & ) ) );
-       connect( iModeToggler, SIGNAL( changingMode( const QString & ) ), this, SIGNAL( changingMode( const QString & ) ) );
-       connect( iModeToggler, SIGNAL( toggleErrorSending( bool ) ), this, SLOT( toggleErrorSending( bool ) ) );
-       iModeToggler->start();
 }
 
 bool DeviceManager::setCurrentOperationMode()
@@ -126,25 +133,14 @@ bool DeviceManager::finalizeStandAloneMode()
        return true;
 }
 
-void DeviceManager::handleKeyPresses( bool aHandle )
-{
-       qDebug() << "DeviceManager::handleKeyPresses( bool )";
-       if ( !aHandle )
-               disconnect( iHWKeyListener, SIGNAL( HWKeyFullScreenPressed() ), this, SLOT( HWKeyFullScreenPressed() ) );
-       else
-               connect( iHWKeyListener, SIGNAL( HWKeyFullScreenPressed() ), this, SLOT( HWKeyFullScreenPressed() ) );
-}
-
 void DeviceManager::HWKeyFullScreenPressed()
 {
        qDebug() << "DeviceManager::HWKeyFullScreenPressed()";
-       
+       handleHWKeyPresses( false );
        // no more key presses before this one is handled
-       handleKeyPresses( false );
-       
+       //handleKeyPresses( false );
        OperationMode nextMode;
-       switch ( iMode )
-       {
+       switch ( iMode ) {
                case KioskMode:
                        nextMode = StandAloneMode;
                        break;
@@ -157,8 +153,6 @@ void DeviceManager::HWKeyFullScreenPressed()
        }
        if ( nextMode != EmptyMode )
                emit changeModeOrdered( nextMode );
-       else
-               handleKeyPresses( true );
 }
 
 void DeviceManager::errorSender( DeviceManager::ErrorCode aErrorCode, const QString &aAddInfo )
@@ -181,14 +175,24 @@ void DeviceManager::modeChanged()
 {
        qDebug() << "DeviceManager::modeChanged()";
        if( iModeToggler != 0 ) {
-               if ( iModeToggler->success() ) //mode changing went well
+               if ( iModeToggler->success() ) {//mode changing went well
+                       emit changingMode( "Restarting device" );
+                       sleep( 2 );
                        iConfigurator->restartDevice();
+               }
                else
                        emit changeModeFailed();
                delete iModeToggler;
                iModeToggler = 0;
        }
-       
-       //in case device restarting fails we just continue
-       handleKeyPresses( true );
+       handleHWKeyPresses( true );
+}
+
+void DeviceManager::handleHWKeyPresses( bool aToggle )
+{
+       qDebug() << "DeviceManager::handleHWKeyPresses( bool )";
+       if( aToggle )
+               connect( iHWKeyListener, SIGNAL( HWKeyFullScreenPressed() ), this, SLOT( HWKeyFullScreenPressed() ) );
+       else
+               disconnect( iHWKeyListener, SIGNAL( HWKeyFullScreenPressed() ), this, SLOT( HWKeyFullScreenPressed() ) );
 }
index 267cf96..2c7531a 100644 (file)
@@ -90,9 +90,9 @@ public:
        //! Changes the operation mode.
        /*!
         * Changes the operation mode.
-        * \param aChange To indicate if the mode should be changed or not
         */
-       void changeMode( bool aChange );
+       void changeMode();
+       void handleHWKeyPresses( bool aToggle );
 
 signals:
        //! Signal. Emitted if user tries to change the operation mode.
@@ -164,13 +164,6 @@ private:
         * \return True if operation mode storing and deactivation of the init script succeed; otherwise, false.
         */
        bool finalizeStandAloneMode();
-       //! Connects/disconnects the HWKeyListener signals to the private HWKeyFullScreenPressed() slot.
-       /*!
-        * Connects/disconnects the HWKeyListener signals to the private HWKeyFullScreenPressed() slot. In case
-        * a signal is caught the connection is disabled until the signal handling is finished.
-        * \param aHandle indicates if the signals should be connected or not.
-        */
-       void handleKeyPresses( bool aHandle );
 
 private:
        AlarmSender *iAlarmSender;
index 2029f79..648934b 100644 (file)
@@ -17,7 +17,7 @@ HWKeyListener::~HWKeyListener()
 
 bool HWKeyListener::eventFilter( QObject*, QEvent* e )
 {
-       if ( e->type() == QEvent::KeyPress )
+       if ( e->type() == QEvent::KeyRelease )
        {
                QKeyEvent *keyEvent = static_cast<QKeyEvent *>( e );
                switch ( keyEvent->key() )
index cfa5d5d..14f13aa 100644 (file)
@@ -22,15 +22,6 @@ OperationModeToggler::OperationModeToggler(
        iSuccess( true )
 {
        qDebug() << "OperationModeToggler::OperationModeToggler( ... )";
-       
-       qRegisterMetaType<DeviceManager::ErrorCode>("DeviceManager::ErrorCode");
-       
-       connect( iAlarmSender, SIGNAL( alarmSendingFailed( DeviceManager::ErrorCode, const QString& ) ),
-                       this, SIGNAL( error( DeviceManager::ErrorCode, const QString& ) ) );
-       connect( iConfigurator, SIGNAL( configuringError( DeviceManager::ErrorCode ) ),
-                       this, SLOT( createError( DeviceManager::ErrorCode ) ) );
-       connect( iDataStorage, SIGNAL( dataStorageInitFailed( DeviceManager::ErrorCode ) ),
-                       this, SLOT( createError( DeviceManager::ErrorCode ) ) );
 }
 
 OperationModeToggler::~OperationModeToggler()
@@ -58,6 +49,7 @@ void OperationModeToggler::run()
                                if ( !iAlarmSender->sendAlarms( iSettings->turnOnAt(), iSettings->turnOffAt() ) )
                                {
                                        iSuccess = false;
+                                       emit changingMode( "Rolling back changes..." );
                                        return; //this is critical so returning if no success
                                }
                        }
@@ -95,6 +87,7 @@ void OperationModeToggler::run()
                                // we have to roll back if something fails
                                // of course rolling back may fail as well but it is impossible to catch
                                emit toggleErrorSending( false );
+                               emit changingMode( "Rolling back changes..." );
                                iAlarmSender->removeAlarms();
                                iConfigurator->toggleHWKeys( true );
                                iConfigurator->toggleInitScript( false );
@@ -139,6 +132,7 @@ void OperationModeToggler::run()
                                // we have to roll back if something fails
                                // of course rolling back may fail as well but it is impossible to catch
                                emit toggleErrorSending( false );
+                               emit changingMode( "Rolling back changes..." );
                                iConfigurator->toggleHWKeys( false );
                                iConfigurator->toggleInitScript( true );
                                iConfigurator->toggleScreenSwitchOff( false );
index a31616b..064c7d3 100644 (file)
@@ -28,12 +28,9 @@ PasswordDialog::PasswordDialog( const QString &aPassword, const QString &aText,
 
        QVBoxLayout *layout = new QVBoxLayout;
 
-       if ( !aText.isNull() )
-       {
-               QLabel *text = new QLabel( aText );
-               layout->addWidget( text );
-               layout->addStretch();
-       }
+       iText = new QLabel( aText );
+       layout->addWidget( iText );
+       layout->addStretch();
 
        iPasswordEdit = new QLineEdit;
        iPasswordEdit->setEchoMode( QLineEdit::Password );
@@ -51,8 +48,8 @@ PasswordDialog::PasswordDialog( const QString &aPassword, const QString &aText,
        layout->addLayout( buttonLayout );
 
        // Connect the user action signals to corresponding slots
-       connect( buttonOK, SIGNAL( pressed() ), this, SLOT( okButtonPressed() ) );
-       connect( buttonCancel, SIGNAL( pressed() ), this, SLOT( cancelButtonPressed() ) );
+       connect( buttonOK, SIGNAL( released() ), this, SLOT( okButtonPressed() ) );
+       connect( buttonCancel, SIGNAL( released() ), this, SLOT( cancelButtonPressed() ) );
 
        // Enable the layout
        setLayout( layout );
@@ -95,3 +92,8 @@ void PasswordDialog::cancelButtonPressed()
        emit passwordEntered( PasswordDialog::Canceled );
 }
 
+void PasswordDialog::update( const QString &aText )
+{
+       qDebug() << "PasswordDialog::update()";
+       iText->setText( aText );
+}
index 686523b..c62223c 100644 (file)
@@ -4,6 +4,7 @@
 #include <QDialog>
 
 class QLineEdit;
+class QLabel;
 class QByteArray;
 
 //! UserInterface class. Responsible for poping-up password query on the screen.
@@ -26,6 +27,22 @@ public:
                Incorrect, /*!< Incorrect password. */
                Canceled
        };
+       
+       //! Constructor.
+       /*!
+        * Constructor to initialize a PasswordDialog instance.
+        * \param aParent The parent object.
+        * \param aPassword The password.
+        */
+       PasswordDialog( const QString &aPassword, const QString &aText, const QString &aTitle = "", QWidget *aParent = 0 );
+       //! Destructor.
+       virtual ~PasswordDialog();
+       //! Updates the text of the password dialog label.
+       /*!
+        * Updates the text of the password dialog label.
+        * \param aText The text for the label.
+        */
+       void update( const QString &aText );
 
 signals:
        //! Signals the authenticity of the password when the uuser dismisses the dialog.
@@ -39,18 +56,9 @@ private slots:
        void okButtonPressed();
        void cancelButtonPressed();
 
-public:
-       //! Constructor.
-       /*!
-        * Constructor to initialize a PasswordDialog instance.
-        * \param aParent The parent object.
-        * \param aPassword The password.
-        */
-       PasswordDialog( const QString &aPassword, const QString &aText, const QString &aTitle = "", QWidget *aParent = 0 );
-       //! Destructor.
-       virtual ~PasswordDialog();
-
+private:
        QLineEdit *iPasswordEdit;
+       QLabel *iText;
        QByteArray iPasswordHash;
 };
 
index 6ab9fe2..dd9f94f 100755 (executable)
@@ -8,11 +8,12 @@
 #include <QLabel>
 #include <QtDebug>
 
-ProgressBar::ProgressBar( const QString &aText, bool aCancellable, QWidget *aParent ) :
+ProgressBar::ProgressBar( const QString &aTitle, bool aCancellable, QWidget *aParent ) :
        QDialog( aParent )
 {
        qDebug() << "ProgressBar::ProgressBar( const QString &, bool, QWidget *)";
-       setWindowTitle( aText );
+       setWindowTitle( aTitle );
+       
        setModal( true );
 
        iProgress = new QProgressBar();
@@ -26,12 +27,15 @@ ProgressBar::ProgressBar( const QString &aText, bool aCancellable, QWidget *aPar
        mainLayout->addWidget( iLabel );
        QHBoxLayout *subLayout = new QHBoxLayout;
        subLayout->addWidget( iProgress );
-       if( aCancellable ) {
-               QPushButton *buttonCancel = new QPushButton( tr( "Cancel" ) );
-               subLayout->addSpacing( 5 );
-               subLayout->addWidget( buttonCancel );
-               connect( buttonCancel, SIGNAL( pressed() ), this, SIGNAL( cancel() ) );
+       
+       iButton = new QPushButton( tr( "Cancel" ) );
+       subLayout->addSpacing( 5 );
+       subLayout->addWidget( iButton );
+       connect( iButton, SIGNAL( pressed() ), this, SIGNAL( cancel() ) );
+       if( !aCancellable ) {
+               iButton->setVisible( false );
        }
+       
        mainLayout->addLayout( subLayout );
        mainLayout->setAlignment( Qt::AlignCenter );
        setLayout( mainLayout );
@@ -42,8 +46,18 @@ ProgressBar::~ProgressBar()
        qDebug() << "ProgressBar::~ProgressBar()";
 }
 
-void ProgressBar::update( const QString &aMessage )
+void ProgressBar::update( const QString &aMessage, const QString &aTitle )
 {
        qDebug() << "ProgressBar::update( const QString & )";
        iLabel->setText( aMessage );
+       if( aTitle != "" )
+               setWindowTitle( aTitle );
+}
+
+void ProgressBar::toggleCancellable( bool aEnable )
+{
+       if( aEnable )
+               iButton->setVisible( true );
+       else
+               iButton->setVisible( false );
 }
index bf573cd..ec52bf5 100755 (executable)
@@ -5,6 +5,7 @@
 
 class QProgressBar;
 class QLabel;
+class QPushButton;
 
 //! UserInterface class.
 /*!
@@ -20,13 +21,20 @@ public:
        /*!
         * Constructor to initialize the StatusWidget instance.
         * \param aParent Parent object.
-        * \param aText Title string to be set to the progress bar.
+        * \param aTitle Title string to be set to the progress bar.
         */
-       ProgressBar( const QString &aText, bool aCancellable = false, QWidget *aParent = 0 );
+       ProgressBar( const QString &aTitle, bool aCancellable = false, QWidget *aParent = 0 );
        //! Destructor.
        virtual ~ProgressBar();
+       //! Updates the text fields of progress bar dialog.
+       /*!
+        * Updates the text fields of progress bar dialog.
+        * \param aMessage The text for the label of the dialog.
+        * \param aTitle Title string to be set to the progress bar.
+        */
+       void update( const QString &aMessage, const QString &aTitle = "" );
        
-       void update( const QString &aMessage );
+       void toggleCancellable( bool aEnable );
 
 signals:
        //! Signal. Emitted if user presses cancel button.
@@ -39,6 +47,7 @@ signals:
 private:
        QProgressBar *iProgress;
        QLabel *iLabel;
+       QPushButton *iButton;
 
 };
 
index c903bc0..a1f75a1 100644 (file)
-#include "RoomStatusIndicatorWidget.h"\r
-\r
-#include <QLabel>\r
-#include <QFont>\r
-#include <QVBoxLayout>\r
-#include "DigitalTimeDisplayWidget.h"\r
-#include "ToolBox.h"\r
-\r
-#include <QtDebug>\r
-\r
-QTime RoomStatusIndicatorWidget::endOfTheDay = QTime( 23, 59, 0, 0 );\r
-\r
-RoomStatusIndicatorWidget::RoomStatusIndicatorWidget( Room *aDefaultRoom, Room::Status aStatus, QTime aUntil, QString aTimeFormat, QWidget *aParent ) :\r
-               ViewBase( ViewBase::ObservedView, aParent ), iTimeFormat( aTimeFormat )\r
-{\r
-       QFont importantTextFont;\r
-       //importantTextFont.setBold( true );\r
-       importantTextFont.setPointSize( 20 );\r
-\r
-       QFont regularTextFont;\r
-       //regularTextFont.setBold( true );\r
-       regularTextFont.setPointSize( 12 );\r
-\r
-       // display for current time\r
-       // Note: the time display receives current time info from Engine::clock()\r
-       iTimeDisplay = new DigitalTimeDisplayWidget( QTime::currentTime(), iTimeFormat, this );\r
-       iTimeDisplay->setFrameVisible( false );\r
-       iTimeDisplay->setSize( 250, 120 );\r
-\r
-       // Pegasus\r
-       iDefaultRoomLabel = ToolBox::createLabel( aDefaultRoom->name(), importantTextFont );\r
-       iDefaultRoomLabel->setAlignment( Qt::AlignHCenter );\r
-       iDefaultRoomLabel->setStyleSheet( "background-color: transparent" );\r
-       // is busy\r
-       iStatusLabel = ToolBox::createLabel( tr( "is %1" ).arg( statusToText( aStatus ) ), importantTextFont );\r
-       iStatusLabel->setAlignment( Qt::AlignHCenter );\r
-       iStatusLabel->setStyleSheet( "background-color: transparent" );\r
-\r
-       // until 13:22\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
-       QVBoxLayout *topLayout = new QVBoxLayout;\r
-       topLayout->addStretch();\r
-       topLayout->addWidget( iTimeDisplay );\r
-       topLayout->addWidget( iDefaultRoomLabel );\r
-       topLayout->addWidget( iStatusLabel );\r
-       topLayout->addWidget( iUntilTextLabel );\r
-       topLayout->addStretch();\r
-\r
-       QHBoxLayout *mainLayout = new QHBoxLayout;\r
-       mainLayout->addLayout( topLayout );\r
-       mainLayout->addStretch();\r
-       mainLayout->setMargin( 65 );\r
-       setLayout( mainLayout );\r
-\r
-       statusChanged( aStatus, aUntil );\r
-\r
-       setFocusPolicy( Qt::StrongFocus );\r
-       setEnabled( true ); // enable mouse & key events\r
-}\r
-\r
-RoomStatusIndicatorWidget::~RoomStatusIndicatorWidget()\r
-{\r
-       delete iTimeDisplay;\r
-       iTimeDisplay = 0;\r
-}\r
-\r
-QString RoomStatusIndicatorWidget::statusToText( const Room::Status aStatus )\r
-{\r
-       return ( aStatus == Room::BusyStatus ) ? tr( "busy" ) : tr( "free" );\r
-}\r
-\r
-QPalette RoomStatusIndicatorWidget::createPalette( Room::Status aStatus )\r
-{\r
-       QPixmap pixmap( aStatus == Room::BusyStatus ? ":roomstatus_busy" : ":roomstatus_free" );\r
-\r
-       // The image needs to be moved in normal mode so the traffic light not partly outside the screen\r
-       const int xoffset( 60 );\r
-       const int yoffset( 19 );\r
-       int cropwidth( pixmap.width() - xoffset );\r
-       int cropheight( pixmap.height() - yoffset );\r
-       \r
-       QBrush brush;\r
-       if ( windowState() == Qt::WindowFullScreen )\r
-       {\r
-               // Use the full image in full screen mode\r
-               brush.setTexture( pixmap );\r
-       }\r
-       else\r
-       {\r
-               // Take part of the image so the traffic lights are moved xoffset poxels to left \r
-               // and yoffset pixels to up\r
-               brush.setTexture( pixmap.copy( xoffset, yoffset, cropwidth, cropheight ) );\r
-       }\r
-\r
-       QPalette palette;\r
-       palette.setBrush( QPalette::Window, brush );\r
-       return palette;\r
-}\r
-\r
-void RoomStatusIndicatorWidget::setCurrentTime( QTime aCurrentTime )\r
-{\r
-       iTimeDisplay->setTime( aCurrentTime );\r
-}\r
-\r
-void RoomStatusIndicatorWidget::statusChanged( const Room::Status aStatus, const QTime aUntil )\r
-{\r
-       iStatusLabel->setText( tr( "is %1" ).arg( statusToText( aStatus ) ) );\r
-       if ( aUntil == RoomStatusIndicatorWidget::endOfTheDay )\r
-       {\r
-               iUntilTextLabel->setText( tr( "whole day." ) );\r
-       }\r
-       else\r
-       {\r
-               iUntilTextLabel->setText( tr( "until %1" ).arg( aUntil.toString( iTimeFormat ) ) );\r
-       }\r
-       setPalette( createPalette( aStatus ) );\r
-}\r
+#include "RoomStatusIndicatorWidget.h"
+
+#include <QLabel>
+#include <QFont>
+#include <QVBoxLayout>
+#include "DigitalTimeDisplayWidget.h"
+#include "ToolBox.h"
+
+#include <QEvent>
+
+#include <QtDebug>
+
+QTime RoomStatusIndicatorWidget::endOfTheDay = QTime( 23, 59, 0, 0 );
+
+RoomStatusIndicatorWidget::RoomStatusIndicatorWidget( Room *aDefaultRoom, Room::Status aStatus, QTime aUntil, QString aTimeFormat, QWidget *aParent ) :
+               ViewBase( ViewBase::ObservedView, aParent ), iTimeFormat( aTimeFormat )
+{
+       QFont importantTextFont;
+       //importantTextFont.setBold( true );
+       importantTextFont.setPointSize( 20 );
+
+       QFont regularTextFont;
+       //regularTextFont.setBold( true );
+       regularTextFont.setPointSize( 12 );
+
+       // display for current time
+       // Note: the time display receives current time info from Engine::clock()
+       iTimeDisplay = new DigitalTimeDisplayWidget( QTime::currentTime(), iTimeFormat, this );
+       iTimeDisplay->setFrameVisible( false );
+       iTimeDisplay->setSize( 250, 120 );
+
+       // Pegasus
+       iDefaultRoomLabel = ToolBox::createLabel( aDefaultRoom->name(), importantTextFont );
+       iDefaultRoomLabel->setAlignment( Qt::AlignHCenter );
+       iDefaultRoomLabel->setStyleSheet( "background-color: transparent" );
+       iDefaultRoomLabel->setHidden( true );
+       
+       // is busy
+       iStatusLabel = ToolBox::createLabel( tr( "is %1" ).arg( statusToText( aStatus ) ), importantTextFont );
+       iStatusLabel->setAlignment( Qt::AlignHCenter );
+       iStatusLabel->setStyleSheet( "background-color: transparent" );
+       iStatusLabel->setHidden( true );
+
+       // until 13:22
+       iUntilTextLabel = ToolBox::createLabel( tr( "until %1" ).arg( aUntil.toString( iTimeFormat ) ), importantTextFont );
+       iUntilTextLabel->setAlignment( Qt::AlignHCenter );
+       iUntilTextLabel->setStyleSheet( "background-color: transparent" );
+       iUntilTextLabel->setHidden( true );
+       
+       // No connection to server note
+       qDebug() << "RoomStatusIndicatorWidget::RoomStatusIndicatorWidget() creating connection label";
+       QFrame* connectionLabelFrame = new QFrame( this );
+       iConnectionLabel = new QLabel( tr( "No connection to server" ), connectionLabelFrame );
+       iConnectionLabel->setFont( importantTextFont ); 
+       iConnectionLabel->setAlignment( Qt::AlignHCenter );
+       iConnectionLabel->setWordWrap( true );
+       iConnectionLabel->setStyleSheet( "background-color: transparent; color: red; text-decoration:blink; max-width: 250px" );
+       connectionLabelFrame->setFixedSize( iConnectionLabel->sizeHint() );
+       if( connectedOnce && !connectionError ) iConnectionLabel->setHidden( true );
+               
+
+       QVBoxLayout *topLayout = new QVBoxLayout;
+       topLayout->addStretch();
+       topLayout->addWidget( iTimeDisplay );
+       topLayout->addSpacing( 28 );
+       topLayout->addWidget( iDefaultRoomLabel );
+       topLayout->addWidget( iStatusLabel );
+       topLayout->addWidget( iUntilTextLabel );
+       topLayout->addSpacing( 28 );
+       topLayout->addWidget( connectionLabelFrame );
+       topLayout->addStretch();
+
+       QHBoxLayout *mainLayout = new QHBoxLayout;
+       mainLayout->addLayout( topLayout );
+       mainLayout->addStretch();
+       //mainLayout->setMargin( 65 );
+       mainLayout->setContentsMargins( 65, 65, 65, 0 );
+       setLayout( mainLayout );
+
+       statusChanged( aStatus, aUntil );
+
+       setFocusPolicy( Qt::StrongFocus );
+       setEnabled( true ); // enable mouse & key events
+}
+
+RoomStatusIndicatorWidget::~RoomStatusIndicatorWidget()
+{
+       delete iTimeDisplay;
+       iTimeDisplay = 0;
+}
+
+QString RoomStatusIndicatorWidget::statusToText( const Room::Status aStatus )
+{
+       return ( aStatus == Room::BusyStatus ) ? tr( "busy" ) : tr( "free" );
+}
+
+QPalette RoomStatusIndicatorWidget::createPalette( Room::Status aStatus )
+{
+       QString image = aStatus == Room::BusyStatus ? ":roomstatus_busy" : ":roomstatus_free";
+       QPixmap pixmap( image );
+
+       // The image needs to be moved in normal mode so the traffic light not partly outside the screen
+       const int xoffset( 60 );
+       const int yoffset( 19 );
+       int cropwidth( pixmap.width() - xoffset );
+       int cropheight( pixmap.height() - yoffset );
+       
+       QBrush brush;
+       if ( windowState() == Qt::WindowFullScreen )
+       {
+               // Use the full image in full screen mode
+               brush.setTexture( pixmap );
+       }
+       else
+       {
+               // Take part of the image so the traffic lights are moved xoffset poxels to left 
+               // and yoffset pixels to up
+               brush.setTexture( pixmap.copy( xoffset, yoffset, cropwidth, cropheight ) );
+       }
+
+       QPalette palette;
+       palette.setBrush( QPalette::Window, brush );
+       return palette;
+}
+
+void RoomStatusIndicatorWidget::setCurrentTime( QTime aCurrentTime )
+{
+       iTimeDisplay->setTime( aCurrentTime );
+}
+
+void RoomStatusIndicatorWidget::statusChanged( const Room::Status aStatus, const QTime aUntil )
+{
+       iStatusLabel->setText( tr( "is %1" ).arg( statusToText( aStatus ) ) );
+       if ( aUntil == RoomStatusIndicatorWidget::endOfTheDay )
+       {
+               iUntilTextLabel->setText( tr( "whole day." ) );
+       }
+       else
+       {
+               iUntilTextLabel->setText( tr( "until %1" ).arg( aUntil.toString( iTimeFormat ) ) );
+       }
+       setPalette( createPalette( aStatus ) );
+}
+
+void RoomStatusIndicatorWidget::currentRoomChanged( Room *aRoom )
+{
+       iDefaultRoomLabel->setText( aRoom->name() );
+}
+
+bool RoomStatusIndicatorWidget::event(QEvent *event)
+{
+       switch(event->type())
+       {
+               case QEvent::Paint:
+                       qDebug() << "[RoomStatusIndicatorWidget::event] <Paint event>";
+                       break;
+               case QEvent::PaletteChange:
+                       qDebug() << "[RoomStatusIndicatorWidget::event] <Palette change event>";
+                       break;
+               default:
+                       break;
+       }
+       
+       return ViewBase::event( event );
+}
index c20ce45..643160a 100644 (file)
@@ -12,6 +12,8 @@ class QLabel;
 class QVBoxLayout;\r
 class TimeDisplayWidget;\r
 \r
+class QEvent;\r
+\r
 //! UserInterface class. Indicates if the default meeting room is busy or not.\r
 /*!\r
  * UserInterface class. Indicates if the default meeting room is busy or not. This widget\r
@@ -37,6 +39,8 @@ public:
        RoomStatusIndicatorWidget( Room *aDefaultRoom, Room::Status aStatus, QTime aUntil, QString aTimeFormat, QWidget *aParent = 0 );\r
        //! Destructor.\r
        virtual ~RoomStatusIndicatorWidget();\r
+       \r
+       bool event(QEvent *event);\r
 \r
 public slots:\r
        //! Slot. Sets current time.\r
@@ -56,8 +60,14 @@ public slots:
         */\r
        void statusChanged( const Room::Status aStatus, const QTime aUntil );\r
        \r
+       void currentRoomChanged( Room *aRoom );\r
+       \r
        void viewResized(const QSize &newSize, const QSize &oldSize) { }\r
 \r
+       void connectionEstablished();\r
+       \r
+       void connectionLost();\r
+       \r
 private:\r
        //! Translates the status into human readable text.\r
        /*!\r
@@ -78,6 +88,7 @@ private:
        QLabel *iDefaultRoomLabel;\r
        QLabel *iStatusLabel;\r
        QLabel *iUntilTextLabel;\r
+       QLabel *iConnectionLabel;\r
        TimeDisplayWidget *iTimeDisplay;\r
        QString iTimeFormat;\r
 \r
index 24d6461..14c51aa 100644 (file)
@@ -12,7 +12,8 @@
 
 ViewBase::ViewBase( ViewBase::ViewMode aMode, QWidget *aParent ) : QWidget( aParent ), iViewMode( aMode )
 {
-
+       connectedOnce = false;
+       connectionError = false;
 }
 
 ViewBase::~ViewBase()
@@ -25,6 +26,18 @@ ViewBase::ViewMode ViewBase::viewMode()
        return iViewMode;
 }
 
+void ViewBase::connectionEstablished()
+{
+       connectedOnce = true;
+       connectionError = false;
+}
+
+void ViewBase::connectionLost()
+{
+       connectionError = true;
+}
+
+
 bool ViewBase::event(QEvent *event)
 {
        switch( event->type() )
index 631a089..2a7b73e 100644 (file)
@@ -51,6 +51,10 @@ public slots:
         */
        virtual void viewResized(const QSize &newSize, const QSize &oldSize) = 0;
        
+       void connectionEstablished();
+       
+       void connectionLost();
+       
 signals:
        /*!
         * This signal indicates that some user initiated event has occured.
@@ -60,10 +64,12 @@ signals:
        
 protected:
        void observeChild(QWidget *aChild);
+       bool connectionError; // true if last connection attempt failed
+       // TODO: connectedOnce should actually indicate if the current week has been fetched at least once
+       bool connectedOnce;     // true if connection has been formed at least once
        
 private:
        ViewMode iViewMode;
-       
 };
 
 #endif /*VIEWBASE_*/
index 2f46050..aa736cf 100644 (file)
-#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 <QWidget>
+#include <QStack>
+
+// Forward declarations
+class ViewBase;
+class QEvent;
+class QSize;
+class QDialog;
+class QString;
+
+//! UserInterface class. Manages displayed views.
+/*!
+ * 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 QWidget
+{
+       Q_OBJECT
+
+public:
+       //! Constructor.
+       /*!
+        * Constructor of WindowManager.
+        */
+       WindowManager( QWidget *aParent = 0 );
+       //! Destructor.
+       virtual ~WindowManager();
+       
+       virtual bool event(QEvent *event);
+
+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 eventDetected();
+       
+       //! The view size is changed.
+       /*!
+        * This signal is emitted when the window managers view changes,
+        * i.e. it received resized QEvent.
+        * \param The new view size.
+        */
+       void viewResized(const QSize &newSize, const QSize &oldSize);
+       
+       //! Previous view is restored.
+       /*!
+        * 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 previousViewRestored();
+       
+       void dialogActivated();
+       void dialogDeactivated();
+
+public slots:
+       //! Shows the view.
+       /*!
+        * 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 showView( ViewBase *view );
+       
+       //! Shows modal dialog.
+       /*!
+        * Shows modal dialog. Emits dialogActivated() signal prior calling
+        * QDialog's exec() method and emits dialogDeactivated signal when
+        * the exec() method returns.
+        */
+       void showDialog( QDialog *aDialog, bool blocking = true, bool aSendSignal = true );
+       
+       //! View event is detected.
+       /*!
+        * 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 viewEventDetected();
+       
+       void setFullscreen();
+       
+       void error( const QString &aErrorMessage );
+
+private:
+       //! Name of the application.
+       QString iApplicationName;
+       
+       //! Currently active view.
+       ViewBase *iCurrentView;
+       
+       //! Stack of views previously displayed.
+       QStack<ViewBase *> iViewList;
+
+};
+
+#endif /*WINDOWMANAGER_H_*/