-
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.
[FIX] : fix the ADataTable for support row selections and context menu
- Loading branch information
Showing
14 changed files
with
356 additions
and
72 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
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
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
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,76 @@ | ||
#include <Frontend/Tables/TransactionsTable.h> | ||
#include <Models/DataBase.h> | ||
|
||
TransactionsTable::TransactionsTable() : ADataTable("TransactionsTable", 5) { | ||
} | ||
|
||
TransactionsTable::~TransactionsTable() { | ||
} | ||
|
||
bool TransactionsTable::load() { | ||
ADataTable::load(); | ||
m_updateTransactions(); | ||
return true; | ||
} | ||
|
||
void TransactionsTable::unload() { | ||
ADataTable::unload(); | ||
} | ||
|
||
bool TransactionsTable::drawMenu() { | ||
if (ADataTable::drawMenu()) { | ||
m_updateTransactions(); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
size_t TransactionsTable::m_getItemsCount() const { | ||
return m_Transactions.size(); | ||
} | ||
|
||
RowID TransactionsTable::m_getItemRowID(const size_t& vIdx) const { | ||
if (vIdx < m_Transactions.size()) { | ||
return m_Transactions.at(vIdx).id; | ||
} | ||
return 0; // the db row id cant be 0 | ||
} | ||
|
||
double TransactionsTable::m_getItemAmount(const size_t& vIdx) const { | ||
return m_Transactions.at(vIdx).amount; | ||
} | ||
|
||
void TransactionsTable::m_drawTableContent(const size_t& vIdx, const double& vMaxAmount) { | ||
const auto& t = m_Transactions.at(vIdx); | ||
m_drawColumnSelectable(vIdx, t.id, t.description); | ||
m_drawColumnDebit(t.debit); | ||
m_drawColumnCredit(t.credit); | ||
m_drawColumnAmount(t.amount); | ||
m_drawColumnBars(t.amount, vMaxAmount); | ||
} | ||
|
||
void TransactionsTable::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 TransactionsTable::m_drawContextMenuContent() { | ||
CTOOL_DEBUG_BREAK; | ||
} | ||
|
||
void TransactionsTable::m_doActionOnDblClick() { | ||
CTOOL_DEBUG_BREAK; | ||
} | ||
|
||
void TransactionsTable::m_updateTransactions() { | ||
const auto account_id = m_getAccountID(); | ||
if (account_id > 0) { | ||
m_Transactions.clear(); | ||
CTOOL_DEBUG_BREAK; | ||
} | ||
} |
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,28 @@ | ||
#pragma once | ||
|
||
#include <Frontend/Tables/abstract/ADataTable.h> | ||
|
||
class TransactionsTable : public ADataTable { | ||
private: | ||
std::vector<Transaction> m_Transactions; | ||
|
||
public: | ||
TransactionsTable(); | ||
~TransactionsTable(); | ||
|
||
bool load(); | ||
void unload(); | ||
bool drawMenu(); | ||
|
||
protected: | ||
size_t m_getItemsCount() const final; | ||
RowID m_getItemRowID(const size_t& vIdx) const final; | ||
double m_getItemAmount(const size_t& vIdx) const final; | ||
void m_drawTableContent(const size_t& vIdx, const double& vMaxAmount) final; | ||
void m_setupColumns() final; | ||
void m_drawContextMenuContent() final; | ||
void m_doActionOnDblClick() final; | ||
|
||
private: | ||
void m_updateTransactions(); | ||
}; |
Oops, something went wrong.