810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
|
if(selection.contains(mi))
selected_items.insert(it.key());
}
// Clear content except headers
getWorkspace().getTreeModel().removeRows(0, getWorkspace().getTreeModel().rowCount());
QStandardItem *workspace = new QStandardItem(getInternalIcon(":icons/icon-item-folder"), tr("Files") );
workspace->setData(WorkspaceItem(WorkspaceItem::TYPE_WORKSPACE, ""), ROLE_WORKSPACE_ITEM);
workspace->setEditable(false);
getWorkspace().getTreeModel().appendRow(workspace);
if(viewMode == VIEWMODE_TREE)
{
// FIXME: Change paths to map to allow for automatic sorting
QStringList paths = getWorkspace().getPaths().toList();
paths.sort();
foreach(const QString &dir, paths)
{
if(dir.isEmpty())
continue;
addPathToTree(*workspace, dir,
getInternalIcon(":icons/icon-item-folder"),
getInternalIcon(":icons/icon-item-folder-unchanged"),
getInternalIcon(":icons/icon-item-folder-modified"),
getInternalIcon(":icons/icon-item-folder-unknown"),
getWorkspace().getPathState());
}
// Expand root folder
ui->workspaceTreeView->setExpanded(workspace->index(), true);
}
// Branches
QStandardItem *branches = new QStandardItem(getInternalIcon(":icons/icon-item-branch"), tr("Branches"));
branches->setData(WorkspaceItem(WorkspaceItem::TYPE_BRANCHES, ""), ROLE_WORKSPACE_ITEM);
branches->setEditable(false);
getWorkspace().getTreeModel().appendRow(branches);
foreach(const QString &branch_name, getWorkspace().getBranches())
{
QStandardItem *branch = new QStandardItem(getInternalIcon(":icons/icon-item-branch"), branch_name);
branch->setData(WorkspaceItem(WorkspaceItem::TYPE_BRANCH, branch_name), ROLE_WORKSPACE_ITEM);
bool active = fossil().getCurrentTags().contains(branch_name);
if(active)
{
QFont font = branch->font();
font.setBold(true);
branch->setFont(font);
}
branches->appendRow(branch);
}
// Tags
QStandardItem *tags = new QStandardItem(getInternalIcon(":icons/icon-item-tag"), tr("Tags"));
tags->setData(WorkspaceItem(WorkspaceItem::TYPE_TAGS, ""), ROLE_WORKSPACE_ITEM);
tags->setEditable(false);
getWorkspace().getTreeModel().appendRow(tags);
for(QStringMap::const_iterator it=getWorkspace().getTags().begin(); it!=getWorkspace().getTags().end(); ++it)
{
const QString &tag_name = it.key();
QStandardItem *tag = new QStandardItem(getInternalIcon(":icons/icon-item-tag"), tag_name);
tag->setData(WorkspaceItem(WorkspaceItem::TYPE_TAG, tag_name), ROLE_WORKSPACE_ITEM);
bool active = fossil().getCurrentTags().contains(tag_name);
if(active)
{
QFont font = tag->font();
font.setBold(true);
tag->setFont(font);
}
tags->appendRow(tag);
}
// Stashes
QStandardItem *stashes = new QStandardItem(getInternalIcon(":icons/icon-action-repo-open"), tr("Stashes"));
stashes->setData(WorkspaceItem(WorkspaceItem::TYPE_STASHES, ""), ROLE_WORKSPACE_ITEM);
stashes->setEditable(false);
getWorkspace().getTreeModel().appendRow(stashes);
for(stashmap_t::const_iterator it= getWorkspace().getStashes().begin(); it!=getWorkspace().getStashes().end(); ++it)
{
QStandardItem *stash = new QStandardItem(getInternalIcon(":icons/icon-action-repo-open"), it.key());
stash->setData(WorkspaceItem(WorkspaceItem::TYPE_STASH, it.value()), ROLE_WORKSPACE_ITEM);
stashes->appendRow(stash);
}
// Remotes
QStandardItem *remotes = new QStandardItem(getInternalIcon(":icons/icon-item-remote"), tr("Remotes"));
remotes->setData(WorkspaceItem(WorkspaceItem::TYPE_REMOTES, ""), ROLE_WORKSPACE_ITEM);
remotes->setEditable(false);
getWorkspace().getTreeModel().appendRow(remotes);
for(remote_map_t::const_iterator it=getWorkspace().getRemotes().begin(); it!=getWorkspace().getRemotes().end(); ++it)
{
QStandardItem *remote_item = new QStandardItem(getInternalIcon(":icons/icon-item-remote"), it->name);
remote_item->setData(WorkspaceItem(WorkspaceItem::TYPE_REMOTE, it->url.toString()), ROLE_WORKSPACE_ITEM);
remote_item->setToolTip(UrlToStringDisplay(it->url));
// Mark the default url as bold
if(it->isDefault)
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
|
if(selection.contains(mi))
selected_items.insert(it.key());
}
// Clear content except headers
getWorkspace().getTreeModel().removeRows(0, getWorkspace().getTreeModel().rowCount());
QStandardItem *workspace = new QStandardItem(getCachedIcon(":icons/icon-item-folder"), tr("Files") );
workspace->setData(WorkspaceItem(WorkspaceItem::TYPE_WORKSPACE, ""), ROLE_WORKSPACE_ITEM);
workspace->setEditable(false);
getWorkspace().getTreeModel().appendRow(workspace);
if(viewMode == VIEWMODE_TREE)
{
// FIXME: Change paths to map to allow for automatic sorting
QStringList paths = getWorkspace().getPaths().toList();
paths.sort();
foreach(const QString &dir, paths)
{
if(dir.isEmpty())
continue;
addPathToTree(*workspace, dir,
getCachedIcon(":icons/icon-item-folder"),
getCachedIcon(":icons/icon-item-folder-unchanged"),
getCachedIcon(":icons/icon-item-folder-modified"),
getCachedIcon(":icons/icon-item-folder-unknown"),
getWorkspace().getPathState());
}
// Expand root folder
ui->workspaceTreeView->setExpanded(workspace->index(), true);
}
// Branches
QStandardItem *branches = new QStandardItem(getCachedIcon(":icons/icon-item-branch"), tr("Branches"));
branches->setData(WorkspaceItem(WorkspaceItem::TYPE_BRANCHES, ""), ROLE_WORKSPACE_ITEM);
branches->setEditable(false);
getWorkspace().getTreeModel().appendRow(branches);
foreach(const QString &branch_name, getWorkspace().getBranches())
{
QStandardItem *branch = new QStandardItem(getCachedIcon(":icons/icon-item-branch"), branch_name);
branch->setData(WorkspaceItem(WorkspaceItem::TYPE_BRANCH, branch_name), ROLE_WORKSPACE_ITEM);
bool active = fossil().getCurrentTags().contains(branch_name);
if(active)
{
QFont font = branch->font();
font.setBold(true);
branch->setFont(font);
}
branches->appendRow(branch);
}
// Tags
QStandardItem *tags = new QStandardItem(getCachedIcon(":icons/icon-item-tag"), tr("Tags"));
tags->setData(WorkspaceItem(WorkspaceItem::TYPE_TAGS, ""), ROLE_WORKSPACE_ITEM);
tags->setEditable(false);
getWorkspace().getTreeModel().appendRow(tags);
for(QStringMap::const_iterator it=getWorkspace().getTags().begin(); it!=getWorkspace().getTags().end(); ++it)
{
const QString &tag_name = it.key();
QStandardItem *tag = new QStandardItem(getCachedIcon(":icons/icon-item-tag"), tag_name);
tag->setData(WorkspaceItem(WorkspaceItem::TYPE_TAG, tag_name), ROLE_WORKSPACE_ITEM);
bool active = fossil().getCurrentTags().contains(tag_name);
if(active)
{
QFont font = tag->font();
font.setBold(true);
tag->setFont(font);
}
tags->appendRow(tag);
}
// Stashes
QStandardItem *stashes = new QStandardItem(getCachedIcon(":icons/icon-action-repo-open"), tr("Stashes"));
stashes->setData(WorkspaceItem(WorkspaceItem::TYPE_STASHES, ""), ROLE_WORKSPACE_ITEM);
stashes->setEditable(false);
getWorkspace().getTreeModel().appendRow(stashes);
for(stashmap_t::const_iterator it= getWorkspace().getStashes().begin(); it!=getWorkspace().getStashes().end(); ++it)
{
QStandardItem *stash = new QStandardItem(getCachedIcon(":icons/icon-action-repo-open"), it.key());
stash->setData(WorkspaceItem(WorkspaceItem::TYPE_STASH, it.value()), ROLE_WORKSPACE_ITEM);
stashes->appendRow(stash);
}
// Remotes
QStandardItem *remotes = new QStandardItem(getCachedIcon(":icons/icon-item-remote"), tr("Remotes"));
remotes->setData(WorkspaceItem(WorkspaceItem::TYPE_REMOTES, ""), ROLE_WORKSPACE_ITEM);
remotes->setEditable(false);
getWorkspace().getTreeModel().appendRow(remotes);
for(remote_map_t::const_iterator it=getWorkspace().getRemotes().begin(); it!=getWorkspace().getRemotes().end(); ++it)
{
QStandardItem *remote_item = new QStandardItem(getCachedIcon(":icons/icon-item-remote"), it->name);
remote_item->setData(WorkspaceItem(WorkspaceItem::TYPE_REMOTE, it->url.toString()), ROLE_WORKSPACE_ITEM);
remote_item->setToolTip(UrlToStringDisplay(it->url));
// Mark the default url as bold
if(it->isDefault)
{
|
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
|
{
status_text = &stats[t].text;
status_icon_path = stats[t].icon;
break;
}
}
QStandardItem *status = new QStandardItem(getInternalIcon(status_icon_path), *status_text);
status->setToolTip(*status_text);
getWorkspace().getFileModel().setItem(item_id, COLUMN_STATUS, status);
QFileInfo finfo = e.getFileInfo();
const QIcon *icon = &getInternalFileIcon(finfo);
QStandardItem *filename_item = 0;
getWorkspace().getFileModel().setItem(item_id, COLUMN_PATH, new QStandardItem(path));
if(display_path)
filename_item = new QStandardItem(*icon, native_file_path);
else
|
|
|
|
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
|
{
status_text = &stats[t].text;
status_icon_path = stats[t].icon;
break;
}
}
QStandardItem *status = new QStandardItem(getCachedIcon(status_icon_path), *status_text);
status->setToolTip(*status_text);
getWorkspace().getFileModel().setItem(item_id, COLUMN_STATUS, status);
QFileInfo finfo = e.getFileInfo();
const QIcon *icon = &getCachedFileIcon(finfo);
QStandardItem *filename_item = 0;
getWorkspace().getFileModel().setItem(item_id, COLUMN_PATH, new QStandardItem(path));
if(display_path)
filename_item = new QStandardItem(*icon, native_file_path);
else
|
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
|
//------------------------------------------------------------------------------
QMenu * MainWindow::createPopupMenu()
{
return NULL;
}
//------------------------------------------------------------------------------
const QIcon &MainWindow::getInternalIcon(const char* name)
{
if(!iconCache.contains(name))
iconCache.insert(name, QIcon(name));
return iconCache[name];
}
//------------------------------------------------------------------------------
const QIcon &MainWindow::getInternalFileIcon(const QFileInfo &finfo)
{
QString icon_type = iconProvider.type(finfo);
if(!iconCache.contains(icon_type))
iconCache.insert(icon_type, iconProvider.icon(finfo));
return iconCache[icon_type];
|
|
|
|
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
|
//------------------------------------------------------------------------------
QMenu * MainWindow::createPopupMenu()
{
return NULL;
}
//------------------------------------------------------------------------------
const QIcon &MainWindow::getCachedIcon(const char* name)
{
if(!iconCache.contains(name))
iconCache.insert(name, QIcon(name));
return iconCache[name];
}
//------------------------------------------------------------------------------
const QIcon &MainWindow::getCachedFileIcon(const QFileInfo &finfo)
{
QString icon_type = iconProvider.type(finfo);
if(!iconCache.contains(icon_type))
iconCache.insert(icon_type, iconProvider.icon(finfo));
return iconCache[icon_type];
|
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
|
continue;
// Attempt to extract an icon
QString cmd, extra_params;
SplitCommandLine(cust_act.Command, cmd, extra_params);
QFileInfo fi(cmd);
if(fi.isFile())
action->setIcon(getInternalFileIcon(fi));
if(cust_act.IsActive(ACTION_CONTEXT_FILES))
{
ui->fileTableView->addAction(action);
has_file_actions = true;
}
|
|
|
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
|
continue;
// Attempt to extract an icon
QString cmd, extra_params;
SplitCommandLine(cust_act.Command, cmd, extra_params);
QFileInfo fi(cmd);
if(fi.isFile())
action->setIcon(getCachedFileIcon(fi));
if(cust_act.IsActive(ACTION_CONTEXT_FILES))
{
ui->fileTableView->addAction(action);
has_file_actions = true;
}
|