iWindowManager( 0 ), iUIManager( 0 )
{
qDebug() << "Engine::Engine()";
+ iCommunicationFailed = false;
+ iCurrentWeekFetched = false;
initConfiguration();
initDevice();
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;
}
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 ) );
QList<Meeting*> iMeetings;
Room *iCurrentRoom;
+ bool iCommunicationFailed;
+ bool iCurrentWeekFetched;
};
#endif /*ENGINE_H_*/
}
}
+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>";
* 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:
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
\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
\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
QLabel *iDefaultRoomLabel;\r
QLabel *iStatusLabel;\r
QLabel *iUntilTextLabel;\r
+ QLabel *iConnectionLabel;\r
TimeDisplayWidget *iTimeDisplay;\r
QString iTimeFormat;\r
\r
ViewBase::ViewBase( ViewBase::ViewMode aMode, QWidget *aParent ) : QWidget( aParent ), iViewMode( aMode )
{
-
+ connectedOnce = false;
+ connectionError = false;
}
ViewBase::~ViewBase()
return iViewMode;
}
+void ViewBase::connectionEstablished()
+{
+ connectedOnce = true;
+ connectionError = false;
+}
+
+void ViewBase::connectionLost()
+{
+ connectionError = true;
+}
+
+
bool ViewBase::event(QEvent *event)
{
switch( event->type() )
*/
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.
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_*/
-#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_*/