Apply clang-format

This commit is contained in:
Martchus 2017-05-01 03:26:04 +02:00
parent 1c033b4746
commit f5bdf4c438
26 changed files with 721 additions and 739 deletions

3
.gitignore vendored
View File

@ -39,3 +39,6 @@ Makefile*
# documentation # documentation
/doc /doc
# clang-format
/.clang-format

View File

@ -1,18 +1,18 @@
#include "./cli.h" #include "./cli.h"
#include <passwordfile/io/passwordfile.h>
#include <passwordfile/io/cryptoexception.h> #include <passwordfile/io/cryptoexception.h>
#include <passwordfile/io/parsingexception.h>
#include <passwordfile/io/entry.h> #include <passwordfile/io/entry.h>
#include <passwordfile/io/field.h> #include <passwordfile/io/field.h>
#include <passwordfile/io/parsingexception.h>
#include <passwordfile/io/passwordfile.h>
#include <c++utilities/conversion/stringconversion.h>
#include <c++utilities/application/commandlineutils.h> #include <c++utilities/application/commandlineutils.h>
#include <c++utilities/conversion/stringconversion.h>
#include <c++utilities/io/catchiofailure.h> #include <c++utilities/io/catchiofailure.h>
#if defined(PLATFORM_UNIX) #if defined(PLATFORM_UNIX)
#include <unistd.h>
#include <c++utilities/io/ansiescapecodes.h> #include <c++utilities/io/ansiescapecodes.h>
#include <unistd.h>
#endif #endif
#include <algorithm> #include <algorithm>
@ -53,26 +53,26 @@ InputMuter::~InputMuter()
void clearConsole() void clearConsole()
{ {
#if defined(PLATFORM_WINDOWS) #if defined(PLATFORM_WINDOWS)
HANDLE hStdOut; HANDLE hStdOut;
CONSOLE_SCREEN_BUFFER_INFO csbi; CONSOLE_SCREEN_BUFFER_INFO csbi;
DWORD count; DWORD count;
DWORD cellCount; DWORD cellCount;
COORD homeCoords = {0, 0}; COORD homeCoords = { 0, 0 };
hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
if(hStdOut == INVALID_HANDLE_VALUE) { if (hStdOut == INVALID_HANDLE_VALUE) {
return; return;
} }
// get the number of cells in the current buffer // get the number of cells in the current buffer
if(!GetConsoleScreenBufferInfo(hStdOut, &csbi)) { if (!GetConsoleScreenBufferInfo(hStdOut, &csbi)) {
return; return;
} }
cellCount = csbi.dwSize.X * csbi.dwSize.Y; cellCount = csbi.dwSize.X * csbi.dwSize.Y;
// fill the entire buffer with spaces // fill the entire buffer with spaces
if(!FillConsoleOutputCharacter(hStdOut, (TCHAR) ' ', cellCount, homeCoords, &count)) { if (!FillConsoleOutputCharacter(hStdOut, (TCHAR)' ', cellCount, homeCoords, &count)) {
return; return;
} }
// fill the entire buffer with the current colors and attributes // fill the entire buffer with the current colors and attributes
if(!FillConsoleOutputAttribute(hStdOut, csbi.wAttributes, cellCount, homeCoords, &count)) { if (!FillConsoleOutputAttribute(hStdOut, csbi.wAttributes, cellCount, homeCoords, &count)) {
return; return;
} }
// move the cursor home // move the cursor home
@ -83,25 +83,25 @@ void clearConsole()
#endif #endif
} }
InteractiveCli::InteractiveCli() : InteractiveCli::InteractiveCli()
m_o(cout), : m_o(cout)
m_i(cin), , m_i(cin)
m_currentEntry(nullptr), , m_currentEntry(nullptr)
m_modified(false), , m_modified(false)
m_quit(false) , m_quit(false)
{ {
CMD_UTILS_START_CONSOLE; CMD_UTILS_START_CONSOLE;
} }
void InteractiveCli::run(const string &file) void InteractiveCli::run(const string &file)
{ {
if(!file.empty()) { if (!file.empty()) {
openFile(file, false); openFile(file, false);
} }
string input; string input;
while(!m_quit) { while (!m_quit) {
getline(m_i, input); getline(m_i, input);
if(!input.empty()) { if (!input.empty()) {
processCommand(input); processCommand(input);
} }
} }
@ -116,60 +116,60 @@ void InteractiveCli::processCommand(const string &cmd)
string param; string param;
bool paramMissing = false; bool paramMissing = false;
if(CMD2("quit", "q")) { if (CMD2("quit", "q")) {
quit(); quit();
} else if(CMD("q!")) { } else if (CMD("q!")) {
m_quit = true; m_quit = true;
} else if(CMD("wq")) { } else if (CMD("wq")) {
saveFile(); saveFile();
m_quit = true; m_quit = true;
} else if(CMD2("clear", "c")) { } else if (CMD2("clear", "c")) {
clearConsole(); clearConsole();
} else if(CMD2_P("openreadonly", "or")) { } else if (CMD2_P("openreadonly", "or")) {
openFile(param, true); openFile(param, true);
} else if(CMD2_P("open", "o")) { } else if (CMD2_P("open", "o")) {
openFile(param, false); openFile(param, false);
} else if(CMD2("close", "c")) { } else if (CMD2("close", "c")) {
closeFile(); closeFile();
} else if(CMD2("save", "w")) { } else if (CMD2("save", "w")) {
saveFile(); saveFile();
} else if(CMD2_P("create", "cr")) { } else if (CMD2_P("create", "cr")) {
createFile(param); createFile(param);
} else if(CMD("chpassphrase")) { } else if (CMD("chpassphrase")) {
changePassphrase(); changePassphrase();
} else if(CMD("rmpassphrase")) { } else if (CMD("rmpassphrase")) {
removePassphrase(); removePassphrase();
} else if(CMD("pwd")) { } else if (CMD("pwd")) {
pwd(); pwd();
} else if(CMD_P("cd")) { } else if (CMD_P("cd")) {
cd(param); cd(param);
} else if(CMD("ls")) { } else if (CMD("ls")) {
ls(); ls();
} else if(CMD2("tree", "t")) { } else if (CMD2("tree", "t")) {
tree(); tree();
} else if(CMD2_P("mknode", "mkn")) { } else if (CMD2_P("mknode", "mkn")) {
makeEntry(EntryType::Node, param); makeEntry(EntryType::Node, param);
} else if(CMD2_P("mkaccount", "mka")) { } else if (CMD2_P("mkaccount", "mka")) {
makeEntry(EntryType::Account, param); makeEntry(EntryType::Account, param);
} else if(CMD2("rmentry", "rme")) { } else if (CMD2("rmentry", "rme")) {
removeEntry("."); removeEntry(".");
} else if(CMD2_P("rmentry", "rme")) { } else if (CMD2_P("rmentry", "rme")) {
removeEntry(param); removeEntry(param);
} else if(CMD2_P("rnentry", "rne")) { } else if (CMD2_P("rnentry", "rne")) {
renameEntry(param); renameEntry(param);
} else if(CMD2_P("mventry", "me")) { } else if (CMD2_P("mventry", "me")) {
moveEntry(param); moveEntry(param);
} else if(CMD2_P("readfield", "rf")) { } else if (CMD2_P("readfield", "rf")) {
readField(param); readField(param);
} else if(CMD2_P("setfield", "sf")) { } else if (CMD2_P("setfield", "sf")) {
setField(false, param); setField(false, param);
} else if(CMD2_P("setfieldpw", "sp")) { } else if (CMD2_P("setfieldpw", "sp")) {
setField(true, param); setField(true, param);
} else if(CMD2_P("rmfield", "rf")) { } else if (CMD2_P("rmfield", "rf")) {
removeField(param); removeField(param);
} else if(CMD2("help", "?")) { } else if (CMD2("help", "?")) {
printHelp(); printHelp();
} else if(paramMissing) { } else if (paramMissing) {
m_o << "parameter is missing" << endl; m_o << "parameter is missing" << endl;
} else { } else {
m_o << "command is unknown" << endl; m_o << "command is unknown" << endl;
@ -180,26 +180,26 @@ Entry *InteractiveCli::resolvePath(const string &path)
{ {
auto parts = splitString<vector<string> >(path, "/", EmptyPartsTreat::Merge); auto parts = splitString<vector<string> >(path, "/", EmptyPartsTreat::Merge);
bool fromRoot = path.at(0) == '/'; bool fromRoot = path.at(0) == '/';
if(fromRoot && parts.empty()) { if (fromRoot && parts.empty()) {
return m_file.rootEntry(); return m_file.rootEntry();
} else { } else {
Entry *entry = fromRoot ? m_file.rootEntry() : m_currentEntry; Entry *entry = fromRoot ? m_file.rootEntry() : m_currentEntry;
for(const string &part : parts) { for (const string &part : parts) {
if(part == "..") { if (part == "..") {
if(entry->parent()) { if (entry->parent()) {
entry = entry->parent(); entry = entry->parent();
} else { } else {
m_o << "can not resolve path; entry \"" << entry->label() << "\" is root" << endl; m_o << "can not resolve path; entry \"" << entry->label() << "\" is root" << endl;
return nullptr; return nullptr;
} }
} else if(part != ".") { } else if (part != ".") {
switch(entry->type()) { switch (entry->type()) {
case EntryType::Account: case EntryType::Account:
m_o << "can not resolve path; entry \"" << entry->label() << "\" is not a node entry" << endl; m_o << "can not resolve path; entry \"" << entry->label() << "\" is not a node entry" << endl;
return nullptr; return nullptr;
case EntryType::Node: case EntryType::Node:
for(Entry *child : (static_cast<NodeEntry *>(entry)->children())) { for (Entry *child : (static_cast<NodeEntry *>(entry)->children())) {
if(child->label() == part) { if (child->label() == part) {
entry = child; entry = child;
goto next; goto next;
} }
@ -208,7 +208,7 @@ Entry *InteractiveCli::resolvePath(const string &path)
return nullptr; return nullptr;
} }
} }
next:; next:;
} }
return entry; return entry;
} }
@ -216,10 +216,10 @@ Entry *InteractiveCli::resolvePath(const string &path)
bool InteractiveCli::checkCommand(const string &str, const char *phrase, std::string &param, bool &paramMissing) bool InteractiveCli::checkCommand(const string &str, const char *phrase, std::string &param, bool &paramMissing)
{ {
for(auto i = str.cbegin(), end = str.cend(); i != end; ++i, ++phrase) { for (auto i = str.cbegin(), end = str.cend(); i != end; ++i, ++phrase) {
if(*phrase == 0) { if (*phrase == 0) {
if(*i == ' ') { if (*i == ' ') {
if(++i != end) { if (++i != end) {
param.assign(i, end); param.assign(i, end);
return true; return true;
} else { } else {
@ -227,7 +227,7 @@ bool InteractiveCli::checkCommand(const string &str, const char *phrase, std::st
} }
} }
return false; return false;
} else if(*i != *phrase) { } else if (*i != *phrase) {
return false; return false;
} }
} }
@ -237,14 +237,14 @@ bool InteractiveCli::checkCommand(const string &str, const char *phrase, std::st
void InteractiveCli::openFile(const string &file, bool readOnly) void InteractiveCli::openFile(const string &file, bool readOnly)
{ {
if(m_file.isOpen()) { if (m_file.isOpen()) {
m_o << "file \"" << m_file.path() << "\" currently open; close first" << endl; m_o << "file \"" << m_file.path() << "\" currently open; close first" << endl;
} else { } else {
m_file.setPath(file); m_file.setPath(file);
try { try {
try { try {
m_file.open(readOnly); m_file.open(readOnly);
if(m_file.isEncryptionUsed()) { if (m_file.isEncryptionUsed()) {
m_file.setPassword(askForPassphrase()); m_file.setPassword(askForPassphrase());
} }
m_file.load(); m_file.load();
@ -256,13 +256,13 @@ void InteractiveCli::openFile(const string &file, bool readOnly)
} catch (const CryptoException &) { } catch (const CryptoException &) {
m_o << "error occured when decrypting file \"" << file << "\"" << endl; m_o << "error occured when decrypting file \"" << file << "\"" << endl;
throw; throw;
} catch(...) { } catch (...) {
const char *what = catchIoFailure(); const char *what = catchIoFailure();
m_o << "IO error occured when opening file \"" << file << "\"" << endl; m_o << "IO error occured when opening file \"" << file << "\"" << endl;
throw ios_base::failure(what); throw ios_base::failure(what);
} }
} catch(const std::exception &e) { } catch (const std::exception &e) {
if(*e.what() != 0) { if (*e.what() != 0) {
m_o << e.what() << endl; m_o << e.what() << endl;
} }
m_file.clear(); m_file.clear();
@ -274,7 +274,7 @@ void InteractiveCli::openFile(const string &file, bool readOnly)
void InteractiveCli::closeFile() void InteractiveCli::closeFile()
{ {
if(m_file.isOpen()) { if (m_file.isOpen()) {
m_file.clear(); m_file.clear();
m_currentEntry = nullptr; m_currentEntry = nullptr;
m_o << "file closed" << endl; m_o << "file closed" << endl;
@ -285,7 +285,7 @@ void InteractiveCli::closeFile()
void InteractiveCli::saveFile() void InteractiveCli::saveFile()
{ {
if(m_file.isOpen()) { if (m_file.isOpen()) {
try { try {
try { try {
m_file.save(*m_file.password()); m_file.save(*m_file.password());
@ -301,8 +301,8 @@ void InteractiveCli::saveFile()
m_o << "IO error occured when saving file \"" << m_file.path() << "\"" << endl; m_o << "IO error occured when saving file \"" << m_file.path() << "\"" << endl;
throw ios_base::failure(what); throw ios_base::failure(what);
} }
} catch(const exception &e) { } catch (const exception &e) {
if(*e.what() != 0) { if (*e.what() != 0) {
m_o << e.what() << endl; m_o << e.what() << endl;
} }
m_o << "file has been closed; try reopening the file" << endl; m_o << "file has been closed; try reopening the file" << endl;
@ -316,7 +316,7 @@ void InteractiveCli::saveFile()
void InteractiveCli::createFile(const string &file) void InteractiveCli::createFile(const string &file)
{ {
if(m_file.isOpen()) { if (m_file.isOpen()) {
m_o << "file \"" << m_file.path() << "\" currently open; close first" << endl; m_o << "file \"" << m_file.path() << "\" currently open; close first" << endl;
} else { } else {
m_file.setPath(file); m_file.setPath(file);
@ -331,8 +331,8 @@ void InteractiveCli::createFile(const string &file)
m_o << "IO error occured when creating file \"" << file << "\"" << endl; m_o << "IO error occured when creating file \"" << file << "\"" << endl;
throw ios_base::failure(what); throw ios_base::failure(what);
} }
} catch(exception &e) { } catch (exception &e) {
if(*e.what() != 0) { if (*e.what() != 0) {
m_o << e.what() << endl; m_o << e.what() << endl;
} }
m_file.clear(); m_file.clear();
@ -344,12 +344,12 @@ void InteractiveCli::createFile(const string &file)
void InteractiveCli::changePassphrase() void InteractiveCli::changePassphrase()
{ {
if(m_file.isOpen()) { if (m_file.isOpen()) {
try { try {
m_file.setPassword(askForPassphrase(true)); m_file.setPassword(askForPassphrase(true));
m_modified = true; m_modified = true;
m_o << "passphrase changed; use save to apply" << endl; m_o << "passphrase changed; use save to apply" << endl;
} catch(runtime_error &) { } catch (runtime_error &) {
m_o << "passphrase has not changed" << endl; m_o << "passphrase has not changed" << endl;
} }
} else { } else {
@ -359,8 +359,8 @@ void InteractiveCli::changePassphrase()
void InteractiveCli::removePassphrase() void InteractiveCli::removePassphrase()
{ {
if(m_file.isOpen()) { if (m_file.isOpen()) {
if(*m_file.password()) { if (*m_file.password()) {
m_file.clearPassword(); m_file.clearPassword();
m_o << "passphrase removed; use save to apply" << endl; m_o << "passphrase removed; use save to apply" << endl;
m_modified = true; m_modified = true;
@ -374,7 +374,7 @@ void InteractiveCli::removePassphrase()
void InteractiveCli::pwd() void InteractiveCli::pwd()
{ {
if(m_file.isOpen()) { if (m_file.isOpen()) {
auto path = m_currentEntry->path(); auto path = m_currentEntry->path();
m_o << path.front() << ": /"; m_o << path.front() << ": /";
path.pop_front(); path.pop_front();
@ -386,8 +386,8 @@ void InteractiveCli::pwd()
void InteractiveCli::cd(const string &path) void InteractiveCli::cd(const string &path)
{ {
if(m_file.isOpen()) { if (m_file.isOpen()) {
if(Entry *entry = resolvePath(path)) { if (Entry *entry = resolvePath(path)) {
m_currentEntry = entry; m_currentEntry = entry;
m_o << "changed to \"" << entry->label() << "\"" << endl; m_o << "changed to \"" << entry->label() << "\"" << endl;
} }
@ -398,17 +398,18 @@ void InteractiveCli::cd(const string &path)
void InteractiveCli::ls() void InteractiveCli::ls()
{ {
if(m_file.isOpen()) { if (m_file.isOpen()) {
switch(m_currentEntry->type()) { switch (m_currentEntry->type()) {
case EntryType::Account: { case EntryType::Account: {
m_o << "fields:"; m_o << "fields:";
for(const Field &field : static_cast<AccountEntry *>(m_currentEntry)->fields()) { for (const Field &field : static_cast<AccountEntry *>(m_currentEntry)->fields()) {
m_o << " " << field.name(); m_o << " " << field.name();
} }
break; break;
} case EntryType::Node: { }
case EntryType::Node: {
m_o << "entries:"; m_o << "entries:";
for(const Entry *entry : static_cast<NodeEntry *>(m_currentEntry)->children()) { for (const Entry *entry : static_cast<NodeEntry *>(m_currentEntry)->children()) {
m_o << " " << entry->label(); m_o << " " << entry->label();
} }
break; break;
@ -422,15 +423,15 @@ void InteractiveCli::ls()
void InteractiveCli::tree() void InteractiveCli::tree()
{ {
if(m_file.isOpen()) { if (m_file.isOpen()) {
function<void(const Entry *entry, unsigned char level)> printEntries; function<void(const Entry *entry, unsigned char level)> printEntries;
printEntries = [&printEntries, this] (const Entry *entry, unsigned char level) { printEntries = [&printEntries, this](const Entry *entry, unsigned char level) {
for(unsigned char i = 0; i < level; ++i) { for (unsigned char i = 0; i < level; ++i) {
m_o << " "; m_o << " ";
} }
m_o << entry->label() << endl; m_o << entry->label() << endl;
if(entry->type() == EntryType::Node) { if (entry->type() == EntryType::Node) {
for(const Entry *child : (static_cast<const NodeEntry *>(entry)->children())) { for (const Entry *child : (static_cast<const NodeEntry *>(entry)->children())) {
printEntries(child, level + 2); printEntries(child, level + 2);
} }
} }
@ -443,10 +444,10 @@ void InteractiveCli::tree()
void InteractiveCli::makeEntry(EntryType entryType, const string &label) void InteractiveCli::makeEntry(EntryType entryType, const string &label)
{ {
if(m_file.isOpen()) { if (m_file.isOpen()) {
switch(m_currentEntry->type()) { switch (m_currentEntry->type()) {
case EntryType::Node: case EntryType::Node:
switch(entryType) { switch (entryType) {
case EntryType::Node: case EntryType::Node:
m_o << "node entry \"" << (new NodeEntry(label, static_cast<NodeEntry *>(m_currentEntry)))->label() << "\" created" << endl; m_o << "node entry \"" << (new NodeEntry(label, static_cast<NodeEntry *>(m_currentEntry)))->label() << "\" created" << endl;
break; break;
@ -466,12 +467,12 @@ void InteractiveCli::makeEntry(EntryType entryType, const string &label)
void InteractiveCli::removeEntry(const string &path) void InteractiveCli::removeEntry(const string &path)
{ {
if(m_file.isOpen()) { if (m_file.isOpen()) {
if(Entry *entry = resolvePath(path)) { if (Entry *entry = resolvePath(path)) {
if(entry == m_file.rootEntry()) { if (entry == m_file.rootEntry()) {
m_o << "can not remove root entry" << endl; m_o << "can not remove root entry" << endl;
} else { } else {
if(entry == m_currentEntry) { if (entry == m_currentEntry) {
m_currentEntry = entry->parent(); m_currentEntry = entry->parent();
} }
m_o << "removed entry \"" << entry->label() << "\"" << endl; m_o << "removed entry \"" << entry->label() << "\"" << endl;
@ -486,12 +487,12 @@ void InteractiveCli::removeEntry(const string &path)
void InteractiveCli::renameEntry(const string &path) void InteractiveCli::renameEntry(const string &path)
{ {
if(m_file.isOpen()) { if (m_file.isOpen()) {
if(Entry *entry = resolvePath(path)) { if (Entry *entry = resolvePath(path)) {
string label; string label;
m_o << "enter new name: " << endl; m_o << "enter new name: " << endl;
getline(m_i, label); getline(m_i, label);
if(label.empty()) { if (label.empty()) {
m_o << "can not rename; new name is empty" << endl; m_o << "can not rename; new name is empty" << endl;
} else { } else {
entry->setLabel(label); entry->setLabel(label);
@ -506,23 +507,23 @@ void InteractiveCli::renameEntry(const string &path)
void InteractiveCli::moveEntry(const string &path) void InteractiveCli::moveEntry(const string &path)
{ {
if(m_file.isOpen()) { if (m_file.isOpen()) {
if(Entry *entry = resolvePath(path)) { if (Entry *entry = resolvePath(path)) {
string newParentPath; string newParentPath;
m_o << "enter path of new parent: " << endl; m_o << "enter path of new parent: " << endl;
getline(m_i, newParentPath); getline(m_i, newParentPath);
if(newParentPath.empty()) { if (newParentPath.empty()) {
m_o << "can not move; path of new parent is empty" << endl; m_o << "can not move; path of new parent is empty" << endl;
} else { } else {
if(Entry *newParent = resolvePath(newParentPath)) { if (Entry *newParent = resolvePath(newParentPath)) {
switch(newParent->type()) { switch (newParent->type()) {
case EntryType::Account: case EntryType::Account:
m_o << "can not move; new parent must be a node entry" << endl; m_o << "can not move; new parent must be a node entry" << endl;
break; break;
case EntryType::Node: case EntryType::Node:
if(entry->parent() == entry) { if (entry->parent() == entry) {
m_o << "element not moved; parent doesn't change" << endl; m_o << "element not moved; parent doesn't change" << endl;
} else if(entry->type() == EntryType::Node && newParent->isIndirectChildOf(static_cast<NodeEntry *>(entry))) { } else if (entry->type() == EntryType::Node && newParent->isIndirectChildOf(static_cast<NodeEntry *>(entry))) {
m_o << "can not move; new parent mustn't be child of the entry to move" << endl; m_o << "can not move; new parent mustn't be child of the entry to move" << endl;
} else { } else {
entry->setParent(static_cast<NodeEntry *>(newParent)); entry->setParent(static_cast<NodeEntry *>(newParent));
@ -540,17 +541,17 @@ void InteractiveCli::moveEntry(const string &path)
void InteractiveCli::readField(const string &fieldName) void InteractiveCli::readField(const string &fieldName)
{ {
if(m_file.isOpen()) { if (m_file.isOpen()) {
if(m_currentEntry->type() == EntryType::Account) { if (m_currentEntry->type() == EntryType::Account) {
const vector<Field> &fields = static_cast<AccountEntry *>(m_currentEntry)->fields(); const vector<Field> &fields = static_cast<AccountEntry *>(m_currentEntry)->fields();
bool valuesFound = false; bool valuesFound = false;
for(const Field &field : fields) { for (const Field &field : fields) {
if(field.name() == fieldName) { if (field.name() == fieldName) {
m_o << field.value() << endl; m_o << field.value() << endl;
valuesFound = true; valuesFound = true;
} }
} }
if(!valuesFound) { if (!valuesFound) {
m_o << "field \"" << fieldName << "\" does not exist" << endl; m_o << "field \"" << fieldName << "\" does not exist" << endl;
} }
} else { } else {
@ -563,40 +564,40 @@ void InteractiveCli::readField(const string &fieldName)
void InteractiveCli::setField(bool useMuter, const string &fieldName) void InteractiveCli::setField(bool useMuter, const string &fieldName)
{ {
if(m_file.isOpen()) { if (m_file.isOpen()) {
if(m_currentEntry->type() == EntryType::Account) { if (m_currentEntry->type() == EntryType::Account) {
vector<Field> &fields = static_cast<AccountEntry *>(m_currentEntry)->fields(); vector<Field> &fields = static_cast<AccountEntry *>(m_currentEntry)->fields();
unsigned int valuesFound = 0; unsigned int valuesFound = 0;
string value; string value;
m_o << "enter new value: "; m_o << "enter new value: ";
if(useMuter) { if (useMuter) {
InputMuter m; InputMuter m;
getline(m_i, value); getline(m_i, value);
m_o << endl << "repeat: "; m_o << endl << "repeat: ";
string repeat; string repeat;
getline(m_i, repeat); getline(m_i, repeat);
if(value != repeat) { if (value != repeat) {
m_o << "values do not match; field has not been altered" << endl; m_o << "values do not match; field has not been altered" << endl;
return; return;
} }
} else { } else {
getline(m_i, value); getline(m_i, value);
} }
for(Field &field : fields) { for (Field &field : fields) {
if(field.name() == fieldName) { if (field.name() == fieldName) {
++valuesFound; ++valuesFound;
if(valuesFound == 1) { if (valuesFound == 1) {
field.setValue(value); field.setValue(value);
} else { } else {
m_o << "enter new value for " << valuesFound << ". field (with the specified field): "; m_o << "enter new value for " << valuesFound << ". field (with the specified field): ";
value.clear(); value.clear();
if(useMuter) { if (useMuter) {
InputMuter m; InputMuter m;
getline(m_i, value); getline(m_i, value);
m_o << endl << "repeat: "; m_o << endl << "repeat: ";
string repeat; string repeat;
getline(m_i, repeat); getline(m_i, repeat);
if(value == repeat) { if (value == repeat) {
field.setValue(value); field.setValue(value);
} else { } else {
m_o << "values do not match; field has not been altered" << endl; m_o << "values do not match; field has not been altered" << endl;
@ -609,10 +610,10 @@ void InteractiveCli::setField(bool useMuter, const string &fieldName)
field.setType(useMuter ? FieldType::Password : FieldType::Normal); field.setType(useMuter ? FieldType::Password : FieldType::Normal);
} }
} }
switch(valuesFound) { switch (valuesFound) {
case 0: case 0:
fields.emplace_back(static_cast<AccountEntry *>(m_currentEntry), fieldName, value); fields.emplace_back(static_cast<AccountEntry *>(m_currentEntry), fieldName, value);
if(useMuter) { if (useMuter) {
fields.back().setType(FieldType::Password); fields.back().setType(FieldType::Password);
} }
m_o << "new field with value inserted" << endl; m_o << "new field with value inserted" << endl;
@ -635,27 +636,25 @@ void InteractiveCli::setField(bool useMuter, const string &fieldName)
void InteractiveCli::removeField(const string &fieldName) void InteractiveCli::removeField(const string &fieldName)
{ {
if(m_file.isOpen()) { if (m_file.isOpen()) {
if(m_currentEntry->type() == EntryType::Account) { if (m_currentEntry->type() == EntryType::Account) {
vector<Field> &fields = static_cast<AccountEntry *>(m_currentEntry)->fields(); vector<Field> &fields = static_cast<AccountEntry *>(m_currentEntry)->fields();
unsigned int valuesFound = 0; unsigned int valuesFound = 0;
for(Field &field : fields) { for (Field &field : fields) {
if(field.name() == fieldName) { if (field.name() == fieldName) {
++valuesFound; ++valuesFound;
} }
} }
switch(valuesFound) { switch (valuesFound) {
valuesFound = 0; valuesFound = 0;
case 0: case 0:
break; break;
case 1: case 1:
fields.erase(remove_if(fields.begin(), fields.end(), [&fieldName] (Field &field) { fields.erase(remove_if(fields.begin(), fields.end(), [&fieldName](Field &field) { return field.name() == fieldName; }));
return field.name() == fieldName;
}));
break; break;
default: default:
fields.erase(remove_if(fields.begin(), fields.end(), [this, &fieldName, &valuesFound] (Field &field) { fields.erase(remove_if(fields.begin(), fields.end(), [this, &fieldName, &valuesFound](Field &field) {
if(field.name() == fieldName) { if (field.name() == fieldName) {
m_o << "remove " << ++valuesFound << ". occurrence? [y]=yes, different key=no " << endl; m_o << "remove " << ++valuesFound << ". occurrence? [y]=yes, different key=no " << endl;
string res; string res;
getline(m_i, res); getline(m_i, res);
@ -665,7 +664,7 @@ void InteractiveCli::removeField(const string &fieldName)
} }
})); }));
} }
switch(valuesFound) { switch (valuesFound) {
case 0: case 0:
m_o << "can not remove field; specified field \"" << fieldName << "\" not found" << endl; m_o << "can not remove field; specified field \"" << fieldName << "\" not found" << endl;
break; break;
@ -714,12 +713,13 @@ void InteractiveCli::printHelp()
"readfield,rf reads the specified field of the current account\n" "readfield,rf reads the specified field of the current account\n"
"setfield,sf sets the specified field of the current account\n" "setfield,sf sets the specified field of the current account\n"
"setfieldpw,sp sets the specified password field of the current account\n" "setfieldpw,sp sets the specified password field of the current account\n"
"rmfield,rf removes the specified field of the current account\n" << endl; "rmfield,rf removes the specified field of the current account\n"
<< endl;
} }
void InteractiveCli::quit() void InteractiveCli::quit()
{ {
if(m_file.isOpen() && m_modified) { if (m_file.isOpen() && m_modified) {
m_o << "file modified; use q! or wq" << endl; m_o << "file modified; use q! or wq" << endl;
} else { } else {
m_quit = true; m_quit = true;
@ -728,7 +728,7 @@ void InteractiveCli::quit()
string InteractiveCli::askForPassphrase(bool confirm) string InteractiveCli::askForPassphrase(bool confirm)
{ {
if(confirm) { if (confirm) {
m_o << "enter new passphrase: "; m_o << "enter new passphrase: ";
} else { } else {
m_o << "enter passphrase: "; m_o << "enter passphrase: ";
@ -740,10 +740,10 @@ string InteractiveCli::askForPassphrase(bool confirm)
getline(m_i, input1); getline(m_i, input1);
} }
m_o << endl; m_o << endl;
if(input1.empty()) { if (input1.empty()) {
m_o << "you did not enter a passphrase" << endl; m_o << "you did not enter a passphrase" << endl;
} else { } else {
if(confirm) { if (confirm) {
m_o << "confirm new passphrase: "; m_o << "confirm new passphrase: ";
m_o.flush(); m_o.flush();
string input2; string input2;
@ -752,7 +752,7 @@ string InteractiveCli::askForPassphrase(bool confirm)
getline(m_i, input2); getline(m_i, input2);
} }
m_o << endl; m_o << endl;
if(input1 != input2) { if (input1 != input2) {
m_o << "phrases do not match" << endl; m_o << "phrases do not match" << endl;
throw runtime_error("confirmation failed"); throw runtime_error("confirmation failed");
} }
@ -760,6 +760,4 @@ string InteractiveCli::askForPassphrase(bool confirm)
} }
return input1; return input1;
} }
} }

View File

@ -4,15 +4,15 @@
#include <passwordfile/io/passwordfile.h> #include <passwordfile/io/passwordfile.h>
#if defined(PLATFORM_UNIX) #if defined(PLATFORM_UNIX)
# include <termios.h> #include <termios.h>
#elif defined(PLATFORM_WINDOWS) #elif defined(PLATFORM_WINDOWS)
# include <windows.h> #include <windows.h>
#endif #endif
#include <string>
#include <vector>
#include <istream> #include <istream>
#include <ostream> #include <ostream>
#include <string>
#include <vector>
namespace ApplicationUtilities { namespace ApplicationUtilities {
typedef std::vector<std::string> StringVector; typedef std::vector<std::string> StringVector;
@ -25,8 +25,7 @@ enum class EntryType : int;
namespace Cli { namespace Cli {
class InputMuter class InputMuter {
{
public: public:
InputMuter(); InputMuter();
~InputMuter(); ~InputMuter();
@ -42,8 +41,7 @@ private:
void clearConsole(); void clearConsole();
class InteractiveCli class InteractiveCli {
{
public: public:
InteractiveCli(); InteractiveCli();
void run(const std::string &file = std::string()); void run(const std::string &file = std::string());
@ -80,7 +78,6 @@ private:
bool m_modified; bool m_modified;
bool m_quit; bool m_quit;
}; };
} }
#endif // CLI_CLI_H #endif // CLI_CLI_H

View File

@ -11,18 +11,20 @@ using namespace Io;
namespace QtGui { namespace QtGui {
FieldDelegate::FieldDelegate(QObject *parent) : FieldDelegate::FieldDelegate(QObject *parent)
QStyledItemDelegate(parent) : QStyledItemDelegate(parent)
{} {
}
void FieldDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const void FieldDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{ {
if(auto *lineEdit = qobject_cast<QLineEdit *>(editor)) { if (auto *lineEdit = qobject_cast<QLineEdit *>(editor)) {
const auto *model = index.model(); const auto *model = index.model();
lineEdit->setText(model->data(index, Qt::EditRole).toString()); lineEdit->setText(model->data(index, Qt::EditRole).toString());
if(const auto *fieldModel = qobject_cast<const FieldModel *>(model)) { if (const auto *fieldModel = qobject_cast<const FieldModel *>(model)) {
if(fieldModel->passwordVisibility() == PasswordVisibility::Never) { if (fieldModel->passwordVisibility() == PasswordVisibility::Never) {
lineEdit->setEchoMode(fieldModel->field(static_cast<size_t>(index.row()))->type() != FieldType::Password ? QLineEdit::Normal : QLineEdit::Password); lineEdit->setEchoMode(
fieldModel->field(static_cast<size_t>(index.row()))->type() != FieldType::Password ? QLineEdit::Normal : QLineEdit::Password);
} else { } else {
lineEdit->setEchoMode(QLineEdit::Normal); lineEdit->setEchoMode(QLineEdit::Normal);
} }
@ -35,4 +37,3 @@ void FieldDelegate::setEditorData(QWidget *editor, const QModelIndex &index) con
} }
} // namespace QtGui } // namespace QtGui

View File

@ -5,8 +5,7 @@
namespace QtGui { namespace QtGui {
class FieldDelegate : public QStyledItemDelegate class FieldDelegate : public QStyledItemDelegate {
{
public: public:
FieldDelegate(QObject *parent = nullptr); FieldDelegate(QObject *parent = nullptr);

View File

@ -12,7 +12,6 @@ class QtConfigArguments;
namespace QtGui { namespace QtGui {
int runWidgetsGui(int argc, char *argv[], const ApplicationUtilities::QtConfigArguments &qtConfigArgs, const QString &file); int runWidgetsGui(int argc, char *argv[], const ApplicationUtilities::QtConfigArguments &qtConfigArgs, const QString &file);
} }
#endif // INITIATE_H #endif // INITIATE_H

View File

@ -4,14 +4,14 @@
#include "resources/config.h" #include "resources/config.h"
#include <qtutilities/resources/importplugin.h>
#include <qtutilities/resources/qtconfigarguments.h> #include <qtutilities/resources/qtconfigarguments.h>
#include <qtutilities/resources/resources.h> #include <qtutilities/resources/resources.h>
#include <qtutilities/resources/importplugin.h>
#include <qtutilities/settingsdialog/qtsettings.h> #include <qtutilities/settingsdialog/qtsettings.h>
#include <QApplication> #include <QApplication>
#include <QSettings>
#include <QFile> #include <QFile>
#include <QSettings>
using namespace ApplicationUtilities; using namespace ApplicationUtilities;
using namespace Dialogs; using namespace Dialogs;
@ -27,7 +27,8 @@ int runWidgetsGui(int argc, char *argv[], const QtConfigArguments &qtConfigArgs,
QtSettings qtSettings; QtSettings qtSettings;
QSettings settings(QSettings::IniFormat, QSettings::UserScope, QStringLiteral(PROJECT_NAME)); QSettings settings(QSettings::IniFormat, QSettings::UserScope, QStringLiteral(PROJECT_NAME));
// move old config to new location // move old config to new location
const QString oldConfig = QSettings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), QApplication::applicationName()).fileName(); const QString oldConfig
= QSettings(QSettings::IniFormat, QSettings::UserScope, QApplication::organizationName(), QApplication::applicationName()).fileName();
QFile::rename(oldConfig, settings.fileName()) || QFile::remove(oldConfig); QFile::rename(oldConfig, settings.fileName()) || QFile::remove(oldConfig);
settings.sync(); settings.sync();
qtSettings.restore(settings); qtSettings.restore(settings);
@ -38,7 +39,7 @@ int runWidgetsGui(int argc, char *argv[], const QtConfigArguments &qtConfigArgs,
// init widgets GUI // init widgets GUI
MainWindow w(settings, &qtSettings); MainWindow w(settings, &qtSettings);
w.show(); w.show();
if(!file.isEmpty()) { if (!file.isEmpty()) {
w.openFile(file); w.openFile(file);
} }
// start event loop // start event loop
@ -47,5 +48,4 @@ int runWidgetsGui(int argc, char *argv[], const QtConfigArguments &qtConfigArgs,
qtSettings.save(settings); qtSettings.save(settings);
return res; return res;
} }
} }

View File

@ -1,9 +1,9 @@
#include "./mainwindow.h" #include "./mainwindow.h"
#include "./fielddelegate.h" #include "./fielddelegate.h"
#include "../model/fieldmodel.h"
#include "../model/entrymodel.h"
#include "../model/entryfiltermodel.h" #include "../model/entryfiltermodel.h"
#include "../model/entrymodel.h"
#include "../model/fieldmodel.h"
#include "ui_mainwindow.h" #include "ui_mainwindow.h"
@ -12,34 +12,34 @@
#include <passwordfile/io/cryptoexception.h> #include <passwordfile/io/cryptoexception.h>
#include <passwordfile/io/entry.h> #include <passwordfile/io/entry.h>
#include <qtutilities/enterpassworddialog/enterpassworddialog.h>
#include <qtutilities/misc/dialogutils.h>
#include <qtutilities/misc/desktoputils.h>
#include <qtutilities/misc/recentmenumanager.h>
#include <qtutilities/aboutdialog/aboutdialog.h> #include <qtutilities/aboutdialog/aboutdialog.h>
#include <qtutilities/settingsdialog/settingsdialog.h> #include <qtutilities/enterpassworddialog/enterpassworddialog.h>
#include <qtutilities/misc/desktoputils.h>
#include <qtutilities/misc/dialogutils.h>
#include <qtutilities/misc/recentmenumanager.h>
#include <qtutilities/settingsdialog/optioncategorymodel.h> #include <qtutilities/settingsdialog/optioncategorymodel.h>
#include <qtutilities/settingsdialog/qtsettings.h> #include <qtutilities/settingsdialog/qtsettings.h>
#include <qtutilities/settingsdialog/settingsdialog.h>
#include <c++utilities/io/path.h>
#include <c++utilities/io/catchiofailure.h>
#include <c++utilities/conversion/stringconversion.h> #include <c++utilities/conversion/stringconversion.h>
#include <c++utilities/io/catchiofailure.h>
#include <c++utilities/io/path.h>
#include <QFileDialog>
#include <QMessageBox>
#include <QInputDialog>
#include <QActionGroup> #include <QActionGroup>
#include <QClipboard> #include <QClipboard>
#include <QSettings>
#include <QCloseEvent> #include <QCloseEvent>
#include <QDesktopServices>
#include <QFileDialog>
#include <QInputDialog>
#include <QMessageBox>
#include <QMimeData>
#include <QSettings>
#include <QTimerEvent> #include <QTimerEvent>
#include <QUndoStack> #include <QUndoStack>
#include <QUndoView> #include <QUndoView>
#include <QMimeData>
#include <QDesktopServices>
#include <stdexcept>
#include <cassert> #include <cassert>
#include <stdexcept>
using namespace std; using namespace std;
using namespace IoUtilities; using namespace IoUtilities;
@ -101,7 +101,7 @@ void MainWindow::setSomethingChanged()
*/ */
void MainWindow::setSomethingChanged(bool somethingChanged) void MainWindow::setSomethingChanged(bool somethingChanged)
{ {
if(m_somethingChanged != somethingChanged) { if (m_somethingChanged != somethingChanged) {
m_somethingChanged = somethingChanged; m_somethingChanged = somethingChanged;
updateWindowTitle(); updateWindowTitle();
} }
@ -110,19 +110,21 @@ void MainWindow::setSomethingChanged(bool somethingChanged)
/*! /*!
* \brief Constructs a new main window. * \brief Constructs a new main window.
*/ */
MainWindow::MainWindow(QSettings &settings, Dialogs::QtSettings *qtSettings, QWidget *parent) : MainWindow::MainWindow(QSettings &settings, Dialogs::QtSettings *qtSettings, QWidget *parent)
QMainWindow(parent), : QMainWindow(parent)
m_ui(new Ui::MainWindow), , m_ui(new Ui::MainWindow)
m_clearClipboardTimer(0), , m_clearClipboardTimer(0)
m_aboutDlg(nullptr), , m_aboutDlg(nullptr)
m_settings(settings), , m_settings(settings)
m_qtSettings(qtSettings), , m_qtSettings(qtSettings)
m_settingsDlg(nullptr) , m_settingsDlg(nullptr)
{ {
// setup ui // setup ui
m_ui->setupUi(this); m_ui->setupUi(this);
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN32
setStyleSheet(QStringLiteral("%1 #splitter QWidget { background-color: palette(base); color: palette(text); } #splitter QWidget *, #splitter QWidget * { background-color: none; } #leftWidget { border-right: 1px solid %2; }").arg(dialogStyle(), windowFrameColor().name())); setStyleSheet(QStringLiteral("%1 #splitter QWidget { background-color: palette(base); color: palette(text); } #splitter QWidget *, #splitter "
"QWidget * { background-color: none; } #leftWidget { border-right: 1px solid %2; }")
.arg(dialogStyle(), windowFrameColor().name()));
#endif #endif
// set default values // set default values
setSomethingChanged(false); setSomethingChanged(false);
@ -165,9 +167,9 @@ MainWindow::MainWindow(QSettings &settings, Dialogs::QtSettings *qtSettings, QWi
passwordVisibilityGroup->addAction(m_ui->actionHideAlways); passwordVisibilityGroup->addAction(m_ui->actionHideAlways);
QString pwVisibility(settings.value(QStringLiteral("pwvisibility")).toString()); QString pwVisibility(settings.value(QStringLiteral("pwvisibility")).toString());
QAction *pwVisibilityAction; QAction *pwVisibilityAction;
if(pwVisibility == QStringLiteral("always")) { if (pwVisibility == QStringLiteral("always")) {
pwVisibilityAction = m_ui->actionShowAlways; pwVisibilityAction = m_ui->actionShowAlways;
} else if(pwVisibility == QStringLiteral("hidden")) { } else if (pwVisibility == QStringLiteral("hidden")) {
pwVisibilityAction = m_ui->actionHideAlways; pwVisibilityAction = m_ui->actionHideAlways;
} else { } else {
pwVisibilityAction = m_ui->actionShowOnlyWhenEditing; pwVisibilityAction = m_ui->actionShowOnlyWhenEditing;
@ -225,43 +227,42 @@ MainWindow::MainWindow(QSettings &settings, Dialogs::QtSettings *qtSettings, QWi
* \brief Destroys the main window. * \brief Destroys the main window.
*/ */
MainWindow::~MainWindow() MainWindow::~MainWindow()
{} {
}
bool MainWindow::eventFilter(QObject *obj, QEvent *event) bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{ {
if(obj == m_undoView) { if (obj == m_undoView) {
switch(event->type()) { switch (event->type()) {
case QEvent::Hide: case QEvent::Hide:
m_ui->actionShowUndoStack->setChecked(false); m_ui->actionShowUndoStack->setChecked(false);
break; break;
default: default:;
;
} }
} else if(obj == m_ui->centralWidget) { } else if (obj == m_ui->centralWidget) {
switch(event->type()) { switch (event->type()) {
case QEvent::DragEnter: case QEvent::DragEnter:
case QEvent::Drop: case QEvent::Drop:
if(QDropEvent *dropEvent = static_cast<QDropEvent *>(event)) { if (QDropEvent *dropEvent = static_cast<QDropEvent *>(event)) {
QString data; QString data;
const QMimeData *mimeData = dropEvent->mimeData(); const QMimeData *mimeData = dropEvent->mimeData();
if(mimeData->hasUrls()) { if (mimeData->hasUrls()) {
const QUrl url = mimeData->urls().front(); const QUrl url = mimeData->urls().front();
if(url.scheme() == QLatin1String("file")) { if (url.scheme() == QLatin1String("file")) {
data = url.path(); data = url.path();
} }
} else if(mimeData->hasText()) { } else if (mimeData->hasText()) {
data = mimeData->text(); data = mimeData->text();
} }
if(!data.isEmpty()) { if (!data.isEmpty()) {
event->accept(); event->accept();
if(event->type() == QEvent::Drop) { if (event->type() == QEvent::Drop) {
openFile(data); openFile(data);
} }
} }
return true; return true;
} }
default: default:;
;
} }
} }
return QMainWindow::eventFilter(obj, event); return QMainWindow::eventFilter(obj, event);
@ -270,14 +271,14 @@ bool MainWindow::eventFilter(QObject *obj, QEvent *event)
void MainWindow::closeEvent(QCloseEvent *event) void MainWindow::closeEvent(QCloseEvent *event)
{ {
// ask if file is opened // ask if file is opened
if(m_file.hasRootEntry()) { if (m_file.hasRootEntry()) {
if(!closeFile()) { if (!closeFile()) {
event->ignore(); event->ignore();
return; return;
} }
} }
// close undow view // close undow view
if(m_undoView) { if (m_undoView) {
m_undoView->close(); m_undoView->close();
} }
// save settings // save settings
@ -288,9 +289,9 @@ void MainWindow::closeEvent(QCloseEvent *event)
m_settings.setValue(QStringLiteral("accountfilter"), m_ui->accountFilterLineEdit->text()); m_settings.setValue(QStringLiteral("accountfilter"), m_ui->accountFilterLineEdit->text());
m_settings.setValue(QStringLiteral("alwayscreatebackup"), m_ui->actionAlwaysCreateBackup->isChecked()); m_settings.setValue(QStringLiteral("alwayscreatebackup"), m_ui->actionAlwaysCreateBackup->isChecked());
QString pwVisibility; QString pwVisibility;
if(m_ui->actionShowAlways->isChecked()) { if (m_ui->actionShowAlways->isChecked()) {
pwVisibility = QStringLiteral("always"); pwVisibility = QStringLiteral("always");
} else if(m_ui->actionHideAlways->isChecked()) { } else if (m_ui->actionHideAlways->isChecked()) {
pwVisibility = QStringLiteral("hidden"); pwVisibility = QStringLiteral("hidden");
} else { } else {
pwVisibility = QStringLiteral("editing"); pwVisibility = QStringLiteral("editing");
@ -301,7 +302,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
void MainWindow::timerEvent(QTimerEvent *event) void MainWindow::timerEvent(QTimerEvent *event)
{ {
if(event->timerId() == m_clearClipboardTimer) { if (event->timerId() == m_clearClipboardTimer) {
clearClipboard(); clearClipboard();
m_clearClipboardTimer = 0; m_clearClipboardTimer = 0;
} }
@ -312,15 +313,15 @@ void MainWindow::timerEvent(QTimerEvent *event)
*/ */
void MainWindow::showSettingsDialog() void MainWindow::showSettingsDialog()
{ {
if(!m_settingsDlg) { if (!m_settingsDlg) {
m_settingsDlg = new SettingsDialog(this); m_settingsDlg = new SettingsDialog(this);
if(m_qtSettings) { if (m_qtSettings) {
m_settingsDlg->setWindowTitle(tr("Qt settings")); m_settingsDlg->setWindowTitle(tr("Qt settings"));
m_settingsDlg->setSingleCategory(m_qtSettings->category()); m_settingsDlg->setSingleCategory(m_qtSettings->category());
} }
//connect(m_settingsDlg, &SettingsDialog::applied, this, &MainWindow::settingsAccepted); //connect(m_settingsDlg, &SettingsDialog::applied, this, &MainWindow::settingsAccepted);
} }
if(m_settingsDlg->isHidden()) { if (m_settingsDlg->isHidden()) {
m_settingsDlg->showNormal(); m_settingsDlg->showNormal();
} else { } else {
m_settingsDlg->activateWindow(); m_settingsDlg->activateWindow();
@ -332,8 +333,9 @@ void MainWindow::showSettingsDialog()
*/ */
void MainWindow::showAboutDialog() void MainWindow::showAboutDialog()
{ {
if(!m_aboutDlg) { if (!m_aboutDlg) {
m_aboutDlg = new AboutDialog(this, tr("A simple password store using AES-256-CBC encryption via OpenSSL."), QImage(":/icons/hicolor/128x128/apps/passwordmanager.png")); m_aboutDlg = new AboutDialog(this, tr("A simple password store using AES-256-CBC encryption via OpenSSL."),
QImage(":/icons/hicolor/128x128/apps/passwordmanager.png"));
} }
m_aboutDlg->show(); m_aboutDlg->show();
} }
@ -343,7 +345,7 @@ void MainWindow::showAboutDialog()
*/ */
void MainWindow::showPassowrdGeneratorDialog() void MainWindow::showPassowrdGeneratorDialog()
{ {
PasswordGeneratorDialog* pwgDialog = new PasswordGeneratorDialog(this); PasswordGeneratorDialog *pwgDialog = new PasswordGeneratorDialog(this);
pwgDialog->show(); pwgDialog->show();
} }
@ -352,11 +354,12 @@ void MainWindow::showPassowrdGeneratorDialog()
*/ */
void MainWindow::showOpenFileDialog() void MainWindow::showOpenFileDialog()
{ {
if(m_file.hasRootEntry() && !closeFile()) { if (m_file.hasRootEntry() && !closeFile()) {
return; return;
} }
QString fileName = QFileDialog::getOpenFileName(this, tr("Select a password list"), QString(), tr("Password Manager files (*.pwmgr);;All files (*)")); QString fileName
if(!fileName.isEmpty()) { = QFileDialog::getOpenFileName(this, tr("Select a password list"), QString(), tr("Password Manager files (*.pwmgr);;All files (*)"));
if (!fileName.isEmpty()) {
openFile(fileName); openFile(fileName);
} }
} }
@ -366,10 +369,10 @@ void MainWindow::showOpenFileDialog()
*/ */
void MainWindow::showSaveFileDialog() void MainWindow::showSaveFileDialog()
{ {
if(showNoFileOpened()) { if (showNoFileOpened()) {
return; return;
} }
if(askForCreatingFile()) { if (askForCreatingFile()) {
saveFile(); saveFile();
} }
} }
@ -379,8 +382,8 @@ void MainWindow::showSaveFileDialog()
*/ */
void MainWindow::showUndoView() void MainWindow::showUndoView()
{ {
if(m_ui->actionShowUndoStack->isChecked()) { if (m_ui->actionShowUndoStack->isChecked()) {
if(!m_undoView) { if (!m_undoView) {
m_undoView = new QUndoView(m_undoStack); m_undoView = new QUndoView(m_undoStack);
m_undoView->setWindowTitle(tr("Undo stack")); m_undoView->setWindowTitle(tr("Undo stack"));
m_undoView->setWindowFlags(Qt::Tool); m_undoView->setWindowFlags(Qt::Tool);
@ -389,7 +392,7 @@ void MainWindow::showUndoView()
m_undoView->installEventFilter(this); m_undoView->installEventFilter(this);
} }
m_undoView->show(); m_undoView->show();
} else if(m_undoView) { } else if (m_undoView) {
m_undoView->hide(); m_undoView->hide();
} }
} }
@ -402,7 +405,7 @@ bool MainWindow::openFile(const QString &path)
{ {
using namespace Dialogs; using namespace Dialogs;
// close previous file // close previous file
if(m_file.hasRootEntry() && !closeFile()) { if (m_file.hasRootEntry() && !closeFile()) {
return false; return false;
} }
// set path and open file // set path and open file
@ -410,27 +413,30 @@ bool MainWindow::openFile(const QString &path)
try { try {
m_file.open(); m_file.open();
} catch (...) { } catch (...) {
const QString errmsg = tr("An IO error occured when opening the specified file \"%1\".\n\n(%2)").arg(path, QString::fromLocal8Bit(catchIoFailure())); const QString errmsg
= tr("An IO error occured when opening the specified file \"%1\".\n\n(%2)").arg(path, QString::fromLocal8Bit(catchIoFailure()));
m_ui->statusBar->showMessage(errmsg, 5000); m_ui->statusBar->showMessage(errmsg, 5000);
QMessageBox::critical(this, QApplication::applicationName(), errmsg); QMessageBox::critical(this, QApplication::applicationName(), errmsg);
return false; return false;
} }
// warn before loading a very big file // warn before loading a very big file
if(m_file.size() > 10485760) { if (m_file.size() > 10485760) {
if(QMessageBox::warning(this, QApplication::applicationName(), tr("The file you want to load seems to be very big. Do you really want to open it?"), QMessageBox::Yes, QMessageBox::No) == QMessageBox::No) { if (QMessageBox::warning(this, QApplication::applicationName(),
tr("The file you want to load seems to be very big. Do you really want to open it?"), QMessageBox::Yes, QMessageBox::No)
== QMessageBox::No) {
m_file.clear(); m_file.clear();
return false; return false;
} }
} }
// ask for a password if required // ask for a password if required
if(m_file.isEncryptionUsed()) { if (m_file.isEncryptionUsed()) {
EnterPasswordDialog pwDlg(this); EnterPasswordDialog pwDlg(this);
pwDlg.setWindowTitle(tr("Opening file") + QStringLiteral(" - " APP_NAME)); pwDlg.setWindowTitle(tr("Opening file") + QStringLiteral(" - " APP_NAME));
pwDlg.setInstruction(tr("Enter the password to open the file \"%1\"").arg(path)); pwDlg.setInstruction(tr("Enter the password to open the file \"%1\"").arg(path));
pwDlg.setPasswordRequired(true); pwDlg.setPasswordRequired(true);
switch(pwDlg.exec()) { switch (pwDlg.exec()) {
case QDialog::Accepted: case QDialog::Accepted:
if(pwDlg.password().isEmpty()) { if (pwDlg.password().isEmpty()) {
m_ui->statusBar->showMessage(tr("A password is needed to open the file."), 5000); m_ui->statusBar->showMessage(tr("A password is needed to open the file."), 5000);
QMessageBox::warning(this, QApplication::applicationName(), tr("A password is needed to open the file.")); QMessageBox::warning(this, QApplication::applicationName(), tr("A password is needed to open the file."));
m_file.clear(); m_file.clear();
@ -441,8 +447,7 @@ bool MainWindow::openFile(const QString &path)
case QDialog::Rejected: case QDialog::Rejected:
m_file.clear(); m_file.clear();
return false; return false;
default: default:;
;
} }
m_file.setPassword(pwDlg.password().toStdString()); m_file.setPassword(pwDlg.password().toStdString());
} }
@ -450,21 +455,20 @@ bool MainWindow::openFile(const QString &path)
QString msg; QString msg;
try { try {
m_file.load(); m_file.load();
} catch(const CryptoException &e) { } catch (const CryptoException &e) {
msg = tr("The file couldn't be decrypted.\nOpenSSL error queue: %1").arg(QString::fromLocal8Bit(e.what())); msg = tr("The file couldn't be decrypted.\nOpenSSL error queue: %1").arg(QString::fromLocal8Bit(e.what()));
} catch (...) { } catch (...) {
try { try {
msg = QString::fromLocal8Bit(catchIoFailure()); msg = QString::fromLocal8Bit(catchIoFailure());
} catch(const runtime_error &e) { } catch (const runtime_error &e) {
msg = tr("Unable to parse the file. %1").arg(QString::fromLocal8Bit(e.what())); msg = tr("Unable to parse the file. %1").arg(QString::fromLocal8Bit(e.what()));
} }
} }
// show a message in the error case // show a message in the error case
if(!msg.isEmpty()) { if (!msg.isEmpty()) {
m_file.clear(); m_file.clear();
m_ui->statusBar->showMessage(msg, 5000); m_ui->statusBar->showMessage(msg, 5000);
if(QMessageBox::critical(this, QApplication::applicationName(), msg, if (QMessageBox::critical(this, QApplication::applicationName(), msg, QMessageBox::Cancel, QMessageBox::Retry) == QMessageBox::Retry) {
QMessageBox::Cancel, QMessageBox::Retry) == QMessageBox::Retry) {
return openFile(path); // retry return openFile(path); // retry
} else { } else {
return false; return false;
@ -482,7 +486,7 @@ bool MainWindow::openFile(const QString &path)
bool MainWindow::createFile() bool MainWindow::createFile()
{ {
// close previous file // close previous file
if(m_file.hasRootEntry() && !closeFile()) { if (m_file.hasRootEntry() && !closeFile()) {
return false; return false;
} }
m_file.generateRootEntry(); m_file.generateRootEntry();
@ -505,7 +509,7 @@ void MainWindow::createFile(const QString &path)
void MainWindow::createFile(const QString &path, const QString &password) void MainWindow::createFile(const QString &path, const QString &password)
{ {
// close previous file // close previous file
if(m_file.hasRootEntry() && !closeFile()) { if (m_file.hasRootEntry() && !closeFile()) {
return; return;
} }
// set path and password // set path and password
@ -532,7 +536,7 @@ bool MainWindow::showFile()
m_fieldModel->reset(); m_fieldModel->reset();
m_entryModel->setRootEntry(m_file.rootEntry()); m_entryModel->setRootEntry(m_file.rootEntry());
applyDefaultExpanding(QModelIndex()); applyDefaultExpanding(QModelIndex());
if(m_file.path().empty()) { if (m_file.path().empty()) {
m_ui->statusBar->showMessage(tr("A new password list has been created."), 5000); m_ui->statusBar->showMessage(tr("A new password list has been created."), 5000);
} else { } else {
m_recentMgr->addEntry(QString::fromStdString(m_file.path())); m_recentMgr->addEntry(QString::fromStdString(m_file.path()));
@ -569,8 +573,8 @@ void MainWindow::updateUiStatus()
void MainWindow::updateWindowTitle() void MainWindow::updateWindowTitle()
{ {
Dialogs::DocumentStatus docStatus; Dialogs::DocumentStatus docStatus;
if(m_file.hasRootEntry()) { if (m_file.hasRootEntry()) {
if(m_somethingChanged) { if (m_somethingChanged) {
docStatus = Dialogs::DocumentStatus::Unsaved; docStatus = Dialogs::DocumentStatus::Unsaved;
} else { } else {
docStatus = Dialogs::DocumentStatus::Saved; docStatus = Dialogs::DocumentStatus::Saved;
@ -583,9 +587,9 @@ void MainWindow::updateWindowTitle()
void MainWindow::applyDefaultExpanding(const QModelIndex &parent) void MainWindow::applyDefaultExpanding(const QModelIndex &parent)
{ {
for(int row = 0, rows = m_entryFilterModel->rowCount(parent); row < rows; ++row) { for (int row = 0, rows = m_entryFilterModel->rowCount(parent); row < rows; ++row) {
QModelIndex index = m_entryFilterModel->index(row, 0, parent); QModelIndex index = m_entryFilterModel->index(row, 0, parent);
if(!index.isValid()) { if (!index.isValid()) {
return; return;
} }
applyDefaultExpanding(index); applyDefaultExpanding(index);
@ -601,30 +605,30 @@ QString MainWindow::selectedFieldsString() const
{ {
QModelIndexList selectedIndexes = m_ui->tableView->selectionModel()->selectedIndexes(); QModelIndexList selectedIndexes = m_ui->tableView->selectionModel()->selectedIndexes();
QString text; QString text;
if(!selectedIndexes.isEmpty()) { if (!selectedIndexes.isEmpty()) {
if(selectedIndexes.size() > 1) { if (selectedIndexes.size() > 1) {
int maxRow = m_fieldModel->rowCount() - 1; int maxRow = m_fieldModel->rowCount() - 1;
int firstRow = maxRow, lastRow = 0; int firstRow = maxRow, lastRow = 0;
int maxCol = m_fieldModel->columnCount() - 1; int maxCol = m_fieldModel->columnCount() - 1;
int firstCol = maxCol, lastCol = 0; int firstCol = maxCol, lastCol = 0;
for(const QModelIndex &index : selectedIndexes) { for (const QModelIndex &index : selectedIndexes) {
if(index.row() < firstRow) { if (index.row() < firstRow) {
firstRow = index.row(); firstRow = index.row();
} }
if(index.row() > lastRow) { if (index.row() > lastRow) {
lastRow = index.row(); lastRow = index.row();
} }
if(index.column() < firstCol) { if (index.column() < firstCol) {
firstCol = index.column(); firstCol = index.column();
} }
if(index.column() > lastCol) { if (index.column() > lastCol) {
lastCol = index.column(); lastCol = index.column();
} }
} }
for(int row = firstRow; row <= lastRow; ++row) { for (int row = firstRow; row <= lastRow; ++row) {
for(int col = firstCol; col <= lastCol; ++col) { for (int col = firstCol; col <= lastCol; ++col) {
QModelIndex index = m_fieldModel->index(row, col); QModelIndex index = m_fieldModel->index(row, col);
if(selectedIndexes.contains(index)) { if (selectedIndexes.contains(index)) {
text.append(index.data(Qt::EditRole).toString()); text.append(index.data(Qt::EditRole).toString());
} }
text.append('\t'); text.append('\t');
@ -644,20 +648,20 @@ QString MainWindow::selectedFieldsString() const
void MainWindow::insertFields(const QString &fieldsString) void MainWindow::insertFields(const QString &fieldsString)
{ {
QModelIndexList selectedIndexes = m_ui->tableView->selectionModel()->selectedIndexes(); QModelIndexList selectedIndexes = m_ui->tableView->selectionModel()->selectedIndexes();
if(selectedIndexes.size() == 1) { if (selectedIndexes.size() == 1) {
int rows = m_fieldModel->rowCount(), cols = m_fieldModel->columnCount(); int rows = m_fieldModel->rowCount(), cols = m_fieldModel->columnCount();
int row = selectedIndexes.front().row(); int row = selectedIndexes.front().row();
int initCol = selectedIndexes.front().column(); int initCol = selectedIndexes.front().column();
assert(row < rows); assert(row < rows);
QStringList rowValues = fieldsString.split('\n'); QStringList rowValues = fieldsString.split('\n');
if(rowValues.back().isEmpty()) { if (rowValues.back().isEmpty()) {
rowValues.pop_back(); rowValues.pop_back();
} }
m_fieldModel->insertRows(row, rowValues.size(), QModelIndex()); m_fieldModel->insertRows(row, rowValues.size(), QModelIndex());
for(const QString &rowValue : rowValues) { for (const QString &rowValue : rowValues) {
int col = initCol; int col = initCol;
for(const QString &cellValue : rowValue.split('\t')) { for (const QString &cellValue : rowValue.split('\t')) {
if(col < cols) { if (col < cols) {
m_fieldModel->setData(m_fieldModel->index(row, col), cellValue, Qt::EditRole); m_fieldModel->setData(m_fieldModel->index(row, col), cellValue, Qt::EditRole);
++col; ++col;
} else { } else {
@ -676,17 +680,13 @@ void MainWindow::insertFields(const QString &fieldsString)
*/ */
bool MainWindow::askForCreatingFile() bool MainWindow::askForCreatingFile()
{ {
if(showNoFileOpened()) { if (showNoFileOpened()) {
return false; return false;
} }
QString fileName = QString fileName = QFileDialog::getSaveFileName(
QFileDialog::getSaveFileName( this, tr("Select where you want to save the password list"), QString(), tr("Password Manager files (*.pwmgr);;All files (*)"));
this, if (fileName.isEmpty()) {
tr("Select where you want to save the password list"),
QString(),
tr("Password Manager files (*.pwmgr);;All files (*)"));
if(fileName.isEmpty()) {
m_ui->statusBar->showMessage(tr("The file was not be saved."), 7000); m_ui->statusBar->showMessage(tr("The file was not be saved."), 7000);
return false; return false;
} else { } else {
@ -708,7 +708,7 @@ bool MainWindow::askForCreatingFile()
*/ */
bool MainWindow::showNoFileOpened() bool MainWindow::showNoFileOpened()
{ {
if(!m_file.hasRootEntry()) { if (!m_file.hasRootEntry()) {
QMessageBox::warning(this, QApplication::applicationName(), tr("There is no password list opened.")); QMessageBox::warning(this, QApplication::applicationName(), tr("There is no password list opened."));
return true; return true;
} }
@ -721,7 +721,7 @@ bool MainWindow::showNoFileOpened()
*/ */
bool MainWindow::showNoAccount() bool MainWindow::showNoAccount()
{ {
if(!m_fieldModel->fields()) { if (!m_fieldModel->fields()) {
QMessageBox::warning(this, QApplication::applicationName(), tr("There's no account selected.")); QMessageBox::warning(this, QApplication::applicationName(), tr("There's no account selected."));
return true; return true;
} }
@ -734,10 +734,10 @@ bool MainWindow::showNoAccount()
*/ */
bool MainWindow::closeFile() bool MainWindow::closeFile()
{ {
if(showNoFileOpened()) { if (showNoFileOpened()) {
return false; return false;
} }
if(m_somethingChanged) { if (m_somethingChanged) {
QMessageBox msg(this); QMessageBox msg(this);
msg.setText(tr("The password file has been modified.")); msg.setText(tr("The password file has been modified."));
msg.setInformativeText(tr("Do you want to save the changes before closing?")); msg.setInformativeText(tr("Do you want to save the changes before closing?"));
@ -745,16 +745,15 @@ bool MainWindow::closeFile()
msg.setDefaultButton(QMessageBox::Save); msg.setDefaultButton(QMessageBox::Save);
msg.setIcon(QMessageBox::Warning); msg.setIcon(QMessageBox::Warning);
switch (msg.exec()) { switch (msg.exec()) {
case QMessageBox::Save: case QMessageBox::Save:
if(saveFile()) { if (saveFile()) {
break; break;
} else { } else {
return false; return false;
} }
case QMessageBox::Cancel: case QMessageBox::Cancel:
return false; return false;
default: default:;
;
} }
} }
m_fieldModel->reset(); m_fieldModel->reset();
@ -774,34 +773,35 @@ bool MainWindow::closeFile()
bool MainWindow::saveFile() bool MainWindow::saveFile()
{ {
using namespace Dialogs; using namespace Dialogs;
if(showNoFileOpened()) { if (showNoFileOpened()) {
return false; return false;
} }
// create backup // create backup
if(!m_file.path().empty() && QFile::exists(QString::fromStdString(m_file.path()))) { if (!m_file.path().empty() && QFile::exists(QString::fromStdString(m_file.path()))) {
if(m_ui->actionAlwaysCreateBackup->isChecked()) { if (m_ui->actionAlwaysCreateBackup->isChecked()) {
try { try {
m_file.doBackup(); m_file.doBackup();
} catch(...) { } catch (...) {
QString message(tr("The backup file couldn't be created because in IO error occured: %1").arg(QString::fromLocal8Bit(catchIoFailure()))); QString message(
tr("The backup file couldn't be created because in IO error occured: %1").arg(QString::fromLocal8Bit(catchIoFailure())));
QMessageBox::critical(this, QApplication::applicationName(), message); QMessageBox::critical(this, QApplication::applicationName(), message);
m_ui->statusBar->showMessage(message, 7000); m_ui->statusBar->showMessage(message, 7000);
return false; return false;
} }
} }
} else { } else {
if(!askForCreatingFile()) { if (!askForCreatingFile()) {
return false; return false;
} }
} }
// ask for a password if none is set // ask for a password if none is set
if(m_file.password()[0] == 0) { if (m_file.password()[0] == 0) {
EnterPasswordDialog pwDlg(this); EnterPasswordDialog pwDlg(this);
pwDlg.setWindowTitle(tr("Saving file") + QStringLiteral(" - " APP_NAME)); pwDlg.setWindowTitle(tr("Saving file") + QStringLiteral(" - " APP_NAME));
pwDlg.setInstruction(tr("Enter a password to save the file")); pwDlg.setInstruction(tr("Enter a password to save the file"));
pwDlg.setVerificationRequired(true); pwDlg.setVerificationRequired(true);
switch(pwDlg.exec()) { switch (pwDlg.exec()) {
case QDialog::Accepted: case QDialog::Accepted:
m_file.setPassword(pwDlg.password().toStdString()); m_file.setPassword(pwDlg.password().toStdString());
break; break;
@ -816,14 +816,14 @@ bool MainWindow::saveFile()
m_file.save(m_file.password()[0] != 0); m_file.save(m_file.password()[0] != 0);
} catch (const CryptoException &ex) { } catch (const CryptoException &ex) {
msg = tr("The password list couldn't be saved due to encryption failure.\nOpenSSL error queue: %1").arg(QString::fromLocal8Bit(ex.what())); msg = tr("The password list couldn't be saved due to encryption failure.\nOpenSSL error queue: %1").arg(QString::fromLocal8Bit(ex.what()));
} catch(...) { } catch (...) {
msg = QString::fromLocal8Bit(catchIoFailure()); msg = QString::fromLocal8Bit(catchIoFailure());
} }
// show status // show status
if(!msg.isEmpty()) { if (!msg.isEmpty()) {
m_ui->statusBar->showMessage(msg, 5000); m_ui->statusBar->showMessage(msg, 5000);
QMessageBox::critical(this, QApplication::applicationName(), msg); QMessageBox::critical(this, QApplication::applicationName(), msg);
return false; return false;
} else { } else {
setSomethingChanged(false); setSomethingChanged(false);
m_recentMgr->addEntry(QString::fromStdString(m_file.path())); m_recentMgr->addEntry(QString::fromStdString(m_file.path()));
@ -837,22 +837,23 @@ bool MainWindow::saveFile()
*/ */
void MainWindow::exportFile() void MainWindow::exportFile()
{ {
if(showNoFileOpened()) { if (showNoFileOpened()) {
return; return;
} }
QString targetPath = QFileDialog::getSaveFileName(this, QApplication::applicationName(), QString(), tr("Plain text document (*.txt);;All files (*.*)")); QString targetPath
if(!targetPath.isNull()) { = QFileDialog::getSaveFileName(this, QApplication::applicationName(), QString(), tr("Plain text document (*.txt);;All files (*.*)"));
if (!targetPath.isNull()) {
QString errmsg; QString errmsg;
try { try {
m_file.exportToTextfile(targetPath.toStdString()); m_file.exportToTextfile(targetPath.toStdString());
} catch (...) { } catch (...) {
errmsg = tr("The password list couldn't be exported. %1").arg(QString::fromLocal8Bit(catchIoFailure())); errmsg = tr("The password list couldn't be exported. %1").arg(QString::fromLocal8Bit(catchIoFailure()));
} }
if(errmsg.isEmpty()) { if (errmsg.isEmpty()) {
m_ui->statusBar->showMessage(tr("The password list has been exported."), 5000); m_ui->statusBar->showMessage(tr("The password list has been exported."), 5000);
} else { } else {
m_ui->statusBar->showMessage(errmsg, 5000); m_ui->statusBar->showMessage(errmsg, 5000);
QMessageBox::critical(this, QApplication::applicationName(), errmsg); QMessageBox::critical(this, QApplication::applicationName(), errmsg);
} }
} }
} }
@ -862,13 +863,13 @@ void MainWindow::exportFile()
*/ */
void MainWindow::showContainingDirectory() void MainWindow::showContainingDirectory()
{ {
if(showNoFileOpened()) { if (showNoFileOpened()) {
return; return;
} else if(m_file.path().empty()) { } else if (m_file.path().empty()) {
QMessageBox::warning(this, QApplication::applicationName(), tr("The currently opened file hasn't been saved yet.")); QMessageBox::warning(this, QApplication::applicationName(), tr("The currently opened file hasn't been saved yet."));
} else { } else {
QFileInfo file(QString::fromStdString(m_file.path())); QFileInfo file(QString::fromStdString(m_file.path()));
if(file.dir().exists()) { if (file.dir().exists()) {
DesktopUtils::openLocalFileOrDir(file.dir().absolutePath()); DesktopUtils::openLocalFileOrDir(file.dir().absolutePath());
} }
} }
@ -897,20 +898,21 @@ void MainWindow::addCategory()
*/ */
void MainWindow::addEntry(EntryType type) void MainWindow::addEntry(EntryType type)
{ {
if(showNoFileOpened()) { if (showNoFileOpened()) {
return; return;
} }
QModelIndexList selectedIndexes = m_ui->treeView->selectionModel()->selectedRows(0); QModelIndexList selectedIndexes = m_ui->treeView->selectionModel()->selectedRows(0);
if(selectedIndexes.size() == 1) { if (selectedIndexes.size() == 1) {
QModelIndex selected = m_entryFilterModel->mapToSource(selectedIndexes.at(0)); QModelIndex selected = m_entryFilterModel->mapToSource(selectedIndexes.at(0));
if(m_entryModel->isNode(selected)) { if (m_entryModel->isNode(selected)) {
bool result; bool result;
const QString text = QInputDialog::getText(this, type == EntryType::Account ? tr("Add account") : tr("Add category"), tr("Enter the entry name"), QLineEdit::Normal, tr("new entry"), &result); const QString text = QInputDialog::getText(this, type == EntryType::Account ? tr("Add account") : tr("Add category"),
tr("Enter the entry name"), QLineEdit::Normal, tr("new entry"), &result);
if (result) { if (result) {
if(!text.isEmpty()) { if (!text.isEmpty()) {
int row = m_entryModel->rowCount(selected); int row = m_entryModel->rowCount(selected);
m_entryModel->setInsertType(type); m_entryModel->setInsertType(type);
if(m_entryModel->insertRow(row, selected)) { if (m_entryModel->insertRow(row, selected)) {
m_entryModel->setData(m_entryModel->index(row, 0, selected), text, Qt::DisplayRole); m_entryModel->setData(m_entryModel->index(row, 0, selected), text, Qt::DisplayRole);
setSomethingChanged(true); setSomethingChanged(true);
} else { } else {
@ -931,13 +933,13 @@ void MainWindow::addEntry(EntryType type)
*/ */
void MainWindow::removeEntry() void MainWindow::removeEntry()
{ {
if(showNoFileOpened()) { if (showNoFileOpened()) {
return; return;
} }
QModelIndexList selectedIndexes = m_ui->treeView->selectionModel()->selectedRows(0); QModelIndexList selectedIndexes = m_ui->treeView->selectionModel()->selectedRows(0);
if(selectedIndexes.size() == 1) { if (selectedIndexes.size() == 1) {
const QModelIndex selected = m_entryFilterModel->mapToSource(selectedIndexes.at(0)); const QModelIndex selected = m_entryFilterModel->mapToSource(selectedIndexes.at(0));
if(!m_entryModel->removeRow(selected.row(), selected.parent())) { if (!m_entryModel->removeRow(selected.row(), selected.parent())) {
QMessageBox::warning(this, QApplication::applicationName(), tr("Unable to remove the entry.")); QMessageBox::warning(this, QApplication::applicationName(), tr("Unable to remove the entry."));
} }
} else { } else {
@ -952,7 +954,7 @@ void MainWindow::removeEntry()
void MainWindow::applyFilter(const QString &filterText) void MainWindow::applyFilter(const QString &filterText)
{ {
m_entryFilterModel->setFilterRegExp(filterText); m_entryFilterModel->setFilterRegExp(filterText);
if(filterText.isEmpty()) { if (filterText.isEmpty()) {
applyDefaultExpanding(QModelIndex()); applyDefaultExpanding(QModelIndex());
} else { } else {
m_ui->treeView->expandAll(); m_ui->treeView->expandAll();
@ -964,8 +966,8 @@ void MainWindow::applyFilter(const QString &filterText)
*/ */
void MainWindow::accountSelected(const QModelIndex &selected, const QModelIndex &) void MainWindow::accountSelected(const QModelIndex &selected, const QModelIndex &)
{ {
if(Entry *entry = m_entryModel->entry(m_entryFilterModel->mapToSource(selected))) { if (Entry *entry = m_entryModel->entry(m_entryFilterModel->mapToSource(selected))) {
if(entry->type() == EntryType::Account) { if (entry->type() == EntryType::Account) {
m_fieldModel->setAccountEntry(static_cast<AccountEntry *>(entry)); m_fieldModel->setAccountEntry(static_cast<AccountEntry *>(entry));
return; return;
} }
@ -978,22 +980,23 @@ void MainWindow::accountSelected(const QModelIndex &selected, const QModelIndex
*/ */
void MainWindow::insertRow() void MainWindow::insertRow()
{ {
if(showNoFileOpened() || showNoAccount()) { if (showNoFileOpened() || showNoAccount()) {
return; return;
} }
QModelIndexList selectedIndexes = m_ui->tableView->selectionModel()->selectedIndexes(); QModelIndexList selectedIndexes = m_ui->tableView->selectionModel()->selectedIndexes();
if(selectedIndexes.size()) { if (selectedIndexes.size()) {
int row = m_fieldModel->rowCount(); int row = m_fieldModel->rowCount();
for(const QModelIndex &index : selectedIndexes) { for (const QModelIndex &index : selectedIndexes) {
if(index.row() < row) { if (index.row() < row) {
row = index.row(); row = index.row();
} }
} }
if(row < m_fieldModel->rowCount() - 1) { if (row < m_fieldModel->rowCount() - 1) {
m_fieldModel->insertRow(row); m_fieldModel->insertRow(row);
} }
} else { } else {
QMessageBox::warning(this, windowTitle(), tr("A field has to be selected since new fields are always inserted before the currently selected field.")); QMessageBox::warning(
this, windowTitle(), tr("A field has to be selected since new fields are always inserted before the currently selected field."));
} }
} }
@ -1002,17 +1005,17 @@ void MainWindow::insertRow()
*/ */
void MainWindow::removeRows() void MainWindow::removeRows()
{ {
if(showNoFileOpened() || showNoAccount()) { if (showNoFileOpened() || showNoAccount()) {
return; return;
} }
const QModelIndexList selectedIndexes = m_ui->tableView->selectionModel()->selectedIndexes(); const QModelIndexList selectedIndexes = m_ui->tableView->selectionModel()->selectedIndexes();
QList<int> rows; QList<int> rows;
for(const QModelIndex &index : selectedIndexes) { for (const QModelIndex &index : selectedIndexes) {
rows << index.row(); rows << index.row();
} }
if(rows.size()) { if (rows.size()) {
for(int i = m_fieldModel->rowCount() - 1; i >= 0; --i) { for (int i = m_fieldModel->rowCount() - 1; i >= 0; --i) {
if(rows.contains(i)) { if (rows.contains(i)) {
m_fieldModel->removeRow(i); m_fieldModel->removeRow(i);
} }
} }
@ -1042,13 +1045,13 @@ void MainWindow::markAsNormalField()
*/ */
void MainWindow::setFieldType(FieldType fieldType) void MainWindow::setFieldType(FieldType fieldType)
{ {
if(showNoFileOpened() || showNoAccount()) { if (showNoFileOpened() || showNoAccount()) {
return; return;
} }
QModelIndexList selectedIndexes = m_ui->tableView->selectionModel()->selectedIndexes(); QModelIndexList selectedIndexes = m_ui->tableView->selectionModel()->selectedIndexes();
if(!selectedIndexes.isEmpty()) { if (!selectedIndexes.isEmpty()) {
const QVariant typeVariant(static_cast<int>(fieldType)); const QVariant typeVariant(static_cast<int>(fieldType));
for(const QModelIndex &index : selectedIndexes) { for (const QModelIndex &index : selectedIndexes) {
m_fieldModel->setData(index, typeVariant, FieldTypeRole); m_fieldModel->setData(index, typeVariant, FieldTypeRole);
} }
} else { } else {
@ -1063,11 +1066,11 @@ void MainWindow::setFieldType(FieldType fieldType)
*/ */
void MainWindow::setPasswordVisibility(QAction *selectedAction) void MainWindow::setPasswordVisibility(QAction *selectedAction)
{ {
if(selectedAction == m_ui->actionShowAlways) { if (selectedAction == m_ui->actionShowAlways) {
m_fieldModel->setPasswordVisibility(PasswordVisibility::Always); m_fieldModel->setPasswordVisibility(PasswordVisibility::Always);
} else if(selectedAction == m_ui->actionShowOnlyWhenEditing) { } else if (selectedAction == m_ui->actionShowOnlyWhenEditing) {
m_fieldModel->setPasswordVisibility(PasswordVisibility::OnlyWhenEditing); m_fieldModel->setPasswordVisibility(PasswordVisibility::OnlyWhenEditing);
} else if(selectedAction == m_ui->actionHideAlways) { } else if (selectedAction == m_ui->actionHideAlways) {
m_fieldModel->setPasswordVisibility(PasswordVisibility::Never); m_fieldModel->setPasswordVisibility(PasswordVisibility::Never);
} }
} }
@ -1078,18 +1081,19 @@ void MainWindow::setPasswordVisibility(QAction *selectedAction)
void MainWindow::changePassword() void MainWindow::changePassword()
{ {
using namespace Dialogs; using namespace Dialogs;
if(showNoFileOpened()) { if (showNoFileOpened()) {
return; return;
} }
EnterPasswordDialog pwDlg(this); EnterPasswordDialog pwDlg(this);
pwDlg.setWindowTitle(tr("Changing password") + QStringLiteral(" - " APP_NAME)); pwDlg.setWindowTitle(tr("Changing password") + QStringLiteral(" - " APP_NAME));
pwDlg.setVerificationRequired(true); pwDlg.setVerificationRequired(true);
switch(pwDlg.exec()) { switch (pwDlg.exec()) {
case QDialog::Accepted: case QDialog::Accepted:
if(pwDlg.password().isEmpty()) { if (pwDlg.password().isEmpty()) {
m_file.clearPassword(); m_file.clearPassword();
setSomethingChanged(true); setSomethingChanged(true);
QMessageBox::warning(this, QApplication::applicationName(), tr("You didn't enter a password. <strong>No encryption</strong> will be used when saving the file next time.")); QMessageBox::warning(this, QApplication::applicationName(),
tr("You didn't enter a password. <strong>No encryption</strong> will be used when saving the file next time."));
} else { } else {
m_file.setPassword(pwDlg.password().toStdString()); m_file.setPassword(pwDlg.password().toStdString());
setSomethingChanged(true); setSomethingChanged(true);
@ -1097,7 +1101,8 @@ void MainWindow::changePassword()
} }
break; break;
default: default:
QMessageBox::warning(this, QApplication::applicationName(), tr("You aborted. The old password will still be used when saving the file next time.")); QMessageBox::warning(
this, QApplication::applicationName(), tr("You aborted. The old password will still be used when saving the file next time."));
} }
} }
@ -1106,27 +1111,28 @@ void MainWindow::changePassword()
*/ */
void MainWindow::showTreeViewContextMenu() void MainWindow::showTreeViewContextMenu()
{ {
if(!m_file.hasRootEntry()) { if (!m_file.hasRootEntry()) {
return; return;
} }
QModelIndexList selectedIndexes = m_ui->treeView->selectionModel()->selectedRows(0); QModelIndexList selectedIndexes = m_ui->treeView->selectionModel()->selectedRows(0);
if(selectedIndexes.size() == 1) { if (selectedIndexes.size() == 1) {
QMenu contextMenu(this); QMenu contextMenu(this);
QModelIndex selected = m_entryFilterModel->mapToSource(selectedIndexes.at(0)); QModelIndex selected = m_entryFilterModel->mapToSource(selectedIndexes.at(0));
Entry *entry = m_entryModel->entry(selected); Entry *entry = m_entryModel->entry(selected);
if(entry->type() == EntryType::Node) { if (entry->type() == EntryType::Node) {
contextMenu.addAction(QIcon::fromTheme(QStringLiteral("list-add")), tr("Add account"), this, &MainWindow::addAccount); contextMenu.addAction(QIcon::fromTheme(QStringLiteral("list-add")), tr("Add account"), this, &MainWindow::addAccount);
contextMenu.addAction(QIcon::fromTheme(QStringLiteral("list-add")), tr("Add category"), this, &MainWindow::addCategory); contextMenu.addAction(QIcon::fromTheme(QStringLiteral("list-add")), tr("Add category"), this, &MainWindow::addCategory);
} }
contextMenu.addAction(QIcon::fromTheme(QStringLiteral("list-remove")), tr("Remove entry"), this, &MainWindow::removeEntry); contextMenu.addAction(QIcon::fromTheme(QStringLiteral("list-remove")), tr("Remove entry"), this, &MainWindow::removeEntry);
if(entry->type() == EntryType::Node) { if (entry->type() == EntryType::Node) {
auto *nodeEntry = static_cast<NodeEntry *>(entry); auto *nodeEntry = static_cast<NodeEntry *>(entry);
contextMenu.addSeparator(); contextMenu.addSeparator();
auto *action = new QAction(&contextMenu); auto *action = new QAction(&contextMenu);
action->setCheckable(true); action->setCheckable(true);
action->setText(tr("Expanded by default")); action->setText(tr("Expanded by default"));
action->setChecked(nodeEntry->isExpandedByDefault()); action->setChecked(nodeEntry->isExpandedByDefault());
connect(action, &QAction::triggered, std::bind(&EntryModel::setData, m_entryModel, std::cref(selected), QVariant(!nodeEntry->isExpandedByDefault()), DefaultExpandedRole)); connect(action, &QAction::triggered,
std::bind(&EntryModel::setData, m_entryModel, std::cref(selected), QVariant(!nodeEntry->isExpandedByDefault()), DefaultExpandedRole));
contextMenu.addAction(action); contextMenu.addAction(action);
} }
contextMenu.exec(QCursor::pos()); contextMenu.exec(QCursor::pos());
@ -1140,7 +1146,7 @@ void MainWindow::showTableViewContextMenu()
{ {
// check whether there is a selection at all // check whether there is a selection at all
QModelIndexList selectedIndexes = m_ui->tableView->selectionModel()->selectedIndexes(); QModelIndexList selectedIndexes = m_ui->tableView->selectionModel()->selectedIndexes();
if(!m_file.hasRootEntry() || !m_fieldModel->fields() || selectedIndexes.isEmpty()) { if (!m_file.hasRootEntry() || !m_fieldModel->fields() || selectedIndexes.isEmpty()) {
return; return;
} }
@ -1151,20 +1157,18 @@ void MainWindow::showTableViewContextMenu()
int row = selectedIndexes.front().row(); int row = selectedIndexes.front().row();
int multipleRows = 1; int multipleRows = 1;
QUrl url; QUrl url;
static const string protocols[] = { static const string protocols[] = { "http:", "https:", "file:" };
"http:", "https:", "file:" for (const QModelIndex &index : selectedIndexes) {
}; if (const Field *field = m_fieldModel->field(index.row())) {
for(const QModelIndex &index : selectedIndexes) { if (url.isEmpty() && field->type() != FieldType::Password) {
if(const Field *field = m_fieldModel->field(index.row())) { for (const string &protocol : protocols) {
if(url.isEmpty() && field->type() != FieldType::Password) { if (ConversionUtilities::startsWith(field->value(), protocol)) {
for(const string &protocol : protocols) {
if(ConversionUtilities::startsWith(field->value(), protocol)) {
url = QString::fromUtf8(field->value().data()); url = QString::fromUtf8(field->value().data());
} }
} }
} }
if(hasFirstFieldType) { if (hasFirstFieldType) {
if(firstType != field->type()) { if (firstType != field->type()) {
allOfSameType = false; allOfSameType = false;
break; break;
} }
@ -1173,7 +1177,7 @@ void MainWindow::showTableViewContextMenu()
hasFirstFieldType = true; hasFirstFieldType = true;
} }
} }
if(multipleRows == 1 && index.row() != row) { if (multipleRows == 1 && index.row() != row) {
++multipleRows; ++multipleRows;
} }
} }
@ -1184,10 +1188,11 @@ void MainWindow::showTableViewContextMenu()
contextMenu.addAction(QIcon::fromTheme(QStringLiteral("list-add")), tr("Insert field"), this, &MainWindow::insertRow); contextMenu.addAction(QIcon::fromTheme(QStringLiteral("list-add")), tr("Insert field"), this, &MainWindow::insertRow);
contextMenu.addAction(QIcon::fromTheme(QStringLiteral("list-remove")), tr("Remove field(s)", 0, multipleRows), this, &MainWindow::removeRows); contextMenu.addAction(QIcon::fromTheme(QStringLiteral("list-remove")), tr("Remove field(s)", 0, multipleRows), this, &MainWindow::removeRows);
// -> show the "Mark as ..." action only when all selected indexes are of the same type // -> show the "Mark as ..." action only when all selected indexes are of the same type
if(hasFirstFieldType && allOfSameType) { if (hasFirstFieldType && allOfSameType) {
switch(firstType) { switch (firstType) {
case FieldType::Normal: case FieldType::Normal:
contextMenu.addAction(QIcon::fromTheme(QStringLiteral("flag-black")), tr("Mark as password field"), this, &MainWindow::markAsPasswordField); contextMenu.addAction(
QIcon::fromTheme(QStringLiteral("flag-black")), tr("Mark as password field"), this, &MainWindow::markAsPasswordField);
break; break;
case FieldType::Password: case FieldType::Password:
contextMenu.addAction(QIcon::fromTheme(QStringLiteral("flag-blue")), tr("Mark as normal field"), this, &MainWindow::markAsNormalField); contextMenu.addAction(QIcon::fromTheme(QStringLiteral("flag-blue")), tr("Mark as normal field"), this, &MainWindow::markAsNormalField);
@ -1198,11 +1203,11 @@ void MainWindow::showTableViewContextMenu()
contextMenu.addSeparator(); contextMenu.addSeparator();
contextMenu.addAction(QIcon::fromTheme(QStringLiteral("edit-copy")), tr("Copy"), this, &MainWindow::copyFields); contextMenu.addAction(QIcon::fromTheme(QStringLiteral("edit-copy")), tr("Copy"), this, &MainWindow::copyFields);
contextMenu.addAction(QIcon::fromTheme(QStringLiteral("edit-copy")), tr("Copy for 5 seconds"), this, &MainWindow::copyFieldsForXMilliSeconds); contextMenu.addAction(QIcon::fromTheme(QStringLiteral("edit-copy")), tr("Copy for 5 seconds"), this, &MainWindow::copyFieldsForXMilliSeconds);
if(QApplication::clipboard()->mimeData()->hasText()) { if (QApplication::clipboard()->mimeData()->hasText()) {
contextMenu.addAction(QIcon::fromTheme(QStringLiteral("edit-paste")), tr("Paste"), this, &MainWindow::insertFieldsFromClipboard); contextMenu.addAction(QIcon::fromTheme(QStringLiteral("edit-paste")), tr("Paste"), this, &MainWindow::insertFieldsFromClipboard);
} }
// -> insert open URL // -> insert open URL
if(multipleRows == 1 && !url.isEmpty()) { if (multipleRows == 1 && !url.isEmpty()) {
auto *openUrlAction = new QAction(QIcon::fromTheme(QStringLiteral("applications-internet")), tr("Open URL"), &contextMenu); auto *openUrlAction = new QAction(QIcon::fromTheme(QStringLiteral("applications-internet")), tr("Open URL"), &contextMenu);
connect(openUrlAction, &QAction::triggered, bind(&QDesktopServices::openUrl, url)); connect(openUrlAction, &QAction::triggered, bind(&QDesktopServices::openUrl, url));
contextMenu.addAction(openUrlAction); contextMenu.addAction(openUrlAction);
@ -1217,17 +1222,16 @@ void MainWindow::showTableViewContextMenu()
void MainWindow::copyFieldsForXMilliSeconds(int x) void MainWindow::copyFieldsForXMilliSeconds(int x)
{ {
QString text = selectedFieldsString(); QString text = selectedFieldsString();
if(!text.isEmpty()) { if (!text.isEmpty()) {
if(m_clearClipboardTimer) { if (m_clearClipboardTimer) {
killTimer(m_clearClipboardTimer); killTimer(m_clearClipboardTimer);
} }
QApplication::clipboard()->setText(text); QApplication::clipboard()->setText(text);
if(x > 0) { if (x > 0) {
m_clearClipboardTimer = startTimer(x, Qt::CoarseTimer); m_clearClipboardTimer = startTimer(x, Qt::CoarseTimer);
} }
} else { } else {
QMessageBox::warning(this, QApplication::applicationName(), tr("The selection is empty.")); QMessageBox::warning(this, QApplication::applicationName(), tr("The selection is empty."));
} }
} }
} }

View File

@ -44,10 +44,9 @@ namespace Ui {
class MainWindow; class MainWindow;
} }
class MainWindow : public QMainWindow class MainWindow : public QMainWindow {
{
Q_OBJECT Q_OBJECT
public: public:
explicit MainWindow(QSettings &settings, Dialogs::QtSettings *qtSettings = nullptr, QWidget *parent = nullptr); explicit MainWindow(QSettings &settings, Dialogs::QtSettings *qtSettings = nullptr, QWidget *parent = nullptr);
~MainWindow(); ~MainWindow();
@ -106,7 +105,7 @@ private slots:
void setSomethingChanged(); void setSomethingChanged();
void setSomethingChanged(bool somethingChanged); void setSomethingChanged(bool somethingChanged);
private: private:
// showing conditional messages/prompts // showing conditional messages/prompts
bool askForCreatingFile(); bool askForCreatingFile();
bool showNoFileOpened(); bool showNoFileOpened();
@ -132,7 +131,6 @@ private:
Dialogs::QtSettings *m_qtSettings; Dialogs::QtSettings *m_qtSettings;
Dialogs::SettingsDialog *m_settingsDlg; Dialogs::SettingsDialog *m_settingsDlg;
}; };
} }
#endif // MAINWINDOW_H #endif // MAINWINDOW_H

View File

@ -10,13 +10,13 @@
#include <openssl/rand.h> #include <openssl/rand.h>
#include <QMessageBox>
#include <QClipboard> #include <QClipboard>
#include <QMessageBox>
#include <string>
#include <sstream>
#include <algorithm> #include <algorithm>
#include <random> #include <random>
#include <sstream>
#include <string>
using namespace std; using namespace std;
using namespace Io; using namespace Io;
@ -25,20 +25,13 @@ using namespace Dialogs;
namespace QtGui { namespace QtGui {
const char smallLetters[] = {'a','b','c','d','e','f', const char smallLetters[]
'g','h','i','j','k', = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
'l','m','n','o','p',
'q','r','s','t','u',
'v','w','x','y','z'};
const char capitalLetters[] = {'A','B','C','D','E','F', const char capitalLetters[]
'G','H','I','J','K', = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };
'L','M','N','O','P',
'Q','R','S','T','U',
'V','W','X','Y','Z'};
const char digits[] = {'0','1','2','3','4', const char digits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
'5','6','7','8','9'};
/*! /*!
* \class PasswordGeneratorDialog * \class PasswordGeneratorDialog
@ -48,13 +41,14 @@ const char digits[] = {'0','1','2','3','4',
/*! /*!
* \brief Constructs a new password generator dialog. * \brief Constructs a new password generator dialog.
*/ */
PasswordGeneratorDialog::PasswordGeneratorDialog(QWidget *parent) : PasswordGeneratorDialog::PasswordGeneratorDialog(QWidget *parent)
QDialog(parent), : QDialog(parent)
m_ui(new Ui::PasswordGeneratorDialog) , m_ui(new Ui::PasswordGeneratorDialog)
{ {
m_ui->setupUi(this); m_ui->setupUi(this);
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN32
setStyleSheet(QStringLiteral("%1 QCommandLinkButton { font-size: 12pt; color: %2; font-weight: normal; }").arg(dialogStyle(), instructionTextColor().name())); setStyleSheet(QStringLiteral("%1 QCommandLinkButton { font-size: 12pt; color: %2; font-weight: normal; }")
.arg(dialogStyle(), instructionTextColor().name()));
#endif #endif
setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint); setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint);
@ -85,52 +79,51 @@ PasswordGeneratorDialog::~PasswordGeneratorDialog()
void PasswordGeneratorDialog::generateNewPassword() void PasswordGeneratorDialog::generateNewPassword()
{ {
int length = m_ui->LengthSpinBox->value(); int length = m_ui->LengthSpinBox->value();
if(length > 0) { if (length > 0) {
if(m_charset.empty()) { if (m_charset.empty()) {
bool useSmallLetters = m_ui->useSmallLettersCheckBox->isChecked(); bool useSmallLetters = m_ui->useSmallLettersCheckBox->isChecked();
bool useCapitalLetters = m_ui->useCapitalLettersCheckBox->isChecked(); bool useCapitalLetters = m_ui->useCapitalLettersCheckBox->isChecked();
bool useDigits = m_ui->useDigitsCheckBox->isChecked(); bool useDigits = m_ui->useDigitsCheckBox->isChecked();
QString otherChars = m_ui->otherCharsLineEdit->text(); QString otherChars = m_ui->otherCharsLineEdit->text();
int charsetSize = otherChars.length(); int charsetSize = otherChars.length();
if(useSmallLetters) { if (useSmallLetters) {
charsetSize += sizeof(smallLetters); charsetSize += sizeof(smallLetters);
} }
if(useCapitalLetters) { if (useCapitalLetters) {
charsetSize += sizeof(capitalLetters); charsetSize += sizeof(capitalLetters);
} }
if(useDigits) { if (useDigits) {
charsetSize += sizeof(digits); charsetSize += sizeof(digits);
} }
m_charset.reserve(charsetSize); m_charset.reserve(charsetSize);
if(useSmallLetters) { if (useSmallLetters) {
m_charset.insert(m_charset.end(), std::begin(smallLetters), std::end(smallLetters)); m_charset.insert(m_charset.end(), std::begin(smallLetters), std::end(smallLetters));
} }
if(useCapitalLetters) { if (useCapitalLetters) {
m_charset.insert(m_charset.end(), std::begin(capitalLetters), std::end(capitalLetters)); m_charset.insert(m_charset.end(), std::begin(capitalLetters), std::end(capitalLetters));
} }
if(useDigits) { if (useDigits) {
m_charset.insert(m_charset.end(), std::begin(digits), std::end(digits)); m_charset.insert(m_charset.end(), std::begin(digits), std::end(digits));
} }
char charval; char charval;
foreach(QChar qchar, otherChars) { foreach (QChar qchar, otherChars) {
charval = qchar.toLatin1(); charval = qchar.toLatin1();
if(charval != '\x00' && charval != ' ' && std::find(m_charset.begin(), m_charset.end(), charval) == m_charset.end()) { if (charval != '\x00' && charval != ' ' && std::find(m_charset.begin(), m_charset.end(), charval) == m_charset.end()) {
m_charset.push_back(charval); m_charset.push_back(charval);
} }
} }
} }
if(!m_charset.empty()) { if (!m_charset.empty()) {
try { try {
default_random_engine rng(m_random()); default_random_engine rng(m_random());
uniform_int_distribution<> dist(0, m_charset.size() - 1); uniform_int_distribution<> dist(0, m_charset.size() - 1);
auto randchar = [this, &dist, &rng]() { auto randchar = [this, &dist, &rng]() { return m_charset[dist(rng)]; };
return m_charset[dist(rng)];
};
string res(length, 0); string res(length, 0);
generate_n(res.begin(), length, randchar); generate_n(res.begin(), length, randchar);
m_ui->passwordLineEdit->setText(QString::fromLatin1(res.c_str())); m_ui->passwordLineEdit->setText(QString::fromLatin1(res.c_str()));
} catch(const CryptoException &ex) { } catch (const CryptoException &ex) {
QMessageBox::warning(this, QApplication::applicationName(), tr("Failed to generate password.\nOpenSSL error: %1").arg(QString::fromLocal8Bit(ex.what()))); QMessageBox::warning(this, QApplication::applicationName(),
tr("Failed to generate password.\nOpenSSL error: %1").arg(QString::fromLocal8Bit(ex.what())));
} }
} else { } else {
QMessageBox::warning(this, QApplication::applicationName(), tr("You have to select at least one checkbox.")); QMessageBox::warning(this, QApplication::applicationName(), tr("You have to select at least one checkbox."));
@ -145,10 +138,8 @@ void PasswordGeneratorDialog::generateNewPassword()
*/ */
void PasswordGeneratorDialog::handleCheckedCategoriesChanged() void PasswordGeneratorDialog::handleCheckedCategoriesChanged()
{ {
m_ui->generatePassowordCommandLinkButton->setEnabled(m_ui->useCapitalLettersCheckBox->isChecked() m_ui->generatePassowordCommandLinkButton->setEnabled(m_ui->useCapitalLettersCheckBox->isChecked() || m_ui->useDigitsCheckBox->isChecked()
|| m_ui->useDigitsCheckBox->isChecked() || m_ui->useSmallLettersCheckBox->isChecked() || !m_ui->otherCharsLineEdit->text().isEmpty());
|| m_ui->useSmallLettersCheckBox->isChecked()
|| !m_ui->otherCharsLineEdit->text().isEmpty());
m_charset.clear(); m_charset.clear();
} }
@ -168,5 +159,4 @@ void PasswordGeneratorDialog::copyPassword()
QClipboard *cb = QApplication::clipboard(); QClipboard *cb = QApplication::clipboard();
cb->setText(m_ui->passwordLineEdit->text()); cb->setText(m_ui->passwordLineEdit->text());
} }
} }

View File

@ -13,14 +13,13 @@ namespace Ui {
class PasswordGeneratorDialog; class PasswordGeneratorDialog;
} }
class PasswordGeneratorDialog : public QDialog class PasswordGeneratorDialog : public QDialog {
{
Q_OBJECT Q_OBJECT
public: public:
explicit PasswordGeneratorDialog(QWidget *parent = 0); explicit PasswordGeneratorDialog(QWidget *parent = 0);
~PasswordGeneratorDialog(); ~PasswordGeneratorDialog();
private Q_SLOTS: private Q_SLOTS:
void generateNewPassword(); void generateNewPassword();
void handleCheckedCategoriesChanged(); void handleCheckedCategoriesChanged();
@ -32,7 +31,6 @@ private:
std::vector<char> m_charset; std::vector<char> m_charset;
Util::OpenSslRandomDevice m_random; Util::OpenSslRandomDevice m_random;
}; };
} }
#endif // PASSWORDGENERATORDIALOG_H #endif // PASSWORDGENERATORDIALOG_H

View File

@ -10,8 +10,8 @@ namespace QtGui {
/*! /*!
* \brief Constructs a new stack support with the specified \a undoStack. * \brief Constructs a new stack support with the specified \a undoStack.
*/ */
StackSupport::StackSupport(QUndoStack *undoStack) : StackSupport::StackSupport(QUndoStack *undoStack)
m_undoStack(undoStack) : m_undoStack(undoStack)
{} {
}
} }

View File

@ -9,9 +9,9 @@ namespace QtGui {
class StackAbsorper; class StackAbsorper;
class StackSupport class StackSupport {
{
friend class StackAbsorper; friend class StackAbsorper;
public: public:
StackSupport(QUndoStack *undoStack = nullptr); StackSupport(QUndoStack *undoStack = nullptr);
@ -37,8 +37,8 @@ inline QUndoStack *StackSupport::undoStack()
*/ */
inline bool StackSupport::push(CustomUndoCommand *command) inline bool StackSupport::push(CustomUndoCommand *command)
{ {
if(m_undoStack) { if (m_undoStack) {
if(command->isNoop()) { if (command->isNoop()) {
return true; // doing nothing can never fail return true; // doing nothing can never fail
} else { } else {
m_undoStack->push(command); m_undoStack->push(command);
@ -53,7 +53,7 @@ inline bool StackSupport::push(CustomUndoCommand *command)
*/ */
inline void StackSupport::clearUndoStack() inline void StackSupport::clearUndoStack()
{ {
if(m_undoStack) { if (m_undoStack) {
m_undoStack->clear(); m_undoStack->clear();
} }
} }
@ -62,12 +62,12 @@ inline void StackSupport::clearUndoStack()
* \brief The StackAbsorper class is used by the CustomUndoCommand class to prevent infinite recursion when pushing * \brief The StackAbsorper class is used by the CustomUndoCommand class to prevent infinite recursion when pushing
* a new command to the stack. * a new command to the stack.
*/ */
class StackAbsorper class StackAbsorper {
{
public: public:
StackAbsorper(StackSupport *supported); StackAbsorper(StackSupport *supported);
~StackAbsorper(); ~StackAbsorper();
QUndoStack *stack(); QUndoStack *stack();
private: private:
StackSupport *m_supported; StackSupport *m_supported;
QUndoStack *m_stack; QUndoStack *m_stack;
@ -76,9 +76,9 @@ private:
/*! /*!
* \brief Detaches the undo stack from the specified stack support temporary. * \brief Detaches the undo stack from the specified stack support temporary.
*/ */
inline StackAbsorper::StackAbsorper(StackSupport *supported) : inline StackAbsorper::StackAbsorper(StackSupport *supported)
m_supported(supported), : m_supported(supported)
m_stack(supported->m_undoStack) , m_stack(supported->m_undoStack)
{ {
m_supported->m_undoStack = nullptr; m_supported->m_undoStack = nullptr;
} }
@ -98,7 +98,6 @@ inline QUndoStack *StackAbsorper::stack()
{ {
return m_stack; return m_stack;
} }
} }
#endif // QTGUI_STACKSUPPORT_H #endif // QTGUI_STACKSUPPORT_H

View File

@ -1,8 +1,8 @@
#include "./undocommands.h" #include "./undocommands.h"
#include "./stacksupport.h" #include "./stacksupport.h"
#include "../model/fieldmodel.h"
#include "../model/entrymodel.h" #include "../model/entrymodel.h"
#include "../model/fieldmodel.h"
#include <passwordfile/io/entry.h> #include <passwordfile/io/entry.h>
@ -23,16 +23,17 @@ namespace QtGui {
/*! /*!
* \brief Constructs a new custom undo command with the specified \a stackSupport. * \brief Constructs a new custom undo command with the specified \a stackSupport.
*/ */
CustomUndoCommand::CustomUndoCommand(StackSupport *stackSupport) : CustomUndoCommand::CustomUndoCommand(StackSupport *stackSupport)
m_stackSupport(stackSupport), : m_stackSupport(stackSupport)
m_redoResult(false), , m_redoResult(false)
m_undoResult(true), , m_undoResult(true)
m_noop(false) , m_noop(false)
{} {
}
void CustomUndoCommand::redo() void CustomUndoCommand::redo()
{ {
if(m_undoResult) { if (m_undoResult) {
StackAbsorper stackAbsorper(m_stackSupport); StackAbsorper stackAbsorper(m_stackSupport);
m_redoResult = internalRedo(); m_redoResult = internalRedo();
} }
@ -40,7 +41,7 @@ void CustomUndoCommand::redo()
void CustomUndoCommand::undo() void CustomUndoCommand::undo()
{ {
if(m_redoResult) { if (m_redoResult) {
StackAbsorper stackAbsorper(m_stackSupport); StackAbsorper stackAbsorper(m_stackSupport);
m_undoResult = internalUndo(); m_undoResult = internalUndo();
} }
@ -64,30 +65,30 @@ void CustomUndoCommand::undo()
/*! /*!
* \brief Constructs a new command. * \brief Constructs a new command.
*/ */
FieldModelSetValueCommand::FieldModelSetValueCommand(FieldModel *model, const QModelIndex &index, const QVariant &value, int role) : FieldModelSetValueCommand::FieldModelSetValueCommand(FieldModel *model, const QModelIndex &index, const QVariant &value, int role)
CustomUndoCommand(model), : CustomUndoCommand(model)
m_account(model->accountEntry()), , m_account(model->accountEntry())
m_model(model), , m_model(model)
m_row(index.row()), , m_row(index.row())
m_col(index.column()), , m_col(index.column())
m_newValue(value), , m_newValue(value)
m_oldValue(model->data(index, role)), , m_oldValue(model->data(index, role))
m_role(role) , m_role(role)
{ {
QString fieldName = model->index(m_row, 0, index.parent()).data().toString(); QString fieldName = model->index(m_row, 0, index.parent()).data().toString();
switch(role) { switch (role) {
case Qt::DisplayRole: case Qt::DisplayRole:
case Qt::EditRole: case Qt::EditRole:
switch(m_col) { switch (m_col) {
case 0: case 0:
if(m_oldValue.toString().isEmpty()) { if (m_oldValue.toString().isEmpty()) {
setText(QApplication::translate("undocommands", "setting field name to »%1«").arg(m_newValue.toString())); setText(QApplication::translate("undocommands", "setting field name to »%1«").arg(m_newValue.toString()));
} else { } else {
setText(QApplication::translate("undocommands", "setting field name »%1« to »%2«").arg(m_oldValue.toString(), m_newValue.toString())); setText(QApplication::translate("undocommands", "setting field name »%1« to »%2«").arg(m_oldValue.toString(), m_newValue.toString()));
} }
break; break;
case 1: case 1:
if(fieldName.isEmpty()) { if (fieldName.isEmpty()) {
setText(QApplication::translate("undocommands", "setting value of empty field")); setText(QApplication::translate("undocommands", "setting value of empty field"));
} else { } else {
setText(QApplication::translate("undocommands", "setting value of »%1« field").arg(fieldName)); setText(QApplication::translate("undocommands", "setting value of »%1« field").arg(fieldName));
@ -124,12 +125,12 @@ bool FieldModelSetValueCommand::internalUndo()
/*! /*!
* \brief Constructs a new command. * \brief Constructs a new command.
*/ */
FieldModelInsertRowsCommand::FieldModelInsertRowsCommand(FieldModel *model, int row, int count) : FieldModelInsertRowsCommand::FieldModelInsertRowsCommand(FieldModel *model, int row, int count)
CustomUndoCommand(model), : CustomUndoCommand(model)
m_account(model->accountEntry()), , m_account(model->accountEntry())
m_model(model), , m_model(model)
m_row(row), , m_row(row)
m_count(count) , m_count(count)
{ {
setText(QApplication::translate("undocommands", "insertion of %1 row(s) before row %2", 0, count).arg(count).arg(row + 1)); setText(QApplication::translate("undocommands", "insertion of %1 row(s) before row %2", 0, count).arg(count).arg(row + 1));
} }
@ -154,14 +155,14 @@ bool FieldModelInsertRowsCommand::internalUndo()
/*! /*!
* \brief Constructs a new command. * \brief Constructs a new command.
*/ */
FieldModelRemoveRowsCommand::FieldModelRemoveRowsCommand(FieldModel *model, int row, int count) : FieldModelRemoveRowsCommand::FieldModelRemoveRowsCommand(FieldModel *model, int row, int count)
CustomUndoCommand(model), : CustomUndoCommand(model)
m_account(model->accountEntry()), , m_account(model->accountEntry())
m_model(model), , m_model(model)
m_row(row), , m_row(row)
m_count(count) , m_count(count)
{ {
if(count == 1) { if (count == 1) {
setText(QApplication::translate("undocommands", "removal of row %1", 0, count).arg(row + 1)); setText(QApplication::translate("undocommands", "removal of row %1", 0, count).arg(row + 1));
} else { } else {
setText(QApplication::translate("undocommands", "removal of the rows %1 to %2", 0, count).arg(row + 1).arg(row + count)); setText(QApplication::translate("undocommands", "removal of the rows %1 to %2", 0, count).arg(row + 1).arg(row + count));
@ -171,9 +172,9 @@ FieldModelRemoveRowsCommand::FieldModelRemoveRowsCommand(FieldModel *model, int
bool FieldModelRemoveRowsCommand::internalRedo() bool FieldModelRemoveRowsCommand::internalRedo()
{ {
m_model->setAccountEntry(m_account); m_model->setAccountEntry(m_account);
if(m_values.isEmpty()) { if (m_values.isEmpty()) {
for(int row = m_row, end = m_row + m_count; row < end; ++row) { for (int row = m_row, end = m_row + m_count; row < end; ++row) {
if(const Field *field = m_model->field(row)) { if (const Field *field = m_model->field(row)) {
m_values << Field(*field); m_values << Field(*field);
} }
} }
@ -185,7 +186,7 @@ bool FieldModelRemoveRowsCommand::internalUndo()
{ {
m_model->setAccountEntry(m_account); m_model->setAccountEntry(m_account);
bool res = m_model->insertRows(m_row, m_count, QModelIndex()); bool res = m_model->insertRows(m_row, m_count, QModelIndex());
for(int row = m_row, end = m_row + m_count, value = 0, values = m_values.size(); row < end && value < values; ++row, ++value) { for (int row = m_row, end = m_row + m_count, value = 0, values = m_values.size(); row < end && value < values; ++row, ++value) {
m_model->setData(m_model->index(row, 0), QString::fromStdString(m_values.at(value).name()), Qt::EditRole); m_model->setData(m_model->index(row, 0), QString::fromStdString(m_values.at(value).name()), Qt::EditRole);
m_model->setData(m_model->index(row, 1), QString::fromStdString(m_values.at(value).value()), Qt::EditRole); m_model->setData(m_model->index(row, 1), QString::fromStdString(m_values.at(value).value()), Qt::EditRole);
m_model->setData(m_model->index(row, 0), static_cast<int>(m_values.at(value).type()), FieldTypeRole); m_model->setData(m_model->index(row, 0), static_cast<int>(m_values.at(value).type()), FieldTypeRole);
@ -199,7 +200,7 @@ bool FieldModelRemoveRowsCommand::internalUndo()
void indexToPath(EntryModel *model, const QModelIndex &index, list<string> &res) void indexToPath(EntryModel *model, const QModelIndex &index, list<string> &res)
{ {
res.clear(); res.clear();
if(Entry *entry = model->entry(index)) { if (Entry *entry = model->entry(index)) {
entry->path(res); entry->path(res);
} }
} }
@ -210,7 +211,7 @@ void indexToPath(EntryModel *model, const QModelIndex &index, list<string> &res)
*/ */
Entry *entryFromPath(EntryModel *model, list<string> &path) Entry *entryFromPath(EntryModel *model, list<string> &path)
{ {
if(NodeEntry *rootEntry = model->rootEntry()) { if (NodeEntry *rootEntry = model->rootEntry()) {
return rootEntry->entryByPath(path); return rootEntry->entryByPath(path);
} }
return nullptr; return nullptr;
@ -232,26 +233,27 @@ Entry *entryFromPathCpy(EntryModel *model, list<string> path)
/*! /*!
* \brief Constructs a new command. * \brief Constructs a new command.
*/ */
EntryModelSetValueCommand::EntryModelSetValueCommand(EntryModel *model, const QModelIndex &index, const QVariant &value, int role) : EntryModelSetValueCommand::EntryModelSetValueCommand(EntryModel *model, const QModelIndex &index, const QVariant &value, int role)
CustomUndoCommand(model), : CustomUndoCommand(model)
m_model(model), , m_model(model)
m_newValue(value), , m_newValue(value)
m_oldValue(model->data(index, role)), , m_oldValue(model->data(index, role))
m_role(role) , m_role(role)
{ {
indexToPath(model, index, m_path); indexToPath(model, index, m_path);
switch(role) { switch (role) {
case Qt::DisplayRole: case Qt::DisplayRole:
case Qt::EditRole: case Qt::EditRole:
if(m_oldValue.toString().isEmpty()) { if (m_oldValue.toString().isEmpty()) {
setText(QApplication::translate("undocommands", "setting entry name to »%1«").arg(m_newValue.toString())); setText(QApplication::translate("undocommands", "setting entry name to »%1«").arg(m_newValue.toString()));
} else { } else {
setText(QApplication::translate("undocommands", "setting entry name from »%1« to »%2«").arg(m_oldValue.toString(), m_newValue.toString())); setText(
QApplication::translate("undocommands", "setting entry name from »%1« to »%2«").arg(m_oldValue.toString(), m_newValue.toString()));
} }
break; break;
default: default:
QString name = model->data(model->index(index.row(), 0, index.parent()), Qt::DisplayRole).toString(); QString name = model->data(model->index(index.row(), 0, index.parent()), Qt::DisplayRole).toString();
if(name.isEmpty()) { if (name.isEmpty()) {
setText(QApplication::translate("undocommands", "setting property of an entry")); setText(QApplication::translate("undocommands", "setting property of an entry"));
} else { } else {
setText(QApplication::translate("undocommands", "setting property of entry »%1«").arg(name)); setText(QApplication::translate("undocommands", "setting property of entry »%1«").arg(name));
@ -262,7 +264,7 @@ EntryModelSetValueCommand::EntryModelSetValueCommand(EntryModel *model, const QM
bool EntryModelSetValueCommand::internalRedo() bool EntryModelSetValueCommand::internalRedo()
{ {
if(Entry *entry = entryFromPath(m_model, m_path)) { if (Entry *entry = entryFromPath(m_model, m_path)) {
bool res = m_model->setData(m_model->index(entry), m_newValue, m_role); bool res = m_model->setData(m_model->index(entry), m_newValue, m_role);
m_path.clear(); m_path.clear();
entry->path(m_path); entry->path(m_path);
@ -273,7 +275,7 @@ bool EntryModelSetValueCommand::internalRedo()
bool EntryModelSetValueCommand::internalUndo() bool EntryModelSetValueCommand::internalUndo()
{ {
if(Entry *entry = entryFromPath(m_model, m_path)) { if (Entry *entry = entryFromPath(m_model, m_path)) {
bool res = m_model->setData(m_model->index(entry), m_oldValue, m_role); bool res = m_model->setData(m_model->index(entry), m_oldValue, m_role);
m_path.clear(); m_path.clear();
entry->path(m_path); entry->path(m_path);
@ -290,11 +292,11 @@ bool EntryModelSetValueCommand::internalUndo()
/*! /*!
* \brief Constructs a new command. * \brief Constructs a new command.
*/ */
EntryModelModifyRowsCommand::EntryModelModifyRowsCommand(EntryModel *model, int row, int count, const QModelIndex &parent) : EntryModelModifyRowsCommand::EntryModelModifyRowsCommand(EntryModel *model, int row, int count, const QModelIndex &parent)
CustomUndoCommand(model), : CustomUndoCommand(model)
m_model(model), , m_model(model)
m_row(row), , m_row(row)
m_count(count) , m_count(count)
{ {
indexToPath(model, parent, m_parentPath); indexToPath(model, parent, m_parentPath);
} }
@ -314,8 +316,8 @@ EntryModelModifyRowsCommand::~EntryModelModifyRowsCommand()
*/ */
bool EntryModelModifyRowsCommand::insert() bool EntryModelModifyRowsCommand::insert()
{ {
if(Entry *parentEntry = entryFromPathCpy(m_model, m_parentPath)) { if (Entry *parentEntry = entryFromPathCpy(m_model, m_parentPath)) {
if(m_model->insertEntries(m_row, m_model->index(parentEntry), m_values)) { if (m_model->insertEntries(m_row, m_model->index(parentEntry), m_values)) {
m_values.clear(); m_values.clear();
return true; return true;
} }
@ -332,7 +334,7 @@ bool EntryModelModifyRowsCommand::insert()
*/ */
bool EntryModelModifyRowsCommand::remove() bool EntryModelModifyRowsCommand::remove()
{ {
if(Entry *parentEntry = entryFromPathCpy(m_model, m_parentPath)) { if (Entry *parentEntry = entryFromPathCpy(m_model, m_parentPath)) {
m_values = m_model->takeEntries(m_row, m_count, m_model->index(parentEntry)); m_values = m_model->takeEntries(m_row, m_count, m_model->index(parentEntry));
return !m_values.isEmpty(); return !m_values.isEmpty();
} }
@ -347,11 +349,11 @@ bool EntryModelModifyRowsCommand::remove()
/*! /*!
* \brief Constructs a new command. * \brief Constructs a new command.
*/ */
EntryModelInsertRowsCommand::EntryModelInsertRowsCommand(EntryModel *model, int row, int count, const QModelIndex &parent) : EntryModelInsertRowsCommand::EntryModelInsertRowsCommand(EntryModel *model, int row, int count, const QModelIndex &parent)
EntryModelModifyRowsCommand(model, row, count, parent) : EntryModelModifyRowsCommand(model, row, count, parent)
{ {
setText(QApplication::translate("undocommands", "insertion of %1 entry/entries", 0, count).arg(count)); setText(QApplication::translate("undocommands", "insertion of %1 entry/entries", 0, count).arg(count));
switch(m_model->insertType()) { switch (m_model->insertType()) {
case EntryType::Account: case EntryType::Account:
m_values << new AccountEntry; m_values << new AccountEntry;
break; break;
@ -379,8 +381,8 @@ bool EntryModelInsertRowsCommand::internalUndo()
/*! /*!
* \brief Constructs a new command. * \brief Constructs a new command.
*/ */
EntryModelRemoveRowsCommand::EntryModelRemoveRowsCommand(EntryModel *model, int row, int count, const QModelIndex &parent) : EntryModelRemoveRowsCommand::EntryModelRemoveRowsCommand(EntryModel *model, int row, int count, const QModelIndex &parent)
EntryModelModifyRowsCommand(model, row, count, parent) : EntryModelModifyRowsCommand(model, row, count, parent)
{ {
setText(QApplication::translate("undocommands", "removal of %1 entry/entries", 0, count).arg(count)); setText(QApplication::translate("undocommands", "removal of %1 entry/entries", 0, count).arg(count));
} }
@ -403,12 +405,13 @@ bool EntryModelRemoveRowsCommand::internalUndo()
/*! /*!
* \brief Constructs a new command. * \brief Constructs a new command.
*/ */
EntryModelMoveRowsCommand::EntryModelMoveRowsCommand(EntryModel *model, const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild) : EntryModelMoveRowsCommand::EntryModelMoveRowsCommand(
CustomUndoCommand(model), EntryModel *model, const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild)
m_model(model), : CustomUndoCommand(model)
m_sourceRow(sourceRow), , m_model(model)
m_count(count), , m_sourceRow(sourceRow)
m_destChild(destinationChild) , m_count(count)
, m_destChild(destinationChild)
{ {
indexToPath(model, sourceParent, m_sourceParentPath); indexToPath(model, sourceParent, m_sourceParentPath);
indexToPath(model, destinationParent, m_destParentPath); indexToPath(model, destinationParent, m_destParentPath);
@ -417,10 +420,10 @@ EntryModelMoveRowsCommand::EntryModelMoveRowsCommand(EntryModel *model, const QM
bool EntryModelMoveRowsCommand::internalRedo() bool EntryModelMoveRowsCommand::internalRedo()
{ {
if(m_count) { if (m_count) {
Entry *sourceParentEntry = entryFromPathCpy(m_model, m_sourceParentPath); Entry *sourceParentEntry = entryFromPathCpy(m_model, m_sourceParentPath);
Entry *destParentEntry = entryFromPathCpy(m_model, m_destParentPath); Entry *destParentEntry = entryFromPathCpy(m_model, m_destParentPath);
if(sourceParentEntry && destParentEntry) { if (sourceParentEntry && destParentEntry) {
return m_model->moveRows(m_model->index(sourceParentEntry), m_sourceRow, m_count, m_model->index(destParentEntry), m_destChild); return m_model->moveRows(m_model->index(sourceParentEntry), m_sourceRow, m_count, m_model->index(destParentEntry), m_destChild);
} }
return false; return false;
@ -430,21 +433,21 @@ bool EntryModelMoveRowsCommand::internalRedo()
bool EntryModelMoveRowsCommand::internalUndo() bool EntryModelMoveRowsCommand::internalUndo()
{ {
if(m_count) { if (m_count) {
Entry *sourceParentEntry = entryFromPathCpy(m_model, m_sourceParentPath); Entry *sourceParentEntry = entryFromPathCpy(m_model, m_sourceParentPath);
Entry *destParentEntry = entryFromPathCpy(m_model, m_destParentPath); Entry *destParentEntry = entryFromPathCpy(m_model, m_destParentPath);
if(sourceParentEntry && destParentEntry) { if (sourceParentEntry && destParentEntry) {
int sourceRow = m_destChild; int sourceRow = m_destChild;
int destChild = m_sourceRow; int destChild = m_sourceRow;
// moves whithin the same parent needs special consideration // moves whithin the same parent needs special consideration
if(sourceParentEntry == destParentEntry) { if (sourceParentEntry == destParentEntry) {
// move entry down // move entry down
if(m_sourceRow < m_destChild) { if (m_sourceRow < m_destChild) {
sourceRow -= m_count; sourceRow -= m_count;
// move entry up // move entry up
} else if(m_sourceRow > m_destChild) { } else if (m_sourceRow > m_destChild) {
destChild += m_count; destChild += m_count;
// keep entry were it is // keep entry were it is
} else { } else {
return true; return true;
} }
@ -455,5 +458,4 @@ bool EntryModelMoveRowsCommand::internalUndo()
} }
return true; return true;
} }
} }

View File

@ -3,9 +3,9 @@
#include <passwordfile/io/field.h> #include <passwordfile/io/field.h>
#include <QList>
#include <QUndoCommand> #include <QUndoCommand>
#include <QUndoStack> #include <QUndoStack>
#include <QList>
#include <QVariant> #include <QVariant>
QT_FORWARD_DECLARE_CLASS(QModelIndex) QT_FORWARD_DECLARE_CLASS(QModelIndex)
@ -21,8 +21,7 @@ class FieldModel;
class EntryModel; class EntryModel;
class StackSupport; class StackSupport;
class CustomUndoCommand : public QUndoCommand class CustomUndoCommand : public QUndoCommand {
{
public: public:
explicit CustomUndoCommand(StackSupport *stackSupport); explicit CustomUndoCommand(StackSupport *stackSupport);
bool redoResult() const; bool redoResult() const;
@ -30,10 +29,12 @@ public:
bool isNoop() const; bool isNoop() const;
void redo(); void redo();
void undo(); void undo();
protected: protected:
void setNoop(bool noop); void setNoop(bool noop);
virtual bool internalRedo() = 0; virtual bool internalRedo() = 0;
virtual bool internalUndo() = 0; virtual bool internalUndo() = 0;
private: private:
StackSupport *m_stackSupport; StackSupport *m_stackSupport;
bool m_redoResult; bool m_redoResult;
@ -75,13 +76,14 @@ inline void CustomUndoCommand::setNoop(bool noop)
m_noop = noop; m_noop = noop;
} }
class FieldModelSetValueCommand : public CustomUndoCommand class FieldModelSetValueCommand : public CustomUndoCommand {
{
public: public:
explicit FieldModelSetValueCommand(FieldModel *model, const QModelIndex &index, const QVariant &value, int role); explicit FieldModelSetValueCommand(FieldModel *model, const QModelIndex &index, const QVariant &value, int role);
protected: protected:
bool internalRedo(); bool internalRedo();
bool internalUndo(); bool internalUndo();
private: private:
Io::AccountEntry *m_account; Io::AccountEntry *m_account;
FieldModel *m_model; FieldModel *m_model;
@ -92,13 +94,14 @@ private:
int m_role; int m_role;
}; };
class FieldModelInsertRowsCommand : public CustomUndoCommand class FieldModelInsertRowsCommand : public CustomUndoCommand {
{
public: public:
explicit FieldModelInsertRowsCommand(FieldModel *model, int row, int count); explicit FieldModelInsertRowsCommand(FieldModel *model, int row, int count);
protected: protected:
bool internalRedo(); bool internalRedo();
bool internalUndo(); bool internalUndo();
private: private:
Io::AccountEntry *m_account; Io::AccountEntry *m_account;
FieldModel *m_model; FieldModel *m_model;
@ -106,13 +109,14 @@ private:
int m_count; int m_count;
}; };
class FieldModelRemoveRowsCommand : public CustomUndoCommand class FieldModelRemoveRowsCommand : public CustomUndoCommand {
{
public: public:
explicit FieldModelRemoveRowsCommand(FieldModel *model, int row, int count); explicit FieldModelRemoveRowsCommand(FieldModel *model, int row, int count);
protected: protected:
bool internalRedo(); bool internalRedo();
bool internalUndo(); bool internalUndo();
private: private:
Io::AccountEntry *m_account; Io::AccountEntry *m_account;
FieldModel *m_model; FieldModel *m_model;
@ -121,13 +125,14 @@ private:
QList<Io::Field> m_values; QList<Io::Field> m_values;
}; };
class EntryModelSetValueCommand : public CustomUndoCommand class EntryModelSetValueCommand : public CustomUndoCommand {
{
public: public:
explicit EntryModelSetValueCommand(EntryModel *model, const QModelIndex &index, const QVariant &value, int role); explicit EntryModelSetValueCommand(EntryModel *model, const QModelIndex &index, const QVariant &value, int role);
protected: protected:
bool internalRedo(); bool internalRedo();
bool internalUndo(); bool internalUndo();
private: private:
EntryModel *m_model; EntryModel *m_model;
std::list<std::string> m_path; std::list<std::string> m_path;
@ -136,10 +141,10 @@ private:
int m_role; int m_role;
}; };
class EntryModelModifyRowsCommand : public CustomUndoCommand class EntryModelModifyRowsCommand : public CustomUndoCommand {
{
public: public:
~EntryModelModifyRowsCommand(); ~EntryModelModifyRowsCommand();
protected: protected:
explicit EntryModelModifyRowsCommand(EntryModel *model, int row, int count, const QModelIndex &parent); explicit EntryModelModifyRowsCommand(EntryModel *model, int row, int count, const QModelIndex &parent);
bool internalRedo() = 0; bool internalRedo() = 0;
@ -153,31 +158,33 @@ protected:
QList<Io::Entry *> m_values; QList<Io::Entry *> m_values;
}; };
class EntryModelInsertRowsCommand : public EntryModelModifyRowsCommand class EntryModelInsertRowsCommand : public EntryModelModifyRowsCommand {
{
public: public:
explicit EntryModelInsertRowsCommand(EntryModel *model, int row, int count, const QModelIndex &parent); explicit EntryModelInsertRowsCommand(EntryModel *model, int row, int count, const QModelIndex &parent);
protected: protected:
bool internalRedo(); bool internalRedo();
bool internalUndo(); bool internalUndo();
}; };
class EntryModelRemoveRowsCommand : public EntryModelModifyRowsCommand class EntryModelRemoveRowsCommand : public EntryModelModifyRowsCommand {
{
public: public:
explicit EntryModelRemoveRowsCommand(EntryModel *model, int row, int count, const QModelIndex &parent); explicit EntryModelRemoveRowsCommand(EntryModel *model, int row, int count, const QModelIndex &parent);
protected: protected:
bool internalRedo(); bool internalRedo();
bool internalUndo(); bool internalUndo();
}; };
class EntryModelMoveRowsCommand : public CustomUndoCommand class EntryModelMoveRowsCommand : public CustomUndoCommand {
{
public: public:
explicit EntryModelMoveRowsCommand(EntryModel *model, const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild); explicit EntryModelMoveRowsCommand(
EntryModel *model, const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild);
protected: protected:
bool internalRedo(); bool internalRedo();
bool internalUndo(); bool internalUndo();
private: private:
EntryModel *m_model; EntryModel *m_model;
std::list<std::string> m_sourceParentPath; std::list<std::string> m_sourceParentPath;
@ -186,7 +193,6 @@ private:
std::list<std::string> m_destParentPath; std::list<std::string> m_destParentPath;
int m_destChild; int m_destChild;
}; };
} }
#endif // UNDOCOMMANDS_H #endif // UNDOCOMMANDS_H

View File

@ -1,9 +1,9 @@
#include "./cli/cli.h" #include "./cli/cli.h"
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS #ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
# include "./gui/initiategui.h" #include "./gui/initiategui.h"
#endif #endif
#ifdef PASSWORD_MANAGER_GUI_QTQUICK #ifdef PASSWORD_MANAGER_GUI_QTQUICK
# include "./quickgui/initiatequick.h" #include "./quickgui/initiatequick.h"
#endif #endif
#include "resources/config.h" #include "resources/config.h"
@ -11,15 +11,15 @@
#include <passwordfile/util/openssl.h> #include <passwordfile/util/openssl.h>
#include <c++utilities/application/argumentparser.h> #include <c++utilities/application/argumentparser.h>
#include <c++utilities/application/failure.h>
#include <c++utilities/application/commandlineutils.h> #include <c++utilities/application/commandlineutils.h>
#include <c++utilities/application/failure.h>
#if defined(PASSWORD_MANAGER_GUI_QTWIDGETS) || defined(PASSWORD_MANAGER_GUI_QTQUICK) #if defined(PASSWORD_MANAGER_GUI_QTWIDGETS) || defined(PASSWORD_MANAGER_GUI_QTQUICK)
# include <qtutilities/resources/qtconfigarguments.h> #include <QString>
# include <QString> #include <qtutilities/resources/qtconfigarguments.h>
ENABLE_QT_RESOURCES_OF_STATIC_DEPENDENCIES ENABLE_QT_RESOURCES_OF_STATIC_DEPENDENCIES
#else #else
# include <c++utilities/application/fakeqtconfigarguments.h> #include <c++utilities/application/fakeqtconfigarguments.h>
#endif #endif
#include <iostream> #include <iostream>
@ -37,7 +37,7 @@ int main(int argc, char *argv[])
ArgumentParser parser; ArgumentParser parser;
// file argument // file argument
Argument fileArg("file", 'f', "specifies the file to be opened (or created when using --modify)"); Argument fileArg("file", 'f', "specifies the file to be opened (or created when using --modify)");
fileArg.setValueNames({"path"}); fileArg.setValueNames({ "path" });
fileArg.setRequiredValueCount(1); fileArg.setRequiredValueCount(1);
fileArg.setCombinable(true); fileArg.setCombinable(true);
fileArg.setRequired(false); fileArg.setRequired(false);
@ -47,38 +47,38 @@ int main(int argc, char *argv[])
qtConfigArgs.qtWidgetsGuiArg().addSubArgument(&fileArg); qtConfigArgs.qtWidgetsGuiArg().addSubArgument(&fileArg);
// cli argument // cli argument
Argument cliArg("interactive-cli", 'i', "starts the interactive command line interface"); Argument cliArg("interactive-cli", 'i', "starts the interactive command line interface");
cliArg.setSubArguments({&fileArg}); cliArg.setSubArguments({ &fileArg });
// help argument // help argument
HelpArgument helpArg(parser); HelpArgument helpArg(parser);
parser.setMainArguments({&qtConfigArgs.qtWidgetsGuiArg(), &qtConfigArgs.qtQuickGuiArg(), &cliArg, &helpArg}); parser.setMainArguments({ &qtConfigArgs.qtWidgetsGuiArg(), &qtConfigArgs.qtQuickGuiArg(), &cliArg, &helpArg });
// holds the application's return code // holds the application's return code
int res = 0; int res = 0;
// parse the specified arguments // parse the specified arguments
try { try {
parser.parseArgs(argc, argv); parser.parseArgs(argc, argv);
if(cliArg.isPresent()) { if (cliArg.isPresent()) {
Cli::InteractiveCli cli; Cli::InteractiveCli cli;
if(fileArg.isPresent()) { if (fileArg.isPresent()) {
cli.run(fileArg.values().front()); cli.run(fileArg.values().front());
} else { } else {
cli.run(); cli.run();
} }
} else if(qtConfigArgs.areQtGuiArgsPresent()) { } else if (qtConfigArgs.areQtGuiArgsPresent()) {
// run Qt gui if no arguments, --qt-gui or --qt-quick-gui specified, a file might be specified // run Qt gui if no arguments, --qt-gui or --qt-quick-gui specified, a file might be specified
#if defined(PASSWORD_MANAGER_GUI_QTWIDGETS) || defined(PASSWORD_MANAGER_GUI_QTQUICK) #if defined(PASSWORD_MANAGER_GUI_QTWIDGETS) || defined(PASSWORD_MANAGER_GUI_QTQUICK)
QString file; QString file;
if(fileArg.isPresent()) { if (fileArg.isPresent()) {
file = QString::fromLocal8Bit(fileArg.values().front()); file = QString::fromLocal8Bit(fileArg.values().front());
} }
#endif #endif
if(qtConfigArgs.qtWidgetsGuiArg().isPresent()) { if (qtConfigArgs.qtWidgetsGuiArg().isPresent()) {
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS #ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
res = QtGui::runWidgetsGui(argc, argv, qtConfigArgs, file); res = QtGui::runWidgetsGui(argc, argv, qtConfigArgs, file);
#else #else
CMD_UTILS_START_CONSOLE; CMD_UTILS_START_CONSOLE;
cout << "The application has not been built with Qt widgets support." << endl; cout << "The application has not been built with Qt widgets support." << endl;
#endif #endif
} else if(qtConfigArgs.qtQuickGuiArg().isPresent()) { } else if (qtConfigArgs.qtQuickGuiArg().isPresent()) {
#ifdef PASSWORD_MANAGER_GUI_QTQUICK #ifdef PASSWORD_MANAGER_GUI_QTQUICK
res = QtGui::runQuickGui(argc, argv, qtConfigArgs); res = QtGui::runQuickGui(argc, argv, qtConfigArgs);
#else #else
@ -96,7 +96,7 @@ int main(int argc, char *argv[])
#endif #endif
} }
} }
} catch(const Failure &ex) { } catch (const Failure &ex) {
CMD_UTILS_START_CONSOLE; CMD_UTILS_START_CONSOLE;
cout << "Unable to parse arguments. " << ex.what() << "\nSee --help for available commands." << endl; cout << "Unable to parse arguments. " << ex.what() << "\nSee --help for available commands." << endl;
} }

View File

@ -5,8 +5,7 @@
namespace QtGui { namespace QtGui {
class EntryFilterModel : public QSortFilterProxyModel class EntryFilterModel : public QSortFilterProxyModel {
{
Q_OBJECT Q_OBJECT
public: public:
explicit EntryFilterModel(QObject *parent = nullptr); explicit EntryFilterModel(QObject *parent = nullptr);
@ -16,9 +15,7 @@ protected:
private: private:
bool hasAcceptedChildren(const QModelIndex &index) const; bool hasAcceptedChildren(const QModelIndex &index) const;
}; };
} }
#endif // ENTRYFILTERMODEL_H #endif // ENTRYFILTERMODEL_H

View File

@ -2,7 +2,7 @@
#define ENTRYMODEL_H #define ENTRYMODEL_H
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS #ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
# include "gui/stacksupport.h" #include "gui/stacksupport.h"
#endif #endif
#include <c++utilities/application/global.h> #include <c++utilities/application/global.h>
@ -20,15 +20,15 @@ namespace QtGui {
/*! /*!
* \brief The EntryModelRoles enum defines custom roles for the EntryModel class. * \brief The EntryModelRoles enum defines custom roles for the EntryModel class.
*/ */
enum EntryModelRoles enum EntryModelRoles {
{
SerializedRole = Qt::UserRole + 1, /**< the entry (including descendants) in serialized from (QByteArray) */ SerializedRole = Qt::UserRole + 1, /**< the entry (including descendants) in serialized from (QByteArray) */
DefaultExpandedRole = Qt::UserRole + 2 /**< whether the entry should be expanded by default */ DefaultExpandedRole = Qt::UserRole + 2 /**< whether the entry should be expanded by default */
}; };
class EntryModel : public QAbstractItemModel class EntryModel : public QAbstractItemModel
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS #ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
, public StackSupport ,
public StackSupport
#endif #endif
{ {
Q_OBJECT Q_OBJECT
@ -89,7 +89,7 @@ inline Io::NodeEntry *EntryModel::rootEntry()
*/ */
inline void EntryModel::setRootEntry(Io::NodeEntry *entry) inline void EntryModel::setRootEntry(Io::NodeEntry *entry)
{ {
if(m_rootEntry != entry) { if (m_rootEntry != entry) {
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS #ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
clearUndoStack(); clearUndoStack();
#endif #endif
@ -122,7 +122,6 @@ inline void EntryModel::setInsertType(Io::EntryType type)
{ {
m_insertType = type; m_insertType = type;
} }
} }
#endif // ENTRYMODEL_H #endif // ENTRYMODEL_H

View File

@ -2,7 +2,7 @@
#define FIELDMODEL_H #define FIELDMODEL_H
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS #ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
# include "gui/stacksupport.h" #include "gui/stacksupport.h"
#endif #endif
#include <passwordfile/io/entry.h> #include <passwordfile/io/entry.h>
@ -20,16 +20,14 @@ namespace QtGui {
/*! /*!
* \brief The FieldModelRoles enum defines custom roles for the FieldModel class. * \brief The FieldModelRoles enum defines custom roles for the FieldModel class.
*/ */
enum FieldModelRoles enum FieldModelRoles {
{
FieldTypeRole = Qt::UserRole + 1 /**< the field type */ FieldTypeRole = Qt::UserRole + 1 /**< the field type */
}; };
/*! /*!
* \brief The PasswordVisibility enum defines when passwords will be visible. * \brief The PasswordVisibility enum defines when passwords will be visible.
*/ */
enum PasswordVisibility enum PasswordVisibility {
{
Always, /**< passwords are always visible */ Always, /**< passwords are always visible */
OnlyWhenEditing, /**< passwords are only visible when editing */ OnlyWhenEditing, /**< passwords are only visible when editing */
Never /**< passwords are never visible */ Never /**< passwords are never visible */
@ -37,11 +35,12 @@ enum PasswordVisibility
class FieldModel : public QAbstractTableModel class FieldModel : public QAbstractTableModel
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS #ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
, public StackSupport ,
public StackSupport
#endif #endif
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit FieldModel(QObject *parent = nullptr); explicit FieldModel(QObject *parent = nullptr);
#ifdef PASSWORD_MANAGER_GUI_QTWIDGETS #ifdef PASSWORD_MANAGER_GUI_QTWIDGETS
explicit FieldModel(QUndoStack *undoStack, QObject *parent = nullptr); explicit FieldModel(QUndoStack *undoStack, QObject *parent = nullptr);
@ -128,11 +127,10 @@ inline PasswordVisibility FieldModel::passwordVisibility() const
inline void FieldModel::setPasswordVisibility(PasswordVisibility passwordVisibility) inline void FieldModel::setPasswordVisibility(PasswordVisibility passwordVisibility)
{ {
m_passwordVisibility = passwordVisibility; m_passwordVisibility = passwordVisibility;
if(m_fields) { if (m_fields) {
emit dataChanged(index(0, 1), index(m_fields->size() - 1, 1), QVector<int>() << Qt::DisplayRole << Qt::EditRole); emit dataChanged(index(0, 1), index(m_fields->size() - 1, 1), QVector<int>() << Qt::DisplayRole << Qt::EditRole);
} }
} }
} }
#endif // FIELDMODEL_H #endif // FIELDMODEL_H

View File

@ -2,13 +2,13 @@
#include <qmath.h> #include <qmath.h>
#include <QDebug>
#include <QFile> #include <QFile>
#include <QGuiApplication>
#include <QRegExp> #include <QRegExp>
#include <QScreen>
#include <QUrl> #include <QUrl>
#include <QUrlQuery> #include <QUrlQuery>
#include <QGuiApplication>
#include <QScreen>
#include <QDebug>
using namespace Io; using namespace Io;
@ -40,14 +40,14 @@ ApplicationInfo::ApplicationInfo()
m_sliderHandleHeight = sizeWithRatio(87); m_sliderHandleHeight = sizeWithRatio(87);
m_sliderGapWidth = sizeWithRatio(100); m_sliderGapWidth = sizeWithRatio(100);
m_isPortraitMode = isMobile() ? rect.height() > rect.width() : false; m_isPortraitMode = isMobile() ? rect.height() > rect.width() : false;
m_hMargin = m_isPortraitMode ? 20 * ratio() : 50 * ratio(); m_hMargin = m_isPortraitMode ? 20 * ratio() : 50 * ratio();
m_applicationWidth = isMobile() ? rect.width() : 1120; m_applicationWidth = isMobile() ? rect.width() : 1120;
m_constants->insert(QLatin1String("rowDelegateHeight"), QVariant(sizeWithRatio(118))); m_constants->insert(QLatin1String("rowDelegateHeight"), QVariant(sizeWithRatio(118)));
m_fieldModel = new FieldModel(this); m_fieldModel = new FieldModel(this);
if(isMobile()) { if (isMobile()) {
connect(QGuiApplication::primaryScreen(), &QScreen::orientationChanged, this, &ApplicationInfo::notifyPortraitMode); connect(QGuiApplication::primaryScreen(), &QScreen::orientationChanged, this, &ApplicationInfo::notifyPortraitMode);
} }
} }
@ -90,5 +90,4 @@ void ApplicationInfo::setIsPortraitMode(const bool newMode)
emit hMarginChanged(); emit hMarginChanged();
} }
} }
} }

View File

@ -8,8 +8,7 @@
namespace QtGui { namespace QtGui {
class ApplicationInfo : public QObject class ApplicationInfo : public QObject {
{
Q_OBJECT Q_OBJECT
Q_PROPERTY(int applicationWidth READ applicationWidth WRITE setApplicationWidth NOTIFY applicationWidthChanged) Q_PROPERTY(int applicationWidth READ applicationWidth WRITE setApplicationWidth NOTIFY applicationWidthChanged)
Q_PROPERTY(bool isMobile READ isMobile CONSTANT) Q_PROPERTY(bool isMobile READ isMobile CONSTANT)
@ -114,7 +113,7 @@ inline const QString &ApplicationInfo::currentFile() const
inline void ApplicationInfo::setCurrentFile(const QString &currentFile) inline void ApplicationInfo::setCurrentFile(const QString &currentFile)
{ {
if(m_currentFile != currentFile) { if (m_currentFile != currentFile) {
m_currentFile = currentFile; m_currentFile = currentFile;
emit currentFileChanged(); emit currentFileChanged();
} }
@ -132,7 +131,7 @@ inline Io::AccountEntry *ApplicationInfo::currentAccountEntry()
inline QString ApplicationInfo::currentAccountName() const inline QString ApplicationInfo::currentAccountName() const
{ {
if(m_fieldModel->accountEntry()) { if (m_fieldModel->accountEntry()) {
return QString::fromStdString(m_fieldModel->accountEntry()->label()); return QString::fromStdString(m_fieldModel->accountEntry()->label());
} }
return QString(); return QString();
@ -172,7 +171,6 @@ inline qreal ApplicationInfo::sizeWithRatio(const qreal height)
{ {
return ratio() * height; return ratio() * height;
} }
} }
#endif // APPLICATIONINFO_H #endif // APPLICATIONINFO_H

View File

@ -7,11 +7,11 @@
namespace QtGui { namespace QtGui {
class ApplicationPaths class ApplicationPaths {
{
public: public:
static QString settingsPath(); static QString settingsPath();
static QString dowloadedFilesPath(); static QString dowloadedFilesPath();
protected: protected:
static QString path(QStandardPaths::StandardLocation location); static QString path(QStandardPaths::StandardLocation location);
}; };
@ -30,13 +30,12 @@ inline QString ApplicationPaths::path(QStandardPaths::StandardLocation location)
{ {
QString path = QStandardPaths::standardLocations(location).value(0); QString path = QStandardPaths::standardLocations(location).value(0);
QDir dir(path); QDir dir(path);
if(!dir.exists()) if (!dir.exists())
dir.mkpath(path); dir.mkpath(path);
if(!path.isEmpty() && !path.endsWith("/")) if (!path.isEmpty() && !path.endsWith("/"))
path += "/"; path += "/";
return path; return path;
} }
} }
#endif // APPLICATIONPATHS_H #endif // APPLICATIONPATHS_H

View File

@ -11,15 +11,15 @@
#include <qtutilities/resources/resources.h> #include <qtutilities/resources/resources.h>
#if defined(GUI_QTWIDGETS) #if defined(GUI_QTWIDGETS)
# include <QApplication> #include <QApplication>
#else #else
# include <QGuiApplication>
#endif
#include <QGuiApplication> #include <QGuiApplication>
#endif
#include <QDebug>
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QTextCodec> #include <QTextCodec>
#include <QtQml> #include <QtQml>
#include <QQmlApplicationEngine>
#include <QDebug>
using namespace ApplicationUtilities; using namespace ApplicationUtilities;
@ -55,5 +55,4 @@ int runQuickGui(int argc, char *argv[], const QtConfigArguments &qtConfigArgs)
int res = a.exec(); int res = a.exec();
return res; return res;
} }
} }

View File

@ -12,7 +12,6 @@ class QtConfigArguments;
namespace QtGui { namespace QtGui {
int runQuickGui(int argc, char *argv[], const ApplicationUtilities::QtConfigArguments &qtConfigArgs); int runQuickGui(int argc, char *argv[], const ApplicationUtilities::QtConfigArguments &qtConfigArgs);
} }
#endif // QT_QUICK_GUI_INITIATE_H #endif // QT_QUICK_GUI_INITIATE_H

View File

@ -265,92 +265,92 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="318"/> <location filename="../gui/mainwindow.cpp" line="319"/>
<source>Qt settings</source> <source>Qt settings</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="336"/> <location filename="../gui/mainwindow.cpp" line="337"/>
<source>A simple password store using AES-256-CBC encryption via OpenSSL.</source> <source>A simple password store using AES-256-CBC encryption via OpenSSL.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="358"/> <location filename="../gui/mainwindow.cpp" line="361"/>
<source>Select a password list</source> <source>Select a password list</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="358"/> <location filename="../gui/mainwindow.cpp" line="361"/>
<location filename="../gui/mainwindow.cpp" line="688"/> <location filename="../gui/mainwindow.cpp" line="688"/>
<source>Password Manager files (*.pwmgr);;All files (*)</source> <source>Password Manager files (*.pwmgr);;All files (*)</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="385"/> <location filename="../gui/mainwindow.cpp" line="388"/>
<source>Undo stack</source> <source>Undo stack</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="413"/> <location filename="../gui/mainwindow.cpp" line="417"/>
<source>An IO error occured when opening the specified file &quot;%1&quot;. <source>An IO error occured when opening the specified file &quot;%1&quot;.
(%2)</source> (%2)</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="420"/> <location filename="../gui/mainwindow.cpp" line="425"/>
<source>The file you want to load seems to be very big. Do you really want to open it?</source> <source>The file you want to load seems to be very big. Do you really want to open it?</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="428"/> <location filename="../gui/mainwindow.cpp" line="434"/>
<source>Opening file</source> <source>Opening file</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="429"/> <location filename="../gui/mainwindow.cpp" line="435"/>
<source>Enter the password to open the file &quot;%1&quot;</source> <source>Enter the password to open the file &quot;%1&quot;</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="434"/> <location filename="../gui/mainwindow.cpp" line="440"/>
<location filename="../gui/mainwindow.cpp" line="435"/> <location filename="../gui/mainwindow.cpp" line="441"/>
<source>A password is needed to open the file.</source> <source>A password is needed to open the file.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="454"/> <location filename="../gui/mainwindow.cpp" line="459"/>
<source>The file couldn&apos;t be decrypted. <source>The file couldn&apos;t be decrypted.
OpenSSL error queue: %1</source> OpenSSL error queue: %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="459"/> <location filename="../gui/mainwindow.cpp" line="464"/>
<source>Unable to parse the file. %1</source> <source>Unable to parse the file. %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="519"/> <location filename="../gui/mainwindow.cpp" line="523"/>
<source>The file &lt;i&gt;%1&lt;/i&gt; couldn&apos;t be created.</source> <source>The file &lt;i&gt;%1&lt;/i&gt; couldn&apos;t be created.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="536"/> <location filename="../gui/mainwindow.cpp" line="540"/>
<source>A new password list has been created.</source> <source>A new password list has been created.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="539"/> <location filename="../gui/mainwindow.cpp" line="543"/>
<source>The password list has been load.</source> <source>The password list has been load.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="670"/> <location filename="../gui/mainwindow.cpp" line="674"/>
<source>Exactly one fields needs to be selected (top-left corner for insertion).</source> <source>Exactly one fields needs to be selected (top-left corner for insertion).</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="686"/> <location filename="../gui/mainwindow.cpp" line="688"/>
<source>Select where you want to save the password list</source> <source>Select where you want to save the password list</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -380,7 +380,7 @@ OpenSSL error queue: %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="763"/> <location filename="../gui/mainwindow.cpp" line="762"/>
<source>The password list has been closed.</source> <source>The password list has been closed.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -416,124 +416,124 @@ OpenSSL error queue: %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="843"/> <location filename="../gui/mainwindow.cpp" line="844"/>
<source>Plain text document (*.txt);;All files (*.*)</source> <source>Plain text document (*.txt);;All files (*.*)</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="849"/> <location filename="../gui/mainwindow.cpp" line="850"/>
<source>The password list couldn&apos;t be exported. %1</source> <source>The password list couldn&apos;t be exported. %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="852"/> <location filename="../gui/mainwindow.cpp" line="853"/>
<source>The password list has been exported.</source> <source>The password list has been exported.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="868"/> <location filename="../gui/mainwindow.cpp" line="869"/>
<source>The currently opened file hasn&apos;t been saved yet.</source> <source>The currently opened file hasn&apos;t been saved yet.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="908"/> <location filename="../gui/mainwindow.cpp" line="909"/>
<location filename="../gui/mainwindow.cpp" line="1118"/> <location filename="../gui/mainwindow.cpp" line="1123"/>
<source>Add account</source> <source>Add account</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="908"/> <location filename="../gui/mainwindow.cpp" line="909"/>
<location filename="../gui/mainwindow.cpp" line="1119"/> <location filename="../gui/mainwindow.cpp" line="1124"/>
<source>Add category</source> <source>Add category</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="908"/> <location filename="../gui/mainwindow.cpp" line="910"/>
<source>Enter the entry name</source> <source>Enter the entry name</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="908"/> <location filename="../gui/mainwindow.cpp" line="910"/>
<source>new entry</source> <source>new entry</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="917"/> <location filename="../gui/mainwindow.cpp" line="919"/>
<source>Unable to create new entry.</source> <source>Unable to create new entry.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="920"/> <location filename="../gui/mainwindow.cpp" line="922"/>
<source>You didn&apos;t enter text.</source> <source>You didn&apos;t enter text.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="926"/> <location filename="../gui/mainwindow.cpp" line="928"/>
<source>No node element selected.</source> <source>No node element selected.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="941"/> <location filename="../gui/mainwindow.cpp" line="943"/>
<source>Unable to remove the entry.</source> <source>Unable to remove the entry.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="944"/> <location filename="../gui/mainwindow.cpp" line="946"/>
<source>No entry selected.</source> <source>No entry selected.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="996"/> <location filename="../gui/mainwindow.cpp" line="999"/>
<source>A field has to be selected since new fields are always inserted before the currently selected field.</source> <source>A field has to be selected since new fields are always inserted before the currently selected field.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="1020"/> <location filename="../gui/mainwindow.cpp" line="1023"/>
<source>No fields have been removed since there are currently no fields selected.</source> <source>No fields have been removed since there are currently no fields selected.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="1055"/> <location filename="../gui/mainwindow.cpp" line="1058"/>
<source>No fields have been changed since there are currently no fields selected.</source> <source>No fields have been changed since there are currently no fields selected.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="1085"/> <location filename="../gui/mainwindow.cpp" line="1088"/>
<source>Changing password</source> <source>Changing password</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="1092"/> <location filename="../gui/mainwindow.cpp" line="1096"/>
<source>You didn&apos;t enter a password. &lt;strong&gt;No encryption&lt;/strong&gt; will be used when saving the file next time.</source> <source>You didn&apos;t enter a password. &lt;strong&gt;No encryption&lt;/strong&gt; will be used when saving the file next time.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="1096"/> <location filename="../gui/mainwindow.cpp" line="1100"/>
<source>The new password will be used next time you save the file.</source> <source>The new password will be used next time you save the file.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="1100"/> <location filename="../gui/mainwindow.cpp" line="1105"/>
<source>You aborted. The old password will still be used when saving the file next time.</source> <source>You aborted. The old password will still be used when saving the file next time.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="1121"/> <location filename="../gui/mainwindow.cpp" line="1126"/>
<source>Remove entry</source> <source>Remove entry</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="1127"/> <location filename="../gui/mainwindow.cpp" line="1132"/>
<source>Expanded by default</source> <source>Expanded by default</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="1184"/> <location filename="../gui/mainwindow.cpp" line="1188"/>
<source>Insert field</source> <source>Insert field</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="../gui/mainwindow.cpp" line="1185"/> <location filename="../gui/mainwindow.cpp" line="1189"/>
<source>Remove field(s)</source> <source>Remove field(s)</source>
<translation type="unfinished"> <translation type="unfinished">
<numerusform></numerusform> <numerusform></numerusform>
@ -541,37 +541,37 @@ OpenSSL error queue: %1</source>
</translation> </translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="1190"/> <location filename="../gui/mainwindow.cpp" line="1195"/>
<source>Mark as password field</source> <source>Mark as password field</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="1193"/> <location filename="../gui/mainwindow.cpp" line="1198"/>
<source>Mark as normal field</source> <source>Mark as normal field</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="1199"/> <location filename="../gui/mainwindow.cpp" line="1204"/>
<source>Copy</source> <source>Copy</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="1200"/> <location filename="../gui/mainwindow.cpp" line="1205"/>
<source>Copy for 5 seconds</source> <source>Copy for 5 seconds</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="1202"/> <location filename="../gui/mainwindow.cpp" line="1207"/>
<source>Paste</source> <source>Paste</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="1206"/> <location filename="../gui/mainwindow.cpp" line="1211"/>
<source>Open URL</source> <source>Open URL</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="1229"/> <location filename="../gui/mainwindow.cpp" line="1234"/>
<source>The selection is empty.</source> <source>The selection is empty.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -634,18 +634,18 @@ OpenSSL error queue: %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/passwordgeneratordialog.cpp" line="133"/> <location filename="../gui/passwordgeneratordialog.cpp" line="126"/>
<source>Failed to generate password. <source>Failed to generate password.
OpenSSL error: %1</source> OpenSSL error: %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/passwordgeneratordialog.cpp" line="136"/> <location filename="../gui/passwordgeneratordialog.cpp" line="129"/>
<source>You have to select at least one checkbox.</source> <source>You have to select at least one checkbox.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/passwordgeneratordialog.cpp" line="139"/> <location filename="../gui/passwordgeneratordialog.cpp" line="132"/>
<source>The length has to be at least one.</source> <source>The length has to be at least one.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -714,37 +714,37 @@ OpenSSL error: %1</source>
<context> <context>
<name>undocommands</name> <name>undocommands</name>
<message> <message>
<location filename="../gui/undocommands.cpp" line="84"/> <location filename="../gui/undocommands.cpp" line="85"/>
<source>setting field name to »%1«</source> <source>setting field name to »%1«</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/undocommands.cpp" line="86"/> <location filename="../gui/undocommands.cpp" line="87"/>
<source>setting field name »%1« to »%2«</source> <source>setting field name »%1« to »%2«</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/undocommands.cpp" line="91"/> <location filename="../gui/undocommands.cpp" line="92"/>
<source>setting value of empty field</source> <source>setting value of empty field</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/undocommands.cpp" line="93"/> <location filename="../gui/undocommands.cpp" line="94"/>
<source>setting value of »%1« field</source> <source>setting value of »%1« field</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/undocommands.cpp" line="99"/> <location filename="../gui/undocommands.cpp" line="100"/>
<source>setting type of »%1« field</source> <source>setting type of »%1« field</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/undocommands.cpp" line="102"/> <location filename="../gui/undocommands.cpp" line="103"/>
<source>setting field property in row »%1«</source> <source>setting field property in row »%1«</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="../gui/undocommands.cpp" line="134"/> <location filename="../gui/undocommands.cpp" line="135"/>
<source>insertion of %1 row(s) before row %2</source> <source>insertion of %1 row(s) before row %2</source>
<translation type="unfinished"> <translation type="unfinished">
<numerusform></numerusform> <numerusform></numerusform>
@ -752,7 +752,7 @@ OpenSSL error: %1</source>
</translation> </translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="../gui/undocommands.cpp" line="165"/> <location filename="../gui/undocommands.cpp" line="166"/>
<source>removal of row %1</source> <source>removal of row %1</source>
<translation type="unfinished"> <translation type="unfinished">
<numerusform></numerusform> <numerusform></numerusform>
@ -760,7 +760,7 @@ OpenSSL error: %1</source>
</translation> </translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="../gui/undocommands.cpp" line="167"/> <location filename="../gui/undocommands.cpp" line="168"/>
<source>removal of the rows %1 to %2</source> <source>removal of the rows %1 to %2</source>
<translation type="unfinished"> <translation type="unfinished">
<numerusform></numerusform> <numerusform></numerusform>
@ -768,27 +768,27 @@ OpenSSL error: %1</source>
</translation> </translation>
</message> </message>
<message> <message>
<location filename="../gui/undocommands.cpp" line="247"/> <location filename="../gui/undocommands.cpp" line="248"/>
<source>setting entry name to »%1«</source> <source>setting entry name to »%1«</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/undocommands.cpp" line="249"/> <location filename="../gui/undocommands.cpp" line="251"/>
<source>setting entry name from »%1« to »%2«</source> <source>setting entry name from »%1« to »%2«</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/undocommands.cpp" line="255"/> <location filename="../gui/undocommands.cpp" line="257"/>
<source>setting property of an entry</source> <source>setting property of an entry</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/undocommands.cpp" line="257"/> <location filename="../gui/undocommands.cpp" line="259"/>
<source>setting property of entry »%1«</source> <source>setting property of entry »%1«</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="../gui/undocommands.cpp" line="353"/> <location filename="../gui/undocommands.cpp" line="355"/>
<source>insertion of %1 entry/entries</source> <source>insertion of %1 entry/entries</source>
<translation type="unfinished"> <translation type="unfinished">
<numerusform></numerusform> <numerusform></numerusform>
@ -796,7 +796,7 @@ OpenSSL error: %1</source>
</translation> </translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="../gui/undocommands.cpp" line="385"/> <location filename="../gui/undocommands.cpp" line="387"/>
<source>removal of %1 entry/entries</source> <source>removal of %1 entry/entries</source>
<translation type="unfinished"> <translation type="unfinished">
<numerusform></numerusform> <numerusform></numerusform>
@ -804,7 +804,7 @@ OpenSSL error: %1</source>
</translation> </translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="../gui/undocommands.cpp" line="415"/> <location filename="../gui/undocommands.cpp" line="418"/>
<source>move of %1 entry/entries</source> <source>move of %1 entry/entries</source>
<translation type="unfinished"> <translation type="unfinished">
<numerusform></numerusform> <numerusform></numerusform>

View File

@ -265,92 +265,92 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="318"/> <location filename="../gui/mainwindow.cpp" line="319"/>
<source>Qt settings</source> <source>Qt settings</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="336"/> <location filename="../gui/mainwindow.cpp" line="337"/>
<source>A simple password store using AES-256-CBC encryption via OpenSSL.</source> <source>A simple password store using AES-256-CBC encryption via OpenSSL.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="358"/> <location filename="../gui/mainwindow.cpp" line="361"/>
<source>Select a password list</source> <source>Select a password list</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="358"/> <location filename="../gui/mainwindow.cpp" line="361"/>
<location filename="../gui/mainwindow.cpp" line="688"/> <location filename="../gui/mainwindow.cpp" line="688"/>
<source>Password Manager files (*.pwmgr);;All files (*)</source> <source>Password Manager files (*.pwmgr);;All files (*)</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="385"/> <location filename="../gui/mainwindow.cpp" line="388"/>
<source>Undo stack</source> <source>Undo stack</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="413"/> <location filename="../gui/mainwindow.cpp" line="417"/>
<source>An IO error occured when opening the specified file &quot;%1&quot;. <source>An IO error occured when opening the specified file &quot;%1&quot;.
(%2)</source> (%2)</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="420"/> <location filename="../gui/mainwindow.cpp" line="425"/>
<source>The file you want to load seems to be very big. Do you really want to open it?</source> <source>The file you want to load seems to be very big. Do you really want to open it?</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="428"/> <location filename="../gui/mainwindow.cpp" line="434"/>
<source>Opening file</source> <source>Opening file</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="429"/> <location filename="../gui/mainwindow.cpp" line="435"/>
<source>Enter the password to open the file &quot;%1&quot;</source> <source>Enter the password to open the file &quot;%1&quot;</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="434"/> <location filename="../gui/mainwindow.cpp" line="440"/>
<location filename="../gui/mainwindow.cpp" line="435"/> <location filename="../gui/mainwindow.cpp" line="441"/>
<source>A password is needed to open the file.</source> <source>A password is needed to open the file.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="454"/> <location filename="../gui/mainwindow.cpp" line="459"/>
<source>The file couldn&apos;t be decrypted. <source>The file couldn&apos;t be decrypted.
OpenSSL error queue: %1</source> OpenSSL error queue: %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="459"/> <location filename="../gui/mainwindow.cpp" line="464"/>
<source>Unable to parse the file. %1</source> <source>Unable to parse the file. %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="519"/> <location filename="../gui/mainwindow.cpp" line="523"/>
<source>The file &lt;i&gt;%1&lt;/i&gt; couldn&apos;t be created.</source> <source>The file &lt;i&gt;%1&lt;/i&gt; couldn&apos;t be created.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="536"/> <location filename="../gui/mainwindow.cpp" line="540"/>
<source>A new password list has been created.</source> <source>A new password list has been created.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="539"/> <location filename="../gui/mainwindow.cpp" line="543"/>
<source>The password list has been load.</source> <source>The password list has been load.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="670"/> <location filename="../gui/mainwindow.cpp" line="674"/>
<source>Exactly one fields needs to be selected (top-left corner for insertion).</source> <source>Exactly one fields needs to be selected (top-left corner for insertion).</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="686"/> <location filename="../gui/mainwindow.cpp" line="688"/>
<source>Select where you want to save the password list</source> <source>Select where you want to save the password list</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -380,7 +380,7 @@ OpenSSL error queue: %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="763"/> <location filename="../gui/mainwindow.cpp" line="762"/>
<source>The password list has been closed.</source> <source>The password list has been closed.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -416,124 +416,124 @@ OpenSSL error queue: %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="843"/> <location filename="../gui/mainwindow.cpp" line="844"/>
<source>Plain text document (*.txt);;All files (*.*)</source> <source>Plain text document (*.txt);;All files (*.*)</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="849"/> <location filename="../gui/mainwindow.cpp" line="850"/>
<source>The password list couldn&apos;t be exported. %1</source> <source>The password list couldn&apos;t be exported. %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="852"/> <location filename="../gui/mainwindow.cpp" line="853"/>
<source>The password list has been exported.</source> <source>The password list has been exported.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="868"/> <location filename="../gui/mainwindow.cpp" line="869"/>
<source>The currently opened file hasn&apos;t been saved yet.</source> <source>The currently opened file hasn&apos;t been saved yet.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="908"/> <location filename="../gui/mainwindow.cpp" line="909"/>
<location filename="../gui/mainwindow.cpp" line="1118"/> <location filename="../gui/mainwindow.cpp" line="1123"/>
<source>Add account</source> <source>Add account</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="908"/> <location filename="../gui/mainwindow.cpp" line="909"/>
<location filename="../gui/mainwindow.cpp" line="1119"/> <location filename="../gui/mainwindow.cpp" line="1124"/>
<source>Add category</source> <source>Add category</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="908"/> <location filename="../gui/mainwindow.cpp" line="910"/>
<source>Enter the entry name</source> <source>Enter the entry name</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="908"/> <location filename="../gui/mainwindow.cpp" line="910"/>
<source>new entry</source> <source>new entry</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="917"/> <location filename="../gui/mainwindow.cpp" line="919"/>
<source>Unable to create new entry.</source> <source>Unable to create new entry.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="920"/> <location filename="../gui/mainwindow.cpp" line="922"/>
<source>You didn&apos;t enter text.</source> <source>You didn&apos;t enter text.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="926"/> <location filename="../gui/mainwindow.cpp" line="928"/>
<source>No node element selected.</source> <source>No node element selected.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="941"/> <location filename="../gui/mainwindow.cpp" line="943"/>
<source>Unable to remove the entry.</source> <source>Unable to remove the entry.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="944"/> <location filename="../gui/mainwindow.cpp" line="946"/>
<source>No entry selected.</source> <source>No entry selected.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="996"/> <location filename="../gui/mainwindow.cpp" line="999"/>
<source>A field has to be selected since new fields are always inserted before the currently selected field.</source> <source>A field has to be selected since new fields are always inserted before the currently selected field.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="1020"/> <location filename="../gui/mainwindow.cpp" line="1023"/>
<source>No fields have been removed since there are currently no fields selected.</source> <source>No fields have been removed since there are currently no fields selected.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="1055"/> <location filename="../gui/mainwindow.cpp" line="1058"/>
<source>No fields have been changed since there are currently no fields selected.</source> <source>No fields have been changed since there are currently no fields selected.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="1085"/> <location filename="../gui/mainwindow.cpp" line="1088"/>
<source>Changing password</source> <source>Changing password</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="1092"/> <location filename="../gui/mainwindow.cpp" line="1096"/>
<source>You didn&apos;t enter a password. &lt;strong&gt;No encryption&lt;/strong&gt; will be used when saving the file next time.</source> <source>You didn&apos;t enter a password. &lt;strong&gt;No encryption&lt;/strong&gt; will be used when saving the file next time.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="1096"/> <location filename="../gui/mainwindow.cpp" line="1100"/>
<source>The new password will be used next time you save the file.</source> <source>The new password will be used next time you save the file.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="1100"/> <location filename="../gui/mainwindow.cpp" line="1105"/>
<source>You aborted. The old password will still be used when saving the file next time.</source> <source>You aborted. The old password will still be used when saving the file next time.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="1121"/> <location filename="../gui/mainwindow.cpp" line="1126"/>
<source>Remove entry</source> <source>Remove entry</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="1127"/> <location filename="../gui/mainwindow.cpp" line="1132"/>
<source>Expanded by default</source> <source>Expanded by default</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="1184"/> <location filename="../gui/mainwindow.cpp" line="1188"/>
<source>Insert field</source> <source>Insert field</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="../gui/mainwindow.cpp" line="1185"/> <location filename="../gui/mainwindow.cpp" line="1189"/>
<source>Remove field(s)</source> <source>Remove field(s)</source>
<translation type="unfinished"> <translation type="unfinished">
<numerusform></numerusform> <numerusform></numerusform>
@ -541,37 +541,37 @@ OpenSSL error queue: %1</source>
</translation> </translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="1190"/> <location filename="../gui/mainwindow.cpp" line="1195"/>
<source>Mark as password field</source> <source>Mark as password field</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="1193"/> <location filename="../gui/mainwindow.cpp" line="1198"/>
<source>Mark as normal field</source> <source>Mark as normal field</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="1199"/> <location filename="../gui/mainwindow.cpp" line="1204"/>
<source>Copy</source> <source>Copy</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="1200"/> <location filename="../gui/mainwindow.cpp" line="1205"/>
<source>Copy for 5 seconds</source> <source>Copy for 5 seconds</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="1202"/> <location filename="../gui/mainwindow.cpp" line="1207"/>
<source>Paste</source> <source>Paste</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="1206"/> <location filename="../gui/mainwindow.cpp" line="1211"/>
<source>Open URL</source> <source>Open URL</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/mainwindow.cpp" line="1229"/> <location filename="../gui/mainwindow.cpp" line="1234"/>
<source>The selection is empty.</source> <source>The selection is empty.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -634,18 +634,18 @@ OpenSSL error queue: %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/passwordgeneratordialog.cpp" line="133"/> <location filename="../gui/passwordgeneratordialog.cpp" line="126"/>
<source>Failed to generate password. <source>Failed to generate password.
OpenSSL error: %1</source> OpenSSL error: %1</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/passwordgeneratordialog.cpp" line="136"/> <location filename="../gui/passwordgeneratordialog.cpp" line="129"/>
<source>You have to select at least one checkbox.</source> <source>You have to select at least one checkbox.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/passwordgeneratordialog.cpp" line="139"/> <location filename="../gui/passwordgeneratordialog.cpp" line="132"/>
<source>The length has to be at least one.</source> <source>The length has to be at least one.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -714,37 +714,37 @@ OpenSSL error: %1</source>
<context> <context>
<name>undocommands</name> <name>undocommands</name>
<message> <message>
<location filename="../gui/undocommands.cpp" line="84"/> <location filename="../gui/undocommands.cpp" line="85"/>
<source>setting field name to »%1«</source> <source>setting field name to »%1«</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/undocommands.cpp" line="86"/> <location filename="../gui/undocommands.cpp" line="87"/>
<source>setting field name »%1« to »%2«</source> <source>setting field name »%1« to »%2«</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/undocommands.cpp" line="91"/> <location filename="../gui/undocommands.cpp" line="92"/>
<source>setting value of empty field</source> <source>setting value of empty field</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/undocommands.cpp" line="93"/> <location filename="../gui/undocommands.cpp" line="94"/>
<source>setting value of »%1« field</source> <source>setting value of »%1« field</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/undocommands.cpp" line="99"/> <location filename="../gui/undocommands.cpp" line="100"/>
<source>setting type of »%1« field</source> <source>setting type of »%1« field</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/undocommands.cpp" line="102"/> <location filename="../gui/undocommands.cpp" line="103"/>
<source>setting field property in row »%1«</source> <source>setting field property in row »%1«</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="../gui/undocommands.cpp" line="134"/> <location filename="../gui/undocommands.cpp" line="135"/>
<source>insertion of %1 row(s) before row %2</source> <source>insertion of %1 row(s) before row %2</source>
<translation type="unfinished"> <translation type="unfinished">
<numerusform></numerusform> <numerusform></numerusform>
@ -752,7 +752,7 @@ OpenSSL error: %1</source>
</translation> </translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="../gui/undocommands.cpp" line="165"/> <location filename="../gui/undocommands.cpp" line="166"/>
<source>removal of row %1</source> <source>removal of row %1</source>
<translation type="unfinished"> <translation type="unfinished">
<numerusform></numerusform> <numerusform></numerusform>
@ -760,7 +760,7 @@ OpenSSL error: %1</source>
</translation> </translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="../gui/undocommands.cpp" line="167"/> <location filename="../gui/undocommands.cpp" line="168"/>
<source>removal of the rows %1 to %2</source> <source>removal of the rows %1 to %2</source>
<translation type="unfinished"> <translation type="unfinished">
<numerusform></numerusform> <numerusform></numerusform>
@ -768,27 +768,27 @@ OpenSSL error: %1</source>
</translation> </translation>
</message> </message>
<message> <message>
<location filename="../gui/undocommands.cpp" line="247"/> <location filename="../gui/undocommands.cpp" line="248"/>
<source>setting entry name to »%1«</source> <source>setting entry name to »%1«</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/undocommands.cpp" line="249"/> <location filename="../gui/undocommands.cpp" line="251"/>
<source>setting entry name from »%1« to »%2«</source> <source>setting entry name from »%1« to »%2«</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/undocommands.cpp" line="255"/> <location filename="../gui/undocommands.cpp" line="257"/>
<source>setting property of an entry</source> <source>setting property of an entry</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../gui/undocommands.cpp" line="257"/> <location filename="../gui/undocommands.cpp" line="259"/>
<source>setting property of entry »%1«</source> <source>setting property of entry »%1«</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="../gui/undocommands.cpp" line="353"/> <location filename="../gui/undocommands.cpp" line="355"/>
<source>insertion of %1 entry/entries</source> <source>insertion of %1 entry/entries</source>
<translation type="unfinished"> <translation type="unfinished">
<numerusform></numerusform> <numerusform></numerusform>
@ -796,7 +796,7 @@ OpenSSL error: %1</source>
</translation> </translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="../gui/undocommands.cpp" line="385"/> <location filename="../gui/undocommands.cpp" line="387"/>
<source>removal of %1 entry/entries</source> <source>removal of %1 entry/entries</source>
<translation type="unfinished"> <translation type="unfinished">
<numerusform></numerusform> <numerusform></numerusform>
@ -804,7 +804,7 @@ OpenSSL error: %1</source>
</translation> </translation>
</message> </message>
<message numerus="yes"> <message numerus="yes">
<location filename="../gui/undocommands.cpp" line="415"/> <location filename="../gui/undocommands.cpp" line="418"/>
<source>move of %1 entry/entries</source> <source>move of %1 entry/entries</source>
<translation type="unfinished"> <translation type="unfinished">
<numerusform></numerusform> <numerusform></numerusform>