Replace GetDateFormat() method by GetDateLocalFormat() cause of Win32
Forgot to set start and end dates when adding an account
This commit is contained in:
parent
b51c4d2d2d
commit
e9ec135b27
|
@ -386,7 +386,12 @@ void KissCount::NewUser(const QString& name)
|
||||||
/*.shared = */false,
|
/*.shared = */false,
|
||||||
/*.blocked = */false,
|
/*.blocked = */false,
|
||||||
/*._default = */true,
|
/*._default = */true,
|
||||||
/*.is_owner = */true};
|
/*.is_owner = */true,
|
||||||
|
/* ._virtual = */false,
|
||||||
|
/* .hidden = */false,
|
||||||
|
/* .start_date = */QDate::currentDate(),
|
||||||
|
/* .end_date = */QDate::currentDate().addYears(50),
|
||||||
|
};
|
||||||
Category cat ;
|
Category cat ;
|
||||||
|
|
||||||
_db->NewUser(name);
|
_db->NewUser(name);
|
||||||
|
@ -717,12 +722,12 @@ QLocale* KissCount::GetLocale()
|
||||||
return _wxUI->GetLocale();
|
return _wxUI->GetLocale();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString KissCount::GetDateFormat()
|
QString KissCount::GetDateLocalFormat()
|
||||||
{
|
{
|
||||||
return _wxUI->GetDateFormat();
|
return _wxUI->GetDateLocalFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString KissCount::FormatDate(int day, int month, int year)
|
QString KissCount::FormatDate(int day, int month, int year)
|
||||||
{
|
{
|
||||||
return QDate(year, month, day).toString(_wxUI->GetDateFormat());
|
return QDate(year, month, day).toString(_wxUI->GetDateLocalFormat());
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,7 +152,7 @@ public:
|
||||||
bool ChangeDatabase(QString filename);
|
bool ChangeDatabase(QString filename);
|
||||||
|
|
||||||
QLocale* GetLocale();
|
QLocale* GetLocale();
|
||||||
QString GetDateFormat();
|
QString GetDateLocalFormat();
|
||||||
QString FormatDate(int day, int month, int year);
|
QString FormatDate(int day, int month, int year);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -96,10 +96,9 @@ void Database::CreateDatabase()
|
||||||
|
|
||||||
if (!init_script.exists() || !init_script.open(QIODevice::ReadOnly | QIODevice::Text))
|
if (!init_script.exists() || !init_script.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||||
{
|
{
|
||||||
QMessageBox::critical(0, _("Error"), _(INIT_SCRIPT " not found, aborting"));
|
QMessageBox::critical(0, _("Error"), INIT_SCRIPT + _(" not found, aborting"));
|
||||||
throw "init.sql not found, aborting";
|
throw "init.sql not found, aborting";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dirname.exists() && !dirname.mkdir(dirname.absolutePath()))
|
if (!dirname.exists() && !dirname.mkdir(dirname.absolutePath()))
|
||||||
{
|
{
|
||||||
QMessageBox::critical(0, _("Error"), _("Unable to Create ") + dirname.absolutePath() );
|
QMessageBox::critical(0, _("Error"), _("Unable to Create ") + dirname.absolutePath() );
|
||||||
|
@ -784,6 +783,7 @@ int Database::AddAccount(User* user, Account& ac)
|
||||||
{
|
{
|
||||||
QString req;
|
QString req;
|
||||||
QSqlQuery query(_db);
|
QSqlQuery query(_db);
|
||||||
|
int id;
|
||||||
|
|
||||||
req = "INSERT INTO account ('user', 'name', 'number', 'shared', 'blocked', 'default_account', 'virtual', 'hidden') VALUES " ;
|
req = "INSERT INTO account ('user', 'name', 'number', 'shared', 'blocked', 'default_account', 'virtual', 'hidden') VALUES " ;
|
||||||
req += "('%1', '%2', '%3', '%4', '%5', '%6', '%7', '%8')";
|
req += "('%1', '%2', '%3', '%4', '%5', '%6', '%7', '%8')";
|
||||||
|
@ -799,7 +799,13 @@ int Database::AddAccount(User* user, Account& ac)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return query.lastInsertId().toInt();
|
id = query.lastInsertId().toInt();
|
||||||
|
req = "UPDATE account SET start='%1', end='%2' WHERE id='%3'";
|
||||||
|
req = req.arg(ac.start_date.toString("yyyy-MM-dd"), ac.end_date.toString("yyyy-MM-dd"), QString::number(id));
|
||||||
|
|
||||||
|
EXECUTE_SQL_UPDATE(req, 0);
|
||||||
|
|
||||||
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Database::UpdateAccount(Account& ac)
|
void Database::UpdateAccount(Account& ac)
|
||||||
|
|
|
@ -104,10 +104,10 @@ PreferencesPanel::PreferencesPanel(KissCount* kiss, wxUI *parent, bool lowResolu
|
||||||
|
|
||||||
_accountsGrid = new QTableWidget();
|
_accountsGrid = new QTableWidget();
|
||||||
|
|
||||||
CalendarDelegate* calendarDelegate = new CalendarDelegate(this, &user->_accounts, true, _kiss->GetDateFormat());
|
CalendarDelegate* calendarDelegate = new CalendarDelegate(this, &user->_accounts, true, _kiss->GetDateLocalFormat());
|
||||||
_accountsGrid->setItemDelegateForColumn(ACCOUNT_START, calendarDelegate);
|
_accountsGrid->setItemDelegateForColumn(ACCOUNT_START, calendarDelegate);
|
||||||
|
|
||||||
calendarDelegate = new CalendarDelegate(this, &user->_accounts, false, _kiss->GetDateFormat());
|
calendarDelegate = new CalendarDelegate(this, &user->_accounts, false, _kiss->GetDateLocalFormat());
|
||||||
_accountsGrid->setItemDelegateForColumn(ACCOUNT_END, calendarDelegate);
|
_accountsGrid->setItemDelegateForColumn(ACCOUNT_END, calendarDelegate);
|
||||||
|
|
||||||
InitAccounts(user);
|
InitAccounts(user);
|
||||||
|
@ -370,8 +370,8 @@ void PreferencesPanel::AddAccount(int line, Account ac)
|
||||||
_hiddenAccountSignalMapper.setMapping(checkBox, ac.id);
|
_hiddenAccountSignalMapper.setMapping(checkBox, ac.id);
|
||||||
connect(checkBox, SIGNAL(stateChanged(int)), &_hiddenAccountSignalMapper, SLOT(map()));
|
connect(checkBox, SIGNAL(stateChanged(int)), &_hiddenAccountSignalMapper, SLOT(map()));
|
||||||
|
|
||||||
_accountsGrid->setItem(line, ACCOUNT_START, new QTableWidgetItem(ac.start_date.toString(_kiss->GetDateFormat())));
|
_accountsGrid->setItem(line, ACCOUNT_START, new QTableWidgetItem(ac.start_date.toString(_kiss->GetDateLocalFormat())));
|
||||||
_accountsGrid->setItem(line, ACCOUNT_END, new QTableWidgetItem(ac.end_date.toString(_kiss->GetDateFormat())));
|
_accountsGrid->setItem(line, ACCOUNT_END, new QTableWidgetItem(ac.end_date.toString(_kiss->GetDateLocalFormat())));
|
||||||
|
|
||||||
for(int i=0; i<NUMBER_COLS_ACCOUNT; i++)
|
for(int i=0; i<NUMBER_COLS_ACCOUNT; i++)
|
||||||
if (!_accountsGrid->item(line, i))
|
if (!_accountsGrid->item(line, i))
|
||||||
|
@ -403,9 +403,9 @@ void PreferencesPanel::AddAccount(int line, Account ac)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QDate date = QDate::currentDate();
|
QDate date = QDate::currentDate();
|
||||||
_accountsGrid->setItem(line, ACCOUNT_START, new QTableWidgetItem(date.toString(_kiss->GetDateFormat())));
|
_accountsGrid->setItem(line, ACCOUNT_START, new QTableWidgetItem(date.toString(_kiss->GetDateLocalFormat())));
|
||||||
date = date.addYears(30);
|
date = date.addYears(30);
|
||||||
_accountsGrid->setItem(line, ACCOUNT_END, new QTableWidgetItem(date.toString(_kiss->GetDateFormat())));
|
_accountsGrid->setItem(line, ACCOUNT_END, new QTableWidgetItem(date.toString(_kiss->GetDateLocalFormat())));
|
||||||
|
|
||||||
for(int i=0; i<NUMBER_COLS_ACCOUNT; i++)
|
for(int i=0; i<NUMBER_COLS_ACCOUNT; i++)
|
||||||
if (!_accountsGrid->item(line, i))
|
if (!_accountsGrid->item(line, i))
|
||||||
|
|
|
@ -261,7 +261,7 @@ void GridAccount::LoadOperations(std::vector<Operation>* operations, int month,
|
||||||
ChoiceDelegate* accountEditor = new ChoiceDelegate(this, _accounts, _nbAccounts);
|
ChoiceDelegate* accountEditor = new ChoiceDelegate(this, _accounts, _nbAccounts);
|
||||||
setItemDelegateForColumn(ACCOUNT, accountEditor);
|
setItemDelegateForColumn(ACCOUNT, accountEditor);
|
||||||
|
|
||||||
DateDelegate* dateEditor = new DateDelegate(this, month+1, year, _kiss->GetDateFormat());
|
DateDelegate* dateEditor = new DateDelegate(this, month+1, year, _kiss->GetDateLocalFormat());
|
||||||
setItemDelegateForColumn(OP_DATE, dateEditor);
|
setItemDelegateForColumn(OP_DATE, dateEditor);
|
||||||
|
|
||||||
FormulaDelegate* formulaEditor = new FormulaDelegate(this, &_displayedOperations);
|
FormulaDelegate* formulaEditor = new FormulaDelegate(this, &_displayedOperations);
|
||||||
|
@ -1011,7 +1011,7 @@ void GridAccount::OnOperationModified(int row, int col)
|
||||||
value = item(row, OP_DATE)->text();
|
value = item(row, OP_DATE)->text();
|
||||||
if (value.length())
|
if (value.length())
|
||||||
{
|
{
|
||||||
date = QDate::fromString(value, _kiss->GetDateFormat());
|
date = QDate::fromString(value, _kiss->GetDateLocalFormat());
|
||||||
new_op.day = date.day()-1;
|
new_op.day = date.day()-1;
|
||||||
new_op.month = date.month()-1;
|
new_op.month = date.month()-1;
|
||||||
new_op.year = date.year();
|
new_op.year = date.year();
|
||||||
|
|
|
@ -378,7 +378,7 @@ void wxUI::NeedReload(KissPanel* panel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString wxUI::GetDateFormat()
|
QString wxUI::GetDateLocalFormat()
|
||||||
{
|
{
|
||||||
return _curLanguage.dateFormat;
|
return _curLanguage.dateFormat;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ public:
|
||||||
void NeedReload(KissPanel* panel);
|
void NeedReload(KissPanel* panel);
|
||||||
|
|
||||||
QLocale* GetLocale() {return _locale;}
|
QLocale* GetLocale() {return _locale;}
|
||||||
QString GetDateFormat();
|
QString GetDateLocalFormat();
|
||||||
|
|
||||||
QString _language;
|
QString _language;
|
||||||
SupportedLanguages::language _curLanguage;
|
SupportedLanguages::language _curLanguage;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user