Implemented CommitAction, DeleteAction, RevertAction, NewRepository, OpenRepository
New Action: Open containing folder New filetypes ADDED, DELETED We now detect invalid or outdated repositories FossilOrigin-Name: 2ac3cf9717f3529f809ffde1e802295988dfda05
This commit is contained in:
parent
dd9e18f113
commit
54ca948fae
389
MainWindow.cpp
389
MainWindow.cpp
@ -6,9 +6,20 @@
|
||||
#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,
|
||||
@ -18,6 +29,20 @@ enum
|
||||
COLUMN_MODIFIED
|
||||
};
|
||||
|
||||
static QString QuotePath(const QString &path)
|
||||
{
|
||||
return path;
|
||||
}
|
||||
|
||||
static QStringList QuotePaths(const QStringList &paths)
|
||||
{
|
||||
QStringList res;
|
||||
for(int i=0; i<paths.size(); ++i)
|
||||
res.append(QuotePath(paths[i]));
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
@ -25,19 +50,31 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->tableView->setModel(&itemModel);
|
||||
itemModel.setHorizontalHeaderLabels(QStringList() << tr("S") << tr("Path") << tr("File") << tr("Ext") << tr("Modified") );
|
||||
|
||||
ui->tableView->addAction(ui->actionDiff);
|
||||
ui->tableView->addAction(ui->actionHistory);
|
||||
ui->tableView->addAction(ui->actionOpenFile);
|
||||
ui->tableView->addAction(ui->actionOpenContaining);
|
||||
ui->tableView->addAction(ui->actionAdd);
|
||||
ui->tableView->addAction(ui->actionDelete);
|
||||
ui->tableView->addAction(ui->actionRename);
|
||||
|
||||
statusLabel = new QLabel();
|
||||
statusLabel->setMinimumSize( statusLabel->sizeHint() );
|
||||
ui->statusBar->addWidget( statusLabel, 1 );
|
||||
|
||||
settingsFile = QDir::homePath() + QDir::separator() + ".fuelrc";
|
||||
currentWorkspace = 0;
|
||||
loadSettings();
|
||||
|
||||
#ifdef DEV_SETTINGS
|
||||
if(workspaces.empty())
|
||||
workspaces.append("/home/kostas/tmp/cheesy-fos");
|
||||
workspaces.append("/home/kostas/tmp/testfossil");
|
||||
|
||||
fossilPath = "fossil";
|
||||
#else
|
||||
loadSettings();
|
||||
#endif
|
||||
|
||||
refresh();
|
||||
}
|
||||
@ -46,7 +83,9 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
stopUI();
|
||||
#ifndef DEV_SETTINGS
|
||||
saveSettings();
|
||||
#endif
|
||||
delete ui;
|
||||
}
|
||||
|
||||
@ -59,11 +98,12 @@ void MainWindow::on_actionRefresh_triggered()
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::on_actionOpen_triggered()
|
||||
{
|
||||
QString path = QFileDialog::getExistingDirectory (this, tr("Fossil Checkout"));
|
||||
QString path = QFileDialog::getExistingDirectory(this, tr("Fossil Checkout"));
|
||||
if(!path.isNull())
|
||||
{
|
||||
workspaces.append(path);
|
||||
currentWorkspace = workspaces.size()-1;
|
||||
on_actionClearLog_triggered();
|
||||
refresh();
|
||||
}
|
||||
}
|
||||
@ -94,12 +134,58 @@ static void RecurseDirectory(QFileInfoList &entries, const QString& dirPath, con
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::enableActions(bool on)
|
||||
{
|
||||
ui->actionCommit->setEnabled(on);
|
||||
ui->actionDiff->setEnabled(on);
|
||||
ui->actionAdd->setEnabled(on);
|
||||
ui->actionDelete->setEnabled(on);
|
||||
ui->actionPush->setEnabled(on);
|
||||
ui->actionPull->setEnabled(on);
|
||||
ui->actionRename->setEnabled(on);
|
||||
ui->actionHistory->setEnabled(on);
|
||||
ui->actionFossilUI->setEnabled(on);
|
||||
ui->actionRevert->setEnabled(on);
|
||||
ui->actionTimeline->setEnabled(on);
|
||||
ui->actionOpenFile->setEnabled(on);
|
||||
ui->actionOpenContaining->setEnabled(on);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::refresh()
|
||||
{
|
||||
// Load repository info
|
||||
updateStatus();
|
||||
RepoStatus st = getRepoStatus();
|
||||
|
||||
if(st==REPO_NOT_FOUND)
|
||||
{
|
||||
setStatus(tr("No checkout detected."));
|
||||
enableActions(false);
|
||||
itemModel.removeRows(0, itemModel.rowCount());
|
||||
return;
|
||||
}
|
||||
else if(st==REPO_OLD_SCHEMA)
|
||||
{
|
||||
setStatus(tr("Old fossil schema detected. Consider running rebuild."));
|
||||
enableActions(false);
|
||||
itemModel.removeRows(0, itemModel.rowCount());
|
||||
return;
|
||||
}
|
||||
|
||||
scanWorkspace();
|
||||
setStatus("");
|
||||
enableActions(true);
|
||||
|
||||
QString title = "Fuel";
|
||||
if(!projectName.isEmpty())
|
||||
title += " - "+projectName;
|
||||
|
||||
setWindowTitle(title);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::scanWorkspace()
|
||||
{
|
||||
// Scan all workspace files
|
||||
QFileInfoList all_files;
|
||||
QString wkdir = getCurrentWorkspace();
|
||||
@ -109,7 +195,6 @@ void MainWindow::refresh()
|
||||
for(QFileInfoList::iterator it=all_files.begin(); it!=all_files.end(); ++it)
|
||||
{
|
||||
QString filename = it->fileName();
|
||||
QString qqq = it->absoluteFilePath();
|
||||
|
||||
// Skip fossil files
|
||||
if(filename == "_FOSSIL_" || (!repositoryFile.isEmpty() && it->absoluteFilePath()==repositoryFile))
|
||||
@ -122,7 +207,7 @@ void MainWindow::refresh()
|
||||
|
||||
// Retrieve the status of files tracked by fossil
|
||||
QStringList res;
|
||||
if(!runFossil(res, QStringList() << "ls" << "-l"))
|
||||
if(!runFossil(res, QStringList() << "ls" << "-l", SILENT_STATUS))
|
||||
return;
|
||||
|
||||
for(QStringList::iterator it=res.begin(); it!=res.end(); ++it)
|
||||
@ -136,6 +221,10 @@ void MainWindow::refresh()
|
||||
|
||||
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;
|
||||
|
||||
@ -148,35 +237,39 @@ void MainWindow::refresh()
|
||||
}
|
||||
|
||||
// Update the model
|
||||
itemModel.clear();
|
||||
itemModel.setHorizontalHeaderLabels(QStringList() << "S" << "Path" << "File" << "Ext" << "Modified" );
|
||||
// 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();
|
||||
switch(e.getType())
|
||||
{
|
||||
case FileEntry::TYPE_EDITTED:
|
||||
{
|
||||
QIcon modicon(":icons/icons/Button Blank Yellow-01.png");
|
||||
itemModel.setItem(i, COLUMN_STATUS, new QStandardItem(modicon, "E"));
|
||||
break;
|
||||
}
|
||||
case FileEntry::TYPE_UNCHANGED:
|
||||
{
|
||||
QIcon modicon(":icons/icons/Button Blank Green-01.png");
|
||||
itemModel.setItem(i, COLUMN_STATUS, new QStandardItem(modicon, "U"));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
QIcon modicon(":icons/icons/Button Blank Gray-01.png");
|
||||
itemModel.setItem(i, COLUMN_STATUS, new QStandardItem(modicon, "?"));
|
||||
}
|
||||
|
||||
// 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();
|
||||
@ -190,19 +283,63 @@ void MainWindow::refresh()
|
||||
|
||||
ui->tableView->resizeColumnsToContents();
|
||||
ui->tableView->resizeRowsToContents();
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
MainWindow::RepoStatus MainWindow::getRepoStatus()
|
||||
{
|
||||
QStringList res;
|
||||
int exit_code = EXIT_FAILURE;
|
||||
|
||||
QString title = "Fuel";
|
||||
if(!projectName.isEmpty())
|
||||
title += " - "+projectName;
|
||||
// We need to differentiate the reason why fossil has failed
|
||||
// so we delay processing of the exit_code
|
||||
if(!runFossil(res, QStringList() << "info", exit_code, SILENT_STATUS))
|
||||
return REPO_NOT_FOUND;
|
||||
|
||||
setWindowTitle(title);
|
||||
bool run_ok = exit_code == EXIT_SUCCESS;
|
||||
|
||||
for(QStringList::iterator it=res.begin(); it!=res.end(); ++it)
|
||||
{
|
||||
QStringList tokens = it->split(":");
|
||||
if(tokens.length()!=2)
|
||||
continue;
|
||||
QString key = tokens[0].trimmed();
|
||||
QString value = tokens[1].trimmed();
|
||||
|
||||
if(key=="fossil")
|
||||
{
|
||||
if(value=="incorrect repository schema version")
|
||||
return REPO_OLD_SCHEMA;
|
||||
else if(value=="not within an open checkout")
|
||||
return REPO_NOT_FOUND;
|
||||
}
|
||||
|
||||
if(run_ok)
|
||||
{
|
||||
if(key=="project-name")
|
||||
projectName = value;
|
||||
else if(key=="repository")
|
||||
repositoryFile = value;
|
||||
}
|
||||
}
|
||||
|
||||
return run_ok ? REPO_OK : REPO_NOT_FOUND;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::log(const QString &text)
|
||||
{
|
||||
ui->textBrowser->insertPlainText(text);
|
||||
QTextCursor c = ui->textBrowser->textCursor();
|
||||
c.movePosition(QTextCursor::End);
|
||||
ui->textBrowser->setTextCursor(c);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::Log(const QString &text)
|
||||
void MainWindow::setStatus(const QString &text)
|
||||
{
|
||||
ui->textBrowser->append(text);
|
||||
Q_ASSERT(statusLabel);
|
||||
statusLabel->setText(text);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::on_actionClearLog_triggered()
|
||||
{
|
||||
@ -210,22 +347,32 @@ void MainWindow::on_actionClearLog_triggered()
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool MainWindow::runFossil(QStringList &result, const QStringList &args)
|
||||
bool MainWindow::runFossil(QStringList &result, const QStringList &args, bool silent)
|
||||
{
|
||||
QProcess process;
|
||||
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);
|
||||
process.setWorkingDirectory(getCurrentWorkspace());
|
||||
QString wkdir = getCurrentWorkspace();
|
||||
process.setWorkingDirectory(wkdir);
|
||||
|
||||
QStringList rargs;
|
||||
rargs << args;
|
||||
if(!silent)
|
||||
log("> fossil "+args.join(" ")+"\n");
|
||||
|
||||
Log("> fossil "+rargs.join(" "));
|
||||
|
||||
process.start(fossilPath, rargs);
|
||||
process.start(fossilPath, args);
|
||||
if(!process.waitForStarted())
|
||||
{
|
||||
Log(fossilPath + " does not exist\n");
|
||||
log("Could not start fossil executable '"+fossilPath + "''\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -238,15 +385,25 @@ bool MainWindow::runFossil(QStringList &result, const QStringList &args)
|
||||
{
|
||||
QString line = it->trimmed();
|
||||
result.append(line);
|
||||
Log(line);
|
||||
if(!silent)
|
||||
log(line+"\n");
|
||||
}
|
||||
|
||||
if(process.exitStatus()!=QProcess::NormalExit)
|
||||
QProcess::ExitStatus es = process.exitStatus();
|
||||
|
||||
if(es!=QProcess::NormalExit)
|
||||
return false;
|
||||
|
||||
return process.exitCode() == EXIT_SUCCESS;
|
||||
exitCode = process.exitCode();
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::addWorkspace(const QString &dir)
|
||||
{
|
||||
workspaces.append(dir);
|
||||
currentWorkspace = workspaces.size()-1;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::loadSettings()
|
||||
{
|
||||
@ -314,9 +471,16 @@ void MainWindow::saveSettings()
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::getSelectionFilenames(QStringList &filenames, int includeMask)
|
||||
void MainWindow::getSelectionFilenames(QStringList &filenames, int includeMask, bool allIfEmpty)
|
||||
{
|
||||
QModelIndexList selection = ui->tableView->selectionModel()->selectedIndexes();
|
||||
if(selection.empty() && allIfEmpty)
|
||||
{
|
||||
ui->tableView->selectAll();
|
||||
selection = ui->tableView->selectionModel()->selectedIndexes();
|
||||
ui->tableView->clearSelection();
|
||||
}
|
||||
|
||||
for(QModelIndexList::iterator mi_it = selection.begin(); mi_it!=selection.end(); ++mi_it)
|
||||
{
|
||||
const QModelIndex &mi = *mi_it;
|
||||
@ -348,7 +512,7 @@ void MainWindow::on_actionDiff_triggered()
|
||||
for(QStringList::iterator it = selection.begin(); it!=selection.end(); ++it)
|
||||
{
|
||||
QStringList res;
|
||||
if(!runFossil(res, QStringList() << "gdiff" << *it))
|
||||
if(!runFossil(res, QStringList() << "gdiff" << QuotePath(*it)))
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -362,12 +526,12 @@ bool MainWindow::startUI()
|
||||
fossilUI.setProcessChannelMode(QProcess::MergedChannels);
|
||||
fossilUI.setWorkingDirectory(getCurrentWorkspace());
|
||||
|
||||
Log("> fossil ui");
|
||||
log("> fossil ui\n");
|
||||
|
||||
fossilUI.start(fossilPath, QStringList() << "ui");
|
||||
if(!fossilUI.waitForStarted())
|
||||
{
|
||||
Log(fossilPath + " does not exist\n");
|
||||
log(fossilPath + tr(" does not exist") +"\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -457,32 +621,12 @@ void MainWindow::on_actionPull_triggered()
|
||||
runFossil(res, QStringList() << "pull");
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::updateStatus()
|
||||
{
|
||||
QStringList res;
|
||||
if(!runFossil(res, QStringList() << "info"))
|
||||
return;
|
||||
|
||||
for(QStringList::iterator it=res.begin(); it!=res.end(); ++it)
|
||||
{
|
||||
QStringList tokens = it->split(":");
|
||||
if(tokens.length()!=2)
|
||||
continue;
|
||||
QString key = tokens[0].trimmed();
|
||||
QString value = tokens[1].trimmed();
|
||||
if(key=="project-name")
|
||||
projectName = value;
|
||||
else if(key=="repository")
|
||||
repositoryFile = value;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void MainWindow::on_actionCommit_triggered()
|
||||
{
|
||||
QStringList modified_files;
|
||||
getSelectionFilenames(modified_files, FileEntry::TYPE_EDITTED);
|
||||
getSelectionFilenames(modified_files, FileEntry::TYPE_REPO_MODIFIED, true);
|
||||
|
||||
if(modified_files.empty())
|
||||
return;
|
||||
@ -493,6 +637,18 @@ void MainWindow::on_actionCommit_triggered()
|
||||
|
||||
// Do commit
|
||||
commitMessages.push_front(msg);
|
||||
|
||||
{
|
||||
QTemporaryFile comment_file;
|
||||
comment_file.open();
|
||||
comment_file.write(msg.toUtf8());
|
||||
comment_file.close();
|
||||
|
||||
QStringList res;
|
||||
runFossil(res, QStringList() << "commit" << "--message-file" << QuotePath(comment_file.fileName()) << QuotePaths(modified_files) );
|
||||
}
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
@ -505,17 +661,21 @@ void MainWindow::on_actionAdd_triggered()
|
||||
if(selection.empty())
|
||||
return;
|
||||
|
||||
if(!FileActionDialog::run("Add files", "The following files will be added. Are you sure?", selection, this))
|
||||
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_EDITTED|FileEntry::TYPE_UNCHANGED);
|
||||
getSelectionFilenames(repo_files, FileEntry::TYPE_REPO);
|
||||
|
||||
QStringList unknown_files;
|
||||
getSelectionFilenames(unknown_files, FileEntry::TYPE_UNKNOWN);
|
||||
@ -523,24 +683,103 @@ void MainWindow::on_actionDelete_triggered()
|
||||
if(repo_files.empty() && unknown_files.empty())
|
||||
return;
|
||||
|
||||
if(!FileActionDialog::run("Delete files", "The following files will be deleted. Are you sure?", repo_files+unknown_files, this))
|
||||
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_EDITTED);
|
||||
getSelectionFilenames(modified_files, FileEntry::TYPE_ADDED|FileEntry::TYPE_EDITTED);
|
||||
|
||||
if(modified_files.empty())
|
||||
return;
|
||||
|
||||
if(!FileActionDialog::run("Revert files", "The following files will be reverted. Are you sure?", modified_files, this))
|
||||
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)"));
|
||||
|
||||
QString path = QFileDialog::getSaveFileName(
|
||||
this,
|
||||
tr("New Fossil Repository"),
|
||||
QString(),
|
||||
filter,
|
||||
&filter);
|
||||
|
||||
if(path.isEmpty())
|
||||
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();
|
||||
|
||||
// Create repo
|
||||
QStringList res;
|
||||
if(!runFossil(res, QStringList() << "new" << QuotePath(repositoryFile), false))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error"), tr("Repository creation failed."), QMessageBox::Ok );
|
||||
return;
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
41
MainWindow.h
41
MainWindow.h
@ -19,10 +19,14 @@ struct FileEntry
|
||||
{
|
||||
enum EntryType
|
||||
{
|
||||
TYPE_UNKNOWN = 1<<0,
|
||||
TYPE_UNCHANGED = 1<<1,
|
||||
TYPE_EDITTED = 1<<2,
|
||||
TYPE_ALL = TYPE_UNKNOWN|TYPE_UNCHANGED|TYPE_EDITTED
|
||||
TYPE_UNKNOWN = 1<<0,
|
||||
TYPE_UNCHANGED = 1<<1,
|
||||
TYPE_EDITTED = 1<<2,
|
||||
TYPE_ADDED = 1<<3,
|
||||
TYPE_DELETED = 1<<4,
|
||||
TYPE_REPO_MODIFIED = TYPE_EDITTED|TYPE_ADDED|TYPE_DELETED,
|
||||
TYPE_REPO = TYPE_UNCHANGED|TYPE_REPO_MODIFIED,
|
||||
TYPE_ALL = TYPE_UNKNOWN|TYPE_REPO
|
||||
};
|
||||
|
||||
void set(QFileInfo &info, EntryType type, const QString &repoPath)
|
||||
@ -81,6 +85,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
@ -91,16 +96,29 @@ public:
|
||||
|
||||
private:
|
||||
void refresh();
|
||||
bool runFossil(QStringList &result, const QStringList &args);
|
||||
void scanWorkspace();
|
||||
bool runFossil(QStringList &result, const QStringList &args, bool silent=false);
|
||||
bool runFossil(QStringList &result, const QStringList &args, int &exitCode, bool silent=false);
|
||||
void loadSettings();
|
||||
void saveSettings();
|
||||
const QString &getCurrentWorkspace() { Q_ASSERT(currentWorkspace<workspaces.size()); return workspaces[currentWorkspace]; }
|
||||
void Log(const QString &text);
|
||||
void log(const QString &text);
|
||||
void setStatus(const QString &text);
|
||||
bool uiRunning() const { return fossilUI.state() == QProcess::Running; }
|
||||
void getSelectionFilenames(QStringList &filenames, int includeMask=FileEntry::TYPE_ALL);
|
||||
void getSelectionFilenames(QStringList &filenames, int includeMask=FileEntry::TYPE_ALL, bool allIfEmpty=false);
|
||||
bool startUI();
|
||||
void stopUI();
|
||||
void updateStatus();
|
||||
void enableActions(bool on);
|
||||
void addWorkspace(const QString &dir);
|
||||
|
||||
enum RepoStatus
|
||||
{
|
||||
REPO_OK,
|
||||
REPO_NOT_FOUND,
|
||||
REPO_OLD_SCHEMA
|
||||
};
|
||||
|
||||
RepoStatus getRepoStatus();
|
||||
|
||||
private slots:
|
||||
void on_actionRefresh_triggered();
|
||||
@ -117,10 +135,12 @@ private slots:
|
||||
void on_actionPull_triggered();
|
||||
void on_actionCommit_triggered();
|
||||
void on_actionAdd_triggered();
|
||||
|
||||
void on_actionDelete_triggered();
|
||||
|
||||
void on_actionRevert_triggered();
|
||||
void on_actionNew_triggered();
|
||||
void on_actionClone_triggered();
|
||||
|
||||
void on_actionOpenContaining_triggered();
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
@ -136,6 +156,7 @@ private:
|
||||
filemap_t workspaceFiles;
|
||||
int currentWorkspace;
|
||||
QStringList commitMessages;
|
||||
class QLabel *statusLabel;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
@ -91,6 +91,9 @@
|
||||
</property>
|
||||
<addaction name="actionOpen"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionNew"/>
|
||||
<addaction name="actionClone"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionQuit"/>
|
||||
</widget>
|
||||
@ -115,10 +118,10 @@
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionRefresh"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionCommit"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionRefresh"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionPush"/>
|
||||
<addaction name="actionPull"/>
|
||||
<addaction name="separator"/>
|
||||
@ -130,11 +133,11 @@
|
||||
<addaction name="actionDiff"/>
|
||||
<addaction name="actionHistory"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionClearLog"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionTimeline"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionFossilUI"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionOpenContaining"/>
|
||||
<addaction name="actionClearLog"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
<action name="actionRefresh">
|
||||
@ -149,7 +152,7 @@
|
||||
<action name="actionCommit">
|
||||
<property name="icon">
|
||||
<iconset resource="resources.qrc">
|
||||
<normaloff>:/icons/icons/Button Add-01.png</normaloff>:/icons/icons/Button Add-01.png</iconset>
|
||||
<normaloff>:/icons/icons/Save-01.png</normaloff>:/icons/icons/Save-01.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Commit</string>
|
||||
@ -304,6 +307,33 @@
|
||||
<string>Open file</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionNew">
|
||||
<property name="icon">
|
||||
<iconset resource="resources.qrc">
|
||||
<normaloff>:/icons/icons/Book-01.png</normaloff>:/icons/icons/Book-01.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>New Repository...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionClone">
|
||||
<property name="icon">
|
||||
<iconset resource="resources.qrc">
|
||||
<normaloff>:/icons/icons/Address Book-01.png</normaloff>:/icons/icons/Address Book-01.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Clone Repository...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionOpenContaining">
|
||||
<property name="icon">
|
||||
<iconset resource="resources.qrc">
|
||||
<normaloff>:/icons/icons/My Documents-01.png</normaloff>:/icons/icons/My Documents-01.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Open Containing Folder</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources>
|
||||
|
14
RepoDialog.cpp
Normal file
14
RepoDialog.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
#include "RepoDialog.h"
|
||||
#include "ui_RepoDialog.h"
|
||||
|
||||
RepoDialog::RepoDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::RepoDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
RepoDialog::~RepoDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
22
RepoDialog.h
Normal file
22
RepoDialog.h
Normal file
@ -0,0 +1,22 @@
|
||||
#ifndef REPODIALOG_H
|
||||
#define REPODIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class RepoDialog;
|
||||
}
|
||||
|
||||
class RepoDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RepoDialog(QWidget *parent = 0);
|
||||
~RepoDialog();
|
||||
|
||||
private:
|
||||
Ui::RepoDialog *ui;
|
||||
};
|
||||
|
||||
#endif // REPODIALOG_H
|
91
RepoDialog.ui
Normal file
91
RepoDialog.ui
Normal file
@ -0,0 +1,91 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>RepoDialog</class>
|
||||
<widget class="QDialog" name="RepoDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>240</y>
|
||||
<width>341</width>
|
||||
<height>32</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>150</x>
|
||||
<y>60</y>
|
||||
<width>241</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>30</x>
|
||||
<y>70</y>
|
||||
<width>181</width>
|
||||
<height>17</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Repository Name</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>RepoDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>RepoDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
23
manifest
23
manifest
@ -1,14 +1,17 @@
|
||||
C Added\sCommit\sand\sFileAction\sdialogs\nSkeleton\scode\sfor\sCommit,\sAdd,\sDelete,\sRevert\sactions
|
||||
D 2011-08-03T15:30:09.277
|
||||
C Implemented\sCommitAction,\sDeleteAction,\sRevertAction,\sNewRepository,\sOpenRepository\nNew\sAction:\sOpen\scontaining\sfolder\nNew\sfiletypes\sADDED,\sDELETED\nWe\snow\sdetect\sinvalid\sor\soutdated\srepositories\n
|
||||
D 2011-08-04T15:52:07.126
|
||||
F CommitDialog.cpp f4065a49dfaa6904ffb1ad4ebe5efd01506cf550
|
||||
F CommitDialog.h c18c73998f8a925723ec1407ce75dc17a27a5ff7
|
||||
F CommitDialog.ui 482961858d1e7c31745966c347b21b6318e2e7b5
|
||||
F FileActionDialog.cpp 02dc244b0bcaad2021327186d5870bc408210a41
|
||||
F FileActionDialog.h 6082f84f6b5d48be6104034d6dc896a9d343b613
|
||||
F FileActionDialog.ui 2d7a0fa47f9555f4a4a7485feacd5bce504415a0
|
||||
F MainWindow.cpp b2fb908aefa74484a4b7f751f8ad9570b79454bb
|
||||
F MainWindow.h a3fda2c06f47a831e799a441f183810e6585b9bb
|
||||
F MainWindow.ui 71a58630d7a3b6af128d427a9390eadfc4fc83e3
|
||||
F MainWindow.cpp f8433657efea2e502d790b6d094891aaee1134c5
|
||||
F MainWindow.h f193166dbdafd922ba6513f16a6d12bda09a8ffc
|
||||
F MainWindow.ui 6f445eb6b5d58e54050d255420b6eac005a81eeb
|
||||
F RepoDialog.cpp 8f20e1511526973555c774350ec413dcecf51c9e
|
||||
F RepoDialog.h a958c5f98f1e6882bf41dbdd2e4df3cb89700802
|
||||
F RepoDialog.ui 8fe9b7f7528332ca9a45e919cf116aaf144a3286
|
||||
F icons/Address\sBook-01.png ef2cec80ea5a559b72e8be4a344a1869fe69cbd8
|
||||
F icons/Adobe\sIllustrator\sCS3\sDocument-01.png 2e44e933d58eefee7ccfa1650fed4ceadcf3c2be
|
||||
F icons/Adobe\sPDF\sDocument-01.png 8a0bc3ba633d08debde748d64b5a9675e30447a3
|
||||
@ -162,10 +165,10 @@ F icons/Zoom\sIn-01.png bdd24558fd23a1003f1a569f092f22022736f236
|
||||
F icons/Zoom\sOut-01.png 8eda092100d9e00c9097f43a80d1e26695947448
|
||||
F icons/Zoom-01.png 67ca532922e9166325c5c75fce1ca3fbb0d2b6a6
|
||||
F main.cpp f53e9e1e34f65565f06b2d37d7be5c38e2113a03
|
||||
F qtfossil.pro 728f1eec3adbcfc0e030cad1ea0867f765d9f179
|
||||
F qtfossil.pro.user 3aa11e8cc637ac9de0e6396307370f20bee7f62f
|
||||
F qtfossil.pro 047d5e691c772ef110e4eaef75ddba39a0142544
|
||||
F qtfossil.pro.user 46795d72c37bdb7016c9673180cecb5264713f50
|
||||
F resources.qrc e98383ed205f4e37100c60057e0129c3b86dea53
|
||||
P aea0b01c82bcd9caa71a5049c60e07ad6b3aed41
|
||||
R c84ec25e7c6ecb8c98cb5544d5a2d147
|
||||
P 9e35495cc3f4e18f458cf02f83d1d8075c0a85b9
|
||||
R 59296ed5593ab777a8dc300eeb4e43dc
|
||||
U kostas
|
||||
Z c73d16be1ed5c7fe4f1970c96b7dab6a
|
||||
Z 301a78f530bab5b00a799f65640fa487
|
||||
|
@ -1 +1 @@
|
||||
9e35495cc3f4e18f458cf02f83d1d8075c0a85b9
|
||||
2ac3cf9717f3529f809ffde1e802295988dfda05
|
12
qtfossil.pro
12
qtfossil.pro
@ -13,15 +13,18 @@ TEMPLATE = app
|
||||
SOURCES += main.cpp\
|
||||
MainWindow.cpp \
|
||||
CommitDialog.cpp \
|
||||
FileActionDialog.cpp
|
||||
FileActionDialog.cpp \
|
||||
RepoDialog.cpp
|
||||
|
||||
HEADERS += MainWindow.h \
|
||||
CommitDialog.h \
|
||||
FileActionDialog.h
|
||||
FileActionDialog.h \
|
||||
RepoDialog.h
|
||||
|
||||
FORMS += MainWindow.ui \
|
||||
CommitDialog.ui \
|
||||
FileActionDialog.ui
|
||||
FileActionDialog.ui \
|
||||
RepoDialog.ui
|
||||
|
||||
RESOURCES += \
|
||||
resources.qrc
|
||||
@ -32,3 +35,6 @@ RESOURCES += \
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by Qt Creator 2.2.82, 2011-08-04T00:26:04. -->
|
||||
<!-- Written by Qt Creator 2.2.82, 2011-08-05T00:47:26. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>ProjectExplorer.Project.ActiveTarget</variable>
|
||||
|
Loading…
x
Reference in New Issue
Block a user