Fuel

Diff
Login

Differences From Artifact [ec7c571b76]:

To Artifact [0299d46ad7]:


21
22
23
24
25
26
27
28

29
30
31







32
33
34
35
36
37
38
21
22
23
24
25
26
27

28
29


30
31
32
33
34
35
36
37
38
39
40
41
42
43







-
+

-
-
+
+
+
+
+
+
+







#include <QUrl>
#include "CommitDialog.h"
#include "FileActionDialog.h"
#include "CloneDialog.h"
#include "Utils.h"
#include "LoggedProcess.h"

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

#define PATH_SEP			"/"
static const unsigned char UTF8_BOM[] = { 0xEF, 0xBB, 0xBF };
#define PATH_SEP				"/"

static const unsigned char		UTF8_BOM[] = { 0xEF, 0xBB, 0xBF };

// 19: [5c46757d4b9765] on 2012-04-22 04:41:15
static const QRegExp			REGEX_STASH("\\s*(\\d+):\\s+\\[(.*)\\] on (\\d+)-(\\d+)-(\\d+) (\\d+):(\\d+):(\\d+)", Qt::CaseInsensitive);


//-----------------------------------------------------------------------------
enum
{
	COLUMN_STATUS,
	COLUMN_FILENAME,
	COLUMN_EXTENSION,
225
226
227
228
229
230
231
232
233
234
235
236
237
238

239
240

241
242
243
244
245
246
247
230
231
232
233
234
235
236

237
238
239
240
241

242
243

244
245
246
247
248
249
250
251







-





-
+

-
+







	abortShortcut->setContext(Qt::ApplicationShortcut);
	abortShortcut->setEnabled(false);
	connect(abortShortcut, SIGNAL(activated()), this, SLOT(onAbort()));

	viewMode = VIEWMODE_TREE;

	applySettings();
	refreshOnShow = true;

	// Apply any explicit workspace path if available
	if(workspacePath && !workspacePath->isEmpty())
		openWorkspace(*workspacePath);

	abortCurrentAction = false;
	abortOperation = false;

	connect(this, SIGNAL(show), SLOT(onShow()), Qt::DirectConnection);
	rebuildRecent();
}

