forked from qt-creator/qt-creator
QmlDesigner: Improving SessionChangeSets
Task-number: QDS-2998 Change-Id: I9b559bf593dd968172649d1f6c45fb9fb454f1a5 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -151,6 +151,11 @@ void Database::applyAndUpdateSessions()
|
||||
m_statements->sessions.applyAndUpdateSessions();
|
||||
}
|
||||
|
||||
SessionChangeSets Database::changeSets() const
|
||||
{
|
||||
return m_statements->sessions.changeSets();
|
||||
}
|
||||
|
||||
const Utils::PathString &Database::databaseFilePath() const
|
||||
{
|
||||
return m_databaseFilePath;
|
||||
|
@@ -28,6 +28,7 @@
|
||||
#include "sqlitedatabasebackend.h"
|
||||
#include "sqlitedatabaseinterface.h"
|
||||
#include "sqliteglobal.h"
|
||||
#include "sqlitesessionchangeset.h"
|
||||
#include "sqlitetable.h"
|
||||
#include "sqlitetransaction.h"
|
||||
|
||||
@@ -131,6 +132,8 @@ public:
|
||||
void setAttachedTables(const Utils::SmallStringVector &tables) override;
|
||||
void applyAndUpdateSessions() override;
|
||||
|
||||
SessionChangeSets changeSets() const;
|
||||
|
||||
private:
|
||||
void deferredBegin() override;
|
||||
void immediateBegin() override;
|
||||
|
@@ -41,9 +41,10 @@ namespace Sqlite {
|
||||
|
||||
class Sessions;
|
||||
|
||||
namespace SessionChangeSetInternal {
|
||||
enum class Operation : char { Invalid, Insert, Update, Delete };
|
||||
|
||||
namespace SessionChangeSetInternal {
|
||||
|
||||
class SentinelIterator
|
||||
{};
|
||||
|
||||
@@ -54,7 +55,7 @@ public:
|
||||
ValueView oldValue;
|
||||
};
|
||||
|
||||
class ConstTupleIterator
|
||||
class SQLITE_EXPORT ConstTupleIterator
|
||||
{
|
||||
public:
|
||||
using difference_type = int;
|
||||
@@ -63,7 +64,9 @@ public:
|
||||
using reference = const ValueView &;
|
||||
using iterator_category = std::forward_iterator_tag;
|
||||
|
||||
ConstTupleIterator(sqlite3_changeset_iter *sessionIterator, int index, Operation operation)
|
||||
ConstTupleIterator(sqlite3_changeset_iter *sessionIterator,
|
||||
int index,
|
||||
Sqlite::Operation operation)
|
||||
: m_sessionIterator{sessionIterator}
|
||||
, m_column{index}
|
||||
, m_operation{operation}
|
||||
@@ -91,10 +94,10 @@ public:
|
||||
private:
|
||||
sqlite3_changeset_iter *m_sessionIterator = {};
|
||||
int m_column = 0;
|
||||
Operation m_operation = Operation::Invalid;
|
||||
Sqlite::Operation m_operation = Sqlite::Operation::Invalid;
|
||||
};
|
||||
|
||||
class Tuple
|
||||
class SQLITE_EXPORT Tuple
|
||||
{
|
||||
public:
|
||||
using difference_type = int;
|
||||
@@ -108,7 +111,7 @@ public:
|
||||
Utils::SmallStringView table;
|
||||
sqlite3_changeset_iter *sessionIterator = {};
|
||||
int columnCount = 0;
|
||||
Operation operation = Operation::Invalid;
|
||||
Sqlite::Operation operation = Sqlite::Operation::Invalid;
|
||||
|
||||
ValueViews operator[](int column) const;
|
||||
ConstTupleIterator begin() const { return {sessionIterator, 0, operation}; }
|
||||
@@ -117,7 +120,7 @@ public:
|
||||
|
||||
enum class State : char { Invalid, Row, Done };
|
||||
|
||||
class ConstIterator
|
||||
class SQLITE_EXPORT ConstIterator
|
||||
{
|
||||
public:
|
||||
using difference_type = long;
|
||||
|
@@ -415,6 +415,22 @@ std::ostream &operator<<(std::ostream &out, sqlite3_changeset_iter *iter)
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
const char *toText(Operation operation)
|
||||
{
|
||||
switch (operation) {
|
||||
case Operation::Invalid:
|
||||
return "Invalid";
|
||||
case Operation::Insert:
|
||||
return "Invalid";
|
||||
case Operation::Update:
|
||||
return "Invalid";
|
||||
case Operation::Delete:
|
||||
return "Invalid";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
} // namespace
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const SessionChangeSet &changeset)
|
||||
@@ -437,25 +453,14 @@ std::ostream &operator<<(std::ostream &out, const SessionChangeSet &changeset)
|
||||
return out;
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, Operation operation)
|
||||
{
|
||||
return out << toText(operation);
|
||||
}
|
||||
|
||||
namespace SessionChangeSetInternal {
|
||||
namespace {
|
||||
|
||||
const char *toText(Operation operation)
|
||||
{
|
||||
switch (operation) {
|
||||
case Operation::Invalid:
|
||||
return "Invalid";
|
||||
case Operation::Insert:
|
||||
return "Invalid";
|
||||
case Operation::Update:
|
||||
return "Invalid";
|
||||
case Operation::Delete:
|
||||
return "Invalid";
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
const char *toText(State state)
|
||||
{
|
||||
switch (state) {
|
||||
@@ -476,11 +481,6 @@ std::ostream &operator<<(std::ostream &out, SentinelIterator)
|
||||
return out << "sentinel";
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, Operation operation)
|
||||
{
|
||||
return out << toText(operation);
|
||||
}
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, State state)
|
||||
{
|
||||
return out << toText(state);
|
||||
|
@@ -68,24 +68,25 @@ namespace Sqlite {
|
||||
class Value;
|
||||
class ValueView;
|
||||
class SessionChangeSet;
|
||||
enum class Operation : char;
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, const Value &value);
|
||||
std::ostream &operator<<(std::ostream &out, const ValueView &value);
|
||||
std::ostream &operator<<(std::ostream &out, Operation operation);
|
||||
std::ostream &operator<<(std::ostream &out, const SessionChangeSet &changeset);
|
||||
|
||||
namespace SessionChangeSetInternal {
|
||||
class ConstIterator;
|
||||
class ConstTupleIterator;
|
||||
class SentinelIterator;
|
||||
class Tuple;
|
||||
class ValueViews;
|
||||
enum class Operation : char;
|
||||
enum class State : char;
|
||||
|
||||
std::ostream &operator<<(std::ostream &out, SentinelIterator iterator);
|
||||
std::ostream &operator<<(std::ostream &out, const ConstIterator &iterator);
|
||||
std::ostream &operator<<(std::ostream &out, const ConstTupleIterator &iterator);
|
||||
std::ostream &operator<<(std::ostream &out, const Tuple &tuple);
|
||||
std::ostream &operator<<(std::ostream &out, Operation operation);
|
||||
std::ostream &operator<<(std::ostream &out, State operation);
|
||||
std::ostream &operator<<(std::ostream &out, const ValueViews &valueViews);
|
||||
|
||||
|
@@ -36,9 +36,9 @@
|
||||
|
||||
namespace {
|
||||
|
||||
using Sqlite::Operation;
|
||||
using Sqlite::SessionChangeSet;
|
||||
using Sqlite::SessionChangeSets;
|
||||
using Sqlite::SessionChangeSetInternal::Operation;
|
||||
using Sqlite::SessionChangeSetInternal::ValueViews;
|
||||
|
||||
class DatabaseExecute
|
||||
|
Reference in New Issue
Block a user