mirror of
https://github.com/Murmele/Gittyup.git
synced 2024-09-11 10:45:39 +03:00
Update DiffTreeModel.cpp and DiffTreeModel.h
This commit is contained in:
parent
627f73d9fd
commit
0e0b78c618
@ -21,6 +21,15 @@ namespace {
|
||||
|
||||
const QString kLinkFmt = "<a href='%1'>%2</a>";
|
||||
|
||||
class Lock {
|
||||
public:
|
||||
Lock(bool &var) : mVar(var) { var = true; }
|
||||
~Lock() { mVar = false; }
|
||||
|
||||
private:
|
||||
bool &mVar;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
DiffTreeModel::DiffTreeModel(const git::Repository &repo, QObject *parent)
|
||||
@ -51,6 +60,8 @@ void DiffTreeModel::setDiff(const git::Diff &diff) {
|
||||
}
|
||||
|
||||
void DiffTreeModel::refresh(const QStringList &paths) {
|
||||
if (suppressRefresh)
|
||||
return;
|
||||
for (auto path : paths) {
|
||||
auto index = this->index(path);
|
||||
emit dataChanged(index, index, {Qt::CheckStateRole});
|
||||
@ -305,6 +316,8 @@ bool DiffTreeModel::discard(const QModelIndex &index) {
|
||||
|
||||
bool DiffTreeModel::setData(const QModelIndex &index, const QVariant &value,
|
||||
int role, bool ignoreIndexChanges) {
|
||||
|
||||
Lock l(suppressRefresh);
|
||||
switch (role) {
|
||||
case Qt::CheckStateRole: {
|
||||
QStringList files;
|
||||
|
@ -162,6 +162,7 @@ private:
|
||||
git::Repository mRepo;
|
||||
|
||||
bool mListView = false;
|
||||
bool suppressRefresh{false};
|
||||
};
|
||||
|
||||
#endif /* DIFFTREEMODEL */
|
||||
|
Loading…
Reference in New Issue
Block a user