🎨 Added clang-format

This commit is contained in:
Edgar 2021-09-23 15:40:55 +02:00
parent d6eaf13e78
commit 5dc8db6919
39 changed files with 4823 additions and 5072 deletions

25
.clang-format Normal file
View File

@ -0,0 +1,25 @@
Language: Cpp
AccessModifierOffset: -4
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: false
AllowShortLambdasOnASingleLine: Empty
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakBeforeMultilineStrings: false
BasedOnStyle: Microsoft
BreakBeforeBraces: Allman
BreakConstructorInitializers: AfterColon
BreakInheritanceList: AfterColon
ColumnLimit: 200
ConstructorInitializerAllOnOneLineOrOnePerLine: false
FixNamespaceComments: true
IndentCaseLabels: true
IndentWidth: 4
IndentWrappedFunctionNames: true
IndentPPDirectives: AfterHash
IncludeBlocks: Preserve
NamespaceIndentation: Inner
SpacesBeforeTrailingComments: 2
Standard: Auto
ReflowComments: false

View File

@ -2,9 +2,7 @@
#include "ui_AboutDialog.h"
#include <QFile>
AboutDialog::AboutDialog(QWidget *parent, const QString &fossilVersion) :
QDialog(parent),
ui(new Ui::AboutDialog)
AboutDialog::AboutDialog(QWidget *parent, const QString &fossilVersion) : QDialog(parent), ui(new Ui::AboutDialog)
{
ui->setupUi(this);
QString banner(QCoreApplication::applicationName() + " " + QCoreApplication::applicationVersion());

View File

@ -3,7 +3,8 @@
#include <QDialog>
namespace Ui {
namespace Ui
{
class AboutDialog;
}

View File

@ -1,11 +1,11 @@
#include "AppSettings.h"
#include <QSettings>
#include <QCoreApplication>
#include <QDir>
#include <QTranslator>
#include <QResource>
#include <QSettings>
#include <QTextCodec>
#include <QTranslator>
///////////////////////////////////////////////////////////////////////////////
Settings::Settings(bool portableMode) : store(0)
@ -37,7 +37,6 @@ Settings::Settings(bool portableMode) : store(0)
if (!HasValue(FUEL_SETTING_WEB_BROWSER))
SetValue(FUEL_SETTING_WEB_BROWSER, 0);
for (int i = 0; i < MAX_CUSTOM_ACTIONS; ++i)
{
CustomAction action;
@ -82,7 +81,6 @@ bool Settings::InstallLang(const QString &langId)
Q_ASSERT(!translator.isEmpty());
QCoreApplication::instance()->installTranslator(&translator);
return true;
}

View File

@ -2,8 +2,8 @@
#define APPSETTINGS_H
#include <QMap>
#include <QVariant>
#include <QTranslator>
#include <QVariant>
#include <QVector>
#define FUEL_SETTING_FOSSIL_PATH "FossilPath"
@ -19,7 +19,6 @@
#define FOSSIL_SETTING_CRNL_GLOB "crnl-glob"
#define FOSSIL_SETTING_HTTP_PORT "http-port"
enum FileDblClickAction
{
FILE_DLBCLICK_ACTION_DIFF,
@ -29,7 +28,6 @@ enum FileDblClickAction
FILE_DLBCLICK_ACTION_MAX
};
enum CustomActionContext
{
ACTION_CONTEXT_FILES = 1 << 0,
@ -37,7 +35,6 @@ enum CustomActionContext
ACTION_CONTEXT_FILES_AND_FOLDERS = ACTION_CONTEXT_FILES | ACTION_CONTEXT_FOLDERS
};
enum
{
MAX_CUSTOM_ACTIONS = 9
@ -51,20 +48,11 @@ struct CustomAction
CustomActionContext Context;
bool MultipleSelection;
CustomAction()
{
Clear();
}
CustomAction() { Clear(); }
bool IsValid() const
{
return !(Description.isEmpty() || Command.isEmpty());
}
bool IsValid() const { return !(Description.isEmpty() || Command.isEmpty()); }
bool IsActive(CustomActionContext context) const
{
return (Context & context) != 0;
}
bool IsActive(CustomActionContext context) const { return (Context & context) != 0; }
void Clear()
{
@ -85,15 +73,13 @@ struct Settings
TYPE_FOSSIL_LOCAL
};
Setting(QVariant value, SettingType type) : Value(value), Type(type)
{}
Setting(QVariant value, SettingType type) : Value(value), Type(type) {}
QVariant Value;
SettingType Type;
};
typedef QMap<QString, Setting> mappings_t;
typedef QVector<CustomAction> custom_actions_t;
Settings(bool portableMode = false);
~Settings();
@ -114,6 +100,7 @@ struct Settings
bool InstallLang(const QString &langId);
custom_actions_t &GetCustomActions() { return customActions; }
private:
mappings_t Mappings;
class QSettings *store;
@ -122,5 +109,4 @@ private:
custom_actions_t customActions;
};
#endif // APPSETTINGS_H

View File

@ -1,10 +1,8 @@
#include <QLineEdit>
#include "BrowserWidget.h"
#include "ui_BrowserWidget.h"
#include <QLineEdit>
BrowserWidget::BrowserWidget(QWidget *parent) :
QWidget(parent),
loading(false)
BrowserWidget::BrowserWidget(QWidget *parent) : QWidget(parent), loading(false)
{
ui = new Ui::BrowserWidget;
ui->setupUi(this);
@ -42,7 +40,6 @@ void BrowserWidget::on_webView_loadFinished(bool /*errorOccured*/)
ui->actionBrowserStop->setVisible(false);
}
void BrowserWidget::on_txtUrl_returnPressed()
{
QUrl url(ui->txtUrl->text());
@ -51,7 +48,6 @@ void BrowserWidget::on_txtUrl_returnPressed()
ui->webView->load(url);
}
void BrowserWidget::on_actionBrowserBack_triggered()
{
ui->webView->back();

View File

@ -1,10 +1,11 @@
#ifndef BROWSERWIDGET_H
#define BROWSERWIDGET_H
#include <QWidget>
#include <QUrl>
#include <QWidget>
namespace Ui {
namespace Ui
{
class BrowserWidget;
}

View File

@ -1,16 +1,14 @@
#include "CloneDialog.h"
#include "ui_CloneDialog.h"
#include <QFileDialog>
#include <QDir>
#include <QMessageBox>
#include <QClipboard>
#include <QUrl>
#include "Utils.h"
#include "ui_CloneDialog.h"
#include <QClipboard>
#include <QDir>
#include <QFileDialog>
#include <QMessageBox>
#include <QUrl>
//-----------------------------------------------------------------------------
CloneDialog::CloneDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::CloneDialog)
CloneDialog::CloneDialog(QWidget *parent) : QDialog(parent), ui(new Ui::CloneDialog)
{
ui->setupUi(this);
}
@ -90,13 +88,7 @@ void CloneDialog::GetRepositoryPath(QString &pathResult)
{
QString filter(tr("Fossil Repository") + QString(" (*." FOSSIL_EXT ")"));
pathResult = QFileDialog::getSaveFileName(
this,
tr("Select Fossil Repository"),
QDir::toNativeSeparators(pathResult),
filter,
&filter,
QFileDialog::DontConfirmOverwrite);
pathResult = QFileDialog::getSaveFileName(this, tr("Select Fossil Repository"), QDir::toNativeSeparators(pathResult), filter, &filter, QFileDialog::DontConfirmOverwrite);
// Ensure that it ends in the required extension (On GTK, Qt doesn't seem to add it automatically)
QFileInfo fi(pathResult);

View File

@ -3,7 +3,8 @@
#include <QDialog>
namespace Ui {
namespace Ui
{
class CloneDialog;
}

View File

@ -1,13 +1,11 @@
#include "CommitDialog.h"
#include "MainWindow.h" // Ugly. I know.
#include "ui_CommitDialog.h"
#include <QAction>
#include <QPushButton>
#include <QShortcut>
#include <QAction>
#include "ui_CommitDialog.h"
#include "MainWindow.h" // Ugly. I know.
CommitDialog::CommitDialog(QWidget *parent, const QString &title, QStringList &files, const QStringList *history, bool stashMode) :
QDialog(parent, Qt::Sheet),
ui(new Ui::CommitDialog)
CommitDialog::CommitDialog(QWidget *parent, const QString &title, QStringList &files, const QStringList *history, bool stashMode) : QDialog(parent, Qt::Sheet), ui(new Ui::CommitDialog)
{
ui->setupUi(this);
ui->plainTextEdit->clear();
@ -54,7 +52,6 @@ CommitDialog::CommitDialog(QWidget *parent, const QString &title, QStringList &f
itemModel.appendRow(si);
}
// Trigger commit with a Ctrl-Return from the comment box
QAction *action = new QAction(ui->plainTextEdit);
QShortcut *shortcut = new QShortcut(QKeySequence("Ctrl+Return"), ui->plainTextEdit);

View File

@ -4,7 +4,8 @@
#include <QDialog>
#include <QStandardItemModel>
namespace Ui {
namespace Ui
{
class CommitDialog;
}

View File

@ -1,8 +1,7 @@
#include "CustomWebView.h"
#include <QMouseEvent>
CustomWebView::CustomWebView(QWidget *parent) :
QWebEngineView(parent)
CustomWebView::CustomWebView(QWidget *parent) : QWebEngineView(parent)
{
setUrl(QUrl("about:blank"));
}

View File

@ -15,7 +15,6 @@ public slots:
protected:
virtual void mousePressEvent(QMouseEvent *event);
};
#endif // CUSTOMWEBVIEW_H

View File

@ -1,11 +1,9 @@
#include <QCheckBox>
#include "FileActionDialog.h"
#include "ui_FileActionDialog.h"
#include <QCheckBox>
FileActionDialog::FileActionDialog(QWidget *parent, const QString &title, const QString &message, const QStringList &listData, const QString &checkBoxText, bool *checkBoxResult) :
QDialog(parent, Qt::Sheet),
ui(new Ui::FileActionDialog),
clickedButton(QDialogButtonBox::NoButton)
QDialog(parent, Qt::Sheet), ui(new Ui::FileActionDialog), clickedButton(QDialogButtonBox::NoButton)
{
ui->setupUi(this);
setWindowTitle(title);
@ -61,4 +59,3 @@ void FileActionDialog::on_buttonBox_clicked(QAbstractButton *button)
// Retrieve the flag corresponding to the standard clicked
clickedButton = ui->buttonBox->standardButton(button);
}

View File

@ -2,10 +2,11 @@
#define FILEACTIONDIALOG_H
#include <QDialog>
#include <QStandardItemModel>
#include <QDialogButtonBox>
#include <QStandardItemModel>
namespace Ui {
namespace Ui
{
class FileActionDialog;
}
@ -23,7 +24,6 @@ public:
static StandardButton runStandardButtons(QWidget *parent, StandardButtons, const QString &title, const QString &message, const QStringList &listData);
private slots:
void on_buttonBox_clicked(QAbstractButton *button);

View File

@ -1,11 +1,8 @@
#include "FileTableView.h"
#include <QMouseEvent>
#include <QApplication>
#include <QMouseEvent>
FileTableView::FileTableView(QWidget *parent) :
QTableView(parent)
{
}
FileTableView::FileTableView(QWidget *parent) : QTableView(parent) {}
//------------------------------------------------------------------------------
void FileTableView::mousePressEvent(QMouseEvent *event)
@ -27,5 +24,4 @@ void FileTableView::mouseMoveEvent(QMouseEvent *event)
}
else
QTableView::mouseMoveEvent(event);
}

View File

@ -1,8 +1,8 @@
#ifndef FILETABLEVIEW_H
#define FILETABLEVIEW_H
#include <QTableView>
#include <QPoint>
#include <QTableView>
class FileTableView : public QTableView
{

View File

@ -1,20 +1,17 @@
#include "Fossil.h"
#include <QStringList>
#include "Utils.h"
#include <QCoreApplication>
#include <QTextCodec>
#include <QDebug>
#include <QDir>
#include <QStringList>
#include <QTemporaryFile>
#include <QTextCodec>
#include <QUrl>
#include "Utils.h"
static const unsigned char UTF8_BOM[] = {0xEF, 0xBB, 0xBF};
///////////////////////////////////////////////////////////////////////////////
Fossil::Fossil()
: uiCallback(0)
{
}
Fossil::Fossil() : uiCallback(0) {}
///////////////////////////////////////////////////////////////////////////////
void Fossil::Init(UICallback *callback, const QString &exePath)
@ -139,7 +136,9 @@ void Fossil::setWorkspace(const QString &_workspacePath)
//------------------------------------------------------------------------------
bool Fossil::listFiles(QStringList &files)
{
return runFossil(QStringList() << "ls" << "-l", &files, RUNFLAGS_SILENT_ALL);
return runFossil(QStringList() << "ls"
<< "-l",
&files, RUNFLAGS_SILENT_ALL);
}
//------------------------------------------------------------------------------
@ -207,7 +206,8 @@ bool Fossil::cloneRepository(const QString& repository, const QUrl& url, const Q
QStringList cmd = QStringList() << "clone";
// Log Command
QStringList logcmd = QStringList() << "fossil" << "clone";
QStringList logcmd = QStringList() << "fossil"
<< "clone";
QString source = url.toString();
QString logsource = url.toString(QUrl::RemovePassword);
@ -290,7 +290,8 @@ bool Fossil::commitFiles(const QStringList& fileList, const QString& comment, co
// Generate fossil parameters.
QStringList params;
params << "commit" << "--message-file" << QuotePath(comment_fname);
params << "commit"
<< "--message-file" << QuotePath(comment_fname);
// Commit to new branch
if (!newBranchName.isEmpty())
@ -399,7 +400,6 @@ bool Fossil::updateWorkspace(QStringList &result, const QString &revision, bool
else
params << revision;
result.clear();
return runFossil(params, &result);
}
@ -489,7 +489,9 @@ bool Fossil::stashList(stashmap_t& stashes)
stashes.clear();
QStringList res;
if(!runFossil(QStringList() << "stash" << "ls", &res, RUNFLAGS_SILENT_ALL))
if (!runFossil(QStringList() << "stash"
<< "ls",
&res, RUNFLAGS_SILENT_ALL))
return false;
// 19: [5c46757d4b9765] on 2012-04-22 04:41:15
@ -527,19 +529,23 @@ bool Fossil::stashList(stashmap_t& stashes)
//------------------------------------------------------------------------------
bool Fossil::stashApply(const QString &name)
{
return runFossil(QStringList() << "stash" << "apply" << name);
return runFossil(QStringList() << "stash"
<< "apply" << name);
}
//------------------------------------------------------------------------------
bool Fossil::stashDrop(const QString &name)
{
return runFossil(QStringList() << "stash" << "drop" << name);
return runFossil(QStringList() << "stash"
<< "drop" << name);
}
//------------------------------------------------------------------------------
bool Fossil::stashDiff(const QString &name)
{
return runFossil(QStringList() << "stash" << "diff" << name, 0);
return runFossil(QStringList() << "stash"
<< "diff" << name,
0);
}
//------------------------------------------------------------------------------
@ -548,7 +554,9 @@ bool Fossil::tagList(QStringMap& tags)
tags.clear();
QStringList tagnames;
if(!runFossil(QStringList() << "tag" << "ls", &tagnames, RUNFLAGS_SILENT_ALL))
if (!runFossil(QStringList() << "tag"
<< "ls",
&tagnames, RUNFLAGS_SILENT_ALL))
return false;
QStringList info;
@ -562,7 +570,9 @@ bool Fossil::tagList(QStringMap& tags)
info.clear();
// Use "whatis" instead of "info" to get extra information like the closed raw-tag
if(!runFossil(QStringList() << "whatis" << "tag:"+tag, &info, RUNFLAGS_SILENT_ALL))
if (!runFossil(QStringList() << "whatis"
<< "tag:" + tag,
&info, RUNFLAGS_SILENT_ALL))
return false;
/*
@ -607,7 +617,9 @@ bool Fossil::tagNew(const QString& name, const QString& revision)
{
QStringList res;
if(!runFossil(QStringList() << "tag" << "add" << name << revision, &res))
if (!runFossil(QStringList() << "tag"
<< "add" << name << revision,
&res))
return false;
return true;
}
@ -617,7 +629,10 @@ bool Fossil::tagDelete(const QString& name, const QString &revision)
{
QStringList res;
if(!runFossil(QStringList() << "tag" << "cancel" << "tag:"+name << revision, &res))
if (!runFossil(QStringList() << "tag"
<< "cancel"
<< "tag:" + name << revision,
&res))
return false;
return true;
@ -664,7 +679,8 @@ bool Fossil::branchNew(const QString& name, const QString& revisionBasis, bool i
{
QStringList params;
params <<"branch" << "new" << name << revisionBasis;
params << "branch"
<< "new" << name << revisionBasis;
if (isPrivate)
params << "--private";
@ -1113,7 +1129,8 @@ bool Fossil::startUI(const QString &httpPort)
QString fossil = getFossilPath();
QStringList params;
params << "server" << "--localauth";
params << "server"
<< "--localauth";
if (!httpPort.isEmpty())
params << "-P" << httpPort;

View File

@ -2,17 +2,16 @@
#define FOSSIL_H
class QStringList;
#include <QString>
#include <QStringList>
#include <QUrl>
#include "LoggedProcess.h"
#include "Utils.h"
#include "WorkspaceCommon.h"
#include <QString>
#include <QStringList>
#include <QUrl>
class Fossil
{
public:
Fossil();
void Init(UICallback *callback, const QString &exePath);
@ -118,5 +117,4 @@ private:
QString fossilUIPort;
};
#endif // FOSSIL_H

View File

@ -1,14 +1,11 @@
#include "FslSettingsDialog.h"
#include "ui_FslSettingsDialog.h"
#include "Utils.h"
#include "ui_FslSettingsDialog.h"
#include <QDir>
///////////////////////////////////////////////////////////////////////////////
FslSettingsDialog::FslSettingsDialog(QWidget *parent, Settings &_settings) :
QDialog(parent, Qt::Sheet),
ui(new Ui::FslSettingsDialog),
settings(&_settings)
FslSettingsDialog::FslSettingsDialog(QWidget *parent, Settings &_settings) : QDialog(parent, Qt::Sheet), ui(new Ui::FslSettingsDialog), settings(&_settings)
{
ui->setupUi(this);
@ -67,4 +64,3 @@ void FslSettingsDialog::on_btnSelectGMerge_clicked()
if (!path.isEmpty())
ui->lineGMergeCommand->setText(path);
}

View File

@ -1,10 +1,11 @@
#ifndef FSLSETTINGSDIALOG_H
#define FSLSETTINGSDIALOG_H
#include <QDialog>
#include "AppSettings.h"
#include <QDialog>
namespace Ui {
namespace Ui
{
class FslSettingsDialog;
}
@ -18,14 +19,12 @@ public:
static bool run(QWidget *parent, Settings &_settings);
private slots:
void on_buttonBox_accepted();
void on_btnSelectFossilGDiff_clicked();
void on_btnSelectGMerge_clicked();
private:
Ui::FslSettingsDialog *ui;
Settings *settings;
};

View File

@ -19,4 +19,3 @@ void LoggedProcess::onReadyReadStandardOutput()
QMutexLocker lck(&mutex);
log.append(readAllStandardOutput());
}

View File

@ -1,8 +1,8 @@
#ifndef LOGGEDPROCESS_H
#define LOGGEDPROCESS_H
#include <QProcess>
#include <QMutex>
#include <QProcess>
class LoggedProcess : public QProcess
{

View File

@ -1,4 +1,14 @@
#include "MainWindow.h"
#include "AboutDialog.h"
#include "CloneDialog.h"
#include "CommitDialog.h"
#include "FileActionDialog.h"
#include "FslSettingsDialog.h"
#include "RemoteDialog.h"
#include "RevisionDialog.h"
#include "SearchBox.h"
#include "SettingsDialog.h"
#include "Utils.h"
#include "ui_MainWindow.h"
#include <QDateTime>
#include <QDebug>
@ -7,22 +17,12 @@
#include <QDragEnterEvent>
#include <QFileDialog>
#include <QInputDialog>
#include <QLabel>
#include <QMimeData>
#include <QProgressBar>
#include <QToolButton>
#include <QLabel>
#include <QSettings>
#include <QShortcut>
#include "SettingsDialog.h"
#include "FslSettingsDialog.h"
#include "SearchBox.h"
#include "CommitDialog.h"
#include "FileActionDialog.h"
#include "CloneDialog.h"
#include "RevisionDialog.h"
#include "RemoteDialog.h"
#include "AboutDialog.h"
#include "Utils.h"
#include <QToolButton>
//-----------------------------------------------------------------------------
enum
@ -70,17 +70,9 @@ struct WorkspaceItem
STATE_UNKNOWN
};
WorkspaceItem() : Type(TYPE_UNKNOWN), State(STATE_DEFAULT) {}
WorkspaceItem()
: Type(TYPE_UNKNOWN)
, State(STATE_DEFAULT)
{
}
WorkspaceItem(int type, const QString &value, int state=STATE_DEFAULT)
: Type(type), State(state), Value(value)
{
}
WorkspaceItem(int type, const QString &value, int state = STATE_DEFAULT) : Type(type), State(state), Value(value) {}
WorkspaceItem(const WorkspaceItem &other)
{
@ -93,19 +85,12 @@ struct WorkspaceItem
int State;
QString Value;
operator QVariant() const
{
return QVariant::fromValue(*this);
}
operator QVariant() const { return QVariant::fromValue(*this); }
};
Q_DECLARE_METATYPE(WorkspaceItem)
///////////////////////////////////////////////////////////////////////////////
MainWindow::MainWindow(Settings &_settings, QWidget *parent, QString *workspacePath) :
QMainWindow(parent),
ui(new Ui::MainWindow),
settings(_settings)
MainWindow::MainWindow(Settings &_settings, QWidget *parent, QString *workspacePath) : QMainWindow(parent), ui(new Ui::MainWindow), settings(_settings)
{
ui->setupUi(this);
@ -131,10 +116,7 @@ MainWindow::MainWindow(Settings &_settings, QWidget *parent, QString *workspaceP
ui->fileTableView->addAction(ui->actionRename);
ui->fileTableView->addAction(ui->actionDelete);
connect( ui->fileTableView,
SIGNAL( dragOutEvent() ),
SLOT( onFileViewDragOut() ),
Qt::DirectConnection );
connect(ui->fileTableView, SIGNAL(dragOutEvent()), SLOT(onFileViewDragOut()), Qt::DirectConnection);
QStringList header;
header << tr("Status") << tr("File") << tr("Extension") << tr("Modified") << tr("Path");
@ -157,10 +139,8 @@ MainWindow::MainWindow(Settings &_settings, QWidget *parent, QString *workspaceP
header << tr("Workspace");
getWorkspace().getTreeModel().setHorizontalHeaderLabels(header);
connect( ui->workspaceTreeView->selectionModel(),
SIGNAL( selectionChanged(const QItemSelection &, const QItemSelection &) ),
SLOT( onWorkspaceTreeViewSelectionChanged(const QItemSelection &, const QItemSelection &) ),
Qt::DirectConnection );
connect(ui->workspaceTreeView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)),
SLOT(onWorkspaceTreeViewSelectionChanged(const QItemSelection &, const QItemSelection &)), Qt::DirectConnection);
// Workspace Menus
menuWorkspace = new QMenu(this);
@ -306,10 +286,7 @@ MainWindow::MainWindow(Settings &_settings, QWidget *parent, QString *workspaceP
searchBox->setMinimumWidth(230);
ui->mainToolBar->addWidget(searchBox);
connect( searchBox,
SIGNAL( textChanged(const QString&)),
SLOT( onSearchBoxTextChanged(const QString&)),
Qt::DirectConnection );
connect(searchBox, SIGNAL(textChanged(const QString &)), SLOT(onSearchBoxTextChanged(const QString &)), Qt::DirectConnection);
// Add another spacer to the right
spacer = new QWidget();
@ -395,10 +372,7 @@ bool MainWindow::openWorkspace(const QString &path)
{
if (QMessageBox::Yes != DialogQuery(this, tr("Open Workspace"), tr("A workspace does not exist in this folder.\nWould you like to create one here?")))
{
wkspace = QFileDialog::getExistingDirectory(
this,
tr("Select Workspace Folder"),
wkspace);
wkspace = QFileDialog::getExistingDirectory(this, tr("Select Workspace Folder"), wkspace);
if (wkspace.isEmpty() || !QDir(wkspace).exists())
return false;
@ -410,7 +384,6 @@ bool MainWindow::openWorkspace(const QString &path)
QMessageBox::critical(this, tr("Error"), tr("Could not open repository."), QMessageBox::Ok);
return false;
}
}
else
{
@ -455,12 +428,7 @@ void MainWindow::on_actionOpenRepository_triggered()
{
QString filter(tr("Fossil Files") + QString(" (*." FOSSIL_EXT " " FOSSIL_CHECKOUT1 " " FOSSIL_CHECKOUT2 ")"));
QString path = QFileDialog::getOpenFileName(
this,
tr("Open Fossil Repository"),
QDir::currentPath(),
filter,
&filter);
QString path = QFileDialog::getOpenFileName(this, tr("Open Fossil Repository"), QDir::currentPath(), filter, &filter);
if (path.isEmpty())
return;
@ -473,12 +441,7 @@ void MainWindow::on_actionNewRepository_triggered()
QString filter(tr("Fossil Repositories") + QString(" (*." FOSSIL_EXT ")"));
// Get Repository file
QString repo_path = QFileDialog::getSaveFileName(
this,
tr("New Fossil Repository"),
QDir::currentPath(),
filter,
&filter);
QString repo_path = QFileDialog::getSaveFileName(this, tr("New Fossil Repository"), QDir::currentPath(), filter, &filter);
if (repo_path.isEmpty())
return;
@ -496,10 +459,7 @@ void MainWindow::on_actionNewRepository_triggered()
QString wkdir = repo_path_info.absoluteDir().absolutePath();
if (QMessageBox::Yes != DialogQuery(this, tr("Create Workspace"), tr("Would you like to create a workspace in the same folder?")))
{
wkdir = QFileDialog::getExistingDirectory(
this,
tr("Select Workspace Folder"),
wkdir);
wkdir = QFileDialog::getExistingDirectory(this, tr("Select Workspace Folder"), wkdir);
if (wkdir.isEmpty() || !QDir(wkdir).exists())
return;
@ -636,48 +596,18 @@ void MainWindow::onOpenRecent()
openWorkspace(workspace);
}
//------------------------------------------------------------------------------
void MainWindow::enableActions(bool on)
{
QAction *actions[] = {
ui->actionCloseRepository,
ui->actionCommit,
ui->actionDiff,
ui->actionAdd,
ui->actionDelete,
ui->actionPush,
ui->actionPull,
ui->actionRename,
ui->actionHistory,
ui->actionFossilUI,
ui->actionRevert,
ui->actionTimeline,
ui->actionOpenFile,
ui->actionOpenContaining,
ui->actionUndo,
ui->actionUpdate,
ui->actionOpenFolder,
ui->actionRenameFolder,
ui->actionCreateStash,
ui->actionDeleteStash,
ui->actionDiffStash,
ui->actionApplyStash,
ui->actionDeleteStash,
ui->actionCreateTag,
ui->actionDeleteTag,
ui->actionCreateBranch,
ui->actionMergeBranch,
ui->actionFossilSettings,
ui->actionViewAll,
ui->actionViewAsFolders,
ui->actionViewAsList,
ui->actionViewIgnored,
ui->actionViewModifedOnly,
ui->actionViewModified,
ui->actionViewUnchanged,
ui->actionViewUnknown
};
QAction *actions[] = {ui->actionCloseRepository, ui->actionCommit, ui->actionDiff, ui->actionAdd,
ui->actionDelete, ui->actionPush, ui->actionPull, ui->actionRename,
ui->actionHistory, ui->actionFossilUI, ui->actionRevert, ui->actionTimeline,
ui->actionOpenFile, ui->actionOpenContaining, ui->actionUndo, ui->actionUpdate,
ui->actionOpenFolder, ui->actionRenameFolder, ui->actionCreateStash, ui->actionDeleteStash,
ui->actionDiffStash, ui->actionApplyStash, ui->actionDeleteStash, ui->actionCreateTag,
ui->actionDeleteTag, ui->actionCreateBranch, ui->actionMergeBranch, ui->actionFossilSettings,
ui->actionViewAll, ui->actionViewAsFolders, ui->actionViewAsList, ui->actionViewIgnored,
ui->actionViewModifedOnly, ui->actionViewModified, ui->actionViewUnchanged, ui->actionViewUnknown};
for (size_t i = 0; i < COUNTOF(actions); ++i)
actions[i]->setEnabled(on);
@ -752,13 +682,8 @@ bool MainWindow::scanWorkspace()
TrimStringList(ignore_patterns);
}
getWorkspace().scanWorkspace(ui->actionViewUnknown->isChecked(),
ui->actionViewIgnored->isChecked(),
ui->actionViewModified->isChecked(),
ui->actionViewUnchanged->isChecked(),
ignore_patterns,
uiCallback
);
getWorkspace().scanWorkspace(ui->actionViewUnknown->isChecked(), ui->actionViewIgnored->isChecked(), ui->actionViewModified->isChecked(), ui->actionViewUnchanged->isChecked(), ignore_patterns,
uiCallback);
// Build default versions list
versionList += getWorkspace().getBranches();
@ -777,7 +702,8 @@ bool MainWindow::scanWorkspace()
}
//------------------------------------------------------------------------------
static void addPathToTree(QStandardItem &root, const QString &path, const QIcon &iconDefault, const QIcon &iconUnchanged, const QIcon &iconModified, const QIcon &iconUnknown, const pathstate_map_t &pathState)
static void addPathToTree(QStandardItem &root, const QString &path, const QIcon &iconDefault, const QIcon &iconUnchanged, const QIcon &iconModified, const QIcon &iconUnknown,
const pathstate_map_t &pathState)
{
QStringList dirs = path.split(PATH_SEPARATOR);
QStandardItem *parent = &root;
@ -891,12 +817,8 @@ void MainWindow::updateWorkspaceView()
if (dir.isEmpty())
continue;
addPathToTree(*workspace, dir,
getCachedIcon(":icons/icon-item-folder"),
getCachedIcon(":icons/icon-item-folder-unchanged"),
getCachedIcon(":icons/icon-item-folder-modified"),
getCachedIcon(":icons/icon-item-folder-unknown"),
getWorkspace().getPathState());
addPathToTree(*workspace, dir, getCachedIcon(":icons/icon-item-folder"), getCachedIcon(":icons/icon-item-folder-unchanged"), getCachedIcon(":icons/icon-item-folder-modified"),
getCachedIcon(":icons/icon-item-folder-unknown"), getWorkspace().getPathState());
}
// Expand root folder
@ -1008,9 +930,12 @@ void MainWindow::updateFileView()
// Clear content except headers
getWorkspace().getFileModel().removeRows(0, getWorkspace().getFileModel().rowCount());
struct { WorkspaceFile::Type type; QString text; const char *icon; }
stats[] =
struct
{
WorkspaceFile::Type type;
QString text;
const char *icon;
} stats[] = {
{WorkspaceFile::TYPE_EDITTED, tr("Edited"), ":icons/icon-item-edited"},
{WorkspaceFile::TYPE_UNCHANGED, tr("Unchanged"), ":icons/icon-item-unchanged"},
{WorkspaceFile::TYPE_ADDED, tr("Added"), ":icons/icon-item-added"},
@ -1150,11 +1075,9 @@ void MainWindow::applySettings()
int cur_index = ui->fileTableView->horizontalHeader()->visualIndex(i);
ui->fileTableView->horizontalHeader()->moveSection(cur_index, index);
}
}
store->endArray();
if (store->contains("WindowX") && store->contains("WindowY"))
{
QPoint _pos;
@ -1190,7 +1113,6 @@ void MainWindow::applySettings()
if (!active_workspace.isEmpty())
setCurrentWorkspace(active_workspace);
// Custom Actions
for (int i = 0; i < MAX_CUSTOM_ACTIONS; ++i)
settings.GetCustomActions()[i].Clear();
@ -1395,7 +1317,6 @@ void MainWindow::getDirViewSelection(QStringList &filenames, int includeMask, bo
filenames.append(e.getFilePath());
}
}
//------------------------------------------------------------------------------
@ -1656,7 +1577,8 @@ void MainWindow::on_actionDelete_triggered()
bool remove_local = false;
if(!FileActionDialog::run(this, tr("Remove files"), tr("The following files will be removed from the repository.")+"\n"+tr("Are you sure?"), all_files, tr("Also delete the local files"), &remove_local ))
if (!FileActionDialog::run(this, tr("Remove files"), tr("The following files will be removed from the repository.") + "\n" + tr("Are you sure?"), all_files, tr("Also delete the local files"),
&remove_local))
return;
// Remove repository files
@ -2029,9 +1951,7 @@ void MainWindow::on_actionRenameFolder_triggered()
if (!ok || old_name == new_name)
return;
const char* invalid_tokens[] = {
"/", "\\", "\\\\", ":", ">", "<", "*", "?", "|", "\"", ".."
};
const char *invalid_tokens[] = {"/", "\\", "\\\\", ":", ">", "<", "*", "?", "|", "\"", ".."};
for (size_t i = 0; i < COUNTOF(invalid_tokens); ++i)
{
@ -2070,10 +1990,13 @@ void MainWindow::on_actionRenameFolder_triggered()
return;
bool move_local = false;
if(!FileActionDialog::run(this, tr("Rename Folder"), tr("Renaming folder '%0' to '%1'\n"
"The following files will be moved in the repository.").arg(old_path, new_path)+"\n"+tr("Are you sure?"),
operations,
tr("Also move the workspace files"), &move_local)) {
if (!FileActionDialog::run(this, tr("Rename Folder"),
tr("Renaming folder '%0' to '%1'\n"
"The following files will be moved in the repository.")
.arg(old_path, new_path) +
"\n" + tr("Are you sure?"),
operations, tr("Also move the workspace files"), &move_local))
{
return;
}
@ -2378,7 +2301,6 @@ void MainWindow::on_fileTableView_customContextMenuRequested(const QPoint &pos)
menu->addActions(ui->fileTableView->actions());
menu->popup(gpos);
}
}
//------------------------------------------------------------------------------

View File

@ -1,13 +1,14 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QStringList>
#include <QFileIconProvider>
#include "AppSettings.h"
#include "Workspace.h"
#include <QFileIconProvider>
#include <QMainWindow>
#include <QStringList>
namespace Ui {
namespace Ui
{
class MainWindow;
}
@ -140,13 +141,9 @@ private:
class MainWinUICallback : public UICallback
{
public:
MainWinUICallback() : mainWindow(0), aborted(false)
{}
MainWinUICallback() : mainWindow(0), aborted(false) {}
void init(class MainWindow *mainWindow)
{
this->mainWindow = mainWindow;
}
void init(class MainWindow *mainWindow) { this->mainWindow = mainWindow; }
virtual void logText(const QString &text, bool isHTML);
virtual void beginProcess(const QString &text);
@ -207,4 +204,3 @@ private:
};
#endif // MAINWINDOW_H

View File

@ -1,16 +1,14 @@
#include "RemoteDialog.h"
#include "ui_RemoteDialog.h"
#include <QFileDialog>
#include <QDir>
#include <QMessageBox>
#include <QClipboard>
#include <QUrl>
#include "Utils.h"
#include "ui_RemoteDialog.h"
#include <QClipboard>
#include <QDir>
#include <QFileDialog>
#include <QMessageBox>
#include <QUrl>
//-----------------------------------------------------------------------------
RemoteDialog::RemoteDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::RemoteDialog)
RemoteDialog::RemoteDialog(QWidget *parent) : QDialog(parent), ui(new Ui::RemoteDialog)
{
ui->setupUi(this);
}
@ -78,13 +76,7 @@ void RemoteDialog::GetRepositoryPath(QString &pathResult)
{
QString filter(tr("Fossil Repository") + QString(" (*." FOSSIL_EXT ")"));
pathResult = QFileDialog::getSaveFileName(
this,
tr("Select Fossil Repository"),
QDir::toNativeSeparators(pathResult),
filter,
&filter,
QFileDialog::DontConfirmOverwrite);
pathResult = QFileDialog::getSaveFileName(this, tr("Select Fossil Repository"), QDir::toNativeSeparators(pathResult), filter, &filter, QFileDialog::DontConfirmOverwrite);
}
//-----------------------------------------------------------------------------
@ -104,4 +96,3 @@ void RemoteDialog::on_btnSelectSourceRepo_clicked()
ui->lineURL->setText(QDir::toNativeSeparators(path));
}

View File

@ -3,7 +3,8 @@
#include <QDialog>
namespace Ui {
namespace Ui
{
class RemoteDialog;
}

View File

@ -1,12 +1,9 @@
#include "RevisionDialog.h"
#include "ui_RevisionDialog.h"
#include "Utils.h"
#include "ui_RevisionDialog.h"
//-----------------------------------------------------------------------------
RevisionDialog::RevisionDialog(QWidget *parent, const QStringList &completions, const QString &defaultValue) :
QDialog(parent),
ui(new Ui::RevisionDialog),
completer(completions, parent)
RevisionDialog::RevisionDialog(QWidget *parent, const QStringList &completions, const QString &defaultValue) : QDialog(parent), ui(new Ui::RevisionDialog), completer(completions, parent)
{
ui->setupUi(this);
ui->cmbRevision->setCompleter(&completer);
@ -75,7 +72,6 @@ QString RevisionDialog::runMerge(QWidget *parent, const QString &title, const QS
return dlg.ui->cmbRevision->currentText().trimmed();
}
//-----------------------------------------------------------------------------
bool RevisionDialog::runNewTag(QWidget *parent, const QString &title, const QStringList &completions, const QString &defaultValue, QString &revision, QString &name)
{

View File

@ -1,10 +1,11 @@
#ifndef REVISIONDIALOG_H
#define REVISIONDIALOG_H
#include <QDialog>
#include <QCompleter>
#include <QDialog>
namespace Ui {
namespace Ui
{
class RevisionDialog;
}

View File

@ -1,14 +1,9 @@
#include "SearchBox.h"
#include <QKeyEvent>
SearchBox::SearchBox(QWidget *parent) : QLineEdit(parent)
{
}
SearchBox::SearchBox(QWidget *parent) : QLineEdit(parent) {}
SearchBox::~SearchBox()
{
}
SearchBox::~SearchBox() {}
void SearchBox::keyPressEvent(QKeyEvent *event)
{
@ -21,4 +16,3 @@ void SearchBox::keyPressEvent(QKeyEvent *event)
else
QLineEdit::keyPressEvent(event);
}

View File

@ -16,8 +16,6 @@ public slots:
protected:
void keyPressEvent(QKeyEvent *event);
};
#endif // SEARCHBOX_H

View File

@ -1,14 +1,11 @@
#include "SettingsDialog.h"
#include "ui_SettingsDialog.h"
#include "Utils.h"
#include "ui_SettingsDialog.h"
#include <QDir>
///////////////////////////////////////////////////////////////////////////////
SettingsDialog::SettingsDialog(QWidget *parent, Settings &_settings) :
QDialog(parent, Qt::Sheet),
ui(new Ui::SettingsDialog),
settings(&_settings)
SettingsDialog::SettingsDialog(QWidget *parent, Settings &_settings) : QDialog(parent, Qt::Sheet), ui(new Ui::SettingsDialog), settings(&_settings)
{
ui->setupUi(this);
@ -33,10 +30,7 @@ SettingsDialog::SettingsDialog(QWidget *parent, Settings &_settings) :
QString lang = settings->GetValue(FUEL_SETTING_LANGUAGE).toString();
// Select current language
ui->cmbActiveLanguage->setCurrentIndex(
ui->cmbActiveLanguage->findText(
LangIdToName(lang)));
ui->cmbActiveLanguage->setCurrentIndex(ui->cmbActiveLanguage->findText(LangIdToName(lang)));
lastActionIndex = 0;
currentCustomActions = settings->GetCustomActions();

View File

@ -1,10 +1,11 @@
#ifndef SETTINGSDIALOG_H
#define SETTINGSDIALOG_H
#include <QDialog>
#include "AppSettings.h"
#include <QDialog>
namespace Ui {
namespace Ui
{
class SettingsDialog;
}
@ -18,7 +19,6 @@ public:
static bool run(QWidget *parent, Settings &_settings);
private slots:
void on_btnSelectFossil_clicked();
void on_buttonBox_accepted();
@ -36,10 +36,7 @@ private:
struct LangMap
{
LangMap(const QString &_id, const QString &_name)
: id(_id), name(_name)
{
}
LangMap(const QString &_id, const QString &_name) : id(_id), name(_name) {}
QString id;
QString name;

View File

@ -1,11 +1,11 @@
#include "Utils.h"
#include <QMessageBox>
#include <QDialogButtonBox>
#include <QFileDialog>
#include <QEventLoop>
#include <QUrl>
#include <QProcess>
#include <QCryptographicHash>
#include <QDialogButtonBox>
#include <QEventLoop>
#include <QFileDialog>
#include <QMessageBox>
#include <QProcess>
#include <QUrl>
#include <qt5keychain/keychain.h>
///////////////////////////////////////////////////////////////////////////////
@ -44,12 +44,7 @@ QString SelectExe(QWidget *parent, const QString &description)
#else
filter += " (*)";
#endif
QString path = QFileDialog::getOpenFileName(
parent,
description,
QString(),
filter,
&filter);
QString path = QFileDialog::getOpenFileName(parent, description, QString(), filter, &filter);
if (!QFile::exists(path))
return QString();
@ -92,7 +87,6 @@ static bool DialogQueryText(QWidget *parent, const QString &title, const QString
}
#endif
#ifdef Q_OS_WIN
// Explorer File Context Menu support. Based on http://www.microsoft.com/msj/0497/wicked/wicked0497.aspx
# include <shlobj.h>
@ -150,7 +144,8 @@ bool ShowExplorerMenu(HWND hwnd, const QString &path, const QPoint &qpoint)
UINT nCount;
nCount = 0;
while ((nLen = pidl->mkid.cb) != 0) {
while ((nLen = pidl->mkid.cb) != 0)
{
pidl = GetNextItem(pidl);
nCount++;
}
@ -183,8 +178,7 @@ bool ShowExplorerMenu(HWND hwnd, const QString &path, const QPoint &qpoint)
if (nLen == 0)
return NULL;
pidlNew = (LPITEMIDLIST) pMalloc->Alloc (
nLen + sizeof (USHORT));
pidlNew = (LPITEMIDLIST)pMalloc->Alloc(nLen + sizeof(USHORT));
if (pidlNew == NULL)
return NULL;
@ -195,7 +189,6 @@ bool ShowExplorerMenu(HWND hwnd, const QString &path, const QPoint &qpoint)
}
};
LPITEMIDLIST pidlMain, pidlItem, pidlNextItem, *ppidl;
UINT nCount;
POINT point;
@ -218,7 +211,8 @@ bool ShowExplorerMenu(HWND hwnd, const QString &path, const QPoint &qpoint)
return bResult;
LPSHELLFOLDER psfFolder;
if (!SUCCEEDED (SHGetDesktopFolder (&psfFolder))) {
if (!SUCCEEDED(SHGetDesktopFolder(&psfFolder)))
{
pMalloc->Release();
return bResult;
}
@ -227,10 +221,11 @@ bool ShowExplorerMenu(HWND hwnd, const QString &path, const QPoint &qpoint)
// Convert the path name into a pointer to an item ID list (pidl).
//
ULONG ulCount, ulAttr;
if (SUCCEEDED (psfFolder->ParseDisplayName (hwnd,
NULL, wchPath, &ulCount, &pidlMain, &ulAttr)) && (pidlMain != NULL)) {
if (SUCCEEDED(psfFolder->ParseDisplayName(hwnd, NULL, wchPath, &ulCount, &pidlMain, &ulAttr)) && (pidlMain != NULL))
{
if ( (nCount = Util::GetItemCount (pidlMain))>0) { // nCount must be > 0
if ((nCount = Util::GetItemCount(pidlMain)) > 0)
{ // nCount must be > 0
//
// Initialize psfFolder with a pointer to the IShellFolder
// interface of the folder that contains the item whose context
@ -241,12 +236,14 @@ bool ShowExplorerMenu(HWND hwnd, const QString &path, const QPoint &qpoint)
//
pidlItem = pidlMain;
while (--nCount) {
while (--nCount)
{
//
// Create a 1-item item ID list for the next item in pidlMain.
//
pidlNextItem = Util::DuplicateItem(pMalloc, pidlItem);
if (pidlNextItem == NULL) {
if (pidlNextItem == NULL)
{
pMalloc->Free(pidlMain);
psfFolder->Release();
pMalloc->Release();
@ -257,8 +254,8 @@ bool ShowExplorerMenu(HWND hwnd, const QString &path, const QPoint &qpoint)
// Bind to the folder specified in the new item ID list.
//
LPSHELLFOLDER psfNextFolder;
if (!SUCCEEDED (psfFolder->BindToObject (
pidlNextItem, NULL, IID_IShellFolder, (void**)&psfNextFolder))) {
if (!SUCCEEDED(psfFolder->BindToObject(pidlNextItem, NULL, IID_IShellFolder, (void **)&psfNextFolder)))
{
pMalloc->Free(pidlNextItem);
pMalloc->Free(pidlMain);
psfFolder->Release();
@ -289,26 +286,23 @@ bool ShowExplorerMenu(HWND hwnd, const QString &path, const QPoint &qpoint)
//
ppidl = &pidlItem;
LPCONTEXTMENU pContextMenu;
if (SUCCEEDED (psfFolder->GetUIObjectOf (
hwnd, 1, (const ITEMIDLIST **)ppidl, IID_IContextMenu, NULL, (void**)&pContextMenu))) {
if (SUCCEEDED(psfFolder->GetUIObjectOf(hwnd, 1, (const ITEMIDLIST **)ppidl, IID_IContextMenu, NULL, (void **)&pContextMenu)))
{
HMENU hMenu = CreatePopupMenu();
if (SUCCEEDED (pContextMenu->QueryContextMenu (
hMenu, 0, 1, 0x7FFF, CMF_EXPLORE))) {
if (SUCCEEDED(pContextMenu->QueryContextMenu(hMenu, 0, 1, 0x7FFF, CMF_EXPLORE)))
{
//
// Display the context menu.
//
UINT nCmd = TrackPopupMenu (hMenu, TPM_LEFTALIGN |
TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RETURNCMD,
point.x, point.y, 0, hwnd, NULL);
UINT nCmd = TrackPopupMenu(hMenu, TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RETURNCMD, point.x, point.y, 0, hwnd, NULL);
//
// If a command was selected from the menu, execute it.
//
if (nCmd) {
if (nCmd)
{
CMINVOKECOMMANDINFO ici;
memset(&ici, 0, sizeof(ici));
ici.cbSize = sizeof(CMINVOKECOMMANDINFO);
@ -321,9 +315,7 @@ bool ShowExplorerMenu(HWND hwnd, const QString &path, const QPoint &qpoint)
ici.dwHotKey = 0;
ici.hIcon = NULL;
if (SUCCEEDED (
pContextMenu->InvokeCommand (
(CMINVOKECOMMANDINFO*)&ici)))
if (SUCCEEDED(pContextMenu->InvokeCommand((CMINVOKECOMMANDINFO *)&ici)))
bResult = true;
}
}
@ -368,7 +360,6 @@ void ParseProperties(QStringMap &properties, const QStringList &lines, QChar sep
}
}
//------------------------------------------------------------------------------
void GetStandardItemTextRecursive(QString &name, const QStandardItem &item, const QChar &separator)
{

View File

@ -1,12 +1,12 @@
#ifndef UTILS_H
#define UTILS_H
#include <QString>
#include <QMessageBox>
#include <QMap>
#include <QStandardItem>
#include <QMessageBox>
#include <QSet>
#include <QSettings>
#include <QStandardItem>
#include <QString>
#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define FOSSIL_CHECKOUT1 "_FOSSIL_"
@ -16,7 +16,6 @@
typedef QSet<QString> stringset_t;
class UICallback
{
public:
@ -28,31 +27,22 @@ public:
virtual QMessageBox::StandardButton Query(const QString &title, const QString &query, QMessageBox::StandardButtons buttons) = 0;
};
class ScopedStatus
{
public:
ScopedStatus(UICallback *callback, const QString &text) : uiCallback(callback)
{
uiCallback->beginProcess(text);
}
ScopedStatus(UICallback *callback, const QString &text) : uiCallback(callback) { uiCallback->beginProcess(text); }
~ScopedStatus()
{
uiCallback->endProcess();
}
~ScopedStatus() { uiCallback->endProcess(); }
private:
UICallback *uiCallback;
};
QMessageBox::StandardButton DialogQuery(QWidget *parent, const QString &title, const QString &query, QMessageBox::StandardButtons buttons = QMessageBox::Yes | QMessageBox::No);
QString QuotePath(const QString &path);
QStringList QuotePaths(const QStringList &paths);
QString SelectExe(QWidget *parent, const QString &description);
typedef QMap<QString, QModelIndex> name_modelindex_map_t;
void GetStandardItemTextRecursive(QString &name, const QStandardItem &item, const QChar &separator = '/');
void BuildNameToModelIndex(name_modelindex_map_t &map, const QStandardItem &item);

View File

@ -1,11 +1,9 @@
#include "Workspace.h"
#include <QCoreApplication>
#include "Utils.h"
#include <QCoreApplication>
//-----------------------------------------------------------------------------
Workspace::Workspace()
{
}
Workspace::Workspace() {}
//-----------------------------------------------------------------------------
Workspace::~Workspace()
{
@ -55,7 +53,6 @@ void Workspace::storeWorkspace(QSettings &store)
}
store.endArray();
store.endGroup();
}
//------------------------------------------------------------------------------
@ -265,8 +262,7 @@ void Workspace::scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModifie
type = WorkspaceFile::TYPE_MERGED;
// Filter unwanted file types
if( ((type & WorkspaceFile::TYPE_MODIFIED) && !scanModified) ||
((type & WorkspaceFile::TYPE_UNCHANGED) && !scanUnchanged))
if (((type & WorkspaceFile::TYPE_MODIFIED) && !scanModified) || ((type & WorkspaceFile::TYPE_UNCHANGED) && !scanUnchanged))
{
getFiles().remove(fname);
continue;
@ -423,4 +419,3 @@ Remote * Workspace::findRemote(const QUrl& url)
return &(*it);
return NULL;
}

View File

@ -1,15 +1,15 @@
#ifndef WORKSPACE_H
#define WORKSPACE_H
#include <QStandardItemModel>
#include <QFileInfo>
#include <QDir>
#include <QSet>
#include <QMap>
#include <QSettings>
#include "Fossil.h"
#include "Utils.h"
#include "WorkspaceCommon.h"
#include "Fossil.h"
#include <QDir>
#include <QFileInfo>
#include <QMap>
#include <QSet>
#include <QSettings>
#include <QStandardItemModel>
//////////////////////////////////////////////////////////////////////////
// Workspace
@ -54,148 +54,67 @@ public:
void storeWorkspace(QSettings &store);
// Fossil Wrappers
void Init(UICallback *callback, const QString &exePath)
{
fossil().Init(callback, exePath);
}
void Init(UICallback *callback, const QString &exePath) { fossil().Init(callback, exePath); }
bool create(const QString &repositoryPath, const QString& workspacePath)
{
return fossil().createWorkspace(repositoryPath, workspacePath);
}
bool create(const QString &repositoryPath, const QString &workspacePath) { return fossil().createWorkspace(repositoryPath, workspacePath); }
bool createRepository(const QString &repositoryPath)
{
return fossil().createRepository(repositoryPath);
}
bool createRepository(const QString &repositoryPath) { return fossil().createRepository(repositoryPath); }
WorkspaceState getState()
{
return fossil().getWorkspaceState();
}
WorkspaceState getState() { return fossil().getWorkspaceState(); }
bool close(bool force=false)
{
return fossil().closeWorkspace(force);
}
bool close(bool force = false) { return fossil().closeWorkspace(force); }
bool cloneRepository(const QString &repository, const QUrl &url, const QUrl &proxyUrl)
{
return fossil().cloneRepository(repository, url, proxyUrl);
}
bool cloneRepository(const QString &repository, const QUrl &url, const QUrl &proxyUrl) { return fossil().cloneRepository(repository, url, proxyUrl); }
bool push(const QUrl& url)
{
return fossil().pushWorkspace(url);
}
bool push(const QUrl &url) { return fossil().pushWorkspace(url); }
bool pull(const QUrl& url)
{
return fossil().pullWorkspace(url);
}
bool pull(const QUrl &url) { return fossil().pullWorkspace(url); }
bool update(QStringList& result, const QString& revision, bool explainOnly)
{
return fossil().updateWorkspace(result, revision, explainOnly);
}
bool update(QStringList &result, const QString &revision, bool explainOnly) { return fossil().updateWorkspace(result, revision, explainOnly); }
bool undo(QStringList& result, bool explainOnly)
{
return fossil().undoWorkspace(result, explainOnly);
}
bool undo(QStringList &result, bool explainOnly) { return fossil().undoWorkspace(result, explainOnly); }
bool diffFile(const QString &repoFile, bool graphical)
{
return fossil().diffFile(repoFile, graphical);
}
bool diffFile(const QString &repoFile, bool graphical) { return fossil().diffFile(repoFile, graphical); }
bool commitFiles(const QStringList &fileList, const QString &comment, const QString &newBranchName, bool isPrivateBranch)
{
return fossil().commitFiles(fileList, comment, newBranchName, isPrivateBranch);
}
bool addFiles(const QStringList& fileList)
{
return fossil().addFiles(fileList);
}
bool addFiles(const QStringList &fileList) { return fossil().addFiles(fileList); }
bool removeFiles(const QStringList& fileList, bool deleteLocal)
{
return fossil().removeFiles(fileList, deleteLocal);
}
bool removeFiles(const QStringList &fileList, bool deleteLocal) { return fossil().removeFiles(fileList, deleteLocal); }
bool revertFiles(const QStringList& fileList)
{
return fossil().revertFiles(fileList);
}
bool revertFiles(const QStringList &fileList) { return fossil().revertFiles(fileList); }
bool renameFile(const QString& beforePath, const QString& afterPath, bool renameLocal)
{
return fossil().renameFile(beforePath, afterPath, renameLocal);
}
bool renameFile(const QString &beforePath, const QString &afterPath, bool renameLocal) { return fossil().renameFile(beforePath, afterPath, renameLocal); }
// Stashes
bool stashNew(const QStringList& fileList, const QString& name, bool revert)
{
return fossil().stashNew(fileList, name, revert);
}
bool stashNew(const QStringList &fileList, const QString &name, bool revert) { return fossil().stashNew(fileList, name, revert); }
bool stashList(stashmap_t &stashes)
{
return fossil().stashList(stashes);
}
bool stashList(stashmap_t &stashes) { return fossil().stashList(stashes); }
bool stashApply(const QString& name)
{
return fossil().stashApply(name);
}
bool stashApply(const QString &name) { return fossil().stashApply(name); }
bool stashDrop(const QString& name)
{
return fossil().stashDrop(name);
}
bool stashDrop(const QString &name) { return fossil().stashDrop(name); }
bool stashDiff(const QString& name)
{
return fossil().stashDiff(name);
}
bool stashDiff(const QString &name) { return fossil().stashDiff(name); }
// Tags
bool tagList(QStringMap& tags)
{
return fossil().tagList(tags);
}
bool tagList(QStringMap &tags) { return fossil().tagList(tags); }
bool tagNew(const QString& name, const QString& revision)
{
return fossil().tagNew(name, revision);
}
bool tagNew(const QString &name, const QString &revision) { return fossil().tagNew(name, revision); }
bool tagDelete(const QString& name, const QString& revision)
{
return fossil().tagDelete(name, revision);
}
bool tagDelete(const QString &name, const QString &revision) { return fossil().tagDelete(name, revision); }
// Branches
bool branchList(QStringList& branches, QStringList& activeBranches)
{
return fossil().branchList(branches, activeBranches);
}
bool branchList(QStringList &branches, QStringList &activeBranches) { return fossil().branchList(branches, activeBranches); }
bool branchNew(const QString& name, const QString& revisionBasis, bool isPrivate=false)
{
return fossil().branchNew(name, revisionBasis, isPrivate);
}
bool branchNew(const QString &name, const QString &revisionBasis, bool isPrivate = false) { return fossil().branchNew(name, revisionBasis, isPrivate); }
bool branchMerge(QStringList& res, const QString& revision, bool integrate, bool force, bool testOnly)
{
return fossil().branchMerge(res, revision, integrate, force, testOnly);
}
bool branchMerge(QStringList &res, const QString &revision, bool integrate, bool force, bool testOnly) { return fossil().branchMerge(res, revision, integrate, force, testOnly); }
bool getInterfaceVersion(QString &version)
{
return fossil().getExeVersion(version);
}
bool getInterfaceVersion(QString &version) { return fossil().getExeVersion(version); }
private:
static bool scanDirectory(QFileInfoList &entries, const QString &dirPath, const QString &baseDir, const QStringList &ignorePatterns, UICallback &uiCallback);

View File

@ -1,12 +1,12 @@
#ifndef WORKSPACECOMMON_H
#define WORKSPACECOMMON_H
#include <QFileInfo>
#include <QDir>
#include <QSet>
#include <QMap>
#include <QUrl>
#include "Utils.h"
#include <QDir>
#include <QFileInfo>
#include <QMap>
#include <QSet>
#include <QUrl>
//////////////////////////////////////////////////////////////////////////
// WorkspaceState
@ -51,40 +51,19 @@ struct WorkspaceFile
Path = Path.mid(repoPath.length() + 1);
}
bool isType(Type t) const
{
return FileType == t;
}
bool isType(Type t) const { return FileType == t; }
void setType(Type t)
{
FileType = t;
}
void setType(Type t) { FileType = t; }
Type getType() const
{
return FileType;
}
Type getType() const { return FileType; }
QFileInfo getFileInfo() const
{
return FileInfo;
}
QFileInfo getFileInfo() const { return FileInfo; }
const QString &getFilePath() const
{
return FilePath;
}
const QString &getFilePath() const { return FilePath; }
QString getFilename() const
{
return FileInfo.fileName();
}
QString getFilename() const { return FileInfo.fileName(); }
const QString &getPath() const
{
return Path;
}
const QString &getPath() const { return Path; }
QString getRelativeFilename(const QString &path)
{
@ -108,15 +87,11 @@ private:
class Remote
{
public:
Remote(const QString &_name, const QUrl &_url, bool _isDefault=false)
: name(_name), url(_url), isDefault(_isDefault)
{
}
Remote(const QString &_name, const QUrl &_url, bool _isDefault = false) : name(_name), url(_url), isDefault(_isDefault) {}
QString name;
QUrl url;
bool isDefault;
};
typedef QMap<QUrl, Remote> remote_map_t;
@ -125,5 +100,4 @@ typedef QList<WorkspaceFile*> filelist_t;
typedef QMap<QString, WorkspaceFile *> filemap_t;
typedef QMap<QString, QString> stashmap_t;
#endif // WORKSPACECOMMON_H

View File

@ -1,5 +1,5 @@
#include <QApplication>
#include "MainWindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
@ -9,7 +9,6 @@ int main(int argc, char *argv[])
app.setOrganizationDomain("fuel-scm.org");
app.setOrganizationName("Fuel-SCM");
#ifdef Q_OS_MACX
// Native OSX applications don't have menu icons
app.setAttribute(Qt::AA_DontShowIconsInMenus);
@ -35,12 +34,9 @@ int main(int argc, char *argv[])
Settings settings(portable);
MainWindow mainwin(settings,
0,
workspace.isEmpty() ? 0 : &workspace);
MainWindow mainwin(settings, 0, workspace.isEmpty() ? 0 : &workspace);
mainwin.show();
mainwin.fullRefresh();
return app.exec();
}
}