KissCount/src/controller/KissCount.cpp

658 lines
16 KiB
C++
Raw Normal View History

2010-07-10 16:34:30 +02:00
/*
2012-02-01 11:02:54 +01:00
Copyright 2010-2012 Grégory Soutadé
2010-07-10 16:34:30 +02:00
This file is part of KissCount.
2010-07-10 16:34:30 +02:00
KissCount is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
2010-07-10 16:34:30 +02:00
KissCount is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
2010-07-10 16:34:30 +02:00
You should have received a copy of the GNU General Public License
along with KissCount. If not, see <http://www.gnu.org/licenses/>.
2010-07-10 16:34:30 +02:00
*/
2011-08-20 11:43:12 +02:00
#include <fstream>
#include <iostream>
#include <algorithm>
2011-08-20 14:02:47 +02:00
#include "KissCount.hpp"
2011-08-20 11:43:12 +02:00
2011-08-20 14:02:47 +02:00
#include <view/view.hpp>
2010-07-04 19:39:39 +02:00
std::vector<ImportEngine*> * KissCount::_importEngines;
std::vector<ExportEngine*> * KissCount::_exportEngines;
2011-03-13 19:15:21 +01:00
2011-09-04 11:21:30 +02:00
KissCount::KissCount(int argc, char** argv) : QApplication(argc, argv), _user(0)
{
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("utf8"));
QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8"));
2011-08-27 18:35:36 +02:00
_wxUI = new wxUI(this, "KissCount");
2011-09-04 11:21:30 +02:00
_wxUI->showMaximized();
_wxUI->setDisabled(true);
try
{
2011-09-04 11:21:30 +02:00
_db = new Database((argc == 2) ? argv[1] : 0, this);
}
catch (std::string s)
{
2011-08-27 18:35:36 +02:00
_wxUI->close();
throw s;
}
2011-03-13 19:15:21 +01:00
_wxUI->ChangeUser();
2011-09-04 11:21:30 +02:00
_wxUI->setDisabled(false);
}
KissCount::~KissCount()
{
delete _db;
delete _wxUI;
delete _importEngines;
delete _exportEngines;
if (_user) delete _user;
}
2011-08-27 18:35:36 +02:00
std::list<QString> KissCount::GetUsers()
{
return _db->GetUsers();
}
2011-08-27 18:35:36 +02:00
bool KissCount::IsValidUser(const QString& user, const QString& password)
{
return _db->IsValidUser(user, password) ;
}
2011-08-27 18:35:36 +02:00
void KissCount::LoadUser(const QString& user)
{
if (_user) delete _user;
_user = _db->LoadUser(user) ;
if (_user)
_wxUI->LoadUser();
2010-05-16 10:35:34 +02:00
}
2010-05-17 18:03:21 +02:00
void KissCount::LoadYear(int year, bool force)
2010-05-16 10:35:34 +02:00
{
2011-08-14 17:47:16 +02:00
if (!force && _user->_operations[year] != 0) return;
2010-05-16 10:35:34 +02:00
2011-08-14 17:47:16 +02:00
if (_user->_operations[year] != 0)
2010-05-16 10:35:34 +02:00
{
delete _user->_operations[year];
2011-08-14 17:47:16 +02:00
_user->_operations[year] = 0;
2010-05-16 10:35:34 +02:00
}
_db->LoadYear(_user, year);
2010-05-16 10:35:34 +02:00
}
2010-05-16 10:35:34 +02:00
User* KissCount::GetUser()
{
return _user;
}
2010-06-02 22:14:11 +02:00
2012-04-30 21:15:51 +02:00
int KissCount::GetAccountAmount(int id, int month, int year, bool* had_value)
2010-06-02 22:14:11 +02:00
{
return _db->GetAccountAmount(id, month, year, had_value);
2010-06-02 22:14:11 +02:00
}
2010-06-03 18:28:38 +02:00
2012-04-30 21:15:51 +02:00
int KissCount::CalcAccountAmount(int id, int month, int year, bool* had_values)
{
return _db->CalcAccountAmount(id, month, year, had_values);
}
void KissCount::UpdateOperation(Operation& op, bool checkTransfert)
2010-06-03 18:28:38 +02:00
{
// Unlink
if (checkTransfert)
{
2011-08-25 17:45:41 +02:00
op.transfert = 0;
_user->LinkOrUnlinkOperation(op);
}
_db->UpdateOperation(_user, op, checkTransfert);
// Link
if (checkTransfert)
_user->LinkOrUnlinkOperation(op);
2010-06-03 18:28:38 +02:00
}
2011-08-25 17:45:41 +02:00
int KissCount::AddOperation(Operation& op, bool checkTransfert)
2010-06-03 18:28:38 +02:00
{
2011-08-25 17:45:41 +02:00
int ret = _db->AddOperation(_user, op, checkTransfert);
2011-08-27 18:35:36 +02:00
if (checkTransfert && op.transfert)
_user->LinkOrUnlinkOperation(op);
return ret;
2010-06-03 18:28:38 +02:00
}
2010-07-05 18:35:12 +02:00
void KissCount::DeleteOperation(Operation& op)
2010-06-03 18:28:38 +02:00
{
2011-08-27 18:35:36 +02:00
if (op.transfert)
{
2011-08-25 17:45:41 +02:00
op.transfert = 0;
_user->LinkOrUnlinkOperation(op);
}
2011-02-14 20:56:59 +01:00
_db->DeleteOperation(_user, op);
2010-06-03 18:28:38 +02:00
}
2010-06-12 15:59:27 +02:00
2010-06-24 21:02:42 +02:00
void KissCount::DeleteOperations(int month, int year)
{
_db->DeleteOperations(_user, month, year);
if (month != -1)
(*_user->_operations[year]).erase(month);
2010-06-24 21:02:42 +02:00
if (month == -1 || !_user->_operations[year]->size())
2010-06-24 21:02:42 +02:00
{
delete _user->_operations[year];
_user->_operations.erase(year);
2010-06-24 21:02:42 +02:00
}
}
2012-04-30 21:15:51 +02:00
int KissCount::MetaAmount(int id)
2010-10-24 16:04:56 +02:00
{
return _db->MetaAmount(id);
}
2012-04-30 21:15:51 +02:00
int KissCount::MetaPositiveAmount(int id)
2010-10-24 16:04:56 +02:00
{
return _db->MetaPositiveAmount(id);
}
2012-04-30 21:15:51 +02:00
void KissCount::SetAccountAmount(int accountId, int month, int year, int amount)
2010-06-12 15:59:27 +02:00
{
_db->SetAccountAmount(accountId, month, year, amount);
2010-06-12 15:59:27 +02:00
}
2010-06-21 10:53:43 +02:00
2011-08-25 17:45:41 +02:00
int KissCount::AddAccount(Account& ac)
2010-06-21 10:53:43 +02:00
{
2011-08-27 18:35:36 +02:00
QDate curDate = QDate::currentDate();
ac.id = _db->AddAccount(_user, ac);
_user->AddAccount(ac);
SetAccountAmount(ac.id, curDate.month()-1, curDate.year(), 0.0);
return ac.id;
2010-06-21 10:53:43 +02:00
}
2010-07-05 18:35:12 +02:00
void KissCount::UpdateAccount(Account& ac)
2010-06-21 10:53:43 +02:00
{
_db->UpdateAccount(ac);
_user->UpdateAccount(ac);
2010-06-21 10:53:43 +02:00
}
2011-08-25 17:45:41 +02:00
void KissCount::DeleteAccount(Account& ac, int replacement)
2010-06-21 10:53:43 +02:00
{
std::map<unsigned int, std::map<unsigned int, std::vector<Operation> >* >::iterator it2;
2010-06-21 13:02:02 +02:00
_db->DeleteAccount(_user, ac, replacement);
_user->DeleteAccount(ac);
for (it2= _user->_operations.begin();
it2 != _user->_operations.end();
it2++)
LoadYear(it2->first, true);
2010-06-21 10:53:43 +02:00
}
2010-06-22 11:35:21 +02:00
2011-08-27 18:35:36 +02:00
void KissCount::AddSharedAccount(Account& ac, const QString& granted)
{
_db->AddSharedAccount(ac, granted);
}
2011-08-27 18:35:36 +02:00
void KissCount::RemoveSharedAccount(Account& ac, int granted)
2010-10-24 16:04:56 +02:00
{
_db->RemoveSharedAccount(ac, granted);
}
2011-08-27 18:35:36 +02:00
std::map<QString, QString> KissCount::getSharedAccountOwners(int account)
2010-10-24 16:04:56 +02:00
{
return _db->getSharedAccountOwners(account);
}
2011-08-27 18:35:36 +02:00
QString KissCount::getSharedAccountOwner(int account)
2010-10-24 16:04:56 +02:00
{
return _db->getSharedAccountOwner(account);
}
2011-08-25 17:45:41 +02:00
int KissCount::AddCategory(Category& category)
2010-06-22 11:35:21 +02:00
{
category.id = _db->AddCategory(_user, category);
_user->AddCategory(category);
2010-06-27 21:39:49 +02:00
return category.id;
2010-06-22 11:35:21 +02:00
}
2010-07-05 18:35:12 +02:00
void KissCount::UpdateCategory(Category& category)
2010-06-22 11:35:21 +02:00
{
_db->UpdateCategory(category);
_user->UpdateCategory(category);
2010-06-22 11:35:21 +02:00
}
2011-08-25 17:45:41 +02:00
void KissCount::DeleteCategory(Category& category, int replacement)
2010-06-22 11:35:21 +02:00
{
std::map<unsigned int, std::map<unsigned int, std::vector<Operation> >* >::iterator it;
_db->DeleteCategory(_user, category, replacement);
_user->DeleteCategory(category);
for (it= _user->_operations.begin();
it != _user->_operations.end();
it++)
LoadYear(it->first, true);
2010-06-22 11:35:21 +02:00
}
2010-06-23 14:25:00 +02:00
std::map<int, std::vector<int> > KissCount::GetAllOperations()
{
return _db->GetAllOperations(_user);
2010-06-23 14:25:00 +02:00
}
2010-06-23 19:32:42 +02:00
void KissCount::GenerateMonth(int monthFrom, int yearFrom, int monthTo, int yearTo)
{
std::vector<Operation>::iterator it, it2;
2011-08-25 17:45:41 +02:00
std::map<int, int> meta;
Operation op;
2010-06-23 19:32:42 +02:00
_db->GenerateMonth(_user, monthFrom, yearFrom, monthTo, yearTo);
2010-06-24 21:02:42 +02:00
if (!_user->_operations[yearTo])
_user->_operations[yearTo] = new std::map<unsigned int, std::vector<Operation> >();
2010-06-24 21:02:42 +02:00
if (monthFrom != -1 && yearFrom != -1)
2010-06-23 19:32:42 +02:00
{
LoadYear(yearFrom, false);
2010-06-24 21:02:42 +02:00
for(it = (*_user->_operations[yearFrom])[monthFrom].begin();
it != (*_user->_operations[yearFrom])[monthFrom].end();
it++)
2010-06-23 19:32:42 +02:00
{
if (!it->fix_cost) continue;
op = *it;
op.month = monthTo;
op.year = yearTo;
2010-09-08 11:02:03 +02:00
op.checked = false;
op.id = AddOperation(op);
op.childs.clear();
2011-02-14 20:56:59 +01:00
op._virtual = false;
if (op.meta)
meta[it->id] = op.id;
(*_user->_operations[yearTo])[monthTo].push_back(op);
2010-06-23 19:32:42 +02:00
}
// Re Generate parents
for(it = (*_user->_operations[yearTo])[monthTo].begin();
it != (*_user->_operations[yearTo])[monthTo].end();
it++)
{
2011-08-27 18:35:36 +02:00
if (it->parent)
{
it->parent = meta[it->parent];
UpdateOperation(*it);
for(it2 = (*_user->_operations[yearTo])[monthTo].begin();
it2 != (*_user->_operations[yearTo])[monthTo].end();
it2++)
if (it2->id == it->parent)
{
it2->childs.push_back(it->id);
break;
}
}
}
2010-06-23 19:32:42 +02:00
}
_wxUI->GenerateMonth(monthTo, yearTo);
2010-06-23 19:32:42 +02:00
}
2010-06-27 21:39:49 +02:00
2011-08-27 18:35:36 +02:00
void KissCount::ChangePassword(const QString& password)
2010-06-27 21:39:49 +02:00
{
_db->ChangePassword(_user, password);
2010-06-27 21:39:49 +02:00
}
2011-08-27 18:35:36 +02:00
bool KissCount::UserExists(const QString& name)
2010-06-27 21:39:49 +02:00
{
return _db->UserExists(name);
2010-06-27 21:39:49 +02:00
}
2011-08-27 18:35:36 +02:00
void KissCount::ChangeName(const QString& name)
2010-06-27 21:39:49 +02:00
{
_db->ChangeName(_user, name);
_user->_name = name;
2010-06-27 21:39:49 +02:00
}
// To enable translation during xgettext
2011-08-27 18:35:36 +02:00
QString default_cats[] = {
_("Fix"), _("Groceries"), _("Hobbies"), _("Car"),
_("Unexpected"), _("Other")
};
2011-08-27 18:35:36 +02:00
void KissCount::NewUser(const QString& name)
2010-06-27 21:39:49 +02:00
{
// QDate curDate = QDate::currentDate();
2010-11-15 13:32:17 +01:00
Account ac = {
2011-08-25 17:45:41 +02:00
/*.id = */0,
2010-11-15 21:12:31 +01:00
/*.name = */_("Account 1"),
2011-08-25 17:45:41 +02:00
/*.number = */0,
2010-11-15 21:12:31 +01:00
/*.shared = */false,
/*.blocked = */false,
/*._default = */true,
/*.is_owner = */true};
Category cat ;
2010-06-27 21:39:49 +02:00
_db->NewUser(name);
if (_user) delete _user;
_user = _db->LoadUser(name) ;
2010-06-27 21:39:49 +02:00
AddAccount(ac);
2011-08-25 17:45:41 +02:00
cat.parent = 0 ; cat.name = "Fix" ; cat.backcolor = view::OWN_YELLOW ; cat.forecolor = Qt::black; cat.fix_cost = true;
AddCategory(cat);
2011-08-25 17:45:41 +02:00
cat.parent = 0 ; cat.name = "Groceries" ; cat.backcolor = view::OWN_GREEN; cat.forecolor = Qt::black; cat.fix_cost = false;
AddCategory(cat);
2011-08-25 17:45:41 +02:00
cat.parent = 0 ; cat.name = "Hobbies" ; cat.backcolor = view::OWN_GREEN; cat.forecolor = Qt::black; cat.fix_cost = false;
AddCategory(cat);
2011-08-25 17:45:41 +02:00
cat.parent = 0 ; cat.name = "Car" ; cat.backcolor = view::OWN_GREEN; cat.forecolor = Qt::black; cat.fix_cost = false;
AddCategory(cat);
2011-08-25 17:45:41 +02:00
cat.parent = 0 ; cat.name = "Unexpected" ; cat.backcolor = view::OWN_GREEN; cat.forecolor = Qt::black; cat.fix_cost = false;
AddCategory(cat);
2011-08-25 17:45:41 +02:00
cat.parent = 0 ; cat.name = "Other" ; cat.backcolor = view::OWN_GREEN; cat.forecolor = Qt::black; cat.fix_cost = false;
AddCategory(cat);
2011-08-25 17:45:41 +02:00
SetOperationOrder("ASC");
2010-06-27 21:39:49 +02:00
}
void KissCount::KillMe()
{
_wxUI->KillMe();
_db->KillMe(_user);
delete _user;
2011-08-14 17:47:16 +02:00
_user = 0;
_wxUI->ChangeUser();
2010-06-27 21:39:49 +02:00
}
2011-08-27 18:35:36 +02:00
void KissCount::SetLanguage(QString language)
{
2011-08-27 18:35:36 +02:00
_user->_preferences["language"] = language;
2011-08-25 17:45:41 +02:00
_db->UpdatePreference(_user, "language");
}
/*
ASC (default) or DESC
*/
2011-08-27 18:35:36 +02:00
void KissCount::SetOperationOrder(const QString& order)
{
2011-08-25 17:45:41 +02:00
_user->_preferences["operation_order"] = order;
_db->UpdatePreference(_user, "operation_order");
}
2011-08-27 18:35:36 +02:00
const QString& KissCount::GetOperationOrder()
{
2011-08-25 17:45:41 +02:00
return _user->_preferences["operation_order"] ;
}
2011-08-27 18:35:36 +02:00
std::vector<Operation>* KissCount::Search(QString* description, QDate* dateFrom, QDate* dateTo,
2012-04-30 21:15:51 +02:00
int* amountFrom, int* amountTo,
2011-08-25 17:45:41 +02:00
std::vector<int> categories, int types, std::vector<int> accounts)
{
return _db->Search(_user, description, dateFrom, dateTo, amountFrom, amountTo, categories, types, accounts, true);
}
bool KissCount::SearchPreviousOperation(Operation* res, Operation& op, int month, int year, bool limitToType, int index)
{
std::vector<Operation>* operations;
//wxDateSpan threeMonths(0, 3); Not working :(
2011-08-27 18:35:36 +02:00
std::vector<int> v;
int i;
month -= 3;
if (month < 0)
{
year -= 1;
month += 12;
}
QDate date = QDate(year, month, 0);
if (limitToType)
operations = _db->Search(_user, &op.description, &date, 0, 0, 0, v, op.fix_cost ? +Database::FIX_OP : +Database::NON_FIX_OP, v, false);
else
operations = _db->Search(_user, &op.description, &date, 0, 0, 0, v, Database::ALL_OP, v, false);
if (!operations->size())
{
delete operations;
return false;
}
for(i=operations->size()-1; i>=0; i--)
if (!(*operations)[i].meta && index--)
{
*res = (*operations)[i];
delete operations;
return true;
}
delete operations;
return false;
}
void KissCount::GetHistory(int month, int year, QStringList& list)
{
month -= 3;
if (month < 0)
{
year -= 1;
month += 12;
}
_db->GetHistory(month, year, list);
}
void KissCount::GetStats(int monthFrom, int yearFrom, int monthTo, int yearTo,
2012-04-30 21:15:51 +02:00
std::map<int, std::map<int, std::map<int, int> > >* accountAmounts,
std::map<int, int>* categories)
{
2011-08-27 18:35:36 +02:00
_db->GetStats(_user, monthFrom, yearFrom, monthTo, yearTo, accountAmounts, categories);
}
2010-11-19 19:58:02 +01:00
void KissCount::GetMonthStats(int month, int year, int nbDays,
2012-04-30 21:15:51 +02:00
std::map<int, std::vector<int> >* operations,
std::map<int, int>* categories)
2010-11-19 19:58:02 +01:00
{
2011-08-27 18:35:36 +02:00
_db->GetMonthStats(_user, month, year, nbDays, operations, categories);
2010-11-19 19:58:02 +01:00
}
void KissCount::UpdateStats()
{
_wxUI->UpdateStats();
}
2010-11-19 19:58:02 +01:00
2012-04-30 21:15:51 +02:00
std::map<int, int>* KissCount::GetNotChecked(int month, int year)
{
return _db->GetNotChecked(_user, month, year);
}
2010-09-08 11:02:03 +02:00
2012-04-30 21:15:51 +02:00
std::map<int, int>* KissCount::GetVirtualAmount(int month, int year)
2011-02-14 20:56:59 +01:00
{
return _db->GetVirtualAmount(_user, month, year);
}
2011-08-27 18:35:36 +02:00
QFont KissCount::ExtractFont(QString strFont)
2010-09-08 11:02:03 +02:00
{
2011-08-27 18:35:36 +02:00
long int pointSize, weight, family, style;
QString faceName;
2010-09-08 11:02:03 +02:00
2011-08-25 17:45:41 +02:00
if (!strFont.size())
2010-09-08 11:02:03 +02:00
{
DEFAULT_FONT(f);
return f;
}
2011-08-27 18:35:36 +02:00
QStringList list = strFont.split(";");
2010-09-08 11:02:03 +02:00
2011-08-27 18:35:36 +02:00
pointSize = list[0].toInt();
family = list[1].toInt();
style = list[2].toInt();
weight = list[3].toInt();
faceName = list[4];
2010-09-08 11:02:03 +02:00
2011-08-25 17:45:41 +02:00
return QFont(faceName, pointSize, weight);
2010-09-08 11:02:03 +02:00
}
2011-08-27 18:35:36 +02:00
QString KissCount::CompactFont(const QFont& font)
2010-09-08 11:02:03 +02:00
{
2011-08-27 18:35:36 +02:00
QString res ;
res = res.sprintf("%d;%d;%d;%d;", font.pointSize(), 0, 0, font.weight());
2011-08-25 17:45:41 +02:00
res += font.family();
2010-09-08 11:02:03 +02:00
2011-08-27 18:35:36 +02:00
return res;
2010-09-08 11:02:03 +02:00
}
2011-03-13 19:15:21 +01:00
void KissCount::UnRegisterImportEngine(ImportEngine* engine)
{
std::vector<ImportEngine*>* importEngines = KissCount::GetImportEngines();
2011-03-13 19:15:21 +01:00
std::vector<ImportEngine*>::iterator it = std::find(importEngines->begin(), importEngines->end(), engine);
if (it!=importEngines->end()) importEngines->erase(it);
2011-03-13 19:15:21 +01:00
}
void KissCount::RegisterImportEngine(ImportEngine* engine)
{
std::vector<ImportEngine*>* importEngines = KissCount::GetImportEngines();
importEngines->push_back(engine);
2011-03-13 19:15:21 +01:00
}
2011-08-27 18:35:36 +02:00
QString KissCount::GetImportEngineExtensions()
2011-03-13 19:15:21 +01:00
{
2011-08-27 18:35:36 +02:00
QString res;
2011-03-13 19:15:21 +01:00
std::vector<ImportEngine*>::iterator it;
int i;
std::vector<ImportEngine*>* importEngines = KissCount::GetImportEngines();
2011-03-13 19:15:21 +01:00
for(i=0; i<(int)importEngines->size()-1; i++)
res = res + (*importEngines)[i]->GetFileExt() + ";;" ;
2011-03-13 19:15:21 +01:00
if (importEngines->size())
res = res + (*importEngines)[i]->GetFileExt();
2011-03-13 19:15:21 +01:00
return res;
}
ImportEngine* KissCount::GetImportEngine(QString path)
2011-03-13 19:15:21 +01:00
{
std::vector<ImportEngine*>::iterator it;
std::vector<ImportEngine*>* importEngines = KissCount::GetImportEngines();
2011-03-13 19:15:21 +01:00
for(it=importEngines->begin(); it!=importEngines->end(); it++)
{
if ((*it)->HandleFile(path, _user, _db, this))
return *it;
}
2011-03-13 19:15:21 +01:00
2011-08-14 17:47:16 +02:00
return 0;
2011-03-13 19:15:21 +01:00
}
2011-03-23 20:35:29 +01:00
void KissCount::UpdateImportPattern()
{
_db->UpdateImportPattern(_user);
}
void KissCount::UnRegisterExportEngine(ExportEngine* engine)
{
std::vector<ExportEngine*>* exportEngines = KissCount::GetExportEngines();
std::vector<ExportEngine*>::iterator it = std::find(exportEngines->begin(), exportEngines->end(), engine);
if (it!=exportEngines->end()) exportEngines->erase(it);
}
void KissCount::RegisterExportEngine(ExportEngine* engine)
{
std::vector<ExportEngine*>* exportEngines = KissCount::GetExportEngines();
exportEngines->push_back(engine);
}
2011-08-27 18:35:36 +02:00
QString KissCount::GetExportEngineExtensions()
{
2011-08-27 18:35:36 +02:00
QString res;
std::vector<ExportEngine*>::iterator it;
int i;
std::vector<ExportEngine*>* exportEngines = KissCount::GetExportEngines();
for(i=0; i<(int)exportEngines->size()-1; i++)
res = res + (*exportEngines)[i]->GetFileExt() + ";;" ;
if (exportEngines->size())
res = res + (*exportEngines)[i]->GetFileExt();
return res;
}
ExportEngine* KissCount::GetExportEngine(QString path, QString filter)
{
std::vector<ExportEngine*>::iterator it;
std::vector<ExportEngine*>* exportEngines = KissCount::GetExportEngines();
QString tmp;
for(it=exportEngines->begin(); it!=exportEngines->end(); it++)
{
if (filter == (*it)->GetFileExt())
{
tmp = path;
if (!tmp.endsWith((*it)->GetShortExt()))
tmp += (*it)->GetShortExt();
if ((*it)->HandleFile(tmp, _user, _db, this))
return *it;
}
}
2011-08-14 17:47:16 +02:00
return 0;
}
std::vector<ImportEngine*>* KissCount::GetImportEngines()
{
if (!_importEngines)
_importEngines = new std::vector<ImportEngine*>;
return _importEngines;
}
std::vector<ExportEngine*>* KissCount::GetExportEngines()
{
if (!_exportEngines)
_exportEngines = new std::vector<ExportEngine*>;
return _exportEngines;
}
bool KissCount::ChangeDatabase(QString filename)
{
return _db->ChangeDatabase(filename);
}
QLocale* KissCount::GetLocale()
{
return _wxUI->GetLocale();
}
QString KissCount::GetDateFormat()
{
return _wxUI->GetDateFormat();
}
QString KissCount::FormatDate(int day, int month, int year)
{
return QDate(year, month, day).toString(_wxUI->GetDateFormat());
}