Changes to screen saver mode connection status handling
authorZoltan Papp <zoltan.papp@ixonos.com>
Thu, 28 May 2009 10:11:27 +0000 (13:11 +0300)
committerZoltan Papp <zoltan.papp@ixonos.com>
Thu, 28 May 2009 10:11:27 +0000 (13:11 +0300)
src/BusinessLogic/Engine.cpp
src/BusinessLogic/Engine.h
src/BusinessLogic/UIManager.cpp
src/BusinessLogic/UIManager.h
src/UserInterface/Views/RoomStatusIndicatorWidget.cpp
src/UserInterface/Views/RoomStatusIndicatorWidget.h
src/UserInterface/Views/ViewBase.cpp
src/UserInterface/Views/ViewBase.h
src/UserInterface/WindowManager.cpp
src/UserInterface/WindowManager.h

index 195b0aa..3a5d24f 100644 (file)
@@ -33,6 +33,7 @@ Engine::Engine() :
 {
        qDebug() << "Engine::Engine()";
        iCommunicationFailed = false;
+       iCurrentWeekFetched = false;
        
        initConfiguration();
        initDevice();
@@ -196,10 +197,12 @@ void Engine::fetchMeetingDetails( Meeting *aMeeting )
 void Engine::meetingsFetched( const QList<Meeting*> &aMeetings )
 {
        qDebug() << "Engine::meetingsFetched( const QList<Meeting*> & )";
-       if( iCommunicationFailed )
+       // TODO: should check if this week's meetings were fetched
+       if( iCommunicationFailed || !iCurrentWeekFetched )
        {
+               iCurrentWeekFetched = true;
                iCommunicationFailed = false;
-               iWindowManager->connectionEstablished();
+               iUIManager->connectionEstablished();
        }
 
        for ( int i = 0; i < iMeetings.count(); ++i ) 
@@ -222,8 +225,7 @@ void Engine::errorHandler( int aCode, const QString &aAddInfo )
        if( aCode >= 100 && aCode < 150 )
        {
                iCommunicationFailed = true;
-               //TODO: Call window manager
-               //if ( iWindowManager != 0 ) iWindowManager->connectionLost();
+               if ( iUIManager != 0 ) iUIManager->connectionLost();
        }
        if ( iWindowManager != 0 )
        {
@@ -256,7 +258,6 @@ void Engine::shownWeekChanged( QDate aFrom )
 void Engine::changeDeviceMode( bool aChange )
 {
        if ( aChange )
-       }
        {
                connect( iDevice, SIGNAL( changingModeFailed() ), this, SLOT( changeModeFailed() ) );
                iAutoRefresh->stop(); // Stop the meeting update
index 69239d4..b0be476 100644 (file)
@@ -207,6 +207,7 @@ private:
        
        Room *iCurrentRoom;
        bool iCommunicationFailed;
+       bool iCurrentWeekFetched;
 };
 
 #endif /*ENGINE_H_*/
index d6d16b3..a540f96 100644 (file)
@@ -237,6 +237,22 @@ void UIManager::changeModeOrdered( DeviceManager::OperationMode aMode )
        }
 }
 
+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)
 {
        if ( iWeeklyView != 0 )
index de123b6..6721510 100644 (file)
@@ -40,6 +40,12 @@ public slots:
        void roomStatusIndicatorRequested();
        void previousViewRestored();
        void changeModeOrdered( DeviceManager::OperationMode aMode );
+
+       //! Shows any view specific indicators for connection error
+       void connectionLost();
+       
+       //! Removes any view specific indicators for connection error
+       void connectionEstablished();
        
 private slots:
 
index ce5c8eb..60d9253 100644 (file)
@@ -31,15 +31,19 @@ RoomStatusIndicatorWidget::RoomStatusIndicatorWidget( Room *aDefaultRoom, Room::
        iDefaultRoomLabel = ToolBox::createLabel( aDefaultRoom->name(), importantTextFont );\r
        iDefaultRoomLabel->setAlignment( Qt::AlignHCenter );\r
        iDefaultRoomLabel->setStyleSheet( "background-color: transparent" );\r
+       iDefaultRoomLabel->setHidden( true );\r
+       \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
+       iStatusLabel->setHidden( true );\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
+       iUntilTextLabel->setHidden( true );\r
        \r
        // No connection to server note\r
        qDebug() << "RoomStatusIndicatorWidget::RoomStatusIndicatorWidget() creating connection label";\r
@@ -50,7 +54,8 @@ RoomStatusIndicatorWidget::RoomStatusIndicatorWidget( Room *aDefaultRoom, Room::
        iConnectionLabel->setWordWrap( true );\r
        iConnectionLabel->setStyleSheet( "background-color: transparent; color: red; text-decoration:blink; max-width: 250px" );\r
        connectionLabelFrame->setFixedSize( iConnectionLabel->sizeHint() );\r
-       //iConnectionLabel->setHidden( true );\r
+       if( connectedOnce && !connectionError ) iConnectionLabel->setHidden( true );\r
+               \r
 \r
        QVBoxLayout *topLayout = new QVBoxLayout;\r
        topLayout->addStretch();\r
@@ -133,3 +138,24 @@ void RoomStatusIndicatorWidget::statusChanged( const Room::Status aStatus, const
        }\r
        setPalette( createPalette( aStatus ) );\r
 }\r
+\r
+void RoomStatusIndicatorWidget::connectionEstablished()\r
+{\r
+       if( !connectedOnce )\r
+       {\r
+               // Just got the required meetings for the first time\r
+               qDebug() << "RoomStatusIndicatorWidget::connectionEstablished() first call";\r
+               iDefaultRoomLabel->setHidden( false );\r
+               iUntilTextLabel->setHidden( false );\r
+               iStatusLabel->setHidden( false );\r
+       }\r
+       ViewBase::connectionEstablished();\r
+       iConnectionLabel->setHidden( true );\r
+}\r
+\r
+void RoomStatusIndicatorWidget::connectionLost()\r
+{\r
+       ViewBase::connectionLost();\r
+       iConnectionLabel->setHidden( false );\r
+}\r
+\r
index 465c6e1..736d230 100644 (file)
@@ -58,6 +58,10 @@ public slots:
        \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
index 24d6461..902f177 100644 (file)
@@ -25,6 +25,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 f4b7aea..af006f1 100644 (file)
@@ -126,16 +126,3 @@ void WindowManager::setFullscreen()
        this->setWindowState( Qt::WindowFullScreen );
        // Resize event handles the rest.
 }
-
-void WindowManager::connectionLost()
-{
-       //TODO: Inform all views
-       qDebug() << "WindowManager::connectionLost()";
-}
-
-void WindowManager::connectionEstablished()
-{
-       //TODO: Inform all views
-       qDebug() << "WindowManager::connectionEstablished()";
-}
-
index a3f7440..aa736cf 100644 (file)
@@ -33,13 +33,6 @@ public:
        
        virtual bool event(QEvent *event);
 
-       
-       //! Shows any view specific indicators for connection error
-       void connectionLost();
-       
-       //! Removes any view specific indicators for connection error
-       void connectionEstablished();
-
 signals:
        //! Request current status of the room.
        /*!