EntryProvider: Introduce isSavable() to avoid code duplicates
Esse commit está contido em:
pai
38cc87fbcd
commit
ac5498990b
@ -13,6 +13,11 @@ EntryProvider::EntryProvider(QStringList userEntriesDirsPaths, QStringList syste
|
||||
<< "%u";
|
||||
}
|
||||
|
||||
bool EntryProvider::isSavable(const EntryConfig &config) const
|
||||
{
|
||||
return ! config.entryPath.isEmpty() && (config.type == EntryType::USER || config.type == EntryType::INHERIT);
|
||||
}
|
||||
|
||||
EntryConfig EntryProvider::readFromDesktopFile(const QString &path)
|
||||
{
|
||||
EntryConfig result;
|
||||
@ -285,7 +290,7 @@ QVector<EntryConfig> EntryProvider::getSystemEntries()
|
||||
|
||||
void EntryProvider::saveUserEntry(const EntryConfig &config)
|
||||
{
|
||||
if(config.type == EntryType::SYSTEM || config.entryPath.isEmpty())
|
||||
if(!isSavable(config))
|
||||
{
|
||||
throw std::runtime_error("Only user/inherited entries can be saved");
|
||||
}
|
||||
@ -339,7 +344,7 @@ void EntryProvider::saveUserEntry(const EntryConfig &config)
|
||||
|
||||
bool EntryProvider::deleteUserEntry(const EntryConfig &config)
|
||||
{
|
||||
if(config.type == EntryType::SYSTEM || config.entryPath.isEmpty())
|
||||
if(!isSavable(config))
|
||||
{
|
||||
throw std::runtime_error("Only user/inherited entries can be deleted");
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ class EntryProvider
|
||||
|
||||
public:
|
||||
EntryProvider(QStringList userEntriesDirsPaths, QStringList systemEntriesDirsPaths);
|
||||
bool isSavable(const EntryConfig &config) const;
|
||||
QVector<EntryConfig> getUserEntries();
|
||||
QVector<EntryConfig> getSystemEntries();
|
||||
void saveUserEntry(const EntryConfig &config);
|
||||
|
Carregando…
Referência em uma nova issue
Block a user