src/UserInterface/Components/ \
src/UserInterface/Utils/ \
src/UserInterface/Views/
-HEADERS += src/IO/DeviceControl/OperationModeToggler.h \
+HEADERS += src/BusinessLogic/UIManager.h \
+ src/IO/DeviceControl/OperationModeToggler.h \
src/UserInterface/Utils/ProgressBar.h \
src/Domain/Room.h \
src/Domain/Meeting.h \
src/UserInterface/Views/WeeklyViewWidget.h \
src/UserInterface/Views/MeetingInfoDialog.h \
src/UserInterface/Views/SettingsView.h \
- src/UserInterface/WindowManager.h
-SOURCES += src/IO/DeviceControl/OperationModeToggler.cpp \
+ src/UserInterface/WindowManager.h \
+ src/UserInterface/Views/ViewBase.h
+SOURCES += src/BusinessLogic/UIManager.cpp \
+ src/IO/DeviceControl/OperationModeToggler.cpp \
src/UserInterface/Utils/ProgressBar.cpp \
src/Domain/Room.cpp \
src/Domain/Meeting.cpp \
src/UserInterface/Views/MeetingInfoDialog.cpp \
src/UserInterface/Views/SettingsView.cpp \
src/UserInterface/WindowManager.cpp \
+ src/UserInterface/Views/ViewBase.cpp \
src/main.cpp
RESOURCES += resources/BusinessLogic.qrc \
resources/UserInterface.qrc
<error code="109">Communication: SOAP error when fetching meeting details</error>
<error code="110">Communication error</error>
<error code="111">Communication: Invalid username or password</error>
- <error code="200">Failed to change the operation mode. Error creating internal file storage.</error>
+ <error code="200">Device Control: Error creating internal file storage.</error>
<error code="201">Failed to change the operation mode. Error removing old alarm events.</error>
<error code="202">Failed to change the operation mode. Error sending alarm events. %1</error>
<error code="203">Failed to change the operation mode. Error storing data about sent alarm events. Removing the already sent alarm events.</error>
- <error code="204">Failed to change the operation mode. Error fetching data of original hardware key settings.</error>
- <error code="205">Failed to change the operation mode. Error storing data of original hardware key settings.</error>
- <error code="206">Failed to change the operation mode. Error changing hardware key settings.</error>
- <error code="207">Failed to change the operation mode. Init script to auto launch the application was not installed/removed.</error>
- <error code="208">Failed to change the operation mode. The application failed to know the current mode of itself.</error>
- <error code="209">Failed to change the operation mode. The application failed to store the current mode of itself.</error>
- <error code="210">Error storing data of original automatic screen switching-off and dimming parameter values. Using the default values instead.</error>
- <error code="211">Error fetching data of original automatic screen switching-off and dimming parameter values. Using the default values instead.</error>
- <error code="212">Failed to change the operation mode. Error changing automatic screen switching-off and dimming parameter values.</error>
+ <error code="204">Error storing data of original automatic screen switching-off and dimming parameter values. Using the default values instead.</error>
+ <error code="205">Error fetching data of original automatic screen switching-off and dimming parameter values. Using the default values instead.</error>
+ <error code="206">Failed to change the operation mode. Error changing automatic screen switching-off and dimming parameter values.</error>
+ <error code="207">Failed to change the operation mode. Error fetching data of original hardware key settings.</error>
+ <error code="208">Failed to change the operation mode. Error storing data of original hardware key settings.</error>
+ <error code="209">Failed to change the operation mode. Error changing hardware key settings.</error>
+ <error code="210">Failed to change the operation mode. Init script to auto launch the application was not installed/removed.</error>
+ <error code="211">Failed to change the operation mode. The application failed to know the current mode of itself.</error>
+ <error code="212">Failed to change the operation mode. The application failed to store the current mode of itself.</error>
<error code="213">Failed to change the operation mode. Error restarting the device. Restart device manually.</error>
</errors>
#include "Configuration.h"
#include "DisplaySettings.h"
#include "CommunicationManager.h"
-#include "DeviceManager.h"
+// #include "DeviceManager.h"
#include "Clock.h"
#include "ErrorMapper.h"
-#include "WeeklyViewWidget.h"
+#include "UIManager.h"
#include <QApplication>
#include <QTimer>
#include <QList>
#include <QtDebug>
-QTime Engine::endOfTheDay = QTime( 23, 59, 0, 0 ); // end of the day is 11:59pm
+QTime Engine::endOfTheDay = QTime( 23, 59, 0, 0); // end of the day is 11:59pm
const int IDLE_TIME_MULTIPLIER = 60000; // Multiplies milliseconds to minutes
+// Macro to help deleting objects. This could be global.
+#define QT_DELETE(X) \
+ if ( X != 0 ) \
+ { \
+ delete X; \
+ X = 0; \
+ }
+
+
Engine::Engine() :
- iClock( 0 ), iConfiguration( Configuration::instance() ), iCommunication( 0 )
+ iClock( 0 ), iConfiguration( 0 ), iCommunication( 0 ),
+ iWindowManager( 0 ), iUIManager( 0 )
{
qDebug() << "Engine::Engine()";
- // if reading of configuration fails, signal that initialization failed
- if ( iConfiguration == 0 )
- {
- QTimer::singleShot( 0, this, SLOT( closeApplication() ) );
- return;
- }
-
- //initialize window manager
- iWindowManager = new WindowManager( iConfiguration );
- connect( iWindowManager, SIGNAL( roomStatusInfoNeeded( Room * ) ), this, SLOT( roomStatusInfoNeeded( Room * ) ) );
- connect( iWindowManager, SIGNAL( observedEventDetected() ), this, SLOT( observedEventDetected() ) );
- connect( iWindowManager, SIGNAL( meetingActivated( Meeting * ) ), this, SLOT( fetchMeetingDetails( Meeting * ) ) );
- connect( iWindowManager, SIGNAL( currentRoomChanged( Room * ) ), this, SLOT( currentRoomChanged( Room * ) ) );
- connect( iWindowManager, SIGNAL( shownWeekChanged( QDate ) ), this, SLOT( shownWeekChanged( QDate ) ) );
- connect( iWindowManager, SIGNAL( passwordEntered( PasswordDialog::PasswordStatus ) ),
- this, SLOT( passwordEntered( PasswordDialog::PasswordStatus ) ) );
-
- // initialize communication
- iCommunication = new CommunicationManager( *(iConfiguration->connectionSettings()) );
- connect( iCommunication, SIGNAL( error( int, CommunicationManager::CommunicationType ) ),
- this, SLOT( errorHandler( int ) ) );
- connect( iCommunication, SIGNAL( meetingsFetched( const QList<Meeting*>& ) ),
- this, SLOT( meetingsFetched( const QList<Meeting*>& ) ) );
- connect( iCommunication, SIGNAL( meetingDetailsFetched( Meeting& ) ),
- this, SLOT( meetingDetailsFetched( Meeting& ) ) );
-
+ initConfiguration();
+ initDevice();
+ initCommunication();
+ initUserInterface();
+
//initialize idle time counter
iIdleTimeCounter = new QTimer();
- iIdleTimeCounter->setSingleShot( true );
- iIdleTimeCounter->setInterval( IDLE_TIME_MULTIPLIER * iConfiguration->displaySettings()->screensaver() );
+ iIdleTimeCounter->setSingleShot( true);
+ iIdleTimeCounter->setInterval(IDLE_TIME_MULTIPLIER * iConfiguration->displaySettings()->screensaver() );
iIdleTimeCounter->start();
- connect( iIdleTimeCounter, SIGNAL( timeout() ), iWindowManager, SLOT( showRoomStatus() ) );
// create application clock
iClock = new Clock;
connect( iClock, SIGNAL( tick( QDateTime ) ), this, SLOT( checkStatusOfAllRooms() ) );
- connect( iClock, SIGNAL( tick( QDateTime ) ), iWindowManager, SLOT( distributeDateTimeInfo( QDateTime ) ) );
+ // connect( iClock, SIGNAL( tick( QDateTime ) ), iWindowManager, SLOT( distributeDateTimeInfo( QDateTime ) ) );
+ // Create auto refresh timer
iAutoRefresh = new QTimer;
- iAutoRefresh->setInterval( iConfiguration->connectionSettings()->refreshInterval() * 1000 );
+ iAutoRefresh->setInterval(iConfiguration->connectionSettings()->refreshInterval() * 1000);
iAutoRefresh->start();
connect( iAutoRefresh, SIGNAL( timeout() ), iAutoRefresh, SLOT( start() ) );
- connect( iAutoRefresh, SIGNAL( timeout() ), this, SLOT( fetchMeetings() ) );
-
- // create device manager
- iDevice = new DeviceManager( iConfiguration->startupSettings() );
- connect( iDevice, SIGNAL( error( int, const QString& ) ), this, SLOT( errorHandler( int, const QString& ) ) );
- connect( iDevice, SIGNAL( changeModeOrdered( DeviceManager::OperationMode ) ),
- this, SLOT( changeModeOrdered( DeviceManager::OperationMode ) ) );
- iDevice->initDeviceManager();
+ // connect( iAutoRefresh, SIGNAL( timeout() ), this, SLOT( fetchMeetings() ) );
if( iDevice->currentOperationMode() == DeviceManager::KioskMode )
- iWindowManager->fullScreen();
+ {
+ iWindowManager->setFullscreen();
+ }
- QTimer::singleShot( 0, this, SLOT( fetchMeetings() ) );
+ connectSignals();
+
+ // QTimer::singleShot( 0, this, SLOT( fetchMeetings() ) );
// TODO: continue implementation
}
qDebug() << "Engine::~Engine()";
while ( !iMeetings.isEmpty() )
delete iMeetings.takeFirst();
- iIdleTimeCounter->stop();
- delete iIdleTimeCounter;
- iIdleTimeCounter = 0;
- delete iWindowManager;
- iWindowManager = 0;
- delete iClock;
- iClock = 0;
- delete iDevice;
- iDevice = 0;
+
+ if ( iIdleTimeCounter != 0 )
+ {
+ iIdleTimeCounter->stop();
+ delete iIdleTimeCounter;
+ iIdleTimeCounter = 0;
+ }
+ QT_DELETE( iClock );
+ QT_DELETE( iDevice );
+
+ QT_DELETE( iUIManager );
+ QT_DELETE( iWindowManager );
}
void Engine::closeApplication()
{
qDebug() << "Engine::closeApplication()";
// closes application after 1 second
- QTimer::singleShot( 1000, QApplication::instance(), SLOT( quit() ) );
-}
-
-void Engine::observedEventDetected()
-{
- qDebug() << "Engine::observedEventDetected()";
- iWindowManager->showWeeklyView();
- // prepare to restart idle counter
- if ( iIdleTimeCounter->isActive() )
- {
- iIdleTimeCounter->stop();
- }
- // (re)start idle counter
- iIdleTimeCounter->start();
+ QTimer::singleShot( 1000, QApplication::instance(), SLOT( quit() ));
}
Room* Engine::defaultRoom()
void Engine::checkStatusOfAllRooms()
{
- qDebug() << "Engine::checkStatusOfAllRooms()";
+// qDebug() << "Engine::checkStatusOfAllRooms()";
// iterate trough on the rooms
- for ( int i = 0; i < iConfiguration->rooms().count(); i++ )
+ for (int i = 0; i < iConfiguration->rooms().count(); i++)
{
// and check the status
- roomStatusInfoNeeded( iConfiguration->rooms().at( i ) );
+ roomStatusInfoNeeded(iConfiguration->rooms().at(i) );
}
}
-int Engine::indexOfMeetingAt( Room *aRoom, QDateTime aAt )
+int Engine::indexOfMeetingAt(Room *aRoom, QDateTime aAt)
{
- qDebug() << "Engine::indexOfMeetingAt( Room *, QDateTime )";
+// qDebug() << "Engine::indexOfMeetingAt( Room *, QDateTime )";
for ( int i = 0; i < iMeetings.count(); i++ )
{
// exchange server ensures that there is only one meeting in a room at a specified time
- if ( aRoom->equals( iMeetings.at( i )->room() )
- && iMeetings.at( i )->startsAt() <= aAt
- && iMeetings.at( i )->endsAt() >= aAt )
+ if (aRoom->equals(iMeetings.at( i )->room() ) && iMeetings.at( i )->startsAt() <= aAt && iMeetings.at( i )->endsAt() >= aAt)
{
return i;
}
return -1;
}
-int Engine::indexOfMeetingAfter( Room *aRoom, QDateTime aAfter )
+int Engine::indexOfMeetingAfter(Room *aRoom, QDateTime aAfter)
{
- qDebug() << "Engine::indexOfMeetingAfter( Room *, QDateTime )";
+// qDebug() << "Engine::indexOfMeetingAfter( Room *, QDateTime )";
// seeks for the next meeting on the SAME DAY
int min = -1;
- for ( int i = 0; i < iMeetings.count(); i++ )
+ for (int i = 0; i < iMeetings.count(); i++)
{
// if the meeting is in the same room, on the same day but after the specified time
- if ( aRoom->equals( iMeetings.at( i )->room() )
- && iMeetings.at( i )->startsAt().date() == aAfter.date()
- && iMeetings.at( i )->startsAt() > aAfter )
+ if (aRoom->equals(iMeetings.at( i )->room() ) && iMeetings.at( i )->startsAt().date() == aAfter.date() && iMeetings.at( i )->startsAt() > aAfter)
{
// if there was not any meeting find yet or the previously found is a later one then the (i)th
- if ( min == -1
- || iMeetings.at( min )->startsAt() > iMeetings.at( i )->startsAt() )
+ if (min == -1 || iMeetings.at( min )->startsAt() > iMeetings.at( i )->startsAt() )
{
min = i;
}
return min;
}
-void Engine::roomStatusInfoNeeded( Room *aRoom )
+void Engine::roomStatusInfoNeeded(Room *aRoom)
{
- qDebug() << "Engine::roomStatusInfoNeeded( Room * )";
+// qDebug() << "Engine::roomStatusInfoNeeded( Room * )";
if ( aRoom == 0 )
{
return;
}
- int indexOfCurrentMeeting = indexOfMeetingAt( aRoom, iClock->datetime() );
- int indexOfNextMeeting = indexOfMeetingAfter( aRoom, iClock->datetime() );
+ int indexOfCurrentMeeting = indexOfMeetingAt(aRoom, iClock->datetime() );
+ int indexOfNextMeeting = indexOfMeetingAfter(aRoom, iClock->datetime() );
// if there is no meeting, then status is Free; otherwise Busy
- Room::Status status = ( indexOfCurrentMeeting == -1 ) ? Room::FreeStatus : Room::BusyStatus;
+ Room::Status status = (indexOfCurrentMeeting == -1 ) ? Room::FreeStatus : Room::BusyStatus;
// if room is Busy, then check end time, otherwise...
- QTime until = ( status == Room::BusyStatus ) ? iMeetings.at( indexOfCurrentMeeting )->endsAt().time() :
- // ...if there is meeting following on the same day then check end time, otherwise end is the of the working day
- (( indexOfNextMeeting != -1 ) ? iMeetings.at( indexOfNextMeeting )->startsAt().time() : Engine::endOfTheDay );
+ QTime until = (status == Room::BusyStatus ) ? iMeetings.at( indexOfCurrentMeeting )->endsAt().time() :
+ // ...if there is meeting following on the same day then check end time, otherwise end is the of the working day
+ ( ( indexOfNextMeeting != -1 ) ? iMeetings.at( indexOfNextMeeting )->startsAt().time() : Engine::endOfTheDay );
//currently works only for deafult room
- if( aRoom->equals( *(defaultRoom() ) ) )
- iWindowManager->roomStatusChanged( aRoom, status, until );
+// if( aRoom->equals( *(defaultRoom() ) ) )
+// iWindowManager->roomStatusChanged( aRoom, status, until );
}
+/*
void Engine::fetchMeetings()
{
- Room *room = defaultRoom();
- qDebug() << "Engine::fetchMeetings for " << room->name();
- fetchMeetings( iClock->datetime(), iClock->datetime().addDays( 7 ), room );
+ qDebug() << "Engine::fetchMeetings for " << iCurrentRoom;
+ QDateTime from( iWindowManager->weeklyView()->beginnigOfShownWeek() );
+ QDateTime to( from.addDays( 7 ) );
+ // fetchMeetings( from, to, iWindowManager->weeklyView()->currentRoom() );
+ // Signal is connected to the currentRoomChanged slot which keeps the iCurrentRoom up to date
+ fetchMeetings( from, to, iCurrentRoom );
}
+*/
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() )
- );
+/* iWindowManager->showProgressBar(tr("Please Wait"), true);
+ iWindowManager->updateProgressBar(tr("Fetching Meeting Details...") );
+ connect(iWindowManager,
+ SIGNAL( progressBarCancelled() ), this,
+ SLOT( fetchMeetingDetailsCancelled() ));
+ iCommunication->fetchMeetingDetails( *aMeeting); */
iCommunication->fetchMeetingDetails( *aMeeting );
}
-bool Engine::isMeetingInList( const QList<Meeting*> &aList, const Meeting *aMeeting )
-{
- qDebug() << "Engine::isMeetingInList( const QList<Meeting*> &, const Meeting * )";
- for ( int i = 0; i < aList.count(); i++ )
- {
- if ( aMeeting->equals( *(aList.at( i )) ) )
- {
- return true;
- }
- }
- return false;
-}
-
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++ )
- {
- // if the (i)th meeting is not in the local meeting list
- if ( !isMeetingInList( iMeetings, aMeetings.at( i ) ) )
- {
- // add to the local database =)
- Meeting* m = new Meeting( *(aMeetings.at( i )) );
- iMeetings.append( m );
- // and signal the changes
- iWindowManager->insertMeeting( m );
- }
+
+ for ( int i = 0; i < iMeetings.count(); ++i ) {
+ Meeting* m = iMeetings.takeAt( i );
+ delete m;
}
-
- // check if there is any meeting NOT in the list came from the server -> deleted
- for ( int i = 0; i < iMeetings.count(); i++ )
- {
- // if the (i)th meeting is in the local but NOT in the server's meeting list
- 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;
- }
+ iMeetings.clear();
+ for ( int i = 0; i < aMeetings.count(); ++i ) {
+ Meeting* m = new Meeting( *( aMeetings.at( i ) ) );
+ iMeetings.append( m );
}
// refresh room status info
roomStatusInfoNeeded( defaultRoom() );
}
-void Engine::meetingDetailsFetched( Meeting &aDetailedMeeting )
-{
- qDebug() << "Engine::meetingDetailsFetched( Meeting & )";
- iWindowManager->closeProgressBar();
- iWindowManager->showMeetingInfo( &aDetailedMeeting );
-}
-
void Engine::errorHandler( int aCode, const QString &aAddInfo )
-{
- qDebug() << "Engine::ErrorHandler, aCode: " << aCode;
- // inform UI about the problem
- if( aCode >= 100 && aCode <= 150 ) { //communication errors
- //we don't want these to close operation changing
- qDebug() << "CommunicationManager signaled an error:" << aCode;
- iWindowManager->closeProgressBar();
+{
+ if ( iWindowManager != 0 )
+ {
+ iWindowManager->error( ErrorMapper::codeToString( aCode, aAddInfo ) );
}
- iWindowManager->error( ErrorMapper::codeToString( aCode, aAddInfo ) );
}
-void Engine::currentRoomChanged( Room *aCurrentRoom )
+void Engine::fetchMeetings( const QDateTime &aFrom, const QDateTime &aUntil, const Room *aIn )
{
- qDebug() << "Engine::currentRoomChanged to " << aCurrentRoom->name();
- QDateTime from( iWindowManager->weeklyView()->beginnigOfShownWeek() );
- QDateTime to( from.addDays( 8 ) );
- fetchMeetings( from, to, aCurrentRoom );
+ qDebug()
+ << "Engine::fetchMeetings( const QDateTime &, const QDateTime &, const Room * )";
+ iCommunication->fetchMeetings(aFrom, aUntil, *aIn);
}
-void Engine::fetchMeetings( const QDateTime &aFrom, const QDateTime &aUntil, const Room *aIn )
+void Engine::cancelFetchMeetingDetails()
{
- qDebug() << "Engine::fetchMeetings( const QDateTime &, const QDateTime &, const Room * )";
- iCommunication->fetchMeetings( aFrom, aUntil, *aIn );
+ iCommunication->cancelFetchMeetingDetails();
}
void Engine::shownWeekChanged( QDate aFrom )
{
- qDebug() << "Engine::shownWeekChanged( QDate )";
+ qDebug() << "[Engine::shownWeekChanged] <Invoked>";
QDateTime from( aFrom );
QDateTime to( aFrom.addDays( 7 ), QTime( 23, 59 ) );
- qDebug() << "Engine::shownWeekChanged " << aFrom.toString( "d.m. h:mm" ) << " to " << to.toString( "d.m. h:mm" );
- fetchMeetings( from, to, iWindowManager->weeklyView()->currentRoom() );
+ qDebug() << "[Engine::shownWeekChanged] <From " << aFrom.toString( "d.m. h:mm" ) << " to " << to.toString( "d.m. h:mm" ) << ">";
+ iCommunication->fetchMeetings( from, to, *defaultRoom() );
+// fetchMeetings( from, to, iWindowManager->weeklyView()->currentRoom() );
}
-void Engine::changeModeOrdered( DeviceManager::OperationMode aMode )
-{
- qDebug() << "Engine::changeModeOrdered( DeviceManager::OperationMode )";
- QString message = tr( "You are about to change operation mode to %1." )
- .arg( iDevice->operationModeToString( aMode ) );
+void Engine::changeDeviceMode( bool aChange )
+{
+ if ( aChange )
+ {
+ connect( iDevice, SIGNAL( changingModeFailed() ), this, SLOT( changeModeFailed() ) );
+ iAutoRefresh->stop(); // Stop the meeting update
+ }
+ iDevice->changeMode( aChange );
+}
+
+void Engine::changeModeFailed()
+{
+ qDebug() << "Engine::progressBarCancelled()";
+ iDevice->changeMode( false );
+ iAutoRefresh->start(); //we start the metting updating
+}
+
+void Engine::initUserInterface()
+{
+ qDebug() << "[Engine::initUserInterface] <Invoked>";
+
+ // Initialize the window manager and connect what ever signals can be connected
+ iWindowManager = new WindowManager;
+ // Create the UIManager which internally handles most of the UI actions
+ iUIManager = new UIManager( this, iWindowManager );
+
+ connect( iWindowManager, SIGNAL( eventDetected() ), this, SLOT( handleViewEvent() ) );
+ connect( iWindowManager, SIGNAL( previousViewRestored() ), iUIManager, SLOT( previousViewRestored() ) );
+ connect( iWindowManager, SIGNAL( dialogActivated() ), this, SLOT( dialogActivated() ) );
+ connect( iWindowManager, SIGNAL( dialogDeactivated() ), this, SLOT( dialogDeactivated() ) );
- iWindowManager->showPasswordDialog( iConfiguration->adminPassword(), message );
+ // Show the UI
+ iWindowManager->setWindowState( Qt::WindowMaximized );
+ iWindowManager->show();
+ iUIManager->showMainView();
+
+ qDebug() << "[Engine::initUserInterface] <Finished>";
}
-void Engine::passwordEntered( PasswordDialog::PasswordStatus aPasswordStatus )
+void Engine::handleViewEvent()
{
- qDebug() << "Engine::passwordEntered( PasswordDialog::PasswordStatus )";
- iWindowManager->closePasswordDialog();
+ if ( iIdleTimeCounter != 0 )
+ {
+ // Restart the idle time counter when view event is received
+ iIdleTimeCounter->stop();
+ iIdleTimeCounter->start();
+ }
+}
+
+void Engine::initConfiguration()
+{
+ iConfiguration = Configuration::instance();
+ if ( iConfiguration == 0 )
+ {
+ QTimer::singleShot( 0, this, SLOT( closeApplication() ) );
+ }
+ iCurrentRoom = iConfiguration->defaultRoom();
+}
+
+void Engine::connectSignals()
+{
+ // Connect engine objects signals to UIManager
+ connect( iClock, SIGNAL( tick( QDateTime ) ), iUIManager, SLOT( updateTime( QDateTime ) ) );
+ connect( iIdleTimeCounter, SIGNAL( timeout() ) , iUIManager, SLOT( roomStatusIndicatorRequested() ) );
- switch ( aPasswordStatus )
+ iUIManager->connectDeviceManager( iDevice );
+ iUIManager->connectCommunicationManager( iCommunication );
+}
+
+void Engine::initCommunication()
+{
+ // initialize communication
+ iCommunication = new CommunicationManager( *(iConfiguration->connectionSettings()) );
+ connect( iCommunication, SIGNAL( error( int, CommunicationManager::CommunicationType ) ),
+ this, SLOT( errorHandler( int ) ) );
+ connect( iCommunication, SIGNAL( meetingsFetched( const QList<Meeting*>& ) ),
+ this, SLOT( meetingsFetched( const QList<Meeting*>& ) ) );
+}
+
+void Engine::initDevice()
+{
+ // create device manager
+ iDevice = new DeviceManager( iConfiguration->startupSettings() );
+ connect( iDevice, SIGNAL( error( int, const QString& ) ), this, SLOT( errorHandler( int, const QString& ) ) );
+ iDevice->initDeviceManager();
+}
+
+void Engine::dialogActivated()
+{
+ if ( iIdleTimeCounter != 0 )
{
- case PasswordDialog::Correct :
- {
- iAutoRefresh->stop(); //we stop the metting updating
- iWindowManager->showProgressBar( "Changing current operation mode." );
- connect( iDevice, SIGNAL( changingMode( const QString & ) ),
- iWindowManager, SLOT( updateProgressBar( const QString & ) ) );
- connect( iDevice, SIGNAL( changeModeFailed() ), this, SLOT( changeModeFailed() ) );
- iDevice->changeMode( true );
- break;
- }
- case PasswordDialog::Incorrect :
- {
- iWindowManager->error( tr( "Incorrect password." ) );
- iDevice->changeMode( false );
- break;
- }
- default : //case PasswordDialog::Canceled
- {
- iDevice->changeMode( false );
- }
+ iIdleTimeCounter->stop();
}
}
-void Engine::changeModeFailed()
+void Engine::dialogDeactivated()
{
- qDebug() << "Engine::changeModeFailed()";
- iWindowManager->closeProgressBar();
- iAutoRefresh->start(); //we start the metting updating
+ if ( iIdleTimeCounter != 0 )
+ {
+ iIdleTimeCounter->start();
+ }
}
-void Engine::fetchMeetingDetailsCancelled()
+void Engine::previousViewRestored()
{
- iCommunication->cancelFetchMeetingDetails();
- iWindowManager->closeProgressBar();
+ if ( iIdleTimeCounter != 0 )
+ {
+ iIdleTimeCounter->start();
+ }
}
+
+void Engine::stopIdleTimeCounter()
+{
+ if ( iIdleTimeCounter != 0 )
+ {
+ iIdleTimeCounter->stop();
+ }
+}
+
+void Engine::startIdleTimeCounter()
+{
+ if ( iIdleTimeCounter != 0 )
+ {
+ iIdleTimeCounter->start();
+ }
+}
+
+void Engine::currentRoomChanged(Room *aRoom)
+{
+ iCurrentRoom = aRoom;
+}
\ No newline at end of file
#include <QDateTime>
#include "Room.h"
#include "WindowManager.h"
+#include "DeviceManager.h"
+#include "PasswordDialog.h"
class QTimer;
class Clock;
class Configuration;
class CommunicationManager;
class Meeting;
-class DeviceManager;
+class UIManager;
//! BusinessLogic class. Contains all the business logic of the application.
/*!
signals:
- void meetingDetailsFetched( Meeting *aDetailedMeeting );
-
private slots:
//! Slot. Closes the application.
/*!
* \param aRoom The room which availability information is needed.
*/
void roomStatusInfoNeeded( Room *aRoom );
- //! Slot. Indicates that some user event has happened.
- /*!
- * Slot. Indicates that some user event has happened.
- */
- void observedEventDetected();
- //! Slot. Asks the communication to fetch new meeting data.
- /*!
- * Slot. Asks the communication to fetch new meeting data.
- * \param aCurrentRoom The current room.
- */
- void currentRoomChanged( Room *aCurrentRoom );
//! Slot. Asks the communication to fetch new meeting data.
/*!
* Slot. Asks the communication to fetch new meeting data.
* Slot. Fetches meetings from the server. Parameters are hard coded: the meetings of the default
* room from current and +/- 2 weeks are fetched.
*/
- void fetchMeetings();
+// void fetchMeetings();
//! Slot. Saves fetched meetings to the current instance's local storage.
/*!
* Slot. Saves fetched meetings to the current instance's local storage. Meetings are soted in a
* \param aMeetings The list of freshly fetched meetings.
*/
void meetingsFetched( const QList<Meeting*>& );
-
- void meetingDetailsFetched( Meeting &aDetailedMeeting );
-
//! Slot. Checks the availability of all the rooms.
/*!
* Slot. Checks the availability of all the rooms by iterating through the current object's local
* room storage and calling the roomStatusInfoNeeded() separately on each of them.
*/
void checkStatusOfAllRooms();
- //! Slot for popping up the confirmation dialog to change the current operation mode
- /*!
- * Slot. Asks Window manager to pop up a confirmation dialog.
- * \param aMode The operation mode to be changed to
- */
- void changeModeOrdered( DeviceManager::OperationMode aMode );
- //! Slot. Fetches meeting details from the server.
- /*!
- * Slot. Fetches meeting details from the server.
- * \param aMeeting The meeting.
- */
- void fetchMeetingDetails( Meeting *aMeeting );
- //! Slot for receiving the status of the entered password
- /*!
- * Slot. Receives the status of the entered password and makes the DeviceManager to change the
- * operation mode if the password is correct.
- * \param aPasswordStatus The status of the password.
- */
- void passwordEntered( PasswordDialog::PasswordStatus aPasswordStatus );
//! Slot for receiving the failure event of operation mode changing.
/*!
* Slot. Receives the failure event of operation mode changing.
/*!
* Receives the cancel event of the progress bar when meeting details requested.
*/
- void fetchMeetingDetailsCancelled();
+ void fetchMeetingDetails( Meeting *aMeeting );
+ void cancelFetchMeetingDetails();
+
+ void handleViewEvent();
+ void previousViewRestored();
+
+ //! Slot for dialog activation signal.
+ /*!
+ * This slot is used to inform that dialog is activated. It stops
+ * the idle time counter so screensaver is not activated while the
+ * dialog is displayed.
+ */
+ void dialogActivated();
+ //! Slot for dialog deactivation signal.
+ /*!
+ * This slot is used to inform that dialog is deactivated. It restarts
+ * the idle time counter so that the screensaver is being activated again
+ * as needed.
+ */
+ void dialogDeactivated();
+
+ void stopIdleTimeCounter();
+ void startIdleTimeCounter();
+
+ void changeDeviceMode( bool aChange );
+
+ void currentRoomChanged( Room *aRoom );
private:
+ // Make the UIManager as friendly class so it can connect to private slots.
+ friend class UIManager;
+
//! Provides the index of the Meeting instance which is at the specified time.
/*!
* Provides the index of the Meeting instance which is at the specified time. If there are
* \return Index of the meeting if found; otherwise, -1.
*/
int indexOfMeetingAfter( Room *aRoom, QDateTime aAfter );
- //! Indicates if the QList contains the Meeting or not.
- /*!
- * Indicates if the QList contains the Meeting or not.
- * \param aList List of meetings.
- * \param aMeeting The meeting which is seeked in the list for.
- * \return True if contains; otherwise, false.
- */
- static bool isMeetingInList( const QList<Meeting*> &aList, const Meeting *aMeeting );
//! Slot. Fetches meetings from the server.
/*!
* Slot. Fetches meetings from the server, exact parameters are specified in the parameter list.
* \param aIn The room which meetings need to be fetched.
*/
void fetchMeetings( const QDateTime &aFrom, const QDateTime &aUntil, const Room *aIn );
+ //! Initialize configuration package.
+ /*!
+ * This method initializes configuration classes and
+ * connects signals from and to the engine.
+ */
+ void initConfiguration();
+ //! Initialize device package.
+ /*!
+ * This method initializes device manager and
+ * connects signals from and to the engine.
+ */
+ void initDevice();
+ //! Initialize communication package.
+ /*!
+ * This method initializes the communication manager and
+ * connects signals from and to the engine.
+ */
+ void initCommunication();
+ //! Initialize user interface package.
+ /*!
+ * This method initializes the user interface and
+ * connects signals from and to the engine. This method
+ * makes the window manager visible and shows weekly
+ * view as the first view.
+ */
+ void initUserInterface();
+ //! Connects signal between objects.
+ /*!
+ * Signals that could not be connected while initializing different
+ * packages are connected here.
+ */
+ void connectSignals();
+
+ bool isMeetingInList(const QList<Meeting*> &aList, const Meeting *aMeeting);
private:
static QTime endOfTheDay;
WindowManager *iWindowManager;
+
QTimer *iIdleTimeCounter;
Clock *iClock;
Configuration *iConfiguration;
CommunicationManager *iCommunication;
DeviceManager *iDevice;
+ UIManager *iUIManager;
QTimer *iAutoRefresh;
QList<Meeting*> iMeetings;
+
+ Room *iCurrentRoom;
};
#endif /*ENGINE_H_*/
--- /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 ) ) );
+ connect( iWeeklyView, SIGNAL( currentRoomChanged( Room * ) ), iEngine, SLOT( currentRoomChanged( Room * ) ) );
+}
+
+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( 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] <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 )
+ {
+ 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::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();
+ 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
+ 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();
+ }
+}
--- /dev/null
+#ifndef UIMANAGER_H_
+#define UIMANAGER_H_
+
+#include <QObject>
+#include <QList>
+
+#include "Meeting.h"
+#include "DeviceManager.h"
+#include "PasswordDialog.h"
+
+class Engine;
+class WindowManager;
+class WeeklyViewWidget;
+class SettingsView;
+class RoomStatusIndicatorWidget;
+class ProgressBar;
+class MeetingInfoDialog;
+class CommunicationManager;
+class QDateTime;
+
+class UIManager : public QObject
+{
+ Q_OBJECT
+
+public:
+ UIManager( Engine *aEngine, WindowManager *aWindowManager );
+ virtual ~UIManager();
+
+ void connectDeviceManager( DeviceManager *aDeviceManager );
+ void connectCommunicationManager( CommunicationManager *aCommunicationManager );
+ void showMainView();
+ void showProgressBar( QString aText );
+
+signals:
+
+public slots:
+
+ void settingsViewRequest();
+ void settingsOkClicked();
+ void roomStatusIndicatorRequested();
+ void previousViewRestored();
+ void changeModeOrdered( DeviceManager::OperationMode aMode );
+
+private slots:
+
+ void meetingsFetched( const QList<Meeting*> &aMeetings );
+ void meetingDetailsFetched( Meeting &aDetailedMeeting );
+ void currentRoomChanged( Room *aRoom );
+ void progressBarCancelled();
+ void updateTime( QDateTime aDateTime );
+ void passwordEntered( PasswordDialog::PasswordStatus aStatus );
+ void showMeetingProgressBar( Meeting *aMeeting );
+ void updateProgressBarText( const QString &aText );
+ void hideProgressBar();
+
+private:
+
+ void createWeeklyView();
+ void createSettingsView();
+ void createRoomStatusIndicator();
+ void createPasswordDialog();
+ void createProgressBar();
+ void createMeetingInfoDialog();
+
+private:
+ Engine *iEngine;
+ WindowManager *iWindowManager;
+
+ WeeklyViewWidget *iWeeklyView;
+ SettingsView *iSettingsView;
+ RoomStatusIndicatorWidget *iRoomStatusIndicator;
+ PasswordDialog *iPasswordDialog;
+ ProgressBar *iProgressBar;
+ MeetingInfoDialog *iMeetingInfo;
+};
+
+#endif /*UIMANAGER_H_*/
bool DeviceManager::setCurrentOperationMode()
{
- qDebug() << "DeviceManager::currentOperationMode()";
+ qDebug() << "DeviceManager::setCurrentOperationMode()";
QStringList modeResult;
if ( !iDataStorage->readData( iDataStorage->dataSectionToString( DeviceDataStorage::DeviceMode ), modeResult ) )
{
//in case device restarting fails we just continue
handleKeyPresses( true );
-}
\ No newline at end of file
+}
#include <QtDebug>
MeetingRoomCombo::MeetingRoomCombo( QList<Room*> aRooms, QWidget *aParent ) :
- ObservedWidget( aParent )
+ QWidget( aParent )
{
iRooms = aRooms;
qSort( iRooms.begin(), iRooms.end(), Room::caseInsensitiveLessThan );
#ifndef MEETINGROOMCOMBO_H_\r
#define MEETINGROOMCOMBO_H_\r
\r
-#include "ObservedWidget.h"\r
#include <QWidget>\r
#include <QList>\r
\r
* Userinterface class. Displays a list of selectable meeting rooms. Customized QComboBox which hides\r
* all the not needed functionality of the "base" class.\r
*/\r
-class MeetingRoomCombo : public ObservedWidget\r
+class MeetingRoomCombo : public QWidget\r
{\r
Q_OBJECT\r
\r
void ScheduleTableWidget::paintEvent( QPaintEvent* aEvent )
{
+ qDebug() << "ScheduleTableWidget::paintEvent()";
QTableWidget::paintEvent( aEvent );
ScheduleWidget* schedule = static_cast<ScheduleWidget*>( parent() );
void ScheduleTableWidget::populateMeetingList()
{
+ qDebug() << "ScheduleTableWidget::populateMeetingList()";
ScheduleWidget* schedule = static_cast<ScheduleWidget*>( parent() );
for ( int i = 0; i < schedule->weekLengthAsDays(); ++i )
{
Meeting* meeting = schedule->iMeetings[i];
int day = meeting->startsAt().date().dayOfWeek() - 1;
+
if (( meeting->startsAt().date().weekNumber() == schedule->iShownDate.weekNumber() ) &&
( day < schedule->weekLengthAsDays() ) &&
( meeting->endsAt().time() > QTime( schedule->iStartHour, 0 ) ) &&
ScheduleWidget::~ScheduleWidget()
{
- clear();
delete iScheduleTable;
}
-int ScheduleWidget::shownWeek()
-{
- return iShownDate.weekNumber();
-}
-
QDate ScheduleWidget::beginningOfShownWeek()
{
return iShownDate.addDays( -1 * iShownDate.dayOfWeek() + 1 );
}
-Meeting* ScheduleWidget::currentMeeting()
-{
- return meeting( iCurrentDateTime );
-}
-
-Meeting* ScheduleWidget::meeting( QDateTime aAt )
-{
- for ( int i = 0; i < iMeetings.count(); ++i )
- {
- if ( iMeetings[i]->startsAt() <= aAt && iMeetings[i]->endsAt() >= aAt )
- {
- return iMeetings[i];
- }
- }
-
- return 0;
-}
-
-void ScheduleWidget::clear()
-{
- qDebug() << "ScheduleWidget::clear";
- int i = 0;
- while ( !iMeetings.isEmpty() )
- {
- i++;
- iMeetings.removeFirst();
- }
- qDebug() << "Deleted " << i << " items";
-}
-
-void ScheduleWidget::clear( QDateTime aFrom, QDateTime aUntil )
-{
- for ( int i = 0; i < iMeetings.count(); ++i )
- {
- if (( iMeetings[i]->startsAt() >= aFrom && iMeetings[i]->startsAt() <= aUntil ) ||
- ( iMeetings[i]->startsAt() <= aFrom && iMeetings[i]->endsAt() >= aFrom ) )
- {
- iMeetings.removeAt( i );
- --i;
- }
- }
-}
-
void ScheduleWidget::refresh()
{
+ qDebug() << "ScheduleWidget::refresh()";
+
for ( int i = 0; i < iScheduleTable->columnCount(); ++i )
{
QTableWidgetItem* item = iScheduleTable->item( 0, i );
item->setFont( font );
}
}
-
+
// force repaint of the main area
iScheduleTable->setSpan( 1, 1, iNumberOfHours, weekLengthAsDays() );
iLastRefresh = iCurrentDateTime.time();
}
+void ScheduleWidget::refreshMeetings( const QList<Meeting*> &aMeetings )
+{
+ iMeetings = aMeetings;
+ qDebug() << "Count: " << iMeetings.size();
+ refresh();
+}
+
void ScheduleWidget::setCurrentDateTime( QDateTime aCurrentDateTime )
{
- Meeting* previous = meeting( iCurrentDateTime );
- Meeting* current = meeting( aCurrentDateTime );
iCurrentDateTime = aCurrentDateTime;
if ( iLastRefresh.secsTo( iCurrentDateTime.time() ) > sRefreshIntervalInSeconds )
// enough time has elapsed since last refresh
refresh();
}
-
- if ( previous != current )
- {
- emit currentMeetingChanged( current );
- }
}
-void ScheduleWidget::insertMeeting( Meeting *aMeeting )
-{
- Meeting* previous = meeting( iCurrentDateTime );
- iMeetings.append( aMeeting );
- Meeting* current = meeting( iCurrentDateTime );
-
- qDebug() << "Inserted" << aMeeting->toString();
-
- refresh();
-
- if ( previous != current )
- {
- emit currentMeetingChanged( current );
- }
-}
-
-void ScheduleWidget::removeMeeting( Meeting *aMeeting )
-{
- Meeting* previous = meeting( iCurrentDateTime );
-
- qDebug() << "Delete" << aMeeting->toString();
- for ( int i = 0; i < iMeetings.count(); ++i )
- {
- if ( iMeetings[i]->equals( *(aMeeting) ) )
- {
- iMeetings.removeAt( i );
-
- refresh();
-
- Meeting* current = meeting( iCurrentDateTime );
- if ( previous != current )
- emit currentMeetingChanged( current );
-
- return;
- }
- }
-}
-
-//void ScheduleWidget::updateMeeting( Meeting *aMeeting )
-//{
-//
-//}
-
void ScheduleWidget::showPreviousWeek()
{
iShownDate = iShownDate.addDays( -7 );
//! Destructor.
~ScheduleTableWidget();
+
+ //! Populates meeting list.
+ /*!
+ * Populates meeting list.
+ */
+ void populateMeetingList();
protected:
//! Handles drawing of main table area.
private:
- //! Populates meeting list.
- /*!
- * Populates meeting list.
- */
- void populateMeetingList();
-
//! Finds overlapping meetings.
/*!
* Finds overlapping meetings.
*/
int currentWeek();
- //! Gets number of shown week.
- /*!
- * Gets number of shown week.
- * \return The week which is currently shown.
- */
- int shownWeek();
-
//! Gets the first day of shown week.
/*!
* Gets the first day of shown week.
*/
QDate beginningOfShownWeek();
- //! Gets current meeting.
- /*!
- * Gets current meeting.
- * \return current meeting, 0 if none.
- */
- Meeting* currentMeeting();
-
- //! Gets meeting at a specified date and time.
- /*!
- * Gets meeting at a specified date and time.
- * \param aAt Time when the meeting is.
- * \return meeting At the given time, 0 if none.
- */
- Meeting* meeting( QDateTime aAt );
-
signals:
//! Signal. Emitted if a meeting is activated.
* \param aMeeting Actived meeting.
*/
void meetingActivated( Meeting *aMeeting );
-
- //! Signal. Emitted when the current meeting changes to another.
- /*!
- * Signal. Emitted when the current meeting changes to another.
- * \param aNewMeeting New meeting.
- */
- void currentMeetingChanged( Meeting *aNewMeeting );
-
//! Signal. Emitted if the shown week has been changed.
/*!
* Signal. Emitted if the shown week has been changed.
public slots:
- //! Slot. Clears all meetings.
- /*!
- * Slot. Clears all meetings.
- */
- void clear();
-
- //! Slot. Clears meetings based on a range.
- /*!
- * Slot. Clears meetings based on a range.
- * \param aFrom Date and time from which the meetings are cleared.
- * \param aUntil Date and time until which the meetings are cleared.
- */
- void clear( QDateTime aFrom, QDateTime aUntil );
-
//! Slot. Refreshes display.
/*!
* Slot. Refreshes display.
+ * \param aMeetings The meeting list.
*/
void refresh();
-
+ //! Refreshes the meeting list.
+ /*!
+ * Refreshes the meeting list.
+ * \param aMeetings The list of meetings.
+ */
+ void refreshMeetings( const QList<Meeting*> &aMeetings );
+
//! Slot. Sets current date and time.
/*!
* Slot. Sets current date and time.
*/
void setCurrentDateTime( QDateTime aCurrentDateTime );
- //! Slot. Inserts a meeting to the schedule.
- /*!
- * Slot. Inserts a meeting to the schedule.
- * \param aMeeting Meeting to be inserted.
- */
- void insertMeeting( Meeting *aMeeting );
-
- //! Slot. Removes a meeting from the schedule.
- /*!
- * Slot. Removes a meeting from the schedule.
- * \param aMeeting Meeting to be removed.
- */
- void removeMeeting( Meeting *aMeeting );
-
- //! Slot. Updates a meeting in the schedule. (TODO)
- /*!
- * Slot updates a meeting in the schedule.
- * \param aMeeting Meeting was updated.
- */
- void updateMeeting( Meeting */*aMeeting*/ ) {};
-
//! Slot. Shows previous week.
/*!
* Slot. Shows previous week.
//! Current date and time.
QDateTime iCurrentDateTime;
- //! Meetings.
- QList<Meeting*> iMeetings; /*! Not owned */
-
//! Currently shown week.
QDate iShownDate;
//! When refresh() was called previously
QTime iLastRefresh;
+
+ //! Meetings.
+ QList<Meeting*> iMeetings; /*! Not owned */
//! Color for a free cell.
static const QColor sFreeBackground;
#include "TimeDisplayWidget.h"\r
\r
TimeDisplayWidget::TimeDisplayWidget( QTime aNow, QWidget *aParent ) :\r
- ObservedWidget( aParent )\r
+ QWidget( aParent )\r
\r
{\r
iCurrentTime = aNow;\r
#ifndef TIMEDISPLAYWIDGET_H_\r
#define TIMEDISPLAYWIDGET_H_\r
\r
-#include "ObservedWidget.h"\r
#include <QWidget>\r
#include <QColor>\r
#include <QTime>\r
* Abstact. UserInterface class. Offers basic functionality to display time. Inherited by\r
* DigitalTimeDisplayWidget.\r
*/\r
-class TimeDisplayWidget : public ObservedWidget\r
+class TimeDisplayWidget : public QWidget\r
{\r
Q_OBJECT\r
\r
{
setWindowTitle( tr( "Details" ) );
+ if ( aMeeting != 0 )
+ {
+ createDialogView( aMeeting );
+ }
+
+ setMinimumWidth( MeetingInfoDialog::width );
+ setMinimumHeight( MeetingInfoDialog::height );
+}
+
+MeetingInfoDialog::~MeetingInfoDialog()
+{
+}
+
+void MeetingInfoDialog::setMeeting(Meeting *aMeeting)
+{
+ createDialogView( aMeeting );
+}
+
+void MeetingInfoDialog::createDialogView(Meeting *aMeeting)
+{
+ qDebug() << "[MeetingInfoDialog::createDialogView] <Invoked>";
+
QFont normalFont;
normalFont.setPointSize( 11 );
layout->addStretch();
layout->addLayout( buttonLayout );
setLayout( layout );
-
- setMinimumWidth( MeetingInfoDialog::width );
- setMinimumHeight( MeetingInfoDialog::height );
-}
-
-MeetingInfoDialog::~MeetingInfoDialog()
-{
+
+ qDebug() << "[MeetingInfoDialog::createDialogView] <Finished>";
}
* \param aMeeting The Meeting instance which is needed to be presented in detail.\r
* \param aParent Pointer to the parent widget. Optional.\r
*/\r
- MeetingInfoDialog( Meeting *aMeeting, QWidget *aParent = 0 );\r
+ MeetingInfoDialog( Meeting *aMeeting = 0, QWidget *aParent = 0 );\r
//! Destructor.\r
virtual ~MeetingInfoDialog();\r
+ \r
+ void setMeeting( Meeting * aMeeting );\r
\r
private:\r
+ void createDialogView(Meeting *aMeeting);\r
\r
static const int width = 200;\r
static const int height = 400;\r
QTime RoomStatusIndicatorWidget::endOfTheDay = QTime( 23, 59, 0, 0 );\r
\r
RoomStatusIndicatorWidget::RoomStatusIndicatorWidget( Room *aDefaultRoom, Room::Status aStatus, QTime aUntil, QString aTimeFormat, QWidget *aParent ) :\r
- ObservedWidget( aParent ), iTimeFormat( aTimeFormat )\r
+ ViewBase( ViewBase::ObservedView, aParent ), iTimeFormat( aTimeFormat )\r
{\r
QFont importantTextFont;\r
//importantTextFont.setBold( true );\r
#ifndef ROOMSTATUSINDICATORWIDGET_H_\r
#define ROOMSTATUSINDICATORWIDGET_H_\r
\r
-#include "ObservedWidget.h"\r
+#include "ViewBase.h"\r
#include <QTime>\r
#include <QKeyEvent>\r
#include <QTabletEvent>\r
* and disappears if there is any. Its function is to behave like a screen saver on one hand, and\r
* to provide details about the current availability on the other hand.\r
*/\r
-class RoomStatusIndicatorWidget : public ObservedWidget\r
+class RoomStatusIndicatorWidget : public ViewBase\r
{\r
Q_OBJECT\r
\r
* \param aUntil The new time until the specified status is valid.\r
*/\r
void statusChanged( const Room::Status aStatus, const QTime aUntil );\r
+ \r
+ void viewResized(const QSize &newSize, const QSize &oldSize) { }\r
\r
private:\r
//! Translates the status into human readable text.\r
#include <QtDebug>
SettingsView::SettingsView( QWidget *aParent ) :
- ObservedWidget( aParent )
+ ViewBase( ViewBase::NormalView, aParent )
{
qDebug() << "SettingsView::ctor invoked";
// Prepare the tabbed view
QHBoxLayout *buttonLayout = new QHBoxLayout;
iOkButton = new QPushButton;
iOkButton->setText( tr( "OK" ) );
- iCancelButton = new QPushButton;
- iCancelButton->setText( tr( "Cancel" ) );
buttonLayout->addWidget( iOkButton );
- buttonLayout->addWidget( iCancelButton );
// Handle the main layout
QVBoxLayout *mainLayout = new QVBoxLayout;
setLayout( mainLayout );
// Handle component connections
- connect( iOkButton, SIGNAL( pressed() ), this, SLOT( okClicked() ) );
- connect( iCancelButton, SIGNAL( pressed() ), this, SLOT( cancelClicked() ) );
+ connect( iOkButton, SIGNAL( clicked() ), this, SLOT( handleOkClicked() ) );
}
SettingsView::~SettingsView()
delete iOkButton;
iOkButton = 0;
}
- if ( iCancelButton != 0 )
- {
- delete iCancelButton;
- iCancelButton = 0;
- }
if ( iSettingsTab != 0 )
{
delete iSettingsTab;
return widget;
}
-void SettingsView::okClicked()
+void SettingsView::handleOkClicked()
{
qDebug() << "[SettingsView::okClicked] <Invoked>";
bool powerSaveEnabled = iPowerSaveEnabled->isChecked();
// TODO : Set the values to configuration and save it
-
- close();
+
+ // Emit the signal to notify that ok is pressed and data is saved.
+ emit okClicked();
}
-void SettingsView::cancelClicked()
+void SettingsView::viewResized(const QSize &newSize, const QSize &oldSize)
{
- qDebug() << "[SettingsView::cancelClicked] <Invoked>";
- close();
-}
+ if ( oldSize.height() > newSize.height() )
+ {
+ // Get the button's height and add that to the new size so that
+ // the ok button is hidden under the keyboard.
+ size().rheight() += iOkButton->size().height();
+ }
+}
\ No newline at end of file
#ifndef SETTINGSVIEW_H_
#define SETTINGSVIEW_H_
-#include "ObservedWidget.h"
+#include "ViewBase.h"
class QTabWidget;
class QPushButton;
class QTimeEdit;
class QRadioButton;
class QCheckBox;
+class QSize;
//! User interface class. Shows the settings view and handles configuration changes.
-class SettingsView : public ObservedWidget
+class SettingsView : public ViewBase
{
Q_OBJECT
SettingsView( QWidget *aParent = 0 );
//! Destructor.
virtual ~SettingsView();
+
+signals:
+ void okClicked();
+
+public slots:
+ void viewResized(const QSize &newSize, const QSize &oldSize);
private slots:
//! Slot to handle the Ok button pressing.
- void okClicked();
- //! Slot to handle the cancel button pressing.
- void cancelClicked();
+ void handleOkClicked();
private:
//! Initialize "Settings" tab.
QTabWidget *iTabWidget;
//! OK button to dismiss the settings view with saving the settings.
QPushButton *iOkButton;
- //! Cancel button to dismiss the settings view without saving settings.
- QPushButton *iCancelButton;
//! Settings tab.
QWidget *iSettingsTab;
//! Week View tab.
--- /dev/null
+#include "ViewBase.h"
+
+#include <QEvent>
+#include <QKeyEvent>
+#include <QTabletEvent>
+#include <QMouseEvent>
+#include <QMouseEvent>
+#include <QMouseEvent>
+#include <QLayout>
+
+#include <QtDebug>
+
+ViewBase::ViewBase( ViewBase::ViewMode aMode, QWidget *aParent ) : QWidget( aParent ), iViewMode( aMode )
+{
+
+}
+
+ViewBase::~ViewBase()
+{
+
+}
+
+ViewBase::ViewMode ViewBase::viewMode()
+{
+ return iViewMode;
+}
+
+bool ViewBase::event(QEvent *event)
+{
+ switch( event->type() )
+ {
+ // TODO : Add events as needed !!!
+ case QEvent::KeyPress:
+ case QEvent::KeyRelease:
+ case QEvent::TabletMove:
+ case QEvent::TabletPress:
+ case QEvent::MouseMove:
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseButtonDblClick:
+ emit eventDetected();
+ break;
+ default:
+ break;
+ }
+
+ return QWidget::event( event );
+}
+
+bool ViewBase::eventFilter( QObject *watched, QEvent *event )
+{
+ if ( watched != this ) // We do not filter our own events
+ {
+ switch( event->type() )
+ {
+ // TODO : Add events as needed !!!!
+ case QEvent::KeyPress:
+ case QEvent::KeyRelease:
+ case QEvent::TabletMove:
+ case QEvent::TabletPress:
+ case QEvent::MouseMove:
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseButtonDblClick:
+ emit eventDetected();
+ break;
+ default:
+ break;
+ }
+ }
+
+ return QWidget::eventFilter( watched, event );
+}
+
+void ViewBase::observeChild(QWidget *aChild)
+{
+ aChild->setMouseTracking( true );
+ aChild->installEventFilter( this );
+}
--- /dev/null
+#ifndef VIEWBASE_
+#define VIEWBASE_
+
+#include <QWidget>
+
+class QEvent;
+class QSize;
+
+class ViewBase : public QWidget
+{
+ Q_OBJECT
+
+public:
+ enum ViewMode
+ {
+ NormalView, /*!< Indicates that the view is normal view that isn't hidden by events. */
+ ObservedView /*!< Indicates that the view will be hidden when event occurs. */
+ };
+
+public:
+ ViewBase( ViewBase::ViewMode aMode, QWidget *aParent = 0 );
+ virtual ~ViewBase();
+
+ //! Overwritten event handler.
+ /*!
+ * Listens for events and emits eventDetected signal when observed
+ * event is triggered.
+ */
+ virtual bool event(QEvent *event);
+
+ //! Event filter.
+ /*!
+ * Event filter method that is used to listen for child widgets
+ * events.
+ */
+ virtual bool eventFilter(QObject *watched, QEvent *event);
+
+ //! Returns view mode.
+ /*!
+ * Returns the views mode which is one of the ViewMode enumerations.
+ */
+ ViewBase::ViewMode viewMode();
+
+public slots:
+ //! This slot is called when the view is resized.
+ /*!
+ * This slot will be called after the view is resized by the window manager
+ * to fit its client area. This method can be used to refine the view size
+ * after it has been resized, for example when the on screen keyboard is
+ * displayed.
+ */
+ virtual void viewResized(const QSize &newSize, const QSize &oldSize) = 0;
+
+signals:
+ /*!
+ * This signal indicates that some user initiated event has occured.
+ * Event filter tracks for mouse, pointer and key events.
+ */
+ void eventDetected();
+
+protected:
+ void observeChild(QWidget *aChild);
+
+private:
+ ViewMode iViewMode;
+
+};
+
+#endif /*VIEWBASE_*/
#include <QtDebug>\r
\r
WeeklyViewWidget::WeeklyViewWidget( QDateTime aCurrentDateTime, Configuration *aConfiguration, QWidget *aParent ) :\r
- ObservedWidget( aParent ), iConfiguration( aConfiguration )\r
+ ViewBase( ViewBase::NormalView, aParent ), iConfiguration( aConfiguration )\r
{\r
\r
// *****************************************\r
iSettingsButton = new QPushButton;\r
iSettingsButton->setIcon( QPixmap( ":button_settings" ) );\r
iSettingsButton->setFixedWidth( 36 );\r
- connect( iSettingsButton, SIGNAL( clicked() ), this, SIGNAL( showSettingsView() ) );\r
+ connect( iSettingsButton, SIGNAL( clicked() ), this, SIGNAL( settingsButtonClicked() ) );\r
\r
iCurrentDayLabel = ToolBox::createLabel( aCurrentDateTime.toString( iConfiguration->displaySettings()->dateFormat() ), regularTextFont );\r
iCurrentWeekLabel = ToolBox::createLabel( tr( "Wk %1" ).arg( aCurrentDateTime.date().weekNumber() ), regularTextFont );\r
\r
iRoomsCombo = new MeetingRoomCombo( iConfiguration->rooms(), this );\r
iRoomsCombo->setCurrentRoom( iConfiguration->defaultRoom() );\r
- connect( iRoomsCombo, SIGNAL( observedEventDetected() ), this, SIGNAL( observedEventDetected() ) );\r
+ connect( iRoomsCombo, SIGNAL( currentRoomChanged( Room * ) ), this, SIGNAL( currentRoomChanged( Room * ) ) );\r
\r
iTimeDisplay = new DigitalTimeDisplayWidget( aCurrentDateTime.time(), iConfiguration->displaySettings()->timeFormat(), this );\r
iTimeDisplay->setFrameVisible( false );\r
iTimeDisplay->setFont( regularTextFont );\r
- connect( iTimeDisplay, SIGNAL( observedEventDetected() ), this, SIGNAL( observedEventDetected() ) );\r
\r
iSchedule = new ScheduleWidget( aCurrentDateTime, iConfiguration->displaySettings(), this );\r
connect( iSchedule, SIGNAL( shownWeekChanged( QDate ) ), this, SIGNAL( shownWeekChanged( QDate ) ) );\r
- connect( iSchedule, SIGNAL( observedEventDetected() ), this, SIGNAL( observedEventDetected() ) );\r
connect( iSchedule, SIGNAL( meetingActivated( Meeting* ) ), this, SIGNAL( meetingActivated( Meeting* ) ) );\r
\r
iPreviousWeekButton = new QPushButton( this );\r
mainLayout->addLayout( tableLayout );\r
mainLayout->addLayout( bottomLayout );\r
setLayout( mainLayout );\r
+ \r
+ // Set child observing\r
+ observeChild( iRoomsCombo );\r
+ observeChild( iTimeDisplay );\r
+ observeChild( iCurrentDayLabel );\r
+ observeChild( iCurrentWeekLabel );\r
+ observeChild( iPreviousWeekButton );\r
+ observeChild( iCurrentWeekButton );\r
+ observeChild( iNextWeekButton );\r
+ observeChild( iSettingsButton );\r
\r
QPalette palette;\r
palette.setColor( QPalette::Window, Qt::white );\r
// ******************************************\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
}\r
}\r
\r
-Meeting* WeeklyViewWidget::currentMeeting()\r
-{\r
- return iSchedule->currentMeeting();\r
-}\r
-\r
Room* WeeklyViewWidget::currentRoom()\r
{\r
return iRoomsCombo->currentRoom();\r
iSchedule->setCurrentDateTime( aCurrentDateTime );\r
}\r
\r
-void WeeklyViewWidget::insertMeeting( Meeting *aMeeting )\r
+QDate WeeklyViewWidget::beginnigOfShownWeek()\r
{\r
- iSchedule->insertMeeting( aMeeting );\r
+ return iSchedule->beginningOfShownWeek();\r
}\r
\r
-void WeeklyViewWidget::deleteMeeting( Meeting *aMeeting )\r
+void WeeklyViewWidget::refreshMeetings( const QList<Meeting*> &aMeetings )\r
{\r
- iSchedule->removeMeeting( aMeeting );\r
+ qDebug() << "WeeklyViewWidget::refreshMeetings()";\r
+ iSchedule->refreshMeetings( aMeetings );\r
}\r
\r
-void WeeklyViewWidget::updateMeeting( Meeting *aMeeting )\r
+void WeeklyViewWidget::showCurrentWeek()\r
{\r
- iSchedule->updateMeeting( aMeeting );\r
+ iSchedule->showCurrentWeek();\r
}\r
\r
-QDate WeeklyViewWidget::beginnigOfShownWeek()\r
+void WeeklyViewWidget::setDefaultRoom()\r
{\r
- return iSchedule->beginningOfShownWeek();\r
+ iRoomsCombo->setCurrentRoom( iConfiguration->defaultRoom() );\r
}\r
#ifndef WEEKLYVIEWWIDGET_H_\r
#define WEEKLYVIEWWIDGET_H_\r
\r
-#include "ObservedWidget.h"\r
+#include "ViewBase.h"\r
#include <QDateTime>\r
\r
class QLabel;\r
* selected meeting room. User can select meeting room, browse weeks back and forth, and can navigate\r
* back to the current week.\r
*/\r
-class WeeklyViewWidget : public ObservedWidget\r
+class WeeklyViewWidget : public ViewBase\r
{\r
Q_OBJECT\r
\r
//! Destructor.\r
virtual ~WeeklyViewWidget();\r
\r
- //! Current meeting\r
- /*!\r
- * Returns the current meeting if any\r
- * \return Current meeting if any, otherwise null pointer\r
- */\r
- Meeting* currentMeeting();\r
//! Current room\r
/*!\r
* Returns the currently selected meeting room.\r
* \return First day of week.\r
*/\r
QDate beginnigOfShownWeek();\r
-\r
+ //! Sends the refresh command to schedule widget.\r
+ /*!\r
+ * Sends the refresh command to schedule widget.\r
+ * \param aMeetings The list of meetings.\r
+ */\r
+ void refreshMeetings( const QList<Meeting*> &aMeetings );\r
+ \r
+ void showCurrentWeek();\r
+ \r
+ void setDefaultRoom();\r
+ \r
signals:\r
//! Signals change of the meeting room.\r
/*!\r
* \param aNewRoom Selected meeting room.\r
*/\r
void currentRoomChanged( Room *aNewRoom );\r
- //! Signals change of the current meeting.\r
- /*!\r
- * Signal is emited when new meeting is started.\r
- * \param aNewMeeting Meeting that has been started.\r
- */\r
- void currentMeetingChanged( Meeting *aNewMeeting );\r
//! Meeting activated.\r
/*!\r
* Signal is emitted when a meeting is clicked by the user.\r
/*!\r
* Signal is emited when settings button is clicked.\r
*/\r
- void showSettingsView();\r
+ void settingsButtonClicked();\r
\r
//! Signal. Emitted if the shown week has been changed.\r
/*!\r
* Signal. Emitted if the shown week has been changed.
* \param aDate The first date of the shown week.
*/
- void shownWeekChanged( QDate aDate );
+ void shownWeekChanged( QDate aDate );\r
\r
public slots:\r
//! Sets the date and time\r
* \param aCurrentDateTime Date and time to be displayd.\r
*/\r
void setCurrentDateTime( QDateTime aCurrentDateTime );\r
- //! Insert meeting\r
- /*!\r
- * Inserts new meeting into the calendar\r
- * \param aMeeting Meeting to be inserted.\r
- */\r
- void insertMeeting( Meeting *aMeeting );\r
- //! Delete meeting\r
- /*!\r
- * Removes meeting from the calendar\r
- * \param aMeeting Meeting to be deleted.\r
- */\r
- void deleteMeeting( Meeting *aMeeting );\r
- //! Update meeting\r
+ //! Handle resizing\r
/*!\r
- * Updates the display of given meeting in calendar.\r
- * \param aMeeting Meeting to be updated.\r
+ * Handle possible resize changes after the view is resized\r
+ * to match the window managers client area.\r
*/\r
- void updateMeeting( Meeting *aMeeting );\r
+ void viewResized(const QSize &newSize, const QSize &oldSize) { }\r
\r
private:\r
//! Displays the selectable meeting rooms.\r
#include "WindowManager.h"
-#include <QTimer>
-#include "Configuration.h"
-#include "DisplaySettings.h"
-#include "Meeting.h"
-#include "Room.h"
-#include "Clock.h"
-#include "WeeklyViewWidget.h"
-#include "RoomStatusIndicatorWidget.h"
-#include "MeetingInfoDialog.h"
+#include <QEvent>
+#include <QDialog>
+#include "ViewBase.h"
#include "PopUpMessageBox.h"
-#include "DeviceManager.h"
-#include "SettingsView.h"
-#include "ProgressBar.h"
#include <QtDebug>
-WindowManager::WindowManager( Configuration *aConfiguration ) :
- QObject(),
+WindowManager::WindowManager( QWidget *aParent ) :
+ QWidget( aParent ),
iApplicationName( tr( "Qt Meetings" ) ),
- iFullScreen( false ),
- iConfiguration( aConfiguration ),
- iWeeklyView( 0 ),
- iRoomStatusView( 0 ),
- iMeetingInfo( 0 ),
- iProgressBar( 0 ),
- iPasswordDialog( 0 )
+ iCurrentView( 0 )
{
- iWeeklyView = new WeeklyViewWidget( QDateTime::currentDateTime(), aConfiguration );
- iWeeklyView->setWindowTitle( iApplicationName );
- connect( iWeeklyView, SIGNAL( observedEventDetected() ), this, SIGNAL( observedEventDetected() ) );
- connect( iWeeklyView, SIGNAL( meetingActivated( Meeting * ) ), this, SIGNAL( meetingActivated( Meeting * ) ) );
- connect( iWeeklyView, SIGNAL( currentRoomChanged( Room * ) ), this, SIGNAL( currentRoomChanged( Room * ) ) );
- connect( iWeeklyView, SIGNAL( shownWeekChanged( QDate ) ), this, SIGNAL( shownWeekChanged( QDate ) ) );
-
- showWeeklyView();
-
+ this->setWindowTitle( iApplicationName );
}
WindowManager::~WindowManager()
{
- delete iWeeklyView;
- iWeeklyView = 0;
- delete iRoomStatusView;
- iRoomStatusView = 0;
- delete iMeetingInfo;
- iMeetingInfo = 0;
- delete iProgressBar;
- iProgressBar = 0;
- delete iPasswordDialog;
- iPasswordDialog = 0;
+
}
-void WindowManager::distributeDateTimeInfo( QDateTime aCurrentDateTime )
+void WindowManager::showView( ViewBase *view )
{
- if ( iRoomStatusView != 0 && iRoomStatusView->isActiveWindow() )
+ // The views parent must be WindowManager when it is displayed trough this
+ QWidget *parent = static_cast<QWidget *>(view->parent());
+ if ( parent != this )
{
- iRoomStatusView->setCurrentTime( aCurrentDateTime.time() );
+ view->setParent( this );
}
-
- if ( iWeeklyView != 0 && iWeeklyView->isActiveWindow() )
+
+ // Store the current view because it is hidden after the new view is shown
+ QWidget *oldView = iCurrentView;
+
+ // If the new view is observed view we store the current into stack
+ // from which it is restored when the new view receives event we are
+ // listening to.
+ if ( view->viewMode() == ViewBase::ObservedView )
+ {
+ iViewList.push( iCurrentView );
+ }
+
+ // Make the new view visible and handle connections
+ iCurrentView = view;
+ connect( iCurrentView, SIGNAL( eventDetected() ), this, SLOT( viewEventDetected() ) );
+ connect( this, SIGNAL( viewResized(const QSize &, const QSize &) ), iCurrentView, SLOT( viewResized( const QSize &, const QSize & ) ) );
+ view->resize( this->size() );
+
+ view->show();
+
+ // Disconnect old connections and hide the view
+ if ( oldView != 0 )
{
- iWeeklyView->setCurrentDateTime( aCurrentDateTime );
+ disconnect( oldView, SIGNAL( eventDetected() ), this, SLOT( viewEventDetected() ) );
+ disconnect( this, SIGNAL( viewResized(const QSize &, const QSize &) ), oldView, SLOT( viewResized(const QSize &, const QSize &) ) );
+ oldView->hide();
}
+
}
-void WindowManager::roomStatusChanged( Room *aRoom, Room::Status aStatus, QTime aTime )
+void WindowManager::showDialog(QDialog *aDialog, bool blocking, bool aSendSignal)
{
- if ( iRoomStatusView == 0 )
+ // Handle dialog displaying
+ if ( aSendSignal ) emit dialogActivated();
+ if ( blocking )
{
- iRoomStatusView = new RoomStatusIndicatorWidget( aRoom, aStatus, aTime, iConfiguration->displaySettings()->timeFormat() );
- iRoomStatusView->setWindowTitle( iApplicationName );
- if( iFullScreen )
- iRoomStatusView->setWindowState( Qt::WindowFullScreen );
- connect( iRoomStatusView, SIGNAL( observedEventDetected() ), this, SIGNAL( observedEventDetected() ) );
+ aDialog->exec();
}
else
{
- iRoomStatusView->statusChanged( aStatus, aTime );
- }
- if ( !iWeeklyView->isVisible() && !iRoomStatusView->isVisible() )
- {
- showRoomStatus();
+ aDialog->show();
}
+ if ( aSendSignal ) emit dialogDeactivated();
}
-void WindowManager::showRoomStatus()
+void WindowManager::viewEventDetected()
{
- qDebug() << "WindowManager::showRoomStatus";
-
- if ( iRoomStatusView == 0 )
- {
- emit roomStatusInfoNeeded( iWeeklyView->currentRoom() );
- }
- else
+
+ if ( iCurrentView != 0 )
{
- iRoomStatusView->show();
- if ( iWeeklyView->isVisible() )
+ if ( iCurrentView->viewMode() == ViewBase::NormalView )
+ {
+ emit eventDetected();
+ }
+ else if ( iCurrentView->viewMode() == ViewBase::ObservedView )
{
- iWeeklyView->hide();
+ if ( !iViewList.isEmpty() )
+ {
+ ViewBase *previousView = static_cast<ViewBase *>( iViewList.pop() );
+ this->showView( previousView );
+ emit previousViewRestored();
+ }
}
}
- // closing/deleting meeting info dialog
- if ( iMeetingInfo != 0 )
- {
- iMeetingInfo->hide();
- }
}
-void WindowManager::showWeeklyView()
+bool WindowManager::event(QEvent *event)
{
- qDebug() << "WindowManager::showWeeklyView";
- if ( iRoomStatusView != 0 && iRoomStatusView->isVisible() )
+ if ( event->type() == QEvent::Resize )
{
- iRoomStatusView->hide();
+ if ( iCurrentView != 0 )
+ {
+ QSize currentSize = iCurrentView->size();
+ iCurrentView->setFixedSize( this->size() );
+ emit viewResized( this->size(), currentSize );
+ }
}
-
- iWeeklyView->show();
-}
-
-void WindowManager::fullScreen()
-{
- if ( iRoomStatusView != 0 )
- iRoomStatusView->setWindowState( Qt::WindowFullScreen );
- if ( iWeeklyView != 0 )
- iWeeklyView->setWindowState( Qt::WindowFullScreen );
- iFullScreen = true;
-}
-
-void WindowManager::insertMeeting( Meeting *aMeeting )
-{
- iWeeklyView->insertMeeting( aMeeting );
-}
-
-void WindowManager::deleteMeeting( Meeting *aMeeting )
-{
- iWeeklyView->deleteMeeting( aMeeting );
-}
-
-void WindowManager::showMeetingInfo( Meeting *aMeeting )
-{
- iMeetingInfo = new MeetingInfoDialog( aMeeting );
- // Display modal dialog
- iMeetingInfo->exec();
-
- delete iMeetingInfo;
- iMeetingInfo = 0;
-}
-
-void WindowManager::showSettingsView()
-{
- // TODO : give the Torspo for the person who was responsible to write this method
-}
-
-WeeklyViewWidget * WindowManager::weeklyView()
-{
- return iWeeklyView;
-}
-
-void WindowManager::error( const QString &aErrorMessage )
-{
- qDebug() << "WindowManager::showErrorPopup";
-
- PopUpMessageBox::error( 0, aErrorMessage );
-}
-
-void WindowManager::showPasswordDialog( QByteArray aAdminPassword, const QString &aMessage )
-{
- iPasswordDialog = new PasswordDialog( aAdminPassword, aMessage );
- connect( iPasswordDialog, SIGNAL( passwordEntered( PasswordDialog::PasswordStatus ) ),
- this, SIGNAL( passwordEntered( PasswordDialog::PasswordStatus ) ) );
- iPasswordDialog->show();
- //TODO connect connect( iWeeklyView, SIGNAL( observedEventDetected() ), this, SIGNAL( observedEventDetected() ) );
+ return QWidget::event( event );
}
-void WindowManager::closePasswordDialog()
-{
- iPasswordDialog->close();
- delete iPasswordDialog;
- iPasswordDialog = 0;
-}
-
-void WindowManager::showProgressBar( const QString &aText, bool aCancellable )
+void WindowManager::error( const QString &aErrorMessage )
{
- qDebug() << "WindowManager::showProgressBar( const QString & )";
- if( iProgressBar == 0 ) {
- iProgressBar = new ProgressBar( aText, aCancellable );
- iProgressBar->setFixedSize( 600, 125 );
- iProgressBar->show();
- if( aCancellable )
- connect( iProgressBar, SIGNAL( cancel() ), this, SIGNAL( progressBarCancelled() ) );
- }
-
- //TODO connect connect( iWeeklyView, SIGNAL( observedEventDetected() ), this, SIGNAL( observedEventDetected() ) );
-}
+ qDebug() << "WindowManager::error ";
-void WindowManager::closeProgressBar()
-{
- qDebug() << "WindowManager::closeProgressBar()";
- if( iProgressBar )
+ PopUpMessageBox *popup = PopUpMessageBox::error( 0, aErrorMessage );
+ if ( popup != 0 )
{
- iProgressBar->close();
- delete iProgressBar;
- iProgressBar = 0;
+ showDialog( static_cast<QDialog *>( popup ), false );
}
}
-void WindowManager::updateProgressBar( const QString &aMessage )
+void WindowManager::setFullscreen()
{
- qDebug() << "WindowManager::updateProgressBar( const QString & )";
- if( iProgressBar != 0 )
- iProgressBar->update( aMessage );
+ this->setWindowState( Qt::WindowFullScreen );
+ // Resize event handles the rest.
}
-#ifndef WINDOWMANAGER_H_
-#define WINDOWMANAGER_H_
-
-#include <QObject>
-#include <QTime>
-#include "Room.h"
-#include "Meeting.h"
-#include "PasswordDialog.h"
-#include "DeviceManager.h"
-
-class QTimer;
-class RoomStatusIndicatorWidget;
-class WeeklyViewWidget;
-class Engine;
-class MeetingInfoDialog;
-class SettingsView;
-class ProgressBar;
-class Configuration;
-
-//! UserInterface class. Behaves as a proxy between the user interface and application's business logic.
-/*!
- * UserInterface class. Controls the whole user interface, starting with displaying the appropriate
- * views. It behaves as a proxy between the user interface and application's business logic, it connects
- * the specified components together and forwards the data to the correct place. It also manages the correct
- * appearance of current views on the screen.
- */
-class WindowManager : public QObject
-{
- Q_OBJECT
-
-public:
- //! Constructor.
- /*!
- * Constructor of WindowManager.
- * \param aConfiguration The pointer to configuration.
- */
- WindowManager( Configuration *aConfiguration );
- //! Destructor.
- virtual ~WindowManager();
- /*!
- * Displays an error message
- * \param aErrorMessage Message to be displayd
- */
- void error( const QString &aErrorMessage );
- //! Updates the rooms status.
- /*!
- * Forwards the signal of changed status to current view.
- * \param aRoom Room which status is changed.
- * \param aStatus Current status of room.
- * \param aTime Time when status is changed.
- */
- void roomStatusChanged( Room *aRoom, Room::Status aStatus, QTime aTime );
- //! Shows the password dialog.
- /*!
- * Shows the password dialog.
- * \param aAdminPassword The correct password.
- * \param aMessage The message to be shown in the password dialog.
- */
- void showPasswordDialog( QByteArray aAdminPassword, const QString &aMessage );
- //! Closes the password dialog.
- /*!
- * Closes the password dialog.
- */
- void closePasswordDialog();
- //! Displays the weekly view.
- /*!
- * Displays the weekly view.
- */
- void showWeeklyView();
- //! Displays the meeting info dialog.
- /*!
- * Displays the meeting info dialog.
- * \param aMeeting Meeting to be displayd
- */
- void showMeetingInfo( Meeting *aMeeting );
- //! Returns the pointer to the weekly view.
- /*!
- * Returns the pointer to the weekly view.
- */
- WeeklyViewWidget * weeklyView();
- //! Switches the views to full screen.
- /*!
- * Switches the views to full screen.
- */
- void fullScreen();
- //! Shows the progress bar.
- /*!
- * Starts showing the progress bar.
- * \param aText The text to be shown in progress bar.
- * \param aCancellable Is the Cancel button visible. By default not visible.
- */
- void showProgressBar( const QString &aText, bool aCancellable = false );
- //! Closes the progress bar.
- /*!
- * Closes the progress bar.
- */
- void closeProgressBar();
-
- void insertMeeting( Meeting *aMeeting );
-
- void deleteMeeting( Meeting *aMeeting );
-
-signals:
- //! Request current status of the room.
- /*!
- * Signal is emitted when there is need to check current status of room aRoom.
- * \param aRoom Meetingroom which status is requested.
- */
- void roomStatusInfoNeeded( Room *aRoom );
- //! Indicate that some user event has happened.
- /*!
- * Signal is emitted if some user event has happened.
- */
- void observedEventDetected();
- //! Meeting activated.
- /*!
- * Signal is emitted when a meeting is clicked by the user.
- * \param aMeeting actived meeting.
- */
- void meetingActivated( Meeting *aMeeting );
- //! Signals if the shown week has been changed.
- /*!
- * Signal. Emitted if the shown week has been changed.
- * \param aDate The first date of the shown week.
- */
- void shownWeekChanged( QDate aDate );
- //! Signals change of the meeting room.
- /*!
- * Signal is emitted when meeting room is changed.
- * \param aRoom Selected meeting room.
- */
- void currentRoomChanged( Room *aRoom );
- //! Signals when the password dialog buttons are clicked.
- /*!
- * Signal is emitted when the password dialog buttons are clicked.
- * \param aPasswordStatus The status of the password.
- */
- void passwordEntered( PasswordDialog::PasswordStatus aPasswordStatus );
- //! Signals when the cancel button in the progress bar is clicked.
- /*!
- * Signal is emitted when the cancel button in the progress bar is clicked.
- */
- void progressBarCancelled();
-
-public slots:
- //! Slot for displaying the screensaver (room status view).
- /*!
- * Slot. Displays the screensaver.
- */
- void showRoomStatus();
- //! Slot for updating the time.
- /*!
- * Slot. Forwards the signal of changed time to current view.
- * \param aCurrentDateTime Current date and time.
- */
- void distributeDateTimeInfo( QDateTime aCurrentDateTime );
-
- void updateProgressBar( const QString &aMessage );
-
-private slots:
- //! Displays the settings view
- void showSettingsView();
-
-private:
- //! Name of the application.
- QString iApplicationName;
- //! Defines whether the views should be shown as full screen
- bool iFullScreen;
- //! Pointer to the configuration.
- Configuration *iConfiguration;
- //! Pointer to the weekly view.
- WeeklyViewWidget *iWeeklyView;
- //! Pointer to the screensaver (room status view).
- RoomStatusIndicatorWidget *iRoomStatusView;
- //! Pointer to the meeting info dialog
- MeetingInfoDialog *iMeetingInfo;
- //! Pointer to the settings view
- SettingsView *iSettingsView;
- //! Pointer to the progress bar
- ProgressBar *iProgressBar;
- //! Pointer to the password dialog.
- PasswordDialog *iPasswordDialog;
-
-};
-
-#endif /*WINDOWMANAGER_H_*/
+#ifndef WINDOWMANAGER_H_\r
+#define WINDOWMANAGER_H_\r
+\r
+#include <QWidget>\r
+#include <QStack>\r
+\r
+// Forward declarations\r
+class ViewBase;\r
+class QEvent;\r
+class QSize;\r
+class QDialog;\r
+class QString;\r
+\r
+//! UserInterface class. Manages displayed views.\r
+/*!\r
+ * UserInterface class. WindowManager class is responsible for displaying views that inherit the\r
+ * ViewBase class. It also handles dialog showing. Depending on the views type the WindowManager\r
+ * can track the views events and restore previous view if the current on is ObservedView. This\r
+ * is a handy mechanism for screensaver etc.\r
+ */\r
+class WindowManager : public QWidget\r
+{\r
+ Q_OBJECT\r
+\r
+public:\r
+ //! Constructor.\r
+ /*!\r
+ * Constructor of WindowManager.\r
+ */\r
+ WindowManager( QWidget *aParent = 0 );\r
+ //! Destructor.\r
+ virtual ~WindowManager();\r
+ \r
+ virtual bool event(QEvent *event);\r
+\r
+signals:\r
+ //! Request current status of the room.\r
+ /*!\r
+ * Signal is emitted when there is need to check current status of room aRoom.\r
+ * \param aRoom Meetingroom which status is requested.\r
+ */\r
+ void eventDetected();\r
+ \r
+ //! The view size is changed.\r
+ /*!\r
+ * This signal is emitted when the window managers view changes,\r
+ * i.e. it received resized QEvent.\r
+ * \param The new view size.\r
+ */\r
+ void viewResized(const QSize &newSize, const QSize &oldSize);\r
+ \r
+ //! Previous view is restored.\r
+ /*!\r
+ * This signal is emitted when previously stored view is\r
+ * restored. This happens when view with type ViewMode::ObservedView\r
+ * is shown and it receives an event that initiates the view\r
+ * restoring chain.\r
+ */\r
+ void previousViewRestored();\r
+ \r
+ void dialogActivated();\r
+ void dialogDeactivated();\r
+\r
+public slots:\r
+ //! Shows the view.\r
+ /*!\r
+ * Show view that inherits ViewBase class. If the views parent is not\r
+ * the WindowManager it will changed within this method. Depeding on the\r
+ * views type the currently active view might be stored and restored\r
+ * when specific event occurs in the view to be displayed.\r
+ */\r
+ void showView( ViewBase *view );\r
+ \r
+ //! Shows modal dialog.\r
+ /*!\r
+ * Shows modal dialog. Emits dialogActivated() signal prior calling\r
+ * QDialog's exec() method and emits dialogDeactivated signal when\r
+ * the exec() method returns.\r
+ */\r
+ void showDialog( QDialog *aDialog, bool blocking = true, bool aSendSignal = true );\r
+ \r
+ //! View event is detected.\r
+ /*!\r
+ * WindowManager connects this slot to ViewBase classes eventDetected()\r
+ * signal and either emits eventDetected() signal if the current views\r
+ * type is ViewMode::NormalView or restores possible previous view\r
+ * if the current views type is ViewMode::ObservedView.\r
+ */\r
+ void viewEventDetected();\r
+ \r
+ void setFullscreen();\r
+ \r
+ void error( const QString &aErrorMessage );\r
+\r
+private:\r
+ //! Name of the application.\r
+ QString iApplicationName;\r
+ \r
+ //! Currently active view.\r
+ ViewBase *iCurrentView;\r
+ \r
+ //! Stack of views previously displayed.\r
+ QStack<ViewBase *> iViewList;\r
+\r
+};\r
+\r
+#endif /*WINDOWMANAGER_H_*/\r
delete room;
}
-void TestEngine::testUpdateMeeting()
-{
- Room* room = new Room( "foo", "bar" );
- Meeting* meeting = new Meeting( 1234, room, QDateTime( QDate( 2009, 4, 1 ), QTime( 12, 0, 0 ) ),
- QDateTime( QDate( 2009, 4, 1 ), QTime( 12, 30, 0 ) ) );
- iEngine->updateMeeting( meeting, "foo", "bar" );
- delete meeting;
- delete room;
-}
-
void TestEngine::testDeleteMeeting()
{
Room* room = new Room( "foo", "bar" );