#ifndef WINDOWMANAGER_H_
#define WINDOWMANAGER_H_
-#include <QObject>
-#include <QTime>
-#include "Room.h"
-#include "Meeting.h"
-#include "PasswordDialog.h"
-#include "DeviceManager.h"
+#include <QWidget>
+#include <QStack>
-class QTimer;
-class RoomStatusIndicatorWidget;
-class WeeklyViewWidget;
-class Engine;
-class MeetingInfoDialog;
-class SettingsView;
-class ProgressBar;
-class Configuration;
+// Forward declarations
+class ViewBase;
+class QEvent;
+class QSize;
+class QDialog;
+class QString;
-//! UserInterface class. Behaves as a proxy between the user interface and application's business logic.
+//! UserInterface class. Manages displayed views.
/*!
- * 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.
+ * UserInterface class. WindowManager class is responsible for displaying views that inherit the
+ * ViewBase class. It also handles dialog showing. Depending on the views type the WindowManager
+ * can track the views events and restore previous view if the current on is ObservedView. This
+ * is a handy mechanism for screensaver etc.
*/
-class WindowManager : public QObject
+class WindowManager : public QWidget
{
Q_OBJECT
//! Constructor.
/*!
* Constructor of WindowManager.
- * \param aConfiguration The pointer to configuration.
*/
- WindowManager( Configuration *aConfiguration );
+ WindowManager( QWidget *aParent = 0 );
//! 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 );
+ virtual bool event(QEvent *event);
+
//! Shows any view specific indicators for connection error
void connectionLost();
* 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.
+ void eventDetected();
+
+ //! The view size is changed.
/*!
- * Signal is emitted when meeting room is changed.
- * \param aRoom Selected meeting room.
+ * This signal is emitted when the window managers view changes,
+ * i.e. it received resized QEvent.
+ * \param The new view size.
*/
- void currentRoomChanged( Room *aRoom );
- //! Signals when the password dialog buttons are clicked.
+ void viewResized(const QSize &newSize, const QSize &oldSize);
+
+ //! Previous view is restored.
/*!
- * Signal is emitted when the password dialog buttons are clicked.
- * \param aPasswordStatus The status of the password.
+ * This signal is emitted when previously stored view is
+ * restored. This happens when view with type ViewMode::ObservedView
+ * is shown and it receives an event that initiates the view
+ * restoring chain.
*/
- void passwordEntered( PasswordDialog::PasswordStatus aPasswordStatus );
- //! Signals when the cancel button in the progress bar is clicked.
+ void previousViewRestored();
+
+ void dialogActivated();
+ void dialogDeactivated();
+
+public slots:
+ //! Shows the view.
/*!
- * Signal is emitted when the cancel button in the progress bar is clicked.
+ * Show view that inherits ViewBase class. If the views parent is not
+ * the WindowManager it will changed within this method. Depeding on the
+ * views type the currently active view might be stored and restored
+ * when specific event occurs in the view to be displayed.
*/
- void progressBarCancelled();
+ void showView( ViewBase *view );
-public slots:
- //! Slot for displaying the screensaver (room status view).
+ //! Shows modal dialog.
/*!
- * Slot. Displays the screensaver.
+ * Shows modal dialog. Emits dialogActivated() signal prior calling
+ * QDialog's exec() method and emits dialogDeactivated signal when
+ * the exec() method returns.
*/
- void showRoomStatus();
- //! Slot for updating the time.
+ void showDialog( QDialog *aDialog, bool blocking = true, bool aSendSignal = true );
+
+ //! View event is detected.
/*!
- * Slot. Forwards the signal of changed time to current view.
- * \param aCurrentDateTime Current date and time.
+ * WindowManager connects this slot to ViewBase classes eventDetected()
+ * signal and either emits eventDetected() signal if the current views
+ * type is ViewMode::NormalView or restores possible previous view
+ * if the current views type is ViewMode::ObservedView.
*/
- void distributeDateTimeInfo( QDateTime aCurrentDateTime );
+ void viewEventDetected();
- void updateProgressBar( const QString &aMessage );
+ void setFullscreen();
-private slots:
- //! Displays the settings view
- void showSettingsView();
+ void error( const QString &aErrorMessage );
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;
+
+ //! Currently active view.
+ ViewBase *iCurrentView;
+
+ //! Stack of views previously displayed.
+ QStack<ViewBase *> iViewList;
};