Clean-up.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33576 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jonas Sundström
2009-10-14 00:14:34 +00:00
parent 41426d9bac
commit 3363f0c5bd
6 changed files with 85 additions and 83 deletions
+4 -4
View File
@@ -38,7 +38,7 @@ public:
void UpdateFrom(BMessage* message); void UpdateFrom(BMessage* message);
private: private:
status_t Open(BFile *file, int32 mode); status_t _Open(BFile* file, int32 mode);
BMessage fMessage; BMessage fMessage;
bool fUpdated; bool fUpdated;
@@ -70,7 +70,7 @@ Settings::Settings()
fUpdated(false) fUpdated(false)
{ {
BFile file; BFile file;
if (Open(&file, B_READ_ONLY) != B_OK if (_Open(&file, B_READ_ONLY) != B_OK
|| fMessage.Unflatten(&file) != B_OK) { || fMessage.Unflatten(&file) != B_OK) {
// set default prefs // set default prefs
fMessage.AddString("language", "en"); fMessage.AddString("language", "en");
@@ -86,7 +86,7 @@ Settings::~Settings()
return; return;
BFile file; BFile file;
if (Open(&file, B_CREATE_FILE | B_ERASE_FILE | B_WRITE_ONLY) != B_OK) if (_Open(&file, B_CREATE_FILE | B_ERASE_FILE | B_WRITE_ONLY) != B_OK)
return; return;
fMessage.Flatten(&file); fMessage.Flatten(&file);
@@ -94,7 +94,7 @@ Settings::~Settings()
status_t status_t
Settings::Open(BFile *file, int32 mode) Settings::_Open(BFile* file, int32 mode)
{ {
BPath path; BPath path;
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK) if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK)
+2
View File
@@ -11,9 +11,11 @@
extern const char* kSignature; extern const char* kSignature;
static const uint32 kMsgCountrySelection = 'csel';
static const uint32 kMsgSettingsChanged = 'SeCh'; static const uint32 kMsgSettingsChanged = 'SeCh';
static const uint32 kMsgSelectLanguage = 'slng'; static const uint32 kMsgSelectLanguage = 'slng';
static const uint32 kMsgDefaults = 'dflt'; static const uint32 kMsgDefaults = 'dflt';
static const uint32 kMsgRevert = 'revt'; static const uint32 kMsgRevert = 'revt';
#endif /* LOCALE_H */ #endif /* LOCALE_H */
+7 -8
View File
@@ -395,8 +395,7 @@ LocaleWindow::LocaleWindow()
BListView* listView = new BListView("country", B_SINGLE_SELECTION_LIST); BListView* listView = new BListView("country", B_SINGLE_SELECTION_LIST);
BScrollView* scrollView = new BScrollView("scroller", BScrollView* scrollView = new BScrollView("scroller",
listView, B_WILL_DRAW | B_FRAME_EVENTS, false, true); listView, B_WILL_DRAW | B_FRAME_EVENTS, false, true);
BMessage* msg = new BMessage('csel'); listView->SetSelectionMessage(new BMessage(kMsgCountrySelection));
listView->SetSelectionMessage(msg);
// get all available countries from ICU // get all available countries from ICU
// Use DateFormat::getAvailableLocale so we get only the one we can // Use DateFormat::getAvailableLocale so we get only the one we can
@@ -423,13 +422,13 @@ LocaleWindow::LocaleWindow()
// TODO: find a real solution intead of this hack // TODO: find a real solution intead of this hack
listView->SetExplicitMinSize(BSize(300, B_SIZE_UNSET)); listView->SetExplicitMinSize(BSize(300, B_SIZE_UNSET));
fTimeFormatSettings = new TimeFormatSettingsView(defaultCountry); fFormatView = new FormatView(defaultCountry);
countryTab->AddChild(BLayoutBuilder::Group<>(B_HORIZONTAL, 5) countryTab->AddChild(BLayoutBuilder::Group<>(B_HORIZONTAL, 5)
.AddGroup(B_VERTICAL, 3) .AddGroup(B_VERTICAL, 3)
.Add(scrollView) .Add(scrollView)
.End() .End()
.Add(fTimeFormatSettings) .Add(fFormatView)
.View() .View()
); );
@@ -478,14 +477,14 @@ LocaleWindow::MessageReceived(BMessage *message)
{ {
switch (message->what) { switch (message->what) {
case kMsgDefaults: case kMsgDefaults:
// reset default settings // TODO
break; break;
case kMsgRevert: case kMsgRevert:
// revert to last settings // TODO
break; break;
case 'csel': case kMsgCountrySelection:
{ {
// Country selection changed. // Country selection changed.
// Get the new selected country from the ListView and send it to the // Get the new selected country from the ListView and send it to the
@@ -500,7 +499,7 @@ LocaleWindow::MessageReceived(BMessage *message)
be_app_messenger.SendMessage(newMessage); be_app_messenger.SendMessage(newMessage);
BCountry* country = new BCountry(lli->LanguageCode()); BCountry* country = new BCountry(lli->LanguageCode());
fTimeFormatSettings->SetCountry(country); fFormatView->SetCountry(country);
break; break;
} }
+6 -5
View File
@@ -1,6 +1,6 @@
/* /*
* Copyright 2005, Axel Dörfler, [email protected]. All rights reserved. * Copyright 2005-2009, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License. * All rights reserved. Distributed under the terms of the MIT License.
*/ */
#ifndef LOCALE_WINDOW_H #ifndef LOCALE_WINDOW_H
#define LOCALE_WINDOW_H #define LOCALE_WINDOW_H
@@ -10,7 +10,7 @@
class BButton; class BButton;
class BListView; class BListView;
class TimeFormatSettingsView; class FormatView;
class LocaleWindow : public BWindow { class LocaleWindow : public BWindow {
@@ -23,7 +23,8 @@ class LocaleWindow : public BWindow {
private: private:
BButton* fRevertButton; BButton* fRevertButton;
BListView* fPreferredListView; BListView* fPreferredListView;
TimeFormatSettingsView* fTimeFormatSettings; FormatView* fFormatView;
}; };
#endif /* LOCALE_WINDOW_H */ #endif // LOCALE_WINDOW_H
@@ -38,7 +38,7 @@
BMessage* BMessage*
MenuMessage(const char* format, BMenuField* field) MenuMessage(const char* format, BMenuField* field)
{ {
BMessage* msg = new BMessage('FRMT'); BMessage* msg = new BMessage(kMenuMessage);
msg->AddPointer("dest", field); msg->AddPointer("dest", field);
msg->AddString("format", format); msg->AddString("format", format);
@@ -48,14 +48,15 @@ MenuMessage(const char* format, BMenuField* field)
class DateMenuItem: public BMenuItem { class DateMenuItem: public BMenuItem {
public: public:
DateMenuItem(const char* label, const char* code, BMenuField* field) DateMenuItem(const char* label, const char* code,
BMenuField* field)
: :
BMenuItem(label, MenuMessage(code, field)) BMenuItem(label, MenuMessage(code, field))
{ {
icuCode = code; fIcuCode = code;
} }
BString icuCode; BString fIcuCode;
}; };
@@ -115,7 +116,7 @@ CreateDateMenu(BMenuField** field, bool longFormat = true)
} }
TimeFormatSettingsView::TimeFormatSettingsView(BCountry* country) FormatView::FormatView(BCountry* country)
: :
BView("WindowsSettingsView", B_FRAME_EVENTS), BView("WindowsSettingsView", B_FRAME_EVENTS),
fCountry(country) fCountry(country)
@@ -346,7 +347,7 @@ bool IsSpecialDateChar(char charToTest)
// Get the date format from ICU and set the date fields accordingly // Get the date format from ICU and set the date fields accordingly
void void
TimeFormatSettingsView::_ParseDateFormat() FormatView::_ParseDateFormat()
{ {
// TODO parse the short date too // TODO parse the short date too
BString dateFormatString; BString dateFormatString;
@@ -374,7 +375,7 @@ TimeFormatSettingsView::_ParseDateFormat()
BMenuItem* item; BMenuItem* item;
for (int itemIndex = 0; (item = subMenu->ItemAt(itemIndex)) != NULL; for (int itemIndex = 0; (item = subMenu->ItemAt(itemIndex)) != NULL;
itemIndex++) { itemIndex++) {
if (static_cast<DateMenuItem*>(item)->icuCode == str) { if (static_cast<DateMenuItem*>(item)->fIcuCode == str) {
item->SetMarked(true); item->SetMarked(true);
fLongDateMenu[i]->MenuItem()->SetLabel(item->Label()); fLongDateMenu[i]->MenuItem()->SetLabel(item->Label());
isFound = true; isFound = true;
@@ -426,7 +427,7 @@ TimeFormatSettingsView::_ParseDateFormat()
BMenuItem* item; BMenuItem* item;
for (int itemIndex = 0; (item = subMenu->ItemAt(itemIndex)) != NULL; for (int itemIndex = 0; (item = subMenu->ItemAt(itemIndex)) != NULL;
itemIndex++) { itemIndex++) {
if (static_cast<DateMenuItem*>(item)->icuCode == str) { if (static_cast<DateMenuItem*>(item)->fIcuCode == str) {
item->SetMarked(true); item->SetMarked(true);
fDateMenu[i]->MenuItem()->SetLabel(item->Label()); fDateMenu[i]->MenuItem()->SetLabel(item->Label());
isFound = true; isFound = true;
@@ -459,7 +460,7 @@ TimeFormatSettingsView::_ParseDateFormat()
void void
TimeFormatSettingsView::AttachedToWindow() FormatView::AttachedToWindow()
{ {
f24HrRadioButton->SetTarget(this); f24HrRadioButton->SetTarget(this);
f12HrRadioButton->SetTarget(this); f12HrRadioButton->SetTarget(this);
@@ -480,7 +481,7 @@ TimeFormatSettingsView::AttachedToWindow()
void void
TimeFormatSettingsView::_UpdateLongDateFormatString() FormatView::_UpdateLongDateFormatString()
{ {
BString newDateFormat; BString newDateFormat;
@@ -506,10 +507,10 @@ TimeFormatSettingsView::_UpdateLongDateFormatString()
void void
TimeFormatSettingsView::MessageReceived(BMessage *message) FormatView::MessageReceived(BMessage* message)
{ {
switch (message->what) { switch (message->what) {
case 'FRMT': case kMenuMessage:
{ {
// Update one of the dropdown menus // Update one of the dropdown menus
void* pointerFromMessage; void* pointerFromMessage;
@@ -570,13 +571,13 @@ TimeFormatSettingsView::MessageReceived(BMessage *message)
} }
default: default:
_inherited::MessageReceived(message); BView::MessageReceived(message);
} }
} }
void void
TimeFormatSettingsView::SetDefaults() FormatView::SetDefaults()
{ {
/* /*
TrackerSettings settings; TrackerSettings settings;
@@ -594,7 +595,7 @@ TimeFormatSettingsView::SetDefaults()
bool bool
TimeFormatSettingsView::IsDefaultable() const FormatView::IsDefaultable() const
{ {
/* /*
TrackerSettings settings; TrackerSettings settings;
@@ -608,7 +609,7 @@ TimeFormatSettingsView::IsDefaultable() const
void void
TimeFormatSettingsView::Revert() FormatView::Revert()
{ {
/* /*
TrackerSettings settings; TrackerSettings settings;
@@ -624,7 +625,7 @@ TimeFormatSettingsView::Revert()
void void
TimeFormatSettingsView::_SendNotices() FormatView::_SendNotices()
{ {
// Make the notification message and send it to the tracker: // Make the notification message and send it to the tracker:
/* /*
@@ -638,7 +639,7 @@ TimeFormatSettingsView::_SendNotices()
void void
TimeFormatSettingsView::SetCountry(BCountry* country) FormatView::SetCountry(BCountry* country)
{ {
delete fCountry; delete fCountry;
fCountry = country; fCountry = country;
@@ -658,7 +659,7 @@ TimeFormatSettingsView::SetCountry(BCountry* country)
void void
TimeFormatSettingsView::RecordRevertSettings() FormatView::RecordRevertSettings()
{ {
/* /*
f24HrClock = settings.ClockIs24Hr(); f24HrClock = settings.ClockIs24Hr();
@@ -671,7 +672,7 @@ TimeFormatSettingsView::RecordRevertSettings()
// Return true if the Revert button should be enabled (ie some setting was // Return true if the Revert button should be enabled (ie some setting was
// changed) // changed)
bool bool
TimeFormatSettingsView::IsRevertable() const FormatView::IsRevertable() const
{ {
FormatSeparator separator; FormatSeparator separator;
@@ -697,7 +698,7 @@ TimeFormatSettingsView::IsRevertable() const
void void
TimeFormatSettingsView::_UpdateExamples() FormatView::_UpdateExamples()
{ {
time_t timeValue = (time_t)time(NULL); time_t timeValue = (time_t)time(NULL);
BString timeFormat; BString timeFormat;
@@ -30,11 +30,12 @@ enum FormatSeparator {
}; };
const uint32 kSettingsContentsModified = 'Scmo'; const uint32 kSettingsContentsModified = 'Scmo';
const uint32 kMenuMessage = 'FRMT';
class TimeFormatSettingsView : public BView { class FormatView : public BView {
public: public:
TimeFormatSettingsView(BCountry* country); FormatView(BCountry* country);
virtual void MessageReceived(BMessage* message); virtual void MessageReceived(BMessage* message);
virtual void AttachedToWindow(); virtual void AttachedToWindow();
@@ -80,8 +81,6 @@ private:
BBox* fTimeBox; BBox* fTimeBox;
BBox* fNumbersBox; BBox* fNumbersBox;
BBox* fCurrencyBox; BBox* fCurrencyBox;
typedef BView _inherited;
}; };