Fuel

Diff
Login

Differences From Artifact [08e207cc8e]:

To Artifact [351608ee4b]:


281
282
283
284
285
286
287

288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
	rebuildRecent();
}

//------------------------------------------------------------------------------
MainWindow::~MainWindow()
{
	stopUI();

	updateSettings();

	delete ui;
}

//-----------------------------------------------------------------------------
const QString &MainWindow::getCurrentWorkspace()
{
	return fossil().getCurrentWorkspace();
}

//-----------------------------------------------------------------------------
void MainWindow::setCurrentWorkspace(const QString &workspace)
{
	if(workspace.isEmpty())
	{
		fossil().setCurrentWorkspace("");
		return;
	}

	QString new_workspace = QFileInfo(workspace).absoluteFilePath();

	fossil().setCurrentWorkspace(new_workspace);

	addWorkspace(new_workspace);

	if(!QDir::setCurrent(new_workspace))
		QMessageBox::critical(this, tr("Error"), tr("Could not change current directory to '%0'").arg(new_workspace), QMessageBox::Ok );
}

//------------------------------------------------------------------------------
void MainWindow::addWorkspace(const QString &dir)
{
	if(dir.isEmpty())
		return;

	QDir d(dir);
	QString new_workspace = d.absolutePath();








>














<
<
<
<
<
|
<
|
<
|
<
|
<
<



|







281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302





303

304

305

306


307
308
309
310
311
312
313
314
315
316
317
	rebuildRecent();
}

//------------------------------------------------------------------------------
MainWindow::~MainWindow()
{
	stopUI();
	getWorkspace().storeWorkspace(*settings.GetStore());
	updateSettings();

	delete ui;
}

//-----------------------------------------------------------------------------
const QString &MainWindow::getCurrentWorkspace()
{
	return fossil().getCurrentWorkspace();
}

//-----------------------------------------------------------------------------
void MainWindow::setCurrentWorkspace(const QString &workspace)
{





	if(!getWorkspace().switchWorkspace(workspace, *settings.GetStore()))

		QMessageBox::critical(this, tr("Error"), tr("Could not change current directory to '%0'").arg(workspace), QMessageBox::Ok );

	else

		addWorkspaceHistory(fossil().getCurrentWorkspace());


}

//------------------------------------------------------------------------------
void MainWindow::addWorkspaceHistory(const QString &dir)
{
	if(dir.isEmpty())
		return;

	QDir d(dir);
	QString new_workspace = d.absolutePath();

790
791
792
793
794
795
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

824
825
826
827
828
829
830
			QFont font = tag->font();
			font.setBold(true);
			tag->setFont(font);
		}
		tags->appendRow(tag);
	}

	// FIXME: Unique Icon name
	// 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);

	{
		QUrl default_url = fossil().getDefaultRemoteUrl();
		if(!default_url.isEmpty())
		{
			QUrl url = default_url;
			QStandardItem *remote_item = new QStandardItem(getInternalIcon(":icons/icon-item-remote"), url.toDisplayString());
			remote_item->setData(WorkspaceItem(WorkspaceItem::TYPE_REMOTE, default_url.toString()), ROLE_WORKSPACE_ITEM);







			remotes->appendRow(remote_item);
		}

	}

	// 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)







<

















>

<
<
<
<
|
|
>
>
>
>
>
>
>
|

>







781
782
783
784
785
786
787

788
789
790
791
792
793
794
795
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
824
825
			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(it->url.toDisplayString());

		// Mark the default url as bold
		if(it->isDefault)
		{
			QFont font = remote_item->font();
			font.setBold(true);
			remote_item->setFont(font);
		}
		remotes->appendRow(remote_item);
	}

	// 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)
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
		store->setArrayIndex(i);
		QString wk = store->value("Path").toString();

		// Skip invalid workspaces
		if(wk.isEmpty() || !QDir(wk).exists())
			continue;

		addWorkspace(wk);

		if(store->contains("Active") && store->value("Active").toBool())
			setCurrentWorkspace(wk);
	}
	store->endArray();

	store->beginReadArray("FileColumns");







|







965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
		store->setArrayIndex(i);
		QString wk = store->value("Path").toString();

		// Skip invalid workspaces
		if(wk.isEmpty() || !QDir(wk).exists())
			continue;

		addWorkspaceHistory(wk);

		if(store->contains("Active") && store->value("Active").toBool())
			setCurrentWorkspace(wk);
	}
	store->endArray();

	store->beginReadArray("FileColumns");
2459
2460
2461
2462
2463
2464
2465
2466






2467
2468

2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479














