Commit dcfc617c authored by hjk's avatar hjk Committed by Eike Ziller

Core: Add streaming operators for Core::Id

Only used once so far, but makes intended usage clear.

Change-Id: Ia628f5356dd02282e233846268d6c0629e93e3fe
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent aefea10c
......@@ -1981,7 +1981,7 @@ QByteArray EditorManager::saveState() const
foreach (const OpenEditorsModel::Entry &entry, entries) {
if (!entry.editor || !entry.editor->isTemporary())
stream << entry.fileName() << entry.displayName() << entry.id().name();
stream << entry.fileName() << entry.displayName() << entry.id();
}
stream << d->m_splitter->saveState();
......@@ -2012,7 +2012,7 @@ bool EditorManager::restoreState(const QByteArray &state)
stream >> fileName;
QString displayName;
stream >> displayName;
QByteArray id;
Core::Id id;
stream >> id;
if (!fileName.isEmpty() && !displayName.isEmpty()) {
......@@ -2021,9 +2021,9 @@ bool EditorManager::restoreState(const QByteArray &state)
continue;
QFileInfo rfi(autoSaveName(fileName));
if (rfi.exists() && fi.lastModified() < rfi.lastModified())
openEditor(fileName, Id::fromName(id));
openEditor(fileName, id);
else
d->m_editorModel->addRestoredEditor(fileName, displayName, Id::fromName(id));
d->m_editorModel->addRestoredEditor(fileName, displayName, id);
}
}
......
......@@ -354,3 +354,21 @@ QString Id::suffixAfter(Id baseId) const
}
} // namespace Core
QT_BEGIN_NAMESPACE
QDataStream &operator<<(QDataStream &ds, const Core::Id &id)
{
return ds << id.name();
}
QDataStream &operator>>(QDataStream &ds, Core::Id &id)
{
QByteArray ba;
ds >> ba;
id = Core::Id::fromName(ba);
return ds;
}
QT_END_NAMESPACE
......@@ -86,4 +86,9 @@ inline uint qHash(const Id &id) { return id.uniqueIdentifier(); }
Q_DECLARE_METATYPE(Core::Id)
Q_DECLARE_METATYPE(QList<Core::Id>)
QT_BEGIN_NAMESPACE
QDataStream &operator<<(QDataStream &ds, const Core::Id &id);
QDataStream &operator>>(QDataStream &ds, Core::Id &id);
QT_END_NAMESPACE
#endif // CORE_ID_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment