feat(ProfileShowcase): Sync dirty state with the source model
Whenever the source model becomes identical to the showcase dirty model, the dirty flag is removed
This commit is contained in:
parent
204bfb30b6
commit
e7a1f5e831
|
@ -193,6 +193,7 @@ QtObject:
|
||||||
if rpcResponseObj{"error"}.kind != JNull and rpcResponseObj{"error"}.getStr != "":
|
if rpcResponseObj{"error"}.kind != JNull and rpcResponseObj{"error"}.getStr != "":
|
||||||
error "Error saving profile showcase preferences", msg = rpcResponseObj{"error"}
|
error "Error saving profile showcase preferences", msg = rpcResponseObj{"error"}
|
||||||
return
|
return
|
||||||
|
self.requestProfileShowcasePreferences()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error "Error saving profile showcase preferences", msg = e.msg
|
error "Error saving profile showcase preferences", msg = e.msg
|
||||||
|
|
||||||
|
|
|
@ -192,7 +192,7 @@ void WritableProxyModelPrivate::createProxyToSourceRowMap()
|
||||||
bool WritableProxyModelPrivate::contains(const QModelIndex& sourceIndex, const QVector<int>& roles) const {
|
bool WritableProxyModelPrivate::contains(const QModelIndex& sourceIndex, const QVector<int>& roles) const {
|
||||||
if (cache.contains(sourceIndex)) {
|
if (cache.contains(sourceIndex)) {
|
||||||
auto valueMap = cache[sourceIndex];
|
auto valueMap = cache[sourceIndex];
|
||||||
return std::all_of(roles.begin(), roles.end(), [&valueMap](int role) { return valueMap.contains(role); });
|
return std::any_of(roles.begin(), roles.end(), [&valueMap](int role) { return valueMap.contains(role); });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (insertedRows.contains(q.mapFromSource(sourceIndex))) {
|
if (insertedRows.contains(q.mapFromSource(sourceIndex))) {
|
||||||
|
@ -289,7 +289,7 @@ void WritableProxyModelPrivate::checkForDirtyRemoval(const QModelIndex& sourceIn
|
||||||
{
|
{
|
||||||
if (cachedData.contains(role) && cachedData[role] == q.sourceModel()->data(sourceIndex, role))
|
if (cachedData.contains(role) && cachedData[role] == q.sourceModel()->data(sourceIndex, role))
|
||||||
cachedData.remove(role);
|
cachedData.remove(role);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cachedData.isEmpty()) {
|
if (cachedData.isEmpty()) {
|
||||||
cache.remove(sourceIndex);
|
cache.remove(sourceIndex);
|
||||||
|
@ -605,7 +605,7 @@ bool WritableProxyModel::set(int at, const QVariantMap& data)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto index = this->index(at, 0);
|
auto index = this->index(at, 0);
|
||||||
auto itemData = this->itemData(index);
|
QMap<int, QVariant> itemData;
|
||||||
auto roleNames = this->roleNames();
|
auto roleNames = this->roleNames();
|
||||||
|
|
||||||
for (auto it = data.begin(); it != data.end(); ++it)
|
for (auto it = data.begin(); it != data.end(); ++it)
|
||||||
|
|
|
@ -36,7 +36,7 @@ QObject {
|
||||||
/**
|
/**
|
||||||
* Returns dirty state of the showcase model.
|
* Returns dirty state of the showcase model.
|
||||||
*/
|
*/
|
||||||
readonly property bool dirty: writable.dirty || !visibleModel.synced
|
readonly property bool dirty: writable.dirty
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It sets up a searcher filter on top of both the visible and hidden models.
|
* It sets up a searcher filter on top of both the visible and hidden models.
|
||||||
|
@ -49,9 +49,6 @@ QObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
function currentState() {
|
function currentState() {
|
||||||
if (visible.synced) {
|
|
||||||
return writable.currentState()
|
|
||||||
}
|
|
||||||
return writable.currentState()
|
return writable.currentState()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,18 +49,25 @@ WritableProxyModel {
|
||||||
return
|
return
|
||||||
|
|
||||||
// hiding, changing visibility level
|
// hiding, changing visibility level
|
||||||
if (visibility === visibilityHidden
|
if (visibility === visibilityHidden) {
|
||||||
|| oldVisibility !== visibilityHidden) {
|
set(sourceIdx, { showcaseVisibility: undefined, showcasePosition: undefined})
|
||||||
set(sourceIdx, { showcaseVisibility: visibility })
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// unhiding
|
if (oldVisibility === visibilityHidden || oldVisibility === undefined) {
|
||||||
const positions = d.getVisibleEntries().map(e => e.showcasePosition)
|
// unhiding
|
||||||
const position = Math.max(-1, ...positions) + 1
|
const positions = d.getVisibleEntries().map(e => e.showcasePosition)
|
||||||
set(sourceIdx, { showcaseVisibility: visibility, showcasePosition: position })
|
const position = Math.max(-1, ...positions) + 1
|
||||||
|
set(sourceIdx, { showcaseVisibility: visibility, showcasePosition: position })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// changing visibility level
|
||||||
|
set(sourceIdx, { showcaseVisibility: visibility })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
syncedRemovals: true
|
||||||
|
|
||||||
readonly property QtObject d_: QtObject {
|
readonly property QtObject d_: QtObject {
|
||||||
id: d
|
id: d
|
||||||
|
|
||||||
|
|
|
@ -166,7 +166,6 @@ SettingsContentBase {
|
||||||
profileHeader.cropRect.y.toFixed(),
|
profileHeader.cropRect.y.toFixed(),
|
||||||
(profileHeader.cropRect.x + profileHeader.cropRect.width).toFixed(),
|
(profileHeader.cropRect.x + profileHeader.cropRect.width).toFixed(),
|
||||||
(profileHeader.cropRect.y + profileHeader.cropRect.height).toFixed())
|
(profileHeader.cropRect.y + profileHeader.cropRect.height).toFixed())
|
||||||
reset()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue