Fuel

Diff
Login

Differences From Artifact [f8433657ef]:

To Artifact [b0e2b89153]:


1
2
3
4
5
6
7
8
9
10
11
12

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "MainWindow.h"
#include "ui_MainWindow.h"
#include <QFileDialog>
#include <QStandardItem>
#include <QProcess>
#include <QSettings>
#include <QDesktopServices>
#include <QDateTime>
#include <QLabel>
#include <QTemporaryFile>
#include <QMessageBox>
#include <QUrl>

#include "CommitDialog.h"
#include "FileActionDialog.h"

#define SILENT_STATUS true
#define COUNTOF(array) (sizeof(array)/sizeof(array[0]))

#define DEV_SETTINGS



enum
{
	COLUMN_STATUS,
	COLUMN_PATH,
	COLUMN_FILENAME,
	COLUMN_EXTENSION,












>






|
<
<







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20


21
22
23
24
25
26
27
#include "MainWindow.h"
#include "ui_MainWindow.h"
#include <QFileDialog>
#include <QStandardItem>
#include <QProcess>
#include <QSettings>
#include <QDesktopServices>
#include <QDateTime>
#include <QLabel>
#include <QTemporaryFile>
#include <QMessageBox>
#include <QUrl>
#include <QInputDialog>
#include "CommitDialog.h"
#include "FileActionDialog.h"

#define SILENT_STATUS true
#define COUNTOF(array) (sizeof(array)/sizeof(array[0]))

//#define DEV_SETTINGS



enum
{
	COLUMN_STATUS,
	COLUMN_PATH,
	COLUMN_FILENAME,
	COLUMN_EXTENSION,
84
85
86
87
88
89
90






91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106

107
108
109
110
111
112
113
{
	stopUI();
#ifndef DEV_SETTINGS
	saveSettings();
#endif
	delete ui;
}







//------------------------------------------------------------------------------
void MainWindow::on_actionRefresh_triggered()
{
	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionOpen_triggered()
{
	QString path = QFileDialog::getExistingDirectory(this, tr("Fossil Checkout"));
	if(!path.isNull())
	{
		workspaces.append(path);
		currentWorkspace = workspaces.size()-1;
		on_actionClearLog_triggered();

		refresh();
	}
}

//------------------------------------------------------------------------------
static void RecurseDirectory(QFileInfoList &entries, const QString& dirPath, const QString &baseDir)
{







>
>
>
>
>
>
















>







83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
{
	stopUI();
#ifndef DEV_SETTINGS
	saveSettings();
#endif
	delete ui;
}
const QString &MainWindow::getCurrentWorkspace()
{
	Q_ASSERT(currentWorkspace<workspaces.size());
	Q_ASSERT(QDir(workspaces[currentWorkspace]).exists());
	return workspaces[currentWorkspace];
}

//------------------------------------------------------------------------------
void MainWindow::on_actionRefresh_triggered()
{
	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionOpen_triggered()
{
	QString path = QFileDialog::getExistingDirectory(this, tr("Fossil Checkout"));
	if(!path.isNull())
	{
		workspaces.append(path);
		currentWorkspace = workspaces.size()-1;
		on_actionClearLog_triggered();
		stopUI();
		refresh();
	}
}

//------------------------------------------------------------------------------
static void RecurseDirectory(QFileInfoList &entries, const QString& dirPath, const QString &baseDir)
{
213
214
215
216
217
218
219

220


221
222
223
224
225
226

227









228
229
230

231

232






233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249


250
251
252
253
254
255
256
257
258

259
260
261
262
263
264
265

266
267
268
269
270


271
272
273
274
275
276
277
278
	for(QStringList::iterator it=res.begin(); it!=res.end(); ++it)
	{
		QString line = (*it).trimmed();
		if(line.length()==0)
			continue;

		QString status_text = line.left(10).trimmed();

		FileEntry::EntryType type = FileEntry::TYPE_UNKNOWN;



		if(status_text=="EDITED")
			type = FileEntry::TYPE_EDITTED;
		if(status_text=="ADDED")
			type = FileEntry::TYPE_ADDED;
		if(status_text=="DELETED")

			type = FileEntry::TYPE_DELETED;









		else if(status_text=="UNCHANGED")
			type = FileEntry::TYPE_UNCHANGED;


		QString fname = line.right(line.length() - 10).trimmed();








		filemap_t::iterator it = workspaceFiles.find(fname);
		Q_ASSERT(it!=workspaceFiles.end());

		it.value().setType(type);
	}

	// Update the model
	// Clear all rows (except header)
	itemModel.removeRows(0, itemModel.rowCount());

	struct { FileEntry::EntryType type; const char *tag; const char *icon; }
	stats[]=
	{
		{	FileEntry::TYPE_EDITTED, "E", ":icons/icons/Button Blank Yellow-01.png" },
		{	FileEntry::TYPE_UNCHANGED, "U", ":icons/icons/Button Blank Green-01.png" },
		{	FileEntry::TYPE_ADDED, "A", ":icons/icons/Button Add-01.png" },
		{	FileEntry::TYPE_DELETED, "D", ":icons/icons/Button Close-01.png" },


	};

	size_t i=0;
	for(filemap_t::iterator it = workspaceFiles.begin(); it!=workspaceFiles.end(); ++it, ++i)
	{
		const FileEntry &e = it.value();

		// Status Column
		const char *tag = "?"; // Default Tag

		const char *icon = ":icons/icons/Button Blank Gray-01.png"; // Default icon

		for(size_t t=0; t<COUNTOF(stats); ++t)
		{
			if(e.getType() == stats[t].type)
			{
				tag = stats[t].tag;

				icon = stats[t].icon;
				break;
			}
		}



		itemModel.setItem(i, COLUMN_STATUS, new QStandardItem(QIcon(icon), tag));

		QString path = e.getFilename();
		path = path.left(path.indexOf(e.getFileInfo().fileName()));
		QFileInfo finfo = e.getFileInfo();

		itemModel.setItem(i, COLUMN_PATH, new QStandardItem(path));
		itemModel.setItem(i, COLUMN_FILENAME, new QStandardItem(e.getFilename()));







>

>
>



|

|
>

>
>
>
>
>
>
>
>
>



>
|
>
|
>
>
>
>
>
>
|









|
|
<
|
|
|
|
>
>









>







>





>
>
|







219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271

272
273
274
275
276
277
278
279
280
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
	for(QStringList::iterator it=res.begin(); it!=res.end(); ++it)
	{
		QString line = (*it).trimmed();
		if(line.length()==0)
			continue;

		QString status_text = line.left(10).trimmed();
		QString fname = line.right(line.length() - 10).trimmed();
		FileEntry::EntryType type = FileEntry::TYPE_UNKNOWN;

		bool add_missing = false;

		if(status_text=="EDITED")
			type = FileEntry::TYPE_EDITTED;
		else if(status_text=="ADDED")
			type = FileEntry::TYPE_ADDED;
		else if(status_text=="DELETED")
		{
			type = FileEntry::TYPE_DELETED;
			add_missing = true;
		}
		else if(status_text=="MISSING")
		{
			type = FileEntry::TYPE_MISSING;
			add_missing = true;
		}
		else if(status_text=="RENAMED")
			type = FileEntry::TYPE_RENAMED;
		else if(status_text=="UNCHANGED")
			type = FileEntry::TYPE_UNCHANGED;

		filemap_t::iterator it = workspaceFiles.find(fname);

		if(add_missing && it==workspaceFiles.end())
		{
			FileEntry e;
			QFileInfo info(wkdir+QDir::separator()+fname);
			e.set(info, type, wkdir);
			workspaceFiles.insert(e.getFilename(), e);
		}

		it = workspaceFiles.find(fname);
		Q_ASSERT(it!=workspaceFiles.end());

		it.value().setType(type);
	}

	// Update the model
	// Clear all rows (except header)
	itemModel.removeRows(0, itemModel.rowCount());

	struct { FileEntry::EntryType type; const char *tag; const char *tooltip; const char *icon; }
	stats[] = {

		{	FileEntry::TYPE_EDITTED, "E", "Editted", ":icons/icons/Button Blank Yellow-01.png" },
		{	FileEntry::TYPE_UNCHANGED, "U", "Unchanged", ":icons/icons/Button Blank Green-01.png" },
		{	FileEntry::TYPE_ADDED, "A", "Added", ":icons/icons/Button Add-01.png" },
		{	FileEntry::TYPE_DELETED, "D", "Deleted", ":icons/icons/Button Close-01.png" },
		{	FileEntry::TYPE_RENAMED, "R", "Renamed", ":icons/icons/Button Reload-01.png" },
		{	FileEntry::TYPE_MISSING, "M", "Missing", ":icons/icons/Button Help-01.png" },
	};

	size_t i=0;
	for(filemap_t::iterator it = workspaceFiles.begin(); it!=workspaceFiles.end(); ++it, ++i)
	{
		const FileEntry &e = it.value();

		// Status Column
		const char *tag = "?"; // Default Tag
		const char *tooltip = "Unknown";
		const char *icon = ":icons/icons/Button Blank Gray-01.png"; // Default icon

		for(size_t t=0; t<COUNTOF(stats); ++t)
		{
			if(e.getType() == stats[t].type)
			{
				tag = stats[t].tag;
				tooltip = stats[t].tooltip;
				icon = stats[t].icon;
				break;
			}
		}

		QStandardItem *status = new QStandardItem(QIcon(icon), tag);
		status->setToolTip(tooltip);
		itemModel.setItem(i, COLUMN_STATUS, status);

		QString path = e.getFilename();
		path = path.left(path.indexOf(e.getFileInfo().fileName()));
		QFileInfo finfo = e.getFileInfo();

		itemModel.setItem(i, COLUMN_PATH, new QStandardItem(path));
		itemModel.setItem(i, COLUMN_FILENAME, new QStandardItem(e.getFilename()));
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363

364
365
366
367

368


369
370



371
372
373
374
375
376
377
//------------------------------------------------------------------------------
void MainWindow::on_actionClearLog_triggered()
{
	ui->textBrowser->clear();
}

//------------------------------------------------------------------------------
bool MainWindow::runFossil(QStringList &result, const QStringList &args, bool silent)
{
	int exit_code = EXIT_FAILURE;
	if(!runFossil(result, args, exit_code, silent))
		return false;

	return exit_code == EXIT_SUCCESS;
}
//------------------------------------------------------------------------------
// Run fossil. Returns true if execution was succesfull regardless if fossil
// issued an error
bool MainWindow::runFossil(QStringList &result, const QStringList &args, int &exitCode, bool silent)
{
	QProcess process(this);


	process.setProcessChannelMode(QProcess::MergedChannels);
	QString wkdir = getCurrentWorkspace();
	process.setWorkingDirectory(wkdir);




	if(!silent)
		log("> fossil "+args.join(" ")+"\n");




	process.start(fossilPath, args);
	if(!process.waitForStarted())
	{
		log("Could not start fossil executable '"+fossilPath + "''\n");
		return false;
	}







|


|







|

|
>

<

|
>
|
>
>
|
<
>
>
>







375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397

398
399
400
401
402
403
404

405
406
407
408
409
410
411
412
413
414
//------------------------------------------------------------------------------
void MainWindow::on_actionClearLog_triggered()
{
	ui->textBrowser->clear();
}

//------------------------------------------------------------------------------
bool MainWindow::runFossil(QStringList &result, const QStringList &args, bool silent, bool detached)
{
	int exit_code = EXIT_FAILURE;
	if(!runFossil(result, args, exit_code, silent, detached))
		return false;

	return exit_code == EXIT_SUCCESS;
}
//------------------------------------------------------------------------------
// Run fossil. Returns true if execution was succesfull regardless if fossil
// issued an error
bool MainWindow::runFossil(QStringList &result, const QStringList &args, int &exitCode, bool silent, bool detached)
{
	if(!silent)
		log("> fossil "+args.join(" ")+"\n");


	QString wkdir = getCurrentWorkspace();

	if(detached)
	{
		return QProcess::startDetached(fossilPath, args, wkdir);
	}


	QProcess process(this);
	process.setProcessChannelMode(QProcess::MergedChannels);
	process.setWorkingDirectory(wkdir);

	process.start(fossilPath, args);
	if(!process.waitForStarted())
	{
		log("Could not start fossil executable '"+fossilPath + "''\n");
		return false;
	}
397
398
399
400
401
402
403

404
405
406
407
408
409
410
411
	exitCode = process.exitCode();
	return true;
}

//------------------------------------------------------------------------------
void MainWindow::addWorkspace(const QString &dir)
{

	workspaces.append(dir);
	currentWorkspace = workspaces.size()-1;
}
//------------------------------------------------------------------------------
void MainWindow::loadSettings()
{
	QSettings settings(settingsFile, QSettings::NativeFormat);








>
|







434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
	exitCode = process.exitCode();
	return true;
}

//------------------------------------------------------------------------------
void MainWindow::addWorkspace(const QString &dir)
{
	QDir d(dir);
	workspaces.append(d.absolutePath());
	currentWorkspace = workspaces.size()-1;
}
//------------------------------------------------------------------------------
void MainWindow::loadSettings()
{
	QSettings settings(settingsFile, QSettings::NativeFormat);

499
500
501
502
503
504
505









506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
		// Skip unwanted files
		if(!(includeMask & e.getType()))
			continue;

		filenames.append(filename);
	}
}









//------------------------------------------------------------------------------
void MainWindow::on_actionDiff_triggered()
{
	QStringList selection;
	getSelectionFilenames(selection);

	for(QStringList::iterator it = selection.begin(); it!=selection.end(); ++it)
	{
		QStringList res;
		if(!runFossil(res, QStringList() << "gdiff" << QuotePath(*it)))
			return;
	}
}

//------------------------------------------------------------------------------
bool MainWindow::startUI()
{
	if(uiRunning())
		return true;







>
>
>
>
>
>
>
>
>




|


<
<
|

<







537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559


560
561

562
563
564
565
566
567
568
		// Skip unwanted files
		if(!(includeMask & e.getType()))
			continue;

		filenames.append(filename);
	}
}
//------------------------------------------------------------------------------
bool MainWindow::diffFile(QString repoFile)
{
	QStringList res;
	int exitcode;
	// Run the diff detached
	return runFossil(res, QStringList() << "gdiff" << QuotePath(repoFile), exitcode, false, true);
}

//------------------------------------------------------------------------------
void MainWindow::on_actionDiff_triggered()
{
	QStringList selection;
	getSelectionFilenames(selection, FileEntry::TYPE_REPO);

	for(QStringList::iterator it = selection.begin(); it!=selection.end(); ++it)


		if(!diffFile(*it))
			return;

}

//------------------------------------------------------------------------------
bool MainWindow::startUI()
{
	if(uiRunning())
		return true;
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
	QStringList modified_files;
	getSelectionFilenames(modified_files, FileEntry::TYPE_REPO_MODIFIED, true);

	if(modified_files.empty())
		return;

	QString msg;
	if(!CommitDialog::run(msg, commitMessages, modified_files, this))
		return;

	// Do commit
	commitMessages.push_front(msg);

	{
		QTemporaryFile comment_file;







|







672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
	QStringList modified_files;
	getSelectionFilenames(modified_files, FileEntry::TYPE_REPO_MODIFIED, true);

	if(modified_files.empty())
		return;

	QString msg;
	if(!CommitDialog::run(this, msg, commitMessages, modified_files))
		return;

	// Do commit
	commitMessages.push_front(msg);

	{
		QTemporaryFile comment_file;
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682


683
684
685

686

687
688


689
690
691












692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711




































712
713
714
715
716
717
718
	// Get unknown files only
	QStringList selection;
	getSelectionFilenames(selection, FileEntry::TYPE_UNKNOWN);

	if(selection.empty())
		return;

	if(!FileActionDialog::run(tr("Add files"), tr("The following files will be added. Are you sure?"), selection, this))
		return;

	// Do Add
	QStringList res;
	runFossil(res, QStringList() << "add" << QuotePaths(selection) );

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionDelete_triggered()
{
	QStringList repo_files;
	getSelectionFilenames(repo_files, FileEntry::TYPE_REPO);

	QStringList unknown_files;
	getSelectionFilenames(unknown_files, FileEntry::TYPE_UNKNOWN);



	if(repo_files.empty() && unknown_files.empty())
		return;


	if(!FileActionDialog::run(tr("Delete files"), tr("The following files will be deleted. Are you sure?"), repo_files+unknown_files, this))

		return;



	// Do Delete
	QStringList res;
	runFossil(res, QStringList() << "delete" << QuotePaths(repo_files) );













	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionRevert_triggered()
{
	QStringList modified_files;
	getSelectionFilenames(modified_files, FileEntry::TYPE_ADDED|FileEntry::TYPE_EDITTED);

	if(modified_files.empty())
		return;

	if(!FileActionDialog::run(tr("Revert files"), tr("The following files will be reverted. Are you sure?"), modified_files, this))
		return;

	// Do Revert
	QStringList res;
	runFossil(res, QStringList() << "revert" << QuotePaths(modified_files) );





































	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionNew_triggered()
{
	QString filter(tr("Fossil Repositories (*.fossil)"));







|


















>
>
|


>
|
>


>
>
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>








|




|






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







701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
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
	// Get unknown files only
	QStringList selection;
	getSelectionFilenames(selection, FileEntry::TYPE_UNKNOWN);

	if(selection.empty())
		return;

	if(!FileActionDialog::run(this, tr("Add files"), tr("The following files will be added. Are you sure?"), selection))
		return;

	// Do Add
	QStringList res;
	runFossil(res, QStringList() << "add" << QuotePaths(selection) );

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionDelete_triggered()
{
	QStringList repo_files;
	getSelectionFilenames(repo_files, FileEntry::TYPE_REPO);

	QStringList unknown_files;
	getSelectionFilenames(unknown_files, FileEntry::TYPE_UNKNOWN);

	QStringList all_files = repo_files+unknown_files;

	if(all_files.empty())
		return;

	bool remove_local = false;

	if(!FileActionDialog::run(this, tr("Remove files"), tr("The following files will be removed from the repository.\nAre you sure?"), all_files, tr("Also delete the local files"), &remove_local ))
		return;

	if(!repo_files.empty())
	{
		// Do Delete
		QStringList res;
		if(!runFossil(res, QStringList() << "delete" << QuotePaths(repo_files)))
			return;
	}

	if(remove_local)
	{
		for(int i=0; i<all_files.size(); ++i)
		{
			QFileInfo fi(getCurrentWorkspace() + QDir::separator() + all_files[i]);
			Q_ASSERT(fi.exists());
			QFile::remove(fi.filePath());
		}
	}

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionRevert_triggered()
{
	QStringList modified_files;
	getSelectionFilenames(modified_files, FileEntry::TYPE_EDITTED|FileEntry::TYPE_DELETED|FileEntry::TYPE_MISSING);

	if(modified_files.empty())
		return;

	if(!FileActionDialog::run(this, tr("Revert files"), tr("The following files will be reverted. Are you sure?"), modified_files))
		return;

	// Do Revert
	QStringList res;
	runFossil(res, QStringList() << "revert" << QuotePaths(modified_files) );

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionRename_triggered()
{
	QStringList repo_files;
	getSelectionFilenames(repo_files, FileEntry::TYPE_REPO);

	if(repo_files.length()!=1)
		return;

	QFileInfo fi_before(repo_files[0]);

	bool ok = false;
	QString new_name = QInputDialog::getText(this, tr("Rename"), tr("Enter new name"), QLineEdit::Normal, fi_before.filePath(), &ok );
	if(!ok)
		return;

	QFileInfo fi_after(new_name);

	if(fi_after.exists())
	{
		QMessageBox::critical(this, tr("Error"), tr("File ")+new_name+tr(" already exists.\nRename aborted."), QMessageBox::Ok );
		return;
	}

	// Do Rename
	QStringList res;
	runFossil(res, QStringList() << "mv" << QuotePath(fi_before.filePath()) << QuotePath(fi_after.filePath()) );

	QString wkdir = getCurrentWorkspace() + QDir::separator();

	// Also rename the file
	QFile::rename( wkdir+fi_before.filePath(), wkdir+fi_after.filePath());

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionNew_triggered()
{
	QString filter(tr("Fossil Repositories (*.fossil)"));
728
729
730
731
732
733
734

735
736
737
738
739
740
741
		return;

	if(QFile::exists(path))
	{
		QMessageBox::critical(this, tr("Error"), tr("A repository file already exists.\nRepository creation aborted."), QMessageBox::Ok );
		return;
	}


	QFileInfo path_info(path);
	Q_ASSERT(path_info.dir().exists());
	QString wkdir = path_info.absoluteDir().absolutePath();
	addWorkspace(wkdir);
	repositoryFile = path_info.absoluteFilePath();








>







826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
		return;

	if(QFile::exists(path))
	{
		QMessageBox::critical(this, tr("Error"), tr("A repository file already exists.\nRepository creation aborted."), QMessageBox::Ok );
		return;
	}
	stopUI();

	QFileInfo path_info(path);
	Q_ASSERT(path_info.dir().exists());
	QString wkdir = path_info.absoluteDir().absolutePath();
	addWorkspace(wkdir);
	repositoryFile = path_info.absoluteFilePath();

749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785


































	// Open repo
	if(!runFossil(res, QStringList() << "open" << QuotePath(repositoryFile), false))
	{
		QMessageBox::critical(this, tr("Error"), tr("Repository checkout failed."), QMessageBox::Ok );
		return;
	}

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionClone_triggered()
{

}


//------------------------------------------------------------------------------
void MainWindow::on_actionOpenContaining_triggered()
{
	QStringList selection;
	getSelectionFilenames(selection);

	QString target;

	if(selection.empty())
		target = QDir::toNativeSeparators(getCurrentWorkspace());
	else
	{
		QFileInfo file_info(selection[0]);
		target = QDir::toNativeSeparators(file_info.absoluteDir().absolutePath());
	}

	QUrl url = QUrl::fromLocalFile(target);
	QDesktopServices::openUrl(url);
}








































<






|

<




















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
914
915

	// Open repo
	if(!runFossil(res, QStringList() << "open" << QuotePath(repositoryFile), false))
	{
		QMessageBox::critical(this, tr("Error"), tr("Repository checkout failed."), QMessageBox::Ok );
		return;
	}

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionClone_triggered()
{
	stopUI();
}


//------------------------------------------------------------------------------
void MainWindow::on_actionOpenContaining_triggered()
{
	QStringList selection;
	getSelectionFilenames(selection);

	QString target;

	if(selection.empty())
		target = QDir::toNativeSeparators(getCurrentWorkspace());
	else
	{
		QFileInfo file_info(selection[0]);
		target = QDir::toNativeSeparators(file_info.absoluteDir().absolutePath());
	}

	QUrl url = QUrl::fromLocalFile(target);
	QDesktopServices::openUrl(url);
}

//------------------------------------------------------------------------------
void MainWindow::on_actionUndo_triggered()
{
	// Gather Undo actions
	QStringList res;

	if(!runFossil(res, QStringList() << "undo" << "--explain" ))
		return;

	if(res.length()>0 && res[0]=="No undo or redo is available")
		return;

	if(!FileActionDialog::run(this, tr("Undo"), tr("The following actions will be undone. Are you sure?"), res))
		return;

	// Do Undo
	runFossil(res, QStringList() << "undo" );

	refresh();
}

//------------------------------------------------------------------------------
void MainWindow::on_actionAbout_triggered()
{
	QMessageBox::about(this, tr("About..."), tr(
						   "Fuel, a GUI frontend to Fossil SCM\n"
						   "by Kostas Karanikolas\n"
						   "Released under the GNU GPL\n\n"
						   "Icon-set by Deleket - Jojo Mendoza\n"
						   "Available under the CC Attribution-Noncommercial-No Derivate 3.0 License"));
}