1 #include "WindowManager.h"
4 #include "Configuration.h"
5 #include "DisplaySettings.h"
9 #include "WeeklyViewWidget.h"
10 #include "RoomStatusIndicatorWidget.h"
11 #include "MeetingInfoDialog.h"
12 #include "PopUpMessageBox.h"
13 #include "DeviceManager.h"
14 #include "SettingsView.h"
15 #include "ProgressBar.h"
19 WindowManager::WindowManager( Configuration *aConfiguration ) :
21 iApplicationName( tr( "Qt Meetings" ) ),
22 iConfiguration( aConfiguration ),
29 iWeeklyView = new WeeklyViewWidget( QDateTime::currentDateTime(), aConfiguration );
30 iWeeklyView->setWindowTitle( iApplicationName );
31 connect( iWeeklyView, SIGNAL( observedEventDetected() ), this, SIGNAL( observedEventDetected() ) );
32 connect( iWeeklyView, SIGNAL( meetingActivated( Meeting * ) ), this, SIGNAL( meetingActivated( Meeting * ) ) );
33 connect( iWeeklyView, SIGNAL( currentRoomChanged( Room * ) ), this, SIGNAL( currentRoomChanged( Room * ) ) );
34 connect( iWeeklyView, SIGNAL( shownWeekChanged( QDate ) ), this, SIGNAL( shownWeekChanged( QDate ) ) );
40 WindowManager::~WindowManager()
44 delete iRoomStatusView;
50 delete iPasswordDialog;
54 void WindowManager::distributeDateTimeInfo( QDateTime aCurrentDateTime )
56 if ( iRoomStatusView != 0 && iRoomStatusView->isActiveWindow() )
58 iRoomStatusView->setCurrentTime( aCurrentDateTime.time() );
61 if ( iWeeklyView != 0 && iWeeklyView->isActiveWindow() )
63 iWeeklyView->setCurrentDateTime( aCurrentDateTime );
67 void WindowManager::roomStatusChanged( Room *aRoom, Room::Status aStatus, QTime aTime )
69 if ( iRoomStatusView == 0 )
71 iRoomStatusView = new RoomStatusIndicatorWidget( aRoom, aStatus, aTime, iConfiguration->displaySettings()->timeFormat() );
72 iRoomStatusView->setWindowTitle( iApplicationName );
73 connect( iRoomStatusView, SIGNAL( observedEventDetected() ), this, SIGNAL( observedEventDetected() ) );
77 iRoomStatusView->statusChanged( aStatus, aTime );
79 if ( !iWeeklyView->isVisible() && !iRoomStatusView->isVisible() )
85 void WindowManager::showRoomStatus()
87 qDebug() << "WindowManager::showRoomStatus";
89 if ( iRoomStatusView == 0 )
91 emit roomStatusInfoNeeded( iWeeklyView->currentRoom() );
95 iRoomStatusView->show();
96 if ( iWeeklyView->isVisible() )
102 // closing/deleting meeting info dialog
103 if ( iMeetingInfo != 0 )
105 iMeetingInfo->hide();
109 void WindowManager::showWeeklyView()
111 qDebug() << "WindowManager::showWeeklyView";
112 if ( iRoomStatusView != 0 && iRoomStatusView->isVisible() )
114 iRoomStatusView->hide();
120 void WindowManager::fullScreen()
122 iRoomStatusView->setWindowState( Qt::WindowFullScreen );
123 iWeeklyView->setWindowState( Qt::WindowFullScreen );
126 void WindowManager::insertMeeting( Meeting *aMeeting )
128 iWeeklyView->insertMeeting( aMeeting );
131 void WindowManager::deleteMeeting( Meeting *aMeeting )
133 iWeeklyView->deleteMeeting( aMeeting );
136 void WindowManager::showMeetingInfo( Meeting *aMeeting )
138 iMeetingInfo = new MeetingInfoDialog( aMeeting );
139 // Display modal dialog
140 iMeetingInfo->exec();
146 void WindowManager::showSettingsView()
148 // TODO : give the Torspo for the person who was responsible to write this method
151 WeeklyViewWidget * WindowManager::weeklyView()
156 void WindowManager::error( const QString &aErrorMessage )
158 qDebug() << "WindowManager::showErrorPopup";
160 PopUpMessageBox::error( 0, aErrorMessage );
163 void WindowManager::passwordEntered( PasswordDialog::PasswordStatus aPasswordStatus )
165 delete iPasswordDialog;
168 switch ( aPasswordStatus )
170 case PasswordDialog::Correct :
172 progressBar( tr( "Changing operation mode" ), true );
173 iProgressBar->show();
177 case PasswordDialog::Incorrect :
179 error( tr( "Incorrect password." ) );
182 default : //case PasswordDialog::Canceled
188 void WindowManager::showPasswordDialog( QByteArray aAdminPassword, const QString &aMessage )
190 iPasswordDialog = new PasswordDialog( aAdminPassword, aMessage );
191 iPasswordDialog->show();
195 void WindowManager::progressBar( const QString &aText, bool aStart )
197 qDebug() << "WindowManager::progressBar( const QString &, bool)";
199 if( iProgressBar == 0 ) {
200 iProgressBar = new ProgressBar( aText );
201 connect( iProgressBar, SIGNAL( cancel() ), this, SLOT( progressBar() ) );
202 connect( iProgressBar, SIGNAL( started() ), this, SLOT( changeMode() ) );
206 if( iProgressBar != 0 ) {