From: Zoltan Papp Date: Mon, 1 Jun 2009 07:12:18 +0000 (+0300) Subject: Merge branch 'master' of https://git.maemo.org/projects/qtmeetings X-Git-Url: https://vcs.maemo.org/git/?a=commitdiff_plain;h=33edea90bd097065e8c6b63cabc6b4b22c6a5d2c;hp=0707d975553afcef053521d91e8f048992b9f37e;p=qtmeetings Merge branch 'master' of https://git.maemo.org/projects/qtmeetings --- diff --git a/src/BusinessLogic/Engine.cpp b/src/BusinessLogic/Engine.cpp index a07d31e..aac84d4 100644 --- a/src/BusinessLogic/Engine.cpp +++ b/src/BusinessLogic/Engine.cpp @@ -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 &aMeetings ) { qDebug() << "Engine::meetingsFetched( const QList & )"; - - 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 &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 ) ); diff --git a/src/BusinessLogic/Engine.h b/src/BusinessLogic/Engine.h index 50e5135..6bacdd8 100644 --- a/src/BusinessLogic/Engine.h +++ b/src/BusinessLogic/Engine.h @@ -202,6 +202,8 @@ private: QList iMeetings; Room *iCurrentRoom; + bool iCommunicationFailed; + bool iCurrentWeekFetched; }; #endif /*ENGINE_H_*/ diff --git a/src/BusinessLogic/UIManager.cpp b/src/BusinessLogic/UIManager.cpp index da3c877..0b94628 100644 --- a/src/BusinessLogic/UIManager.cpp +++ b/src/BusinessLogic/UIManager.cpp @@ -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] "; diff --git a/src/BusinessLogic/UIManager.h b/src/BusinessLogic/UIManager.h index 837fd58..8f1f04f 100644 --- a/src/BusinessLogic/UIManager.h +++ b/src/BusinessLogic/UIManager.h @@ -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: diff --git a/src/UserInterface/Views/RoomStatusIndicatorWidget.cpp b/src/UserInterface/Views/RoomStatusIndicatorWidget.cpp index 6daf955..1cf48a7 100644 --- a/src/UserInterface/Views/RoomStatusIndicatorWidget.cpp +++ b/src/UserInterface/Views/RoomStatusIndicatorWidget.cpp @@ -33,28 +33,48 @@ RoomStatusIndicatorWidget::RoomStatusIndicatorWidget( Room *aDefaultRoom, Room:: 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->setMargin( 65 ); + mainLayout->setContentsMargins( 65, 65, 65, 0 ); setLayout( mainLayout ); statusChanged( aStatus, aUntil ); @@ -143,3 +163,26 @@ bool RoomStatusIndicatorWidget::event(QEvent *event) return ViewBase::event( event ); } + +void RoomStatusIndicatorWidget::connectionEstablished() +{ + + if( !connectedOnce ) + { + // Just got the required meetings for the first time + qDebug() << "RoomStatusIndicatorWidget::connectionEstablished() first call"; + iDefaultRoomLabel->setHidden( false ); + iUntilTextLabel->setHidden( false ); + iStatusLabel->setHidden( false ); + } + else qDebug() << "RoomStatusIndicatorWidget::connectionEstablished()"; + ViewBase::connectionEstablished(); + iConnectionLabel->setHidden( true ); +} + +void RoomStatusIndicatorWidget::connectionLost() +{ + ViewBase::connectionLost(); + iConnectionLabel->setHidden( false ); +} + diff --git a/src/UserInterface/Views/RoomStatusIndicatorWidget.h b/src/UserInterface/Views/RoomStatusIndicatorWidget.h index 73957b6..643160a 100644 --- a/src/UserInterface/Views/RoomStatusIndicatorWidget.h +++ b/src/UserInterface/Views/RoomStatusIndicatorWidget.h @@ -64,6 +64,10 @@ public slots: void viewResized(const QSize &newSize, const QSize &oldSize) { } + void connectionEstablished(); + + void connectionLost(); + private: //! Translates the status into human readable text. /*! @@ -84,6 +88,7 @@ private: QLabel *iDefaultRoomLabel; QLabel *iStatusLabel; QLabel *iUntilTextLabel; + QLabel *iConnectionLabel; TimeDisplayWidget *iTimeDisplay; QString iTimeFormat; diff --git a/src/UserInterface/Views/ViewBase.cpp b/src/UserInterface/Views/ViewBase.cpp index 24d6461..14c51aa 100644 --- a/src/UserInterface/Views/ViewBase.cpp +++ b/src/UserInterface/Views/ViewBase.cpp @@ -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() ) diff --git a/src/UserInterface/Views/ViewBase.h b/src/UserInterface/Views/ViewBase.h index 631a089..2a7b73e 100644 --- a/src/UserInterface/Views/ViewBase.h +++ b/src/UserInterface/Views/ViewBase.h @@ -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_*/ diff --git a/src/UserInterface/WindowManager.h b/src/UserInterface/WindowManager.h index 2f46050..aa736cf 100644 --- a/src/UserInterface/WindowManager.h +++ b/src/UserInterface/WindowManager.h @@ -1,107 +1,107 @@ -#ifndef WINDOWMANAGER_H_ -#define WINDOWMANAGER_H_ - -#include -#include - -// 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 iViewList; - -}; - -#endif /*WINDOWMANAGER_H_*/ +#ifndef WINDOWMANAGER_H_ +#define WINDOWMANAGER_H_ + +#include +#include + +// 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 iViewList; + +}; + +#endif /*WINDOWMANAGER_H_*/