Changeset View
Changeset View
Standalone View
Standalone View
svn/fileviewsvnplugin.cpp
Show First 20 Lines • Show All 220 Lines • ▼ Show 20 Line(s) | |||||
221 | 221 | | |||
222 | KVersionControlPlugin::ItemVersion FileViewSvnPlugin::itemVersion(const KFileItem& item) const | 222 | KVersionControlPlugin::ItemVersion FileViewSvnPlugin::itemVersion(const KFileItem& item) const | ||
223 | { | 223 | { | ||
224 | const QString itemUrl = item.localPath(); | 224 | const QString itemUrl = item.localPath(); | ||
225 | if (m_versionInfoHash.contains(itemUrl)) { | 225 | if (m_versionInfoHash.contains(itemUrl)) { | ||
226 | return m_versionInfoHash.value(itemUrl); | 226 | return m_versionInfoHash.value(itemUrl); | ||
227 | } | 227 | } | ||
228 | 228 | | |||
229 | // If parent directory is unversioned item itself is unversioned. | ||||
230 | if (isInUnversionedDir(item)) { | ||||
231 | return UnversionedVersion; | ||||
232 | } | ||||
233 | | ||||
229 | if (!item.isDir()) { | 234 | if (!item.isDir()) { | ||
230 | // files that have not been listed by 'svn status' (= m_versionInfoHash) | 235 | // files that have not been listed by 'svn status' (= m_versionInfoHash) | ||
231 | // are under version control per definition | 236 | // are under version control per definition | ||
232 | // NOTE: svn status does not report files in unversioned paths | 237 | // NOTE: svn status does not report files in unversioned paths | ||
233 | const QString path = QFileInfo(itemUrl).path(); | 238 | const QString path = QFileInfo(itemUrl).path(); | ||
234 | return m_versionInfoHash.value(path, NormalVersion); | 239 | return m_versionInfoHash.value(path, NormalVersion); | ||
235 | } | 240 | } | ||
236 | 241 | | |||
Show All 12 Lines | 247 | while (it != m_versionInfoHash.constEnd()) { | |||
249 | ++it; | 254 | ++it; | ||
250 | } | 255 | } | ||
251 | 256 | | |||
252 | return NormalVersion; | 257 | return NormalVersion; | ||
253 | } | 258 | } | ||
254 | 259 | | |||
255 | QList<QAction*> FileViewSvnPlugin::actions(const KFileItemList& items) const | 260 | QList<QAction*> FileViewSvnPlugin::actions(const KFileItemList& items) const | ||
256 | { | 261 | { | ||
262 | // Special case: if any item is in unversioned directory we shouldn't add any actions because | ||||
263 | // we can do nothing with this item. | ||||
264 | for (const auto &i : items) { | ||||
meven: items is already const, not need for `qAsConst` here | |||||
265 | if (isInUnversionedDir(i)) { | ||||
266 | return {}; | ||||
267 | } | ||||
268 | } | ||||
269 | | ||||
257 | if (items.count() == 1 && items.first().isDir()) { | 270 | if (items.count() == 1 && items.first().isDir()) { | ||
258 | return directoryActions(items.first()); | 271 | return directoryActions(items.first()); | ||
259 | } | 272 | } | ||
260 | 273 | | |||
261 | foreach (const KFileItem& item, items) { | 274 | foreach (const KFileItem& item, items) { | ||
262 | m_contextItems.append(item); | 275 | m_contextItems.append(item); | ||
263 | } | 276 | } | ||
264 | m_contextDir.clear(); | 277 | m_contextDir.clear(); | ||
▲ Show 20 Lines • Show All 386 Lines • ▼ Show 20 Line(s) | 635 | { | |||
651 | actions.append(m_showUpdatesAction); | 664 | actions.append(m_showUpdatesAction); | ||
652 | actions.append(m_addAction); | 665 | actions.append(m_addAction); | ||
653 | actions.append(m_removeAction); | 666 | actions.append(m_removeAction); | ||
654 | actions.append(m_revertAction); | 667 | actions.append(m_revertAction); | ||
655 | actions.append(m_logAction); | 668 | actions.append(m_logAction); | ||
656 | return actions; | 669 | return actions; | ||
657 | } | 670 | } | ||
658 | 671 | | |||
672 | bool FileViewSvnPlugin::isInUnversionedDir(const KFileItem& item) const | ||||
673 | { | ||||
674 | const QString itemPath = item.localPath(); | ||||
675 | | ||||
676 | for (auto it = m_versionInfoHash.cbegin(); it != m_versionInfoHash.cend(); ++it) { | ||||
elvisangelaccio: Please move this declaration inside the `for` | |||||
677 | // Add QDir::separator() to m_versionInfoHash entry to ensure this is a directory. | ||||
678 | if (it.value() == UnversionedVersion && itemPath.startsWith(it.key() + QDir::separator())) { | ||||
679 | return true; | ||||
elvisangelaccio: Code style: remove space after ( and before ) | |||||
680 | } | ||||
681 | } | ||||
682 | | ||||
683 | return false; | ||||
684 | } | ||||
685 | | ||||
659 | #include "fileviewsvnplugin.moc" | 686 | #include "fileviewsvnplugin.moc" |
items is already const, not need for qAsConst here