Some modification where not commited previously ???
This commit is contained in:
parent
40ca2a0f25
commit
ebe9ef4a62
|
@ -19,7 +19,8 @@
|
||||||
|
|
||||||
#include "KissCount.h"
|
#include "KissCount.h"
|
||||||
|
|
||||||
std::vector<ImportEngine*> KissCount::_importEngines;
|
std::vector<ImportEngine*> * KissCount::_importEngines;
|
||||||
|
std::vector<ExportEngine*> * KissCount::_exportEngines;
|
||||||
|
|
||||||
KissCount::KissCount(const char* bdd_filename) : _user(NULL)
|
KissCount::KissCount(const char* bdd_filename) : _user(NULL)
|
||||||
{
|
{
|
||||||
|
@ -51,6 +52,9 @@ KissCount::~KissCount()
|
||||||
{
|
{
|
||||||
delete _db;
|
delete _db;
|
||||||
delete _wxUI;
|
delete _wxUI;
|
||||||
|
delete _importEngines;
|
||||||
|
delete _exportEngines;
|
||||||
|
|
||||||
if (_user) delete _user;
|
if (_user) delete _user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -568,18 +572,21 @@ wxString KissCount::CompactFont(const wxFont& font)
|
||||||
void KissCount::UnRegisterImportEngine(ImportEngine* engine)
|
void KissCount::UnRegisterImportEngine(ImportEngine* engine)
|
||||||
{
|
{
|
||||||
std::vector<ImportEngine*>::iterator it;
|
std::vector<ImportEngine*>::iterator it;
|
||||||
|
std::vector<ImportEngine*>* importEngines = KissCount::GetImportEngines();
|
||||||
|
|
||||||
for(it=_importEngines.begin(); it!=_importEngines.end(); it++)
|
for(it=importEngines->begin(); it!=importEngines->end(); it++)
|
||||||
if (*it == engine)
|
if (*it == engine)
|
||||||
{
|
{
|
||||||
_importEngines.erase(it);
|
importEngines->erase(it);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KissCount::RegisterImportEngine(ImportEngine* engine)
|
void KissCount::RegisterImportEngine(ImportEngine* engine)
|
||||||
{
|
{
|
||||||
_importEngines.push_back(engine);
|
std::vector<ImportEngine*>* importEngines = KissCount::GetImportEngines();
|
||||||
|
|
||||||
|
importEngines->push_back(engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString KissCount::GetImportEngineExtensions()
|
wxString KissCount::GetImportEngineExtensions()
|
||||||
|
@ -587,12 +594,13 @@ wxString KissCount::GetImportEngineExtensions()
|
||||||
wxString res;
|
wxString res;
|
||||||
std::vector<ImportEngine*>::iterator it;
|
std::vector<ImportEngine*>::iterator it;
|
||||||
int i;
|
int i;
|
||||||
|
std::vector<ImportEngine*>* importEngines = KissCount::GetImportEngines();
|
||||||
|
|
||||||
for(i=0; i<(int)_importEngines.size()-1; i++)
|
for(i=0; i<(int)importEngines->size()-1; i++)
|
||||||
res = res + _importEngines[i]->GetFileExt() + wxT("|") ;
|
res = res + (*importEngines)[i]->GetFileExt() + wxT("|") ;
|
||||||
|
|
||||||
if (_importEngines.size())
|
if (importEngines->size())
|
||||||
res = res + _importEngines[i]->GetFileExt();
|
res = res + (*importEngines)[i]->GetFileExt();
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -600,8 +608,9 @@ wxString KissCount::GetImportEngineExtensions()
|
||||||
ImportEngine* KissCount::GetImportEngine(wxString path)
|
ImportEngine* KissCount::GetImportEngine(wxString path)
|
||||||
{
|
{
|
||||||
std::vector<ImportEngine*>::iterator it;
|
std::vector<ImportEngine*>::iterator it;
|
||||||
|
std::vector<ImportEngine*>* importEngines = KissCount::GetImportEngines();
|
||||||
|
|
||||||
for(it=_importEngines.begin(); it!=_importEngines.end(); it++)
|
for(it=importEngines->begin(); it!=importEngines->end(); it++)
|
||||||
if ((*it)->HandleFile(path, _user, _db, this))
|
if ((*it)->HandleFile(path, _user, _db, this))
|
||||||
return *it;
|
return *it;
|
||||||
|
|
||||||
|
@ -612,3 +621,67 @@ void KissCount::UpdateImportPattern()
|
||||||
{
|
{
|
||||||
_db->UpdateImportPattern(_user);
|
_db->UpdateImportPattern(_user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KissCount::UnRegisterExportEngine(ExportEngine* engine)
|
||||||
|
{
|
||||||
|
std::vector<ExportEngine*>::iterator it;
|
||||||
|
std::vector<ExportEngine*>* exportEngines = KissCount::GetExportEngines();
|
||||||
|
|
||||||
|
for(it=exportEngines->begin(); it!=exportEngines->end(); it++)
|
||||||
|
if (*it == engine)
|
||||||
|
{
|
||||||
|
exportEngines->erase(it);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void KissCount::RegisterExportEngine(ExportEngine* engine)
|
||||||
|
{
|
||||||
|
std::vector<ExportEngine*>* exportEngines = KissCount::GetExportEngines();
|
||||||
|
|
||||||
|
exportEngines->push_back(engine);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString KissCount::GetExportEngineExtensions()
|
||||||
|
{
|
||||||
|
wxString 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() + wxT("|") ;
|
||||||
|
|
||||||
|
if (exportEngines->size())
|
||||||
|
res = res + (*exportEngines)[i]->GetFileExt();
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
ExportEngine* KissCount::GetExportEngine(wxString path)
|
||||||
|
{
|
||||||
|
std::vector<ExportEngine*>::iterator it;
|
||||||
|
std::vector<ExportEngine*>* exportEngines = KissCount::GetExportEngines();
|
||||||
|
|
||||||
|
for(it=exportEngines->begin(); it!=exportEngines->end(); it++)
|
||||||
|
if ((*it)->HandleFile(path, _user, _db, this))
|
||||||
|
return *it;
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
#include <model/import/ImportEngine.h>
|
#include <model/import/ImportEngine.h>
|
||||||
|
#include <model/export/ExportEngine.h>
|
||||||
#include <model/model.h>
|
#include <model/model.h>
|
||||||
#include <view/wxUI.h>
|
#include <view/wxUI.h>
|
||||||
|
|
||||||
|
@ -32,9 +33,17 @@
|
||||||
|
|
||||||
#define APP_VERSION "0.2"
|
#define APP_VERSION "0.2"
|
||||||
|
|
||||||
|
#define ESCAPE_CHARS(s) { \
|
||||||
|
if (s.Find(wxT("\\\"")) == wxNOT_FOUND) \
|
||||||
|
s.Replace(wxT("\""), wxT("\\\""), true); \
|
||||||
|
if (s.Find(wxT("\\\'")) == wxNOT_FOUND) \
|
||||||
|
s.Replace(wxT("\'"), wxT("\\\'"), true); \
|
||||||
|
}
|
||||||
|
|
||||||
class wxUI;
|
class wxUI;
|
||||||
class Database;
|
class Database;
|
||||||
class ImportEngine;
|
class ImportEngine;
|
||||||
|
class ExportEngine;
|
||||||
|
|
||||||
class KissCount
|
class KissCount
|
||||||
{
|
{
|
||||||
|
@ -111,12 +120,24 @@ public:
|
||||||
wxString GetImportEngineExtensions();
|
wxString GetImportEngineExtensions();
|
||||||
ImportEngine* GetImportEngine(wxString path);
|
ImportEngine* GetImportEngine(wxString path);
|
||||||
|
|
||||||
|
static void RegisterExportEngine(ExportEngine* engine);
|
||||||
|
static void UnRegisterExportEngine(ExportEngine* engine);
|
||||||
|
|
||||||
|
wxString GetExportEngineExtensions();
|
||||||
|
ExportEngine* GetExportEngine(wxString path);
|
||||||
|
|
||||||
void UpdateImportPattern();
|
void UpdateImportPattern();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxUI* _wxUI;
|
wxUI* _wxUI;
|
||||||
Database* _db;
|
Database* _db;
|
||||||
User* _user;
|
User* _user;
|
||||||
static std::vector<ImportEngine*> _importEngines;
|
|
||||||
|
static std::vector<ImportEngine*> *GetImportEngines();
|
||||||
|
static std::vector<ExportEngine*> *GetExportEngines();
|
||||||
|
|
||||||
|
static std::vector<ImportEngine*> *_importEngines;
|
||||||
|
static std::vector<ExportEngine*> *_exportEngines;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1498,6 +1498,7 @@ std::vector<Operation>* Database::Search(User* user, wxString* description, wxDa
|
||||||
op.transfert = set.GetAsString(wxT("transfert"));
|
op.transfert = set.GetAsString(wxT("transfert"));
|
||||||
op.formula = set.GetAsString(wxT("formula"));
|
op.formula = set.GetAsString(wxT("formula"));
|
||||||
op.meta = set.GetBool(wxT("meta"));
|
op.meta = set.GetBool(wxT("meta"));
|
||||||
|
op._virtual = set.GetBool(wxT("virtual"));
|
||||||
res->push_back(op);
|
res->push_back(op);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
#include <wx/file.h>
|
#include <wx/file.h>
|
||||||
#include <sha1.h>
|
#include <sha1.h>
|
||||||
|
|
||||||
#include "../controller/KissCount.h"
|
#include <controller/KissCount.h>
|
||||||
#include "model.h"
|
#include "model.h"
|
||||||
|
|
||||||
#define DATABASE_VERSION 2
|
#define DATABASE_VERSION 2
|
||||||
|
@ -90,13 +90,6 @@
|
||||||
|
|
||||||
#define EXECUTE_SQL_UPDATE(req, return_value) EXECUTE_SQL_UPDATE_WITH_CODE(req, return_value, {}, {})
|
#define EXECUTE_SQL_UPDATE(req, return_value) EXECUTE_SQL_UPDATE_WITH_CODE(req, return_value, {}, {})
|
||||||
|
|
||||||
#define ESCAPE_CHARS(s) { \
|
|
||||||
if (s.Find(wxT("\\\"")) == wxNOT_FOUND) \
|
|
||||||
s.Replace(wxT("\""), wxT("\\\""), true); \
|
|
||||||
if (s.Find(wxT("\\\'")) == wxNOT_FOUND) \
|
|
||||||
s.Replace(wxT("\'"), wxT("\\\'"), true); \
|
|
||||||
}
|
|
||||||
|
|
||||||
class KissCount;
|
class KissCount;
|
||||||
class User;
|
class User;
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,8 @@ bool XMLExportEngine::SaveAccounts()
|
||||||
{
|
{
|
||||||
account = _user->GetAccount(it->first);
|
account = _user->GetAccount(it->first);
|
||||||
|
|
||||||
|
ESCAPE_CHARS(account.name);
|
||||||
|
|
||||||
xmlTextWriterStartElement(_writer, (const xmlChar*) "account");
|
xmlTextWriterStartElement(_writer, (const xmlChar*) "account");
|
||||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "id", (const xmlChar*) account.id.utf8_str().data());
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "id", (const xmlChar*) account.id.utf8_str().data());
|
||||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "name", (const xmlChar*) account.name.utf8_str().data());
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "name", (const xmlChar*) account.name.utf8_str().data());
|
||||||
|
@ -89,6 +91,8 @@ bool XMLExportEngine::SaveCategories()
|
||||||
{
|
{
|
||||||
category = _user->GetCategory(it->first);
|
category = _user->GetCategory(it->first);
|
||||||
|
|
||||||
|
ESCAPE_CHARS(category.name);
|
||||||
|
|
||||||
xmlTextWriterStartElement(_writer, (const xmlChar*) "category");
|
xmlTextWriterStartElement(_writer, (const xmlChar*) "category");
|
||||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "id", (const xmlChar*) category.id.utf8_str().data());
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "id", (const xmlChar*) category.id.utf8_str().data());
|
||||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "name", (const xmlChar*) category.name.utf8_str().data());
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "name", (const xmlChar*) category.name.utf8_str().data());
|
||||||
|
@ -114,6 +118,8 @@ bool XMLExportEngine::SaveOperations(std::vector<Operation>* operations)
|
||||||
|
|
||||||
for(it=operations->begin(); it!=operations->end(); it++)
|
for(it=operations->begin(); it!=operations->end(); it++)
|
||||||
{
|
{
|
||||||
|
ESCAPE_CHARS(it->description);
|
||||||
|
|
||||||
xmlTextWriterStartElement(_writer, (const xmlChar*) "operation");
|
xmlTextWriterStartElement(_writer, (const xmlChar*) "operation");
|
||||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "id", (const xmlChar*) it->id.utf8_str().data());
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "id", (const xmlChar*) it->id.utf8_str().data());
|
||||||
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "parent", (const xmlChar*) it->parent.utf8_str().data());
|
xmlTextWriterWriteAttribute(_writer, (const xmlChar*) "parent", (const xmlChar*) it->parent.utf8_str().data());
|
||||||
|
|
|
@ -141,7 +141,8 @@ AccountPanel::AccountPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, pare
|
||||||
vbox3->Add(buttonUnGroup, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 10);
|
vbox3->Add(buttonUnGroup, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 10);
|
||||||
vbox3->Add(_radioMode, 0, wxALIGN_CENTER_HORIZONTAL|wxUP, 50);
|
vbox3->Add(_radioMode, 0, wxALIGN_CENTER_HORIZONTAL|wxUP, 50);
|
||||||
|
|
||||||
hbox->Add(vbox3, 0, wxGROW|wxALL, 2);
|
hbox->Add(vbox3, 0, wxALL, 2);
|
||||||
|
// hbox->Add(vbox3, 0, wxGROW|wxALL, 2);
|
||||||
hbox2->Add(_accountsGrid, 0, wxGROW|wxALL, 2);
|
hbox2->Add(_accountsGrid, 0, wxGROW|wxALL, 2);
|
||||||
hbox2->Add(_calendar, 0, wxALL, 2);
|
hbox2->Add(_calendar, 0, wxALL, 2);
|
||||||
vbox2->Add(hbox2, 0);
|
vbox2->Add(hbox2, 0);
|
||||||
|
|
|
@ -19,30 +19,21 @@
|
||||||
|
|
||||||
#include "AccountPanel.h"
|
#include "AccountPanel.h"
|
||||||
|
|
||||||
enum {DESCRIPTION_ID=1, SEARCH_ID, GRID_ID, CALENDAR_FROM_ID, CALENDAR_TO_ID,
|
enum {SEARCH_ID=1, GRID_ID,
|
||||||
CHANGE_ACCOUNT_ID, CHANGE_CATEGORY_ID, RENAME_ID};
|
CHANGE_ACCOUNT_ID, CHANGE_CATEGORY_ID, RENAME_ID};
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(SearchPanel, wxPanel)
|
BEGIN_EVENT_TABLE(SearchPanel, wxPanel)
|
||||||
EVT_BUTTON(SEARCH_ID, SearchPanel::OnButtonSearch)
|
EVT_BUTTON(SEARCH_ID, SearchPanel::OnButtonSearch)
|
||||||
EVT_CALENDAR_SEL_CHANGED(CALENDAR_FROM_ID, SearchPanel::OnCalendarFromChange)
|
|
||||||
EVT_CALENDAR_SEL_CHANGED(CALENDAR_TO_ID, SearchPanel::OnCalendarToChange)
|
|
||||||
EVT_GRID_CMD_CELL_CHANGE(GRID_ID, SearchPanel::OnOperationModified)
|
EVT_GRID_CMD_CELL_CHANGE(GRID_ID, SearchPanel::OnOperationModified)
|
||||||
EVT_BUTTON(CHANGE_ACCOUNT_ID, SearchPanel::OnButtonChangeAccount)
|
EVT_BUTTON(CHANGE_ACCOUNT_ID, SearchPanel::OnButtonChangeAccount)
|
||||||
EVT_BUTTON(CHANGE_CATEGORY_ID, SearchPanel::OnButtonChangeCategory)
|
EVT_BUTTON(CHANGE_CATEGORY_ID, SearchPanel::OnButtonChangeCategory)
|
||||||
EVT_BUTTON(RENAME_ID, SearchPanel::OnButtonRename)
|
EVT_BUTTON(RENAME_ID, SearchPanel::OnButtonRename)
|
||||||
EVT_SHOW(SearchPanel::OnShow)
|
EVT_SHOW(SearchPanel::OnShow)
|
||||||
EVT_TEXT_ENTER(DESCRIPTION_ID, SearchPanel::OnEnter)
|
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
#define UNESCAPE_CHARS(s) { \
|
|
||||||
s.Replace(wxT("\\\""), wxT("\""), true); \
|
|
||||||
s.Replace(wxT("\\\'"), wxT("\'"), true); \
|
|
||||||
}
|
|
||||||
|
|
||||||
SearchPanel::SearchPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent), _operations(NULL)
|
SearchPanel::SearchPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent), _operations(NULL)
|
||||||
{
|
{
|
||||||
DEFAULT_FONT(font);
|
DEFAULT_FONT(font);
|
||||||
User* user = _kiss->GetUser();
|
|
||||||
std::vector<Account>::iterator accountIt;
|
std::vector<Account>::iterator accountIt;
|
||||||
std::vector<Category>::iterator categoryIt;
|
std::vector<Category>::iterator categoryIt;
|
||||||
wxDateTime firstOfMonth;
|
wxDateTime firstOfMonth;
|
||||||
|
@ -54,71 +45,12 @@ SearchPanel::SearchPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent
|
||||||
|
|
||||||
SetSizer(vbox);
|
SetSizer(vbox);
|
||||||
|
|
||||||
_checkDateFrom = new wxCheckBox(this, wxID_ANY, _("Date from"));
|
|
||||||
_checkDateTo = new wxCheckBox(this, wxID_ANY, _("Date to"));
|
|
||||||
|
|
||||||
_checkDateFrom->SetValue(wxT("1"));
|
|
||||||
_checkDateTo->SetValue(wxT("1"));
|
|
||||||
|
|
||||||
wxGridBagSizer *gridBagSizer = new wxGridBagSizer(3, 10);
|
|
||||||
|
|
||||||
firstOfMonth.SetToCurrent();
|
|
||||||
firstOfMonth.SetDay(1);
|
|
||||||
_calendarFrom = new wxCalendarCtrl(this, CALENDAR_FROM_ID, firstOfMonth, wxDefaultPosition, wxDefaultSize,
|
|
||||||
wxCAL_MONDAY_FIRST);
|
|
||||||
_calendarTo = new wxCalendarCtrl(this, CALENDAR_TO_ID, wxDefaultDateTime, wxDefaultPosition, wxDefaultSize,
|
|
||||||
wxCAL_MONDAY_FIRST);
|
|
||||||
|
|
||||||
|
|
||||||
_description = new wxTextCtrl(this, DESCRIPTION_ID);
|
|
||||||
_description->SetWindowStyle(_description->GetWindowStyle() | wxTE_PROCESS_ENTER);
|
|
||||||
wxSize size = _description->GetSize();
|
|
||||||
size.SetWidth(size.GetWidth()*2);
|
|
||||||
_description->SetMinSize(size);
|
|
||||||
_amountFrom = new wxTextCtrl(this, wxID_ANY);
|
|
||||||
_amountTo = new wxTextCtrl(this, wxID_ANY);
|
|
||||||
|
|
||||||
_category = new wxCheckListBox(this, wxID_ANY);
|
|
||||||
_category->Append(_("Unknown"));
|
|
||||||
for(categoryIt = user->_categories.begin(); categoryIt != user->_categories.end(); categoryIt++)
|
|
||||||
_category->Append(wxGetTranslation(categoryIt->name));
|
|
||||||
|
|
||||||
wxString stypes[] = {_("Fix"), _("Non fix"), _("Checked"), _("Not checked")};
|
|
||||||
_optype = new wxCheckListBox(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 4, stypes);
|
|
||||||
|
|
||||||
_account = new wxCheckListBox(this, wxID_ANY);
|
|
||||||
_account->Append(_("Unknown"));
|
|
||||||
for(accountIt = user->_accounts.begin(); accountIt != user->_accounts.end(); accountIt++)
|
|
||||||
_account->Append(accountIt->name);
|
|
||||||
|
|
||||||
_searchButton = new wxButton(this, SEARCH_ID, _("Search"));
|
_searchButton = new wxButton(this, SEARCH_ID, _("Search"));
|
||||||
|
|
||||||
wxStaticText* labelDescription = new wxStaticText(this, wxID_ANY, _("Description"));
|
_banner = new SearchBanner(kiss, this, this, OnEnter);
|
||||||
wxStaticText* labelAmountFrom = new wxStaticText(this, wxID_ANY, _("Amount from"));
|
|
||||||
wxStaticText* labelAmountTo = new wxStaticText(this, wxID_ANY, _("Amount to"));
|
|
||||||
wxStaticText* labelCategory = new wxStaticText(this, wxID_ANY, _("Category"));
|
|
||||||
wxStaticText* labelOperations = new wxStaticText(this, wxID_ANY, _("Operations"));
|
|
||||||
wxStaticText* labelAccount = new wxStaticText(this, wxID_ANY, _("Account"));
|
|
||||||
|
|
||||||
gridBagSizer->Add(labelDescription, wxGBPosition(0, 0));
|
vbox->Add(_banner, 0, wxGROW|wxALL, 5);
|
||||||
gridBagSizer->Add(_description, wxGBPosition(1, 0));
|
vbox->Add(_searchButton, 0, wxALL, 5);
|
||||||
gridBagSizer->Add(_checkDateFrom, wxGBPosition(0, 1));
|
|
||||||
gridBagSizer->Add(_calendarFrom, wxGBPosition(1, 1));
|
|
||||||
gridBagSizer->Add(_checkDateTo, wxGBPosition(0, 2));
|
|
||||||
gridBagSizer->Add(_calendarTo, wxGBPosition(1, 2));
|
|
||||||
gridBagSizer->Add(labelAmountFrom, wxGBPosition(0, 3));
|
|
||||||
gridBagSizer->Add(_amountFrom, wxGBPosition(1, 3));
|
|
||||||
gridBagSizer->Add(labelAmountTo, wxGBPosition(0, 4));
|
|
||||||
gridBagSizer->Add(_amountTo, wxGBPosition(1, 4));
|
|
||||||
gridBagSizer->Add(labelCategory, wxGBPosition(0, 5));
|
|
||||||
gridBagSizer->Add(_category, wxGBPosition(1, 5));
|
|
||||||
gridBagSizer->Add(labelOperations, wxGBPosition(0, 6));
|
|
||||||
gridBagSizer->Add(_optype, wxGBPosition(1, 6));
|
|
||||||
gridBagSizer->Add(labelAccount, wxGBPosition(0, 7));
|
|
||||||
gridBagSizer->Add(_account, wxGBPosition(1, 7));
|
|
||||||
gridBagSizer->Add(_searchButton, wxGBPosition(2, 0));
|
|
||||||
|
|
||||||
vbox->Add(gridBagSizer, 0, wxGROW|wxALL, 5);
|
|
||||||
|
|
||||||
_grid = new GridAccount(_kiss, this, GRID_ID, false, false, true);
|
_grid = new GridAccount(_kiss, this, GRID_ID, false, false, true);
|
||||||
|
|
||||||
|
@ -145,7 +77,6 @@ SearchPanel::SearchPanel(KissCount* kiss, wxUI *parent) : KissPanel(kiss, parent
|
||||||
|
|
||||||
SearchPanel::~SearchPanel()
|
SearchPanel::~SearchPanel()
|
||||||
{
|
{
|
||||||
if (_operations) delete _operations;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
KissPanel* SearchPanel::CreatePanel()
|
KissPanel* SearchPanel::CreatePanel()
|
||||||
|
@ -166,111 +97,18 @@ wxString SearchPanel::GetToolTip()
|
||||||
return _("Search");
|
return _("Search");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchPanel::Search()
|
void SearchPanel::OnEnter(void* caller, wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
wxString *description=NULL, *amountFrom=NULL, *amountTo=NULL;
|
SearchPanel* _this = (SearchPanel*) caller;
|
||||||
std::vector<wxString> categories, accounts;
|
|
||||||
wxDateTime *dateFrom=NULL, *dateTo=NULL;
|
|
||||||
User* user= _kiss->GetUser();
|
|
||||||
int i, types=0;
|
|
||||||
std::vector<Operation>::iterator it;
|
|
||||||
double af, at;
|
|
||||||
|
|
||||||
if (_calendarFrom->GetDate() > _calendarTo->GetDate())
|
_this->OnButtonSearch(event);
|
||||||
{
|
|
||||||
wxMessageBox(_("Invalid date range"), _("Error"), wxICON_ERROR | wxOK);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_amountFrom->GetLineText(0).Length())
|
|
||||||
{
|
|
||||||
amountFrom = new wxString;
|
|
||||||
*amountFrom = _amountFrom->GetLineText(0);
|
|
||||||
if (!amountFrom->ToDouble(&af))
|
|
||||||
{
|
|
||||||
wxMessageBox(_("Invalid amount from"), _("Error"), wxICON_ERROR | wxOK);
|
|
||||||
delete amountFrom;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (af < 0) af *= -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_amountTo->GetLineText(0).Length())
|
|
||||||
{
|
|
||||||
amountTo = new wxString;
|
|
||||||
*amountTo = _amountTo->GetLineText(0);
|
|
||||||
if (!amountTo->ToDouble(&at))
|
|
||||||
{
|
|
||||||
wxMessageBox(_("Invalid amount to"), _("Error"), wxICON_ERROR | wxOK);
|
|
||||||
delete amountFrom;
|
|
||||||
delete amountTo;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (at < 0) at *= -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (amountFrom && amountTo && af > at)
|
|
||||||
{
|
|
||||||
wxMessageBox(_("Invalid amount range"), _("Error"), wxICON_ERROR | wxOK);
|
|
||||||
delete amountFrom;
|
|
||||||
delete amountTo;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_grid->DeleteRows(1, _grid->GetNumberRows()-1);
|
|
||||||
|
|
||||||
if (_description->GetLineText(0).Length())
|
|
||||||
{
|
|
||||||
description = new wxString;
|
|
||||||
*description = _description->GetLineText(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_checkDateFrom->IsChecked())
|
|
||||||
{
|
|
||||||
dateFrom = new wxDateTime;
|
|
||||||
*dateFrom = _calendarFrom->GetDate();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_checkDateTo->IsChecked())
|
|
||||||
{
|
|
||||||
dateTo = new wxDateTime;
|
|
||||||
*dateTo = _calendarTo->GetDate();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dateFrom && dateTo && *dateFrom > *dateTo)
|
|
||||||
{
|
|
||||||
;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(i=0; i<user->GetCategoriesNumber(); i++)
|
|
||||||
if (_category->IsChecked(i))
|
|
||||||
categories.push_back((i) ? user->_categories[i-1].id : wxT("0"));
|
|
||||||
|
|
||||||
types |= (_optype->IsChecked(0)) ? FIX_OP : 0;
|
|
||||||
types |= (_optype->IsChecked(1)) ? NON_FIX_OP : 0;
|
|
||||||
types |= (_optype->IsChecked(2)) ? CHECKED_OP : 0;
|
|
||||||
types |= (_optype->IsChecked(3)) ? NOT_CHECKED_OP : 0;
|
|
||||||
|
|
||||||
for(i=0; i<user->GetAccountsNumber(); i++)
|
|
||||||
if (_account->IsChecked(i))
|
|
||||||
accounts.push_back((i) ? user->_accounts[i-1].id : wxT("0"));
|
|
||||||
|
|
||||||
if (_operations)
|
|
||||||
delete _operations;
|
|
||||||
|
|
||||||
_operations = _kiss->Search(description, dateFrom, dateTo, amountFrom, amountTo, categories,types, accounts);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SearchPanel::OnEnter(wxCommandEvent& event)
|
|
||||||
{
|
|
||||||
OnButtonSearch(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchPanel::OnButtonSearch(wxCommandEvent& event)
|
void SearchPanel::OnButtonSearch(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
Search();
|
_operations = _banner->Search();
|
||||||
|
|
||||||
|
if (!_operations) return;
|
||||||
|
|
||||||
if (_operations->size() > 1)
|
if (_operations->size() > 1)
|
||||||
wxMessageBox(wxString::Format(wxT("%d"), _operations->size()) + _(" entries found"), wxT("KissCount"), wxICON_INFORMATION | wxOK);
|
wxMessageBox(wxString::Format(wxT("%d"), _operations->size()) + _(" entries found"), wxT("KissCount"), wxICON_INFORMATION | wxOK);
|
||||||
|
@ -416,16 +254,6 @@ void SearchPanel::OnShow(wxShowEvent& event)
|
||||||
_wxUI->SetTitle(_kiss->GetUser()->_name + wxT(" - ") + _("Search"));
|
_wxUI->SetTitle(_kiss->GetUser()->_name + wxT(" - ") + _("Search"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchPanel::OnCalendarFromChange(wxCalendarEvent& event)
|
|
||||||
{
|
|
||||||
_checkDateFrom->SetValue(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SearchPanel::OnCalendarToChange(wxCalendarEvent& event)
|
|
||||||
{
|
|
||||||
_checkDateTo->SetValue(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SearchPanel::OnOperationModified(wxGridEvent& event)
|
void SearchPanel::OnOperationModified(wxGridEvent& event)
|
||||||
{
|
{
|
||||||
_wxUI->NeedReload();
|
_wxUI->NeedReload();
|
||||||
|
|
|
@ -29,10 +29,12 @@
|
||||||
#include "grid/wxGridCellBitmapRenderer.h"
|
#include "grid/wxGridCellBitmapRenderer.h"
|
||||||
#include "grid/GridAccount.h"
|
#include "grid/GridAccount.h"
|
||||||
#include "AccountPanel.h"
|
#include "AccountPanel.h"
|
||||||
|
#include "SearchBanner.h"
|
||||||
|
|
||||||
#include <model/model.h>
|
#include <model/model.h>
|
||||||
|
|
||||||
class GridAccount;
|
class GridAccount;
|
||||||
|
class SearchBanner;
|
||||||
|
|
||||||
class SearchPanel: public KissPanel
|
class SearchPanel: public KissPanel
|
||||||
{
|
{
|
||||||
|
@ -45,26 +47,22 @@ public:
|
||||||
wxString GetToolTip();
|
wxString GetToolTip();
|
||||||
void OnShow(wxShowEvent& event);
|
void OnShow(wxShowEvent& event);
|
||||||
|
|
||||||
void OnEnter(wxCommandEvent& event);
|
/* void OnEnter(wxCommandEvent& event); */
|
||||||
void OnButtonSearch(wxCommandEvent& event);
|
void OnButtonSearch(wxCommandEvent& event);
|
||||||
void OnOperationModified(wxGridEvent& event);
|
void OnOperationModified(wxGridEvent& event);
|
||||||
void OnCalendarFromChange(wxCalendarEvent& event);
|
|
||||||
void OnCalendarToChange(wxCalendarEvent& event);
|
|
||||||
|
|
||||||
void OnButtonChangeAccount(wxCommandEvent& event);
|
void OnButtonChangeAccount(wxCommandEvent& event);
|
||||||
void OnButtonChangeCategory(wxCommandEvent& event);
|
void OnButtonChangeCategory(wxCommandEvent& event);
|
||||||
void OnButtonRename(wxCommandEvent& event);
|
void OnButtonRename(wxCommandEvent& event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Search();
|
|
||||||
|
|
||||||
std::vector<Operation> *_operations;
|
std::vector<Operation> *_operations;
|
||||||
wxCalendarCtrl* _calendarFrom, *_calendarTo;
|
SearchBanner* _banner;
|
||||||
GridAccount *_grid;
|
GridAccount *_grid;
|
||||||
wxCheckBox *_checkDateFrom, *_checkDateTo;
|
|
||||||
wxTextCtrl* _description, *_amountFrom, *_amountTo;
|
|
||||||
wxCheckListBox* _category, *_account, *_optype;
|
|
||||||
wxButton* _searchButton, *_renameButton, *_changeAccountButton, *_changeCategoryButton;
|
wxButton* _searchButton, *_renameButton, *_changeAccountButton, *_changeCategoryButton;
|
||||||
|
|
||||||
|
static void OnEnter(void* caller, wxCommandEvent& event);
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE();
|
DECLARE_EVENT_TABLE();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -588,7 +588,8 @@ int GridAccount::RemoveMeta(Operation op, int line, bool removeRoot, bool delete
|
||||||
if (deleteOp)
|
if (deleteOp)
|
||||||
{
|
{
|
||||||
DeleteOperation(op2);
|
DeleteOperation(op2);
|
||||||
_kiss->DeleteOperation(op2);
|
if (_databaseSynchronization)
|
||||||
|
_kiss->DeleteOperation(op2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -603,7 +604,8 @@ int GridAccount::RemoveMeta(Operation op, int line, bool removeRoot, bool delete
|
||||||
if (deleteOp)
|
if (deleteOp)
|
||||||
{
|
{
|
||||||
DeleteOperation(op);
|
DeleteOperation(op);
|
||||||
_kiss->DeleteOperation(op);
|
if (_databaseSynchronization)
|
||||||
|
_kiss->DeleteOperation(op);
|
||||||
}
|
}
|
||||||
deletedOperations++;
|
deletedOperations++;
|
||||||
}
|
}
|
||||||
|
@ -728,19 +730,27 @@ void GridAccount::OnOperationModified(wxGridEvent& event)
|
||||||
op_complete--;
|
op_complete--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (col == DESCRIPTION && GetCellValue(row, OP_DATE).Length() &&
|
if (col == DESCRIPTION &&
|
||||||
(!GetCellValue(row, CATEGORY).Length() ||
|
(!GetCellValue(row, CATEGORY).Length() ||
|
||||||
!GetCellValue(row, ACCOUNT).Length() ||
|
!GetCellValue(row, ACCOUNT).Length()))
|
||||||
!_canAddOperation))
|
|
||||||
{
|
{
|
||||||
new_op.fix_cost = (row <= _fixCosts);
|
new_op.fix_cost = (row <= _fixCosts);
|
||||||
if (_kiss->SearchPreviousOperation(&op_tmp, new_op, new_op.month, new_op.year, _canAddOperation))
|
if (_kiss->SearchPreviousOperation(&op_tmp, new_op, _curMonth, _curYear, _canAddOperation))
|
||||||
{
|
{
|
||||||
new_op.category = op_tmp.category;
|
if (!GetCellValue(row, CATEGORY).Length())
|
||||||
new_op.account = op_tmp.account;
|
{
|
||||||
SetCellValue(row, CATEGORY, wxGetTranslation(user->GetCategoryName(new_op.category)));
|
new_op.category = op_tmp.category;
|
||||||
SetCellValue(row, ACCOUNT, user->GetAccountName(new_op.account));
|
SetCellValue(row, CATEGORY, wxGetTranslation(user->GetCategoryName(new_op.category)));
|
||||||
op_complete -= 2;
|
op_complete--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!GetCellValue(row, ACCOUNT).Length())
|
||||||
|
{
|
||||||
|
new_op.account = op_tmp.account;
|
||||||
|
SetCellValue(row, ACCOUNT, user->GetAccountName(new_op.account));
|
||||||
|
op_complete--;
|
||||||
|
}
|
||||||
|
|
||||||
col = CATEGORY;
|
col = CATEGORY;
|
||||||
new_op.fix_cost = (new_op.category == user->GetCategoryId(wxT("Fix")));
|
new_op.fix_cost = (new_op.category == user->GetCategoryId(wxT("Fix")));
|
||||||
}
|
}
|
||||||
|
@ -861,7 +871,7 @@ void GridAccount::OnOperationModified(wxGridEvent& event)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Modify a fix operation
|
// Modify a fix operation
|
||||||
if (row < _fixCosts)
|
if (row < _fixCosts || !_canAddOperation)
|
||||||
{
|
{
|
||||||
if (col == OP_DELETE)
|
if (col == OP_DELETE)
|
||||||
{
|
{
|
||||||
|
@ -885,7 +895,8 @@ void GridAccount::OnOperationModified(wxGridEvent& event)
|
||||||
|
|
||||||
DeleteRows(row, 1);
|
DeleteRows(row, 1);
|
||||||
DeleteOperation(cur_op);
|
DeleteOperation(cur_op);
|
||||||
_kiss->DeleteOperation(cur_op);
|
if (_databaseSynchronization)
|
||||||
|
_kiss->DeleteOperation(cur_op);
|
||||||
_displayedOperations.erase(_displayedOperations.begin()+row);
|
_displayedOperations.erase(_displayedOperations.begin()+row);
|
||||||
|
|
||||||
if (cur_op.parent.Length() && op_tmp.childs.size() < 2)
|
if (cur_op.parent.Length() && op_tmp.childs.size() < 2)
|
||||||
|
@ -901,7 +912,8 @@ void GridAccount::OnOperationModified(wxGridEvent& event)
|
||||||
row = GetDisplayedRow(cur_op.parent);
|
row = GetDisplayedRow(cur_op.parent);
|
||||||
DeleteRows(row, 1);
|
DeleteRows(row, 1);
|
||||||
DeleteOperation(op_tmp);
|
DeleteOperation(op_tmp);
|
||||||
_kiss->DeleteOperation(op_tmp);
|
if (_databaseSynchronization)
|
||||||
|
_kiss->DeleteOperation(op_tmp);
|
||||||
_displayedOperations.erase(_displayedOperations.begin()+row);
|
_displayedOperations.erase(_displayedOperations.begin()+row);
|
||||||
_fixCosts--;
|
_fixCosts--;
|
||||||
}
|
}
|
||||||
|
@ -997,7 +1009,8 @@ void GridAccount::OnOperationModified(wxGridEvent& event)
|
||||||
DeleteRows(row, 1);
|
DeleteRows(row, 1);
|
||||||
DeleteOperation(cur_op);
|
DeleteOperation(cur_op);
|
||||||
_displayedOperations.erase(_displayedOperations.begin()+row);
|
_displayedOperations.erase(_displayedOperations.begin()+row);
|
||||||
_kiss->DeleteOperation(cur_op);
|
if (_databaseSynchronization)
|
||||||
|
_kiss->DeleteOperation(cur_op);
|
||||||
|
|
||||||
if (cur_op.parent.Length() && op_tmp.childs.size() <= 1)
|
if (cur_op.parent.Length() && op_tmp.childs.size() <= 1)
|
||||||
{
|
{
|
||||||
|
@ -1012,7 +1025,8 @@ void GridAccount::OnOperationModified(wxGridEvent& event)
|
||||||
row = GetDisplayedRow(cur_op.parent);
|
row = GetDisplayedRow(cur_op.parent);
|
||||||
DeleteRows(row, 1);
|
DeleteRows(row, 1);
|
||||||
DeleteOperation(op_tmp);
|
DeleteOperation(op_tmp);
|
||||||
_kiss->DeleteOperation(op_tmp);
|
if (_databaseSynchronization)
|
||||||
|
_kiss->DeleteOperation(op_tmp);
|
||||||
_displayedOperations.erase(_displayedOperations.begin()+row);
|
_displayedOperations.erase(_displayedOperations.begin()+row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#define SEARCH_ICON RESSOURCES_ROOT "icons/Search-icon.png"
|
#define SEARCH_ICON RESSOURCES_ROOT "icons/Search-icon.png"
|
||||||
#define PREFS_ICON RESSOURCES_ROOT "icons/options-icon.png"
|
#define PREFS_ICON RESSOURCES_ROOT "icons/options-icon.png"
|
||||||
#define IMPORT_ICON RESSOURCES_ROOT "icons/import-icon.png"
|
#define IMPORT_ICON RESSOURCES_ROOT "icons/import-icon.png"
|
||||||
|
#define EXPORT_ICON RESSOURCES_ROOT "icons/export-icon.png"
|
||||||
#define CHANGE_USER_ICON RESSOURCES_ROOT "icons/Clients-icon.png"
|
#define CHANGE_USER_ICON RESSOURCES_ROOT "icons/Clients-icon.png"
|
||||||
#define ABOUT_ICON RESSOURCES_ROOT "icons/windows-users-icon.png"
|
#define ABOUT_ICON RESSOURCES_ROOT "icons/windows-users-icon.png"
|
||||||
#define QUIT_ICON RESSOURCES_ROOT "icons/system-log-out.png"
|
#define QUIT_ICON RESSOURCES_ROOT "icons/system-log-out.png"
|
||||||
|
|
|
@ -155,6 +155,7 @@ void wxUI::InitPanels()
|
||||||
ADD_PANEL(SearchPanel, 2);
|
ADD_PANEL(SearchPanel, 2);
|
||||||
ADD_PANEL(PreferencesPanel, 3);
|
ADD_PANEL(PreferencesPanel, 3);
|
||||||
ADD_PANEL(ImportPanel, 4);
|
ADD_PANEL(ImportPanel, 4);
|
||||||
|
ADD_PANEL(ExportPanel, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxUI::LoadPanels()
|
void wxUI::LoadPanels()
|
||||||
|
|
|
@ -30,6 +30,7 @@ class ImportEngine;
|
||||||
#include "SearchPanel.h"
|
#include "SearchPanel.h"
|
||||||
#include "StatsPanel.h"
|
#include "StatsPanel.h"
|
||||||
#include "ImportPanel.h"
|
#include "ImportPanel.h"
|
||||||
|
#include "ExportPanel.h"
|
||||||
#include <controller/KissCount.h>
|
#include <controller/KissCount.h>
|
||||||
#include "grid/wxMyGrid.h"
|
#include "grid/wxMyGrid.h"
|
||||||
#include "grid/wxGridCellFastBoolEditor.h"
|
#include "grid/wxGridCellFastBoolEditor.h"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user