Create TimeZoneListView class and move GetToolTipAt into it, fixes #7726
Signed-off-by: Matt Madia <[email protected]>
This commit is contained in:
@@ -19,6 +19,7 @@ local sources =
|
|||||||
TimeSettings.cpp
|
TimeSettings.cpp
|
||||||
TimeWindow.cpp
|
TimeWindow.cpp
|
||||||
TimeZoneListItem.cpp
|
TimeZoneListItem.cpp
|
||||||
|
TimeZoneListView.cpp
|
||||||
TZDisplay.cpp
|
TZDisplay.cpp
|
||||||
ZoneView.cpp
|
ZoneView.cpp
|
||||||
;
|
;
|
||||||
@@ -44,5 +45,6 @@ DoCatalogs Time :
|
|||||||
ntp.cpp
|
ntp.cpp
|
||||||
Time.cpp
|
Time.cpp
|
||||||
TimeWindow.cpp
|
TimeWindow.cpp
|
||||||
|
TimeZoneListView.cpp
|
||||||
ZoneView.cpp
|
ZoneView.cpp
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012, Haiku Inc. All rights reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Sean Bailey <[email protected]>
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "TimeZoneListView.h"
|
||||||
|
|
||||||
|
#include <new>
|
||||||
|
|
||||||
|
#include <Catalog.h>
|
||||||
|
#include <Locale.h>
|
||||||
|
#include <String.h>
|
||||||
|
#include <TimeZone.h>
|
||||||
|
#include <ToolTip.h>
|
||||||
|
|
||||||
|
#include "TimeZoneListItem.h"
|
||||||
|
|
||||||
|
|
||||||
|
#undef B_TRANSLATION_CONTEXT
|
||||||
|
#define B_TRANSLATION_CONTEXT "Time"
|
||||||
|
|
||||||
|
|
||||||
|
TimeZoneListView::TimeZoneListView(void)
|
||||||
|
:
|
||||||
|
BOutlineListView("cityList", B_SINGLE_SELECTION_LIST),
|
||||||
|
fToolTip(NULL)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TimeZoneListView::~TimeZoneListView()
|
||||||
|
{
|
||||||
|
if (fToolTip != NULL)
|
||||||
|
fToolTip->ReleaseReference();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
TimeZoneListView::GetToolTipAt(BPoint point, BToolTip** _tip)
|
||||||
|
{
|
||||||
|
TimeZoneListItem* item = static_cast<TimeZoneListItem*>(
|
||||||
|
this->ItemAt(this->IndexOf(point)));
|
||||||
|
if (item == NULL || !item->HasTimeZone())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
BString nowInTimeZone;
|
||||||
|
time_t now = time(NULL);
|
||||||
|
BLocale::Default()->FormatTime(&nowInTimeZone, now, B_SHORT_TIME_FORMAT,
|
||||||
|
&item->TimeZone());
|
||||||
|
|
||||||
|
BString dateInTimeZone;
|
||||||
|
BLocale::Default()->FormatDate(&dateInTimeZone, now, B_SHORT_DATE_FORMAT,
|
||||||
|
&item->TimeZone());
|
||||||
|
|
||||||
|
BString toolTip = item->Text();
|
||||||
|
toolTip << '\n' << item->TimeZone().ShortName() << " / "
|
||||||
|
<< item->TimeZone().ShortDaylightSavingName()
|
||||||
|
<< B_TRANSLATE("\nNow: ") << nowInTimeZone
|
||||||
|
<< " (" << dateInTimeZone << ')';
|
||||||
|
|
||||||
|
if (fToolTip != NULL)
|
||||||
|
fToolTip->ReleaseReference();
|
||||||
|
fToolTip = new (std::nothrow) BTextToolTip(toolTip.String());
|
||||||
|
if (fToolTip == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
*_tip = fToolTip;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2012, Haiku Inc. All rights reserved.
|
||||||
|
* Distributed under the terms of the MIT License.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Sean Bailey <[email protected]>
|
||||||
|
*/
|
||||||
|
#ifndef _TIME_ZONE_LIST_VIEW_H
|
||||||
|
#define _TIME_ZONE_LIST_VIEW_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <OutlineListView.h>
|
||||||
|
|
||||||
|
|
||||||
|
class BTextToolTip;
|
||||||
|
|
||||||
|
|
||||||
|
class TimeZoneListView : public BOutlineListView {
|
||||||
|
public:
|
||||||
|
TimeZoneListView(void);
|
||||||
|
~TimeZoneListView();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual bool GetToolTipAt(BPoint point, BToolTip** _tip);
|
||||||
|
|
||||||
|
private:
|
||||||
|
BTextToolTip* fToolTip;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // _TIME_ZONE_LIST_VIEW_H
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004-2010, Haiku, Inc. All Rights Reserved.
|
* Copyright 2004-2012, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -42,7 +42,6 @@
|
|||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <StringView.h>
|
#include <StringView.h>
|
||||||
#include <TimeZone.h>
|
#include <TimeZone.h>
|
||||||
#include <ToolTip.h>
|
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
@@ -52,6 +51,7 @@
|
|||||||
|
|
||||||
#include "TimeMessages.h"
|
#include "TimeMessages.h"
|
||||||
#include "TimeZoneListItem.h"
|
#include "TimeZoneListItem.h"
|
||||||
|
#include "TimeZoneListView.h"
|
||||||
#include "TZDisplay.h"
|
#include "TZDisplay.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -84,7 +84,6 @@ TimeZoneView::TimeZoneView(const char* name)
|
|||||||
:
|
:
|
||||||
BGroupView(name, B_HORIZONTAL, B_USE_DEFAULT_SPACING),
|
BGroupView(name, B_HORIZONTAL, B_USE_DEFAULT_SPACING),
|
||||||
fGmtTime(NULL),
|
fGmtTime(NULL),
|
||||||
fToolTip(NULL),
|
|
||||||
fUseGmtTime(false),
|
fUseGmtTime(false),
|
||||||
fCurrentZoneItem(NULL),
|
fCurrentZoneItem(NULL),
|
||||||
fOldZoneItem(NULL),
|
fOldZoneItem(NULL),
|
||||||
@@ -107,8 +106,6 @@ TimeZoneView::CheckCanRevert()
|
|||||||
|
|
||||||
TimeZoneView::~TimeZoneView()
|
TimeZoneView::~TimeZoneView()
|
||||||
{
|
{
|
||||||
if (fToolTip != NULL)
|
|
||||||
fToolTip->ReleaseReference();
|
|
||||||
_WriteRTCSettings();
|
_WriteRTCSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,41 +186,6 @@ TimeZoneView::MessageReceived(BMessage* message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
TimeZoneView::GetToolTipAt(BPoint point, BToolTip** _tip)
|
|
||||||
{
|
|
||||||
TimeZoneListItem* item = static_cast<TimeZoneListItem*>(
|
|
||||||
fZoneList->ItemAt(fZoneList->IndexOf(point)));
|
|
||||||
if (item == NULL || !item->HasTimeZone())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
BString nowInTimeZone;
|
|
||||||
time_t now = time(NULL);
|
|
||||||
BLocale::Default()->FormatTime(&nowInTimeZone, now, B_SHORT_TIME_FORMAT,
|
|
||||||
&item->TimeZone());
|
|
||||||
|
|
||||||
BString dateInTimeZone;
|
|
||||||
BLocale::Default()->FormatDate(&dateInTimeZone, now, B_SHORT_DATE_FORMAT,
|
|
||||||
&item->TimeZone());
|
|
||||||
|
|
||||||
BString toolTip = item->Text();
|
|
||||||
toolTip << '\n' << item->TimeZone().ShortName() << " / "
|
|
||||||
<< item->TimeZone().ShortDaylightSavingName()
|
|
||||||
<< B_TRANSLATE("\nNow: ") << nowInTimeZone
|
|
||||||
<< " (" << dateInTimeZone << ')';
|
|
||||||
|
|
||||||
if (fToolTip != NULL)
|
|
||||||
fToolTip->ReleaseReference();
|
|
||||||
fToolTip = new (std::nothrow) BTextToolTip(toolTip.String());
|
|
||||||
if (fToolTip == NULL)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
*_tip = fToolTip;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TimeZoneView::_UpdateDateTime(BMessage* message)
|
TimeZoneView::_UpdateDateTime(BMessage* message)
|
||||||
{
|
{
|
||||||
@@ -243,7 +205,7 @@ TimeZoneView::_UpdateDateTime(BMessage* message)
|
|||||||
void
|
void
|
||||||
TimeZoneView::_InitView()
|
TimeZoneView::_InitView()
|
||||||
{
|
{
|
||||||
fZoneList = new BOutlineListView("cityList", B_SINGLE_SELECTION_LIST);
|
fZoneList = new TimeZoneListView();
|
||||||
fZoneList->SetSelectionMessage(new BMessage(H_CITY_CHANGED));
|
fZoneList->SetSelectionMessage(new BMessage(H_CITY_CHANGED));
|
||||||
fZoneList->SetInvocationMessage(new BMessage(H_SET_TIME_ZONE));
|
fZoneList->SetInvocationMessage(new BMessage(H_SET_TIME_ZONE));
|
||||||
_BuildZoneMenu();
|
_BuildZoneMenu();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004-2011, Haiku, Inc. All Rights Reserved.
|
* Copyright 2004-2012, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -20,9 +20,9 @@ class BMessage;
|
|||||||
class BOutlineListView;
|
class BOutlineListView;
|
||||||
class BPopUpMenu;
|
class BPopUpMenu;
|
||||||
class BRadioButton;
|
class BRadioButton;
|
||||||
class BTextToolTip;
|
|
||||||
class BTimeZone;
|
class BTimeZone;
|
||||||
class TimeZoneListItem;
|
class TimeZoneListItem;
|
||||||
|
class TimeZoneListView;
|
||||||
class TTZDisplay;
|
class TTZDisplay;
|
||||||
|
|
||||||
|
|
||||||
@@ -36,7 +36,6 @@ public:
|
|||||||
bool CheckCanRevert();
|
bool CheckCanRevert();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool GetToolTipAt(BPoint point, BToolTip** _tip);
|
|
||||||
virtual void DoLayout();
|
virtual void DoLayout();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -58,15 +57,13 @@ private:
|
|||||||
|
|
||||||
void _Revert();
|
void _Revert();
|
||||||
|
|
||||||
BOutlineListView* fZoneList;
|
TimeZoneListView* fZoneList;
|
||||||
BButton* fSetZone;
|
BButton* fSetZone;
|
||||||
TTZDisplay* fCurrent;
|
TTZDisplay* fCurrent;
|
||||||
TTZDisplay* fPreview;
|
TTZDisplay* fPreview;
|
||||||
BRadioButton* fLocalTime;
|
BRadioButton* fLocalTime;
|
||||||
BRadioButton* fGmtTime;
|
BRadioButton* fGmtTime;
|
||||||
|
|
||||||
BTextToolTip* fToolTip;
|
|
||||||
|
|
||||||
int32 fLastUpdateMinute;
|
int32 fLastUpdateMinute;
|
||||||
bool fUseGmtTime;
|
bool fUseGmtTime;
|
||||||
bool fOldUseGmtTime;
|
bool fOldUseGmtTime;
|
||||||
|
|||||||
Reference in New Issue
Block a user