--- a/clock/clockui/clockviews/src/clockmainview.cpp Mon May 03 12:30:32 2010 +0300
+++ b/clock/clockui/clockviews/src/clockmainview.cpp Fri May 14 15:51:09 2010 +0300
@@ -18,7 +18,6 @@
// System includes
#include <QGraphicsItem>
-#include <QDebug>
#include <HbInstance>
#include <HbLabel>
#include <HbAbstractViewItem>
@@ -39,8 +38,8 @@
#include "settingsutility.h"
#include "timezoneclient.h"
#include "clockalarmlistitemprototype.h"
-#include "skinnableclock.h"
#include "clockalarmlistmodel.h"
+#include "clockwidget.h"
/*!
\class ClockMainView
@@ -56,11 +55,10 @@
ClockMainView::ClockMainView(QGraphicsItem *parent)
:HbView(parent),
mAlarmList(0),
- mSelectedItem(-1)
+ mSelectedItem(-1),
+ mIsLongTop(false)
{
- qDebug("clock: ClockMainView::ClockMainView() -->");
-
- qDebug("clock: ClockMainView::ClockMainView() <--");
+ // Nothing yet.
}
/*!
@@ -68,8 +66,6 @@
*/
ClockMainView::~ClockMainView()
{
- qDebug("clock: ClockMainView::~ClockMainView() -->");
-
if (mDocLoader) {
delete mDocLoader;
mDocLoader = 0;
@@ -78,8 +74,11 @@
delete mAlarmListModel;
mAlarmListModel = 0;
}
+ HbStyleLoader::unregisterFilePath(
+ ":/style/clockalarmlistitemprototype.css");
+ HbStyleLoader::unregisterFilePath(
+ ":/style/clockalarmlistitemprototype.widgetml");
- qDebug("clock: ClockMainView::~ClockMainView() <--");
}
/*!
@@ -92,8 +91,6 @@
void ClockMainView::setupView(
ClockAppControllerIf &controllerIf, ClockDocLoader *docLoader)
{
- qDebug("clock: ClockMainView::setupView() -->");
-
mDocLoader = docLoader;
mAppControllerIf = &controllerIf;
@@ -121,17 +118,6 @@
}
int alarmCount = displayInfoList.count();
-
- connect(
- mTimezoneClient, SIGNAL(timechanged()),
- this, SLOT(updatePlaceLabel()));
- connect(
- mTimezoneClient, SIGNAL(timechanged()),
- this, SLOT(updateDateLabel()));
- connect(
- mTimezoneClient, SIGNAL(timechanged()),
- this, SLOT(updateClockWidget()));
-
HbMainWindow *window = hbInstance->allMainWindows().first();
bool loadSuccess = false;
@@ -155,7 +141,9 @@
this,
SLOT(handleLongPress(HbAbstractViewItem*, const QPointF&)));
- HbStyleLoader::registerFilePath(CLOCK_VIEWS_STYLE_PATH);
+ HbStyleLoader::registerFilePath(":/style/clockalarmlistitemprototype.css");
+ HbStyleLoader::registerFilePath(
+ ":/style/clockalarmlistitemprototype.widgetml");
setmodel();
// Load the correct section based on orientation.
@@ -179,6 +167,36 @@
}
}
+ mDayLabel = static_cast<HbLabel *> (
+ mDocLoader->findObject("dateLabel"));
+
+ mPlaceLabel = static_cast<HbLabel *> (
+ mDocLoader->findObject("placeLabel"));
+
+
+
+ mClockWidget = static_cast<ClockWidget*> (
+ mDocLoader->findObject(CLOCK_WIDGET));
+
+ // Update the date info.
+ updateDateLabel();
+ // Update the place info.
+ updatePlaceLabel(mTimezoneClient->timeUpdateOn());
+ // Update clock widget display.
+ updateClockWidget();
+
+ // Connect to orientation change and load appropriate section.
+ connect(
+ window, SIGNAL(orientationChanged(Qt::Orientation)),
+ this, SLOT(checkOrientationAndLoadSection(Qt::Orientation)));
+}
+
+/*!
+ To defer the connects and initialization. To be done after the view is drawn.
+ Should be called in the slot of view ready.
+ */
+void ClockMainView::setupAfterViewReady()
+{
// Get the toolbar/menu actions.
mRefreshMainView = static_cast<HbAction *> (
mDocLoader->findObject("alarmsAction"));
@@ -202,48 +220,23 @@
mAddNewAlarm, SIGNAL(triggered()),
this, SLOT(addNewAlarm()));
- if (Qt::Vertical == currentOrienation) {
- // Remove toolbar item's texts as only icons are shown.
- // TODO to use text ids from ts file.
- mRefreshMainView->setText(tr(""));
- mDisplayWorldClockView->setText(tr(""));
- mAddNewAlarm->setText("");
- } else if (Qt::Horizontal == currentOrienation) {
- // Display toolbar item's texts
- // TODO to use text ids from ts file.
- mRefreshMainView->setText(tr("Alarms"));
- mDisplayWorldClockView->setText(tr("World clock"));
- mAddNewAlarm->setText("New alarm");
- }
-
mSettingsAction = static_cast<HbAction *> (
mDocLoader->findObject("settingsAction"));
connect(
mSettingsAction, SIGNAL(triggered()),
this, SLOT(openSettings()));
- mDayLabel = static_cast<HbLabel *> (
- mDocLoader->findObject("dateLabel"));
-
- mPlaceLabel = static_cast<HbLabel *> (
- mDocLoader->findObject("placeLabel"));
-
- mClockWidget = static_cast<SkinnableClock *> (
- mDocLoader->findObject("clockWidget"));
-
- // Update the date info.
- updateDateLabel();
- // Update the place info.
- updatePlaceLabel();
- // Update clock widget display.
- updateClockWidget();
-
- // Connect to orientation change and load appropriate section.
+ // Connect the necessary timezone client call backs.
+ connect(
+ mTimezoneClient, SIGNAL(timechanged()),
+ this, SLOT(updateView()));
connect(
- window, SIGNAL(orientationChanged(Qt::Orientation)),
- this, SLOT(checkOrientationAndLoadSection(Qt::Orientation)));
-
- qDebug("clock: ClockMainView::setupView() <--");
+ mTimezoneClient, SIGNAL(autoTimeUpdateChanged(int)),
+ this, SLOT(updatePlaceLabel(int)));
+ connect(
+ mTimezoneClient, SIGNAL(cityUpdated()),
+ this, SLOT(updatePlaceLabel()));
+
}
/*!
@@ -254,13 +247,15 @@
*/
void ClockMainView::handleAlarmStatusChanged(int row)
{
- qDebug() << "clock: ClockMainView::handleAlarmStatusChanged -->";
+ AlarmInfo alarmInfo;
// Get the data for the alarm.
QList<QVariant> alarmData =
mAlarmListModel->sourceModel()->index(row, 0).data(
AlarmDetails).toList();
- int alarmStatus = alarmData.at(2).value<int>();
+ int alarmId = alarmData.at(0).value<int>();
+
+ mAlarmClient->getAlarmInfo(alarmId, alarmInfo);
mSelectedItem = row;
@@ -272,19 +267,27 @@
QString displayNote;
// Activate or deactivate the alarm depending on the alarm status.
// Display the NotificationDialog with appropriate message.
- if (!alarmStatus) {
+ if (Snoozed == alarmInfo.alarmState && Enabled == alarmInfo.alarmStatus
+ && Once != alarmInfo.repeatType) {
+ removeSnoozedAlarm();
+ displayNote.append(tr("Snoozed alarm removed"));
+ }else if (Enabled == alarmInfo.alarmStatus) {
mAlarmClient->toggleAlarmStatus(alarmId, Disabled);
- displayNote.append(hbTrId("txt_clock_main_view_dpopinfo_alarm_deactivated"));
- HbNotificationDialog::launchDialog(displayNote);
+ displayNote.append(
+ hbTrId("txt_clock_main_view_dpopinfo_alarm_deactivated"));
} else {
mAlarmClient->toggleAlarmStatus(alarmId, Enabled);
- displayNote.append(hbTrId("txt_clock_main_view_dpopinfo_alarm_activated"));
- HbNotificationDialog::launchDialog(displayNote);
+ displayNote.append(
+ hbTrId("txt_clock_main_view_dpopinfo_alarm_activated"));
}
+
+ HbNotificationDialog *dialog = new HbNotificationDialog();
+ dialog->setTitle(displayNote);
+ dialog->setTimeout(HbPopup::ConfirmationNoteTimeout);
+ dialog->show();
+
mSelectedItem = -1;
}
-
- qDebug() << "clock: ClockMainView::handleAlarmStatusChanged <--";
}
/*!
@@ -293,10 +296,8 @@
*/
void ClockMainView::refreshMainView()
{
- qDebug() << "clock: ClockMainView::refreshMainView -->";
mRefreshMainView->setChecked(true);
- qDebug() << "clock: ClockMainView::refreshMainView <--";
}
/*!
@@ -305,11 +306,8 @@
*/
void ClockMainView::displayWorldClockView()
{
- qDebug() << "clock: ClockMainView::displayWorldClockView -->";
-
mAppControllerIf->switchToView(WorldClock);
- qDebug() << "clock: ClockMainView::displayWorldClockView <--";
}
/*!
@@ -318,16 +316,8 @@
*/
void ClockMainView::addNewAlarm()
{
- qDebug() << "clock: ClockMainView::addNewAlarm -->";
-
- ClockAlarmEditor *alarmEditor = new ClockAlarmEditor();
+ ClockAlarmEditor *alarmEditor = new ClockAlarmEditor(*mAlarmClient);
alarmEditor->showAlarmEditor();
-
- connect(
- alarmEditor, SIGNAL(alarmSet()),
- this, SLOT(handleAlarmSet()));
-
- qDebug() << "clock: ClockMainView::addNewAlarm <--";
}
/*!
@@ -336,13 +326,9 @@
*/
void ClockMainView::openSettings()
{
- qDebug() << "clock: ClockMainView::openSettings -->";
-
// Create the settings view.
ClockSettingsView *settingsView = new ClockSettingsView(this);
settingsView->loadSettingsView();
-
- qDebug() << "clock: ClockMainView::openSettings <--";
}
/*!
@@ -352,23 +338,18 @@
*/
void ClockMainView::handleActivated(const QModelIndex &index)
{
- qDebug() << "clock: ClockMainView::handleActivated -->";
-
- // Get the data for the alarm.
- int row = index.row();
- QList<QVariant> alarmData =
- mAlarmListModel->sourceModel()->index(row, 0).data(
- AlarmDetails).toList();
- int alarmId = alarmData.at(0).value<int>();
+ if(!mIsLongTop) {// Get the data for the alarm.
+ int row = index.row();
+ QList<QVariant> alarmData =
+ mAlarmListModel->sourceModel()->index(row, 0).data(
+ AlarmDetails).toList();
+ int alarmId = alarmData.at(0).value<int>();
- // Construct the alarm editor.
- ClockAlarmEditor *alarmEditor = new ClockAlarmEditor(alarmId);
- alarmEditor->showAlarmEditor();
- connect(
- alarmEditor, SIGNAL(alarmSet()),
- this, SLOT(handleAlarmSet()));
-
- qDebug() << "clock: ClockMainView::handleActivated <--";
+ // Construct the alarm editor.
+ ClockAlarmEditor *alarmEditor = new ClockAlarmEditor(
+ *mAlarmClient, alarmId);
+ alarmEditor->showAlarmEditor();
+ }
}
/*!
@@ -381,8 +362,7 @@
void ClockMainView::handleLongPress(
HbAbstractViewItem *item, const QPointF &coords)
{
- qDebug() << "clock: ClockMainView::handleLongPress -->";
-
+ mIsLongTop = true;
AlarmInfo alarmInfo;
// Save the item row number where the long press was made.
@@ -398,16 +378,17 @@
// On long press we display item specific context menu.
HbMenu *itemContextMenu = new HbMenu();
+ connect(
+ itemContextMenu,SIGNAL(aboutToClose()),
+ this, SLOT(handleMenuClosed()));
// Add the delete action to the context menu.
- HbAction *deleteAction = itemContextMenu->addAction(
- hbTrId("txt_clk_main_view_menu_delete_alarm"));
- connect(deleteAction, SIGNAL(triggered()), this, SLOT(deleteAlarm()));
+ mDeleteAction = itemContextMenu->addAction(
+ hbTrId("txt_clk_main_view_menu_delete_alarm"));
// Show the menu.
- itemContextMenu->exec(coords);
-
- qDebug() << "clock: ClockMainView::handleLongPress <--";
+ itemContextMenu->open(this, SLOT(selectedMenuAction(HbAction*)));
+ itemContextMenu->setPreferredPos(coords);
}
/*!
@@ -416,8 +397,6 @@
*/
void ClockMainView::deleteAlarm()
{
- qDebug() << "clock: ClockMainView::deleteAlarm -->";
-
if (-1 < mSelectedItem) {
// Get the data for the alarm.
QList<QVariant> alarmData = mAlarmListModel->sourceModel()->
@@ -426,41 +405,44 @@
mAlarmClient->deleteAlarm(alarmId);
mSelectedItem = -1;
}
-
- qDebug() << "clock: ClockMainView::deleteAlarm <--";
}
/*!
- Updates the day and date in the day label.
+ Deltes the snoozed alarm.
*/
-void ClockMainView::updateDateLabel()
+void ClockMainView::removeSnoozedAlarm()
{
- qDebug() << "clock: ClockMainView::updateDateLabel -->";
+ if (-1 < mSelectedItem) {
+ // Get the data for the alarm.
+ QList<QVariant> alarmData = mAlarmListModel->sourceModel()->
+ index(mSelectedItem, 0).data(AlarmDetails).toList();
+ int alarmId = alarmData.at(0).value<int>();
+ mAlarmClient->deleteSnoozedAlarm(alarmId);
+ mSelectedItem = -1;
+ }
+}
- // Get the current datetime.
- QDateTime dateTime = QDateTime::currentDateTime();
- // Get the day name.
- QString dayName = dateTime.toString("dddd");
- // Get the date in correct format.
- QString currentDate = mSettingsUtility->date();
- // Construct the day + date string.
- QString dayDateString;
- dayDateString+= dayName;
- dayDateString += " ";
- dayDateString += currentDate;
-
- mDayLabel->setPlainText(dayDateString);
-
- qDebug() << "clock: ClockMainView::updateDateLabel <--";
+void ClockMainView::updateView()
+{
+ // Update the place label.
+ updatePlaceLabel(mTimezoneClient->timeUpdateOn());
+ // Update date label.
+ updateDateLabel();
+ // Update clock widget.
+ updateClockWidget();
}
/*!
- Updates the zone info in the place label.
+ Slot which gets called for value change in auto time update in cenrep.
+
+ \param autoTimeUpdate Value of auto time update.
*/
-void ClockMainView::updatePlaceLabel()
+void ClockMainView::updatePlaceLabel(int autoTimeUpdate)
{
- qDebug() << "clock: MainViewWidget::updateClockZoneInfo -->";
-
+ if (-1 == autoTimeUpdate) {
+ autoTimeUpdate = mTimezoneClient->timeUpdateOn();
+ }
+
// Get the current zone info.
LocationInfo currentZoneInfo = mTimezoneClient->getCurrentZoneInfoL();
@@ -498,13 +480,13 @@
} else {
gmtOffset += QString::number(offsetInMinutes);
}
-
+
// Append space.
gmtOffset += tr(" ");
-
+
// Append GMT sting.
gmtOffset += hbTrId("txt_common_common_gmt");
-
+
// Append space.
gmtOffset += tr(" ");
@@ -515,7 +497,7 @@
// Update the labels with the correct info.
mPlaceLabel->clear();
- if (mTimezoneClient->timeUpdateOn()) {
+ if(autoTimeUpdate) {
mPlaceLabel->setPlainText(
currentZoneInfo.countryName + tr(" ") + gmtOffset);
} else {
@@ -523,20 +505,6 @@
currentZoneInfo.cityName + tr(", ")
+ currentZoneInfo.countryName + tr(" ") + gmtOffset);
}
-
- qDebug() << "clock: MainViewWidget::updateDayDateInfo <--";
-}
-
-/*!
- Updates the clock widget display.
- */
-void ClockMainView::updateClockWidget()
-{
- qDebug() << "clock: ClockMainView::updateClockWidget -->";
-
- mClockWidget->updateDisplay(true);
-
- qDebug() << "clock: ClockMainView::updateClockWidget <--";
}
/*!
@@ -544,8 +512,6 @@
*/
void ClockMainView::handleAlarmListDisplay()
{
- qDebug() << "clock: ClockMainView::handleAlarmListDisplay -->";
-
// Get the list of pending clock alarms from server.
QList<AlarmInfo> alarmInfoList;
QList<AlarmInfo> displayInfoList;
@@ -567,48 +533,6 @@
}
}
- qDebug() << "clock: ClockMainView::handleAlarmListDisplay <--";
-}
-
-/*!
- Sets the model to the alarm list.
- */
-void ClockMainView::setmodel()
-{
- qDebug() << "clock: ClockMainView::setmodel -->";
-
- // Set the model.
- if (mAlarmList) {
- mAlarmList->setModel(mAlarmListModel->sourceModel());
- ClockAlarmListItemPrototype *listItemPrototype =
- new ClockAlarmListItemPrototype(this);
- mAlarmList->setItemPrototype(listItemPrototype);
- mAlarmList->setLayoutName("layout-alarmlist");
- }
-
- qDebug() << "clock: ClockMainView::setmodel <--";
-}
-
-/*!
- Hides the alarmlist in the main view.
-
- \param hide 'true' if alarm list is to be hidden.
- */
-void ClockMainView::hideAlarmList(bool hide)
-{
- qDebug() << "clock: ClockMainView::hideAlarmList -->";
-
- if (hide) {
- mNoAlarmLabel->show();
- mAlarmList->hide();
- mHideAlarmList = true;
- } else {
- mAlarmList->show();
- mNoAlarmLabel->hide();
- mHideAlarmList = false;
- }
-
- qDebug() << "clock: ClockMainView::hideAlarmList <--";
}
/*!
@@ -619,31 +543,16 @@
void ClockMainView::checkOrientationAndLoadSection(
Qt::Orientation orientation)
{
- qDebug() << "clock: ClockMainView::checkOrientationAndLoadSection -->";
-
bool success;
// If horizontal, load the landscape section.
if (Qt::Horizontal == orientation) {
mDocLoader->load(
CLOCK_MAIN_VIEW_DOCML, CLOCK_MAIN_VIEW_LANDSCAPE_SECTION,
&success);
-
- // Display toolbar item's texts
- // TODO have to use text ids from ts file.
- mRefreshMainView->setText(tr("Alarms"));
- mDisplayWorldClockView->setText(tr("World clock"));
- mAddNewAlarm->setText("New alarm");
-
} else {
mDocLoader->load(
CLOCK_MAIN_VIEW_DOCML, CLOCK_MAIN_VIEW_PORTRAIT_SECTION,
&success);
-
- // Remove toolbar item's texts as only icons are shown.
- // TODO have to use text ids from ts file.
- mRefreshMainView->setText(tr(""));
- mDisplayWorldClockView->setText(tr(""));
- mAddNewAlarm->setText("");
}
if(success) {
@@ -656,8 +565,96 @@
hideAlarmList(false);
}
}
+}
- qDebug() << "clock: ClockMainView::checkOrientationAndLoadSection <--";
+/*!
+ Slot to handle context menu actions.
+ */
+void ClockMainView::selectedMenuAction(HbAction *action)
+{
+ if (action == mDeleteAction) {
+ deleteAlarm();
+ }
+}
+
+/*!
+ Slot to handle the context menu closed.
+ */
+void ClockMainView::handleMenuClosed()
+{
+ mIsLongTop = false;
+}
+/*!
+ Sets the model to the alarm list.
+ */
+void ClockMainView::setmodel()
+{
+ // Set the model.
+ if (mAlarmList) {
+ mAlarmList->setModel(mAlarmListModel->sourceModel());
+ ClockAlarmListItemPrototype *listItemPrototype =
+ new ClockAlarmListItemPrototype();
+ connect(
+ listItemPrototype, SIGNAL(alarmStatusHasChanged(int)),
+ this, SLOT(handleAlarmStatusChanged(int)));
+ mAlarmList->setItemPrototype(listItemPrototype);
+ mAlarmList->setLayoutName("layout-alarmlist");
+ }
+
+}
+
+/*!
+ Hides the alarmlist in the main view.
+
+ \param hide 'true' if alarm list is to be hidden.
+ */
+void ClockMainView::hideAlarmList(bool hide)
+{
+ if (hide) {
+ mNoAlarmLabel->show();
+ mAlarmList->hide();
+ mHideAlarmList = true;
+ } else {
+ mAlarmList->show();
+ mNoAlarmLabel->hide();
+ mHideAlarmList = false;
+ }
+}
+
+/*!
+ Updates the day and date in the day label.
+ */
+void ClockMainView::updateDateLabel()
+{
+ // Get the current datetime.
+ QDateTime dateTime = QDateTime::currentDateTime();
+ // Get the day name.
+ QString dayName = dateTime.toString("ddd");
+ // Get the date in correct format.
+ QString currentDate = mSettingsUtility->date();
+ // Construct the day + date string.
+ QString dayDateString;
+ dayDateString+= dayName;
+ dayDateString += " ";
+ dayDateString += currentDate;
+
+ mDayLabel->setPlainText(dayDateString);
+}
+
+/*!
+ Updates the zone info in the place label.
+ */
+/*void ClockMainView::updatePlaceLabel()
+{
+ updatePlaceLabel(mTimezoneClient->timeUpdateOn());
+}*/
+
+/*!
+ Updates the clock widget display.
+ */
+void ClockMainView::updateClockWidget()
+{
+ mClockWidget->updateTime();
}
// End of file --Don't remove.