Changed something cannot remember what
[qtmeetings] / src / BusinessLogic / UIManager.cpp
index 9da0a8a..253e45a 100644 (file)
@@ -9,7 +9,6 @@
 #include "WeeklyViewWidget.h"
 #include "SettingsView.h"
 #include "RoomStatusIndicatorWidget.h"
-#include "PasswordDialog.h"
 #include "MeetingInfoDialog.h"
 #include "ProgressBar.h"
 #include "CommunicationManager.h"
@@ -68,7 +67,7 @@ void UIManager::showProgressBar( QString aText )
 {
        if ( iProgressBar != 0 )
        {
-               iProgressBar->update( tr("Changing current operation mode.") );
+               iProgressBar->update( aText );
                iWindowManager->showDialog( iProgressBar );
        }
 }
@@ -79,9 +78,14 @@ 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( 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()
@@ -100,19 +104,23 @@ void UIManager::createRoomStatusIndicator()
 void UIManager::createPasswordDialog()
 {
        iPasswordDialog = new PasswordDialog( iEngine->iConfiguration->adminPassword(), tr("UIManager::createPasswordDialog"), tr("UIManager::createPasswordDialog") );
+       
+       connect( iPasswordDialog, SIGNAL( passwordEntered( PasswordDialog::PasswordStatus ) ), this, SLOT( passwordEntered( PasswordDialog::PasswordStatus ) ) );
 }
 
 void UIManager::createProgressBar()
 {
-       iProgressBar = new ProgressBar( tr("CHANGE THIS") );
+       iProgressBar = new ProgressBar( tr("CHANGE THIS"), true );
        
-       connect( iProgressBar, SIGNAL( cancelled() ), this, SLOT( progressBarCancelled() ) );
-       connect( iProgressBar, SIGNAL( cancelled() ), iEngine, SLOT( progressBarCancelled() ) );
+       // 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 )
@@ -120,17 +128,14 @@ 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 *> & ) ) );
 }
 
 // ============================================
@@ -157,15 +162,39 @@ void UIManager::settingsOkClicked()
 
 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...") );
+               iWindowManager->showDialog( static_cast<QDialog *>( iProgressBar ), false, false );
+               iEngine->stopIdleTimeCounter();
+       }
 }
 
 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
+               }
+               iEngine->stopIdleTimeCounter(); // Timer restarted when the dialog is dismissed.
+               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 ) );
        }
 }
 
@@ -185,7 +214,11 @@ void UIManager::previousViewRestored()
 
 void UIManager::progressBarCancelled()
 {
-       // TODO : Close progress bar
+       if ( iProgressBar != 0 )
+       {
+               iProgressBar->close();
+               iEngine->startIdleTimeCounter();
+       }
 }
 
 void UIManager::changeModeOrdered( DeviceManager::OperationMode aMode )
@@ -204,6 +237,7 @@ void UIManager::changeModeOrdered( DeviceManager::OperationMode aMode )
 
 void UIManager::currentRoomChanged(Room *aRoom)
 {
+       qDebug() << "[UIManager::currentRoomChanged] <Invoked>";
        if ( iWeeklyView != 0 )
        {
                QDateTime from = QDateTime( iWeeklyView->beginnigOfShownWeek() );
@@ -219,3 +253,47 @@ void UIManager::updateTime(QDateTime aDateTime)
                iWeeklyView->setCurrentDateTime( aDateTime );
        }
 }
+
+void UIManager::passwordEntered( PasswordDialog::PasswordStatus aStatus )
+{
+       switch( aStatus )
+       {
+               case PasswordDialog::Correct:
+                       // Show the progress bar..
+                       if ( iProgressBar != 0 )
+                       {
+                               iWindowManager->showDialog( static_cast<QDialog *>( iProgressBar ), false );
+                       }
+                       // ... and initiate the mode changing
+                       iEngine->changeDeviceMode( true );
+                       break;
+               case PasswordDialog::Incorrect:
+                       iWindowManager->error( tr("Incorrect Password") );
+               case PasswordDialog::Canceled:
+                       iEngine->changeDeviceMode( false );
+                       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();
+       }
+}