Fuel

Diff
Login

Differences From Artifact [8d0d6d8e78]:

To Artifact [e81955c190]:


9
10
11
12
13
14
15

16
17
18
19
20
21
22
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23







+







#include <QLabel>
#include <QTemporaryFile>
#include <QMessageBox>
#include <QUrl>
#include <QInputDialog>
#include <QDrag>
#include <QMimeData>
#include <QFileIconProvider>
#include "CommitDialog.h"
#include "FileActionDialog.h"
#include <QDebug>
#include "Utils.h"

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

131
132
133
134
135
136
137

138
139
140
141
142
143
144
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146







+







	ui->treeView->addAction(ui->actionOpenFolder);

	// StashView
	ui->tableViewStash->setModel(&repoStashModel);
	ui->tableViewStash->addAction(ui->actionApplyStash);
	ui->tableViewStash->addAction(ui->actionDiffStash);
	ui->tableViewStash->addAction(ui->actionDeleteStash);
    ui->tableViewStash->horizontalHeader()->setSortIndicatorShown(false);

	// 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)
	{
170
171
172
173
174
175
176
177

178
179
180
181
182
183
184
172
173
174
175
176
177
178

179
180
181
182
183
184
185
186







-
+







		a->setIconVisibleInMenu(false);
#endif

	viewMode = VIEWMODE_TREE;
	loadSettings();

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

	refresh();
	rebuildRecent();

	// Select the Root of the tree to update the file view
	selectRootDir();
368
369
370
371
372
373
374




375
376
377
378
379
380
381
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387







+
+
+
+







	// Create repo
	if(!runFossil(QStringList() << "new" << QuotePath(repositoryFile)))
	{
		QMessageBox::critical(this, tr("Error"), tr("Could not create repository."), QMessageBox::Ok );
		return;
	}

    // Disable unknown file filter
    if(!ui->actionViewUnknown->isChecked())
        ui->actionViewUnknown->setChecked(true);

	// Open repo
	if(!runFossil(QStringList() << "open" << QuotePath(repositoryFile)))
	{
		QMessageBox::critical(this, tr("Error"), tr("Could not open repository."), QMessageBox::Ok );
		return;
	}
	refresh();
785
786
787
788
789
790
791


792
793
794
795
796
797
798
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806







+
+







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

	QFileIconProvider icon_provider;

	size_t item_id=0;
	for(filemap_t::iterator it = workspaceFiles.begin(); it!=workspaceFiles.end(); ++it)
	{
		const RepoFile &e = *it.value();
		QString path = e.getPath();

		// In Tree mode, filter all items not included in the current dir
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
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







+





-
-
+


-
+












+
+
+
+
+
-
-
+
+







		}

		QStandardItem *status = new QStandardItem(QIcon(status_icon), tag);
		status->setToolTip(tooltip);
		repoFileModel.setItem(item_id, COLUMN_STATUS, status);

		QFileInfo finfo = e.getFileInfo();
		QIcon icon = icon_provider.icon(finfo);

		QStandardItem *filename_item = 0;
		if(viewMode==VIEWMODE_LIST || multiple_dirs)
		{
			repoFileModel.setItem(item_id, COLUMN_PATH, new QStandardItem(path));

			filename_item = new QStandardItem(e.getFilePath());
			filename_item = new QStandardItem(icon, QDir::toNativeSeparators(e.getFilePath()));
		}
		else // In Tree mode the path is implicit so the file name is enough
			filename_item = new QStandardItem(e.getFilename());
		filename_item = new QStandardItem(icon, e.getFilename());

		Q_ASSERT(filename_item);
		// Keep the path in the user data
		filename_item->setData(e.getFilePath());
		repoFileModel.setItem(item_id, COLUMN_FILENAME, filename_item);

		repoFileModel.setItem(item_id, COLUMN_EXTENSION, new QStandardItem(finfo .completeSuffix()));
		repoFileModel.setItem(item_id, COLUMN_MODIFIED, new QStandardItem(finfo .lastModified().toString(Qt::SystemLocaleShortDate)));

		++item_id;
	}

    ui->tableView->horizontalHeader()->setResizeMode(COLUMN_STATUS, QHeaderView::ResizeToContents);
    ui->tableView->horizontalHeader()->setResizeMode(COLUMN_FILENAME, QHeaderView::Stretch);
    ui->tableView->horizontalHeader()->setResizeMode(COLUMN_EXTENSION, QHeaderView::ResizeToContents);
    ui->tableView->horizontalHeader()->setResizeMode(COLUMN_MODIFIED, QHeaderView::ResizeToContents);
    ui->tableView->horizontalHeader()->setResizeMode(COLUMN_PATH, QHeaderView::ResizeToContents);
	ui->tableView->resizeColumnsToContents();
	ui->tableView->resizeRowsToContents();
    ui->tableView->horizontalHeader()->setSortIndicatorShown(true);
    ui->tableView->resizeRowsToContents();
}

//------------------------------------------------------------------------------
MainWindow::RepoStatus MainWindow::getRepoStatus()
{
	QStringList res;
	int exit_code = EXIT_FAILURE;
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322



2323
2324








2326
2327
2328
2329
2330
2331
2332



2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345







-
-
-
+
+
+


+
+
+
+
+
+
+
+
	{
		uris += QUrl::fromLocalFile(getCurrentWorkspace()+QDir::separator()+f).toString() + '\n';
	}

	QMimeData *mime_data = new QMimeData;
	mime_data->setData("text/uri-list", uris.toUtf8());

	QDrag drag(this);
	drag.setMimeData(mime_data);
	drag.exec(Qt::CopyAction);
    QDrag *drag = new QDrag(this);
    drag->setMimeData(mime_data);
    drag->exec(Qt::CopyAction);
}

//------------------------------------------------------------------------------
void MainWindow::on_textBrowser_customContextMenuRequested(const QPoint &pos)
{
    QMenu *menu = ui->textBrowser->createStandardContextMenu();
    menu->addSeparator();
    menu->addAction(ui->actionClearLog);
    menu->popup(ui->textBrowser->mapToGlobal(pos));
}