Still working
[qtmeetings] / src / BusinessLogic / UIManager.cpp
index 9da0a8a..19f445f 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"
@@ -38,12 +37,16 @@ UIManager::UIManager( Engine *aEngine, WindowManager *aWindowManager ) :
        if ( iEngine == 0 ) return;
        if ( iWindowManager == 0 ) return;
        
+       qDebug() << "[UIManager::ctor] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";
+       
        createWeeklyView();
        createSettingsView();
        createRoomStatusIndicator();
        createPasswordDialog();
        createProgressBar();
        createMeetingInfoDialog();
+       
+       qDebug() << "[UIManager::ctor] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";
 }
 
 UIManager::~UIManager()
@@ -79,9 +82,13 @@ 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 ) ) );
 }
 
 void UIManager::createSettingsView()
@@ -100,19 +107,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") );
        
-       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,16 +131,11 @@ 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 & ) ) );
 }
 
 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 & ) ) );
 }
 
@@ -160,10 +166,23 @@ void UIManager::meetingsFetched( const QList<Meeting*> &aMeetings )
        
 }
 
+void UIManager::showMeetingProgressBar( Meeting *aMeeting )
+{
+       if ( iProgressBar != 0 )
+       {
+               iProgressBar->update( tr("Fetching meeting info...") );
+               iWindowManager->showDialog( static_cast<QDialog *>( iProgressBar ) );
+       }
+}
+
 void UIManager::meetingDetailsFetched(Meeting &aDetailedMeeting)
 {
        if ( iMeetingInfo != 0 )
        {
+               if ( iProgressBar != 0 )
+               {
+                       iProgressBar->close(); // Close it in case it's visible
+               }
                iMeetingInfo->setMeeting( &aDetailedMeeting );
                iWindowManager->showDialog( static_cast<QDialog *>( iMeetingInfo ) );
        }
@@ -185,7 +204,10 @@ void UIManager::previousViewRestored()
 
 void UIManager::progressBarCancelled()
 {
-       // TODO : Close progress bar
+       if ( iProgressBar != 0 )
+       {
+               iProgressBar->close();
+       }
 }
 
 void UIManager::changeModeOrdered( DeviceManager::OperationMode aMode )
@@ -219,3 +241,38 @@ 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 ) );
+                       }
+                       // ... 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 );
+       }
+}