Fuel

Diff
Login

Differences From Artifact [4cbfa1fdf3]:

To Artifact [717ccd4c91]:


15
16
17
18
19
20
21

22
23
24
25
26
27
28
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29







+







#include "SettingsDialog.h"
#include "FslSettingsDialog.h"
#include "SearchBox.h"
#include "CommitDialog.h"
#include "FileActionDialog.h"
#include "CloneDialog.h"
#include "RevisionDialog.h"
#include "RemoteDialog.h"
#include "Utils.h"

#define REVISION_LATEST "Latest revision"

//-----------------------------------------------------------------------------
enum
{
54
55
56
57
58
59
60
61

62
63
64
65
66
67
68
55
56
57
58
59
60
61

62
63
64
65
66
67
68
69







-
+







		TYPE_STASHES,
		TYPE_STASH,
		TYPE_BRANCHES,
		TYPE_BRANCH,
		TYPE_TAGS,
		TYPE_TAG,
		TYPE_REMOTES,
		TYPE_SETTINGS
		TYPE_REMOTE,
	};

	WorkspaceItem()
	: Type(TYPE_UNKNOWN)
	{
	}

170
171
172
173
174
175
176




177
178
179
180
181
182
183
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188







+
+
+
+







	// BranchesMenu
	menuBranches = new QMenu(this);
	menuBranches->addAction(ui->actionCreateBranch);
	menuBranches->addAction(separator);
	menuBranches->addAction(ui->actionMergeBranch);
	menuBranches->addAction(ui->actionUpdate);

	// RemotesMenu
	menuRemotes = new QMenu(this);
	menuRemotes->addAction(ui->actionEditRemote);

	// Recent Workspaces
	// Locate a sequence of two separator actions in file menu
	QList<QAction*> file_actions = ui->menuFile->actions();
	QAction *recent_sep=0;
	for(int i=0; i<file_actions.size(); ++i)
	{
		QAction *act = file_actions[i];
796
797
798
799
800
801
802
803

804
805
806
807
808
809
810

811
812
813
814
815
816






817
818
819
820
821
822
823
801
802
803
804
805
806
807

808
809
810
811
812
813


814






815
816
817
818
819
820
821
822
823
824
825
826
827







-
+





-
-
+
-
-
-
-
-
-
+
+
+
+
+
+







	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);
	}

#if 0
#if 1
	// 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);
#endif

	{
#if 0 // Unimplemented for now
	// Settings
	QStandardItem *settings = new QStandardItem(getInternalIcon(":icons/icon-action-settings"), tr("Settings"));
	settings->setData(WorkspaceItem(WorkspaceItem::TYPE_SETTINGS, ""), ROLE_WORKSPACE_ITEM);
	settings->setEditable(false);
	getWorkspace().getTreeModel().appendRow(settings);
		QStandardItem *default_url = new QStandardItem(getInternalIcon(":icons/icon-item-remote"), tr("Default"));
		QString url = settings.GetFossilValue(FOSSIL_SETTING_REMOTE_URL).toString();
		default_url->setData(WorkspaceItem(WorkspaceItem::TYPE_REMOTE, url), ROLE_WORKSPACE_ITEM);
		remotes->appendRow(default_url);
	}

#endif

	// Expand previously selected nodes
	name_map.clear();
	BuildNameToModelIndex(name_map, getWorkspace().getTreeModel());

	for(stringset_t::const_iterator it=expanded_items.begin(); it!=expanded_items.end(); ++it)
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238




















1239
1240
1241
1242
1243
1244
1245
1233
1234
1235
1236
1237
1238
1239



1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266







-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+








		if(tv.Type != WorkspaceItem::TYPE_STASH)
			continue;

		QString name = mi.model()->data(mi, Qt::DisplayRole).toString();
		stashNames.append(name);
	}

}

}

//------------------------------------------------------------------------------
void MainWindow::getSelectionRemotes(QStringList &remoteUrls)
{
	QModelIndexList selection = ui->workspaceTreeView->selectionModel()->selectedIndexes();

	foreach(const QModelIndex &mi, selection)
	{
		QVariant data = mi.model()->data(mi, ROLE_WORKSPACE_ITEM);
		Q_ASSERT(data.isValid());
		WorkspaceItem tv = data.value<WorkspaceItem>();

		if(tv.Type != WorkspaceItem::TYPE_REMOTE)
			continue;

		QString url = tv.Value;
		remoteUrls.append(url);
	}
}
//------------------------------------------------------------------------------
bool MainWindow::diffFile(const QString &repoFile)
{
	return fossil().diffFile(repoFile);
}

//------------------------------------------------------------------------------
2183
2184
2185
2186
2187
2188
2189


2190
2191
2192
2193
2194
2195
2196
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219







+
+







		menu = menuWorkspace;
	else if (tv.Type == WorkspaceItem::TYPE_STASH || tv.Type == WorkspaceItem::TYPE_STASHES)
		menu = menuStashes;
	else if (tv.Type == WorkspaceItem::TYPE_TAG || tv.Type == WorkspaceItem::TYPE_TAGS)
		menu = menuTags;
	else if (tv.Type == WorkspaceItem::TYPE_BRANCH || tv.Type == WorkspaceItem::TYPE_BRANCHES)
		menu = menuBranches;
	else if (tv.Type == WorkspaceItem::TYPE_REMOTE)
		menu = menuRemotes;

	if(menu)
	{
		QPoint pos = QCursor::pos() + QPoint(1, 1);
		menu->popup(pos);
	}
}
2473
2474
2475
2476
2477
2478
2479














2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516







+
+
+
+
+
+
+
+
+
+
+
+
+
+
//------------------------------------------------------------------------------
void MainWindow::onSearch()
{
	searchBox->selectAll();
	searchBox->setFocus();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionEditRemote_triggered()
{
	QStringList remotes;
	getSelectionRemotes(remotes);

	if(remotes.empty())
		return;

	QUrl url(remotes.first());

	if(!RemoteDialog::run(this, url))
		return;
}