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 ) );
// fetchMeetings( from, to, iWindowManager->weeklyView()->currentRoom() );
}
- void Engine::changeDeviceMode( bool aChange )
+ void Engine::changeDeviceMode()
{
- if ( aChange )
- {
- connect( iDevice, SIGNAL( changingModeFailed() ), this, SLOT( changeModeFailed() ) );
- iAutoRefresh->stop(); // Stop the meeting update
- }
- iDevice->changeMode( aChange );
+ connect( iDevice, SIGNAL( changeModeFailed() ), this, SLOT( changeModeFailed() ) );
+ iAutoRefresh->stop(); // Stop the meeting update
+ iDevice->changeMode();
}
void Engine::changeModeFailed()
{
qDebug() << "Engine::progressBarCancelled()";
- iDevice->changeMode( false );
iAutoRefresh->start(); //we start the metting updating
}
connect( iWindowManager, SIGNAL( eventDetected() ), this, SLOT( handleViewEvent() ) );
connect( iWindowManager, SIGNAL( previousViewRestored() ), iUIManager, SLOT( previousViewRestored() ) );
- // connect( iWindowManager, SIGNAL( dialogActivated() ), this, SLOT( dialogActivated() ) );
- // connect( iWindowManager, SIGNAL( dialogDeactivated() ), this, SLOT( dialogDeactivated() ) );
+ connect( iWindowManager, SIGNAL( dialogActivated() ), this, SLOT( dialogActivated() ) );
+ connect( iWindowManager, SIGNAL( dialogDeactivated() ), this, SLOT( dialogDeactivated() ) );
// Show the UI
iWindowManager->setWindowState( Qt::WindowMaximized );
void Engine::handleViewEvent()
{
- if ( iIdleTimeCounter != 0 )
+ if ( iIdleTimeCounter != 0 && iIdleTimeCounter->isActive())
{
// Restart the idle time counter when view event is received
iIdleTimeCounter->stop();
void stopIdleTimeCounter();
void startIdleTimeCounter();
- void changeDeviceMode( bool aChange );
+ void changeDeviceMode();
void currentRoomChanged( Room *aRoom );
QList<Meeting*> iMeetings;
Room *iCurrentRoom;
+ bool iCommunicationFailed;
+ bool iCurrentWeekFetched;
};
#endif /*ENGINE_H_*/
iWindowManager->showView( iWeeklyView );
}
- void UIManager::showProgressBar( QString aText )
- {
- if ( iProgressBar != 0 )
- {
- iProgressBar->update( aText );
- iWindowManager->showDialog( iProgressBar );
- }
- }
-
// ===============================================
// INITIALIZE THE UIMANAGER
void UIManager::createWeeklyView()
void UIManager::createPasswordDialog()
{
- iPasswordDialog = new PasswordDialog( iEngine->iConfiguration->adminPassword(), tr("UIManager::createPasswordDialog"), tr("UIManager::createPasswordDialog") );
-
+ iPasswordDialog = new PasswordDialog( iEngine->iConfiguration->adminPassword(), "", tr("Enter password") );
connect( iPasswordDialog, SIGNAL( passwordEntered( PasswordDialog::PasswordStatus ) ), this, SLOT( passwordEntered( PasswordDialog::PasswordStatus ) ) );
}
void UIManager::createProgressBar()
{
iProgressBar = new ProgressBar( tr("CHANGE THIS"), true );
-
// Connect to UIManager
connect( iProgressBar, SIGNAL( cancel() ), this, SLOT( progressBarCancelled() ) );
// Connect to Engine
{
if ( iProgressBar != 0 )
{
- iProgressBar->update( tr("Fetching meeting info...") );
+ iProgressBar->update( tr( "Fetching meeting info..." ), tr( "Please wait" ) );
+ iProgressBar->toggleCancellable( true );
iWindowManager->showDialog( static_cast<QDialog *>( iProgressBar ), false, false );
- iEngine->stopIdleTimeCounter();
}
}
if ( iProgressBar != 0 )
{
iProgressBar->close();
- iEngine->startIdleTimeCounter();
}
}
void UIManager::changeModeOrdered( DeviceManager::OperationMode aMode )
{
qDebug() << "[UIManager::changeModeOrdered] <Invoked>";
if ( iPasswordDialog != 0 )
{
- // TODO : Set the new text for password dialog
+ QString text = tr( "You are about to change operation mode to %1." )
+ .arg( iEngine->iDevice->operationModeToString( aMode ) );
+ iPasswordDialog->update( text );
iWindowManager->showDialog( static_cast<QDialog *>( iPasswordDialog ) );
}
}
+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>";
// Show the progress bar..
if ( iProgressBar != 0 )
{
- iWindowManager->showDialog( static_cast<QDialog *>( iProgressBar ), false );
+ iProgressBar->update( tr( "" ), tr( "Changing operation mode" ) );
+ iProgressBar->toggleCancellable( false );
+ iWindowManager->showDialog( static_cast<QDialog *>( iProgressBar ), false, false );
}
// ... and initiate the mode changing
- iEngine->changeDeviceMode( true );
+ iEngine->changeDeviceMode();
break;
case PasswordDialog::Incorrect:
iWindowManager->error( tr("Incorrect Password") );
+ break;
case PasswordDialog::Canceled:
- iEngine->changeDeviceMode( false );
break;
}
* Makes the main view visible trough WindowManager.
*/
void showMainView();
- //! Shows the progress bar.
- /*!
- * Shows the progress bar with given text.
- */
- void showProgressBar( QString aText );
signals:
* 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:
#include "DigitalTimeDisplayWidget.h"\r
#include "ToolBox.h"\r
\r
+ #include <QEvent>\r
+ \r
#include <QtDebug>\r
\r
QTime RoomStatusIndicatorWidget::endOfTheDay = QTime( 23, 59, 0, 0 );\r
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
+ // QPixmap pixmap( aStatus == Room::BusyStatus ? ":roomstatus_busy" : ":roomstatus_free" );\r
+ QString image = aStatus == Room::BusyStatus ? ":roomstatus_busy" : ":roomstatus_free";\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( pixmap );\r
+ brush.setTexture( QPixmap(image) );\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( pixmap.copy( xoffset, yoffset, cropwidth, cropheight ) );\r
+ brush.setTexture( QPixmap(image) );\r
}\r
\r
QPalette palette;\r
iUntilTextLabel->setText( tr( "until %1" ).arg( aUntil.toString( iTimeFormat ) ) );\r
}\r
setPalette( createPalette( aStatus ) );\r
+ }
+ \r
+ void RoomStatusIndicatorWidget::currentRoomChanged( Room *aRoom )\r
+ {\r
+ iDefaultRoomLabel->setText( aRoom->name() );\r
+ }\r
+ \r
+ bool RoomStatusIndicatorWidget::event(QEvent *event)\r
+ {\r
+ switch(event->type())\r
+ {\r
+ case QEvent::Paint:\r
+ qDebug() << "[RoomStatusIndicatorWidget::event] <Paint event>";\r
+ break;\r
+ case QEvent::PaletteChange:\r
+ qDebug() << "[RoomStatusIndicatorWidget::event] <Palette change event>";\r
+ break;\r
+ default:\r
+ break;\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
class QVBoxLayout;\r
class TimeDisplayWidget;\r
\r
+ class QEvent;\r
+ \r
//! UserInterface class. Indicates if the default meeting room is busy or not.\r
/*!\r
* UserInterface class. Indicates if the default meeting room is busy or not. This widget\r
RoomStatusIndicatorWidget( Room *aDefaultRoom, Room::Status aStatus, QTime aUntil, QString aTimeFormat, QWidget *aParent = 0 );\r
//! Destructor.\r
virtual ~RoomStatusIndicatorWidget();\r
+ \r
+ bool event(QEvent *event);\r
\r
public slots:\r
//! Slot. Sets current time.\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