Added tag and branch list to workspace view
FossilOrigin-Name: 304f9bd6c61babe7abc522c1a1301fe3f1887505
This commit is contained in:
@ -417,6 +417,63 @@ bool Fossil::stashDiff(const QString& name)
|
||||
return runFossil(QStringList() << "stash" << "diff" << name, 0);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool Fossil::tagList(QStringList& tags)
|
||||
{
|
||||
tags.clear();
|
||||
QStringList res;
|
||||
|
||||
if(!runFossil(QStringList() << "tag" << "ls", &res, RUNFLAGS_SILENT_ALL))
|
||||
return false;
|
||||
|
||||
foreach(const QString &line, res)
|
||||
{
|
||||
QString tag = line.trimmed();
|
||||
|
||||
if(tag.isEmpty())
|
||||
continue;
|
||||
tags.append(tag);
|
||||
}
|
||||
tags.sort();
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool Fossil::branchList(QStringList& branches, QStringList& activeBranches)
|
||||
{
|
||||
branches.clear();
|
||||
activeBranches.clear();
|
||||
QStringList res;
|
||||
|
||||
if(!runFossil(QStringList() << "branch" , &res, RUNFLAGS_SILENT_ALL))
|
||||
return false;
|
||||
|
||||
foreach(const QString &line, res)
|
||||
{
|
||||
QString name = line.trimmed();
|
||||
|
||||
if(name.isEmpty())
|
||||
continue;
|
||||
|
||||
// Active branches start with a start
|
||||
int active_index = name.indexOf('*');
|
||||
bool is_active = (active_index != -1) && active_index==0;
|
||||
|
||||
// Strip
|
||||
if(is_active)
|
||||
{
|
||||
name = name.mid(is_active+1).trimmed();
|
||||
activeBranches.append(name);
|
||||
}
|
||||
else
|
||||
branches.append(name);
|
||||
}
|
||||
|
||||
branches.sort();
|
||||
activeBranches.sort();
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static QString ParseFossilQuery(QString line)
|
||||
{
|
||||
|
@ -110,6 +110,9 @@ public:
|
||||
|
||||
void abortOperation() { operationAborted = true; }
|
||||
|
||||
bool tagList(QStringList& tags);
|
||||
bool branchList(QStringList& branches, QStringList& activeBranches);
|
||||
|
||||
private:
|
||||
void log(const QString &text, bool isHTML=false)
|
||||
{
|
||||
|
@ -669,33 +669,49 @@ void MainWindow::updateDirView()
|
||||
}
|
||||
}
|
||||
|
||||
// Branches
|
||||
QStandardItem *branches = new QStandardItem(QIcon(":icons/icons/Document Organization Chart-01.png"), "Branches");
|
||||
branches->setData(TreeViewItem(TreeViewItem::TYPE_BRANCHES, ""), REPODIRMODEL_ROLE_PATH);
|
||||
branches->setEditable(false);
|
||||
getWorkspace().getDirModel().appendRow(branches);
|
||||
foreach(const QString &branch_name, getWorkspace().getBranches())
|
||||
{
|
||||
QStandardItem *branch = new QStandardItem(QIcon(":icons/icons/Document Organization Chart-01.png"), branch_name);
|
||||
branch->setData(TreeViewItem(TreeViewItem::TYPE_BRANCH, branch_name), REPODIRMODEL_ROLE_PATH);
|
||||
branches->appendRow(branch);
|
||||
}
|
||||
|
||||
// Tags
|
||||
QStandardItem *tags = new QStandardItem(QIcon(":icons/icons/Book-01.png"), "Tags");
|
||||
tags->setData(TreeViewItem(TreeViewItem::TYPE_TAGS, ""), REPODIRMODEL_ROLE_PATH);
|
||||
tags->setEditable(false);
|
||||
getWorkspace().getDirModel().appendRow(tags);
|
||||
foreach(const QString &tag_name, getWorkspace().getTags())
|
||||
{
|
||||
QStandardItem *tag = new QStandardItem(QIcon(":icons/icons/Book-01.png"), tag_name);
|
||||
tag->setData(TreeViewItem(TreeViewItem::TYPE_TAG, tag_name), REPODIRMODEL_ROLE_PATH);
|
||||
tags->appendRow(tag);
|
||||
}
|
||||
|
||||
// Stashes
|
||||
QStandardItem *stashes = new QStandardItem(QIcon(":icons/icons/My Documents-01.png"), "Stashes");
|
||||
stashes->setData(TreeViewItem(TreeViewItem::TYPE_STASHES, ""), REPODIRMODEL_ROLE_PATH);
|
||||
stashes->setEditable(false);
|
||||
getWorkspace().getDirModel().appendRow(stashes);
|
||||
for(stashmap_t::const_iterator it= getWorkspace().getStashes().begin(); it!=getWorkspace().getStashes().end(); ++it)
|
||||
{
|
||||
QStandardItem *stash = new QStandardItem(QIcon(":icons/icons/Folder-01.png"), it.key());
|
||||
QStandardItem *stash = new QStandardItem(QIcon(":icons/icons/My Documents-01.png"), it.key());
|
||||
stash->setData(TreeViewItem(TreeViewItem::TYPE_STASH, it.value()), REPODIRMODEL_ROLE_PATH);
|
||||
stashes->appendRow(stash);
|
||||
}
|
||||
|
||||
|
||||
QStandardItem *tags = new QStandardItem(QIcon(":icons/icons/Book-01.png"), "Tags");
|
||||
tags->setData(TreeViewItem(TreeViewItem::TYPE_TAGS, ""), REPODIRMODEL_ROLE_PATH);
|
||||
tags->setEditable(false);
|
||||
getWorkspace().getDirModel().appendRow(tags);
|
||||
|
||||
// Remotes
|
||||
QStandardItem *remotes = new QStandardItem(QIcon(":icons/icons/Network PC-01.png"), "Remotes");
|
||||
remotes->setData(TreeViewItem(TreeViewItem::TYPE_REMOTES, ""), REPODIRMODEL_ROLE_PATH);
|
||||
remotes->setEditable(false);
|
||||
getWorkspace().getDirModel().appendRow(remotes);
|
||||
|
||||
// Settings
|
||||
QStandardItem *settings = new QStandardItem(QIcon(":icons/icons/Gear-01.png"), "Settings");
|
||||
settings->setData(TreeViewItem(TreeViewItem::TYPE_SETTINGS, ""), REPODIRMODEL_ROLE_PATH);
|
||||
settings->setEditable(false);
|
||||
|
@ -186,6 +186,15 @@ void Workspace::scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModifie
|
||||
|
||||
// Load the stash
|
||||
fossil().stashList(getStashes());
|
||||
|
||||
fossil().branchList(branchList, branchList);
|
||||
|
||||
fossil().tagList(tagList);
|
||||
// Fossil includes the branches in the tag list
|
||||
// So remove them
|
||||
foreach(const QString &name, branchList)
|
||||
tagList.removeAll(name);
|
||||
|
||||
_done:
|
||||
uiCallback.endProcess();
|
||||
}
|
||||
|
@ -120,12 +120,16 @@ public:
|
||||
filemap_t &getFiles() { return workspaceFiles; }
|
||||
stringset_t &getPaths() { return pathSet; }
|
||||
stashmap_t &getStashes() { return stashMap; }
|
||||
QStringList &getTags() { return tagList; }
|
||||
QStringList &getBranches() { return branchList; }
|
||||
|
||||
private:
|
||||
Fossil bridge;
|
||||
filemap_t workspaceFiles;
|
||||
stringset_t pathSet;
|
||||
stashmap_t stashMap;
|
||||
QStringList branchList;
|
||||
QStringList tagList;
|
||||
|
||||
QStandardItemModel repoFileModel;
|
||||
QStandardItemModel repoDirModel;
|
||||
|
Reference in New Issue
Block a user