Fix a bug : Childs where not linked during import

This commit is contained in:
Grégory Soutadé 2012-02-26 08:59:59 +01:00
parent 7440c632dd
commit 1b378924a3
6 changed files with 30 additions and 2 deletions

View File

@ -182,6 +182,7 @@ bool GrisbiImportEngine::HandleFile(const QString& path, User* user, Database* d
try
{
res = _sax.parse(&file);
LinkChilds();
}
catch (const char* s)
{

View File

@ -323,3 +323,19 @@ const std::map<AccountAmount, double, AccountAmount>& ImportEngine::GetAccountAm
{
return _accountAmounts;
}
void ImportEngine::LinkChilds()
{
std::vector<Operation>::iterator it, it2;
for(it=_operations.begin(); it!=_operations.end(); it++)
{
if (!it->meta) continue;
for(it2=_operations.begin(); it2!=_operations.end(); it2++)
{
if (it == it2 || it2->meta) continue;
if (it2->parent == it->id)
it->childs.push_back(it2->id);
}
}
}

View File

@ -81,6 +81,7 @@ protected:
void ApplyPattern(ImportPattern& pattern, Operation& op);
QString FindPattern(QString& s1, QString& s2);
void LinkChilds();
};
#endif

View File

@ -148,7 +148,13 @@ OFXImportEngine::~OFXImportEngine()
bool OFXImportEngine::HandleFile(const QString& path, User* user, Database* db, KissCount* kiss)
{
int res;
if (!ImportEngine::HandleFile(path, user, db, kiss)) return false;
return !libofx_proc_file(_ctx, path.toStdString().c_str(), AUTODETECT);
res = !libofx_proc_file(_ctx, path.toStdString().c_str(), AUTODETECT);
if (res)
LinkChilds();
return res;
}

View File

@ -54,6 +54,7 @@ bool XMLImportEngine::HandleFile(const QString& path, User* user, Database* db,
try
{
res = _sax.parse(&file);
LinkChilds();
}
catch (const char* s)
{

View File

@ -87,6 +87,9 @@ StatsPanel::StatsPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent),
for(i=0, accountIt = user->_accounts.begin(); accountIt != user->_accounts.end(); accountIt++, i++)
{
item = new QListWidgetItem(accountIt->name, _account);
if (accountIt->hidden)
item->setCheckState (Qt::Unchecked);
else
item->setCheckState (Qt::Checked);
}