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