iWindowManager( 0 ), iUIManager( 0 )
{
qDebug() << "Engine::Engine()";
- iCommunicationFailed = false;
- iCurrentWeekFetched = false;
+ iCommunicationFailed = true;
initConfiguration();
initDevice();
void Engine::meetingsFetched( const QList<Meeting*> &aMeetings )
{
qDebug() << "Engine::meetingsFetched( const QList<Meeting*> & )";
- // 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();
}
void Engine::errorHandler( int aCode, const QString &aAddInfo )
{
+ iCommunicationFailed = true;
+
if( aCode >= 100 && aCode < 150 )
{
- iCommunicationFailed = true;
-
if ( iUIManager != 0 )
{
iUIManager->connectionLost();
}
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);
}
void Engine::shownWeekChanged( QDate aFrom )
{
qDebug() << "[Engine::shownWeekChanged] <Invoked>";
+ iCommunicationError = "";
iCommunication->fetchMeetings( aFrom.weekNumber(), aFrom.year(), *iCurrentRoom/*defaultRoom()*/ );
}
*/
Room* defaultRoom();
+ bool connected();
+ QTime lastUpdated();
+ QString errorMessage();
+
signals:
void roomStatusChanged( Room::Status aStatus, QTime aUntil );
Room *iCurrentRoom;
bool iCommunicationFailed;
- bool iCurrentWeekFetched;
+ QString iCommunicationError;
+ QTime iLastCommunication;
};
#endif /*ENGINE_H_*/
{
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() );
}
}
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);
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) ) );
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 );
}
bool event(QEvent *event);\r
\r
public slots:\r
- //! Slot. Sets current time.\r
+ //! Slot. Sets the connection status\r
/*!\r
- * Slots. Sets current time on the widget. It is used to provide up-to-date time for the widget's\r
- * TimeDisplayWidget.\r
- * \param aCurrentTime The current time.\r
+ * Sets the current time, and connection status\r
+ * \param aCurrentTime Time to be displayed.\r
+ * \param aConnected connection status to be displayed.\r
+ * \param aLastUpdated Time of last successful connection to be displayed.\r
*/\r
- void setCurrentTime( QTime aCurrentTime );\r
+ void setConnectionStatus( QDateTime aCurrentTime, bool aConnected, QTime aLastUpdated = QTime(), QString aError = "");\r
//! Slot. Used to indicate changes in the status of the default room.\r
/*!\r
* Slot. Used to indicate changes in the status of the default room. If the specified until time equals\r
*/\r
void statusChanged( const Room::Status aStatus, const QTime aUntil );\r
\r
+ void showError( QString aError );\r
+\r
void currentRoomChanged( Room *aRoom );\r
\r
void viewResized(const QSize &/*newSize*/, const QSize &/*oldSize*/) { }\r
iStatusBar->setFixedHeight( 28 );\r
QPixmap pixmap(":ixonos_logo");\r
iStatusBar->setPixmap( pixmap );\r
+ iStatusBar->setText( tr("Disconnected"), BorderedBarWidget::LeftAlign );\r
\r
iSchedule = new ScheduleWidget( aCurrentDateTime, iConfiguration->displaySettings(), this );\r
connect( iSchedule, SIGNAL( shownWeekChanged( QDate ) ), this, SIGNAL( shownWeekChanged( QDate ) ) );\r
return iRoomsCombo->currentRoom();\r
}\r
\r
-void WeeklyViewWidget::setCurrentDateTime( QDateTime aCurrentDateTime )\r
+void WeeklyViewWidget::setConnectionStatus( QDateTime aCurrentTime, bool aConnected,\r
+ QTime aLastUpdated, QString aError )\r
{\r
- iCurrentDayLabel->setText( aCurrentDateTime.date().toString( iConfiguration->displaySettings()->dateFormat() ) );\r
+ iCurrentDayLabel->setText( aCurrentTime.date().toString( iConfiguration->displaySettings()->dateFormat() ) );\r
+ iCurrentWeekLabel->setText( tr( "Wk %1" ).arg( aCurrentTime.date().weekNumber() ) );\r
+ iSchedule->setCurrentDateTime( aCurrentTime );\r
\r
- iCurrentWeekLabel->setText( tr( "Wk %1" ).arg( aCurrentDateTime.date().weekNumber() ) );\r
-\r
- iTimeDisplay->setText( aCurrentDateTime.toString( iConfiguration->displaySettings()->timeFormat() ) );\r
+ iTimeDisplay->setText( aCurrentTime.toString( iConfiguration->displaySettings()->timeFormat() ) );\r
+ if ( aLastUpdated.isNull() )\r
+ iStatusBar->setText( tr("Disconnected") , BorderedBarWidget::LeftAlign );\r
+ else if ( !aConnected )\r
+ {\r
+ iStatusBar->setText( tr("Disconnected")\r
+ .arg(aLastUpdated.toString(iConfiguration->displaySettings()->timeFormat()))\r
+ , BorderedBarWidget::LeftAlign );\r
+ }\r
+ else\r
+ {\r
+ iStatusBar->setText( tr("Connected - Last update %1")\r
+ .arg(aLastUpdated.toString(iConfiguration->displaySettings()->timeFormat())) ,\r
+ BorderedBarWidget::LeftAlign );\r
+ }\r
+ showError( aError );\r
+ }\r
\r
- iSchedule->setCurrentDateTime( aCurrentDateTime );\r
+void WeeklyViewWidget::showError( QString aError )\r
+{\r
+ iStatusBar->setText( aError );\r
}\r
\r
QDate WeeklyViewWidget::beginnigOfShownWeek()\r
void WeeklyViewWidget::connectionEstablished()\r
{\r
ViewBase::connectionEstablished();\r
- qDebug() << "WeeklyViewWidget::connectionEstablished";\r
- iStatusBar->setText( tr("Connected"), BorderedBarWidget::LeftAlign );\r
}\r
\r
void WeeklyViewWidget::connectionLost()\r
{\r
ViewBase::connectionLost();\r
- iStatusBar->setText( tr("Disconnected"), BorderedBarWidget::LeftAlign );\r
}\r
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
*/
void viewResized(const QSize &/*newSize*/, const QSize &/*oldSize*/) { }
+ void showError( QString aError );
+
void connectionEstablished();
void connectionLost();