2480
2481
2482
2483
2484
2485
2486
void MainWindow::on_actionEditRemote_triggered()
{
	QStringList remotes;
	getSelectionRemotes(remotes);
	if(remotes.empty())
		return;

	QUrl url(remotes.first());






	bool exists = KeychainGet(this, url);


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

	if(!url.isLocalFile())
	{
		if(exists)
			KeychainDelete(this, url);

		if(!KeychainSet(this, url))
			QMessageBox::critical(this, tr("Error"), tr("Could not store information to keychain."), QMessageBox::Ok );
	}














}

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







|
>
>
>
>
>
>
|

>
|


|


|

|


>
>
>
>
>
>
>
>
>
>
>
>
>
>







2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
void MainWindow::on_actionEditRemote_triggered()
{
	QStringList remotes;
	getSelectionRemotes(remotes);
	if(remotes.empty())
		return;

	QUrl old_url(remotes.first());

	QString name;
	Remote *remote = getWorkspace().findRemote(old_url);
	if(remote)
		name = remote->name;

	bool exists = KeychainGet(this, old_url);

	QUrl new_url = old_url;
	if(!RemoteDialog::run(this, new_url, name))
		return;

	if(!new_url.isLocalFile())
	{
		if(exists)
			KeychainDelete(this, new_url);

		if(!KeychainSet(this, new_url))
			QMessageBox::critical(this, tr("Error"), tr("Could not store information to keychain."), QMessageBox::Ok );
	}

	// Remove password
	new_url.setPassword("");
	old_url.setPassword("");
	// Url changed?
	if(new_url != old_url)
	{
		getWorkspace().removeRemote(old_url);
		getWorkspace().addRemote(new_url, name);
	}
	else // Just data changed
		remote->name = name;

	updateWorkspaceView();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionPushRemote_triggered()
{
	QStringList remotes;
	getSelectionRemotes(remotes);
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545

	fossil().pullRepository(url);
}

//------------------------------------------------------------------------------
void MainWindow::on_actionPush_triggered()
{
	QUrl url = fossil().getDefaultRemoteUrl();

	if(url.isEmpty())
	{
		QMessageBox::critical(this, tr("Error"), tr("A default remote repository has not been specified."), QMessageBox::Ok );
		return;
	}

	// Retrieve password from keychain
	if(!url.isLocalFile())
		KeychainGet(this, url);


	fossil().pushRepository(url);
}

//------------------------------------------------------------------------------
void MainWindow::on_actionPull_triggered()
{
	QUrl url = fossil().getDefaultRemoteUrl();

	if(url.isEmpty())
	{
		QMessageBox::critical(this, tr("Error"), tr("A default remote repository has not been specified."), QMessageBox::Ok );
		return;
	}








|











<






|







2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546

2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560

	fossil().pullRepository(url);
}

//------------------------------------------------------------------------------
void MainWindow::on_actionPush_triggered()
{
	QUrl url = getWorkspace().getRemoteDefault();

	if(url.isEmpty())
	{
		QMessageBox::critical(this, tr("Error"), tr("A default remote repository has not been specified."), QMessageBox::Ok );
		return;
	}

	// Retrieve password from keychain
	if(!url.isLocalFile())
		KeychainGet(this, url);


	fossil().pushRepository(url);
}

//------------------------------------------------------------------------------
void MainWindow::on_actionPull_triggered()
{
	QUrl url = getWorkspace().getRemoteDefault();

	if(url.isEmpty())
	{
		QMessageBox::critical(this, tr("Error"), tr("A default remote repository has not been specified."), QMessageBox::Ok );
		return;
	}

2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574

2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588

	QStringList remotes;
	getSelectionRemotes(remotes);
	if(remotes.empty())
		return;

	QUrl url(remotes.first());

	// Retrieve password from keychain
	if(!url.isLocalFile())
		KeychainGet(this, url);

	fossil().setRemoteUrl(url);
	updateWorkspaceView();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionAddRemote_triggered()
{
	QUrl url;

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

	if(!url.isLocalFile())
	{
		KeychainDelete(this, url);

		if(!KeychainSet(this, url))
			QMessageBox::critical(this, tr("Error"), tr("Could not store information to keychain."), QMessageBox::Ok );
	}

	fossil().setRemoteUrl(url);
	updateWorkspaceView();
}








<
<
<
<
|







>
|










|


>
2571
2572
2573
2574
2575
2576
2577




2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
	QStringList remotes;
	getSelectionRemotes(remotes);
	if(remotes.empty())
		return;

	QUrl url(remotes.first());





	getWorkspace().setRemoteDefault(url);
	updateWorkspaceView();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionAddRemote_triggered()
{
	QUrl url;
	QString name;
	if(!RemoteDialog::run(this, url, name))
		return;

	if(!url.isLocalFile())
	{
		KeychainDelete(this, url);

		if(!KeychainSet(this, url))
			QMessageBox::critical(this, tr("Error"), tr("Could not store information to keychain."), QMessageBox::Ok );
	}

	getWorkspace().addRemote(url, name);
	updateWorkspaceView();
}