mirror of
https://invent.kde.org/system/dolphin
synced 2024-11-05 18:47:12 +00:00
Assure that the revision control observer receives the correct revision states of subtree-items.
svn path=/trunk/KDE/kdebase/apps/; revision=1005646
This commit is contained in:
parent
34b6b30050
commit
0706af30c0
3 changed files with 36 additions and 24 deletions
|
@ -63,7 +63,7 @@ void DolphinFileItemDelegate::paint(QPainter* painter,
|
||||||
// The currently shown items are under revision control. Show the current revision
|
// The currently shown items are under revision control. Show the current revision
|
||||||
// state by adding an emblem.
|
// state by adding an emblem.
|
||||||
const QModelIndex dirIndex = proxyModel->mapToSource(index);
|
const QModelIndex dirIndex = proxyModel->mapToSource(index);
|
||||||
const QModelIndex revisionIndex = dolphinModel->index(dirIndex.row(), DolphinModel::Revision);
|
const QModelIndex revisionIndex = dolphinModel->index(dirIndex.row(), DolphinModel::Revision, dirIndex.parent());
|
||||||
const QVariant data = dolphinModel->data(revisionIndex, Qt::DecorationRole);
|
const QVariant data = dolphinModel->data(revisionIndex, Qt::DecorationRole);
|
||||||
const RevisionControlPlugin::RevisionState state = static_cast<RevisionControlPlugin::RevisionState>(data.toInt());
|
const RevisionControlPlugin::RevisionState state = static_cast<RevisionControlPlugin::RevisionState>(data.toInt());
|
||||||
|
|
||||||
|
|
|
@ -73,9 +73,12 @@ void UpdateItemStatesThread::run()
|
||||||
{
|
{
|
||||||
Q_ASSERT(!m_itemStates.isEmpty());
|
Q_ASSERT(!m_itemStates.isEmpty());
|
||||||
Q_ASSERT(m_plugin != 0);
|
Q_ASSERT(m_plugin != 0);
|
||||||
|
|
||||||
// it is assumed that all items have the same parent directory
|
// The items from m_itemStates may be located in different directory levels. The revision
|
||||||
const QString directory = m_itemStates.first().item.url().directory(KUrl::AppendTrailingSlash);
|
// plugin requires the root directory for RevisionControlPlugin::beginRetrieval(). Instead
|
||||||
|
// of doing an expensive search, we utilize the knowledge of the implementation of
|
||||||
|
// RevisionControlObserver::addDirectory() to be sure that the last item contains the root.
|
||||||
|
const QString directory = m_itemStates.last().item.url().directory(KUrl::AppendTrailingSlash);
|
||||||
|
|
||||||
QMutexLocker locker(m_pluginMutex);
|
QMutexLocker locker(m_pluginMutex);
|
||||||
m_retrievedItems = false;
|
m_retrievedItems = false;
|
||||||
|
@ -293,22 +296,9 @@ void RevisionControlObserver::updateItemStates()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int rowCount = m_dolphinModel->rowCount();
|
QList<ItemState> itemStates;
|
||||||
if (rowCount > 0) {
|
addDirectory(QModelIndex(), itemStates);
|
||||||
// Build a list of all items in the current directory and delegate
|
if (!itemStates.isEmpty()) {
|
||||||
// this list to the thread, which adjusts the revision states.
|
|
||||||
QList<ItemState> itemStates;
|
|
||||||
for (int row = 0; row < rowCount; ++row) {
|
|
||||||
const QModelIndex index = m_dolphinModel->index(row, DolphinModel::Revision);
|
|
||||||
|
|
||||||
ItemState itemState;
|
|
||||||
itemState.index = index;
|
|
||||||
itemState.item = m_dolphinModel->itemForIndex(index);
|
|
||||||
itemState.revision = RevisionControlPlugin::UnversionedRevision;
|
|
||||||
|
|
||||||
itemStates.append(itemState);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!m_silentUpdate) {
|
if (!m_silentUpdate) {
|
||||||
emit infoMessage(i18nc("@info:status", "Updating revision information..."));
|
emit infoMessage(i18nc("@info:status", "Updating revision information..."));
|
||||||
}
|
}
|
||||||
|
@ -317,4 +307,20 @@ void RevisionControlObserver::updateItemStates()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RevisionControlObserver::addDirectory(const QModelIndex& parentIndex, QList<ItemState>& itemStates)
|
||||||
|
{
|
||||||
|
const int rowCount = m_dolphinModel->rowCount(parentIndex);
|
||||||
|
for (int row = 0; row < rowCount; ++row) {
|
||||||
|
const QModelIndex index = m_dolphinModel->index(row, DolphinModel::Revision, parentIndex);
|
||||||
|
addDirectory(index, itemStates);
|
||||||
|
|
||||||
|
ItemState itemState;
|
||||||
|
itemState.index = index;
|
||||||
|
itemState.item = m_dolphinModel->itemForIndex(index);
|
||||||
|
itemState.revision = RevisionControlPlugin::UnversionedRevision;
|
||||||
|
|
||||||
|
itemStates.append(itemState);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#include "revisioncontrolobserver.moc"
|
#include "revisioncontrolobserver.moc"
|
||||||
|
|
|
@ -95,9 +95,6 @@ private slots:
|
||||||
void verifyDirectory();
|
void verifyDirectory();
|
||||||
void applyUpdatedItemStates();
|
void applyUpdatedItemStates();
|
||||||
|
|
||||||
private:
|
|
||||||
void updateItemStates();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct ItemState
|
struct ItemState
|
||||||
{
|
{
|
||||||
|
@ -105,7 +102,16 @@ private:
|
||||||
KFileItem item;
|
KFileItem item;
|
||||||
RevisionControlPlugin::RevisionState revision;
|
RevisionControlPlugin::RevisionState revision;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void updateItemStates();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds recursively all items from the directory \p parentIndex into
|
||||||
|
* the list \p itemStates.
|
||||||
|
*/
|
||||||
|
void addDirectory(const QModelIndex& parentIndex, QList<ItemState>& itemStates);
|
||||||
|
|
||||||
|
private:
|
||||||
bool m_pendingItemStatesUpdate;
|
bool m_pendingItemStatesUpdate;
|
||||||
bool m_revisionedDirectory;
|
bool m_revisionedDirectory;
|
||||||
bool m_silentUpdate; // if true, no messages will be send during the update
|
bool m_silentUpdate; // if true, no messages will be send during the update
|
||||||
|
|
Loading…
Reference in a new issue