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