Browse Source

rename old addrbook to .bak and create a new one #109

pull/130/head
DenioD 4 years ago
parent
commit
92e20e1c98
  1. 14
      src/addressbook.cpp

14
src/addressbook.cpp

@ -398,7 +398,16 @@ void AddressBook::readFromStorage()
QList<QList<QString>> stuff; QList<QList<QString>> stuff;
in >> stuff; in >> stuff;
//////////////found old addrbook, and rename it to .bak
if (version != "v2")
{
auto filename = QStringLiteral("addresslabels.dat");
auto dir = QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
QFile address(dir.filePath(filename));
address.rename(dir.filePath("addresslabels.bak"));
}else{
for (int i=0; i < stuff.size(); i++) for (int i=0; i < stuff.size(); i++)
{ {
@ -406,6 +415,7 @@ void AddressBook::readFromStorage()
allLabels.push_back(contact); allLabels.push_back(contact);
} }
}
// qDebug() << "Read " << version << " Hush contacts from disk..."; // qDebug() << "Read " << version << " Hush contacts from disk...";
@ -448,7 +458,7 @@ void AddressBook::writeToStorage()
c.push_back(item.getAvatar()); c.push_back(item.getAvatar());
contacts.push_back(c); contacts.push_back(c);
} }
out << QString("v1") << contacts; out << QString("v2") << contacts;
file.close(); file.close();
} }

Loading…
Cancel
Save