wip
This commit is contained in:
parent
aef7c2b61a
commit
1e79c5114e
7
model/Account.cpp
Executable file
7
model/Account.cpp
Executable file
|
@ -0,0 +1,7 @@
|
|||
#include "Account.h"
|
||||
|
||||
|
||||
Account::~Account()
|
||||
{
|
||||
|
||||
}
|
21
model/Account.h
Executable file
21
model/Account.h
Executable file
|
@ -0,0 +1,21 @@
|
|||
#ifndef ACCOUNT_H
|
||||
#define ACCOUNT_H
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <wx/wx.h>
|
||||
|
||||
class Account
|
||||
{
|
||||
public:
|
||||
~Account();
|
||||
|
||||
wxString _id;
|
||||
wxString _name;
|
||||
wxString _number;
|
||||
int _amount;
|
||||
bool _shared;
|
||||
bool _default;
|
||||
};
|
||||
|
||||
#endif
|
1
model/Preferences.cpp
Normal file
1
model/Preferences.cpp
Normal file
|
@ -0,0 +1 @@
|
|||
#include "Preferences.h"
|
|
@ -350,6 +350,41 @@ enum {DESCRIPTION, DATE, DEBIT, CREDIT, CATEGORY, ACCOUNT, VIEW, NUMBER_COLS_OPS
|
|||
SetMinSize(GetSize());
|
||||
}
|
||||
|
||||
void AccountPanel::InsertOperation(User* user, operation* op, int line, bool fix)
|
||||
{
|
||||
|
||||
_grid->InsertRows(line, 1);
|
||||
|
||||
_grid->SetCellEditor(curLine, DATE, new CalendarEditor(it->day, it->month, it->year));
|
||||
_grid->SetCellEditor(curLine, DEBIT, new wxGridCellFloatEditor(-1, 2));
|
||||
_grid->SetCellEditor(curLine, CREDIT, new wxGridCellFloatEditor(-1, 2));
|
||||
accountEditor = new wxGridCellChoiceEditor(user->_accounts.size()+1, _accounts, false);
|
||||
|
||||
if (fix)
|
||||
{
|
||||
_fixCosts++;
|
||||
SET_ROW_COLOR(curLine, OWN_YELLOW);
|
||||
_grid->SetCellValue(curLine, CATEGORY, _("Fixe"));
|
||||
_grid->SetReadOnly(curLine, CATEGORY);
|
||||
}
|
||||
else
|
||||
{
|
||||
SET_ROW_COLOR(curLine, OWN_GREEN);
|
||||
}
|
||||
|
||||
if (op)
|
||||
{
|
||||
_grid->SetCellValue(curLine, DESCRIPTION, it->description);
|
||||
_grid->SetCellValue(curLine, DATE, wxString::Format(wxT("%02d/%02d/%d"), it->day+1, it->month+1, it->year));
|
||||
if (it->amount < 0)
|
||||
_grid->SetCellValue(curLine, DEBIT, wxString::Format(wxT("%.2lf"), -it->amount));
|
||||
else
|
||||
_grid->SetCellValue(curLine, CREDIT, wxString::Format(wxT("%.2lf"), it->amount));
|
||||
_grid->SetCellEditor(curLine, ACCOUNT, accountEditor);
|
||||
_grid->SetCellValue(curLine, ACCOUNT, user->GetAccountName(it->account));
|
||||
}
|
||||
}
|
||||
|
||||
void AccountPanel::InitAccountsGrid(User* user, int month, int year)
|
||||
{
|
||||
std::map<wxString, Account>::iterator it;
|
||||
|
@ -516,6 +551,7 @@ void AccountPanel::OnOperationModified(wxGridEvent& event)
|
|||
op_complete--;
|
||||
}
|
||||
|
||||
// Penser au fix
|
||||
// Modify a fix operation
|
||||
if (row < _fixCosts)
|
||||
{
|
||||
|
|
81
view/CalendarEditor.cpp
Normal file
81
view/CalendarEditor.cpp
Normal file
|
@ -0,0 +1,81 @@
|
|||
#include "CalendarEditor.h"
|
||||
|
||||
CalendarEditor::CalendarEditor(int day, int month, int year) : _day(day), _month(month), _year(year), _parent(NULL), _calendar(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
CalendarEditor::~CalendarEditor()
|
||||
{
|
||||
if (_calendar) delete _calendar;
|
||||
}
|
||||
|
||||
void CalendarEditor::BeginEdit(int row, int col, wxGrid *grid)
|
||||
{
|
||||
// wxDateTime date, dateDef;
|
||||
|
||||
// if (!grid->GetCellValue(row, col).Len()) return;
|
||||
|
||||
// if (date.ParseFormat(grid->GetCellValue(row, col), _("%d/%m/%Y"), dateDef))
|
||||
// _calendar->SetDate(date);
|
||||
}
|
||||
|
||||
wxGridCellEditor* CalendarEditor::Clone() const
|
||||
{
|
||||
return new CalendarEditor(_day, _month, _year);
|
||||
}
|
||||
|
||||
void CalendarEditor::Create(wxWindow *parent, wxWindowID id, wxEvtHandler *evtHandler)
|
||||
{
|
||||
_parent = parent;
|
||||
_calendar = new wxCalendarCtrl(parent, id);
|
||||
_calendar->EnableHolidayDisplay(false);
|
||||
_calendar->EnableMonthChange(false);
|
||||
_calendar->EnableYearChange(false);
|
||||
_calendar->SetDate(wxDateTime(_day, _month, _year));
|
||||
// (void (wxObject::*)(wxEvent&))
|
||||
Connect((int)id, (int)wxEVT_CALENDAR_SEL_CHANGED, wxCommandEventHandler(CalendarEditor::OnCalendarChange));
|
||||
//evtHandler->Connect((int)id, (int)wxEVT_CALENDAR_DOUBLECLICKED, (void (wxObject::*)(wxEvent&))&CalendarEditor::OnCalendarChange);
|
||||
//evtHandler->Connect(wxEVT_CALENDAR_DOUBLECLICKED, (void (wxObject::*)(wxEvent&))&CalendarEditor::OnCalendarChange);
|
||||
//wxGridCellEditor::Create(parent, id, evtHandler);
|
||||
}
|
||||
|
||||
bool CalendarEditor::EndEdit (int row, int col, wxGrid *grid)
|
||||
{
|
||||
grid->SetCellValue(row, col, wxString::Format(wxT("%02d/%02d/%d"), _day, _month+1, _year)) ;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CalendarEditor::ApplyEdit (int row, int col, wxGrid *grid)
|
||||
{
|
||||
grid->SetCellValue(row, col, wxString::Format(wxT("%02d/%02d/%d"), _day, _month+1, _year)) ;
|
||||
}
|
||||
|
||||
wxString CalendarEditor::GetValue() const
|
||||
{
|
||||
return wxString::Format(wxT("%02d/%02d/%d"), _day, _month+1, _year);
|
||||
}
|
||||
|
||||
void CalendarEditor::Reset()
|
||||
{
|
||||
_calendar->SetDate(wxDateTime(_day, _month, _year));
|
||||
}
|
||||
|
||||
void CalendarEditor::Show (bool show, wxGridCellAttr *attr)
|
||||
{
|
||||
_calendar->Show(show);
|
||||
}
|
||||
|
||||
void CalendarEditor::SetSize (const wxRect &rect)
|
||||
{
|
||||
wxSize size = _calendar->GetMinSize();
|
||||
_calendar->SetSize(wxRect(rect.x, rect.y, size.GetWidth(), size.GetHeight()));
|
||||
}
|
||||
|
||||
void CalendarEditor::OnCalendarChange(wxCommandEvent& event)
|
||||
{
|
||||
std::cout << "ON CHANGE\n" ;
|
||||
//wxDateTime date = _calendar->GetDate();
|
||||
_day = _calendar->GetDate().GetDay();
|
||||
_calendar->Show(false);
|
||||
}
|
36
view/CalendarEditor.h
Normal file
36
view/CalendarEditor.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
#ifndef CALENDAREDITOR_H
|
||||
#define CALENDAREDITOR_H
|
||||
|
||||
#include <wx/wx.h>
|
||||
#include <wx/grid.h>
|
||||
#include <wx/calctrl.h>
|
||||
#include <wx/datetime.h>
|
||||
#include <wx/event.h>
|
||||
|
||||
class CalendarEditor : public wxGridCellEditor, public wxEvtHandler
|
||||
{
|
||||
public:
|
||||
|
||||
CalendarEditor(int day, int month, int year);
|
||||
~CalendarEditor();
|
||||
|
||||
void BeginEdit(int row, int col, wxGrid *grid);
|
||||
wxGridCellEditor* Clone () const;
|
||||
void Create(wxWindow *parent, wxWindowID id, wxEvtHandler *evtHandler);
|
||||
bool EndEdit(int row, int col, wxGrid *grid);
|
||||
void ApplyEdit(int row, int col, wxGrid *grid);
|
||||
wxString GetValue() const;
|
||||
void Reset();
|
||||
void Show(bool show, wxGridCellAttr *attr=NULL);
|
||||
void SetSize (const wxRect &rect);
|
||||
void OnCalendarChange(wxCommandEvent& event);
|
||||
|
||||
private:
|
||||
int _day;
|
||||
int _month;
|
||||
int _year;
|
||||
wxWindow *_parent;
|
||||
wxCalendarCtrl *_calendar;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user