2 * Copyright 2012, Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Sean Bailey <ziusudra@gmail.com>
10 #include "TimeZoneListView.h"
15 #include <DateFormat.h>
21 #include "TimeZoneListItem.h"
24 #undef B_TRANSLATION_CONTEXT
25 #define B_TRANSLATION_CONTEXT "Time"
28 TimeZoneListView::TimeZoneListView(void)
30 BOutlineListView("cityList", B_SINGLE_SELECTION_LIST
)
35 TimeZoneListView::~TimeZoneListView()
41 TimeZoneListView::GetToolTipAt(BPoint point
, BToolTip
** _tip
)
43 TimeZoneListItem
* item
= static_cast<TimeZoneListItem
*>(
44 this->ItemAt(this->IndexOf(point
)));
45 if (item
== NULL
|| !item
->HasTimeZone())
48 BString nowInTimeZone
;
49 time_t now
= time(NULL
);
50 fTimeFormat
.Format(nowInTimeZone
, now
, B_SHORT_TIME_FORMAT
,
53 BString dateInTimeZone
;
54 fDateFormat
.Format(dateInTimeZone
, now
, B_SHORT_DATE_FORMAT
,
57 BString toolTip
= item
->Text();
58 toolTip
<< '\n' << item
->TimeZone().ShortName() << " / "
59 << item
->TimeZone().ShortDaylightSavingName()
60 << B_TRANSLATE("\nNow: ") << nowInTimeZone
61 << " (" << dateInTimeZone
<< ')';
63 SetToolTip(toolTip
.String());