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 ) );
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 );
iWindowManager->show();
iUIManager->showMainView();
+ // This triggers the meeting fetching
+ iUIManager->currentRoomChanged( this->iCurrentRoom );
+
qDebug() << "[Engine::initUserInterface] <Finished>";
}
void Engine::currentRoomChanged(Room *aRoom)
{
+ qDebug() << "[Engine::currentRoomChanged] <invoked>";
iCurrentRoom = aRoom;
}
if ( iEngine == 0 ) return;
if ( iWindowManager == 0 ) return;
- qDebug() << "[UIManager::ctor] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";
-
createWeeklyView();
createSettingsView();
createRoomStatusIndicator();
createPasswordDialog();
createProgressBar();
createMeetingInfoDialog();
-
- qDebug() << "[UIManager::ctor] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";
}
UIManager::~UIManager()
}
}
+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>";
if ( iWeeklyView != 0 )
{
QDateTime from = QDateTime( iWeeklyView->beginnigOfShownWeek() );
class CommunicationManager;
class QDateTime;
+ //! User Interface manager class.
+ /*!
+ * User Interface manager class that is responsible for handling
+ * UI actions. It creates the needed views and connects signals
+ * accordingly. All interactions with the UI is handled by this
+ * class. The Engine class handles the basic logic and does not
+ * know or care about the UI and this class does not know or care
+ * about the basic logic only UI related actions (signals, events etc.).
+ */
class UIManager : public QObject
{
Q_OBJECT
UIManager( Engine *aEngine, WindowManager *aWindowManager );
virtual ~UIManager();
+ //! Connects Device Managers signals.
+ /*!
+ * This method connects Device Managers signals directly to UI
+ * components or to it selft.
+ */
void connectDeviceManager( DeviceManager *aDeviceManager );
+ //! Connects Communication Managers signals.
+ /*!
+ * This method connects Communication Managers signals directly to UI
+ * components or to it selft.
+ */
void connectCommunicationManager( CommunicationManager *aCommunicationManager );
+ //! Shows the main view.
+ /*!
+ * 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:
public slots:
+ //! Handles setting view request.
+ /*!
+ * Handles request to show settings view. Makes the
+ * view visible and stops the idle time counter.
+ */
void settingsViewRequest();
+ //! Handles setting views ok clicked.
+ /*!
+ * Handles the setting views Ok button clicked
+ * signal. Sets the weekly view visible and starts
+ * the idle time counter.
+ */
void settingsOkClicked();
+ //! Handles room status indicator view request.
+ /*!
+ * Handles the request to show room status indicator
+ * view. Sets the view visible and stops the idle
+ * time counter. The WindowManager handles restoring
+ * what ever view was previously visible.
+ */
void roomStatusIndicatorRequested();
+ //! Handles previousViewRestored signal.
+ /*!
+ * Handles the restoring of previous view. This is usually
+ * signaled by WindowManager when room status indicator
+ * view is being hidden.
+ */
void previousViewRestored();
+ //! Handle change mode order.
+ /*!
+ * Handles change mode order. Displays the password query dialog
+ * and waits for its response.
+ */
void changeModeOrdered( DeviceManager::OperationMode aMode );
+ //! Handles select room change.
+ /*!
+ * Handles the changing of currently select room. Engine is requested
+ * 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:
void meetingsFetched( const QList<Meeting*> &aMeetings );
void meetingDetailsFetched( Meeting &aDetailedMeeting );
- void currentRoomChanged( Room *aRoom );
void progressBarCancelled();
void updateTime( QDateTime aDateTime );
void passwordEntered( PasswordDialog::PasswordStatus aStatus );
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
setPalette( createPalette( aStatus ) );\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
ViewBase::ViewBase( ViewBase::ViewMode aMode, QWidget *aParent ) : QWidget( aParent ), iViewMode( aMode )
{
--
++ connectedOnce = false;
++ connectionError = false;
}
ViewBase::~ViewBase()
return iViewMode;
}
+void ViewBase::connectionEstablished()
+{
+ connectedOnce = true;
+ connectionError = false;
+}
+
+void ViewBase::connectionLost()
+{
+ connectionError = true;
+}
+
+
bool ViewBase::event(QEvent *event)
{
switch( event->type() )