pgLab/pglab/querytool/SqlDocumentRegistry.h
eelke 784ad68758 Show UnsavedDocumentsDialog when closing window or quitting application
so user can save and or discard docs more efficiently.
2026-10-19 18:16:25 +02:00

27 lines
736 B
C++

#ifndef SQLDOCUMENTREGISTRY_H
#define SQLDOCUMENTREGISTRY_H
#include <QList>
#include <memory>
#include <vector>
class SqlDocument;
/** Keeps track of all SQL documents that are still in use, without
* extending their lifetime. A document lives as long as at least one
* query tool holds a shared pointer to it.
*/
class SqlDocumentRegistry {
public:
void add(const std::shared_ptr<SqlDocument> &document);
/// All documents that are still alive.
QList<std::shared_ptr<SqlDocument>> documents() const;
/// All documents that are alive and have unsaved changes.
QList<std::shared_ptr<SqlDocument>> modifiedDocuments() const;
private:
std::vector<std::weak_ptr<SqlDocument>> m_documents;
};
#endif // SQLDOCUMENTREGISTRY_H