diff --git a/src/CBLocale.h b/src/CBLocale.h index 96cf91e..df8469a 100644 --- a/src/CBLocale.h +++ b/src/CBLocale.h @@ -30,10 +30,6 @@ class Locale { status_t StringToDate(const char* instring, time_t& date); void NumberToCurrency(const Fixed& number, BString& string); - void SetDateFormat(const date_format& format); - - date_format DateFormat(void) const { return fDateFormat; } - void SetCurrencySymbol(const char* symbol); const char* CurrencySymbol(void) const { return fCurrencySymbol.String(); } @@ -54,10 +50,6 @@ class Locale { uint8 CurrencyDecimalPlace(void) const { return fCurrencyDecimalPlace; } - void SetDateSeparator(const char* symbol); - - const char* DateSeparator(void) const { return fDateSeparator.String(); } - void SetDST(const bool& value); bool UseDST(void) const { return fUseDST; } @@ -69,14 +61,10 @@ class Locale { status_t ConstructDateStringMDY(const char* in, BString& out); status_t ConstructDateStringDMY(const char* in, BString& out); - // Like BeFinancial, we just use two different date formats: mmddyyyy (0) and - // ddmmyyyy (1) - date_format fDateFormat; BString fCurrencySymbol; bool fPrefixSymbol; BString fCurrencySeparator; BString fCurrencyDecimal; - BString fDateSeparator; uint8 fCurrencyDecimalPlace; bool fUseDST; }; @@ -86,7 +74,6 @@ void ShowBug(const char* string); void GetVersionString(BString& string); void CapitalizeEachWord(BString& string); const char* GetCurrencyOnlyMask(void); -const char* GetDateOnlyMask(void); void IllegalCharsToEntities(BString* string); #endif diff --git a/src/Database.cpp b/src/Database.cpp index 7ca2260..a47f723 100644 --- a/src/Database.cpp +++ b/src/Database.cpp @@ -558,11 +558,11 @@ Database::SetAccountLocale(const uint32& accountid, const Locale& data) command << accountid << ";"; CppSQLite3Query query = DBQuery(command.String(), "Database::SetAccountLocale:find accountid"); + // Todo: remove table columns for date format if (query.eof()) { - command << "insert into accountlocale values(" << accountid << ",'" - << (data.DateFormat() == DATE_DMY ? "ddmmyyyy" : "mmddyyyy") << "','" - << data.DateSeparator() << "','" << data.CurrencySymbol() << "','" - << data.CurrencySeparator() << "','" << data.CurrencyDecimal() << "','" + command << "insert into accountlocale values(" << accountid << ",'ddmmyyyy','/','" + << data.CurrencySymbol() << "','" << data.CurrencySeparator() << "','" + << data.CurrencyDecimal() << "','" << (data.IsCurrencySymbolPrefix() ? "true" : "false") << "');"; DBCommand(command.String(), "Database::SetAccountLocale:insert into accountlocale"); UNLOCK; @@ -572,13 +572,12 @@ Database::SetAccountLocale(const uint32& accountid, const Locale& data) query.finalize(); // This already has the locale data in the table, so we'll just update it and return - command << "update accountlocale set dateformat = '" - << (data.DateFormat() == 1 ? "ddmmyyyy" : "mmddyyyy") - << "' where accountid = " << accountid << ";"; + command << "update accountlocale set dateformat = 'ddmmyyyy' where accountid = " << accountid + << ";"; DBCommand(command.String(), "Database::SetAccountLocale:update dateformat"); - command << "update accountlocale set dateseparator = '" << data.DateSeparator() - << "' where accountid = " << accountid << ";"; + command << "update accountlocale set dateseparator = '/' where accountid = " << accountid + << ";"; DBCommand(command.String(), "Database::SetAccountLocale:update dateseparator"); command << "update accountlocale set currencysymbol = '" << data.CurrencySymbol() @@ -615,8 +614,6 @@ Database::LocaleForAccount(const uint32& id) } BString temp = query.getStringField(1); - locale.SetDateFormat((temp.Compare("ddmmyyyy") == 0) ? DATE_DMY : DATE_MDY); - locale.SetDateSeparator(query.getStringField(2)); locale.SetCurrencySymbol(query.getStringField(3)); locale.SetCurrencySeparator(query.getStringField(4)); locale.SetCurrencyDecimal(query.getStringField(5)); @@ -633,13 +630,6 @@ Database::SetDefaultLocale(const Locale& data) BString command; // This already has the locale data in the table, so we'll just update it and return - command << "update defaultlocale set dateformat = '" - << (data.DateFormat() == DATE_MDY ? "mmddyyyy" : "ddmmyyyy") << "';"; - DBCommand(command.String(), "Database::SetAccountLocale:update dateformat"); - - command << "update defaultlocale set dateseparator = '" << data.DateSeparator() << "';"; - DBCommand(command.String(), "Database::SetAccountLocale:update dateseparator"); - command << "update defaultlocale set currencysymbol = '" << data.CurrencySymbol() << "';"; DBCommand(command.String(), "Database::SetAccountLocale:update currencysymbol"); @@ -672,8 +662,6 @@ Database::GetDefaultLocale(void) } BString temp = query.getStringField(0); - locale.SetDateFormat((temp.Compare("ddmmyyyy") == 0) ? DATE_DMY : DATE_MDY); - locale.SetDateSeparator(query.getStringField(1)); locale.SetCurrencySymbol(query.getStringField(2)); locale.SetCurrencySeparator(query.getStringField(3)); locale.SetCurrencyDecimal(query.getStringField(4)); diff --git a/src/DateBox.cpp b/src/DateBox.cpp index 0354efa..913b779 100644 --- a/src/DateBox.cpp +++ b/src/DateBox.cpp @@ -98,9 +98,8 @@ DateBox::DateBox(const char* name, const char* label, const char* text, BMessage SetFilter(new DateBoxFilter(this)); fCurrentDate = GetCurrentDate(); - const char date_disallowed[] = - "`~!@#$%^&*()_=QWERTYUIOP{[}]|\\ASDFGHJKL;:'\"" - "ZXCVBNM,<>?qwertyuiopasdfghjklzxcvbnm"; + const char date_disallowed[] = "`~!@#$%^&*()_=QWERTYUIOP{[}]|\\ASDFGHJKL;:'\"" + "ZXCVBNM,<>?qwertyuiopasdfghjklzxcvbnm"; int32 i = 0; while (date_disallowed[i]) { TextView()->DisallowChar(date_disallowed[i]); diff --git a/src/Locale.cpp b/src/Locale.cpp index dd613c9..ce0b63b 100644 --- a/src/Locale.cpp +++ b/src/Locale.cpp @@ -1,3 +1,5 @@ +#include "App.h" +#include "CBLocale.h" #include #include #include @@ -11,8 +13,6 @@ #include #include #include -#include "App.h" -#include "CBLocale.h" #undef B_TRANSLATION_CONTEXT #define B_TRANSLATION_CONTEXT "Locale" @@ -34,11 +34,12 @@ Locale::operator!=(const Locale& other) const bool Locale::operator==(const Locale& other) const { - if (fDateFormat != other.fDateFormat || fCurrencySymbol != other.fCurrencySymbol || - fPrefixSymbol != other.fPrefixSymbol || fCurrencySeparator != other.fCurrencySeparator || - fCurrencyDecimal != other.fCurrencyDecimal || fDateSeparator != other.fDateSeparator || - fCurrencyDecimalPlace != other.fCurrencyDecimalPlace || fUseDST != other.fUseDST) + if (fCurrencySymbol != other.fCurrencySymbol || fPrefixSymbol != other.fPrefixSymbol + || fCurrencySeparator != other.fCurrencySeparator + || fCurrencyDecimal != other.fCurrencyDecimal + || fCurrencyDecimalPlace != other.fCurrencyDecimalPlace || fUseDST != other.fUseDST) { return false; + } return true; } @@ -47,15 +48,11 @@ Locale::Flatten(BFile* file) { BString str("\t\n"); - if (fDateFormat == DATE_MDY) - str << "\t\t\n"; - else - str << "\t\t\n"; + str << "\t\t\n"; str << "\t\t\n"; str << "\t\t\n"; str << "\t\t\n"; - str << "\t\t\n"; if (!fPrefixSymbol) str << "\t\t\n"; @@ -165,7 +162,7 @@ Locale::DateToString(time_t date, BString& string) status_t Locale::StringToDate(const char* instring, time_t& date) { - if (!instring || (fDateFormat != DATE_MDY && fDateFormat != DATE_DMY)) + if (!instring) return B_BAD_VALUE; BDateFormat dateFormatter; @@ -209,16 +206,15 @@ Locale::NumberToCurrency(const Fixed& number, BString& string) void Locale::SetDefaults(void) { - fDateFormat = DATE_MDY; fCurrencySymbol = "$"; fPrefixSymbol = true; fCurrencySeparator = ","; fCurrencyDecimal = "."; - fDateSeparator = "/"; fCurrencyDecimalPlace = 2; fUseDST = false; } + void ShowAlert(const char* header, const char* message, alert_type type) { @@ -345,11 +341,6 @@ CapitalizeEachWord(BString& string) string.UnlockBuffer(); } -void -Locale::SetDateFormat(const date_format& format) -{ - fDateFormat = format; -} void Locale::SetCurrencySymbol(const char* symbol) @@ -384,12 +375,6 @@ Locale::SetCurrencyDecimalPlace(const uint8& place) fCurrencyDecimalPlace = place; } -void -Locale::SetDateSeparator(const char* symbol) -{ - if (symbol) - fDateSeparator = symbol; -} void Locale::SetDST(const bool& value) @@ -405,11 +390,6 @@ GetCurrencyOnlyMask(void) "à¡™∞ô¶•«»–≠œ∑鮆øπ‘¬å∫∂ƒ©Ωfi∆◊æäñ≈ç√ßñµ…÷"; } -const char* -GetDateOnlyMask(void) -{ - return "`~!@#$%^&*()_=QWERTYUIOP{[}]|\\ASDFGHJKL;:'\"ZXCVBNM,.<>?qwertyuiopasdfghjklzxcvbnm"; -} void IllegalCharsToEntities(BString* string) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 9951eec..655aefe 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -30,8 +30,6 @@ #include "ScheduleAddWindow.h" #include "ScheduleListWindow.h" #include "ScheduledExecutor.h" -#include "StringView.h" -#include "TextControl.h" #include "TransactionEditWindow.h" #include "TransferWindow.h" diff --git a/src/NetWorthReport.cpp b/src/NetWorthReport.cpp index 939f10a..0a6d06d 100644 --- a/src/NetWorthReport.cpp +++ b/src/NetWorthReport.cpp @@ -8,6 +8,7 @@ #include "TimeSupport.h" #include +#include #undef B_TRANSLATION_CONTEXT @@ -64,16 +65,9 @@ ReportWindow::ComputeNetWorth(void) char rowtitle[128]; struct tm* timestruct = localtime(&subtotal_start); - BString formatstring; - if (gCurrentLocale.DateFormat() == DATE_MDY) { - formatstring << "%m" << gCurrentLocale.DateSeparator() << "%d" - << gCurrentLocale.DateSeparator() << "%Y"; - } else { - formatstring << "%d" << gCurrentLocale.DateSeparator() << "%m" - << gCurrentLocale.DateSeparator() << "%Y"; - } - strftime(rowtitle, 128, formatstring.String(), timestruct); - accountgrid.SetRowTitle(subtotal_index, rowtitle); + BString datestring; + gDefaultLocale.DateToString(subtotal_start, datestring); + accountgrid.SetRowTitle(subtotal_index, datestring); int length = strlen(rowtitle); if (length > longestnamelength) { diff --git a/src/PrefWindow.cpp b/src/PrefWindow.cpp index 46f1131..085430e 100644 --- a/src/PrefWindow.cpp +++ b/src/PrefWindow.cpp @@ -19,8 +19,6 @@ // PrefView enum { - M_NEW_DATE_SEPARATOR, - M_NEW_CURRENCY_SYMBOL, M_NEW_CURRENCY_SEPARATOR, M_NEW_CURRENCY_DECIMAL, @@ -44,8 +42,7 @@ PrefWindow::PrefWindow(const BRect& frame) fCurrencyPrefView = new CurrencyPrefView("dateview", &gDefaultLocale); - fOK = new BButton("okbutton", B_TRANSLATE("Cancel"), new BMessage(M_EDIT_OPTIONS)); - fOK->SetLabel(B_TRANSLATE("OK")); + fOK = new BButton("okbutton", B_TRANSLATE("OK"), new BMessage(M_EDIT_OPTIONS)); BButton* cancel = new BButton("cancelbutton", B_TRANSLATE("Cancel"), new BMessage(B_QUIT_REQUESTED)); @@ -60,7 +57,6 @@ PrefWindow::PrefWindow(const BRect& frame) .Add(fLabel) .AddGlue() .End() - .Add(fCurrencyPrefView) .AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING) .AddGlue() @@ -69,8 +65,8 @@ PrefWindow::PrefWindow(const BRect& frame) .End() .End(); // clang on - - CenterIn(Frame()); + ResizeToPreferred(); + CenterIn(frame); } void @@ -102,7 +98,6 @@ CurrencyPrefView::CurrencyPrefView(const char* name, Locale* locale, const int32 fSampleAmount((long)12345678, true) { BString temp; - SetViewUIColor(B_PANEL_BACKGROUND_COLOR); if (locale) fLocale = *locale;