forked from qt-creator/qt-creator
Vcs: colorize file items in submit editor
It's an eye-candy feature "à la" Tortoise client Change-Id: I5f772f2d9b1278712aea690208b0b0d08de6a80a Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
@@ -278,7 +278,7 @@ BazaarClient::StatusItem BazaarClient::parseStatusLine(const QString &line) cons
|
||||
else if (flagVersion == QLatin1Char('-'))
|
||||
item.flags = QLatin1String("Unversioned");
|
||||
else if (flagVersion == QLatin1Char('R'))
|
||||
item.flags = QLatin1String("Renamed");
|
||||
item.flags = QLatin1String(Constants::FSTATUS_RENAMED);
|
||||
else if (flagVersion == QLatin1Char('?'))
|
||||
item.flags = QLatin1String("Unknown");
|
||||
else if (flagVersion == QLatin1Char('X'))
|
||||
@@ -292,13 +292,13 @@ BazaarClient::StatusItem BazaarClient::parseStatusLine(const QString &line) cons
|
||||
if (lineLength >= 2) {
|
||||
const QChar flagContents = line[1];
|
||||
if (flagContents == QLatin1Char('N'))
|
||||
item.flags = QLatin1String("Created");
|
||||
item.flags = QLatin1String(Constants::FSTATUS_CREATED);
|
||||
else if (flagContents == QLatin1Char('D'))
|
||||
item.flags = QLatin1String("Deleted");
|
||||
item.flags = QLatin1String(Constants::FSTATUS_DELETED);
|
||||
else if (flagContents == QLatin1Char('K'))
|
||||
item.flags = QLatin1String("KindChanged");
|
||||
else if (flagContents == QLatin1Char('M'))
|
||||
item.flags = QLatin1String("Modified");
|
||||
item.flags = QLatin1String(Constants::FSTATUS_MODIFIED);
|
||||
}
|
||||
if (lineLength >= 3) {
|
||||
const QChar flagExec = line[2];
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "commiteditor.h"
|
||||
#include "branchinfo.h"
|
||||
#include "bazaarcommitwidget.h"
|
||||
#include "constants.h"
|
||||
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <vcsbase/submitfilemodel.h>
|
||||
@@ -62,6 +63,18 @@ void CommitEditor::setFields(const QString &repositoryRoot,
|
||||
|
||||
m_fileModel = new VcsBase::SubmitFileModel(this);
|
||||
m_fileModel->setRepositoryRoot(repositoryRoot);
|
||||
m_fileModel->setFileStatusQualifier([](const QString &status, const QVariant &) {
|
||||
if (status == QLatin1String(Constants::FSTATUS_CREATED))
|
||||
return VcsBase::SubmitFileModel::FileAdded;
|
||||
if (status == QLatin1String(Constants::FSTATUS_MODIFIED))
|
||||
return VcsBase::SubmitFileModel::FileModified;
|
||||
if (status == QLatin1String(Constants::FSTATUS_DELETED))
|
||||
return VcsBase::SubmitFileModel::FileDeleted;
|
||||
if (status == QLatin1String(Constants::FSTATUS_RENAMED))
|
||||
return VcsBase::SubmitFileModel::FileRenamed;
|
||||
return VcsBase::SubmitFileModel::FileStatusUnknown;
|
||||
} );
|
||||
|
||||
foreach (const VcsBase::VcsBaseClient::StatusItem &item, repoStatus)
|
||||
if (item.flags != QLatin1String("Unknown"))
|
||||
m_fileModel->addFile(item.file, item.flags);
|
||||
|
||||
@@ -60,6 +60,12 @@ const char DIFFLOG_ID[] = "Bazaar Diff Editor";
|
||||
const char DIFFLOG_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "Bazaar Diff Editor");
|
||||
const char DIFFAPP[] = "text/x-patch";
|
||||
|
||||
// File status hint
|
||||
const char FSTATUS_CREATED[] = "Created";
|
||||
const char FSTATUS_DELETED[] = "Deleted";
|
||||
const char FSTATUS_MODIFIED[] = "Modified";
|
||||
const char FSTATUS_RENAMED[] = "Renamed";
|
||||
|
||||
} // namespace Constants
|
||||
} // namespace Bazaar
|
||||
|
||||
|
||||
Reference in New Issue
Block a user