#include "WeeklyViewWidget.h"
#include "SettingsView.h"
#include "RoomStatusIndicatorWidget.h"
-#include "PasswordDialog.h"
#include "MeetingInfoDialog.h"
#include "ProgressBar.h"
#include "CommunicationManager.h"
if ( iEngine == 0 ) return;
if ( iWindowManager == 0 ) return;
+ connect(iWindowManager, SIGNAL(showSettingsClicked()), this, SLOT(settingsViewRequest()));
+
createWeeklyView();
- createSettingsView();
createRoomStatusIndicator();
createPasswordDialog();
createProgressBar();
iWindowManager->showView( iWeeklyView );
}
-void UIManager::showProgressBar( QString aText )
-{
- if ( iProgressBar != 0 )
- {
- iProgressBar->update( tr("Changing current operation mode.") );
- iWindowManager->showDialog( iProgressBar );
- }
-}
-
// ===============================================
// INITIALIZE THE UIMANAGER
void UIManager::createWeeklyView()
{
iWeeklyView = new WeeklyViewWidget( QDateTime::currentDateTime(), iEngine->iConfiguration );
- // Connect signals
+ // Connect signals to UIManager
connect( iWeeklyView, SIGNAL( settingsButtonClicked() ), this, SLOT( settingsViewRequest() ) );
connect( iWeeklyView, SIGNAL( currentRoomChanged( Room * ) ), this, SLOT( currentRoomChanged( Room * ) ) );
+ connect( iWeeklyView, SIGNAL( meetingActivated( Meeting * ) ), this, SLOT( showMeetingProgressBar( Meeting * ) ) );
+ // Connect signals to engine
+ connect( iWeeklyView, SIGNAL( refreshButtonClicked() ), iEngine, SLOT( updateRoomInfo() ) );
+ connect( iWeeklyView, SIGNAL( meetingActivated( Meeting * ) ), iEngine, SLOT( fetchMeetingDetails( Meeting * ) ) );
+ connect( iWeeklyView, SIGNAL( shownWeekChanged( QDate ) ), iEngine, SLOT( shownWeekChanged( QDate ) ) );
+ connect( iWeeklyView, SIGNAL( currentRoomChanged( Room * ) ), iEngine, SLOT( currentRoomChanged( Room * ) ) );
}
void UIManager::createSettingsView()
// Connect signals
connect( iSettingsView, SIGNAL( okClicked() ), this, SLOT( settingsOkClicked() ) );
+ connect( iSettingsView, SIGNAL( cancelClicked() ), this, SLOT( settingsCancelClicked() ) );
}
void UIManager::createRoomStatusIndicator()
{
- iRoomStatusIndicator = new RoomStatusIndicatorWidget( iEngine->defaultRoom(), Room::FreeStatus, QTime::currentTime(), iEngine->iConfiguration->displaySettings()->dateFormat() );
+ iRoomStatusIndicator = new RoomStatusIndicatorWidget( iEngine->defaultRoom(), Room::FreeStatus, QTime::currentTime(), iEngine->iConfiguration->displaySettings()->timeFormat() );
+ connect( iEngine, SIGNAL( roomStatusChanged( Room::Status, QTime ) ), iRoomStatusIndicator, SLOT( statusChanged( Room::Status, QTime ) ) );
+ connect( iWeeklyView, SIGNAL( currentRoomChanged( Room * ) ), iRoomStatusIndicator, SLOT( currentRoomChanged( Room * ) ) );
}
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") );
-
- connect( iProgressBar, SIGNAL( cancelled() ), this, SLOT( progressBarCancelled() ) );
- connect( iProgressBar, SIGNAL( cancelled() ), iEngine, SLOT( progressBarCancelled() ) );
+ iProgressBar = new ProgressBar( tr("CHANGE THIS"), true );
+ // Connect to UIManager
+ connect( iProgressBar, SIGNAL( cancel() ), this, SLOT( progressBarCancelled() ) );
+ // Connect to Engine
+ connect( iProgressBar, SIGNAL( cancel() ), iEngine, SLOT( cancelFetchMeetingDetails() ) );
}
void UIManager::createMeetingInfoDialog()
{
-
+ iMeetingInfo = new MeetingInfoDialog();
}
void UIManager::connectDeviceManager( DeviceManager *aDeviceManager )
connect( aDeviceManager, SIGNAL( changeModeOrdered( DeviceManager::OperationMode ) ),
this, SLOT( changeModeOrdered( DeviceManager::OperationMode ) ) );
- connect( aDeviceManager, SIGNAL( changingMode( const QString & ) ), iProgressBar, SLOT( update( const QString & ) ) );
+ connect( aDeviceManager, SIGNAL( changingMode( const QString & ) ), this, SLOT( updateProgressBarText( const QString & ) ) );
+ connect( aDeviceManager, SIGNAL( changeModeFailed() ), this, SLOT( hideProgressBar() ) );
}
void UIManager::connectCommunicationManager( CommunicationManager *aCommunicationManager )
{
- // To communication manager
- connect( iWeeklyView, SIGNAL( meetingActivated( Meeting * ) ), aCommunicationManager, SLOT( fetchMeetingDetails( Meeting * ) ) );
-
- // From communication manager
- connect( aCommunicationManager, SIGNAL( meetingsFetched( const QList<Meeting *> ) ), this, SLOT( meetingsFetched( const QList<Meeting *> ) ) );
connect( aCommunicationManager, SIGNAL( meetingDetailsFetched( Meeting & ) ), this, SLOT( meetingDetailsFetched( Meeting & ) ) );
+ connect( aCommunicationManager, SIGNAL( meetingsFetched( const QList<Meeting *> & ) ), this, SLOT( meetingsFetched( const QList<Meeting *> & ) ) );
}
// ============================================
// UIMANAGER SLOTS
void UIManager::settingsViewRequest()
{
+ createSettingsView();
+
// Show the settings view and stop the idle timer
- if ( iSettingsView != 0 )
- {
- iWindowManager->showView( static_cast<ViewBase *>( iSettingsView ) );
- iEngine->stopIdleTimeCounter();
- }
+ iWindowManager->showView( static_cast<ViewBase *>( iSettingsView ) );
+ iEngine->stopIdleTimeCounter();
}
void UIManager::settingsOkClicked()
{
// Show the weekly view and restart the idle timer
+ QT_DELETE(iWeeklyView);
+ createWeeklyView();
+
if ( iWeeklyView != 0 )
{
iWindowManager->showView( static_cast<ViewBase *>( iWeeklyView ) );
+ QT_DELETE(iSettingsView);
iEngine->startIdleTimeCounter();
+ currentRoomChanged(iWeeklyView->currentRoom());
}
}
void UIManager::meetingsFetched( const QList<Meeting*> &aMeetings )
{
-
+ qDebug() << "[UIManager::meetingsFetched] <Change the weekly views method to slot so we don't need this>";
+ if ( iWeeklyView != 0 )
+ {
+ iWeeklyView->refreshMeetings( aMeetings );
+ }
+}
+
+void UIManager::showMeetingProgressBar( Meeting */*aMeeting*/ )
+{
+ if ( iProgressBar != 0 )
+ {
+ iProgressBar->update( tr( "Fetching meeting info..." ), tr( "Please wait" ) );
+ iProgressBar->toggleCancellable( true );
+ iWindowManager->showDialog( static_cast<QDialog *>( iProgressBar ), false, false );
+ }
}
void UIManager::meetingDetailsFetched(Meeting &aDetailedMeeting)
{
+ qDebug() << "[UIManager::meetingDetailsFetched] <Invoked>";
if ( iMeetingInfo != 0 )
{
- iMeetingInfo->setMeeting( &aDetailedMeeting );
- iWindowManager->showDialog( static_cast<QDialog *>( iMeetingInfo ) );
+ if ( iProgressBar != 0 && iProgressBar->isVisible() )
+ {
+ iProgressBar->close(); // Close it in case it's visible
+ }
+ MeetingInfoDialog *tmp = new MeetingInfoDialog( &aDetailedMeeting );
+ iWindowManager->showDialog( static_cast<QDialog *>( tmp ) );
+// TODO : We should use the member variable and implement correctly the setMeeting() method !!!
+// iMeetingInfo->setMeeting( &aDetailedMeeting );
+// iWindowManager->showDialog( static_cast<QDialog *>( iMeetingInfo ) );
}
}
void UIManager::progressBarCancelled()
{
- // TODO : Close progress bar
+ if ( iProgressBar != 0 )
+ {
+ iProgressBar->close();
+ }
}
void UIManager::changeModeOrdered( DeviceManager::OperationMode aMode )
{
qDebug() << "[UIManager::changeModeOrdered] <Invoked>";
-
- QString message = tr( "You are about to change operation mode to %1." )
- .arg( iEngine->iDevice->operationModeToString( aMode ) );
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();
+ iRoomStatusIndicator->connectionLost();
+}
+
+void UIManager::connectionEstablished()
+{
+ qDebug() << "UIManager::connectionEstablished()";
+ iWeeklyView->connectionEstablished();
+ iRoomStatusIndicator->connectionEstablished();
+}
+
void UIManager::currentRoomChanged(Room *aRoom)
{
+ qDebug() << "[UIManager::currentRoomChanged] <Invoked>";
if ( iWeeklyView != 0 )
{
- QDateTime from = QDateTime( iWeeklyView->beginnigOfShownWeek() );
- QDateTime to = QDateTime( from.addDays( 8 ) );
- iEngine->fetchMeetings( from, to, aRoom );
+ QDateTime shown = QDateTime( iWeeklyView->beginnigOfShownWeek() );
+ iEngine->fetchMeetings( shown.date().weekNumber(), shown.date().year(), aRoom );
}
}
{
if ( iWeeklyView != 0 )
{
- iWeeklyView->setCurrentDateTime( aDateTime );
+ iWeeklyView->setConnectionStatus( aDateTime, iEngine->connected(), iEngine->lastUpdated(), iEngine->errorMessage() );
+ }
+ if ( iRoomStatusIndicator != 0 )
+ {
+ iRoomStatusIndicator->setConnectionStatus( aDateTime, iEngine->connected(), iEngine->lastUpdated(), iEngine->errorMessage() );
+ }
+}
+
+void UIManager::passwordEntered( PasswordDialog::PasswordStatus aStatus )
+{
+ switch( aStatus )
+ {
+ case PasswordDialog::Correct:
+ // Show the progress bar..
+ if ( iProgressBar != 0 )
+ {
+ 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();
+ break;
+ case PasswordDialog::Incorrect:
+ iWindowManager->error( tr("Incorrect Password") );
+ break;
+ case PasswordDialog::Canceled:
+ break;
+ }
+
+ // Close the dialog after we have handled the status
+ if ( iPasswordDialog != 0 )
+ {
+ iPasswordDialog->close();
+ }
+}
+
+void UIManager::updateProgressBarText(const QString &aText)
+{
+ if ( iProgressBar != 0 )
+ {
+ iProgressBar->update( aText );
+ }
+}
+
+void UIManager::hideProgressBar()
+{
+ qDebug() << "[UIManager::hideProgressBar] <Invoked>";
+ if ( iProgressBar != 0 && iProgressBar->isVisible() )
+ {
+ iProgressBar->close();
+ }
+}
+
+void UIManager::settingsCancelClicked()
+{
+ // Show the weekly view and restart the idle timer
+ if ( iWeeklyView != 0 )
+ {
+ iWindowManager->showView( static_cast<ViewBase *>( iWeeklyView ) );
+ QT_DELETE(iSettingsView);
+ iEngine->startIdleTimeCounter();
}
}