update// improved addressbook performance
This commit is contained in:
@@ -373,35 +373,38 @@ void AddressBook::readFromStorage()
|
|||||||
in >> version;
|
in >> version;
|
||||||
qDebug() << "Detected old addressbook format";
|
qDebug() << "Detected old addressbook format";
|
||||||
// Convert old addressbook format v1 to v2
|
// Convert old addressbook format v1 to v2
|
||||||
QList<QList<QString>> stuff;
|
if(in.status() == QDataStream::ReadCorruptData)
|
||||||
in >> stuff;
|
|
||||||
//qDebug() << "Stuff: " << stuff;
|
|
||||||
for (int i=0; i < stuff.size(); i++)
|
|
||||||
{
|
{
|
||||||
//qDebug() << "0:" << stuff[i][0];
|
qDebug() << "Error reading contacts! ---> Your hush contacts from disk maybe corrupted";
|
||||||
//qDebug() << "1:" << stuff[i][1];
|
QString filepath = QFileInfo(AddressBook::writeableFile()).absolutePath() + QString("/");
|
||||||
//qDebug() << "2:" << stuff[i][2];
|
QFile::rename(filepath + QString("addresslabels.dat"), filepath + QString("addresslabels.dat-corrupted"));
|
||||||
ContactItem contact = ContactItem(stuff[i][0],stuff[i][1], stuff[i][2], stuff[i][3],stuff[i][4]);
|
QMessageBox::critical(
|
||||||
//qDebug() << "contact=" << contact.toQTString();
|
nullptr,
|
||||||
allLabels.push_back(contact);
|
QObject::tr("Error reading contacts!"),
|
||||||
|
QObject::tr("Your hush contacts from disk maybe corrupted"),
|
||||||
|
QMessageBox::Ok
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug() << "Read " << version << " Hush contacts from disk...";
|
||||||
|
QList<QList<QString>> stuff;
|
||||||
|
in >> stuff;
|
||||||
|
for (int i=0; i < stuff.size(); i++)
|
||||||
|
{
|
||||||
|
ContactItem contact = ContactItem(stuff[i][0],stuff[i][1], stuff[i][2], stuff[i][3],stuff[i][4]);
|
||||||
|
allLabels.push_back(contact);
|
||||||
|
}
|
||||||
|
|
||||||
qDebug() << "Read " << version << " Hush contacts from disk...";
|
qDebug() << "Hush contacts readed from disk...";
|
||||||
|
}
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug() << "No Hush contacts found on disk!";
|
qDebug() << "No Hush contacts found on disk!";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special.
|
|
||||||
// Add the default silentdragon donation address if it isn't already present
|
|
||||||
// QList<QString> allAddresses;
|
|
||||||
// std::transform(allLabels.begin(), allLabels.end(),
|
|
||||||
// std::back_inserter(allAddresses), [=] (auto i) { return i.getPartnerAddress(); });
|
|
||||||
// if (!allAddresses.contains(Settings::getDonationAddr(true))) {
|
|
||||||
// allLabels.append(QPair<QString, QString>("silentdragon donation", Settings::getDonationAddr(true)));
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddressBook::writeToStorage()
|
void AddressBook::writeToStorage()
|
||||||
|
|||||||
Reference in New Issue
Block a user