From: Risto Lintinen Date: Mon, 24 Aug 2009 09:04:45 +0000 (+0300) Subject: Status bar fixed X-Git-Url: https://vcs.maemo.org/git/?a=commitdiff_plain;h=51d64b3d9f4cacc447c74e5811e692fbe9b4137f;p=qtmeetings Status bar fixed --- diff --git a/src/BusinessLogic/Engine.cpp b/src/BusinessLogic/Engine.cpp index e46ddc9..6207440 100644 --- a/src/BusinessLogic/Engine.cpp +++ b/src/BusinessLogic/Engine.cpp @@ -32,8 +32,7 @@ Engine::Engine() : iWindowManager( 0 ), iUIManager( 0 ) { qDebug() << "Engine::Engine()"; - iCommunicationFailed = false; - iCurrentWeekFetched = false; + iCommunicationFailed = true; initConfiguration(); initDevice(); @@ -184,10 +183,14 @@ void Engine::fetchMeetingDetails( Meeting *aMeeting ) void Engine::meetingsFetched( const QList &aMeetings ) { qDebug() << "Engine::meetingsFetched( const QList & )"; - // TODO: should check if this week's meetings were fetched - if( iCommunicationFailed || !iCurrentWeekFetched ) + QTime c = QTime::currentTime(); + iLastCommunication.setHMS( c.hour(), c.minute(), c.second() ); + + qDebug() << "Error length: "<< iCommunicationError.length(); + qDebug() << "Error: "<< iCommunicationError; + + if( iCommunicationError.length() == 0 ) { - iCurrentWeekFetched = true; iCommunicationFailed = false; iUIManager->connectionEstablished(); } @@ -210,10 +213,10 @@ void Engine::meetingsFetched( const QList &aMeetings ) void Engine::errorHandler( int aCode, const QString &aAddInfo ) { + iCommunicationFailed = true; + if( aCode >= 100 && aCode < 150 ) { - iCommunicationFailed = true; - if ( iUIManager != 0 ) { iUIManager->connectionLost(); @@ -221,14 +224,31 @@ void Engine::errorHandler( int aCode, const QString &aAddInfo ) } if ( iWindowManager != 0 ) { - iWindowManager->error( ErrorMapper::codeToString( aCode, aAddInfo ) ); + iCommunicationError = ErrorMapper::codeToString( aCode, aAddInfo ); + //iWindowManager->error( ErrorMapper::codeToString( aCode, aAddInfo ) ); } } +bool Engine::connected() +{ + return !iCommunicationFailed; +} + +QTime Engine::lastUpdated() +{ + return iLastCommunication; +} + +QString Engine::errorMessage() +{ + return iCommunicationError; +} + void Engine::fetchMeetings( const int aWeek, const int aYear, const Room *aIn ) { qDebug() << "Engine::fetchMeetings( const int aWeek, const int aYear, const Room * )"; + iCommunicationError = ""; iCommunication->fetchMeetings(aWeek, aYear, *aIn); } @@ -240,6 +260,7 @@ void Engine::cancelFetchMeetingDetails() void Engine::shownWeekChanged( QDate aFrom ) { qDebug() << "[Engine::shownWeekChanged] "; + iCommunicationError = ""; iCommunication->fetchMeetings( aFrom.weekNumber(), aFrom.year(), *iCurrentRoom/*defaultRoom()*/ ); } diff --git a/src/BusinessLogic/Engine.h b/src/BusinessLogic/Engine.h index 39ba221..65690a1 100644 --- a/src/BusinessLogic/Engine.h +++ b/src/BusinessLogic/Engine.h @@ -39,6 +39,10 @@ public: */ Room* defaultRoom(); + bool connected(); + QTime lastUpdated(); + QString errorMessage(); + signals: void roomStatusChanged( Room::Status aStatus, QTime aUntil ); @@ -214,7 +218,8 @@ private: Room *iCurrentRoom; bool iCommunicationFailed; - bool iCurrentWeekFetched; + QString iCommunicationError; + QTime iLastCommunication; }; #endif /*ENGINE_H_*/ diff --git a/src/BusinessLogic/UIManager.cpp b/src/BusinessLogic/UIManager.cpp index 089eb9c..0913697 100644 --- a/src/BusinessLogic/UIManager.cpp +++ b/src/BusinessLogic/UIManager.cpp @@ -253,11 +253,11 @@ void UIManager::updateTime(QDateTime aDateTime) { if ( iWeeklyView != 0 ) { - iWeeklyView->setCurrentDateTime( aDateTime ); + iWeeklyView->setConnectionStatus( aDateTime, iEngine->connected(), iEngine->lastUpdated(), iEngine->errorMessage() ); } if ( iRoomStatusIndicator != 0 ) { - iRoomStatusIndicator->setCurrentTime( aDateTime.time() ); + iRoomStatusIndicator->setConnectionStatus( aDateTime, iEngine->connected(), iEngine->lastUpdated(), iEngine->errorMessage() ); } } diff --git a/src/UserInterface/Views/RoomStatusIndicatorWidget.cpp b/src/UserInterface/Views/RoomStatusIndicatorWidget.cpp index ca53b9d..d71fcb1 100644 --- a/src/UserInterface/Views/RoomStatusIndicatorWidget.cpp +++ b/src/UserInterface/Views/RoomStatusIndicatorWidget.cpp @@ -132,7 +132,7 @@ QPalette RoomStatusIndicatorWidget::createPalette(Room::Status aStatus) int cropheight(pixmap.height() - yoffset); QBrush brush; - if (windowState() == Qt::WindowFullScreen) + if ( (pixmap.width() == rect().width()) && (pixmap.height() == rect().height()) ) { // Use the full image in full screen mode brush.setTexture(pixmap); @@ -151,11 +151,38 @@ QPalette RoomStatusIndicatorWidget::createPalette(Room::Status aStatus) return palette; } -void RoomStatusIndicatorWidget::setCurrentTime(QTime aCurrentTime) +void RoomStatusIndicatorWidget::setConnectionStatus( QDateTime aCurrentTime, bool aConnected, + QTime aLastUpdated, QString aError ) { iTimeDisplay->setText( aCurrentTime.toString( iTimeFormat ) ); + if ( aLastUpdated.isNull() ) + iStatusBar->setText( tr("Disconnected") , BorderedBarWidget::LeftAlign ); + else + { + iDefaultRoomLabel->setHidden( false ); + iUntilTextLabel->setHidden( false ); + iStatusLabel->setHidden( false ); + + if (!aConnected) + { + iStatusBar->setText( tr("Disconnected").arg(aLastUpdated.toString(iTimeFormat)) + , BorderedBarWidget::LeftAlign ); + } + else + { + iStatusBar->setText( tr("Connected - Last update %1").arg(aLastUpdated.toString(iTimeFormat)) , + BorderedBarWidget::LeftAlign ); + } + } + showError( aError ); +} + +void RoomStatusIndicatorWidget::showError( QString aError ) +{ + iStatusBar->setText( aError ); } + void RoomStatusIndicatorWidget::statusChanged(const Room::Status aStatus, const QTime aUntil) { iStatusLabel->setText(tr( "is %1" ).arg(statusToText(aStatus) ) ); @@ -195,24 +222,10 @@ bool RoomStatusIndicatorWidget::event(QEvent *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(); - iStatusBar->setText( tr("Connected"), BorderedBarWidget::LeftAlign ); } void RoomStatusIndicatorWidget::connectionLost() { ViewBase::connectionLost(); - iStatusBar->setText( tr("Disconnected"), BorderedBarWidget::LeftAlign ); } diff --git a/src/UserInterface/Views/RoomStatusIndicatorWidget.h b/src/UserInterface/Views/RoomStatusIndicatorWidget.h index bf82485..c9256dc 100644 --- a/src/UserInterface/Views/RoomStatusIndicatorWidget.h +++ b/src/UserInterface/Views/RoomStatusIndicatorWidget.h @@ -43,13 +43,14 @@ public: bool event(QEvent *event); public slots: - //! Slot. Sets current time. + //! Slot. Sets the connection status /*! - * Slots. Sets current time on the widget. It is used to provide up-to-date time for the widget's - * TimeDisplayWidget. - * \param aCurrentTime The current time. + * Sets the current time, and connection status + * \param aCurrentTime Time to be displayed. + * \param aConnected connection status to be displayed. + * \param aLastUpdated Time of last successful connection to be displayed. */ - void setCurrentTime( QTime aCurrentTime ); + void setConnectionStatus( QDateTime aCurrentTime, bool aConnected, QTime aLastUpdated = QTime(), QString aError = ""); //! Slot. Used to indicate changes in the status of the default room. /*! * Slot. Used to indicate changes in the status of the default room. If the specified until time equals @@ -60,6 +61,8 @@ public slots: */ void statusChanged( const Room::Status aStatus, const QTime aUntil ); + void showError( QString aError ); + void currentRoomChanged( Room *aRoom ); void viewResized(const QSize &/*newSize*/, const QSize &/*oldSize*/) { } diff --git a/src/UserInterface/Views/WeeklyViewWidget.cpp b/src/UserInterface/Views/WeeklyViewWidget.cpp index 6c8b75c..0c9b61f 100644 --- a/src/UserInterface/Views/WeeklyViewWidget.cpp +++ b/src/UserInterface/Views/WeeklyViewWidget.cpp @@ -76,6 +76,7 @@ WeeklyViewWidget::WeeklyViewWidget( QDateTime aCurrentDateTime, Configuration *a iStatusBar->setFixedHeight( 28 ); QPixmap pixmap(":ixonos_logo"); iStatusBar->setPixmap( pixmap ); + iStatusBar->setText( tr("Disconnected"), BorderedBarWidget::LeftAlign ); iSchedule = new ScheduleWidget( aCurrentDateTime, iConfiguration->displaySettings(), this ); connect( iSchedule, SIGNAL( shownWeekChanged( QDate ) ), this, SIGNAL( shownWeekChanged( QDate ) ) ); @@ -227,15 +228,34 @@ Room* WeeklyViewWidget::currentRoom() return iRoomsCombo->currentRoom(); } -void WeeklyViewWidget::setCurrentDateTime( QDateTime aCurrentDateTime ) +void WeeklyViewWidget::setConnectionStatus( QDateTime aCurrentTime, bool aConnected, + QTime aLastUpdated, QString aError ) { - iCurrentDayLabel->setText( aCurrentDateTime.date().toString( iConfiguration->displaySettings()->dateFormat() ) ); + iCurrentDayLabel->setText( aCurrentTime.date().toString( iConfiguration->displaySettings()->dateFormat() ) ); + iCurrentWeekLabel->setText( tr( "Wk %1" ).arg( aCurrentTime.date().weekNumber() ) ); + iSchedule->setCurrentDateTime( aCurrentTime ); - iCurrentWeekLabel->setText( tr( "Wk %1" ).arg( aCurrentDateTime.date().weekNumber() ) ); - - iTimeDisplay->setText( aCurrentDateTime.toString( iConfiguration->displaySettings()->timeFormat() ) ); + iTimeDisplay->setText( aCurrentTime.toString( iConfiguration->displaySettings()->timeFormat() ) ); + if ( aLastUpdated.isNull() ) + iStatusBar->setText( tr("Disconnected") , BorderedBarWidget::LeftAlign ); + else if ( !aConnected ) + { + iStatusBar->setText( tr("Disconnected") + .arg(aLastUpdated.toString(iConfiguration->displaySettings()->timeFormat())) + , BorderedBarWidget::LeftAlign ); + } + else + { + iStatusBar->setText( tr("Connected - Last update %1") + .arg(aLastUpdated.toString(iConfiguration->displaySettings()->timeFormat())) , + BorderedBarWidget::LeftAlign ); + } + showError( aError ); + } - iSchedule->setCurrentDateTime( aCurrentDateTime ); +void WeeklyViewWidget::showError( QString aError ) +{ + iStatusBar->setText( aError ); } QDate WeeklyViewWidget::beginnigOfShownWeek() @@ -262,12 +282,9 @@ void WeeklyViewWidget::setDefaultRoom() void WeeklyViewWidget::connectionEstablished() { ViewBase::connectionEstablished(); - qDebug() << "WeeklyViewWidget::connectionEstablished"; - iStatusBar->setText( tr("Connected"), BorderedBarWidget::LeftAlign ); } void WeeklyViewWidget::connectionLost() { ViewBase::connectionLost(); - iStatusBar->setText( tr("Disconnected"), BorderedBarWidget::LeftAlign ); } diff --git a/src/UserInterface/Views/WeeklyViewWidget.h b/src/UserInterface/Views/WeeklyViewWidget.h index 0fcd1cb..a9632a2 100644 --- a/src/UserInterface/Views/WeeklyViewWidget.h +++ b/src/UserInterface/Views/WeeklyViewWidget.h @@ -112,12 +112,14 @@ signals: void shownWeekChanged( QDate aDate ); public slots: - //! Sets the date and time + //! Slot. Sets the connection status /*! - * Sets the current date and time - * \param aCurrentDateTime Date and time to be displayd. + * Sets the current time, and connection status + * \param aCurrentTime Time to be displayed. + * \param aConnected connection status to be displayed. + * \param aLastUpdated Time of last successful connection to be displayed. */ - void setCurrentDateTime( QDateTime aCurrentDateTime ); + void setConnectionStatus( QDateTime aCurrentTime, bool aConnected, QTime aLastUpdated = QTime(), QString aError = "" ); //! Handle resizing /*! * Handle possible resize changes after the view is resized @@ -125,6 +127,8 @@ public slots: */ void viewResized(const QSize &/*newSize*/, const QSize &/*oldSize*/) { } + void showError( QString aError ); + void connectionEstablished(); void connectionLost();