From: Risto Lintinen Date: Thu, 27 Aug 2009 05:38:59 +0000 (+0300) Subject: 1.0.6 candidate X-Git-Url: https://vcs.maemo.org/git/?p=qtmeetings;a=commitdiff_plain;h=6a31f3484996e9b7e719954c3a64a56d3fa586aa 1.0.6 candidate commit 7e9daec272450fa2eeffe0a08732ef4696b37a4f Author: Risto Lintinen Date: Wed Aug 26 14:57:11 2009 +0300 added refresh on statusbar click commit 627d527566f469ac20bfd9ee536f4624f9dd0655 Author: Risto Lintinen Date: Wed Aug 26 11:45:17 2009 +0300 deleted unnecessary files commit 52cdeca811d3ffc2804aede00616640d93429171 Author: Risto Lintinen Date: Wed Aug 26 11:44:05 2009 +0300 deb packaging improvements commit a39640fc3ee32d823998ea9a14a106c8bca92b1c Author: Risto Lintinen Date: Tue Aug 25 10:28:23 2009 +0300 fixes for debian install commit 031dfbe58e5265dfff05b8ceb7ffae21be7c4868 Author: Risto Lintinen Date: Tue Aug 25 10:27:15 2009 +0300 User interface and menu fixes commit 51d64b3d9f4cacc447c74e5811e692fbe9b4137f Author: Risto Lintinen Date: Mon Aug 24 12:04:45 2009 +0300 Status bar fixed commit a2659d5f04b1662bea18fbbbff3a763fcfe3ff7c Author: Timo Holopainen Date: Mon Aug 24 11:23:38 2009 +0300 Show confidential meeting details setting added Squashed commit of the following: commit d8ce7147dfa33ee9bb79e10b09b3a82018bdb05b Author: Timo Holopainen Date: Mon Aug 24 11:03:06 2009 +0300 Show confidential meeting details setting added to settings. Meeting view updated to support that privacy setting. commit 11e5e6349ca6f86f864075fb9d38a778950cebf2 Author: Risto Lintinen Date: Fri Aug 21 13:01:48 2009 +0300 code warnings cleaned commit 663a2fc8ce3a0b8b987655fe709a831a3db9b315 Author: Risto Lintinen Date: Fri Aug 21 12:05:25 2009 +0300 User interface update --- diff --git a/QtMeetings.conf b/QtMeetings.conf index 04cb472..9f1d726 100644 --- a/QtMeetings.conf +++ b/QtMeetings.conf @@ -2,11 +2,7 @@ - - - jklexch01.ixonos.com + @@ -14,7 +10,7 @@ - + diff --git a/QtMeetings.pro b/QtMeetings.pro index b4c6c65..e46c741 100644 --- a/QtMeetings.pro +++ b/QtMeetings.pro @@ -13,7 +13,8 @@ INCLUDEPATH += src/Domain/ \ src/UserInterface/Components/ \ src/UserInterface/Utils/ \ src/UserInterface/Views/ -HEADERS += src/BusinessLogic/UIManager.h \ +HEADERS += src/UserInterface/Components/BorderedBarWidget.h \ + src/BusinessLogic/UIManager.h \ src/IO/DeviceControl/OperationModeToggler.h \ src/UserInterface/Utils/ProgressBar.h \ src/Domain/Room.h \ @@ -48,7 +49,8 @@ HEADERS += src/BusinessLogic/UIManager.h \ src/UserInterface/Views/SettingsView.h \ src/UserInterface/WindowManager.h \ src/UserInterface/Views/ViewBase.h -SOURCES += src/BusinessLogic/UIManager.cpp \ +SOURCES += src/UserInterface/Components/BorderedBarWidget.cpp \ + src/BusinessLogic/UIManager.cpp \ src/IO/DeviceControl/OperationModeToggler.cpp \ src/UserInterface/Utils/ProgressBar.cpp \ src/Domain/Room.cpp \ diff --git a/debian/changelog b/debian/changelog index 08cf32a..ff20c47 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +qtmeetings (1.0.6-1) unstable; urgency=low + + * Improved user interface + * Fix for settings read and write + + -- Risto Lintinen Mon, 24 May 2009 12:30:00 +0300 + qtmeetings (1.0.5-1) unstable; urgency=low * Improved communication module for getting a meeting secondary id and detailed information diff --git a/debian/files b/debian/files new file mode 100644 index 0000000..216a8e5 --- /dev/null +++ b/debian/files @@ -0,0 +1 @@ +qtmeetings_1.0.6-1_armel.deb user/other optional diff --git a/debian/qtmeetings.install b/debian/qtmeetings.install index e69de29..ad52d9b 100644 --- a/debian/qtmeetings.install +++ b/debian/qtmeetings.install @@ -0,0 +1,2 @@ +QtMeetings.conf etc +QtMeetings.desktop usr/share/applications/hildon diff --git a/resources/icons/roomstatus_busy.png b/resources/icons/roomstatus_busy.png index d735440..d69d8ba 100644 Binary files a/resources/icons/roomstatus_busy.png and b/resources/icons/roomstatus_busy.png differ diff --git a/resources/icons/roomstatus_free.png b/resources/icons/roomstatus_free.png index 14aa52f..2c6edce 100644 Binary files a/resources/icons/roomstatus_free.png and b/resources/icons/roomstatus_free.png differ diff --git a/src/BusinessLogic/Engine.cpp b/src/BusinessLogic/Engine.cpp index c7aad8b..6cf5ee4 100644 --- a/src/BusinessLogic/Engine.cpp +++ b/src/BusinessLogic/Engine.cpp @@ -32,8 +32,7 @@ Engine::Engine() : iWindowManager( 0 ), iUIManager( 0 ) { qDebug() << "Engine::Engine()"; - iCommunicationFailed = false; - iCurrentWeekFetched = false; + iCommunicationFailed = true; initConfiguration(); initDevice(); @@ -53,9 +52,15 @@ Engine::Engine() : // Create auto refresh timer iAutoRefresh = new QTimer; - iAutoRefresh->setInterval(iConfiguration->connectionSettings()->refreshInterval() * 1000); + + iAutoRefresh->setInterval(Configuration::instance()->getRefreshinterval() * 1000); + iAutoRefresh->start(); connect( iAutoRefresh, SIGNAL( timeout() ), iAutoRefresh, SLOT( start() ) ); + connect( iAutoRefresh, SIGNAL( timeout() ), this, SLOT( updateRoomInfo() ) ); + + connect(iWindowManager, SIGNAL(closeClicked()), this, SLOT(closeApplication())); + // connect( iAutoRefresh, SIGNAL( timeout() ), this, SLOT( fetchMeetings() ) ); if( iDevice->currentOperationMode() == DeviceManager::KioskMode ) @@ -64,7 +69,7 @@ Engine::Engine() : } connectSignals(); - + connect( Configuration::instance(), SIGNAL( configurationChanged() ), this, SLOT( configurationChanged() ) ); // QTimer::singleShot( 0, this, SLOT( fetchMeetings() ) ); // TODO: continue implementation @@ -105,7 +110,6 @@ Room* Engine::defaultRoom() void Engine::checkStatusOfAllRooms() { // TODO: Check if date has changed - // qDebug() << "Engine::checkStatusOfAllRooms()"; // iterate trough on the rooms for (int i = 0; i < iConfiguration->rooms().count(); i++) { @@ -182,10 +186,14 @@ void Engine::fetchMeetingDetails( Meeting *aMeeting ) void Engine::meetingsFetched( const QList &aMeetings ) { qDebug() << "Engine::meetingsFetched( const QList & )"; - // TODO: should check if this week's meetings were fetched - if( iCommunicationFailed || !iCurrentWeekFetched ) + QTime c = QTime::currentTime(); + iLastCommunication.setHMS( c.hour(), c.minute(), c.second() ); + + qDebug() << "Error length: "<< iCommunicationError.length(); + qDebug() << "Error: "<< iCommunicationError; + + if( iCommunicationError.length() == 0 ) { - iCurrentWeekFetched = true; iCommunicationFailed = false; iUIManager->connectionEstablished(); } @@ -208,21 +216,42 @@ void Engine::meetingsFetched( const QList &aMeetings ) void Engine::errorHandler( int aCode, const QString &aAddInfo ) { + iCommunicationFailed = true; + if( aCode >= 100 && aCode < 150 ) { - iCommunicationFailed = true; - if ( iUIManager != 0 ) iUIManager->connectionLost(); + if ( iUIManager != 0 ) + { + iUIManager->connectionLost(); + } } if ( iWindowManager != 0 ) { - iWindowManager->error( ErrorMapper::codeToString( aCode, aAddInfo ) ); + iCommunicationError = ErrorMapper::codeToString( aCode, aAddInfo ); + //iWindowManager->error( ErrorMapper::codeToString( aCode, aAddInfo ) ); } } +bool Engine::connected() +{ + return !iCommunicationFailed; +} + +QTime Engine::lastUpdated() +{ + return iLastCommunication; +} + +QString Engine::errorMessage() +{ + return iCommunicationError; +} + void Engine::fetchMeetings( const int aWeek, const int aYear, const Room *aIn ) { qDebug() << "Engine::fetchMeetings( const int aWeek, const int aYear, const Room * )"; + iCommunicationError = ""; iCommunication->fetchMeetings(aWeek, aYear, *aIn); } @@ -234,6 +263,7 @@ void Engine::cancelFetchMeetingDetails() void Engine::shownWeekChanged( QDate aFrom ) { qDebug() << "[Engine::shownWeekChanged] "; + iCommunicationError = ""; iCommunication->fetchMeetings( aFrom.weekNumber(), aFrom.year(), *iCurrentRoom/*defaultRoom()*/ ); } @@ -308,7 +338,7 @@ void Engine::connectSignals() void Engine::initCommunication() { // initialize communication - iCommunication = new CommunicationManager( *(iConfiguration->connectionSettings()) ); + iCommunication = new CommunicationManager(/* *(iConfiguration->connectionSettings()) */); connect( iCommunication, SIGNAL( error( int, CommunicationManager::CommunicationType ) ), this, SLOT( errorHandler( int ) ) ); connect( iCommunication, SIGNAL( meetingsFetched( const QList& ) ), @@ -385,4 +415,16 @@ void Engine::tick( QDateTime aCurrentDateTime ) } } iCurrentDate = aCurrentDateTime.date(); -} \ No newline at end of file +} + + +void Engine::updateRoomInfo() +{ + qDebug() << "ENGINE::: updateMeetings"; + iUIManager->currentRoomChanged( iCurrentRoom ); +} + +void Engine::configurationChanged() +{ + iAutoRefresh->setInterval(Configuration::instance()->getRefreshinterval() * 1000); +} diff --git a/src/BusinessLogic/Engine.h b/src/BusinessLogic/Engine.h index c58e423..65690a1 100644 --- a/src/BusinessLogic/Engine.h +++ b/src/BusinessLogic/Engine.h @@ -39,6 +39,10 @@ public: */ Room* defaultRoom(); + bool connected(); + QTime lastUpdated(); + QString errorMessage(); + signals: void roomStatusChanged( Room::Status aStatus, QTime aUntil ); @@ -122,6 +126,15 @@ private slots: void tick( QDateTime aCurrentDateTime ); + /** + * Updates the current rooms info. + */ + void updateRoomInfo(); + /** + * + */ + void configurationChanged(); + private: // Make the UIManager as friendly class so it can connect to private slots. friend class UIManager; @@ -189,14 +202,13 @@ private: private: static QTime endOfTheDay; - - WindowManager *iWindowManager; QTimer *iIdleTimeCounter; Clock *iClock; QDate iCurrentDate; Configuration *iConfiguration; CommunicationManager *iCommunication; + WindowManager *iWindowManager; DeviceManager *iDevice; UIManager *iUIManager; @@ -206,7 +218,8 @@ private: Room *iCurrentRoom; bool iCommunicationFailed; - bool iCurrentWeekFetched; + QString iCommunicationError; + QTime iLastCommunication; }; #endif /*ENGINE_H_*/ diff --git a/src/BusinessLogic/UIManager.cpp b/src/BusinessLogic/UIManager.cpp index eb80616..1c58381 100644 --- a/src/BusinessLogic/UIManager.cpp +++ b/src/BusinessLogic/UIManager.cpp @@ -37,8 +37,9 @@ UIManager::UIManager( Engine *aEngine, WindowManager *aWindowManager ) : if ( iEngine == 0 ) return; if ( iWindowManager == 0 ) return; + connect(iWindowManager, SIGNAL(showSettingsClicked()), this, SLOT(settingsViewRequest())); + createWeeklyView(); - createSettingsView(); createRoomStatusIndicator(); createPasswordDialog(); createProgressBar(); @@ -74,6 +75,7 @@ void UIManager::createWeeklyView() 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( refreshButtonClicked() ), iEngine, SLOT( updateRoomInfo() ) ); 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 * ) ) ); @@ -134,12 +136,11 @@ void UIManager::connectCommunicationManager( CommunicationManager *aCommunicatio // UIMANAGER SLOTS void UIManager::settingsViewRequest() { + createSettingsView(); + // Show the settings view and stop the idle timer - if ( iSettingsView != 0 ) - { - iWindowManager->showView( static_cast( iSettingsView ) ); - iEngine->stopIdleTimeCounter(); - } + iWindowManager->showView( static_cast( iSettingsView ) ); + iEngine->stopIdleTimeCounter(); } void UIManager::settingsOkClicked() @@ -148,7 +149,9 @@ void UIManager::settingsOkClicked() if ( iWeeklyView != 0 ) { iWindowManager->showView( static_cast( iWeeklyView ) ); + QT_DELETE(iSettingsView); iEngine->startIdleTimeCounter(); + currentRoomChanged(iWeeklyView->currentRoom()); } } @@ -161,7 +164,7 @@ void UIManager::meetingsFetched( const QList &aMeetings ) } } -void UIManager::showMeetingProgressBar( Meeting *aMeeting ) +void UIManager::showMeetingProgressBar( Meeting */*aMeeting*/ ) { if ( iProgressBar != 0 ) { @@ -227,7 +230,6 @@ void UIManager::connectionLost() { qDebug() << "UIManager::connectionLost()"; iWeeklyView->connectionLost(); - iSettingsView->connectionLost(); iRoomStatusIndicator->connectionLost(); } @@ -235,7 +237,6 @@ void UIManager::connectionEstablished() { qDebug() << "UIManager::connectionEstablished()"; iWeeklyView->connectionEstablished(); - iSettingsView->connectionEstablished(); iRoomStatusIndicator->connectionEstablished(); } @@ -253,11 +254,11 @@ void UIManager::updateTime(QDateTime aDateTime) { if ( iWeeklyView != 0 ) { - iWeeklyView->setCurrentDateTime( aDateTime ); + iWeeklyView->setConnectionStatus( aDateTime, iEngine->connected(), iEngine->lastUpdated(), iEngine->errorMessage() ); } if ( iRoomStatusIndicator != 0 ) { - iRoomStatusIndicator->setCurrentTime( aDateTime.time() ); + iRoomStatusIndicator->setConnectionStatus( aDateTime, iEngine->connected(), iEngine->lastUpdated(), iEngine->errorMessage() ); } } @@ -313,6 +314,7 @@ void UIManager::settingsCancelClicked() if ( iWeeklyView != 0 ) { iWindowManager->showView( static_cast( iWeeklyView ) ); + QT_DELETE(iSettingsView); iEngine->startIdleTimeCounter(); } -} \ No newline at end of file +} diff --git a/src/Domain/Configuration/Configuration.cpp b/src/Domain/Configuration/Configuration.cpp index 2a33998..997711b 100644 --- a/src/Domain/Configuration/Configuration.cpp +++ b/src/Domain/Configuration/Configuration.cpp @@ -11,96 +11,111 @@ #include #include +#include +#include Configuration * Configuration::sInstance = 0; QString Configuration::sConfigurationPath = "/etc/QtMeetings.conf"; Configuration::Configuration() : - iConnectionSettings( 0 ), - iStartupSettings( 0 ), - iDisplaySettings( 0 ), - iDateTimeSettings( 0 ) + iConnectionSettings(0), iStartupSettings(0), iDisplaySettings(0), + iDateTimeSettings(0), + iShowConfidentialMeetingDetails(false) { } -Configuration::~Configuration() -{ +Configuration::~Configuration() { delete iConnectionSettings; delete iStartupSettings; delete iDisplaySettings; delete iDateTimeSettings; - while ( !iRooms.isEmpty() ) - { + while (!iRooms.isEmpty()) { delete iRooms.takeFirst(); } } -Configuration* Configuration::instance() -{ - if ( sInstance == 0 ) - { - sInstance = readFromXML( sConfigurationPath ); - if( !sInstance ) - { - qDebug() << "FATAL: Configuration cannot be read from:" << Configuration::sConfigurationPath; - } - } +Configuration* Configuration::instance() { + if (sInstance == 0) { + qDebug() << "HERE"; + sInstance = new Configuration(); + sInstance->readFromXML(sConfigurationPath); + if (!sInstance) { + qDebug() << "FATAL: Configuration cannot be read from:" + << Configuration::sConfigurationPath; + } + } return sInstance; } -ConnectionSettings* Configuration::connectionSettings() -{ - return iConnectionSettings; -} +/*ConnectionSettings* Configuration::connectionSettings() + { + return iConnectionSettings; + }*/ -StartupSettings * Configuration::startupSettings() -{ +StartupSettings * Configuration::startupSettings() { return iStartupSettings; } -DisplaySettings * Configuration::displaySettings() -{ +DisplaySettings * Configuration::displaySettings() { return iDisplaySettings; } -DateTimeSettings * Configuration::dateTimeSettings() -{ +DateTimeSettings * Configuration::dateTimeSettings() { return iDateTimeSettings; } -Room* Configuration::defaultRoom() -{ +Room* Configuration::defaultRoom() { // default room is stored as the first element of the list - return ( iRooms.count() == 0 ) ? 0 : iRooms.at( 0 ); + return (iRooms.count() == 0) ? 0 : iRooms.at(0); } -QString Configuration::languageCode() -{ +QString Configuration::languageCode() { return iLanguageCode; } -QList Configuration::rooms() -{ +QList Configuration::rooms() { return iRooms; } -QByteArray Configuration::adminPassword() -{ +QByteArray Configuration::adminPassword() { return iAdminPassword; } +QUrl Configuration::getServerUrl() { + return iConnectionSettings->serverUrl(); +} -void Configuration::save() -{ - QDomDocument doc; - QFile file( sConfigurationPath ); +QString Configuration::getUsername() { + return iConnectionSettings->username(); +} +QString Configuration::getPassword() { + return iConnectionSettings->password(); +} - if ( !file.open( QIODevice::ReadWrite ) ) - { +unsigned int Configuration::getRefreshinterval() { + return iConnectionSettings->refreshInterval(); +} + +void Configuration::setServerUrl(QUrl serverUrl) { + iConnectionSettings->setServerUrl(serverUrl); +} +void Configuration::setUsername(QString username) { + iConnectionSettings->setUsername(username); +} +void Configuration::setPassword(QString password) { + iConnectionSettings->setPassword(password); +} +void Configuration::setRefreshinterval(unsigned int refreshinterval) { + iConnectionSettings->setRefreshInterval(refreshinterval); +} + +void Configuration::save() { + QDomDocument doc; + QFile file(sConfigurationPath); + if (!file.open(QIODevice::ReadWrite)) { return; } - if ( !doc.setContent( &file ) ) - { + if (!doc.setContent(&file)) { file.close(); return; } @@ -108,110 +123,100 @@ void Configuration::save() QDomElement root = doc.documentElement(); // Save all attributes to document - saveAdminPassword( root ); + saveAdminPassword(root); - for ( QDomNode node = root.firstChild(); !node.isNull(); node = node.nextSibling() ) - { + bool confidentialMeetingDetailsElementMissing = true; + + for (QDomNode node = root.firstChild(); !node.isNull(); node + = node.nextSibling()) { QDomElement e = node.toElement(); QString tagName = e.tagName().toLower(); + if (tagName == QString("connection")) { + saveConnectionSettings(node); + } else if (tagName == QString("rooms")) { + saveRooms(node); + } else if (tagName == QString("language")) { + saveLanguageCode(node); + } else if (tagName == QString("startup")) { + saveStartupSettings(node); + } else if (tagName == QString("display")) { + saveDisplaySettings(node); + } else if (tagName == QString("daylight_saving_time")) { + saveDateTimeSettings(node); + } else if (tagName == QString("privacy")) { + confidentialMeetingDetailsElementMissing = false; + savePrivacySettings(node); + } + } - if ( tagName == QString( "connection" ) ) - { - saveConnectionSettings( node ); - } - else if ( tagName == QString( "rooms" ) ) - { - saveRooms( node ); - } - else if ( tagName == QString( "language" ) ) - { - saveLanguageCode( node ); - } - else if ( tagName == QString( "startup" ) ) - { - saveStartupSettings( node ); - } - else if ( tagName == QString( "display" ) ) - { - saveDisplaySettings( node ); - } - else if (tagName == QString( "daylight_saving_time" ) ) - { - saveDateTimeSettings( node ); - } + if( confidentialMeetingDetailsElementMissing ) + { + QDomElement e = root.ownerDocument().createElement("privacy"); + savePrivacySettings(e); + root.appendChild(e); } //! Empty the file from previous content and write again with new one - file.resize( 0 ); - file.write( doc.toByteArray( 4 ) ); //! 4 as intent + file.resize(0); + file.write(doc.toByteArray(4)); //! 4 as intent file.close(); - + emit configurationChanged(); } -void Configuration::saveConnectionSettings( const QDomNode &aXML ) -{ - for ( QDomNode node = aXML.firstChild(); !node.isNull(); node = node.nextSibling() ) - { +void Configuration::saveConnectionSettings(const QDomNode &aXML) { + QDomElement e = aXML.firstChild().toElement(); + QString tagName = e.tagName().toLower(); + qDebug() << tagName; + for (QDomNode node = aXML.firstChild(); !node.isNull(); node + = node.nextSibling()) { QDomElement e = node.toElement(); QString tagName = e.tagName().toLower(); - if ( tagName == QString( "serverurl" ) ) - { - QDomText t = node.ownerDocument().createTextNode( iConnectionSettings->serverUrl().toString() ); - if ( e.hasChildNodes() ) - { - e.replaceChild( t, e.firstChild() ); - } - else - { - e.appendChild( e.firstChild() ); + qDebug() << tagName; + if (tagName == QString("serverurl")) { + QDomText t = node.ownerDocument().createTextNode( + iConnectionSettings->serverUrl().toString()); + if (e.hasChildNodes()) { + e.replaceChild(t, e.firstChild()); + } else { + e.appendChild(t); } - } - else if ( tagName == QString( "username" ) ) - { - QDomText t = node.ownerDocument().createTextNode( iConnectionSettings->username() ); - if ( e.hasChildNodes() ) - { - e.replaceChild( t, e.firstChild() ); - } - else - { - e.appendChild( e.firstChild() ); + } else if (tagName == QString("username")) { + QDomText t = node.ownerDocument().createTextNode( + iConnectionSettings->username()); + if (e.hasChildNodes()) { + e.replaceChild(t, e.firstChild()); + } else { + e.appendChild(t); } - } - else if ( tagName == QString( "password" ) ) - { - QDomText t = node.ownerDocument().createTextNode( iConnectionSettings->password() ); - if ( e.hasChildNodes() ) - { - e.replaceChild( t, e.firstChild() ); - } - else - { - e.appendChild( e.firstChild() ); + + } else if (tagName == QString("password")) { + QDomText t = node.ownerDocument().createTextNode( + iConnectionSettings->password()); + if (e.hasChildNodes()) { + e.replaceChild(t, e.firstChild()); + } else { + e.appendChild(t); } - } - else if ( tagName == QString( "refreshinterval" ) ) - { - QString s = QString( "%1" ).arg( iConnectionSettings->refreshInterval() ); - QDomText t = node.ownerDocument().createTextNode( s ); - e.replaceChild( t, e.firstChild() ); + } else if (tagName == QString("refreshinterval")) { + QString s = QString("%1").arg( + iConnectionSettings->refreshInterval()); + QDomText t = node.ownerDocument().createTextNode(s); + e.replaceChild(t, e.firstChild()); } } } -void Configuration::saveRooms( const QDomNode &aXML ) -{ +void Configuration::saveRooms(const QDomNode &aXML) { //! List of rooms must be cleared and rewritten again QDomDocument doc = aXML.ownerDocument(); - QDomNode root = aXML; + QDomNode root = aXML; // Remove child nodes... int count = root.childNodes().count(); QDomNode node = root.firstChild(); QDomNode next; - for (int i = 0; i < count; i++) - { + for (int i = 0; i < count; i++) { qDebug() << "remove " << node.toElement().text(); next = node.nextSibling(); node = root.removeChild(node); @@ -220,264 +225,220 @@ void Configuration::saveRooms( const QDomNode &aXML ) node = aXML; QList::iterator i; - for ( i = iRooms.begin(); i != iRooms.end(); ++i ) - { - QDomElement tag = doc.createElement( "room" ); - node.appendChild( tag ); + for (i = iRooms.begin(); i != iRooms.end(); ++i) { + QDomElement tag = doc.createElement("room"); + node.appendChild(tag); // First room in the list is a dafault room - if ( i == iRooms.begin() ) - { - tag.setAttribute( "default", "true" ); + if (i == iRooms.begin()) { + tag.setAttribute("default", "true"); } - QDomElement ename = doc.createElement( "name" ); - QDomText tname = node.ownerDocument().createTextNode(( *i )->name() ); - ename.appendChild( tname ); - tag.appendChild( ename ); + QDomElement ename = doc.createElement("name"); + QDomText tname = node.ownerDocument().createTextNode((*i)->name()); + ename.appendChild(tname); + tag.appendChild(ename); - QDomElement eaddress = doc.createElement( "address" ); - QDomText taddress = node.ownerDocument().createTextNode(( *i )->address() ); - eaddress.appendChild( taddress ); - tag.appendChild( eaddress ); + QDomElement eaddress = doc.createElement("address"); + QDomText taddress = + node.ownerDocument().createTextNode((*i)->address()); + eaddress.appendChild(taddress); + tag.appendChild(eaddress); } } -void Configuration::saveLanguageCode( const QDomNode &aXML ) -{ +void Configuration::saveLanguageCode(const QDomNode &aXML) { QDomElement e = aXML.toElement(); - e.setAttribute( "code", languageCode() ); + e.setAttribute("code", languageCode()); } -void Configuration::saveStartupSettings( const QDomNode &aXML ) -{ +void Configuration::saveStartupSettings(const QDomNode &aXML) { QDomElement e = aXML.toElement(); - for ( QDomNode node = aXML.firstChild(); !node.isNull(); node = node.nextSibling() ) - { + for (QDomNode node = aXML.firstChild(); !node.isNull(); node + = node.nextSibling()) { e = node.toElement(); QString tagName = e.tagName().toLower(); - if ( tagName == QString( "powersaving" ) ) - { - ( iStartupSettings->isPowersavingEnabled() ? - e.setAttribute( "enabled", "true" ) : - e.setAttribute( "enabled", "false" ) ); + if (tagName == QString("powersaving")) { + (iStartupSettings->isPowersavingEnabled() ? e.setAttribute( + "enabled", "true") : e.setAttribute("enabled", "false")); - e.setAttribute( "on", iStartupSettings->turnOnAt().toString( "hh:mm" ) ); - e.setAttribute( "off", iStartupSettings->turnOffAt().toString( "hh:mm" ) ); + e.setAttribute("on", iStartupSettings->turnOnAt().toString("hh:mm")); + e.setAttribute("off", iStartupSettings->turnOffAt().toString( + "hh:mm")); } } } -void Configuration::saveDisplaySettings( const QDomNode &aXML ) -{ - for ( QDomNode node = aXML.firstChild(); !node.isNull(); node = node.nextSibling() ) - { +void Configuration::saveDisplaySettings(const QDomNode &aXML) { + for (QDomNode node = aXML.firstChild(); !node.isNull(); node + = node.nextSibling()) { QDomElement e = node.toElement(); QString tagName = e.tagName().toLower(); - if ( tagName == QString( "schedule" ) ) - { - for ( QDomNode scheduleNode = node.firstChild(); !scheduleNode.isNull(); scheduleNode = scheduleNode.nextSibling() ) - { + if (tagName == QString("schedule")) { + for (QDomNode scheduleNode = node.firstChild(); !scheduleNode.isNull(); scheduleNode + = scheduleNode.nextSibling()) { QDomElement scheduleElem = scheduleNode.toElement(); tagName = scheduleElem.tagName().toLower(); - if ( tagName == QString( "week" ) ) - { - scheduleElem.setAttribute( "days", iDisplaySettings->daysInSchedule() ); + if (tagName == QString("week")) { + scheduleElem.setAttribute("days", + iDisplaySettings->daysInSchedule()); + } else if (tagName == QString("day")) { + scheduleElem.setAttribute("startsat", + iDisplaySettings->dayStartsAt().toString("hh:mm")); + scheduleElem.setAttribute("endsat", + iDisplaySettings->dayEndsAt().toString("hh:mm")); } - else if ( tagName == QString( "day" ) ) - { - scheduleElem.setAttribute( "startsat", iDisplaySettings->dayStartsAt().toString( "hh:mm" ) ); - scheduleElem.setAttribute( "endsat", iDisplaySettings->dayEndsAt().toString( "hh:mm" ) ); - } - } // end of for - } // end of schedule - else if ( tagName == QString( "dateformat" ) ) - { - QDomText t = node.ownerDocument().createTextNode( iDisplaySettings->dateFormat() ); - e.replaceChild( t, e.firstChild() ); - } - else if ( tagName == QString( "timeformat" ) ) - { - QDomText t = node.ownerDocument().createTextNode( iDisplaySettings->timeFormat() ); - e.replaceChild( t, e.firstChild() ); - } - else if ( tagName == QString( "screensaver" ) ) - { - QString s = QString( "%1" ).arg( iDisplaySettings->screensaver() ); - QDomText t = node.ownerDocument().createTextNode( s ); - e.replaceChild( t, e.firstChild() ); + } // end of for + } // end of schedule + else if (tagName == QString("dateformat")) { + QDomText t = node.ownerDocument().createTextNode( + iDisplaySettings->dateFormat()); + e.replaceChild(t, e.firstChild()); + } else if (tagName == QString("timeformat")) { + QDomText t = node.ownerDocument().createTextNode( + iDisplaySettings->timeFormat()); + e.replaceChild(t, e.firstChild()); + } else if (tagName == QString("screensaver")) { + QString s = QString("%1").arg(iDisplaySettings->screensaver()); + QDomText t = node.ownerDocument().createTextNode(s); + e.replaceChild(t, e.firstChild()); } } } -void Configuration::saveDateTimeSettings( const QDomNode &aXML ) -{ - for ( QDomNode node = aXML.firstChild(); !node.isNull(); node = node.nextSibling() ) - { +void Configuration::saveDateTimeSettings(const QDomNode &aXML) { + for (QDomNode node = aXML.firstChild(); !node.isNull(); node + = node.nextSibling()) { QDomElement e = node.toElement(); QString tagName = e.tagName().toLower(); - if ( tagName == QString( "dayofweek" ) ) - { - QDomText t = node.ownerDocument().createTextNode( iDateTimeSettings->switchDay() ); - e.replaceChild( t, e.firstChild() ); - } - else if( tagName == QString( "StandardTimeChangeMoment" ) ) - { - QDomText t = node.ownerDocument().createTextNode( iDateTimeSettings->STDDateTime().toString("ddMMyyyyhhmmss")); - e.replaceChild( t, e.firstChild() ); - } - else if( tagName == QString( "DaylightSaveTimeChangeMoment" ) ) - { - QDomText t = node.ownerDocument().createTextNode( iDateTimeSettings->DSTDateTime().toString("ddMMyyyyhhmmss")); - e.replaceChild( t, e.firstChild() ); + if (tagName == QString("dayofweek")) { + QDomText t = node.ownerDocument().createTextNode( + iDateTimeSettings->switchDay()); + e.replaceChild(t, e.firstChild()); + } else if (tagName == QString("StandardTimeChangeMoment")) { + QDomText t = + node.ownerDocument().createTextNode( + iDateTimeSettings->STDDateTime().toString( + "ddMMyyyyhhmmss")); + e.replaceChild(t, e.firstChild()); + } else if (tagName == QString("DaylightSaveTimeChangeMoment")) { + QDomText t = + node.ownerDocument().createTextNode( + iDateTimeSettings->DSTDateTime().toString( + "ddMMyyyyhhmmss")); + e.replaceChild(t, e.firstChild()); } } } -void Configuration::saveAdminPassword( const QDomNode &aXML ) -{ +void Configuration::saveAdminPassword(const QDomNode &aXML) { QDomElement e = aXML.toElement(); - e.setAttribute( "password", QString( adminPassword() ) ); + e.setAttribute("password", QString(adminPassword())); } - -Configuration* Configuration::readFromXML( const QString &aPath ) -{ +void Configuration::readFromXML(const QString &aPath) { QDomDocument doc; - QFile file( aPath ); + QFile file(aPath); - if ( !file.open( QIODevice::ReadOnly ) ) - { - return 0; + if (!file.open(QIODevice::ReadOnly)) { + return; } - if ( !doc.setContent( &file ) ) - { + if (!doc.setContent(&file)) { file.close(); - return 0; + return; } file.close(); QDomElement root = doc.documentElement(); // check if the file is the one we need - if ( root.tagName().toLower() != QString( "configuration" ) ) - { - return 0; + if (root.tagName().toLower() != QString("configuration")) { + return; } - Configuration* conf = new Configuration(); + iAdminPassword = /*Configuration::*/readAdminPassword(root); - conf->iAdminPassword = Configuration::readAdminPassword( root ); - - for ( QDomNode node = root.firstChild(); !node.isNull(); node = node.nextSibling() ) - { + for (QDomNode node = root.firstChild(); !node.isNull(); node + = node.nextSibling()) { QDomElement e = node.toElement(); QString tagName = e.tagName().toLower(); - if ( tagName == QString( "connection" ) ) - { - conf->iConnectionSettings = Configuration::readConnectionSettings( node ); - } - else if ( tagName == QString( "rooms" ) ) - { - conf->iRooms = Configuration::readRooms( node ); - } - else if ( tagName == QString( "language" ) ) - { - conf->iLanguageCode = Configuration::readLanguageCode( node ); - } - else if ( tagName == QString( "startup" ) ) - { - conf->iStartupSettings = Configuration::readStartupSettings( node ); - } - else if ( tagName == QString( "display" ) ) - { - conf->iDisplaySettings = Configuration::readDisplaySettings( node ); - } - else if ( tagName == QString( "daylight_saving_time" ) ) - { - conf->iDateTimeSettings = Configuration::readDateTimeSettings(node); + if (tagName == QString("connection")) { + iConnectionSettings = readConnectionSettings(node); + } else if (tagName == QString("rooms")) { + iRooms = readRooms(node); + } else if (tagName == QString("language")) { + iLanguageCode = readLanguageCode(node); + } else if (tagName == QString("startup")) { + iStartupSettings = readStartupSettings(node); + } else if (tagName == QString("display")) { + iDisplaySettings = readDisplaySettings(node); + } else if (tagName == QString("daylight_saving_time")) { + iDateTimeSettings = readDateTimeSettings(node); + } else if (tagName == QString("privacy")) { + readPrivacySettings(node); } } - - return conf; } -ConnectionSettings* Configuration::readConnectionSettings( const QDomNode &aXML ) -{ +ConnectionSettings* Configuration::readConnectionSettings(const QDomNode &aXML) { QString server, username, password; unsigned int interval = Configuration::sDefaultInterval; - for ( QDomNode node = aXML.firstChild(); !node.isNull(); node = node.nextSibling() ) - { + for (QDomNode node = aXML.firstChild(); !node.isNull(); node + = node.nextSibling()) { QDomElement e = node.toElement(); QString tagName = e.tagName().toLower(); - if ( tagName == QString( "serverurl" ) ) - { + if (tagName == QString("serverurl")) { server = e.text(); - } - else if ( tagName == QString( "username" ) ) - { + } else if (tagName == QString("username")) { username = e.text(); - } - else if ( tagName == QString( "password" ) ) - { + } else if (tagName == QString("password")) { password = e.text(); - } - else if ( tagName == QString( "refreshinterval" ) ) - { + } else if (tagName == QString("refreshinterval")) { bool success = false; - unsigned int intervalTMP = e.text().toUInt( &success ); - if ( success ) - { + unsigned int intervalTMP = e.text().toUInt(&success); + if (success) { interval = intervalTMP; } } } - return new ConnectionSettings( server, username, password, interval ); + return new ConnectionSettings(server, username, password, interval); } -QList Configuration::readRooms( const QDomNode &aXML ) -{ +QList Configuration::readRooms(const QDomNode &aXML) { QList rooms; - for ( QDomNode node = aXML.firstChild(); !node.isNull(); node = node.nextSibling() ) - { + for (QDomNode node = aXML.firstChild(); !node.isNull(); node + = node.nextSibling()) { QDomElement e = node.toElement(); QString tagName = e.tagName().toLower(); - if ( tagName == QString( "room" ) ) - { + if (tagName == QString("room")) { QString name, address; - for ( QDomNode roomNode = node.firstChild(); !roomNode.isNull(); roomNode = roomNode.nextSibling() ) - { + for (QDomNode roomNode = node.firstChild(); !roomNode.isNull(); roomNode + = roomNode.nextSibling()) { QDomElement roomElem = roomNode.toElement(); tagName = roomElem.tagName().toLower(); - if ( tagName == QString( "name" ) ) - { + if (tagName == QString("name")) { name = roomElem.text(); - } - else if ( tagName == QString( "address" ) ) - { + } else if (tagName == QString("address")) { address = roomElem.text(); } } - Room* room = new Room( name, address ); - QString defaultAttr = e.attribute( "default" ).toLower(); - if ( defaultAttr == QString( "true" ) ) - { - rooms.insert( 0, room ); - } - else - { - rooms.append( room ); + Room* room = new Room(name, address); + QString defaultAttr = e.attribute("default").toLower(); + if (defaultAttr == QString("true")) { + rooms.insert(0, room); + } else { + rooms.append(room); } } } @@ -485,217 +446,240 @@ QList Configuration::readRooms( const QDomNode &aXML ) return rooms; } -QString Configuration::readLanguageCode( const QDomNode &aXML ) -{ +QString Configuration::readLanguageCode(const QDomNode &aXML) { QDomElement e = aXML.toElement(); QString tagName = e.tagName().toLower(); - if ( e.hasAttribute( "code" ) ) - { - return e.attribute( "code" ); - } - else - { + if (e.hasAttribute("code")) { + return e.attribute("code"); + } else { // default language is English return "EN"; } } -StartupSettings * Configuration::readStartupSettings( const QDomNode &aXML ) -{ +StartupSettings * Configuration::readStartupSettings(const QDomNode &aXML) { QDomElement e = aXML.toElement(); bool isPowersavingEnabled = false; QTime turnOnAt, turnOffAt; - for ( QDomNode node = aXML.firstChild(); !node.isNull(); node = node.nextSibling() ) - { + for (QDomNode node = aXML.firstChild(); !node.isNull(); node + = node.nextSibling()) { e = node.toElement(); QString tagName = e.tagName().toLower(); - if ( tagName == QString( "powersaving" ) ) - { - if ( e.hasAttribute( "enabled" ) && - e.attribute( "enabled" ) == QString( "true" ) ) - { + if (tagName == QString("powersaving")) { + if (e.hasAttribute("enabled") && e.attribute("enabled") == QString( + "true")) { isPowersavingEnabled = true; } - if ( e.hasAttribute( "on" ) ) - { - QString on = e.attribute( "on" ); - turnOnAt = QTime::fromString( on, "hh:mm" ); + if (e.hasAttribute("on")) { + QString on = e.attribute("on"); + turnOnAt = QTime::fromString(on, "hh:mm"); } - if ( e.hasAttribute( "off" ) ) - { - QString off = e.attribute( "off" ); - turnOffAt = QTime::fromString( off, "hh:mm" ); + if (e.hasAttribute("off")) { + QString off = e.attribute("off"); + turnOffAt = QTime::fromString(off, "hh:mm"); } } } - return new StartupSettings( isPowersavingEnabled, turnOnAt, turnOffAt ); + return new StartupSettings(isPowersavingEnabled, turnOnAt, turnOffAt); } -DisplaySettings * Configuration::readDisplaySettings( const QDomNode &aXML ) -{ - DisplaySettings::DaysInSchedule daysInSchedule = DisplaySettings::WeekdaysInSchedule; +DisplaySettings * Configuration::readDisplaySettings(const QDomNode &aXML) { + DisplaySettings::DaysInSchedule daysInSchedule = + DisplaySettings::WeekdaysInSchedule; QTime dayStartsAt, dayEndsAt; DisplaySettings::DateFormat dateformat = DisplaySettings::ShortDateFormat; - DisplaySettings::TimeFormat timeformat = DisplaySettings::TwentyFourHoursTimeFormat; - int screensaver = 1; //! Default value for screensaver wait time + DisplaySettings::TimeFormat timeformat = + DisplaySettings::TwentyFourHoursTimeFormat; + int screensaver = 1; //! Default value for screensaver wait time - for ( QDomNode node = aXML.firstChild(); !node.isNull(); node = node.nextSibling() ) - { + for (QDomNode node = aXML.firstChild(); !node.isNull(); node + = node.nextSibling()) { QDomElement e = node.toElement(); QString tagName = e.tagName().toLower(); - if ( tagName == QString( "schedule" ) ) - { - for ( QDomNode scheduleNode = node.firstChild(); !scheduleNode.isNull(); scheduleNode = scheduleNode.nextSibling() ) - { + if (tagName == QString("schedule")) { + for (QDomNode scheduleNode = node.firstChild(); !scheduleNode.isNull(); scheduleNode + = scheduleNode.nextSibling()) { QDomElement scheduleElem = scheduleNode.toElement(); tagName = scheduleElem.tagName().toLower(); - if ( tagName == QString( "week" ) ) - { - if ( scheduleElem.hasAttribute( "days" ) ) - { + if (tagName == QString("week")) { + if (scheduleElem.hasAttribute("days")) { // default value is 5, only other supported possibility is 7 bool success = false; - unsigned int days = scheduleElem.attribute( "days" ).toUInt( &success ); - daysInSchedule = ( success && days == 7 ) ? DisplaySettings::WholeWeekInSchedule : DisplaySettings::WeekdaysInSchedule; + unsigned int days = + scheduleElem.attribute("days").toUInt(&success); + daysInSchedule + = (success && days == 7) ? DisplaySettings::WholeWeekInSchedule + : DisplaySettings::WeekdaysInSchedule; } - } - else if ( tagName == QString( "day" ) ) - { - if ( scheduleElem.hasAttribute( "startsat" ) ) - { - QString time = scheduleElem.attribute( "startsat" ); - dayStartsAt = QTime::fromString( time, "hh:mm" ); + } else if (tagName == QString("day")) { + if (scheduleElem.hasAttribute("startsat")) { + QString time = scheduleElem.attribute("startsat"); + dayStartsAt = QTime::fromString(time, "hh:mm"); } - if ( scheduleElem.hasAttribute( "endsat" ) ) - { - QString time = scheduleElem.attribute( "endsat" ); - dayEndsAt = QTime::fromString( time, "hh:mm" ); + if (scheduleElem.hasAttribute("endsat")) { + QString time = scheduleElem.attribute("endsat"); + dayEndsAt = QTime::fromString(time, "hh:mm"); } } - } // end of for - } // end of schedule - else if ( tagName == QString( "dateformat" ) ) - { + } // end of for + } // end of schedule + else if (tagName == QString("dateformat")) { //! Not able to display long format anyway at the moment /* - if ( e.text() == QObject::tr( "dddd d MMMM yyyy" ) ) - dateformat = DisplaySettings::LongDateFormat; - else - dateformat = DisplaySettings::ShortDateFormat; - */ + if ( e.text() == QObject::tr( "dddd d MMMM yyyy" ) ) + dateformat = DisplaySettings::LongDateFormat; + else + dateformat = DisplaySettings::ShortDateFormat; + */ dateformat = DisplaySettings::ShortDateFormat; - } - else if ( tagName == QString( "timeformat" ) ) - { + } else if (tagName == QString("timeformat")) { //! Not able to display "TwelveHoursTimeFormat" anyway at the moment /* - if ( e.text() == QObject::tr( "hh:mm ap" ) ) - timeformat = DisplaySettings::TwelveHoursTimeFormat; - else - timeformat = DisplaySettings::TwentyFourHoursTimeFormat; - */ + if ( e.text() == QObject::tr( "hh:mm ap" ) ) + timeformat = DisplaySettings::TwelveHoursTimeFormat; + else + timeformat = DisplaySettings::TwentyFourHoursTimeFormat; + */ timeformat = DisplaySettings::TwentyFourHoursTimeFormat; - } - else if ( tagName == QString( "screensaver" ) ) - { + } else if (tagName == QString("screensaver")) { bool success = false; - unsigned int screensaverTMP = e.text().toUInt( &success ); - if ( success ) - { + unsigned int screensaverTMP = e.text().toUInt(&success); + if (success) { screensaver = screensaverTMP; } } } - return new DisplaySettings( dateformat, timeformat, daysInSchedule, dayStartsAt, dayEndsAt, screensaver ); + return new DisplaySettings(dateformat, timeformat, daysInSchedule, + dayStartsAt, dayEndsAt, screensaver); } -DateTimeSettings * Configuration::readDateTimeSettings( const QDomNode &aXML ) -{ +DateTimeSettings * Configuration::readDateTimeSettings(const QDomNode &aXML) { // Set defaults.. - QDateTime standardTimeChangeMoment = QDateTime::fromString("05.10.2009 04:00:00", "dd'.'MM'.'yyyy' 'hh:mm:ss"); - QDateTime daylightSaveTimeChangeMoment = QDateTime::fromString("01.04.2010 03:00:00", "dd'.'MM'.'yyyy' 'hh:mm:ss"); + QDateTime standardTimeChangeMoment = QDateTime::fromString( + "05.10.2009 04:00:00", "dd'.'MM'.'yyyy' 'hh:mm:ss"); + QDateTime daylightSaveTimeChangeMoment = QDateTime::fromString( + "01.04.2010 03:00:00", "dd'.'MM'.'yyyy' 'hh:mm:ss"); DateTimeSettings::weekDay dayOfWeek = DateTimeSettings::Sunday; - - for ( QDomNode node = aXML.firstChild(); !node.isNull(); node = node.nextSibling() ) - { + + for (QDomNode node = aXML.firstChild(); !node.isNull(); node + = node.nextSibling()) { QDomElement e = node.toElement(); QString tagName = e.tagName().toLower(); - if ( tagName == QString( "dayofweek" ) ) - { - qDebug() << "Configuration::readDateTimeSettings: " +e.text(); - + if (tagName == QString("dayofweek")) { + qDebug() << "Configuration::readDateTimeSettings: " + e.text(); + bool success = false; - unsigned int weekDayTmp = e.text().toUInt( &success ); - if( success && weekDayTmp < 7 ) - { - dayOfWeek = (DateTimeSettings::weekDay)weekDayTmp; + unsigned int weekDayTmp = e.text().toUInt(&success); + if (success && weekDayTmp < 7) { + dayOfWeek = (DateTimeSettings::weekDay) weekDayTmp; } - } - else if( tagName == QString( "standardtimechangemoment" ) ) - { - standardTimeChangeMoment = QDateTime::fromString(e.text(), "dd'.'MM'.'yyyy' 'hh:mm:ss"); - qDebug() << "Configuration::readDateTimeSettings: " +standardTimeChangeMoment.toString("dd.MM.yyyy hh:mm:ss"); - } - else if( tagName == QString( "daylightsavetimechangemoment" ) ) - { - daylightSaveTimeChangeMoment = QDateTime::fromString(e.text(), "dd'.'MM'.'yyyy' 'hh:mm:ss"); - qDebug() << "Configuration::readDateTimeSettings: " +daylightSaveTimeChangeMoment.toString("dd.MM.yyyy hh:mm:ss"); + } else if (tagName == QString("standardtimechangemoment")) { + standardTimeChangeMoment = QDateTime::fromString(e.text(), + "dd'.'MM'.'yyyy' 'hh:mm:ss"); + qDebug() << "Configuration::readDateTimeSettings: " + + standardTimeChangeMoment.toString("dd.MM.yyyy hh:mm:ss"); + } else if (tagName == QString("daylightsavetimechangemoment")) { + daylightSaveTimeChangeMoment = QDateTime::fromString(e.text(), + "dd'.'MM'.'yyyy' 'hh:mm:ss"); + qDebug() << "Configuration::readDateTimeSettings: " + + daylightSaveTimeChangeMoment.toString( + "dd.MM.yyyy hh:mm:ss"); } } - - return new DateTimeSettings(standardTimeChangeMoment, daylightSaveTimeChangeMoment, dayOfWeek); + + return new DateTimeSettings(standardTimeChangeMoment, + daylightSaveTimeChangeMoment, dayOfWeek); } -QByteArray Configuration::readAdminPassword( const QDomNode &aXML ) -{ +QByteArray Configuration::readAdminPassword(const QDomNode &aXML) { QDomElement e = aXML.toElement(); QString tagName = e.tagName().toLower(); - if ( e.hasAttribute( "password" ) ) - { - QString pw = e.attribute( "password" ); + if (e.hasAttribute("password")) { + QString pw = e.attribute("password"); // Check if the password is default uncrypted "admin" - if ( pw == QString( "admin" ) ) - { + + int x = QString::compare(pw, "admin", Qt::CaseInsensitive); // x == 0 + + if (x == 0) { // uncrypted password needs to be encoded - QCryptographicHash *hash = new QCryptographicHash( QCryptographicHash::Md5 ); - hash->addData( pw.toUtf8() ); - pw = QString( hash->result() ); + QCryptographicHash *hash = new QCryptographicHash( + QCryptographicHash::Md5); + hash->addData(pw.toUtf8()); + pw = QString(hash->result()); delete hash; + return (pw.toAscii()).toHex(); } - return ( pw.toAscii() ).toHex(); - + + return (pw.toAscii()); + + } else { + return 0; + } +} + +void Configuration::setRooms(const QList aRooms) { + iRooms = aRooms; +} + +void Configuration::readPrivacySettings(const QDomNode &aXML) { + QString s = QString("show_confidential_meeting_details"); + + QDomElement e = aXML.firstChildElement(s); + + if (e.hasAttribute("enabled") && + e.attribute("enabled") == QString("true")) { + iShowConfidentialMeetingDetails = true; } else { - return 0; + iShowConfidentialMeetingDetails = false; } } -void Configuration::setRooms( const QList aRooms ) -{ - iRooms = aRooms; +void Configuration::savePrivacySettings(QDomNode &aXML) { + QString s = QString("show_confidential_meeting_details"); + + QDomElement e = aXML.firstChildElement(s); + + if (e.isNull()) { + e = aXML.ownerDocument().createElement(s); + aXML.appendChild(e); + } + + if( showConfidentialMeetingDetails() ) + e.setAttribute("enabled", "true"); + else + e.setAttribute("enabled", "false"); } -QString Configuration::hashPassword( const QString aPassword ) -{ - QCryptographicHash *hash = new QCryptographicHash( QCryptographicHash::Md5 ); - hash->addData( aPassword.toUtf8() ); +bool Configuration::setShowConfidentialMeetingDetails( + bool showconfidentialmeetingdetails) { + iShowConfidentialMeetingDetails = showconfidentialmeetingdetails; +} + +bool Configuration::showConfidentialMeetingDetails() { + return iShowConfidentialMeetingDetails; +} + +QString Configuration::hashPassword(const QString aPassword) { + QCryptographicHash *hash = new QCryptographicHash(QCryptographicHash::Md5); + hash->addData(aPassword.toUtf8()); QByteArray password = hash->result(); delete hash; - return QString( password ); + return QString(password); } diff --git a/src/Domain/Configuration/Configuration.h b/src/Domain/Configuration/Configuration.h index 5cd7e6d..9c5c253 100644 --- a/src/Domain/Configuration/Configuration.h +++ b/src/Domain/Configuration/Configuration.h @@ -5,6 +5,7 @@ #include #include #include +#include class ConnectionSettings; class StartupSettings; @@ -19,8 +20,7 @@ class DateTimeSettings; * file at initialization time. Since there is one appliation per device normally running, therefore * there is only one instance of this class, which is accessible by using a statis getter method. */ -class Configuration : public QObject -{ +class Configuration: public QObject { Q_OBJECT private: @@ -46,7 +46,47 @@ public: * Gets the connection settings. * \return Pointer to ConnectionSettings instance. */ - ConnectionSettings* connectionSettings(); + //ConnectionSettings* connectionSettings(); + /** + * Returns the current server URL + */ + QUrl getServerUrl(); + /** + * Returns the current username + */ + QString getUsername(); + /** + * Returns the current users password + */ + QString getPassword(); + /** + * Returns the refresh interval + */ + unsigned int getRefreshinterval(); + /** + * Sets the current server URL + */ + void setServerUrl(QUrl serverUrl); + /** + * Sets the current username + */ + void setUsername(QString username); + /** + * Sets the current users password + */ + void setPassword(QString password); + /** + * Sets the refresh interval + */ + void setRefreshinterval(unsigned int refreshinterval); + + //! Sets the confidential meeting details showing setting. + /*! + * Sets the confidential meeting details showing setting. + * \param confidential meeting details showing setting. + */ + bool setShowConfidentialMeetingDetails(bool showconfidentialmeetingdetails); + //! Gets the detault room. /*! * Gets the default meeting room. @@ -91,11 +131,21 @@ public: QByteArray adminPassword(); //! Sets room list. /*! - * Sets room list. + * Sets room list. * \param aRooms List of rooms */ void setRooms(const QList aRooms); + //! Gets the confidential meeting details showing setting. + /*! + * Gets the confidential meeting details showing setting. + * \return confidential meeting details showing setting. + */ + bool showConfidentialMeetingDetails(); + +signals: + void configurationChanged(); + public slots: //! Saves setting values to file. @@ -111,48 +161,48 @@ private: * \param aPath path and name of configuration file * \return Configuration object. */ - static Configuration* readFromXML(const QString &aPath); + void readFromXML(const QString &aPath); //! Static. Reads settings of connection from and XML node. /*! * Static. Reads settings of connection from an XML node. * \param aXml QDomNode containing connection parameters. * \return Pointer to ConnectionSettings object. */ - static ConnectionSettings* readConnectionSettings(const QDomNode &aXML); + ConnectionSettings* readConnectionSettings(const QDomNode &aXML); //! Static. Reads rooms from an XML node. /*! * Static. Reads rooms from an XML node. * \param aXml QDomNode containing meeting room parameters * \return List of meetingrooms. */ - static QList readRooms(const QDomNode &aXML); + QList readRooms(const QDomNode &aXML); //! Static. Reads language code from an XML node. /*! * Static. Reads rooms from an XML node. * \param aXml QDomNode containing language code * \return Language code. */ - static QString readLanguageCode(const QDomNode &aXML); + QString readLanguageCode(const QDomNode &aXML); //! Static. Reads settings of startup from an XML node. /*! * Static. Reads settings of startup from an XML node. * \param aXml QDomNode containing startup parameters * \return Pointer to the read StartupSettings object. */ - static StartupSettings* readStartupSettings(const QDomNode &aXML); + StartupSettings* readStartupSettings(const QDomNode &aXML); /*! * Static function to load and store display settings from xml node. * \param aXml QDomNode containing display parameters * \return Pointer to the read DisplaySettings object. */ - static DisplaySettings* readDisplaySettings(const QDomNode &aXML); + DisplaySettings* readDisplaySettings(const QDomNode &aXML); //! Static. Reads the date/time settings from an XML node. /*! * Static. Reads the date/time settings from an XML node. * \param aXml QDomNode containing the date/time settings * \return The date/time settings. */ - static DateTimeSettings* readDateTimeSettings(const QDomNode &aXML); + DateTimeSettings* readDateTimeSettings(const QDomNode &aXML); //! Static. Reads adminstrator's password from an XML node. /*! @@ -160,8 +210,16 @@ private: * \param aXml QDomNode containing admin password * \return Admin password. */ - static QByteArray readAdminPassword(const QDomNode &aXML); + QByteArray readAdminPassword(const QDomNode &aXML); + //! Static. Reads confidential meeting details setting from an XML node. + /*! + * Static. Reads confidential meeting details setting from an XML node. + * \param aXml QDomNode containing confidential meeting details setting + * \return Confidential meeting details setting. + */ + void readPrivacySettings(const QDomNode &aXML); + //! Saves connection data to the document. /*! * Reads data from iConnectionSettings and saves it to the aXML document. @@ -206,6 +264,13 @@ private: */ void saveAdminPassword(const QDomNode &aXML); + //! Saves confidential meeting details setting to the document. + /*! + * Reads data from iShowConfidentialMeetingDetails and saves it to the aXML document. + * \param aXml QDomNode confidential meeting details setting + */ + void savePrivacySettings(QDomNode &aXML); + //! Hash password with md5 method. /*! * Hash password with md5 method. @@ -236,6 +301,7 @@ private: //! Stores language code QString iLanguageCode; + bool iShowConfidentialMeetingDetails; }; #endif /*CONFIGURATION_H_*/ diff --git a/src/IO/Communication/Communication.cpp b/src/IO/Communication/Communication.cpp index 5c3b924..04a26e2 100644 --- a/src/IO/Communication/Communication.cpp +++ b/src/IO/Communication/Communication.cpp @@ -1,14 +1,16 @@ #include "Communication.h" #include "ConnectionSettings.h" #include +#include "Configuration.h" +#include -Communication::Communication( const ConnectionSettings &aConnection ) : + +Communication::Communication() : iCurrentRequest(0), iAuthFailCount(0) { - iConnectionSettings = new ConnectionSettings( aConnection ); + iHttp = new QHttp(Configuration::instance()->getServerUrl().toString()/*Configuration::instance()->getServerUrl().toString()*/, QHttp::ConnectionModeHttps ); - iHttp = new QHttp( iConnectionSettings->serverUrl().toString(), QHttp::ConnectionModeHttps ); connect( iHttp, SIGNAL( readyRead( const QHttpResponseHeader& ) ), @@ -39,11 +41,12 @@ Communication::Communication( const ConnectionSettings &aConnection ) : iHttp, SLOT( ignoreSslErrors() )/*this, SLOT( notifySsl( const QList& ) )*/ ); + connect(Configuration::instance(),SIGNAL(configrationChanged()), SLOT(configurationChanged())); } Communication::~Communication() { - delete iConnectionSettings; + //delete iConnectionSettings; delete iHttp; QList responses = iResponses.values(); while(!responses.isEmpty()) @@ -86,8 +89,9 @@ void Communication::handleResults( int aId, bool /*aError*/ ) void Communication::handleAuthentication( const QString& /*aHost*/, quint16 /*aPort*/, QAuthenticator* aAuthenticator ) { - aAuthenticator->setPassword( iConnectionSettings->password() ); - aAuthenticator->setUser( iConnectionSettings->username() ); + + aAuthenticator->setPassword( Configuration::instance()->getPassword() ); + aAuthenticator->setUser( Configuration::instance()->getUsername() ); iAuthFailCount++; if( iAuthFailCount > 1 ) { @@ -99,9 +103,12 @@ int Communication::request( const QString &aCommand, const QByteArray &aContent { if( iAuthFailCount > 1 ) return 0; - + + iHttp->setHost(Configuration::instance()->getServerUrl().toString(),QHttp::ConnectionModeHttps); QHttpRequestHeader header( QString( "POST" ), QString( "/ews/exchange.asmx" ) ); - header.setValue( "Host", iConnectionSettings->serverUrl().toString() ); + + header.setValue( "Host",Configuration::instance()->getServerUrl().toString() ); + QString command = aCommand; header.setContentType( command ); @@ -131,3 +138,8 @@ void Communication::handleReadProgress( int aDone, int aTotal ) { emit readProgress( iCurrentRequest, aDone, aTotal ); } + +void Communication::configurationChanged() +{ + iHttp->setHost(Configuration::instance()->getServerUrl().toString(),QHttp::ConnectionModeHttps ); +} diff --git a/src/IO/Communication/Communication.h b/src/IO/Communication/Communication.h index 41dedb5..07c6601 100644 --- a/src/IO/Communication/Communication.h +++ b/src/IO/Communication/Communication.h @@ -23,7 +23,7 @@ public: * \param aConnection Reference to ConnectionSettings which holds * the server to connect to and authentication information. */ - Communication( const ConnectionSettings &aConnection ); + Communication(/* const ConnectionSettings &aConnection*/ ); virtual ~Communication(); //! Returns the response of a request identified by aRequestId. @@ -40,6 +40,8 @@ public: */ int request( const QString &aCommand, const QByteArray &aContent ); + + signals: //! Emitted when a request ongoing. Reports the bytes read from the server. /*! @@ -71,12 +73,15 @@ protected slots: void handleRequestStarted( int aRequestId ); //! Connected to QHttp::dataReadProgress void handleReadProgress( int aDone, int aTotal ); + //!Called when the settings are changed by the user + void configurationChanged(); + private: /*! * Instance of Connection settings of the communication */ - ConnectionSettings *iConnectionSettings; + //ConnectionSettings *iConnectionSettings; /*! * Instance of QHttp */ diff --git a/src/IO/Communication/CommunicationManager.cpp b/src/IO/Communication/CommunicationManager.cpp index 2f340a0..0880920 100644 --- a/src/IO/Communication/CommunicationManager.cpp +++ b/src/IO/Communication/CommunicationManager.cpp @@ -6,14 +6,17 @@ #include #include #include +#include "../../Domain/Configuration/Configuration.h" static const int ERROR_BASE=100; -CommunicationManager::CommunicationManager( const ConnectionSettings &aConnection ) + +CommunicationManager::CommunicationManager() { - iConnectionSettings = new ConnectionSettings( aConnection ); + iModifyingCommunication = NULL; - iFetchingCommunication = new Communication( aConnection ); + + iFetchingCommunication = new Communication(); if ( iFetchingCommunication ) { @@ -28,11 +31,12 @@ CommunicationManager::CommunicationManager( const ConnectionSettings &aConnectio SLOT( requestFinished( int, int ) ) ); } + } CommunicationManager::~CommunicationManager() { - delete iConnectionSettings; + //delete iConnectionSettings; delete iModifyingCommunication; delete iFetchingCommunication; while ( !iMeetings.isEmpty() ) @@ -150,6 +154,9 @@ void CommunicationManager::requestFinished( int aRequestId, int aError ) err = 10; delete rd; emit error( ERROR_BASE+(int)err, CommunicationManager::FetchingCommunication ); + while ( !iMeetings.isEmpty() ) + delete iMeetings.takeFirst(); + emit meetingsFetched( iMeetings ); return; } @@ -164,9 +171,17 @@ void CommunicationManager::requestFinished( int aRequestId, int aError ) int err = msg.getMeetingsFromResponse( iMeetings, *(rd->room) ); if( err ) + { emit error( ERROR_BASE+8, CommunicationManager::FetchingCommunication ); + while ( !iMeetings.isEmpty() ) + delete iMeetings.takeFirst(); + emit meetingsFetched( iMeetings ); + } else + { + qDebug("*** COMMUNICATIONMANAGER ::: Meetings fetched!"); emit meetingsFetched( iMeetings ); + } break; } case ConvertId: @@ -185,7 +200,13 @@ void CommunicationManager::requestFinished( int aRequestId, int aError ) ResMsgGetCalendarItem msg( *response ); int err = msg.getMeetingDetailsFromResponse( *(rd->meeting) ); if( err ) + { emit error( ERROR_BASE+9, CommunicationManager::FetchingCommunication ); + while ( !iMeetings.isEmpty() ) + delete iMeetings.takeFirst(); + emit meetingsFetched( iMeetings ); + } + else emit meetingDetailsFetched( *(rd->meeting) ); break; @@ -235,3 +256,4 @@ const CommunicationManager::RequestData* CommunicationManager::findRequest( Requ } return NULL; } + diff --git a/src/IO/Communication/CommunicationManager.h b/src/IO/Communication/CommunicationManager.h index 4dfd00b..abfce60 100644 --- a/src/IO/Communication/CommunicationManager.h +++ b/src/IO/Communication/CommunicationManager.h @@ -36,7 +36,7 @@ public: /*! * \param aConnection Reference to the fetching ConnectionSettings. */ - CommunicationManager( const ConnectionSettings &aConnection ); + CommunicationManager( /*const ConnectionSettings &aConnection*/ ); virtual ~CommunicationManager(); //! Starts fetching meetings. Meetings are returned by the meetingsFetched signal. /*! @@ -157,7 +157,7 @@ protected: private: //! Instance of Connection settings of the fetching communication - ConnectionSettings *iConnectionSettings; + //ConnectionSettings *iConnectionSettings; //! Instance of the fetching communication Communication* iFetchingCommunication; //! Instance of the modifying communication diff --git a/src/UserInterface/Components/BorderedBarWidget.cpp b/src/UserInterface/Components/BorderedBarWidget.cpp new file mode 100644 index 0000000..0b92511 --- /dev/null +++ b/src/UserInterface/Components/BorderedBarWidget.cpp @@ -0,0 +1,171 @@ +#include +#include "BorderedBarWidget.h" + +BorderedBarWidget::BorderedBarWidget( QWidget *aParent ) : + QWidget( aParent ){ + iCenterLabel = new QLabel(this); + iCenterLabel->setAlignment( Qt::AlignCenter ); + iLeftLabel = new QLabel(this); + iLeftLabel->setAlignment( Qt::AlignLeading | Qt::AlignVCenter); + iRightLabel = new QLabel(this); + iRightLabel->setAlignment( Qt::AlignTrailing | Qt::AlignVCenter); +} + +BorderedBarWidget::~BorderedBarWidget() { + delete iCenterLabel; + delete iLeftLabel; + delete iRightLabel; +} + +QColor BorderedBarWidget::backgroundColor() +{ + return iPalette.color( QPalette::Window );; +} + +QColor BorderedBarWidget::faceColor() +{ + return iPalette.color( QPalette::WindowText );; +} + +int BorderedBarWidget::borderWidth() +{ + return iBorderWidth; +} + +QString BorderedBarWidget::text( TextPosition aPos ) +{ + if ( aPos == CenterAlign ) + return iCenterLabel->text(); + else if ( aPos == LeftAlign ) + return iLeftLabel->text(); + else if ( aPos == RightAlign ) + return iRightLabel->text(); + return ""; +} + +void BorderedBarWidget::setBackgroundColor( QColor aColor ) +{ + iPalette.setColor( QPalette::Window, aColor ); + iCenterLabel->setPalette( iPalette ); + iLeftLabel->setPalette( iPalette ); + iRightLabel->setPalette( iPalette ); +} + +void BorderedBarWidget::setFaceColor( QColor aColor ) +{ + iPalette.setColor( QPalette::WindowText, aColor ); + iCenterLabel->setPalette( iPalette ); + iLeftLabel->setPalette( iPalette ); + iRightLabel->setPalette( iPalette ); +} + +void BorderedBarWidget::setBorderWidth( int aWidth ) +{ + iBorderWidth = aWidth; + iRightLabel->setMargin( 2*iBorderWidth ); + iLeftLabel->setMargin( 2*iBorderWidth ); +} + +void BorderedBarWidget::setText( QString aText, TextPosition aPos ) +{ + if ( aPos == CenterAlign ) + iCenterLabel->setText( aText ); + else if ( aPos == LeftAlign ) + iLeftLabel->setText( aText ); + else if ( aPos == RightAlign ) + iRightLabel->setText( aText ); +} + +void BorderedBarWidget::setPixmap( QPixmap aPixmap, TextPosition aPos ) +{ + if ( aPos == CenterAlign ) + iCenterLabel->setPixmap( aPixmap ); + else if ( aPos == LeftAlign ) + iLeftLabel->setPixmap( aPixmap ); + else if ( aPos == RightAlign ) + iRightLabel->setPixmap( aPixmap ); +} + +void BorderedBarWidget::paintEvent(QPaintEvent *) +{ + drawBorder(); + iCenterLabel->setGeometry( rect() ); + iLeftLabel->setGeometry( rect() ); + iRightLabel->setGeometry( rect() ); +} + +void BorderedBarWidget::mousePressEvent( QMouseEvent * ) +{ + emit ( clicked() ); +} + + +void BorderedBarWidget::drawCorner( QPainter &aPainter, QPoint &aCenter ) +{ + QRadialGradient radialGrad(QPointF(aCenter), iBorderWidth); + radialGrad.setColorAt(0, iPalette.color( QPalette::WindowText)); + radialGrad.setColorAt(1, iPalette.color( QPalette::Window)); + aPainter.setBrush(radialGrad); + aPainter.drawEllipse(QPoint(aCenter), iBorderWidth, iBorderWidth); +} + +void BorderedBarWidget::drawSide( QPainter &aPainter, QPoint aStartPoint, QPoint aEndPoint ) +{ + QPoint d = aEndPoint - aStartPoint; + QPoint gradEnd = aStartPoint; + if ( abs( d.x() ) < abs( d.y() ) ) + gradEnd.setX( aEndPoint.x()+1 ); + else + gradEnd.setY( aEndPoint.y()+1 ); + + QLinearGradient linearGradTop(aStartPoint, gradEnd); + linearGradTop.setColorAt(0, iPalette.color( QPalette::Window)); + linearGradTop.setColorAt(1, iPalette.color( QPalette::WindowText)); + aPainter.setBrush(linearGradTop); + aPainter.drawRect( QRect(aStartPoint,aEndPoint) ); +} + +void BorderedBarWidget::drawBorder() +{ + QPainter painter(this); + painter.setPen(Qt::NoPen); + painter.setRenderHint(QPainter::Antialiasing, true); + + /*top left corner*/ + QPoint center(iBorderWidth,iBorderWidth); + drawCorner( painter, center ); + + /*top right corner*/ + center.setX( this->rect().right()-iBorderWidth ); + center.setY( iBorderWidth ); + drawCorner( painter, center ); + + /*bottom left corner*/ + center.setX( iBorderWidth ); + center.setY( this->rect().bottom()-iBorderWidth ); + drawCorner( painter, center ); + + /*bottom right corner*/ + center.setX( this->rect().right()-iBorderWidth ); + center.setY( this->rect().bottom()-iBorderWidth ); + drawCorner( painter, center ); + + /*top*/ + drawSide( painter, QPoint(iBorderWidth,0), QPoint(this->rect().right()-(iBorderWidth+1),(iBorderWidth-1)) ); + + /*right*/ + drawSide( painter, QPoint(this->rect().right(),this->rect().bottom()-iBorderWidth), QPoint(this->rect().right()-(iBorderWidth+1),iBorderWidth-1) ); + + /*bottom*/ + drawSide( painter, QPoint(this->rect().right()-iBorderWidth, this->rect().bottom()), QPoint((iBorderWidth-1),this->rect().bottom()-(iBorderWidth+1)) ); + + /*left*/ + drawSide( painter, QPoint(0,iBorderWidth), QPoint((iBorderWidth-1), this->rect().bottom()-(iBorderWidth+1)) ); + + /*inside*/ + QBrush brush( iPalette.color( QPalette::Window ) ); + painter.setBrush(brush); + QRect inside(iBorderWidth,iBorderWidth,this->rect().right()-2*iBorderWidth,this->rect().bottom()-2*iBorderWidth); + painter.drawRoundRect(inside,iBorderWidth,iBorderWidth); + +} diff --git a/src/UserInterface/Components/BorderedBarWidget.h b/src/UserInterface/Components/BorderedBarWidget.h new file mode 100644 index 0000000..c3e56bf --- /dev/null +++ b/src/UserInterface/Components/BorderedBarWidget.h @@ -0,0 +1,137 @@ +#ifndef BORDEREDBARWIDGET_H_ +#define BORDEREDBARWIDGET_H_ + +#include +#include + +//! Userinterface class. Displays text or images with a gradient border. +/*! + * Userinterface class. Displays text or images with a gradient border. Inherits QWidget and + * diplays content in QLabel. + */ +class BorderedBarWidget : public QWidget { + + Q_OBJECT; + +public: + enum TextPosition + { + LeftAlign, /*!< Indicates that the item inserted should be aligned to the left. */ + CenterAlign, /*!< Indicates that the item inserted should be aligned to the center. */ + RightAlign /*!< Indicates that the item inserted should be aligned to the right. */ + }; + +public: + //! Constructor. + /*! + * Constructor to initialize a BorderedBarWidget instance. + * \param aParent Parent widget. Optional. + */ + BorderedBarWidget( QWidget *aParent = 0 ); + //! Destructor. + virtual ~BorderedBarWidget(); + + //! Returns background color. + /*! + * \return The background color of the widget. + */ + QColor backgroundColor(); + //! Returns face color. + /*! + * \return The text and border color. + */ + QColor faceColor(); + //! Returns border width. + /*! + * \return The border width. + */ + int borderWidth(); + //! Returns text. + /*! + * \param aPos Text position. Optional. + * \return The text at a position. + */ + QString text( TextPosition aPos = CenterAlign ); + + //! Sets background color. + /*! + * Sets the background color of the widget. + * \param aColor The new color. + */ + void setBackgroundColor( QColor aColor); + //! Sets face color. + /*! + * Sets the text and border color of the widget. + * \param aColor The new color. + */ + void setFaceColor( QColor aColor ); + //! Sets border width. + /*! + * Sets the width of the border. + * \param aWidth The new width in pixels. + */ + void setBorderWidth( int aWidth ); + //! Sets text. + /*! + * Sets text to a certain position in a bar. + * \param aText The new text. + * \param aPos The position of the text. Optional. + */ + void setText( QString aText, TextPosition aPos = CenterAlign ); + //! Sets pixmap. + /*! + * Sets pixmap to a certain position in a bar. + * \param aPixmap The new pixmap. + * \param aPos The position of the pixmap. Optional. + */ + void setPixmap( QPixmap aPixmap, TextPosition aPos = RightAlign ); + +signals: + + void clicked(); + +private: + //! Draws the borders. + /*! + * Handles drawing of the borders. + */ + void drawBorder(); + //! Draws corner. + /*! + * Handles drawing of a corner. + * \param aPainter Painter used for drawing. + * \param aCenter Inner corner of the widget. + */ + void drawCorner( QPainter &aPainter, QPoint &aCenter ); + //! Draws side. + /*! + * Handles drawing of a single side. + * \param aPainter Painter used for drawing. + * \param aStartPoint Start point of drawing area. + * \param aEndPoint End point of drawing area. + */ + void drawSide( QPainter &aPainter, QPoint aStartPoint, QPoint aEndPoint ); + +protected: + //! Handles drawing of the widget. + /*! + * Handles drawing of the widget. + */ + virtual void paintEvent(QPaintEvent *); + + void mousePressEvent( QMouseEvent * ); + +private: + //! Palette for storing colors. + QPalette iPalette; + //! Border width. + int iBorderWidth; + //! Label for left aligned content. + QLabel *iLeftLabel; + //! Label for center aligned content. + QLabel *iCenterLabel; + //! Label for right aligned content. + QLabel *iRightLabel; +}; + +#endif /* BORDEREDBARWIDGET_H_ */ diff --git a/src/UserInterface/Components/MeetingRoomCombo.cpp b/src/UserInterface/Components/MeetingRoomCombo.cpp index fad0493..defd64f 100644 --- a/src/UserInterface/Components/MeetingRoomCombo.cpp +++ b/src/UserInterface/Components/MeetingRoomCombo.cpp @@ -13,8 +13,9 @@ MeetingRoomCombo::MeetingRoomCombo( QList aRooms, QWidget *aParent ) : qSort( iRooms.begin(), iRooms.end(), Room::caseInsensitiveLessThan ); QFont regularTextFont; - regularTextFont.setBold( false ); - regularTextFont.setPointSize( 12 ); + regularTextFont.setStyleHint( QFont::Helvetica ); + regularTextFont.setBold( true ); + regularTextFont.setPixelSize( 18 ); iRoomCombo = new QComboBox( this ); for ( int i = 0; i < iRooms.count(); i++ ) @@ -22,6 +23,7 @@ MeetingRoomCombo::MeetingRoomCombo( QList aRooms, QWidget *aParent ) : iRoomCombo->addItem( iRooms.at( i )->name() ); } iRoomCombo->setFont( regularTextFont ); + iRoomCombo->setFixedHeight( 46 ); connect( iRoomCombo, SIGNAL( currentIndexChanged( int ) ), this, SLOT( setCurrentIndex( int ) ) ); connect( iRoomCombo, SIGNAL( currentIndexChanged( const QString & ) ), this, SLOT( setCurrentRoomBy( const QString & ) ) ); diff --git a/src/UserInterface/Components/ScheduleWidget.cpp b/src/UserInterface/Components/ScheduleWidget.cpp index 0d68da6..181593e 100644 --- a/src/UserInterface/Components/ScheduleWidget.cpp +++ b/src/UserInterface/Components/ScheduleWidget.cpp @@ -9,11 +9,14 @@ #include #include "Meeting.h" -const QColor ScheduleWidget::sFreeBackground = QColor( 192, 238, 189 ); +const QColor ScheduleWidget::sFreeBackground = QColor( Qt::white ); const QColor ScheduleWidget::sBusyBackground = QColor( 238, 147, 17 ); +const QColor ScheduleWidget::sBusyBackgroundStart = QColor( 254, 193, 104 ); +const QColor ScheduleWidget::sCurrentBackgroundStart = QColor( 237, 124, 125 ); +const QColor ScheduleWidget::sCurrentBackground = QColor( 161, 1, 1 ); const QColor ScheduleWidget::sHeaderBackground = QColor( Qt::white ); const QColor ScheduleWidget::sDayHighlightColor = QColor( 255, 235, 160 ); -const QColor ScheduleWidget::sTimeHighlightColor = QColor( Qt::blue ); +const QColor ScheduleWidget::sTimeHighlightColor = QColor( Qt::black ); const QColor ScheduleWidget::sMainGridColor = QColor( 140, 140, 140 ); const QColor ScheduleWidget::sHalfGridColor = QColor( 195, 195, 195 ); const QColor ScheduleWidget::sFrameColor = QColor( Qt::black ); @@ -94,8 +97,6 @@ void ScheduleTableWidget::paintEvent( QPaintEvent* aEvent ) } // draw meetings - QBrush brush( ScheduleWidget::sBusyBackground ); - painter.setBrush( brush ); painter.setRenderHint( QPainter::Antialiasing ); painter.setPen( ScheduleWidget::sFrameColor ); populateMeetingList(); @@ -104,6 +105,21 @@ void ScheduleTableWidget::paintEvent( QPaintEvent* aEvent ) { for ( int i = 0; i < iMeetingsByDay[day].size(); ++i ) { + QLinearGradient linearGrad( QPoint(iMeetingsByDay[day][i].rect.x(),iMeetingsByDay[day][i].rect.y()) , QPoint(iMeetingsByDay[day][i].rect.x(),iMeetingsByDay[day][i].rect.bottom()) ); + // draw meeting with red if it is ongoing + if ( iMeetingsByDay[day][i].meeting->startsAt() <= QDateTime::currentDateTime() && + iMeetingsByDay[day][i].meeting->endsAt() >= QDateTime::currentDateTime() ) + { + linearGrad.setColorAt(0, ScheduleWidget::sCurrentBackgroundStart); + linearGrad.setColorAt(1, ScheduleWidget::sCurrentBackground); + } + else + { + linearGrad.setColorAt(0, ScheduleWidget::sBusyBackgroundStart); + linearGrad.setColorAt(1, ScheduleWidget::sBusyBackground); + } + painter.setBrush(linearGrad); + painter.drawRoundRect( iMeetingsByDay[day][i].rect, 20, 20 ); } } @@ -295,7 +311,9 @@ ScheduleWidget::ScheduleWidget( QDateTime aCurrentDateTime, DisplaySettings *aSe iScheduleTable->setShowGrid( false ); QFont font; - font.setPointSize( 10 ); + font.setStyleHint( QFont::Helvetica ); + font.setBold( true ); + font.setPixelSize( 20 ); // add empty item to top-left corner, this will be updated in refresh() QTableWidgetItem *weekItem = new QTableWidgetItem(); @@ -346,7 +364,11 @@ ScheduleWidget::ScheduleWidget( QDateTime aCurrentDateTime, DisplaySettings *aSe ScheduleWidget::~ScheduleWidget() { - delete iScheduleTable; + if ( iScheduleTable ) + { + delete iScheduleTable; + iScheduleTable = 0; + } } QDate ScheduleWidget::beginningOfShownWeek() @@ -366,7 +388,7 @@ void ScheduleWidget::refresh() item->setText( tr( "Wk %1" ).arg( iShownDate.weekNumber() ) ); continue; } - item->setText( iShownDate.addDays( i - 1 ).toString( tr( "ddd d MMM" ) ) ); + item->setText( iShownDate.addDays( i - 1 ).toString( tr( "ddd d/M" ) ) ); if ( iCurrentDateTime.date() == iShownDate.addDays( i - 1 ) ) { @@ -446,10 +468,10 @@ int ScheduleWidget::weekLengthAsDays() void ScheduleWidget::resizeEvent( QResizeEvent* /* aEvent */ ) { QRect rect = iScheduleTable->contentsRect(); - int rowHeight = ( int )( rect.height() / ( float )iScheduleTable->rowCount() ); - int headerRowHeight = rowHeight; - int columnWidth = ( int )( rect.width() / ( iScheduleTable->columnCount() - 0.5f ) ); - int headerColumnWidth = columnWidth / 2; + int rowHeight = ( int )( rect.height() / ( float )( iScheduleTable->rowCount() + 1 ) ); + int headerRowHeight = ( int )rowHeight*2; + int headerColumnWidth = rect.width() * 0.15f; + int columnWidth = ( rect.width() - headerColumnWidth ) / ( iScheduleTable->columnCount() - 1 ); iScheduleTable->setRowHeight( 0, headerRowHeight ); for ( int i = 1; i < iScheduleTable->rowCount(); ++i ) @@ -466,6 +488,7 @@ void ScheduleWidget::resizeEvent( QResizeEvent* /* aEvent */ ) // resize table so that frame size matches exactly int leftMargin = 0, topMargin = 0, rightMargin = 0, bottomMargin = 0; iScheduleTable->getContentsMargins( &leftMargin, &topMargin, &rightMargin, &bottomMargin ); - iScheduleTable->resize( columnWidth * iScheduleTable->columnCount() - headerColumnWidth + leftMargin + rightMargin, - rowHeight * iScheduleTable->rowCount() + topMargin + bottomMargin ); + iScheduleTable->resize( columnWidth * ( iScheduleTable->columnCount() - 1 ) + + headerColumnWidth + leftMargin + rightMargin, + rowHeight * ( iScheduleTable->rowCount() + 1 ) + topMargin + bottomMargin ); } diff --git a/src/UserInterface/Components/ScheduleWidget.h b/src/UserInterface/Components/ScheduleWidget.h index 47b8e3f..27c7f11 100644 --- a/src/UserInterface/Components/ScheduleWidget.h +++ b/src/UserInterface/Components/ScheduleWidget.h @@ -261,8 +261,17 @@ private: static const QColor sFreeBackground; //! Color for a busy cell. + static const QColor sBusyBackgroundStart; + + //! Color for a busy cell. static const QColor sBusyBackground; + //! Color for a busy cell. + static const QColor sCurrentBackgroundStart; + + //! Color for a busy cell. + static const QColor sCurrentBackground; + //! Color for headers. static const QColor sHeaderBackground; diff --git a/src/UserInterface/Views/MeetingInfoDialog.cpp b/src/UserInterface/Views/MeetingInfoDialog.cpp index 9a08de9..760eca9 100644 --- a/src/UserInterface/Views/MeetingInfoDialog.cpp +++ b/src/UserInterface/Views/MeetingInfoDialog.cpp @@ -1,7 +1,10 @@ #include "MeetingInfoDialog.h" + #include "ToolBox.h" #include "Meeting.h" #include "Room.h" +#include "Configuration.h" + #include #include #include @@ -43,11 +46,30 @@ void MeetingInfoDialog::createDialogView(Meeting *aMeeting) boldFont.setBold( true ); QLabel *subjectLabel = ToolBox::createLabel( tr( "Subject:" ), boldFont ); - QLabel *subjectContent = ToolBox::createLabel( aMeeting->subject(), normalFont ); + QLabel *subjectContent = new QLabel(); + subjectContent->setFont( normalFont ); QLabel *descriptionLabel = ToolBox::createLabel( tr( "Description:" ), boldFont ); QTextEdit *descriptionContent = new QTextEdit( "" ); - descriptionContent->setHtml( aMeeting->description() ); + + if( Configuration::instance()->showConfidentialMeetingDetails() ) + { + subjectContent->setText( aMeeting->subject() ); + descriptionContent->setHtml( aMeeting->description() ); + } + + if( subjectContent->text().isEmpty() ) + { + subjectContent->setText( tr( "Room reserved", "Meeting Info Subject" ) ); // default subject text + } + + qDebug() << "############ Desc: " << descriptionContent->toPlainText().trimmed(); + + if( descriptionContent->toPlainText().trimmed().isEmpty() ) + { + descriptionContent->setPlainText( tr( "Room reserved", "Meeting Info Description" ) ); // default description text + } + descriptionContent->setReadOnly( true ); descriptionContent->setFont( normalFont ); diff --git a/src/UserInterface/Views/RoomStatusIndicatorWidget.cpp b/src/UserInterface/Views/RoomStatusIndicatorWidget.cpp index ebe2a90..2ee240e 100644 --- a/src/UserInterface/Views/RoomStatusIndicatorWidget.cpp +++ b/src/UserInterface/Views/RoomStatusIndicatorWidget.cpp @@ -3,7 +3,8 @@ #include #include #include -#include "DigitalTimeDisplayWidget.h" +#include "BorderedBarWidget.h" + #include "ToolBox.h" #include @@ -15,68 +16,78 @@ QTime RoomStatusIndicatorWidget::endOfTheDay = QTime( 23, 59, 0, 0); RoomStatusIndicatorWidget::RoomStatusIndicatorWidget(Room *aDefaultRoom, Room::Status aStatus, QTime aUntil, QString aTimeFormat, QWidget *aParent) : ViewBase(ViewBase::ObservedView, aParent), iTimeFormat(aTimeFormat) { - QFont importantTextFont; - //importantTextFont.setBold( true ); - importantTextFont.setPointSize( 20); + QFont clockFont; + clockFont.setStyleHint( QFont::Helvetica ); + clockFont.setBold( true ); + clockFont.setPixelSize( 36 ); + + QFont textFont; + textFont.setStyleHint( QFont::Helvetica ); + textFont.setBold( true ); + textFont.setPixelSize( 48 ); - QFont regularTextFont; - //regularTextFont.setBold( true ); - regularTextFont.setPointSize( 12); + QFont statusBarFont; + statusBarFont.setStyleHint( QFont::Helvetica ); + statusBarFont.setPixelSize( 18 ); // display for current time // Note: the time display receives current time info from Engine::clock() - iTimeDisplay = new DigitalTimeDisplayWidget( QTime::currentTime(), iTimeFormat, this ); - iTimeDisplay->setFrameVisible( false); - iTimeDisplay->setSize( 250, 120); + iTimeDisplay = new BorderedBarWidget( this ); + iTimeDisplay->setFaceColor( Qt::darkGray ); + iTimeDisplay->setBackgroundColor( Qt::white ); + iTimeDisplay->setBorderWidth( 6 ); + iTimeDisplay->setFixedWidth( 170 ); + iTimeDisplay->setFixedHeight( 50 ); + iTimeDisplay->setFont( clockFont ); + + iStatusBar = new BorderedBarWidget( this ); + iStatusBar->setFaceColor( Qt::darkGray ); + iStatusBar->setBackgroundColor( Qt::white ); + iStatusBar->setBorderWidth( 4 ); + iStatusBar->setFont(statusBarFont); + iStatusBar->setFixedHeight( 36 ); + iStatusBar->setText( tr("Disconnected"), BorderedBarWidget::LeftAlign ); // Pegasus iDefaultRoomLabel - = ToolBox::createLabel(aDefaultRoom->name(), importantTextFont); - iDefaultRoomLabel->setAlignment(Qt::AlignHCenter); - iDefaultRoomLabel->setHidden( true); + = ToolBox::createLabel(aDefaultRoom->name(), textFont); + iDefaultRoomLabel->setAlignment( Qt::AlignHCenter ); + iDefaultRoomLabel->setHidden( true ); // is busy - iStatusLabel = ToolBox::createLabel(tr( "is %1" ).arg(statusToText(aStatus) ), importantTextFont); - iStatusLabel->setAlignment(Qt::AlignHCenter); - iStatusLabel->setStyleSheet("background-color: transparent"); - iStatusLabel->setHidden( true); + iStatusLabel = ToolBox::createLabel(tr( "is %1" ).arg(statusToText(aStatus) ), textFont); + iStatusLabel->setAlignment( Qt::AlignHCenter ); + iStatusLabel->setHidden( true ); // until 13:22 iUntilTextLabel - = ToolBox::createLabel(tr( "until %1" ).arg(aUntil.toString(iTimeFormat) ), importantTextFont); - iUntilTextLabel->setAlignment(Qt::AlignHCenter); - iUntilTextLabel->setStyleSheet("background-color: transparent"); - iUntilTextLabel->setHidden( true); - - // No connection to server note - qDebug() - << "RoomStatusIndicatorWidget::RoomStatusIndicatorWidget() creating connection label"; - QFrame* connectionLabelFrame = new QFrame( this ); - iConnectionLabel = new QLabel( tr( "No connection to server" ), connectionLabelFrame ); - iConnectionLabel->setFont(importantTextFont); - iConnectionLabel->setAlignment(Qt::AlignHCenter); - iConnectionLabel->setWordWrap( true); - iConnectionLabel->setStyleSheet("background-color: transparent; color: red; text-decoration:blink; max-width: 250px"); - connectionLabelFrame->setFixedSize(iConnectionLabel->sizeHint() ); - if (connectedOnce && !connectionError) - iConnectionLabel->setHidden( true); - - QVBoxLayout *topLayout = new QVBoxLayout; - topLayout->addStretch(); + = ToolBox::createLabel(tr( "until %1" ).arg(aUntil.toString(iTimeFormat) ), textFont); + iUntilTextLabel->setAlignment( Qt::AlignHCenter ); + iUntilTextLabel->setHidden( true ); + + QHBoxLayout *topLayout = new QHBoxLayout; topLayout->addWidget(iTimeDisplay); - topLayout->addSpacing( 28); - topLayout->addWidget(iDefaultRoomLabel); - topLayout->addWidget(iStatusLabel); - topLayout->addWidget(iUntilTextLabel); - topLayout->addSpacing( 28); - topLayout->addWidget(connectionLabelFrame); - topLayout->addStretch(); - - QHBoxLayout *mainLayout = new QHBoxLayout; - mainLayout->addLayout(topLayout); - mainLayout->addStretch(); - //mainLayout->setMargin( 65 ); - mainLayout->setContentsMargins( 65, 65, 65, 0); + + QVBoxLayout *textLayout = new QVBoxLayout; + textLayout->addWidget(iDefaultRoomLabel); + textLayout->addWidget(iStatusLabel); + textLayout->addWidget(iUntilTextLabel); + textLayout->addSpacing( 250 ); + + QHBoxLayout *centerLayout = new QHBoxLayout; + centerLayout->addLayout( textLayout ); + centerLayout->addSpacing( 250 ); + + QHBoxLayout *bottomLayout = new QHBoxLayout; + bottomLayout->addSpacing( 56 ); + bottomLayout->addWidget( iStatusBar ); + bottomLayout->addSpacing( 56 ); + + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addLayout( topLayout ); + mainLayout->addSpacing( 50 ); + mainLayout->addLayout( centerLayout ); + mainLayout->addLayout( bottomLayout ); setLayout(mainLayout); statusChanged(aStatus, aUntil); @@ -95,6 +106,9 @@ RoomStatusIndicatorWidget::~RoomStatusIndicatorWidget() { delete iTimeDisplay; iTimeDisplay = 0; + + delete iStatusBar; + iStatusBar = 0; } QString RoomStatusIndicatorWidget::statusToText(const Room::Status aStatus) @@ -116,7 +130,7 @@ QPalette RoomStatusIndicatorWidget::createPalette(Room::Status aStatus) int cropheight(pixmap.height() - yoffset); QBrush brush; - if (windowState() == Qt::WindowFullScreen) + if ( (pixmap.width() == rect().width()) && (pixmap.height() == rect().height()) ) { // Use the full image in full screen mode brush.setTexture(pixmap); @@ -130,16 +144,42 @@ QPalette RoomStatusIndicatorWidget::createPalette(Room::Status aStatus) QPalette palette; palette.setColor( QPalette::Window, Qt::white ); - palette.setColor( QPalette::WindowText, Qt::darkGray ); + palette.setColor( QPalette::WindowText, Qt::black ); palette.setBrush( QPalette::Window, brush ); return palette; } -void RoomStatusIndicatorWidget::setCurrentTime(QTime aCurrentTime) +void RoomStatusIndicatorWidget::setConnectionStatus( QDateTime aCurrentTime, bool aConnected, + QTime aLastUpdated, QString aError ) { - iTimeDisplay->setTime(aCurrentTime); + iTimeDisplay->setText( aCurrentTime.toString( iTimeFormat ) ); + if ( aLastUpdated.isNull() ) + iStatusBar->setText( tr("Disconnected") , BorderedBarWidget::LeftAlign ); + else + { + iDefaultRoomLabel->setHidden( false ); + iUntilTextLabel->setHidden( false ); + iStatusLabel->setHidden( false ); + + if (!aConnected) + { + iStatusBar->setText( tr("Disconnected"), BorderedBarWidget::LeftAlign ); + } + else + { + iStatusBar->setText( tr("Connected - Last update %1").arg(aLastUpdated.toString(iTimeFormat)) , + BorderedBarWidget::LeftAlign ); + } + } + showError( aError ); } +void RoomStatusIndicatorWidget::showError( QString aError ) +{ + iStatusBar->setText( aError ); +} + + void RoomStatusIndicatorWidget::statusChanged(const Room::Status aStatus, const QTime aUntil) { iStatusLabel->setText(tr( "is %1" ).arg(statusToText(aStatus) ) ); @@ -164,11 +204,11 @@ bool RoomStatusIndicatorWidget::event(QEvent *event) switch (event->type()) { case QEvent::Paint: - qDebug() << "[RoomStatusIndicatorWidget::event] "; + //qDebug() << "[RoomStatusIndicatorWidget::event] "; break; case QEvent::PaletteChange: - qDebug() - << "[RoomStatusIndicatorWidget::event] "; + //qDebug() + // << "[RoomStatusIndicatorWidget::event] "; break; default: break; @@ -179,24 +219,10 @@ bool RoomStatusIndicatorWidget::event(QEvent *event) void RoomStatusIndicatorWidget::connectionEstablished() { - if ( !connectedOnce) - { - // Just got the required meetings for the first time - qDebug() << "RoomStatusIndicatorWidget::connectionEstablished() first call"; - iDefaultRoomLabel->setHidden( false); - iUntilTextLabel->setHidden( false); - iStatusLabel->setHidden( false); - } - else - { - qDebug() << "RoomStatusIndicatorWidget::connectionEstablished()"; - } ViewBase::connectionEstablished(); - iConnectionLabel->setHidden( true); } void RoomStatusIndicatorWidget::connectionLost() { ViewBase::connectionLost(); - iConnectionLabel->setHidden( false); } diff --git a/src/UserInterface/Views/RoomStatusIndicatorWidget.h b/src/UserInterface/Views/RoomStatusIndicatorWidget.h index 643160a..c9256dc 100644 --- a/src/UserInterface/Views/RoomStatusIndicatorWidget.h +++ b/src/UserInterface/Views/RoomStatusIndicatorWidget.h @@ -10,7 +10,7 @@ class QLabel; class QVBoxLayout; -class TimeDisplayWidget; +class BorderedBarWidget; class QEvent; @@ -43,13 +43,14 @@ public: bool event(QEvent *event); public slots: - //! Slot. Sets current time. + //! Slot. Sets the connection status /*! - * Slots. Sets current time on the widget. It is used to provide up-to-date time for the widget's - * TimeDisplayWidget. - * \param aCurrentTime The current time. + * Sets the current time, and connection status + * \param aCurrentTime Time to be displayed. + * \param aConnected connection status to be displayed. + * \param aLastUpdated Time of last successful connection to be displayed. */ - void setCurrentTime( QTime aCurrentTime ); + void setConnectionStatus( QDateTime aCurrentTime, bool aConnected, QTime aLastUpdated = QTime(), QString aError = ""); //! Slot. Used to indicate changes in the status of the default room. /*! * Slot. Used to indicate changes in the status of the default room. If the specified until time equals @@ -60,9 +61,11 @@ public slots: */ void statusChanged( const Room::Status aStatus, const QTime aUntil ); + void showError( QString aError ); + void currentRoomChanged( Room *aRoom ); - void viewResized(const QSize &newSize, const QSize &oldSize) { } + void viewResized(const QSize &/*newSize*/, const QSize &/*oldSize*/) { } void connectionEstablished(); @@ -88,8 +91,9 @@ private: QLabel *iDefaultRoomLabel; QLabel *iStatusLabel; QLabel *iUntilTextLabel; - QLabel *iConnectionLabel; - TimeDisplayWidget *iTimeDisplay; + BorderedBarWidget *iTimeDisplay; + BorderedBarWidget *iStatusBar; + QString iTimeFormat; static QTime endOfTheDay; diff --git a/src/UserInterface/Views/SettingsView.cpp b/src/UserInterface/Views/SettingsView.cpp index 30ab301..fad4c15 100644 --- a/src/UserInterface/Views/SettingsView.cpp +++ b/src/UserInterface/Views/SettingsView.cpp @@ -20,9 +20,18 @@ #include "DisplaySettings.h" #include "ConnectionSettings.h" #include "StartupSettings.h" +#include #include +#define QT_DELETE(X) \ + if ( X != 0 ) \ + { \ + qDebug() << "delete " << X; \ + delete X; \ + X = 0; \ + } + SettingsView::SettingsView( QWidget *aParent ) : ViewBase( ViewBase::NormalView, aParent ) { @@ -66,96 +75,26 @@ SettingsView::SettingsView( QWidget *aParent ) : SettingsView::~SettingsView() { - if ( iTabWidget != 0 ) - { - delete iTabWidget; - iTabWidget = 0; - } - if ( iOkButton != 0 ) - { - delete iOkButton; - iOkButton = 0; - } - if ( iCancelButton != 0 ) - { - delete iCancelButton; - iCancelButton = 0; - } - if ( iSettingsTab != 0 ) - { - delete iSettingsTab; - iSettingsTab = 0; - } - if ( iWeekViewTab != 0 ) - { - delete iWeekViewTab; - iWeekViewTab = 0; - } - if ( iResourcesTab != 0 ) - { - delete iResourcesTab; - iResourcesTab = 0; - } - if ( iKioskModeTab != 0 ) - { - delete iKioskModeTab; - iKioskModeTab = 0; - } - if ( iUserName != 0 ) - { - delete iUserName; - iUserName = 0; - } - if ( iPassword != 0 ) - { - delete iPassword; - iPassword = 0; - } - if ( iServerAddress != 0 ) - { - delete iServerAddress; - iServerAddress = 0; - } - if ( iDayStartTime != 0 ) - { - delete iDayStartTime; - iDayStartTime = 0; - } - if ( iDayEndTime != 0 ) - { - delete iDayEndTime; - iDayEndTime = 0; - } - if ( iFiveDays != 0 ) - { - delete iFiveDays; - iFiveDays = 0; - } - if ( iSevenDays != 0 ) - { - delete iSevenDays; - iSevenDays = 0; - } - if ( iRefreshInterval != 0 ) - { - delete iRefreshInterval; - iRefreshInterval = 0; - } - if ( iPowerSaveEnabled != 0 ) - { - delete iPowerSaveEnabled; - iPowerSaveEnabled = 0; - } - if ( iPowerSaveStartTime != 0 ) - { - delete iPowerSaveStartTime; - iPowerSaveStartTime = 0; - } - if ( iPowerSaveEndTime != 0 ) - { - delete iPowerSaveEndTime; - iPowerSaveEndTime = 0; - } + qDebug() << "[SettingsView::~SettingsView]"; + /*QT_DELETE(iOkButton); + QT_DELETE(iCancelButton); + QT_DELETE(iUserName); + QT_DELETE(iPassword); + QT_DELETE(iServerAddress); + QT_DELETE(iDayStartTime); + QT_DELETE(iDayEndTime); + QT_DELETE(iFiveDays); + QT_DELETE(iSevenDays); + QT_DELETE(iRefreshInterval); + QT_DELETE(iPowerSaveEnabled); + QT_DELETE(iPowerSaveStartTime); + QT_DELETE(iPowerSaveEndTime); + QT_DELETE(iShowConfidentialMeetingDetails); + QT_DELETE(iSettingsTab); + QT_DELETE(iWeekViewTab); + QT_DELETE(iResourcesTab); + QT_DELETE(iKioskModeTab); + QT_DELETE(iTabWidget);*/ } QWidget *SettingsView::initSettingsTab() @@ -174,6 +113,7 @@ QWidget *SettingsView::initSettingsTab() // Create the group boxes QGroupBox *userInformationGroup = new QGroupBox( tr( "User Information" ) ); QGroupBox *serverInformationGroup = new QGroupBox( tr( "Server Information" ) ); + QGroupBox *privacySettingsGroup = new QGroupBox( tr( "Privacy Settings" ) ); // Prepare the user infromation group box QGridLayout *ugl = new QGridLayout; @@ -201,14 +141,25 @@ QWidget *SettingsView::initSettingsTab() serverInformationGroup->setLayout( sgl ); + // Prepare meeting info setting box + QGridLayout *pgl = new QGridLayout; + iShowConfidentialMeetingDetails = new QCheckBox( tr( "Show confidential meeting details" ) ); + + pgl->addWidget( iShowConfidentialMeetingDetails, 0, 0 ); + + privacySettingsGroup->setLayout( pgl ); + // Prepare and set the main layout QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addWidget( userInformationGroup ); mainLayout->addWidget( serverInformationGroup ); + mainLayout->addWidget( privacySettingsGroup ); widget->setLayout( mainLayout ); - return widget; + QScrollArea *scroll = new QScrollArea; + scroll->setWidget(widget); + return scroll; } QWidget *SettingsView::initWeekViewTab() @@ -251,7 +202,9 @@ QWidget *SettingsView::initWeekViewTab() widget->setLayout( mainLayout ); - return widget; + QScrollArea *scroll = new QScrollArea; + scroll->setWidget(widget); + return scroll; } QWidget *SettingsView::initResourcesTab() @@ -298,7 +251,9 @@ QWidget *SettingsView::initResourcesTab() widget->setLayout( mainLayout ); - return widget; + QScrollArea *scroll = new QScrollArea; + scroll->setWidget(widget); + return scroll; } QWidget *SettingsView::initKioskModeTab() @@ -320,7 +275,7 @@ QWidget *SettingsView::initKioskModeTab() } iPowerSaveStartTime->setTime( Configuration::instance()->startupSettings()->turnOnAt() ); iPowerSaveEndTime->setTime( Configuration::instance()->startupSettings()->turnOffAt() ); - + // Prepare the admin password box QGroupBox *adminPasswordGroup = new QGroupBox( tr( "Admin Password" ) ); QLabel *oldPwdLabel = new QLabel( tr( "Old password:" ) ); @@ -369,7 +324,9 @@ QWidget *SettingsView::initKioskModeTab() widget->setLayout( mainLayout ); - return widget; + QScrollArea *scroll = new QScrollArea; + scroll->setWidget(widget); + return scroll; } void SettingsView::handleOkClicked() @@ -392,16 +349,18 @@ void SettingsView::handleOkClicked() bool sevenDays = iSevenDays->isChecked(); bool powerSaveEnabled = iPowerSaveEnabled->isChecked(); + bool showConfidentialMeetingDetails = iShowConfidentialMeetingDetails->isChecked(); + // set values to Configuration // set user information - Configuration::instance()->connectionSettings()->setUsername( userName ); - Configuration::instance()->connectionSettings()->setPassword( password ); + Configuration::instance()->setUsername(userName);//connectionSettings()->setUsername( userName ); + Configuration::instance()->setPassword(password);//connectionSettings()->setPassword( password ); // set server information - Configuration::instance()->connectionSettings()->setServerUrl( serverAddress ); + Configuration::instance()->setServerUrl(serverAddress);//connectionSettings()->setServerUrl( serverAddress ); if ( ok ) { - Configuration::instance()->connectionSettings()->setRefreshInterval( refreshInterval ); + Configuration::instance()->setRefreshinterval(refreshInterval);//connectionSettings()->setRefreshInterval( refreshInterval ); } // set weekly view settings @@ -421,8 +380,15 @@ void SettingsView::handleOkClicked() Configuration::instance()->startupSettings()->setTurnOnAt( powerSaveStart ); Configuration::instance()->startupSettings()->setTurnOffAt( powerSaveEnd ); + // set privacy settings + Configuration::instance()->setShowConfidentialMeetingDetails( showConfidentialMeetingDetails ); + + qDebug() << "[SettingsView::okClicked] save()"; + // save configuration Configuration::instance()->save(); + + qDebug() << "[SettingsView::okClicked] setValues()"; // Emit the signal to notify that ok is pressed and data is saved. setValues(); @@ -448,12 +414,12 @@ void SettingsView::handleCancelClicked() void SettingsView::setValues() { // set user information - iUserName->setText( Configuration::instance()->connectionSettings()->username() ); - iPassword->setText( Configuration::instance()->connectionSettings()->password() ); + iUserName->setText( Configuration::instance()->getUsername() ); + iPassword->setText( Configuration::instance()->getPassword());//connectionSettings()->password() ); // set server information - iServerAddress->setText( Configuration::instance()->connectionSettings()->serverUrl().toString() ); + iServerAddress->setText( Configuration::instance()->getServerUrl().toString());//connectionSettings()->serverUrl().toString() ); QString refreshIntervalStr; - refreshIntervalStr.setNum( Configuration::instance()->connectionSettings()->refreshInterval() ); + refreshIntervalStr.setNum( Configuration::instance()->getRefreshinterval());//connectionSettings()->refreshInterval() ); iRefreshInterval->setText( refreshIntervalStr ); // set weekly view display settings if ( Configuration::instance()->displaySettings()->daysInSchedule() == DisplaySettings::WeekdaysInSchedule ) @@ -479,4 +445,7 @@ void SettingsView::setValues() } iPowerSaveStartTime->setTime( Configuration::instance()->startupSettings()->turnOnAt() ); iPowerSaveEndTime->setTime( Configuration::instance()->startupSettings()->turnOffAt() ); + + // set privacy settings + iShowConfidentialMeetingDetails->setChecked( Configuration::instance()->showConfidentialMeetingDetails() ); } diff --git a/src/UserInterface/Views/SettingsView.h b/src/UserInterface/Views/SettingsView.h index c86e690..923da77 100644 --- a/src/UserInterface/Views/SettingsView.h +++ b/src/UserInterface/Views/SettingsView.h @@ -90,6 +90,9 @@ private: QTimeEdit *iPowerSaveStartTime; //! End time for deactivating power save. QTimeEdit *iPowerSaveEndTime; + + //! Show confidential meeting details. + QCheckBox *iShowConfidentialMeetingDetails; }; #endif /*SETTINGSVIEW_H_*/ diff --git a/src/UserInterface/Views/WeeklyViewWidget.cpp b/src/UserInterface/Views/WeeklyViewWidget.cpp index 643732e..1596933 100644 --- a/src/UserInterface/Views/WeeklyViewWidget.cpp +++ b/src/UserInterface/Views/WeeklyViewWidget.cpp @@ -16,6 +16,7 @@ #include "ScheduleWidget.h" #include "ToolBox.h" #include "MeetingInfoDialog.h" +#include "BorderedBarWidget.h" #include @@ -33,6 +34,20 @@ WeeklyViewWidget::WeeklyViewWidget( QDateTime aCurrentDateTime, Configuration *a regularTextFont.setBold( true ); regularTextFont.setPointSize( 12 ); + QFont clockFont; + clockFont.setStyleHint( QFont::Helvetica ); + clockFont.setBold( true ); + clockFont.setPixelSize( 36 ); + + QFont statusBarFont; + statusBarFont.setStyleHint( QFont::Helvetica ); + statusBarFont.setPixelSize( 18 ); + + QFont buttonFont; + buttonFont.setStyleHint( QFont::Helvetica ); + buttonFont.setBold( true ); + buttonFont.setPixelSize( 18 ); + iSettingsButton = new QPushButton; iSettingsButton->setIcon( QPixmap( ":button_settings" ) ); iSettingsButton->setFixedWidth( 36 ); @@ -41,57 +56,90 @@ WeeklyViewWidget::WeeklyViewWidget( QDateTime aCurrentDateTime, Configuration *a iCurrentDayLabel = ToolBox::createLabel( aCurrentDateTime.toString( iConfiguration->displaySettings()->dateFormat() ), regularTextFont ); iCurrentWeekLabel = ToolBox::createLabel( tr( "Wk %1" ).arg( aCurrentDateTime.date().weekNumber() ), regularTextFont ); + iTimeDisplay = new BorderedBarWidget( this ); + iTimeDisplay->setFaceColor( Qt::darkGray ); + iTimeDisplay->setBackgroundColor( Qt::white); + iTimeDisplay->setBorderWidth( 6 ); + iTimeDisplay->setFixedWidth( 170 ); + iTimeDisplay->setFixedHeight( 50 ); + iTimeDisplay->setFont( clockFont ); + iRoomsCombo = new MeetingRoomCombo( iConfiguration->rooms(), this ); iRoomsCombo->setCurrentRoom( iConfiguration->defaultRoom() ); connect( iRoomsCombo, SIGNAL( currentRoomChanged( Room * ) ), this, SIGNAL( currentRoomChanged( Room * ) ) ); - iTimeDisplay = new DigitalTimeDisplayWidget( aCurrentDateTime.time(), iConfiguration->displaySettings()->timeFormat(), this ); - iTimeDisplay->setFrameVisible( false ); - iTimeDisplay->setFont( regularTextFont ); + iStatusBar = new BorderedBarWidget( this ); + iStatusBar->setFaceColor( Qt::darkGray ); + iStatusBar->setBackgroundColor( Qt::white ); + iStatusBar->setBorderWidth( 4 ); + iStatusBar->setFont(statusBarFont); + iStatusBar->setFixedHeight( 36 ); + iStatusBar->setText( tr("Disconnected"), BorderedBarWidget::LeftAlign ); + + connect( iStatusBar, SIGNAL( clicked() ), this, SIGNAL( refreshButtonClicked() ) ); iSchedule = new ScheduleWidget( aCurrentDateTime, iConfiguration->displaySettings(), this ); connect( iSchedule, SIGNAL( shownWeekChanged( QDate ) ), this, SIGNAL( shownWeekChanged( QDate ) ) ); connect( iSchedule, SIGNAL( meetingActivated( Meeting* ) ), this, SIGNAL( meetingActivated( Meeting* ) ) ); iPreviousWeekButton = new QPushButton( this ); - iPreviousWeekButton->setText( tr( "<<" ) ); - iPreviousWeekButton->setFixedWidth( 60 ); + iPreviousWeekButton->setText( tr( "<" ) ); + iPreviousWeekButton->setFixedWidth( 50 ); + iPreviousWeekButton->setFixedHeight( 100 ); + iPreviousWeekButton->setFont( buttonFont ); connect( iPreviousWeekButton, SIGNAL( clicked() ), iSchedule, SLOT( showPreviousWeek() ) ); iCurrentWeekButton = new QPushButton( this ); iCurrentWeekButton->setFixedWidth( 100 ); - iCurrentWeekButton->setText( tr( "Current" ) ); + iCurrentWeekButton->setFixedHeight( 46 ); + iCurrentWeekButton->setText( tr( "Today" ) ); + iCurrentWeekButton->setFont( buttonFont ); + connect( iCurrentWeekButton, SIGNAL( clicked() ), iSchedule, SLOT( showCurrentWeek() ) ); iNextWeekButton = new QPushButton( this ); - iNextWeekButton->setFixedWidth( 60 ); - iNextWeekButton->setText( tr( ">>" ) ); + iNextWeekButton->setFixedWidth( 50 ); + iNextWeekButton->setFixedHeight( 100 ); + iNextWeekButton->setText( tr( ">" ) ); + iNextWeekButton->setFont( buttonFont ); connect( iNextWeekButton, SIGNAL( clicked() ), iSchedule, SLOT( showNextWeek() ) ); // ********************************** // Create the view's layout + QVBoxLayout *leftLayout = new QVBoxLayout; + QVBoxLayout *centerLayout = new QVBoxLayout; + QVBoxLayout *rightLayout = new QVBoxLayout; + + leftLayout->addWidget( iPreviousWeekButton ); + rightLayout->addWidget( iNextWeekButton ); + QHBoxLayout *tableLayout = new QHBoxLayout; tableLayout->addWidget( iSchedule ); - QHBoxLayout *bottomLayout = new QHBoxLayout; - bottomLayout->addWidget( iRoomsCombo ); - bottomLayout->addWidget( iTimeDisplay ); - QVBoxLayout *dateLayout = new QVBoxLayout; - dateLayout->addWidget( iCurrentDayLabel ); - dateLayout->addWidget( iCurrentWeekLabel ); - bottomLayout->addLayout( dateLayout ); - bottomLayout->addWidget( iPreviousWeekButton ); - bottomLayout->addWidget( iCurrentWeekButton ); - bottomLayout->addWidget( iNextWeekButton ); - bottomLayout->addWidget( iSettingsButton ); - - QVBoxLayout *mainLayout = new QVBoxLayout; - mainLayout->addLayout( tableLayout ); - mainLayout->addLayout( bottomLayout ); + QGridLayout *naviLayout = new QGridLayout; + naviLayout->addWidget( iCurrentWeekButton, 0, 0, Qt::AlignLeft ); + naviLayout->addWidget( iTimeDisplay, 0, 1, Qt::AlignCenter ); + naviLayout->addWidget( iRoomsCombo, 0, 2, Qt::AlignRight ); + +// QVBoxLayout *dateLayout = new QVBoxLayout; +// dateLayout->addWidget( iCurrentDayLabel ); +// dateLayout->addWidget( iCurrentWeekLabel ); +// bottomLayout->addLayout( dateLayout ); +// bottomLayout->addWidget( iSettingsButton ); + + centerLayout->addLayout( naviLayout ); + centerLayout->addLayout( tableLayout ); + centerLayout->addWidget( iStatusBar ); + + QHBoxLayout *mainLayout = new QHBoxLayout; + mainLayout->addLayout( leftLayout ); + mainLayout->addLayout( centerLayout ); + mainLayout->addLayout( rightLayout ); setLayout( mainLayout ); // Set child observing observeChild( iRoomsCombo ); + observeChild( iStatusBar ); observeChild( iTimeDisplay ); observeChild( iCurrentDayLabel ); observeChild( iCurrentWeekLabel ); @@ -102,7 +150,7 @@ WeeklyViewWidget::WeeklyViewWidget( QDateTime aCurrentDateTime, Configuration *a QPalette palette; palette.setColor( QPalette::Window, Qt::white ); - palette.setColor( QPalette::WindowText, Qt::darkGray ); + palette.setColor( QPalette::Foreground, Qt::darkGray ); setPalette( palette ); setAutoFillBackground( true ); @@ -132,6 +180,12 @@ WeeklyViewWidget::~WeeklyViewWidget() delete iTimeDisplay; iTimeDisplay = 0; } + if ( iStatusBar ) + { + delete iStatusBar; + iStatusBar = 0; + } + if ( iSchedule ) { delete iSchedule; @@ -174,15 +228,32 @@ Room* WeeklyViewWidget::currentRoom() return iRoomsCombo->currentRoom(); } -void WeeklyViewWidget::setCurrentDateTime( QDateTime aCurrentDateTime ) +void WeeklyViewWidget::setConnectionStatus( QDateTime aCurrentTime, bool aConnected, + QTime aLastUpdated, QString aError ) { - iCurrentDayLabel->setText( aCurrentDateTime.date().toString( iConfiguration->displaySettings()->dateFormat() ) ); + iCurrentDayLabel->setText( aCurrentTime.date().toString( iConfiguration->displaySettings()->dateFormat() ) ); + iCurrentWeekLabel->setText( tr( "Wk %1" ).arg( aCurrentTime.date().weekNumber() ) ); + iSchedule->setCurrentDateTime( aCurrentTime ); - iCurrentWeekLabel->setText( tr( "Wk %1" ).arg( aCurrentDateTime.date().weekNumber() ) ); - - iTimeDisplay->setTime( aCurrentDateTime.time() ); + iTimeDisplay->setText( aCurrentTime.toString( iConfiguration->displaySettings()->timeFormat() ) ); + if ( aLastUpdated.isNull() ) + iStatusBar->setText( tr("Disconnected") , BorderedBarWidget::LeftAlign ); + else if ( !aConnected ) + { + iStatusBar->setText( tr("Disconnected"), BorderedBarWidget::LeftAlign ); + } + else + { + iStatusBar->setText( tr("Connected - Last update %1") + .arg(aLastUpdated.toString(iConfiguration->displaySettings()->timeFormat())) , + BorderedBarWidget::LeftAlign ); + } + showError( aError ); + } - iSchedule->setCurrentDateTime( aCurrentDateTime ); +void WeeklyViewWidget::showError( QString aError ) +{ + iStatusBar->setText( aError ); } QDate WeeklyViewWidget::beginnigOfShownWeek() @@ -205,3 +276,13 @@ void WeeklyViewWidget::setDefaultRoom() { iRoomsCombo->setCurrentRoom( iConfiguration->defaultRoom() ); } + +void WeeklyViewWidget::connectionEstablished() +{ + ViewBase::connectionEstablished(); +} + +void WeeklyViewWidget::connectionLost() +{ + ViewBase::connectionLost(); +} diff --git a/src/UserInterface/Views/WeeklyViewWidget.h b/src/UserInterface/Views/WeeklyViewWidget.h index 055617b..5ea4bf6 100644 --- a/src/UserInterface/Views/WeeklyViewWidget.h +++ b/src/UserInterface/Views/WeeklyViewWidget.h @@ -1,155 +1,173 @@ -#ifndef WEEKLYVIEWWIDGET_H_ -#define WEEKLYVIEWWIDGET_H_ - -#include "ViewBase.h" -#include - -class QLabel; -class QPushButton; -class MeetingRoomCombo; -class TimeDisplayWidget; -class ScheduleWidget; -class Configuration; -class Meeting; -class Room; - -//! Userinterface class. Shows a weekly calendar for the selected room, provides date and time information. -/*! - * UserInterface class. Shows the current date and time and selected week's calendar for - * selected meeting room. User can select meeting room, browse weeks back and forth, and can navigate - * back to the current week. - */ -class WeeklyViewWidget : public ViewBase -{ - Q_OBJECT - -public: - //! Constructor. - /*! - * Constructor to initialize an WeeklyViewWidget instance. - * \param aCurrentDateTime - * \param aConfiguration Pointer to the configuration object. Not owned. - * \param aParent Pointer to the parent widget. - */ - WeeklyViewWidget( QDateTime aCurrentDateTime, Configuration *aConfiguration, QWidget *aParent = 0 ); - //! Destructor. - virtual ~WeeklyViewWidget(); - - //! Current room - /*! - * Returns the currently selected meeting room. - * \return Selected meeting room. - */ - Room* currentRoom(); - - //! First day of week currently displayd - /*! - * Returns the first day of week currently displayd. - * \return First day of week. - */ - QDate beginnigOfShownWeek(); - //! Sends the refresh command to schedule widget. - /*! - * Sends the refresh command to schedule widget. - * \param aMeetings The list of meetings. - */ - void refreshMeetings( const QList &aMeetings ); - - void showCurrentWeek(); - - void setDefaultRoom(); - -signals: - //! Signals change of the meeting room. - /*! - * Signal is emited when meeting room is changed. - * \param aNewRoom Selected meeting room. - */ - void currentRoomChanged( Room *aNewRoom ); - //! Meeting activated. - /*! - * Signal is emitted when a meeting is clicked by the user. - * \param aMeeting actived meeting. - */ - void meetingActivated( Meeting *aMeeting ); - //! Signals creation of new meeting. - /*! - * Signal is emited when new meeting is created. - * \param aMeeting Meeting that has been created. - * \param aUsername User who created the meeting. - * \param aPassword Password of the "aUsername" - */ - void meetingToCreate( Meeting *aMeeting, const QString &aUsername, const QString &aPassword ); - //! Signals deletion of a meeting. - /*! - * Signal is emited when meeting is deleted. - * \param aMeeting Deleted meeting. - * \param aUsername User who deleted the meeting. - * \param aPassword Password of the "aUsername" - */ - void meetingToDelete( Meeting *aMeeting, const QString &aUsername, const QString &aPassword ); - //! Signals modifications of a meeting. - /*! - * Signal is emited when meeting is modified. - * \param aMeeting Modified meeting. - * \param aUsername User who modified the meeting. - * \param aPassword Password of the "aUsername" - */ - void meetingToUpdate( Meeting *aMeeting, const QString &aUsername, const QString &aPassword ); - - //! Signals - /*! - * Signal is emited when settings button is clicked. - */ - void settingsButtonClicked(); - - //! Signal. Emitted if the shown week has been changed. - /*! +#ifndef WEEKLYVIEWWIDGET_H_ +#define WEEKLYVIEWWIDGET_H_ + +#include "ViewBase.h" +#include + +class QLabel; +class QPushButton; +class MeetingRoomCombo; +class TimeDisplayWidget; +class ScheduleWidget; +class Configuration; +class Meeting; +class Room; +class BorderedBarWidget; + +//! Userinterface class. Shows a weekly calendar for the selected room, provides date and time information. +/*! + * UserInterface class. Shows the current date and time and selected week's calendar for + * selected meeting room. User can select meeting room, browse weeks back and forth, and can navigate + * back to the current week. + */ +class WeeklyViewWidget : public ViewBase +{ + Q_OBJECT + +public: + //! Constructor. + /*! + * Constructor to initialize an WeeklyViewWidget instance. + * \param aCurrentDateTime + * \param aConfiguration Pointer to the configuration object. Not owned. + * \param aParent Pointer to the parent widget. + */ + WeeklyViewWidget( QDateTime aCurrentDateTime, Configuration *aConfiguration, QWidget *aParent = 0 ); + //! Destructor. + virtual ~WeeklyViewWidget(); + + //! Current room + /*! + * Returns the currently selected meeting room. + * \return Selected meeting room. + */ + Room* currentRoom(); + + //! First day of week currently displayd + /*! + * Returns the first day of week currently displayd. + * \return First day of week. + */ + QDate beginnigOfShownWeek(); + //! Sends the refresh command to schedule widget. + /*! + * Sends the refresh command to schedule widget. + * \param aMeetings The list of meetings. + */ + void refreshMeetings( const QList &aMeetings ); + + void showCurrentWeek(); + + void setDefaultRoom(); + +signals: + //! Signals change of the meeting room. + /*! + * Signal is emited when meeting room is changed. + * \param aNewRoom Selected meeting room. + */ + void currentRoomChanged( Room *aNewRoom ); + //! Meeting activated. + /*! + * Signal is emitted when a meeting is clicked by the user. + * \param aMeeting actived meeting. + */ + void meetingActivated( Meeting *aMeeting ); + //! Signals creation of new meeting. + /*! + * Signal is emited when new meeting is created. + * \param aMeeting Meeting that has been created. + * \param aUsername User who created the meeting. + * \param aPassword Password of the "aUsername" + */ + void meetingToCreate( Meeting *aMeeting, const QString &aUsername, const QString &aPassword ); + //! Signals deletion of a meeting. + /*! + * Signal is emited when meeting is deleted. + * \param aMeeting Deleted meeting. + * \param aUsername User who deleted the meeting. + * \param aPassword Password of the "aUsername" + */ + void meetingToDelete( Meeting *aMeeting, const QString &aUsername, const QString &aPassword ); + //! Signals modifications of a meeting. + /*! + * Signal is emited when meeting is modified. + * \param aMeeting Modified meeting. + * \param aUsername User who modified the meeting. + * \param aPassword Password of the "aUsername" + */ + void meetingToUpdate( Meeting *aMeeting, const QString &aUsername, const QString &aPassword ); + + //! Signals + /*! + * Signal is emited when settings button is clicked. + */ + void settingsButtonClicked(); + + //! Signals + /*! + * Signal is emited when refresh button is clicked. + */ + void refreshButtonClicked(); + + + //! Signal. Emitted 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 ); - -public slots: - //! Sets the date and time - /*! - * Sets the current date and time - * \param aCurrentDateTime Date and time to be displayd. - */ - void setCurrentDateTime( QDateTime aCurrentDateTime ); - //! Handle resizing - /*! - * Handle possible resize changes after the view is resized - * to match the window managers client area. - */ - void viewResized(const QSize &newSize, const QSize &oldSize) { } - -private: - //! Displays the selectable meeting rooms. - MeetingRoomCombo *iRoomsCombo; - //! Displays the time. - TimeDisplayWidget *iTimeDisplay; - //! Displays the calendar. - ScheduleWidget *iSchedule; - //! Displays the date. - QLabel *iCurrentDayLabel; - //! Displays the week number. - QLabel *iCurrentWeekLabel; - //! Button used to display previous week's calendar. - QPushButton *iPreviousWeekButton; - //! Button used to display current week's calendar. - QPushButton *iCurrentWeekButton; - //! Button used to display next week's calendar. - QPushButton *iNextWeekButton; - //! Settings button. TODO : Correct widget is needed!! - QPushButton *iSettingsButton; - //! About button. TODO : Correct widget is needed!! - QPushButton *iAboutButton; - /* ! - * Pointer to configuration object. - * Contains configurable data and IS NOT OWNED by the widget. - */ - Configuration *iConfiguration; -}; - -#endif /*WEEKLYVIEWWIDGET_H_*/ + void shownWeekChanged( QDate aDate ); + +public slots: + //! Slot. Sets the connection status + /*! + * Sets the current time, and connection status + * \param aCurrentTime Time to be displayed. + * \param aConnected connection status to be displayed. + * \param aLastUpdated Time of last successful connection to be displayed. + */ + void setConnectionStatus( QDateTime aCurrentTime, bool aConnected, QTime aLastUpdated = QTime(), QString aError = "" ); + //! Handle resizing + /*! + * Handle possible resize changes after the view is resized + * to match the window managers client area. + */ + void viewResized(const QSize &/*newSize*/, const QSize &/*oldSize*/) { } + + void showError( QString aError ); + + void connectionEstablished(); + + void connectionLost(); + +private: + //! Displays the selectable meeting rooms. + MeetingRoomCombo *iRoomsCombo; + //! Displays the time. + BorderedBarWidget *iTimeDisplay; + //! Displays the status. + BorderedBarWidget *iStatusBar; + //! Displays the calendar. + ScheduleWidget *iSchedule; + //! Displays the date. + QLabel *iCurrentDayLabel; + //! Displays the week number. + QLabel *iCurrentWeekLabel; + //! Button used to display previous week's calendar. + QPushButton *iPreviousWeekButton; + //! Button used to display current week's calendar. + QPushButton *iCurrentWeekButton; + //! Button used to display next week's calendar. + QPushButton *iNextWeekButton; + //! Settings button. TODO : Correct widget is needed!! + QPushButton *iSettingsButton; + //! About button. TODO : Correct widget is needed!! + QPushButton *iAboutButton; + /* ! + * Pointer to configuration object. + * Contains configurable data and IS NOT OWNED by the widget. + */ + Configuration *iConfiguration; +}; + +#endif /*WEEKLYVIEWWIDGET_H_*/ diff --git a/src/UserInterface/WindowManager.cpp b/src/UserInterface/WindowManager.cpp index af006f1..aa90587 100644 --- a/src/UserInterface/WindowManager.cpp +++ b/src/UserInterface/WindowManager.cpp @@ -2,17 +2,26 @@ #include #include +#include #include "ViewBase.h" #include "PopUpMessageBox.h" #include WindowManager::WindowManager( QWidget *aParent ) : - QWidget( aParent ), + QMainWindow( aParent ), iApplicationName( tr( "Qt Meetings" ) ), iCurrentView( 0 ) { this->setWindowTitle( iApplicationName ); + settingsAction = new QAction(tr("&Settings"), this); + closeAction = new QAction(tr("&Close"), this); + connect(settingsAction, SIGNAL(triggered()), this, SIGNAL(showSettingsClicked())); + connect(closeAction, SIGNAL(triggered()), this, SIGNAL(closeClicked())); + editMenu = menuBar()->addMenu(tr("&Edit")); + editMenu->addAction(settingsAction); + menuBar()->addMenu(editMenu); + menuBar()->addAction(closeAction); } WindowManager::~WindowManager() @@ -44,8 +53,12 @@ void WindowManager::showView( ViewBase *view ) 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() ); - + if (((QWidget*)view) != this) + { + this->adjustSize(); + } + view->resize(this->size()); + //view->adjustSize(); view->show(); // Disconnect old connections and hide the view diff --git a/src/UserInterface/WindowManager.h b/src/UserInterface/WindowManager.h index aa736cf..b71c04d 100644 --- a/src/UserInterface/WindowManager.h +++ b/src/UserInterface/WindowManager.h @@ -1,7 +1,7 @@ #ifndef WINDOWMANAGER_H_ #define WINDOWMANAGER_H_ -#include +#include #include // Forward declarations @@ -18,7 +18,7 @@ class QString; * 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 QWidget +class WindowManager : public QMainWindow { Q_OBJECT @@ -58,6 +58,10 @@ signals: */ void previousViewRestored(); + void showSettingsClicked(); + + void closeClicked(); + void dialogActivated(); void dialogDeactivated(); @@ -102,6 +106,12 @@ private: //! Stack of views previously displayed. QStack iViewList; + //! Menu settings + QAction *settingsAction; + //! Menu close application + QAction *closeAction; + //! Edit menu + QMenu *editMenu; }; #endif /*WINDOWMANAGER_H_*/