-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shared - Implement NewAccountDialogController
- Loading branch information
Showing
33 changed files
with
1,359 additions
and
748 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"POT-Creation-Date: 2024-03-12 23:50-0400\n" | ||
"POT-Creation-Date: 2024-03-14 00:10-0400\n" | ||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" | ||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
"Language-Team: LANGUAGE <[email protected]>\n" | ||
|
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
113 changes: 111 additions & 2 deletions
113
libdenaro/src/controllers/newaccountdialogcontroller.cpp
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,10 +1,119 @@ | ||
#include "controllers/newaccountdialogcontroller.h" | ||
#include <libnick/filesystem/userdirectories.h> | ||
|
||
using namespace Nickvision::Filesystem; | ||
using namespace Nickvision::Money::Shared::Models; | ||
|
||
namespace Nickvision::Money::Shared::Controllers | ||
{ | ||
NewAccountDialogController::NewAccountDialogController(const std::vector<std::filesystem::path>& openAccounts) | ||
: m_openAccounts(openAccounts) | ||
NewAccountDialogController::NewAccountDialogController() | ||
: m_path{ UserDirectories::getDocuments() / "New.nmoney"}, | ||
m_metadata{ "", AccountType::Checking }, | ||
m_overwriteExisting{ false } | ||
{ | ||
|
||
} | ||
|
||
const std::filesystem::path& NewAccountDialogController::getFilePath() const | ||
{ | ||
return m_path; | ||
} | ||
|
||
const AccountMetadata& NewAccountDialogController::getMetadata() const | ||
{ | ||
return m_metadata; | ||
} | ||
|
||
std::filesystem::path NewAccountDialogController::getFolder() const | ||
{ | ||
return m_path.stem(); | ||
} | ||
|
||
void NewAccountDialogController::setFolder(const std::filesystem::path& folder) | ||
{ | ||
m_path = folder / m_path.filename(); | ||
} | ||
|
||
bool NewAccountDialogController::setName(const std::string& name) | ||
{ | ||
if(std::filesystem::exists(m_path.stem() / (name + ".nmoney")) && !m_overwriteExisting) | ||
{ | ||
return false; | ||
} | ||
m_metadata.setName(name); | ||
m_path.replace_filename(name + ".nmoney"); | ||
return true; | ||
} | ||
|
||
const std::string& NewAccountDialogController::getPassword() const | ||
{ | ||
return m_password; | ||
} | ||
|
||
void NewAccountDialogController::setPassword(const std::string& password) | ||
{ | ||
m_password = password; | ||
} | ||
|
||
bool NewAccountDialogController::getOverwriteExisting() const | ||
{ | ||
return m_overwriteExisting; | ||
} | ||
|
||
void NewAccountDialogController::setOverwriteExisting(bool overwriteExisting) | ||
{ | ||
m_overwriteExisting = overwriteExisting; | ||
} | ||
|
||
void NewAccountDialogController::setAccountType(AccountType accountType) | ||
{ | ||
m_metadata.setType(accountType); | ||
} | ||
|
||
void NewAccountDialogController::setDefaultTransactionType(TransactionType defaultTransactionType) | ||
{ | ||
m_metadata.setDefaultTransactionType(defaultTransactionType); | ||
} | ||
|
||
void NewAccountDialogController::setTransactionRemindersThreshold(RemindersThreshold transactionReminderThreshold) | ||
{ | ||
m_metadata.setTransactionRemindersThreshold(transactionReminderThreshold); | ||
} | ||
|
||
void NewAccountDialogController::setCustomCurrencyOff() | ||
{ | ||
m_metadata.setUseCustomCurrency(false); | ||
m_metadata.setCustomCurrency({}); | ||
} | ||
|
||
CurrencyCheckStatus NewAccountDialogController::setCustomCurrency(const std::string& symbol, const std::string& code, char decimalSeparator, char groupSeparator, int decimalDigits, AmountStyle amountStyle) | ||
{ | ||
Currency currency{ symbol, code }; | ||
currency.setDecimalSeparator(decimalSeparator); | ||
currency.setGroupSeparator(groupSeparator); | ||
currency.setDecimalDigits(decimalDigits); | ||
currency.setAmountStyle(amountStyle); | ||
CurrencyCheckStatus status{ currency.validate() }; | ||
if(status == CurrencyCheckStatus::Valid) | ||
{ | ||
m_metadata.setUseCustomCurrency(true); | ||
m_metadata.setCustomCurrency(currency); | ||
} | ||
return status; | ||
} | ||
|
||
const std::filesystem::path& NewAccountDialogController::getImportFile() const | ||
{ | ||
return m_importFile; | ||
} | ||
|
||
bool NewAccountDialogController::setImportFile(const std::filesystem::path& importFile) | ||
{ | ||
if(std::filesystem::exists(importFile)) | ||
{ | ||
m_importFile = importFile; | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |
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.