-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ADD] : add panes for categories and operations
- Loading branch information
Showing
15 changed files
with
528 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#include <Frontend/Tables/CategoriesTable.h> | ||
#include <Models/DataBase.h> | ||
|
||
CategoriesTable::CategoriesTable() : ADataTable("CategoriesTable", 5) { | ||
} | ||
|
||
CategoriesTable::~CategoriesTable() { | ||
} | ||
|
||
bool CategoriesTable::load() { | ||
ADataTable::load(); | ||
m_updateCategories(); | ||
return true; | ||
} | ||
|
||
void CategoriesTable::unload() { | ||
ADataTable::unload(); | ||
} | ||
|
||
bool CategoriesTable::drawMenu() { | ||
if (ADataTable::drawMenu()) { | ||
m_updateCategories(); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
double CategoriesTable::m_getAmount(const size_t& vIdx) { | ||
return m_Categories.at(vIdx).amount; | ||
} | ||
|
||
void CategoriesTable::m_drawContent(const size_t& vIdx, const double& vMaxAmount) { | ||
const auto& e = m_Categories.at(vIdx); | ||
ImGui::TableNextColumn(); | ||
ImGui::Text("%s", e.name.c_str()); | ||
m_drawColumnDebit(e.debit); | ||
m_drawColumnCredit(e.credit); | ||
m_drawColumnAmount(e.amount); | ||
m_drawColumnBars(e.amount, vMaxAmount); | ||
} | ||
|
||
size_t CategoriesTable::m_getItemsCount() { | ||
return m_Categories.size(); | ||
} | ||
|
||
void CategoriesTable::m_setupColumns() { | ||
ImGui::TableSetupScrollFreeze(0, 1); | ||
ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthFixed); | ||
ImGui::TableSetupColumn("Debit", ImGuiTableColumnFlags_WidthFixed); | ||
ImGui::TableSetupColumn("Credit", ImGuiTableColumnFlags_WidthFixed); | ||
ImGui::TableSetupColumn("Amount", ImGuiTableColumnFlags_WidthFixed); | ||
ImGui::TableSetupColumn("Bars", ImGuiTableColumnFlags_WidthFixed); | ||
ImGui::TableHeadersRow(); | ||
} | ||
|
||
void CategoriesTable::m_updateCategories() { | ||
const auto account_id = m_getAccountID(); | ||
if (account_id > 0) { | ||
m_Categories.clear(); | ||
DataBase::Instance()->GetCategoriesStats( // | ||
account_id, | ||
[this](const CategoryName& vCategoryName, | ||
const TransactionDebit& vTransactionDebit, | ||
const TransactionCredit& vTransactionCredit) { // | ||
Category e; | ||
e.name = vCategoryName; | ||
e.debit = vTransactionDebit; | ||
e.credit = vTransactionCredit; | ||
e.amount = vTransactionDebit + vTransactionCredit; | ||
m_Categories.push_back(e); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
|
||
#include <Frontend/Tables/abstract/ADataTable.h> | ||
|
||
class CategoriesTable : public ADataTable { | ||
private: | ||
std::vector<Category> m_Categories; | ||
|
||
public: | ||
CategoriesTable(); | ||
~CategoriesTable(); | ||
|
||
bool load(); | ||
void unload(); | ||
bool drawMenu(); | ||
|
||
protected: | ||
double m_getAmount(const size_t& vIdx) final; | ||
void m_drawContent(const size_t& vIdx, const double& vMaxAmount) final; | ||
size_t m_getItemsCount() final; | ||
void m_setupColumns() final; | ||
|
||
private: | ||
void m_updateCategories(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#include <Frontend/Tables/OperationsTable.h> | ||
#include <Models/DataBase.h> | ||
|
||
OperationsTable::OperationsTable() : ADataTable("OperationsTable", 5) { | ||
} | ||
|
||
OperationsTable::~OperationsTable() { | ||
} | ||
|
||
bool OperationsTable::load() { | ||
ADataTable::load(); | ||
m_updateOperations(); | ||
return true; | ||
} | ||
|
||
void OperationsTable::unload() { | ||
ADataTable::unload(); | ||
} | ||
|
||
bool OperationsTable::drawMenu() { | ||
if (ADataTable::drawMenu()) { | ||
m_updateOperations(); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
double OperationsTable::m_getAmount(const size_t& vIdx) { | ||
return m_Operations.at(vIdx).amount; | ||
} | ||
|
||
void OperationsTable::m_drawContent(const size_t& vIdx, const double& vMaxAmount) { | ||
const auto& e = m_Operations.at(vIdx); | ||
ImGui::TableNextColumn(); | ||
ImGui::Text("%s", e.name.c_str()); | ||
m_drawColumnDebit(e.debit); | ||
m_drawColumnCredit(e.credit); | ||
m_drawColumnAmount(e.amount); | ||
m_drawColumnBars(e.amount, vMaxAmount); | ||
} | ||
|
||
size_t OperationsTable::m_getItemsCount() { | ||
return m_Operations.size(); | ||
} | ||
|
||
void OperationsTable::m_setupColumns() { | ||
ImGui::TableSetupScrollFreeze(0, 1); | ||
ImGui::TableSetupColumn("Name", ImGuiTableColumnFlags_WidthFixed); | ||
ImGui::TableSetupColumn("Debit", ImGuiTableColumnFlags_WidthFixed); | ||
ImGui::TableSetupColumn("Credit", ImGuiTableColumnFlags_WidthFixed); | ||
ImGui::TableSetupColumn("Amount", ImGuiTableColumnFlags_WidthFixed); | ||
ImGui::TableSetupColumn("Bars", ImGuiTableColumnFlags_WidthFixed); | ||
ImGui::TableHeadersRow(); | ||
} | ||
|
||
void OperationsTable::m_updateOperations() { | ||
const auto account_id = m_getAccountID(); | ||
if (account_id > 0) { | ||
m_Operations.clear(); | ||
DataBase::Instance()->GetOperationsStats( // | ||
account_id, | ||
[this](const OperationName& vOperationName, | ||
const TransactionDebit& vTransactionDebit, | ||
const TransactionCredit& vTransactionCredit) { // | ||
Operation e; | ||
e.name = vOperationName; | ||
e.debit = vTransactionDebit; | ||
e.credit = vTransactionCredit; | ||
e.amount = vTransactionDebit + vTransactionCredit; | ||
m_Operations.push_back(e); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
|
||
#include <Frontend/Tables/abstract/ADataTable.h> | ||
|
||
class OperationsTable : public ADataTable { | ||
private: | ||
std::vector<Operation> m_Operations; | ||
|
||
public: | ||
OperationsTable(); | ||
~OperationsTable(); | ||
|
||
bool load(); | ||
void unload(); | ||
bool drawMenu(); | ||
|
||
protected: | ||
double m_getAmount(const size_t& vIdx) final; | ||
void m_drawContent(const size_t& vIdx, const double& vMaxAmount) final; | ||
size_t m_getItemsCount() final; | ||
void m_setupColumns() final; | ||
|
||
private: | ||
void m_updateOperations(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#pragma once | ||
|
||
#define CashMe_Prefix "CashMe" | ||
#define CashMe_BuildNumber 615 | ||
#define CashMe_BuildNumber 618 | ||
#define CashMe_MinorNumber 0 | ||
#define CashMe_MajorNumber 0 | ||
#define CashMe_BuildId "0.0.615" | ||
#define CashMe_BuildId "0.0.618" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.