User interface update
[qtmeetings] / src / BusinessLogic / UIManager.cpp
index a540f96..6adc9e5 100644 (file)
@@ -37,16 +37,13 @@ UIManager::UIManager( Engine *aEngine, WindowManager *aWindowManager ) :
        if ( iEngine == 0 ) return;
        if ( iWindowManager == 0 ) return;
        
-       qDebug() << "[UIManager::ctor] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";
-       
+       connect(iWindowManager, SIGNAL(showSettingsClicked()), this, SLOT(settingsViewRequest()));
+
        createWeeklyView();
-       createSettingsView();
        createRoomStatusIndicator();
        createPasswordDialog();
        createProgressBar();
        createMeetingInfoDialog();
-       
-       qDebug() << "[UIManager::ctor] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";
 }
 
 UIManager::~UIManager()
@@ -67,15 +64,6 @@ void UIManager::showMainView()
        iWindowManager->showView( iWeeklyView );
 }
 
-void UIManager::showProgressBar( QString aText )
-{
-       if ( iProgressBar != 0 )
-       {
-               iProgressBar->update( aText );
-               iWindowManager->showDialog( iProgressBar );
-       }
-}
-
 // ===============================================
 //             INITIALIZE THE UIMANAGER
 void UIManager::createWeeklyView()
@@ -98,24 +86,25 @@ 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"), true );
-       
        // Connect to UIManager
        connect( iProgressBar, SIGNAL( cancel() ), this, SLOT( progressBarCancelled() ) );
        // Connect to Engine
@@ -146,12 +135,11 @@ void UIManager::connectCommunicationManager( CommunicationManager *aCommunicatio
 //             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()
@@ -160,7 +148,9 @@ void UIManager::settingsOkClicked()
        if ( iWeeklyView != 0 )
        {
                iWindowManager->showView( static_cast<ViewBase *>( iWeeklyView ) );
+               QT_DELETE(iSettingsView);
                iEngine->startIdleTimeCounter();
+               currentRoomChanged(iWeeklyView->currentRoom());
        }
 }
 
@@ -177,9 +167,9 @@ void UIManager::showMeetingProgressBar( Meeting *aMeeting )
 {
        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();
        }
 }
 
@@ -219,20 +209,18 @@ void UIManager::progressBarCancelled()
        if ( iProgressBar != 0 )
        {
                iProgressBar->close();
-               iEngine->startIdleTimeCounter();
        }
 }
 
 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 ) );
        }
 }
@@ -241,7 +229,6 @@ void UIManager::connectionLost()
 {
        qDebug() << "UIManager::connectionLost()";
        iWeeklyView->connectionLost();
-       iSettingsView->connectionLost();
        iRoomStatusIndicator->connectionLost();
 }
 
@@ -249,17 +236,16 @@ 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() );
-               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 );
        }
 }
 
@@ -269,6 +255,10 @@ void UIManager::updateTime(QDateTime aDateTime)
        {
                iWeeklyView->setCurrentDateTime( aDateTime );
        }
+       if ( iRoomStatusIndicator != 0 )
+       {
+               iRoomStatusIndicator->setCurrentTime( aDateTime.time() );
+       }
 }
 
 void UIManager::passwordEntered( PasswordDialog::PasswordStatus aStatus )
@@ -279,15 +269,17 @@ void UIManager::passwordEntered( PasswordDialog::PasswordStatus aStatus )
                        // 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;
        }
        
@@ -314,3 +306,14 @@ void UIManager::hideProgressBar()
                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();
+       }
+}