Fix a bug with
This commit is contained in:
@@ -82,7 +82,7 @@ static inline wxString DoubleToString(double d)
|
||||
return res;
|
||||
}
|
||||
|
||||
Database::Database(const char* filename)
|
||||
Database::Database(const char* filename, KissCount* kiss) : _kiss(kiss)
|
||||
{
|
||||
std::ifstream bdd_file;
|
||||
|
||||
@@ -132,7 +132,13 @@ void Database::CreateDatabase()
|
||||
std::string line;
|
||||
wxString wxline;
|
||||
|
||||
wxMessageBox(_("No database found, creating a new one"), wxT("KissCount"), wxICON_EXCLAMATION | wxOK );
|
||||
wxString message = _("No database found, would you like to create a new one ?\n\n");
|
||||
message += _("!! Warning !! If there was a bug, the old database will be suppressed !");
|
||||
|
||||
wxMessageDialog dialog(NULL, message, wxT("KissCount"), wxYES_NO);
|
||||
|
||||
if (dialog.ShowModal() == wxID_NO)
|
||||
throw std::string("No database") ;
|
||||
|
||||
init_script.open(INIT_SCRIPT);
|
||||
|
||||
@@ -306,6 +312,7 @@ User* Database::LoadUser(const wxString& name)
|
||||
user->_categories.push_back(category);
|
||||
else
|
||||
user->_categories.insert(user->_categories.begin(), category);
|
||||
user->_categoriesFonts.push_back(_kiss->ExtractFont(category.font));
|
||||
}
|
||||
|
||||
set.Finalize();
|
||||
|
||||
@@ -28,14 +28,17 @@
|
||||
#include <sha1.h>
|
||||
|
||||
#include "model.h"
|
||||
#include "../controller/KissCount.h"
|
||||
|
||||
#define BDD_FILE "kc.bdd"
|
||||
#define INIT_SCRIPT "init.sql"
|
||||
|
||||
class KissCount;
|
||||
|
||||
class Database
|
||||
{
|
||||
public:
|
||||
Database(const char* filename);
|
||||
Database(const char* filename, KissCount* kiss);
|
||||
|
||||
std::list<wxString> GetUsers();
|
||||
bool IsValidUser(const wxString& user, const wxString& password);
|
||||
@@ -81,6 +84,7 @@ public:
|
||||
std::map<wxString, double>* GetNotChecked(User* user, int month, int year);
|
||||
|
||||
private:
|
||||
KissCount* _kiss;
|
||||
wxSQLite3Database _db;
|
||||
|
||||
void CreateDatabase();
|
||||
|
||||
@@ -70,6 +70,17 @@ wxString User::GetCategoryId(wxString& catName)
|
||||
return wxT("0") ;
|
||||
}
|
||||
|
||||
const wxFont& User::GetCategoryFont(wxString& catId)
|
||||
{
|
||||
wxFont f;
|
||||
|
||||
for (unsigned int i=0; i<_categories.size(); i++)
|
||||
if (_categories[i].id == catId)
|
||||
return _categoriesFonts[i];
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
wxString User::GetAccountName(const wxString& accountId)
|
||||
{
|
||||
std::vector<Account>::iterator it;
|
||||
|
||||
@@ -40,11 +40,13 @@ public:
|
||||
std::vector<Account> _accounts;
|
||||
std::map<unsigned int, std::map<unsigned int, std::vector<Operation> >* > _operations;
|
||||
std::vector<Category> _categories;
|
||||
std::vector<wxFont> _categoriesFonts;
|
||||
std::map<wxString, wxString> _preferences;
|
||||
|
||||
Category GetCategory(wxString& catId);
|
||||
wxString GetCategoryName(wxString& catId);
|
||||
wxString GetCategoryId(wxString& catName);
|
||||
const wxFont& GetCategoryFont(wxString& catId);
|
||||
wxString GetAccountName(const wxString& accountId);
|
||||
wxString GetAccountId(wxString& accountName);
|
||||
int GetCategoriesNumber();
|
||||
|
||||
Reference in New Issue
Block a user