2010-07-10 16:34:30 +02:00
|
|
|
/*
|
2017-01-01 17:20:08 +01:00
|
|
|
Copyright 2010-2016 Grégory Soutadé
|
2010-07-10 16:34:30 +02:00
|
|
|
|
2010-08-26 21:28:15 +02:00
|
|
|
This file is part of KissCount.
|
2010-07-10 16:34:30 +02:00
|
|
|
|
2010-08-26 21:28:15 +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
|
|
|
|
2010-08-26 21:28:15 +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
|
|
|
|
2010-08-26 21:28:15 +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
|
|
|
*/
|
|
|
|
|
2010-05-14 15:04:01 +02:00
|
|
|
#ifndef KISSCOUNT_H
|
|
|
|
#define KISSCOUNT_H
|
|
|
|
|
|
|
|
#include <list>
|
|
|
|
|
2011-08-25 17:45:41 +02:00
|
|
|
#include <QApplication>
|
|
|
|
|
2011-08-20 14:02:47 +02:00
|
|
|
#include <model/import/ImportEngine.hpp>
|
|
|
|
#include <model/export/ExportEngine.hpp>
|
|
|
|
#include <model/model.hpp>
|
2010-05-14 15:04:01 +02:00
|
|
|
|
2011-08-20 14:02:47 +02:00
|
|
|
#include <view/wxUI.hpp>
|
2011-08-20 11:43:12 +02:00
|
|
|
|
2018-05-07 16:17:21 +02:00
|
|
|
#define APP_VERSION "0.8"
|
2010-08-14 22:04:03 +02:00
|
|
|
|
2012-05-12 10:28:16 +02:00
|
|
|
#define ESCAPE_CHARS(s) s = s.replace("\"", " ");
|
|
|
|
// #define ESCAPE_CHARS(s) s = s.replace("\"", "\\\""); s = s.replace("\'", "\\\'");
|
2011-08-25 17:45:41 +02:00
|
|
|
/*{ \
|
2011-07-03 07:56:48 +02:00
|
|
|
if (s.Find(wxT("\\\"")) == wxNOT_FOUND) \
|
|
|
|
s.Replace(wxT("\""), wxT("\\\""), true); \
|
|
|
|
if (s.Find(wxT("\\\'")) == wxNOT_FOUND) \
|
|
|
|
s.Replace(wxT("\'"), wxT("\\\'"), true); \
|
|
|
|
}
|
2011-08-25 17:45:41 +02:00
|
|
|
*/
|
2012-05-12 10:28:16 +02:00
|
|
|
#define UNESCAPE_CHARS(s) s = s.replace("\\\"", " ");
|
|
|
|
// #define UNESCAPE_CHARS(s) s = s.replace("\\\"", "\""); s = s.replace("\\\'", "\'");
|
2011-08-25 17:45:41 +02:00
|
|
|
/*{ \
|
2011-07-04 20:23:00 +02:00
|
|
|
s.Replace(wxT("\\\""), wxT("\""), true); \
|
|
|
|
s.Replace(wxT("\\\'"), wxT("\'"), true); \
|
|
|
|
}
|
2011-08-25 17:45:41 +02:00
|
|
|
*/
|
2010-05-14 15:04:01 +02:00
|
|
|
class wxUI;
|
2010-09-08 11:02:03 +02:00
|
|
|
class Database;
|
2011-03-13 19:15:21 +01:00
|
|
|
class ImportEngine;
|
2011-07-03 07:56:48 +02:00
|
|
|
class ExportEngine;
|
2010-09-08 11:02:03 +02:00
|
|
|
|
2011-08-25 17:45:41 +02:00
|
|
|
class KissCount : public QApplication
|
2010-05-14 15:04:01 +02:00
|
|
|
{
|
2010-08-26 21:28:15 +02:00
|
|
|
public:
|
2012-08-03 21:08:20 +02:00
|
|
|
KissCount(int& argc, char** argv);
|
2010-08-26 21:28:15 +02:00
|
|
|
~KissCount();
|
2010-05-14 15:04:01 +02:00
|
|
|
|
2011-08-27 18:35:36 +02:00
|
|
|
std::list<QString> GetUsers();
|
|
|
|
bool IsValidUser(const QString& user, const QString& password);
|
|
|
|
void LoadUser(const QString& user);
|
2010-08-26 21:28:15 +02:00
|
|
|
User* GetUser();
|
2011-08-27 18:35:36 +02:00
|
|
|
void ChangePassword(const QString& password);
|
|
|
|
bool UserExists(const QString& name);
|
|
|
|
void ChangeName(const QString& name);
|
|
|
|
void NewUser(const QString& name);
|
2010-06-22 11:35:21 +02:00
|
|
|
|
2010-08-26 21:28:15 +02:00
|
|
|
void LoadYear(int year, bool force=false);
|
2010-06-22 11:35:21 +02:00
|
|
|
|
2011-08-25 17:45:41 +02:00
|
|
|
int AddOperation(Operation& op, bool checkTransfert=true);
|
2011-07-04 20:23:00 +02:00
|
|
|
void UpdateOperation(Operation& op, bool checkTransfert=true);
|
2010-08-26 21:28:15 +02:00
|
|
|
void DeleteOperation(Operation& op);
|
|
|
|
void DeleteOperations(int month, int year);
|
2012-04-30 21:15:51 +02:00
|
|
|
int MetaAmount(int id);
|
|
|
|
int MetaPositiveAmount(int id);
|
2010-06-22 11:35:21 +02:00
|
|
|
|
2013-02-17 18:58:32 +01:00
|
|
|
int GetAccountAmount(int id, int month, int year, bool* had_values=0, bool create_if_not_exsits=true);
|
2012-04-30 21:15:51 +02:00
|
|
|
void SetAccountAmount(int accountId, int month, int year, int value);
|
|
|
|
int CalcAccountAmount(int id, int month, int year, bool* had_values);
|
2011-01-29 20:53:44 +01:00
|
|
|
|
2011-08-25 17:45:41 +02:00
|
|
|
int AddAccount(Account& ac);
|
2010-08-26 21:28:15 +02:00
|
|
|
void UpdateAccount(Account& ac);
|
2011-08-25 17:45:41 +02:00
|
|
|
void DeleteAccount(Account& ac, int replacement);
|
2011-08-27 18:35:36 +02:00
|
|
|
void AddSharedAccount(Account& ac, const QString& granted);
|
|
|
|
void RemoveSharedAccount(Account& ac, int granted);
|
|
|
|
std::map<QString, QString> getSharedAccountOwners(int account);
|
|
|
|
QString getSharedAccountOwner(int account);
|
2010-06-02 22:14:11 +02:00
|
|
|
|
2011-08-25 17:45:41 +02:00
|
|
|
int AddCategory(Category& category);
|
2010-08-26 21:28:15 +02:00
|
|
|
void UpdateCategory(Category& category);
|
2011-08-25 17:45:41 +02:00
|
|
|
void DeleteCategory(Category& category, int replacement);
|
2010-06-22 11:35:21 +02:00
|
|
|
|
2014-11-10 11:54:28 +01:00
|
|
|
int AddTag(Tag& tag);
|
|
|
|
void UpdateTag(Tag& tag);
|
|
|
|
void DeleteTag(Tag& tag, int replacement);
|
|
|
|
|
2010-08-26 21:28:15 +02:00
|
|
|
std::map<int, std::vector<int> > GetAllOperations();
|
2010-06-23 19:32:42 +02:00
|
|
|
|
2014-02-08 15:14:04 +01:00
|
|
|
int GenerateMonth(int monthFrom, int yearFrom, int monthTo, int yearTo);
|
2010-08-26 21:28:15 +02:00
|
|
|
void KillMe();
|
2010-07-07 21:04:38 +02:00
|
|
|
|
2011-08-27 18:35:36 +02:00
|
|
|
void SetLanguage(QString language);
|
2017-10-29 18:21:53 +01:00
|
|
|
QString GetLanguage(void);
|
|
|
|
void SetAccountLimitValue(int limit);
|
|
|
|
void SetAccountLimitColor(QColor& color);
|
|
|
|
int GetAccountLimitValue(void);
|
|
|
|
QColor GetAccountLimitColor(void);
|
2011-08-27 18:35:36 +02:00
|
|
|
void SetOperationOrder(const QString& order);
|
|
|
|
const QString& GetOperationOrder();
|
2011-08-25 17:45:41 +02:00
|
|
|
|
2011-08-27 18:35:36 +02:00
|
|
|
std::vector<Operation>* Search(QString* description, QDate* dateFrom, QDate* dateTo,
|
2012-04-30 21:15:51 +02:00
|
|
|
int* amountFrom, int* amountTo,
|
2014-11-10 11:54:28 +01:00
|
|
|
std::vector<int> categories,
|
|
|
|
int types, std::vector<int> accounts, std::vector<int> tags);
|
2010-07-17 12:33:39 +02:00
|
|
|
|
2012-04-11 19:28:35 +02:00
|
|
|
bool SearchPreviousOperation(Operation* res, Operation& op, int month, int year, bool limitToType, int index);
|
2010-08-17 18:59:19 +02:00
|
|
|
|
2010-08-26 21:28:15 +02:00
|
|
|
void 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,
|
2014-11-10 11:54:28 +01:00
|
|
|
std::map<int, int>* categories, std::map<int, int>* tags);
|
2010-08-17 18:59:19 +02:00
|
|
|
|
2010-11-19 19:58:02 +01:00
|
|
|
void GetMonthStats(int month, int year, int nbDays,
|
2012-04-30 21:15:51 +02:00
|
|
|
std::map<int, std::vector<int> >* operations,
|
2014-11-10 11:54:28 +01:00
|
|
|
std::map<int, int>* categories, std::map<int, int>* tags);
|
2011-11-01 18:01:17 +01:00
|
|
|
void UpdateStats();
|
|
|
|
|
2012-04-30 21:15:51 +02:00
|
|
|
std::map<int, int>* GetNotChecked(int month, int year);
|
|
|
|
std::map<int, int>* GetVirtualAmount(int month, int year);
|
2010-08-21 11:49:03 +02:00
|
|
|
|
2011-08-27 18:35:36 +02:00
|
|
|
static QFont ExtractFont(QString);
|
|
|
|
static QString CompactFont(const QFont& font);
|
2010-09-08 11:02:03 +02:00
|
|
|
|
2011-03-13 19:15:21 +01:00
|
|
|
static void RegisterImportEngine(ImportEngine* engine);
|
|
|
|
static void UnRegisterImportEngine(ImportEngine* engine);
|
|
|
|
|
2011-08-27 18:35:36 +02:00
|
|
|
QString GetImportEngineExtensions();
|
2012-02-20 21:27:51 +01:00
|
|
|
ImportEngine* GetImportEngine(QString path);
|
2011-03-13 19:15:21 +01:00
|
|
|
|
2011-07-03 07:56:48 +02:00
|
|
|
static void RegisterExportEngine(ExportEngine* engine);
|
|
|
|
static void UnRegisterExportEngine(ExportEngine* engine);
|
|
|
|
|
2011-08-27 18:35:36 +02:00
|
|
|
QString GetExportEngineExtensions();
|
2012-02-12 10:20:02 +01:00
|
|
|
ExportEngine* GetExportEngine(QString path, QString filter);
|
2011-07-03 07:56:48 +02:00
|
|
|
|
2011-03-23 20:35:29 +01:00
|
|
|
void UpdateImportPattern();
|
2011-07-03 07:56:48 +02:00
|
|
|
|
2012-02-26 21:16:45 +01:00
|
|
|
void GetHistory(int month, int year, QStringList& list);
|
|
|
|
|
2012-03-20 20:57:45 +01:00
|
|
|
bool ChangeDatabase(QString filename);
|
|
|
|
|
2012-03-27 21:12:55 +02:00
|
|
|
QLocale* GetLocale();
|
2018-03-11 15:57:22 +01:00
|
|
|
QString GetDateLocalFormat();
|
2012-03-27 21:12:55 +02:00
|
|
|
QString FormatDate(int day, int month, int year);
|
|
|
|
|
2010-08-26 21:28:15 +02:00
|
|
|
private:
|
|
|
|
wxUI* _wxUI;
|
|
|
|
Database* _db;
|
|
|
|
User* _user;
|
2011-07-03 07:56:48 +02:00
|
|
|
|
|
|
|
static std::vector<ImportEngine*> *GetImportEngines();
|
|
|
|
static std::vector<ExportEngine*> *GetExportEngines();
|
|
|
|
|
|
|
|
static std::vector<ImportEngine*> *_importEngines;
|
|
|
|
static std::vector<ExportEngine*> *_exportEngines;
|
2010-05-14 15:04:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|