cleanup
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20176 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -49,11 +49,10 @@ TTimeBaseView::SetGMTime(bool gmt)
|
|||||||
void
|
void
|
||||||
TTimeBaseView::DispatchMessage()
|
TTimeBaseView::DispatchMessage()
|
||||||
{
|
{
|
||||||
time_t current;
|
time_t current = time(0);
|
||||||
|
|
||||||
struct tm *ltime;
|
struct tm *ltime;
|
||||||
|
|
||||||
current = time(0);
|
|
||||||
|
|
||||||
if (f_gmtime)
|
if (f_gmtime)
|
||||||
ltime = gmtime(¤t);
|
ltime = gmtime(¤t);
|
||||||
else
|
else
|
||||||
@@ -85,12 +84,8 @@ TTimeBaseView::ChangeTime(BMessage *message)
|
|||||||
if (!(message->FindBool("time", &istime) == B_OK))
|
if (!(message->FindBool("time", &istime) == B_OK))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
time_t atime;
|
time_t atime = time(0);
|
||||||
struct tm *_tm;
|
struct tm *_tm = localtime(&atime);
|
||||||
|
|
||||||
|
|
||||||
atime = time(0);
|
|
||||||
_tm = localtime(&atime);
|
|
||||||
|
|
||||||
int32 hour = 0;
|
int32 hour = 0;
|
||||||
int32 minute = 0;
|
int32 minute = 0;
|
||||||
@@ -121,6 +116,5 @@ TTimeBaseView::ChangeTime(BMessage *message)
|
|||||||
|
|
||||||
time_t atime2 = mktime(_tm);
|
time_t atime2 = mktime(_tm);
|
||||||
set_real_time_clock(atime2);
|
set_real_time_clock(atime2);
|
||||||
DispatchMessage();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,8 +13,7 @@ Preference Time :
|
|||||||
SettingsView.cpp
|
SettingsView.cpp
|
||||||
Time.cpp
|
Time.cpp
|
||||||
TimeSettings.cpp
|
TimeSettings.cpp
|
||||||
TimeView.cpp
|
TimeWindow.cpp
|
||||||
TimeWindow.cpp
|
|
||||||
TZDisplay.cpp
|
TZDisplay.cpp
|
||||||
ZoneView.cpp
|
ZoneView.cpp
|
||||||
: be
|
: be
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ TTZDisplay::SetLabel(const char *label)
|
|||||||
Draw(Bounds());
|
Draw(Bounds());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TTZDisplay::SetText(const char *text)
|
TTZDisplay::SetText(const char *text)
|
||||||
{
|
{
|
||||||
@@ -98,6 +99,7 @@ TTZDisplay::SetText(const char *text)
|
|||||||
Draw(Bounds());
|
Draw(Bounds());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TTZDisplay::SetTo(int32 hour, int32 minute)
|
TTZDisplay::SetTo(int32 hour, int32 minute)
|
||||||
{
|
{
|
||||||
@@ -124,26 +126,26 @@ TTZDisplay::SetTo(int32 hour, int32 minute)
|
|||||||
sprintf(time, "%02lu:%02lu %s", ahour, minute, ap);
|
sprintf(time, "%02lu:%02lu %s", ahour, minute, ap);
|
||||||
f_time->UnlockBuffer(8);
|
f_time->UnlockBuffer(8);
|
||||||
|
|
||||||
Draw(Bounds());
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
TTZDisplay::Text() const
|
TTZDisplay::Text() const
|
||||||
{
|
{
|
||||||
return f_text->String();
|
return f_text->String();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
TTZDisplay::Label() const
|
TTZDisplay::Label() const
|
||||||
{
|
{
|
||||||
return f_label->String();
|
return f_label->String();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
TTZDisplay::Time() const
|
TTZDisplay::Time() const
|
||||||
{
|
{
|
||||||
return f_time->String();
|
return f_time->String();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
#include "BaseView.h"
|
#include "BaseView.h"
|
||||||
#include "Time.h"
|
#include "Time.h"
|
||||||
#include "TimeMessages.h"
|
#include "TimeMessages.h"
|
||||||
#include "TimeView.h"
|
|
||||||
#include "TimeWindow.h"
|
#include "TimeWindow.h"
|
||||||
|
|
||||||
#define TIME_WINDOW_RIGHT 361 //332
|
#define TIME_WINDOW_RIGHT 361 //332
|
||||||
@@ -51,17 +50,16 @@ TTimeWindow::MessageReceived(BMessage *message)
|
|||||||
bool istime;
|
bool istime;
|
||||||
if (message->FindBool("time", &istime) == B_OK)
|
if (message->FindBool("time", &istime) == B_OK)
|
||||||
f_BaseView->ChangeTime(message);
|
f_BaseView->ChangeTime(message);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case H_RTC_CHANGE:
|
case H_RTC_CHANGE:
|
||||||
{
|
|
||||||
f_BaseView->SetGMTime(f_TimeSettings->GMTime());
|
f_BaseView->SetGMTime(f_TimeSettings->GMTime());
|
||||||
}
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BWindow::MessageReceived(message);
|
BWindow::MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,28 +33,29 @@
|
|||||||
|
|
||||||
/*=====> TZoneItem <=====*/
|
/*=====> TZoneItem <=====*/
|
||||||
TZoneItem::TZoneItem(const char *text, const char *zone)
|
TZoneItem::TZoneItem(const char *text, const char *zone)
|
||||||
: BStringItem(text)
|
:BStringItem(text),
|
||||||
|
fZone(new BPath(zone))
|
||||||
{
|
{
|
||||||
f_zone = new BPath(zone);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TZoneItem::~TZoneItem()
|
TZoneItem::~TZoneItem()
|
||||||
{
|
{
|
||||||
delete f_zone;
|
delete fZone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
TZoneItem::Zone() const
|
TZoneItem::Zone() const
|
||||||
{
|
{
|
||||||
return f_zone->Leaf();
|
return fZone->Leaf();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
TZoneItem::Path() const
|
TZoneItem::Path() const
|
||||||
{
|
{
|
||||||
return f_zone->Path();
|
return fZone->Path();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -78,8 +79,7 @@ TZoneView::~TZoneView()
|
|||||||
void
|
void
|
||||||
TZoneView::AllAttached()
|
TZoneView::AllAttached()
|
||||||
{
|
{
|
||||||
|
BView::AllAttached();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -108,14 +108,6 @@ TZoneView::AttachedToWindow()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
TZoneView::Draw(BRect updaterect)
|
|
||||||
{
|
|
||||||
f_current->Draw(updaterect);
|
|
||||||
f_preview->Draw(updaterect);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TZoneView::MessageReceived(BMessage *message)
|
TZoneView::MessageReceived(BMessage *message)
|
||||||
{
|
{
|
||||||
@@ -126,28 +118,28 @@ TZoneView::MessageReceived(BMessage *message)
|
|||||||
switch(change) {
|
switch(change) {
|
||||||
case H_TM_CHANGED:
|
case H_TM_CHANGED:
|
||||||
UpdateDateTime(message);
|
UpdateDateTime(message);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BView::MessageReceived(message);
|
BView::MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case H_REGION_CHANGED:
|
case H_REGION_CHANGED:
|
||||||
ChangeRegion(message);
|
ChangeRegion(message);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case H_SET_TIME_ZONE:
|
case H_SET_TIME_ZONE:
|
||||||
SetTimeZone();
|
SetTimeZone();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case H_CITY_CHANGED:
|
case H_CITY_CHANGED:
|
||||||
SetPreview();
|
SetPreview();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BView::MessageReceived(message);
|
BView::MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,7 +167,7 @@ TZoneView::UpdateDateTime(BMessage *message)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TZoneView:: InitView()
|
TZoneView::InitView()
|
||||||
{
|
{
|
||||||
font_height finfo;
|
font_height finfo;
|
||||||
be_plain_font->GetHeight(&finfo);
|
be_plain_font->GetHeight(&finfo);
|
||||||
@@ -231,13 +223,13 @@ TZoneView:: InitView()
|
|||||||
frame.bottom = frame.top +text_height *2;
|
frame.bottom = frame.top +text_height *2;
|
||||||
frame.right = bounds.right -6;
|
frame.right = bounds.right -6;
|
||||||
f_current = new TTZDisplay(frame, "current",
|
f_current = new TTZDisplay(frame, "current",
|
||||||
B_FOLLOW_LEFT|B_FOLLOW_TOP, 0,
|
B_FOLLOW_LEFT|B_FOLLOW_TOP, B_WILL_DRAW,
|
||||||
"Current time zone:", B_EMPTY_STRING);
|
"Current time zone:", B_EMPTY_STRING);
|
||||||
f_current->ResizeToPreferred();
|
f_current->ResizeToPreferred();
|
||||||
|
|
||||||
frame.OffsetBy(0, (text_height *3) +2);
|
frame.OffsetBy(0, (text_height *3) +2);
|
||||||
f_preview = new TTZDisplay(frame, "timein",
|
f_preview = new TTZDisplay(frame, "timein",
|
||||||
B_FOLLOW_LEFT|B_FOLLOW_TOP, 0,
|
B_FOLLOW_LEFT|B_FOLLOW_TOP, B_WILL_DRAW,
|
||||||
"Time in: ", B_EMPTY_STRING);
|
"Time in: ", B_EMPTY_STRING);
|
||||||
f_preview->ResizeToPreferred();
|
f_preview->ResizeToPreferred();
|
||||||
|
|
||||||
@@ -299,7 +291,8 @@ TZoneView::BuildRegionMenu(float *widest)
|
|||||||
itemtext = itemtext.ReplaceAll('_', ' '); // underscores are spaces
|
itemtext = itemtext.ReplaceAll('_', ' '); // underscores are spaces
|
||||||
|
|
||||||
width = be_plain_font->StringWidth(itemtext.String());
|
width = be_plain_font->StringWidth(itemtext.String());
|
||||||
if (width> *widest) *widest = width;
|
if (width > *widest)
|
||||||
|
*widest = width;
|
||||||
|
|
||||||
BMessage *msg = new BMessage(H_REGION_CHANGED);
|
BMessage *msg = new BMessage(H_REGION_CHANGED);
|
||||||
msg->AddString("region", path.Path());
|
msg->AddString("region", path.Path());
|
||||||
@@ -383,6 +376,16 @@ TZoneView::ChangeRegion(BMessage *message)
|
|||||||
void
|
void
|
||||||
TZoneView::ReadTimeZoneLink()
|
TZoneView::ReadTimeZoneLink()
|
||||||
{
|
{
|
||||||
|
BEntry tzLink;
|
||||||
|
|
||||||
|
#if TARGET_PLATFORM_HAIKU
|
||||||
|
extern status_t _kern_get_tzfilename(char *filename, size_t length, bool *_isGMT);
|
||||||
|
|
||||||
|
char tzFileName[B_OS_PATH_LENGTH];
|
||||||
|
bool isGMT;
|
||||||
|
_kern_get_tzfilename(tzFileName, B_OS_PATH_LENGTH, &isGMT);
|
||||||
|
tzLink.SetTo(tzFileName);
|
||||||
|
#else
|
||||||
/* reads the timezone symlink from B_USER_SETTINGS_DIRECTORY
|
/* reads the timezone symlink from B_USER_SETTINGS_DIRECTORY
|
||||||
currently this sets f_currentzone to the symlink value.
|
currently this sets f_currentzone to the symlink value.
|
||||||
this is wrong. the original can get users timezone without
|
this is wrong. the original can get users timezone without
|
||||||
@@ -393,9 +396,8 @@ TZoneView::ReadTimeZoneLink()
|
|||||||
EST is set when the settings dir can't be found **should never happen**
|
EST is set when the settings dir can't be found **should never happen**
|
||||||
*/
|
*/
|
||||||
|
|
||||||
BPath path;
|
|
||||||
BEntry tzLink;
|
|
||||||
|
|
||||||
|
BPath path;
|
||||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) {
|
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) {
|
||||||
|
|
||||||
path.Append("timezone");
|
path.Append("timezone");
|
||||||
@@ -409,7 +411,7 @@ TZoneView::ReadTimeZoneLink()
|
|||||||
// set tzlink to a default
|
// set tzlink to a default
|
||||||
tzLink.SetTo("/boot/beos/etc/timezones/EST");
|
tzLink.SetTo("/boot/beos/etc/timezones/EST");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
// we need something in the current zone
|
// we need something in the current zone
|
||||||
f_currentzone.SetTo(&tzLink);
|
f_currentzone.SetTo(&tzLink);
|
||||||
}
|
}
|
||||||
@@ -446,11 +448,9 @@ TZoneView::SetPreview()
|
|||||||
void
|
void
|
||||||
TZoneView::SetCurrent(const char *text)
|
TZoneView::SetCurrent(const char *text)
|
||||||
{
|
{
|
||||||
time_t current;
|
|
||||||
struct tm *ltime;
|
|
||||||
SetTimeZone(f_currentzone.Path());
|
SetTimeZone(f_currentzone.Path());
|
||||||
current = time(0);
|
time_t current = time(0);
|
||||||
ltime = localtime(¤t);
|
struct tm *ltime = localtime(¤t);
|
||||||
|
|
||||||
f_current->SetTo(ltime->tm_hour, ltime->tm_min);
|
f_current->SetTo(ltime->tm_hour, ltime->tm_min);
|
||||||
f_current->SetText(text);
|
f_current->SetText(text);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class TZoneItem: public BStringItem {
|
|||||||
const char *Path() const;
|
const char *Path() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BPath *f_zone;
|
BPath *fZone;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -36,7 +36,6 @@ class TZoneView: public BView{
|
|||||||
|
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void AllAttached();
|
virtual void AllAttached();
|
||||||
virtual void Draw(BRect);
|
|
||||||
virtual void MessageReceived(BMessage *message);
|
virtual void MessageReceived(BMessage *message);
|
||||||
protected:
|
protected:
|
||||||
void UpdateDateTime(BMessage *message);
|
void UpdateDateTime(BMessage *message);
|
||||||
|
|||||||
Reference in New Issue
Block a user