iWindowManager( 0 ), iUIManager( 0 )
{
qDebug() << "Engine::Engine()";
+ iCommunicationFailed = false;
+ iCurrentWeekFetched = false;
initConfiguration();
initDevice();
for (int i = 0; i < iConfiguration->rooms().count(); i++)
{
// and check the status
- roomStatusInfoNeeded(iConfiguration->rooms().at(i) );
+ roomStatusInfoNeeded( iConfiguration->rooms().at(i) );
}
}
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 ) );
qDebug() << "[Engine::currentRoomChanged] <invoked>";
iCurrentRoom = aRoom;
roomStatusInfoNeeded( iCurrentRoom );
- }
+ }
void UIManager::createRoomStatusIndicator()
{
iRoomStatusIndicator = new RoomStatusIndicatorWidget( iEngine->defaultRoom(), Room::FreeStatus, QTime::currentTime(), iEngine->iConfiguration->displaySettings()->timeFormat() );
- connect( iEngine, SIGNAL( roomStatusChanged( Room::Status, QTime ) ), this, SLOT( statusChanged( Room::Status, QTime ) ) );
+ connect( iEngine, SIGNAL( roomStatusChanged( Room::Status, QTime ) ), iRoomStatusIndicator, SLOT( statusChanged( Room::Status, QTime ) ) );
connect( iWeeklyView, SIGNAL( currentRoomChanged( Room * ) ), iRoomStatusIndicator, SLOT( currentRoomChanged( Room * ) ) );
}
}
}
+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>";
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
QPalette RoomStatusIndicatorWidget::createPalette( Room::Status aStatus )\r
{\r
- // QPixmap pixmap( aStatus == Room::BusyStatus ? ":roomstatus_busy" : ":roomstatus_free" );\r
QString image = aStatus == Room::BusyStatus ? ":roomstatus_busy" : ":roomstatus_free";\r
+ QPixmap pixmap( image );\r
\r
// The image needs to be moved in normal mode so the traffic light not partly outside the screen\r
const int xoffset( 60 );\r
const int yoffset( 19 );\r
- // int cropwidth( pixmap.width() - xoffset );\r
- // int cropheight( pixmap.height() - yoffset );\r
+ int cropwidth( pixmap.width() - xoffset );\r
+ int cropheight( pixmap.height() - yoffset );\r
\r
QBrush brush;\r
if ( windowState() == Qt::WindowFullScreen )\r
{\r
// Use the full image in full screen mode\r
- // brush.setTexture( pixmap );\r
- brush.setTexture( QPixmap(image) );\r
+ brush.setTexture( pixmap );\r
}\r
else\r
{\r
// Take part of the image so the traffic lights are moved xoffset poxels to left \r
// and yoffset pixels to up\r
- // brush.setTexture( pixmap.copy( xoffset, yoffset, cropwidth, cropheight ) );\r
- brush.setTexture( QPixmap(image) );\r
+ brush.setTexture( pixmap.copy( xoffset, yoffset, cropwidth, cropheight ) );\r
}\r
\r
QPalette palette;\r
\r
void RoomStatusIndicatorWidget::statusChanged( const Room::Status aStatus, const QTime aUntil )\r
{\r
- qDebug() << "[RoomStatusIndicatorWidget::statusChanged] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";\r
iStatusLabel->setText( tr( "is %1" ).arg( statusToText( aStatus ) ) );\r
if ( aUntil == RoomStatusIndicatorWidget::endOfTheDay )\r
{\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