Merge branch 'master' of https://git.maemo.org/projects/qtmeetings
authorZoltan Papp <zoltan.papp@ixonos.com>
Mon, 1 Jun 2009 07:12:18 +0000 (10:12 +0300)
committerZoltan Papp <zoltan.papp@ixonos.com>
Mon, 1 Jun 2009 07:12:18 +0000 (10:12 +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.h

index a07d31e..aac84d4 100644 (file)
@@ -32,6 +32,8 @@ Engine::Engine() :
                iWindowManager( 0 ), iUIManager( 0 )
 {
        qDebug() << "Engine::Engine()";
+       iCommunicationFailed = false;
+       iCurrentWeekFetched = false;
        
        initConfiguration();
        initDevice();
@@ -179,8 +181,16 @@ void Engine::fetchMeetingDetails( Meeting *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;
        }
@@ -196,6 +206,11 @@ void Engine::meetingsFetched( const QList<Meeting*> &aMeetings )
 
 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 ) );
index 50e5135..6bacdd8 100644 (file)
@@ -202,6 +202,8 @@ private:
        QList<Meeting*> iMeetings;
        
        Room *iCurrentRoom;
+       bool iCommunicationFailed;
+       bool iCurrentWeekFetched;
 };
 
 #endif /*ENGINE_H_*/
index da3c877..0b94628 100644 (file)
@@ -222,6 +222,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)
 {
        qDebug() << "[UIManager::currentRoomChanged] <Invoked>";
index 837fd58..8f1f04f 100644 (file)
@@ -97,6 +97,13 @@ public slots:
         * 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:
 
index 6daf955..1cf48a7 100644 (file)
@@ -33,28 +33,48 @@ 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
+       QFrame* connectionLabelFrame = new QFrame( this );\r
+       iConnectionLabel = new QLabel( tr( "No connection to server" ), connectionLabelFrame );\r
+       iConnectionLabel->setFont( importantTextFont ); \r
+       iConnectionLabel->setAlignment( Qt::AlignHCenter );\r
+       iConnectionLabel->setWordWrap( true );\r
+       iConnectionLabel->setStyleSheet( "background-color: transparent; color: red; text-decoration:blink; max-width: 250px" );\r
+       connectionLabelFrame->setFixedSize( iConnectionLabel->sizeHint() );\r
+       if( connectedOnce && !connectionError ) iConnectionLabel->setHidden( true );\r
+               \r
 \r
        QVBoxLayout *topLayout = new QVBoxLayout;\r
        topLayout->addStretch();\r
        topLayout->addWidget( iTimeDisplay );\r
+       topLayout->addSpacing( 28 );\r
        topLayout->addWidget( iDefaultRoomLabel );\r
        topLayout->addWidget( iStatusLabel );\r
        topLayout->addWidget( iUntilTextLabel );\r
+       topLayout->addSpacing( 28 );\r
+       topLayout->addWidget( connectionLabelFrame );\r
        topLayout->addStretch();\r
 \r
        QHBoxLayout *mainLayout = new QHBoxLayout;\r
        mainLayout->addLayout( topLayout );\r
        mainLayout->addStretch();\r
-       mainLayout->setMargin( 65 );\r
+       //mainLayout->setMargin( 65 );\r
+       mainLayout->setContentsMargins( 65, 65, 65, 0 );\r
        setLayout( mainLayout );\r
 \r
        statusChanged( aStatus, aUntil );\r
@@ -143,3 +163,26 @@ bool RoomStatusIndicatorWidget::event(QEvent *event)
        \r
        return ViewBase::event( event );\r
 }\r
+\r
+void RoomStatusIndicatorWidget::connectionEstablished()\r
+{\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
+       else qDebug() << "RoomStatusIndicatorWidget::connectionEstablished()";\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 73957b6..643160a 100644 (file)
@@ -64,6 +64,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
@@ -84,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_*/