//------------------------------------------------------------------------------
MainWindow::~MainWindow()
{
	stopUI();
	updateSettings();
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
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







-
+













-
+
-
-
-
-
-
+
-







	// Dispose RepoFiles
	for(filemap_t::iterator it = workspaceFiles.begin(); it!=workspaceFiles.end(); ++it)
		delete *it;

	workspaceFiles.clear();
	pathSet.clear();

	abortCurrentAction = false;
	abortOperation = false;

	if(scan_files)
	{
		QCoreApplication::processEvents();

		QString ignore;
		// If we should not be showing ignored files, fill in the ignored spec
		if(!ui->actionViewIgnored->isChecked())
		{
			// QDir expects multiple specs being separated by a semicolon
			ignore = settings.GetFossilValue(FOSSIL_SETTING_IGNORE_GLOB).toString().replace(',',';');
		}

		if(!scanDirectory(all_files, wkdir, wkdir, ignore, abortCurrentAction))
		if(!scanDirectory(all_files, wkdir, wkdir, ignore, abortOperation))
		{
			setBusy(false);
			setStatus("");
			QApplication::restoreOverrideCursor();
			return;
			goto _done;
		}

		for(QFileInfoList::iterator it=all_files.begin(); it!=all_files.end(); ++it)
		{
			QString filename = it->fileName();
			QString fullpath = it->absoluteFilePath();

			// Skip fossil files
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
817
818
819
820
821
822
823

824
825
826
827
828
829
830
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
817
818
819
820
821
822







-
-
-
-
-
-
-
+
-
-





-
+



-
+




-
+














+







		pathSet.insert(path);
	}

	// Load the stash
	stashMap.clear();
	res.clear();
	if(!runFossil(QStringList() << "stash" << "ls", &res, RUNFLAGS_SILENT_ALL))
	{
		setBusy(false);
		setStatus("");
		QApplication::restoreOverrideCursor();
		return;
	}

		goto _done;
	// 19: [5c46757d4b9765] on 2012-04-22 04:41:15
	QRegExp stash_rx("\\s*(\\d+):\\s+\\[(.*)\\] on (\\d+)-(\\d+)-(\\d+) (\\d+):(\\d+):(\\d+)", Qt::CaseInsensitive);

	for(QStringList::iterator line_it=res.begin(); line_it!=res.end(); )
	{
		QString line = *line_it;

		int index = stash_rx.indexIn(line);
		int index = REGEX_STASH.indexIn(line);
		if(index==-1)
			break;

		QString id = stash_rx.cap(1);
		QString id = REGEX_STASH.cap(1);
		++line_it;

		QString name;
		// Finish at an anonymous stash or start of a new stash ?
		if(line_it==res.end() || stash_rx.indexIn(*line_it)!=-1)
		if(line_it==res.end() || REGEX_STASH.indexIn(*line_it)!=-1)
			name = line.trimmed();
		else // Named stash
		{
			// Parse stash name
			name = (*line_it);
			name = name.trimmed();
			++line_it;
		}

		stashMap.insert(name, id);
	}


	// Update the file item model
_done:
	updateDirView();
	updateFileView();
	updateStashView();

	setBusy(false);
	setStatus("");
	QApplication::restoreOverrideCursor();
1125
1126
1127
1128
1129
1130
1131
1132

1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153

1154
1155
1156
1157
1158
1159
1160
1117
1118
1119
1120
1121
1122
1123

1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144

1145
1146
1147
1148
1149
1150
1151
1152







-
+




















-
+







	}
	const QChar EOL_MARK('\n');
	QString ans_yes = 'y' + EOL_MARK;
	QString ans_no = 'n' + EOL_MARK;
	QString ans_always = 'a' + EOL_MARK;
	QString ans_convert = 'c' + EOL_MARK;

	abortCurrentAction = false;
	abortOperation = false;
	QString buffer;

#ifdef Q_OS_WIN
	QTextCodec *codec = QTextCodec::codecForName("UTF-8");
#else
	QTextCodec *codec = QTextCodec::codecForLocale();
#endif

	Q_ASSERT(codec);
	QTextDecoder *decoder = codec->makeDecoder();
	Q_ASSERT(decoder);

	while(true)
	{
		QProcess::ProcessState state = process.state();
		qint64 bytes_avail = process.logBytesAvailable();

		if(state!=QProcess::Running && bytes_avail<1)
			break;

		if(abortCurrentAction)
		if(abortOperation)
		{
			#ifdef Q_OS_WIN		// Verify this is still true on Qt5
				process.kill(); // QT on windows cannot terminate console processes with QProcess::terminate
			#else
				process.terminate();
			#endif
			break;
2662
2663
2664
2665
2666
2667
2668
2669
2670



2671
2672
2673
2674

2675
2676
2677
2678

2679
2680
2681


2682
2683

2684
2654
2655
2656
2657
2658
2659
2660


2661
2662
2663
2664
2665
2666

2667
2668



2669



2670
2671


2672








-
-
+
+
+



-
+

-
-
-
+
-
-
-
+
+
-
-
+
-
	ui->mainToolBar->setEnabled(enabled);
	ui->centralWidget->setEnabled(enabled);
}

//------------------------------------------------------------------------------
void MainWindow::onAbort()
{
	abortCurrentAction = true;
	log("\n* "+tr("Terminated")+" *\n");
	abortOperation = true;
	// FIXME: Rename this to something better, Operation Aborted
	log("<br><b>* "+tr("Terminated")+" *</b><br>", true);
}

//------------------------------------------------------------------------------
void MainWindow::onShow()
void MainWindow::fullRefresh()
{
	if(refreshOnShow)
	{
		refresh();
	refresh();
		rebuildRecent();
		// Select the Root of the tree to update the file view
		selectRootDir();
	// Select the Root of the tree to update the file view
	selectRootDir();
		refreshOnShow = false;
	}
}
}