fetchMeetings(iClock->datetime(), iClock->datetime().addDays( 7), room);
}
- bool Engine::isMeetingInList( const QList<Meeting*> &aList, const Meeting *aMeeting )
-void Engine::fetchMeetingDetails(Meeting *aMeeting)
-{
- qDebug() << "Engine::fetchMeetingDetails( Meeting* )";
- iWindowManager->showProgressBar(tr("Please Wait"), true);
- iWindowManager->updateProgressBar(tr("Fetching Meeting Details...") );
- connect(iWindowManager,
- SIGNAL( progressBarCancelled() ), this,
- SLOT( fetchMeetingDetailsCancelled() ));
- iCommunication->fetchMeetingDetails( *aMeeting);
-}
-
-<<<<<<< HEAD:src/BusinessLogic/Engine.cpp
-void Engine::meetingsFetched( const QList<Meeting*> &aMeetings )
-{
- qDebug() << "Engine::meetingsFetched( const QList<Meeting*> & )";
-
- for ( int i = 0; i < iMeetings.count(); ++i ) {
- Meeting* m = iMeetings.takeAt( i );
- delete m;
- }
- iMeetings.clear();
- for ( int i = 0; i < aMeetings.count(); ++i ) {
- Meeting* m = new Meeting( *(aMeetings.at( i )) );
- iMeetings.append( m );
-=======
+ bool Engine::isMeetingInList(const QList<Meeting*> &aList, const Meeting *aMeeting)
{
qDebug()
<< "Engine::isMeetingInList( const QList<Meeting*> &, const Meeting * )";
void Engine::meetingsFetched(const QList<Meeting*> &aMeetings)
{
qDebug() << "Engine::meetingsFetched( const QList<Meeting*> & )";
++
// check if there is any new meeting in the list came from the server -> added
for (int i = 0; i < aMeetings.count(); i++)
{
// add to the local database =)
Meeting* m = new Meeting( *(aMeetings.at( i )) );
iMeetings.append(m);
-- // and signal the changes
- iWindowManager->insertMeeting(m);
}
}
if ( !isMeetingInList(aMeetings, iMeetings.at(i) ) )
{
Meeting* m = iMeetings.takeAt(i);
-- // signal the changes
- iWindowManager->deleteMeeting(m);
// delete the meeting from the local list
delete m;
}
--- /dev/null
+#include "UIManager.h"
+
+#include <QDateTime>
+#include <QTime>
+
+#include "Engine.h"
+#include "WindowManager.h"
+#include "ViewBase.h"
+#include "WeeklyViewWidget.h"
+#include "SettingsView.h"
+#include "RoomStatusIndicatorWidget.h"
+#include "MeetingInfoDialog.h"
+#include "ProgressBar.h"
+#include "CommunicationManager.h"
+#include "Configuration.h"
+#include "DisplaySettings.h"
+
+#include <QtDebug>
+
+#define QT_DELETE(X) \
+ if ( X != 0 ) \
+ { \
+ delete X; \
+ X = 0; \
+ }
+
+UIManager::UIManager( Engine *aEngine, WindowManager *aWindowManager ) :
+ iEngine( aEngine ),
+ iWindowManager( aWindowManager ),
+ iWeeklyView( 0 ),
+ iSettingsView( 0 ),
+ iRoomStatusIndicator( 0 ),
+ iPasswordDialog( 0 ),
+ iProgressBar( 0 ),
+ iMeetingInfo( 0 )
+{
+ if ( iEngine == 0 ) return;
+ if ( iWindowManager == 0 ) return;
+
+ qDebug() << "[UIManager::ctor] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";
+
+ createWeeklyView();
+ createSettingsView();
+ createRoomStatusIndicator();
+ createPasswordDialog();
+ createProgressBar();
+ createMeetingInfoDialog();
+
+ qDebug() << "[UIManager::ctor] <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>";
+}
+
+UIManager::~UIManager()
+{
+ iEngine = 0;
+ iWindowManager = 0;
+
+ QT_DELETE( iMeetingInfo );
+ QT_DELETE( iProgressBar );
+ QT_DELETE( iPasswordDialog );
+ QT_DELETE( iRoomStatusIndicator );
+ QT_DELETE( iSettingsView );
+ QT_DELETE( iWeeklyView );
+}
+
+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()
+{
+ iWeeklyView = new WeeklyViewWidget( QDateTime::currentDateTime(), iEngine->iConfiguration );
+
+ // 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()
+{
+ iSettingsView = new SettingsView;
+
+ // Connect signals
+ connect( iSettingsView, SIGNAL( okClicked() ), this, SLOT( settingsOkClicked() ) );
+}
+
+void UIManager::createRoomStatusIndicator()
+{
+ iRoomStatusIndicator = new RoomStatusIndicatorWidget( iEngine->defaultRoom(), Room::FreeStatus, QTime::currentTime(), iEngine->iConfiguration->displaySettings()->dateFormat() );
+}
+
+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"), 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 & ) ), this, SLOT( updateProgressBarText( const QString & ) ) );
+ connect( aDeviceManager, SIGNAL( changeModeFailed() ), this, SLOT( hideProgressBar() ) );
+}
+
+void UIManager::connectCommunicationManager( CommunicationManager *aCommunicationManager )
+{
- connect( aCommunicationManager, SIGNAL( meetingDetailsFetched( Meeting & ) ), this, SLOT( meetingDetailsFetched( 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()
+{
+ // Show the settings view and stop the idle timer
+ if ( iSettingsView != 0 )
+ {
+ iWindowManager->showView( static_cast<ViewBase *>( iSettingsView ) );
+ iEngine->stopIdleTimeCounter();
+ }
+}
+
+void UIManager::settingsOkClicked()
+{
+ // Show the weekly view and restart the idle timer
+ if ( iWeeklyView != 0 )
+ {
+ iWindowManager->showView( static_cast<ViewBase *>( iWeeklyView ) );
+ iEngine->startIdleTimeCounter();
+ }
+}
+
+void UIManager::meetingsFetched( const QList<Meeting*> &aMeetings )
+{
- qDebug() << "[UIManager::meetingsFetched] <SHOULD NOT SIMPLY INSERT MEETINGS TO WEEKLYVIEW !!!>";
- for ( int i = 0; i < aMeetings.count(); i++ )
++ qDebug() << "[UIManager::meetingsFetched] <Change the weekly views method to slot so we don't need this>";
++ if ( iWeeklyView != 0 )
+ {
- Meeting *m = new Meeting( *( aMeetings.at(i) ) );
- iWeeklyView->insertMeeting( m );
++ iWeeklyView->refreshMeetings( aMeetings );
+ }
+}
+
+void UIManager::showMeetingProgressBar( Meeting *aMeeting )
+{
+ if ( iProgressBar != 0 )
+ {
+ iProgressBar->update( tr("Fetching meeting info...") );
+ iWindowManager->showDialog( static_cast<QDialog *>( iProgressBar ), false );
+ }
+}
+
+void UIManager::meetingDetailsFetched(Meeting &aDetailedMeeting)
+{
+ qDebug() << "[UIManager::meetingDetailsFetched] <Invoked>";
+ if ( iMeetingInfo != 0 )
+ {
+ if ( iProgressBar != 0 && iProgressBar->isVisible() )
+ {
+ iProgressBar->close(); // Close it in case it's visible
+ }
+ // iMeetingInfo->setMeeting( &aDetailedMeeting );
+ MeetingInfoDialog *tmp = new MeetingInfoDialog( &aDetailedMeeting );
+ iWindowManager->showDialog( static_cast<QDialog *>( tmp/*iMeetingInfo*/ ) );
+ }
+}
+
+void UIManager::roomStatusIndicatorRequested()
+{
+ if ( iRoomStatusIndicator != 0 )
+ {
+ iWindowManager->showView( static_cast<ViewBase *>( iRoomStatusIndicator ) );
+ iEngine->stopIdleTimeCounter();
+ }
+}
+
+void UIManager::previousViewRestored()
+{
+ iEngine->startIdleTimeCounter();
+}
+
+void UIManager::progressBarCancelled()
+{
+ 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
+ iWindowManager->showDialog( static_cast<QDialog *>( iPasswordDialog ) );
+ }
+}
+
+void UIManager::currentRoomChanged(Room *aRoom)
+{
+ if ( iWeeklyView != 0 )
+ {
+ QDateTime from = QDateTime( iWeeklyView->beginnigOfShownWeek() );
+ QDateTime to = QDateTime( from.addDays( 8 ) );
+ iEngine->fetchMeetings( from, to, aRoom );
+ }
+}
+
+void UIManager::updateTime(QDateTime aDateTime)
+{
+ if ( iWeeklyView != 0 )
+ {
+ 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();
+ }
+}
// ******************************************\r
// Handle all the signal connections\r
// TODO : this solution if interaction monitoring is not elegant enough\r
- connect( iPreviousWeekButton, SIGNAL( clicked() ), this, SIGNAL( observedEventDetected() ) );\r
- connect( iCurrentWeekButton, SIGNAL( clicked() ), this, SIGNAL( observedEventDetected() ) );\r
- connect( iNextWeekButton, SIGNAL( clicked() ), this, SIGNAL( observedEventDetected() ) );\r
- connect( iRoomsCombo, SIGNAL( currentRoomChanged( Room * ) ), this, SIGNAL( observedEventDetected() ) );\r
- connect( iRoomsCombo, SIGNAL( currentIndexChanged( int ) ), this, SIGNAL( observedEventDetected() ) );\r
+// connect( iPreviousWeekButton, SIGNAL( clicked() ), this, SIGNAL( observedEventDetected() ) );\r
+// connect( iCurrentWeekButton, SIGNAL( clicked() ), this, SIGNAL( observedEventDetected() ) );\r
+// connect( iNextWeekButton, SIGNAL( clicked() ), this, SIGNAL( observedEventDetected() ) );\r
+// connect( iRoomsCombo, SIGNAL( currentRoomChanged( Room * ) ), this, SIGNAL( observedEventDetected() ) );\r
+// connect( iRoomsCombo, SIGNAL( currentIndexChanged( int ) ), this, SIGNAL( observedEventDetected() ) );\r
// TODO: connect RoomCombo signals to change meetings data.\r
- connect( iRoomsCombo, SIGNAL( currentRoomChanged( Room * ) ), iSchedule, SLOT( clear() ) );\r
connect( iRoomsCombo, SIGNAL( currentRoomChanged( Room * ) ), this, SIGNAL( currentRoomChanged( Room * ) ) );\r
connect( iRoomsCombo, SIGNAL( currentRoomChanged( Room * ) ), iSchedule, SLOT( refresh() ) );\r
}\r