🎨 Added clang-format
This commit is contained in:
parent
d6eaf13e78
commit
5dc8db6919
25
.clang-format
Normal file
25
.clang-format
Normal 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
|
@ -2,57 +2,55 @@
|
||||
#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());
|
||||
banner += "\n" + ui->lblBanner->text();
|
||||
banner += "\n<a href=\"https://fuel-scm.org/\">https://fuel-scm.org/</a>";
|
||||
banner = banner.replace("\n", "<br/>");
|
||||
ui->lblBanner->setText(banner);
|
||||
ui->lblBanner->setOpenExternalLinks(true);
|
||||
ui->lblBanner->setTextFormat(Qt::RichText);
|
||||
ui->setupUi(this);
|
||||
QString banner(QCoreApplication::applicationName() + " " + QCoreApplication::applicationVersion());
|
||||
banner += "\n" + ui->lblBanner->text();
|
||||
banner += "\n<a href=\"https://fuel-scm.org/\">https://fuel-scm.org/</a>";
|
||||
banner = banner.replace("\n", "<br/>");
|
||||
ui->lblBanner->setText(banner);
|
||||
ui->lblBanner->setOpenExternalLinks(true);
|
||||
ui->lblBanner->setTextFormat(Qt::RichText);
|
||||
|
||||
ui->lblQtVersion->setText(tr("QT version %0").arg(QT_VERSION_STR));
|
||||
ui->lblQtVersion->setText(tr("QT version %0").arg(QT_VERSION_STR));
|
||||
|
||||
if(!fossilVersion.isEmpty())
|
||||
ui->lblFossilVersion->setText(tr("Fossil version %0").arg(fossilVersion));
|
||||
if (!fossilVersion.isEmpty())
|
||||
ui->lblFossilVersion->setText(tr("Fossil version %0").arg(fossilVersion));
|
||||
|
||||
QString revisiontxt;
|
||||
QFile fmanifest(":/version/manifest");
|
||||
if(fmanifest.open(QFile::ReadOnly))
|
||||
{
|
||||
QString revision = QString(fmanifest.readAll()).trimmed();
|
||||
revisiontxt = QString(tr("Fuel revision %0").arg("<a href=\"https://fuel-scm.org/fossil/timeline?c=%0\">%0</a>").arg(revision));
|
||||
ui->lblFuelRevision->setOpenExternalLinks(true);
|
||||
ui->lblFuelRevision->setTextFormat(Qt::RichText);
|
||||
fmanifest.close();
|
||||
}
|
||||
ui->lblFuelRevision->setText(revisiontxt);
|
||||
QString revisiontxt;
|
||||
QFile fmanifest(":/version/manifest");
|
||||
if (fmanifest.open(QFile::ReadOnly))
|
||||
{
|
||||
QString revision = QString(fmanifest.readAll()).trimmed();
|
||||
revisiontxt = QString(tr("Fuel revision %0").arg("<a href=\"https://fuel-scm.org/fossil/timeline?c=%0\">%0</a>").arg(revision));
|
||||
ui->lblFuelRevision->setOpenExternalLinks(true);
|
||||
ui->lblFuelRevision->setTextFormat(Qt::RichText);
|
||||
fmanifest.close();
|
||||
}
|
||||
ui->lblFuelRevision->setText(revisiontxt);
|
||||
|
||||
QString additional;
|
||||
QFile ftrans(":/docs/docs/Translators.txt");
|
||||
if(ftrans.open(QFile::ReadOnly))
|
||||
{
|
||||
additional.append(tr("Translations with the help of:")+"\n");
|
||||
additional.append(ftrans.readAll());
|
||||
additional.append("\n\n");
|
||||
ftrans.close();
|
||||
}
|
||||
QString additional;
|
||||
QFile ftrans(":/docs/docs/Translators.txt");
|
||||
if (ftrans.open(QFile::ReadOnly))
|
||||
{
|
||||
additional.append(tr("Translations with the help of:") + "\n");
|
||||
additional.append(ftrans.readAll());
|
||||
additional.append("\n\n");
|
||||
ftrans.close();
|
||||
}
|
||||
|
||||
QFile flicenses(":/docs/docs/Licenses.txt");
|
||||
if(flicenses.open(QFile::ReadOnly))
|
||||
{
|
||||
additional.append(tr("This sofware uses the following open-source libraries and assets:")+"\n");
|
||||
additional.append(flicenses.readAll());
|
||||
flicenses.close();
|
||||
}
|
||||
ui->txtAdditional->setText(additional);
|
||||
QFile flicenses(":/docs/docs/Licenses.txt");
|
||||
if (flicenses.open(QFile::ReadOnly))
|
||||
{
|
||||
additional.append(tr("This sofware uses the following open-source libraries and assets:") + "\n");
|
||||
additional.append(flicenses.readAll());
|
||||
flicenses.close();
|
||||
}
|
||||
ui->txtAdditional->setText(additional);
|
||||
}
|
||||
|
||||
AboutDialog::~AboutDialog()
|
||||
{
|
||||
delete ui;
|
||||
delete ui;
|
||||
}
|
||||
|
@ -3,20 +3,21 @@
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
namespace Ui
|
||||
{
|
||||
class AboutDialog;
|
||||
}
|
||||
|
||||
class AboutDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AboutDialog(QWidget *parent, const QString &fossilVersion);
|
||||
~AboutDialog();
|
||||
explicit AboutDialog(QWidget *parent, const QString &fossilVersion);
|
||||
~AboutDialog();
|
||||
|
||||
private:
|
||||
Ui::AboutDialog *ui;
|
||||
Ui::AboutDialog *ui;
|
||||
};
|
||||
|
||||
#endif // ABOUTDIALOG_H
|
||||
#endif // ABOUTDIALOG_H
|
||||
|
@ -1,131 +1,129 @@
|
||||
#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)
|
||||
{
|
||||
Mappings.insert(FOSSIL_SETTING_GDIFF_CMD, Setting("", Setting::TYPE_FOSSIL_GLOBAL));
|
||||
Mappings.insert(FOSSIL_SETTING_GMERGE_CMD, Setting("", Setting::TYPE_FOSSIL_GLOBAL));
|
||||
Mappings.insert(FOSSIL_SETTING_PROXY_URL, Setting("", Setting::TYPE_FOSSIL_GLOBAL));
|
||||
Mappings.insert(FOSSIL_SETTING_HTTP_PORT, Setting("", Setting::TYPE_FOSSIL_GLOBAL));
|
||||
Mappings.insert(FOSSIL_SETTING_GDIFF_CMD, Setting("", Setting::TYPE_FOSSIL_GLOBAL));
|
||||
Mappings.insert(FOSSIL_SETTING_GMERGE_CMD, Setting("", Setting::TYPE_FOSSIL_GLOBAL));
|
||||
Mappings.insert(FOSSIL_SETTING_PROXY_URL, Setting("", Setting::TYPE_FOSSIL_GLOBAL));
|
||||
Mappings.insert(FOSSIL_SETTING_HTTP_PORT, Setting("", Setting::TYPE_FOSSIL_GLOBAL));
|
||||
|
||||
Mappings.insert(FOSSIL_SETTING_IGNORE_GLOB, Setting("", Setting::TYPE_FOSSIL_LOCAL));
|
||||
Mappings.insert(FOSSIL_SETTING_CRNL_GLOB, Setting("", Setting::TYPE_FOSSIL_LOCAL));
|
||||
Mappings.insert(FOSSIL_SETTING_IGNORE_GLOB, Setting("", Setting::TYPE_FOSSIL_LOCAL));
|
||||
Mappings.insert(FOSSIL_SETTING_CRNL_GLOB, Setting("", Setting::TYPE_FOSSIL_LOCAL));
|
||||
|
||||
// Go into portable mode when explicitly requested or if a config file exists next to the executable
|
||||
QString ini_path = QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + QDir::separator() + QCoreApplication::applicationName() + ".ini");
|
||||
if( portableMode || QFile::exists(ini_path))
|
||||
store = new QSettings(ini_path, QSettings::IniFormat);
|
||||
else
|
||||
{
|
||||
// Linux: ~/.config/organizationName/applicationName.conf
|
||||
// Windows: HKEY_CURRENT_USER\Software\organizationName\Fuel
|
||||
store = new QSettings(QSettings::UserScope, QCoreApplication::organizationName(), QCoreApplication::applicationName());
|
||||
}
|
||||
Q_ASSERT(store);
|
||||
// Go into portable mode when explicitly requested or if a config file exists next to the executable
|
||||
QString ini_path = QDir::toNativeSeparators(QCoreApplication::applicationDirPath() + QDir::separator() + QCoreApplication::applicationName() + ".ini");
|
||||
if (portableMode || QFile::exists(ini_path))
|
||||
store = new QSettings(ini_path, QSettings::IniFormat);
|
||||
else
|
||||
{
|
||||
// Linux: ~/.config/organizationName/applicationName.conf
|
||||
// Windows: HKEY_CURRENT_USER\Software\organizationName\Fuel
|
||||
store = new QSettings(QSettings::UserScope, QCoreApplication::organizationName(), QCoreApplication::applicationName());
|
||||
}
|
||||
Q_ASSERT(store);
|
||||
|
||||
if(!HasValue(FUEL_SETTING_FILE_DBLCLICK))
|
||||
SetValue(FUEL_SETTING_FILE_DBLCLICK, 0);
|
||||
if(!HasValue(FUEL_SETTING_LANGUAGE) && SupportsLang(QLocale::system().name()))
|
||||
SetValue(FUEL_SETTING_LANGUAGE, QLocale::system().name());
|
||||
if(!HasValue(FUEL_SETTING_WEB_BROWSER))
|
||||
SetValue(FUEL_SETTING_WEB_BROWSER, 0);
|
||||
if (!HasValue(FUEL_SETTING_FILE_DBLCLICK))
|
||||
SetValue(FUEL_SETTING_FILE_DBLCLICK, 0);
|
||||
if (!HasValue(FUEL_SETTING_LANGUAGE) && SupportsLang(QLocale::system().name()))
|
||||
SetValue(FUEL_SETTING_LANGUAGE, QLocale::system().name());
|
||||
if (!HasValue(FUEL_SETTING_WEB_BROWSER))
|
||||
SetValue(FUEL_SETTING_WEB_BROWSER, 0);
|
||||
|
||||
for (int i = 0; i < MAX_CUSTOM_ACTIONS; ++i)
|
||||
{
|
||||
CustomAction action;
|
||||
action.Id = QObject::tr("Custom Action %0").arg(i + 1);
|
||||
customActions.append(action);
|
||||
}
|
||||
|
||||
for(int i=0; i<MAX_CUSTOM_ACTIONS; ++i)
|
||||
{
|
||||
CustomAction action;
|
||||
action.Id = QObject::tr("Custom Action %0").arg(i+1);
|
||||
customActions.append(action);
|
||||
}
|
||||
|
||||
ApplyEnvironment();
|
||||
ApplyEnvironment();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
Settings::~Settings()
|
||||
{
|
||||
Q_ASSERT(store);
|
||||
delete store;
|
||||
Q_ASSERT(store);
|
||||
delete store;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void Settings::ApplyEnvironment()
|
||||
{
|
||||
QString lang_id = GetValue(FUEL_SETTING_LANGUAGE).toString();
|
||||
QString lang_id = GetValue(FUEL_SETTING_LANGUAGE).toString();
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
|
||||
QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8"));
|
||||
QTextCodec::setCodecForTr(QTextCodec::codecForName("utf8"));
|
||||
#endif
|
||||
if(!InstallLang(lang_id))
|
||||
SetValue(FUEL_SETTING_LANGUAGE, "en_US");
|
||||
if (!InstallLang(lang_id))
|
||||
SetValue(FUEL_SETTING_LANGUAGE, "en_US");
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool Settings::InstallLang(const QString &langId)
|
||||
{
|
||||
if(langId == "en_US")
|
||||
{
|
||||
QCoreApplication::instance()->removeTranslator(&translator);
|
||||
return true;
|
||||
}
|
||||
if (langId == "en_US")
|
||||
{
|
||||
QCoreApplication::instance()->removeTranslator(&translator);
|
||||
return true;
|
||||
}
|
||||
|
||||
QString locale_path = QString(":intl/%0.qm").arg(langId);
|
||||
if(!translator.load(locale_path))
|
||||
return false;
|
||||
QString locale_path = QString(":intl/%0.qm").arg(langId);
|
||||
if (!translator.load(locale_path))
|
||||
return false;
|
||||
|
||||
Q_ASSERT(!translator.isEmpty());
|
||||
QCoreApplication::instance()->installTranslator(&translator);
|
||||
Q_ASSERT(!translator.isEmpty());
|
||||
QCoreApplication::instance()->installTranslator(&translator);
|
||||
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool Settings::HasValue(const QString &name) const
|
||||
{
|
||||
return store->contains(name);
|
||||
return store->contains(name);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
const QVariant Settings::GetValue(const QString &name)
|
||||
{
|
||||
if(!HasValue(name))
|
||||
return QVariant();
|
||||
return store->value(name);
|
||||
if (!HasValue(name))
|
||||
return QVariant();
|
||||
return store->value(name);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void Settings::SetValue(const QString &name, const QVariant &value)
|
||||
{
|
||||
store->setValue(name, value);
|
||||
store->setValue(name, value);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
QVariant &Settings::GetFossilValue(const QString &name)
|
||||
{
|
||||
mappings_t::iterator it=Mappings.find(name);
|
||||
Q_ASSERT(it!=Mappings.end());
|
||||
return it.value().Value;
|
||||
mappings_t::iterator it = Mappings.find(name);
|
||||
Q_ASSERT(it != Mappings.end());
|
||||
return it.value().Value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void Settings::SetFossilValue(const QString &name, const QVariant &value)
|
||||
{
|
||||
mappings_t::iterator it=Mappings.find(name);
|
||||
Q_ASSERT(it!=Mappings.end());
|
||||
it->Value = value;
|
||||
mappings_t::iterator it = Mappings.find(name);
|
||||
Q_ASSERT(it != Mappings.end());
|
||||
it->Value = value;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool Settings::SupportsLang(const QString &langId) const
|
||||
{
|
||||
QString locale_path = QString(":intl/intl/%0.qm").arg(langId);
|
||||
QResource res(locale_path);
|
||||
return res.isValid();
|
||||
QString locale_path = QString(":intl/intl/%0.qm").arg(langId);
|
||||
QResource res(locale_path);
|
||||
return res.isValid();
|
||||
}
|
||||
|
@ -2,125 +2,111 @@
|
||||
#define APPSETTINGS_H
|
||||
|
||||
#include <QMap>
|
||||
#include <QVariant>
|
||||
#include <QTranslator>
|
||||
#include <QVariant>
|
||||
#include <QVector>
|
||||
|
||||
#define FUEL_SETTING_FOSSIL_PATH "FossilPath"
|
||||
#define FUEL_SETTING_COMMIT_MSG "CommitMsgHistory"
|
||||
#define FUEL_SETTING_FILE_DBLCLICK "FileDblClickAction"
|
||||
#define FUEL_SETTING_LANGUAGE "Language"
|
||||
#define FUEL_SETTING_WEB_BROWSER "WebBrowser"
|
||||
|
||||
#define FOSSIL_SETTING_GDIFF_CMD "gdiff-command"
|
||||
#define FOSSIL_SETTING_GMERGE_CMD "gmerge-command"
|
||||
#define FOSSIL_SETTING_PROXY_URL "proxy"
|
||||
#define FOSSIL_SETTING_IGNORE_GLOB "ignore-glob"
|
||||
#define FOSSIL_SETTING_CRNL_GLOB "crnl-glob"
|
||||
#define FOSSIL_SETTING_HTTP_PORT "http-port"
|
||||
#define FUEL_SETTING_FOSSIL_PATH "FossilPath"
|
||||
#define FUEL_SETTING_COMMIT_MSG "CommitMsgHistory"
|
||||
#define FUEL_SETTING_FILE_DBLCLICK "FileDblClickAction"
|
||||
#define FUEL_SETTING_LANGUAGE "Language"
|
||||
#define FUEL_SETTING_WEB_BROWSER "WebBrowser"
|
||||
|
||||
#define FOSSIL_SETTING_GDIFF_CMD "gdiff-command"
|
||||
#define FOSSIL_SETTING_GMERGE_CMD "gmerge-command"
|
||||
#define FOSSIL_SETTING_PROXY_URL "proxy"
|
||||
#define FOSSIL_SETTING_IGNORE_GLOB "ignore-glob"
|
||||
#define FOSSIL_SETTING_CRNL_GLOB "crnl-glob"
|
||||
#define FOSSIL_SETTING_HTTP_PORT "http-port"
|
||||
|
||||
enum FileDblClickAction
|
||||
{
|
||||
FILE_DLBCLICK_ACTION_DIFF,
|
||||
FILE_DLBCLICK_ACTION_OPEN,
|
||||
FILE_DLBCLICK_ACTION_OPENCONTAINING,
|
||||
FILE_DLBCLICK_ACTION_CUSTOM, // Custom Action 1
|
||||
FILE_DLBCLICK_ACTION_MAX
|
||||
FILE_DLBCLICK_ACTION_DIFF,
|
||||
FILE_DLBCLICK_ACTION_OPEN,
|
||||
FILE_DLBCLICK_ACTION_OPENCONTAINING,
|
||||
FILE_DLBCLICK_ACTION_CUSTOM, // Custom Action 1
|
||||
FILE_DLBCLICK_ACTION_MAX
|
||||
};
|
||||
|
||||
|
||||
enum CustomActionContext
|
||||
{
|
||||
ACTION_CONTEXT_FILES = 1 << 0,
|
||||
ACTION_CONTEXT_FOLDERS = 1 << 1,
|
||||
ACTION_CONTEXT_FILES_AND_FOLDERS = ACTION_CONTEXT_FILES|ACTION_CONTEXT_FOLDERS
|
||||
ACTION_CONTEXT_FILES = 1 << 0,
|
||||
ACTION_CONTEXT_FOLDERS = 1 << 1,
|
||||
ACTION_CONTEXT_FILES_AND_FOLDERS = ACTION_CONTEXT_FILES | ACTION_CONTEXT_FOLDERS
|
||||
};
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
MAX_CUSTOM_ACTIONS = 9
|
||||
MAX_CUSTOM_ACTIONS = 9
|
||||
};
|
||||
|
||||
struct CustomAction
|
||||
{
|
||||
QString Id;
|
||||
QString Description;
|
||||
QString Command;
|
||||
CustomActionContext Context;
|
||||
bool MultipleSelection;
|
||||
QString Id;
|
||||
QString Description;
|
||||
QString Command;
|
||||
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()
|
||||
{
|
||||
Description.clear();
|
||||
Command.clear();
|
||||
Context = ACTION_CONTEXT_FILES;
|
||||
MultipleSelection = true;
|
||||
}
|
||||
void Clear()
|
||||
{
|
||||
Description.clear();
|
||||
Command.clear();
|
||||
Context = ACTION_CONTEXT_FILES;
|
||||
MultipleSelection = true;
|
||||
}
|
||||
};
|
||||
|
||||
struct Settings
|
||||
{
|
||||
struct Setting
|
||||
{
|
||||
enum SettingType
|
||||
{
|
||||
TYPE_FOSSIL_GLOBAL,
|
||||
TYPE_FOSSIL_LOCAL
|
||||
};
|
||||
struct Setting
|
||||
{
|
||||
enum SettingType
|
||||
{
|
||||
TYPE_FOSSIL_GLOBAL,
|
||||
TYPE_FOSSIL_LOCAL
|
||||
};
|
||||
|
||||
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;
|
||||
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();
|
||||
|
||||
Settings(bool portableMode = false);
|
||||
~Settings();
|
||||
void ApplyEnvironment();
|
||||
|
||||
void ApplyEnvironment();
|
||||
// App configuration access
|
||||
class QSettings *GetStore() { return store; }
|
||||
bool HasValue(const QString &name) const; // store->contains(FUEL_SETTING_FOSSIL_PATH)
|
||||
const QVariant GetValue(const QString &name); // settings.store->value
|
||||
void SetValue(const QString &name, const QVariant &value); // settings.store->value
|
||||
|
||||
// App configuration access
|
||||
class QSettings * GetStore() { return store; }
|
||||
bool HasValue(const QString &name) const; // store->contains(FUEL_SETTING_FOSSIL_PATH)
|
||||
const QVariant GetValue(const QString &name); // settings.store->value
|
||||
void SetValue(const QString &name, const QVariant &value); // settings.store->value
|
||||
// Fossil configuration access
|
||||
QVariant &GetFossilValue(const QString &name);
|
||||
void SetFossilValue(const QString &name, const QVariant &value);
|
||||
mappings_t &GetMappings() { return Mappings; }
|
||||
|
||||
// Fossil configuration access
|
||||
QVariant & GetFossilValue(const QString &name);
|
||||
void SetFossilValue(const QString &name, const QVariant &value);
|
||||
mappings_t & GetMappings() { return Mappings; }
|
||||
bool SupportsLang(const QString &langId) const;
|
||||
bool InstallLang(const QString &langId);
|
||||
|
||||
bool SupportsLang(const QString &langId) const;
|
||||
bool InstallLang(const QString &langId);
|
||||
custom_actions_t &GetCustomActions() { return customActions; }
|
||||
|
||||
custom_actions_t &GetCustomActions() { return customActions; }
|
||||
private:
|
||||
mappings_t Mappings;
|
||||
class QSettings *store;
|
||||
QTranslator translator;
|
||||
mappings_t Mappings;
|
||||
class QSettings *store;
|
||||
QTranslator translator;
|
||||
|
||||
custom_actions_t customActions;
|
||||
custom_actions_t customActions;
|
||||
};
|
||||
|
||||
|
||||
#endif // APPSETTINGS_H
|
||||
#endif // APPSETTINGS_H
|
||||
|
@ -1,73 +1,69 @@
|
||||
#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);
|
||||
ui->toolBar->addWidget(ui->txtUrl);
|
||||
connect(ui->txtUrl, SIGNAL(returnPressed()), this, SLOT(on_txtUrl_returnPressed()) );
|
||||
ui->actionBrowserStop->setVisible(false);
|
||||
ui = new Ui::BrowserWidget;
|
||||
ui->setupUi(this);
|
||||
ui->toolBar->addWidget(ui->txtUrl);
|
||||
connect(ui->txtUrl, SIGNAL(returnPressed()), this, SLOT(on_txtUrl_returnPressed()));
|
||||
ui->actionBrowserStop->setVisible(false);
|
||||
}
|
||||
|
||||
BrowserWidget::~BrowserWidget()
|
||||
{
|
||||
delete ui;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void BrowserWidget::load(const QUrl &url)
|
||||
{
|
||||
ui->webView->load(url);
|
||||
ui->webView->load(url);
|
||||
}
|
||||
|
||||
void BrowserWidget::on_webView_urlChanged(const QUrl &url)
|
||||
{
|
||||
ui->txtUrl->setText(url.toString());
|
||||
ui->txtUrl->setText(url.toString());
|
||||
}
|
||||
|
||||
void BrowserWidget::on_webView_loadStarted()
|
||||
{
|
||||
loading=true;
|
||||
ui->actionBrowserRefresh->setVisible(false);
|
||||
ui->actionBrowserStop->setVisible(true);
|
||||
loading = true;
|
||||
ui->actionBrowserRefresh->setVisible(false);
|
||||
ui->actionBrowserStop->setVisible(true);
|
||||
}
|
||||
|
||||
void BrowserWidget::on_webView_loadFinished(bool /*errorOccured*/)
|
||||
{
|
||||
loading=false;
|
||||
ui->actionBrowserRefresh->setVisible(true);
|
||||
ui->actionBrowserStop->setVisible(false);
|
||||
loading = false;
|
||||
ui->actionBrowserRefresh->setVisible(true);
|
||||
ui->actionBrowserStop->setVisible(false);
|
||||
}
|
||||
|
||||
|
||||
void BrowserWidget::on_txtUrl_returnPressed()
|
||||
{
|
||||
QUrl url(ui->txtUrl->text());
|
||||
if(url.scheme().isEmpty())
|
||||
url.setScheme("http");
|
||||
ui->webView->load(url);
|
||||
QUrl url(ui->txtUrl->text());
|
||||
if (url.scheme().isEmpty())
|
||||
url.setScheme("http");
|
||||
ui->webView->load(url);
|
||||
}
|
||||
|
||||
|
||||
void BrowserWidget::on_actionBrowserBack_triggered()
|
||||
{
|
||||
ui->webView->back();
|
||||
ui->webView->back();
|
||||
}
|
||||
|
||||
void BrowserWidget::on_actionBrowserForward_triggered()
|
||||
{
|
||||
ui->webView->forward();
|
||||
ui->webView->forward();
|
||||
}
|
||||
|
||||
void BrowserWidget::on_actionBrowserRefresh_triggered()
|
||||
{
|
||||
ui->webView->reload();
|
||||
ui->webView->reload();
|
||||
}
|
||||
|
||||
void BrowserWidget::on_actionBrowserStop_triggered()
|
||||
{
|
||||
ui->webView->stop();
|
||||
ui->webView->stop();
|
||||
}
|
||||
|
@ -1,37 +1,38 @@
|
||||
#ifndef BROWSERWIDGET_H
|
||||
#define BROWSERWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QUrl>
|
||||
#include <QWidget>
|
||||
|
||||
namespace Ui {
|
||||
namespace Ui
|
||||
{
|
||||
class BrowserWidget;
|
||||
}
|
||||
|
||||
class BrowserWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit BrowserWidget(QWidget *parent = 0);
|
||||
~BrowserWidget();
|
||||
explicit BrowserWidget(QWidget *parent = 0);
|
||||
~BrowserWidget();
|
||||
|
||||
void load(const QUrl &url);
|
||||
void load(const QUrl &url);
|
||||
|
||||
private slots:
|
||||
void on_webView_urlChanged(const QUrl &url);
|
||||
void on_webView_loadStarted();
|
||||
void on_webView_loadFinished(bool);
|
||||
void on_actionBrowserBack_triggered();
|
||||
void on_actionBrowserForward_triggered();
|
||||
void on_actionBrowserRefresh_triggered();
|
||||
void on_txtUrl_returnPressed();
|
||||
void on_webView_urlChanged(const QUrl &url);
|
||||
void on_webView_loadStarted();
|
||||
void on_webView_loadFinished(bool);
|
||||
void on_actionBrowserBack_triggered();
|
||||
void on_actionBrowserForward_triggered();
|
||||
void on_actionBrowserRefresh_triggered();
|
||||
void on_txtUrl_returnPressed();
|
||||
|
||||
void on_actionBrowserStop_triggered();
|
||||
void on_actionBrowserStop_triggered();
|
||||
|
||||
private:
|
||||
Ui::BrowserWidget *ui;
|
||||
bool loading;
|
||||
Ui::BrowserWidget *ui;
|
||||
bool loading;
|
||||
};
|
||||
|
||||
#endif // BROWSERWIDGET_H
|
||||
#endif // BROWSERWIDGET_H
|
||||
|
@ -1,142 +1,134 @@
|
||||
#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);
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
CloneDialog::~CloneDialog()
|
||||
{
|
||||
delete ui;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CloneDialog::run(QWidget *parent, QUrl &url, QString &repository, QUrl &urlProxy)
|
||||
{
|
||||
CloneDialog dlg(parent);
|
||||
CloneDialog dlg(parent);
|
||||
|
||||
// Try to parse a url from the clipboard
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
if(clipboard)
|
||||
{
|
||||
QUrl nurl = QUrl::fromUserInput(clipboard->text());
|
||||
// Try to parse a url from the clipboard
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
if (clipboard)
|
||||
{
|
||||
QUrl nurl = QUrl::fromUserInput(clipboard->text());
|
||||
|
||||
// If we have a valid url
|
||||
if(nurl.isValid() && !nurl.isEmpty())
|
||||
{
|
||||
// Fill in dialog
|
||||
dlg.ui->lineUserName->setText(nurl.userName());
|
||||
dlg.ui->linePassword->setText(nurl.password());
|
||||
nurl.setUserName("");
|
||||
nurl.setPassword("");
|
||||
dlg.ui->lineURL->setText(UrlToStringNoCredentials(nurl));
|
||||
}
|
||||
}
|
||||
// If we have a valid url
|
||||
if (nurl.isValid() && !nurl.isEmpty())
|
||||
{
|
||||
// Fill in dialog
|
||||
dlg.ui->lineUserName->setText(nurl.userName());
|
||||
dlg.ui->linePassword->setText(nurl.password());
|
||||
nurl.setUserName("");
|
||||
nurl.setPassword("");
|
||||
dlg.ui->lineURL->setText(UrlToStringNoCredentials(nurl));
|
||||
}
|
||||
}
|
||||
|
||||
if(dlg.exec() != QDialog::Accepted)
|
||||
return false;
|
||||
if (dlg.exec() != QDialog::Accepted)
|
||||
return false;
|
||||
|
||||
QString urltext = dlg.ui->lineURL->text();
|
||||
QString urltext = dlg.ui->lineURL->text();
|
||||
|
||||
// Check if the url is a local file
|
||||
if(QFileInfo(urltext).exists())
|
||||
url = QUrl::fromLocalFile(urltext);
|
||||
else
|
||||
{
|
||||
url = QUrl::fromUserInput(urltext);
|
||||
if(url.isEmpty() || !url.isValid())
|
||||
{
|
||||
QMessageBox::critical(parent, tr("Error"), tr("Invalid URL."), QMessageBox::Ok );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Check if the url is a local file
|
||||
if (QFileInfo(urltext).exists())
|
||||
url = QUrl::fromLocalFile(urltext);
|
||||
else
|
||||
{
|
||||
url = QUrl::fromUserInput(urltext);
|
||||
if (url.isEmpty() || !url.isValid())
|
||||
{
|
||||
QMessageBox::critical(parent, tr("Error"), tr("Invalid URL."), QMessageBox::Ok);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!dlg.ui->lineUserName->text().trimmed().isEmpty())
|
||||
url.setUserName(dlg.ui->lineUserName->text());
|
||||
if (!dlg.ui->lineUserName->text().trimmed().isEmpty())
|
||||
url.setUserName(dlg.ui->lineUserName->text());
|
||||
|
||||
if(!dlg.ui->linePassword->text().trimmed().isEmpty())
|
||||
url.setPassword(dlg.ui->linePassword->text());
|
||||
if (!dlg.ui->linePassword->text().trimmed().isEmpty())
|
||||
url.setPassword(dlg.ui->linePassword->text());
|
||||
|
||||
if(dlg.ui->lineTargetRepository->text().isEmpty())
|
||||
{
|
||||
QMessageBox::critical(parent, tr("Error"), tr("Invalid Repository File."), QMessageBox::Ok );
|
||||
return false;
|
||||
}
|
||||
if (dlg.ui->lineTargetRepository->text().isEmpty())
|
||||
{
|
||||
QMessageBox::critical(parent, tr("Error"), tr("Invalid Repository File."), QMessageBox::Ok);
|
||||
return false;
|
||||
}
|
||||
|
||||
urlProxy = QUrl::fromUserInput(dlg.ui->lineHttpProxyUrl->text());
|
||||
if(!urlProxy.isEmpty() && !urlProxy.isValid())
|
||||
{
|
||||
QMessageBox::critical(parent, tr("Error"), tr("Invalid Proxy URL."), QMessageBox::Ok );
|
||||
return false;
|
||||
}
|
||||
urlProxy = QUrl::fromUserInput(dlg.ui->lineHttpProxyUrl->text());
|
||||
if (!urlProxy.isEmpty() && !urlProxy.isValid())
|
||||
{
|
||||
QMessageBox::critical(parent, tr("Error"), tr("Invalid Proxy URL."), QMessageBox::Ok);
|
||||
return false;
|
||||
}
|
||||
|
||||
repository = dlg.ui->lineTargetRepository->text();
|
||||
return true;
|
||||
repository = dlg.ui->lineTargetRepository->text();
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CloneDialog::GetRepositoryPath(QString &pathResult)
|
||||
{
|
||||
QString filter(tr("Fossil Repository") + QString(" (*." FOSSIL_EXT ")"));
|
||||
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);
|
||||
QString ext = fi.suffix().toLower();
|
||||
if(ext != FOSSIL_EXT)
|
||||
pathResult += "." FOSSIL_EXT;
|
||||
// Ensure that it ends in the required extension (On GTK, Qt doesn't seem to add it automatically)
|
||||
QFileInfo fi(pathResult);
|
||||
QString ext = fi.suffix().toLower();
|
||||
if (ext != FOSSIL_EXT)
|
||||
pathResult += "." FOSSIL_EXT;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CloneDialog::on_btnSelectSourceRepo_clicked()
|
||||
{
|
||||
QString path = ui->lineURL->text();
|
||||
GetRepositoryPath(path);
|
||||
QString path = ui->lineURL->text();
|
||||
GetRepositoryPath(path);
|
||||
|
||||
if(path.trimmed().isEmpty())
|
||||
return;
|
||||
if (path.trimmed().isEmpty())
|
||||
return;
|
||||
|
||||
if(!QFile::exists(path))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error"), tr("Invalid Repository File."), QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
if (!QFile::exists(path))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error"), tr("Invalid Repository File."), QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
|
||||
ui->lineURL->setText(QDir::toNativeSeparators(path));
|
||||
ui->lineURL->setText(QDir::toNativeSeparators(path));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void CloneDialog::on_btnSelectTargetRepo_clicked()
|
||||
{
|
||||
QString path = ui->lineTargetRepository->text();
|
||||
GetRepositoryPath(path);
|
||||
QString path = ui->lineTargetRepository->text();
|
||||
GetRepositoryPath(path);
|
||||
|
||||
if(path.trimmed().isEmpty())
|
||||
return;
|
||||
if (path.trimmed().isEmpty())
|
||||
return;
|
||||
|
||||
if(QFile::exists(path))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error"), tr("This repository file already exists."), QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
if (QFile::exists(path))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error"), tr("This repository file already exists."), QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
|
||||
ui->lineTargetRepository->setText(QDir::toNativeSeparators(path));
|
||||
ui->lineTargetRepository->setText(QDir::toNativeSeparators(path));
|
||||
}
|
||||
|
@ -3,28 +3,29 @@
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
namespace Ui
|
||||
{
|
||||
class CloneDialog;
|
||||
}
|
||||
|
||||
class CloneDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CloneDialog(QWidget *parent = 0);
|
||||
~CloneDialog();
|
||||
explicit CloneDialog(QWidget *parent = 0);
|
||||
~CloneDialog();
|
||||
|
||||
static bool run(QWidget *parent, class QUrl &url, QString &repository, QUrl& urlProxy);
|
||||
static bool run(QWidget *parent, class QUrl &url, QString &repository, QUrl &urlProxy);
|
||||
|
||||
private slots:
|
||||
void on_btnSelectSourceRepo_clicked();
|
||||
void on_btnSelectTargetRepo_clicked();
|
||||
void on_btnSelectSourceRepo_clicked();
|
||||
void on_btnSelectTargetRepo_clicked();
|
||||
|
||||
private:
|
||||
void GetRepositoryPath(QString &pathResult);
|
||||
void GetRepositoryPath(QString &pathResult);
|
||||
|
||||
Ui::CloneDialog *ui;
|
||||
Ui::CloneDialog *ui;
|
||||
};
|
||||
|
||||
#endif // CLONEDIALOG_H
|
||||
#endif // CLONEDIALOG_H
|
||||
|
@ -1,171 +1,168 @@
|
||||
#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();
|
||||
ui->listView->setModel(&itemModel);
|
||||
ui->setupUi(this);
|
||||
ui->plainTextEdit->clear();
|
||||
ui->listView->setModel(&itemModel);
|
||||
|
||||
setWindowTitle(title);
|
||||
setWindowTitle(title);
|
||||
|
||||
// Activate the appropriate control based on mode
|
||||
ui->plainTextEdit->setVisible(!stashMode);
|
||||
ui->lineEdit->setVisible(stashMode);
|
||||
// Activate the appropriate control based on mode
|
||||
ui->plainTextEdit->setVisible(!stashMode);
|
||||
ui->lineEdit->setVisible(stashMode);
|
||||
|
||||
// Activate the checkbox if we have some text
|
||||
ui->chkRevertFiles->setVisible(stashMode);
|
||||
// Activate the checkbox if we have some text
|
||||
ui->chkRevertFiles->setVisible(stashMode);
|
||||
|
||||
ui->widgetBranchOptions->setVisible(!stashMode);
|
||||
ui->widgetBranchOptions->setVisible(!stashMode);
|
||||
|
||||
// Activate the combo if we have history
|
||||
ui->comboBox->setVisible(history!=0);
|
||||
if(history)
|
||||
{
|
||||
// Generate the history combo
|
||||
foreach(const QString msg, *history)
|
||||
{
|
||||
QString trimmed = msg.trimmed();
|
||||
if(trimmed.isEmpty())
|
||||
continue;
|
||||
// Activate the combo if we have history
|
||||
ui->comboBox->setVisible(history != 0);
|
||||
if (history)
|
||||
{
|
||||
// Generate the history combo
|
||||
foreach (const QString msg, *history)
|
||||
{
|
||||
QString trimmed = msg.trimmed();
|
||||
if (trimmed.isEmpty())
|
||||
continue;
|
||||
|
||||
commitMessages.append(trimmed);
|
||||
QStringList lines = trimmed.split('\n');
|
||||
QString first_line;
|
||||
if(!lines.empty())
|
||||
first_line = lines[0] + "...";
|
||||
commitMessages.append(trimmed);
|
||||
QStringList lines = trimmed.split('\n');
|
||||
QString first_line;
|
||||
if (!lines.empty())
|
||||
first_line = lines[0] + "...";
|
||||
|
||||
ui->comboBox->addItem(first_line);
|
||||
}
|
||||
}
|
||||
ui->comboBox->addItem(first_line);
|
||||
}
|
||||
}
|
||||
|
||||
// Populate file list
|
||||
for(QStringList::const_iterator it=files.begin(); it!=files.end(); ++it)
|
||||
{
|
||||
QStandardItem *si = new QStandardItem(*it);
|
||||
si->setCheckable(true);
|
||||
si->setCheckState(Qt::Checked);
|
||||
itemModel.appendRow(si);
|
||||
}
|
||||
// Populate file list
|
||||
for (QStringList::const_iterator it = files.begin(); it != files.end(); ++it)
|
||||
{
|
||||
QStandardItem *si = new QStandardItem(*it);
|
||||
si->setCheckable(true);
|
||||
si->setCheckState(Qt::Checked);
|
||||
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);
|
||||
action->setAutoRepeat(false);
|
||||
connect(shortcut, SIGNAL(activated()), ui->buttonBox->button(QDialogButtonBox::Ok), SLOT(click()));
|
||||
|
||||
// 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);
|
||||
action->setAutoRepeat(false);
|
||||
connect(shortcut, SIGNAL(activated()), ui->buttonBox->button(QDialogButtonBox::Ok), SLOT(click()));
|
||||
|
||||
// Abort commit with an Escape key from the comment box
|
||||
action = new QAction(ui->plainTextEdit);
|
||||
shortcut = new QShortcut(QKeySequence("Escape"), ui->plainTextEdit);
|
||||
action->setAutoRepeat(false);
|
||||
connect(shortcut, SIGNAL(activated()), ui->buttonBox->button(QDialogButtonBox::Cancel), SLOT(click()));
|
||||
// Abort commit with an Escape key from the comment box
|
||||
action = new QAction(ui->plainTextEdit);
|
||||
shortcut = new QShortcut(QKeySequence("Escape"), ui->plainTextEdit);
|
||||
action->setAutoRepeat(false);
|
||||
connect(shortcut, SIGNAL(activated()), ui->buttonBox->button(QDialogButtonBox::Cancel), SLOT(click()));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
CommitDialog::~CommitDialog()
|
||||
{
|
||||
delete ui;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool CommitDialog::runCommit(QWidget* parent, QStringList& files, QString& commitMsg, const QStringList& commitMsgHistory, QString &branchName, bool &privateBranch)
|
||||
bool CommitDialog::runCommit(QWidget *parent, QStringList &files, QString &commitMsg, const QStringList &commitMsgHistory, QString &branchName, bool &privateBranch)
|
||||
{
|
||||
CommitDialog dlg(parent, tr("Commit Changes"), files, &commitMsgHistory, false);
|
||||
int res = dlg.exec();
|
||||
CommitDialog dlg(parent, tr("Commit Changes"), files, &commitMsgHistory, false);
|
||||
int res = dlg.exec();
|
||||
|
||||
commitMsg = dlg.ui->plainTextEdit->toPlainText();
|
||||
commitMsg = dlg.ui->plainTextEdit->toPlainText();
|
||||
|
||||
if(res!=QDialog::Accepted)
|
||||
return false;
|
||||
if (res != QDialog::Accepted)
|
||||
return false;
|
||||
|
||||
files.clear();
|
||||
for(int i=0; i<dlg.itemModel.rowCount(); ++i)
|
||||
{
|
||||
QStandardItem *si = dlg.itemModel.item(i);
|
||||
if(si->checkState()!=Qt::Checked)
|
||||
continue;
|
||||
files.append(si->text());
|
||||
}
|
||||
files.clear();
|
||||
for (int i = 0; i < dlg.itemModel.rowCount(); ++i)
|
||||
{
|
||||
QStandardItem *si = dlg.itemModel.item(i);
|
||||
if (si->checkState() != Qt::Checked)
|
||||
continue;
|
||||
files.append(si->text());
|
||||
}
|
||||
|
||||
branchName.clear();
|
||||
if(dlg.ui->chkNewBranch->isChecked())
|
||||
{
|
||||
branchName = dlg.ui->lineBranchName->text().trimmed();
|
||||
privateBranch = dlg.ui->chkPrivateBranch->isChecked();
|
||||
}
|
||||
branchName.clear();
|
||||
if (dlg.ui->chkNewBranch->isChecked())
|
||||
{
|
||||
branchName = dlg.ui->lineBranchName->text().trimmed();
|
||||
privateBranch = dlg.ui->chkPrivateBranch->isChecked();
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool CommitDialog::runStashNew(QWidget* parent, QStringList& stashedFiles, QString& stashName, bool& revertFiles)
|
||||
bool CommitDialog::runStashNew(QWidget *parent, QStringList &stashedFiles, QString &stashName, bool &revertFiles)
|
||||
{
|
||||
CommitDialog dlg(parent, tr("Stash Changes"), stashedFiles, NULL, true);
|
||||
int res = dlg.exec();
|
||||
CommitDialog dlg(parent, tr("Stash Changes"), stashedFiles, NULL, true);
|
||||
int res = dlg.exec();
|
||||
|
||||
stashName = dlg.ui->lineEdit->text();
|
||||
stashName = dlg.ui->lineEdit->text();
|
||||
|
||||
if(res!=QDialog::Accepted)
|
||||
return false;
|
||||
if (res != QDialog::Accepted)
|
||||
return false;
|
||||
|
||||
stashedFiles.clear();
|
||||
for(int i=0; i<dlg.itemModel.rowCount(); ++i)
|
||||
{
|
||||
QStandardItem *si = dlg.itemModel.item(i);
|
||||
if(si->checkState()!=Qt::Checked)
|
||||
continue;
|
||||
stashedFiles.append(si->text());
|
||||
}
|
||||
stashedFiles.clear();
|
||||
for (int i = 0; i < dlg.itemModel.rowCount(); ++i)
|
||||
{
|
||||
QStandardItem *si = dlg.itemModel.item(i);
|
||||
if (si->checkState() != Qt::Checked)
|
||||
continue;
|
||||
stashedFiles.append(si->text());
|
||||
}
|
||||
|
||||
revertFiles = dlg.ui->chkRevertFiles->checkState() == Qt::Checked;
|
||||
return true;
|
||||
revertFiles = dlg.ui->chkRevertFiles->checkState() == Qt::Checked;
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void CommitDialog::on_comboBox_activated(int index)
|
||||
{
|
||||
Q_ASSERT(index < commitMessages.length());
|
||||
Q_ASSERT(index < commitMessages.length());
|
||||
|
||||
if(ui->plainTextEdit->isVisible())
|
||||
ui->plainTextEdit->setPlainText(commitMessages[index]);
|
||||
if (ui->plainTextEdit->isVisible())
|
||||
ui->plainTextEdit->setPlainText(commitMessages[index]);
|
||||
|
||||
if(ui->lineEdit->isVisible())
|
||||
ui->lineEdit->setText(commitMessages[index]);
|
||||
if (ui->lineEdit->isVisible())
|
||||
ui->lineEdit->setText(commitMessages[index]);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void CommitDialog::on_listView_doubleClicked(const QModelIndex &index)
|
||||
{
|
||||
QVariant data = itemModel.data(index);
|
||||
QString filename = data.toString();
|
||||
reinterpret_cast<MainWindow*>(parent())->diffFile(filename);
|
||||
QVariant data = itemModel.data(index);
|
||||
QString filename = data.toString();
|
||||
reinterpret_cast<MainWindow *>(parent())->diffFile(filename);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void CommitDialog::on_listView_clicked(const QModelIndex &)
|
||||
{
|
||||
int num_selected = 0;
|
||||
for(int i=0; i<itemModel.rowCount(); ++i)
|
||||
{
|
||||
QStandardItem *si = itemModel.item(i);
|
||||
if(si->checkState()==Qt::Checked)
|
||||
++num_selected;
|
||||
}
|
||||
int num_selected = 0;
|
||||
for (int i = 0; i < itemModel.rowCount(); ++i)
|
||||
{
|
||||
QStandardItem *si = itemModel.item(i);
|
||||
if (si->checkState() == Qt::Checked)
|
||||
++num_selected;
|
||||
}
|
||||
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(num_selected>0);
|
||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(num_selected > 0);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void CommitDialog::on_chkNewBranch_toggled(bool checked)
|
||||
{
|
||||
ui->lblPrivateBranch->setEnabled(checked);
|
||||
ui->chkPrivateBranch->setEnabled(checked);
|
||||
ui->lineBranchName->setEnabled(checked);
|
||||
ui->lblPrivateBranch->setEnabled(checked);
|
||||
ui->chkPrivateBranch->setEnabled(checked);
|
||||
ui->lineBranchName->setEnabled(checked);
|
||||
}
|
||||
|
@ -4,31 +4,32 @@
|
||||
#include <QDialog>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
namespace Ui {
|
||||
class CommitDialog;
|
||||
namespace Ui
|
||||
{
|
||||
class CommitDialog;
|
||||
}
|
||||
|
||||
class CommitDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CommitDialog(QWidget *parent, const QString &title, QStringList &files, const QStringList *history, bool stashMode);
|
||||
~CommitDialog();
|
||||
explicit CommitDialog(QWidget *parent, const QString &title, QStringList &files, const QStringList *history, bool stashMode);
|
||||
~CommitDialog();
|
||||
|
||||
static bool runStashNew(QWidget* parent, QStringList& stashedFiles, QString& stashName, bool &revertFiles);
|
||||
static bool runCommit(QWidget* parent, QStringList& files, QString& commitMsg, const QStringList &commitMsgHistory, QString& branchName, bool& privateBranch);
|
||||
static bool runStashNew(QWidget *parent, QStringList &stashedFiles, QString &stashName, bool &revertFiles);
|
||||
static bool runCommit(QWidget *parent, QStringList &files, QString &commitMsg, const QStringList &commitMsgHistory, QString &branchName, bool &privateBranch);
|
||||
|
||||
private slots:
|
||||
void on_comboBox_activated(int index);
|
||||
void on_listView_doubleClicked(const QModelIndex &index);
|
||||
void on_listView_clicked(const QModelIndex &index);
|
||||
void on_chkNewBranch_toggled(bool checked);
|
||||
void on_comboBox_activated(int index);
|
||||
void on_listView_doubleClicked(const QModelIndex &index);
|
||||
void on_listView_clicked(const QModelIndex &index);
|
||||
void on_chkNewBranch_toggled(bool checked);
|
||||
|
||||
private:
|
||||
Ui::CommitDialog *ui;
|
||||
QStandardItemModel itemModel;
|
||||
QStringList commitMessages;
|
||||
Ui::CommitDialog *ui;
|
||||
QStandardItemModel itemModel;
|
||||
QStringList commitMessages;
|
||||
};
|
||||
|
||||
#endif // COMMITDIALOG_H
|
||||
#endif // COMMITDIALOG_H
|
||||
|
@ -1,19 +1,18 @@
|
||||
#include "CustomWebView.h"
|
||||
#include <QMouseEvent>
|
||||
|
||||
CustomWebView::CustomWebView(QWidget *parent) :
|
||||
QWebEngineView(parent)
|
||||
CustomWebView::CustomWebView(QWidget *parent) : QWebEngineView(parent)
|
||||
{
|
||||
setUrl(QUrl("about:blank"));
|
||||
setUrl(QUrl("about:blank"));
|
||||
}
|
||||
|
||||
void CustomWebView::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
Qt::MouseButton but = event->button();
|
||||
if(but == Qt::XButton1)
|
||||
back();
|
||||
else if(but == Qt::XButton2)
|
||||
forward();
|
||||
else
|
||||
QWebEngineView::mousePressEvent(event);
|
||||
Qt::MouseButton but = event->button();
|
||||
if (but == Qt::XButton1)
|
||||
back();
|
||||
else if (but == Qt::XButton2)
|
||||
forward();
|
||||
else
|
||||
QWebEngineView::mousePressEvent(event);
|
||||
}
|
||||
|
@ -5,17 +5,16 @@
|
||||
|
||||
class CustomWebView : public QWebEngineView
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CustomWebView(QWidget *parent = 0);
|
||||
explicit CustomWebView(QWidget *parent = 0);
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
protected:
|
||||
virtual void mousePressEvent(QMouseEvent *event);
|
||||
|
||||
virtual void mousePressEvent(QMouseEvent *event);
|
||||
};
|
||||
|
||||
#endif // CUSTOMWEBVIEW_H
|
||||
#endif // CUSTOMWEBVIEW_H
|
||||
|
@ -1,64 +1,61 @@
|
||||
#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);
|
||||
ui->label->setText(message);
|
||||
ui->listView->setModel(&itemModel);
|
||||
setWindowTitle(title);
|
||||
ui->label->setText(message);
|
||||
ui->listView->setModel(&itemModel);
|
||||
|
||||
if(!checkBoxText.isEmpty() && checkBoxResult)
|
||||
{
|
||||
checkBox = new QCheckBox(this);
|
||||
checkBox->setText(checkBoxText);
|
||||
checkBox->setEnabled(true);
|
||||
checkBox->setChecked(*checkBoxResult);
|
||||
this->checkBoxResult = checkBoxResult;
|
||||
ui->verticalLayout->insertWidget(2, checkBox);
|
||||
}
|
||||
if (!checkBoxText.isEmpty() && checkBoxResult)
|
||||
{
|
||||
checkBox = new QCheckBox(this);
|
||||
checkBox->setText(checkBoxText);
|
||||
checkBox->setEnabled(true);
|
||||
checkBox->setChecked(*checkBoxResult);
|
||||
this->checkBoxResult = checkBoxResult;
|
||||
ui->verticalLayout->insertWidget(2, checkBox);
|
||||
}
|
||||
|
||||
if(listData.empty())
|
||||
ui->listView->setVisible(false);
|
||||
else
|
||||
{
|
||||
foreach(const QString &s, listData)
|
||||
itemModel.appendRow(new QStandardItem(s));
|
||||
}
|
||||
if (listData.empty())
|
||||
ui->listView->setVisible(false);
|
||||
else
|
||||
{
|
||||
foreach (const QString &s, listData)
|
||||
itemModel.appendRow(new QStandardItem(s));
|
||||
}
|
||||
}
|
||||
|
||||
FileActionDialog::~FileActionDialog()
|
||||
{
|
||||
delete ui;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
bool FileActionDialog::run(QWidget *parent, const QString &title, const QString &message, const QStringList &listData, const QString &checkBoxText, bool *checkBoxResult)
|
||||
{
|
||||
FileActionDialog dlg(parent, title, message, listData, checkBoxText, checkBoxResult);
|
||||
int res = dlg.exec();
|
||||
FileActionDialog dlg(parent, title, message, listData, checkBoxText, checkBoxResult);
|
||||
int res = dlg.exec();
|
||||
|
||||
if(!checkBoxText.isEmpty() && checkBoxResult && dlg.checkBox)
|
||||
*checkBoxResult = dlg.checkBox->isChecked();
|
||||
if (!checkBoxText.isEmpty() && checkBoxResult && dlg.checkBox)
|
||||
*checkBoxResult = dlg.checkBox->isChecked();
|
||||
|
||||
return res == QDialog::Accepted;
|
||||
return res == QDialog::Accepted;
|
||||
}
|
||||
|
||||
QDialogButtonBox::StandardButton FileActionDialog::runStandardButtons(QWidget *parent, StandardButtons buttons, const QString &title, const QString &message, const QStringList &listData)
|
||||
{
|
||||
FileActionDialog dlg(parent, title, message, listData);
|
||||
dlg.ui->buttonBox->setStandardButtons(buttons);
|
||||
FileActionDialog dlg(parent, title, message, listData);
|
||||
dlg.ui->buttonBox->setStandardButtons(buttons);
|
||||
|
||||
dlg.exec();
|
||||
return dlg.clickedButton;
|
||||
dlg.exec();
|
||||
return dlg.clickedButton;
|
||||
}
|
||||
|
||||
void FileActionDialog::on_buttonBox_clicked(QAbstractButton *button)
|
||||
{
|
||||
// Retrieve the flag corresponding to the standard clicked
|
||||
clickedButton = ui->buttonBox->standardButton(button);
|
||||
// Retrieve the flag corresponding to the standard clicked
|
||||
clickedButton = ui->buttonBox->standardButton(button);
|
||||
}
|
||||
|
||||
|
@ -2,37 +2,37 @@
|
||||
#define FILEACTIONDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QStandardItemModel>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QStandardItemModel>
|
||||
|
||||
namespace Ui {
|
||||
class FileActionDialog;
|
||||
namespace Ui
|
||||
{
|
||||
class FileActionDialog;
|
||||
}
|
||||
|
||||
class FileActionDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FileActionDialog(QWidget *parent, const QString &title, const QString &message, const QStringList &listData, const QString &checkBoxText=QString(), bool *checkBoxResult=0);
|
||||
explicit FileActionDialog(QWidget *parent, const QString &title, const QString &message, const QStringList &listData, const QString &checkBoxText = QString(), bool *checkBoxResult = 0);
|
||||
~FileActionDialog();
|
||||
|
||||
static bool run(QWidget *parent, const QString &title, const QString &message, const QStringList &listData, const QString &checkBoxText=QString(), bool *checkBoxResult=0);
|
||||
static bool run(QWidget *parent, const QString &title, const QString &message, const QStringList &listData, const QString &checkBoxText = QString(), bool *checkBoxResult = 0);
|
||||
|
||||
typedef QDialogButtonBox::StandardButton StandardButton;
|
||||
typedef QDialogButtonBox::StandardButtons StandardButtons;
|
||||
|
||||
static StandardButton runStandardButtons(QWidget *parent, StandardButtons, const QString &title, const QString &message, const QStringList &listData);
|
||||
typedef QDialogButtonBox::StandardButton StandardButton;
|
||||
typedef QDialogButtonBox::StandardButtons StandardButtons;
|
||||
|
||||
static StandardButton runStandardButtons(QWidget *parent, StandardButtons, const QString &title, const QString &message, const QStringList &listData);
|
||||
|
||||
private slots:
|
||||
void on_buttonBox_clicked(QAbstractButton *button);
|
||||
void on_buttonBox_clicked(QAbstractButton *button);
|
||||
|
||||
private:
|
||||
Ui::FileActionDialog *ui;
|
||||
QStandardItemModel itemModel;
|
||||
class QCheckBox *checkBox;
|
||||
bool *checkBoxResult;
|
||||
StandardButton clickedButton;
|
||||
QStandardItemModel itemModel;
|
||||
class QCheckBox *checkBox;
|
||||
bool *checkBoxResult;
|
||||
StandardButton clickedButton;
|
||||
};
|
||||
|
||||
#endif // FILEACTIONDIALOG_H
|
||||
#endif // FILEACTIONDIALOG_H
|
||||
|
@ -1,31 +1,27 @@
|
||||
#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)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton)
|
||||
dragStartPos = event->pos();
|
||||
if (event->button() == Qt::LeftButton)
|
||||
dragStartPos = event->pos();
|
||||
|
||||
QTableView::mousePressEvent(event);
|
||||
QTableView::mousePressEvent(event);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void FileTableView::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
int distance = (event->pos() - dragStartPos).manhattanLength();
|
||||
if (event->buttons() & Qt::LeftButton && distance >= QApplication::startDragDistance())
|
||||
{
|
||||
dragOutEvent();
|
||||
QTableView::mouseReleaseEvent(event);
|
||||
}
|
||||
else
|
||||
QTableView::mouseMoveEvent(event);
|
||||
|
||||
int distance = (event->pos() - dragStartPos).manhattanLength();
|
||||
if (event->buttons() & Qt::LeftButton && distance >= QApplication::startDragDistance())
|
||||
{
|
||||
dragOutEvent();
|
||||
QTableView::mouseReleaseEvent(event);
|
||||
}
|
||||
else
|
||||
QTableView::mouseMoveEvent(event);
|
||||
}
|
||||
|
@ -1,24 +1,24 @@
|
||||
#ifndef FILETABLEVIEW_H
|
||||
#define FILETABLEVIEW_H
|
||||
|
||||
#include <QTableView>
|
||||
#include <QPoint>
|
||||
#include <QTableView>
|
||||
|
||||
class FileTableView : public QTableView
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit FileTableView(QWidget *parent = 0);
|
||||
explicit FileTableView(QWidget *parent = 0);
|
||||
|
||||
signals:
|
||||
void dragOutEvent();
|
||||
void dragOutEvent();
|
||||
|
||||
private:
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
void mousePressEvent(QMouseEvent *event);
|
||||
void mouseMoveEvent(QMouseEvent *event);
|
||||
|
||||
private:
|
||||
QPoint dragStartPos;
|
||||
QPoint dragStartPos;
|
||||
};
|
||||
|
||||
#endif // FILETABLEVIEW_H
|
||||
#endif // FILETABLEVIEW_H
|
||||
|
1541
src/Fossil.cpp
1541
src/Fossil.cpp
File diff suppressed because it is too large
Load Diff
182
src/Fossil.h
182
src/Fossil.h
@ -2,121 +2,119 @@
|
||||
#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);
|
||||
|
||||
Fossil();
|
||||
void Init(UICallback *callback, const QString &exePath);
|
||||
// Repositories
|
||||
bool createRepository(const QString &repositoryPath);
|
||||
bool cloneRepository(const QString &repository, const QUrl &url, const QUrl &proxyUrl);
|
||||
|
||||
// Repositories
|
||||
bool createRepository(const QString &repositoryPath);
|
||||
bool cloneRepository(const QString &repository, const QUrl &url, const QUrl &proxyUrl);
|
||||
// Workspace
|
||||
bool createWorkspace(const QString &repositoryPath, const QString &workspacePath);
|
||||
bool closeWorkspace(bool force = false);
|
||||
void setWorkspace(const QString &_workspacePath);
|
||||
bool pushWorkspace(const QUrl &url);
|
||||
bool pullWorkspace(const QUrl &url);
|
||||
bool undoWorkspace(QStringList &result, bool explainOnly);
|
||||
bool updateWorkspace(QStringList &result, const QString &revision, bool explainOnly);
|
||||
bool statusWorkspace(QStringList &result);
|
||||
WorkspaceState getWorkspaceState();
|
||||
static bool isWorkspace(const QString &path);
|
||||
|
||||
// Workspace
|
||||
bool createWorkspace(const QString &repositoryPath, const QString& workspacePath);
|
||||
bool closeWorkspace(bool force=false);
|
||||
void setWorkspace(const QString &_workspacePath);
|
||||
bool pushWorkspace(const QUrl& url);
|
||||
bool pullWorkspace(const QUrl& url);
|
||||
bool undoWorkspace(QStringList& result, bool explainOnly);
|
||||
bool updateWorkspace(QStringList& result, const QString& revision, bool explainOnly);
|
||||
bool statusWorkspace(QStringList& result);
|
||||
WorkspaceState getWorkspaceState();
|
||||
static bool isWorkspace(const QString &path);
|
||||
// Workspace Information
|
||||
const QString &getProjectName() const { return projectName; }
|
||||
const QString &getRepositoryFile() const { return repositoryFile; }
|
||||
const QString &getWorkspacePath() const { return workspacePath; }
|
||||
|
||||
// Workspace Information
|
||||
const QString &getProjectName() const { return projectName; }
|
||||
const QString &getRepositoryFile() const { return repositoryFile; }
|
||||
const QString &getWorkspacePath() const { return workspacePath; }
|
||||
// Files
|
||||
bool listFiles(QStringList &files);
|
||||
bool diffFile(const QString &repoFile, bool graphical);
|
||||
bool commitFiles(const QStringList &fileList, const QString &comment, const QString &newBranchName, bool isPrivateBranch);
|
||||
bool addFiles(const QStringList &fileList);
|
||||
bool removeFiles(const QStringList &fileList, bool deleteLocal);
|
||||
bool revertFiles(const QStringList &fileList);
|
||||
bool renameFile(const QString &beforePath, const QString &afterPath, bool renameLocal);
|
||||
|
||||
// Files
|
||||
bool listFiles(QStringList &files);
|
||||
bool diffFile(const QString &repoFile, bool graphical);
|
||||
bool commitFiles(const QStringList &fileList, const QString &comment, const QString& newBranchName, bool isPrivateBranch);
|
||||
bool addFiles(const QStringList& fileList);
|
||||
bool removeFiles(const QStringList& fileList, bool deleteLocal);
|
||||
bool revertFiles(const QStringList& fileList);
|
||||
bool renameFile(const QString& beforePath, const QString& afterPath, bool renameLocal);
|
||||
// Settings
|
||||
bool getSettings(QStringList &result);
|
||||
bool setSetting(const QString &name, const QString &value, bool global);
|
||||
|
||||
// Settings
|
||||
bool getSettings(QStringList& result);
|
||||
bool setSetting(const QString &name, const QString &value, bool global);
|
||||
// Remotes
|
||||
bool setRemoteUrl(const QUrl &url);
|
||||
bool getRemoteUrl(QUrl &url);
|
||||
|
||||
// Remotes
|
||||
bool setRemoteUrl(const QUrl& url);
|
||||
bool getRemoteUrl(QUrl &url);
|
||||
// Stashes
|
||||
bool stashNew(const QStringList &fileList, const QString &name, bool revert);
|
||||
bool stashList(stashmap_t &stashes);
|
||||
bool stashApply(const QString &name);
|
||||
bool stashDrop(const QString &name);
|
||||
bool stashDiff(const QString &name);
|
||||
|
||||
// Stashes
|
||||
bool stashNew(const QStringList& fileList, const QString& name, bool revert);
|
||||
bool stashList(stashmap_t &stashes);
|
||||
bool stashApply(const QString& name);
|
||||
bool stashDrop(const QString& name);
|
||||
bool stashDiff(const QString& name);
|
||||
// Tags
|
||||
bool tagList(QStringMap &tags);
|
||||
bool tagNew(const QString &name, const QString &revision);
|
||||
bool tagDelete(const QString &name, const QString &revision);
|
||||
|
||||
// Tags
|
||||
bool tagList(QStringMap& tags);
|
||||
bool tagNew(const QString& name, const QString& revision);
|
||||
bool tagDelete(const QString& name, const QString& revision);
|
||||
// Branches
|
||||
bool branchList(QStringList &branches, QStringList &activeBranches);
|
||||
bool branchNew(const QString &name, const QString &revisionBasis, bool isPrivate = false);
|
||||
bool branchMerge(QStringList &res, const QString &revision, bool integrate, bool force, bool testOnly);
|
||||
|
||||
// Branches
|
||||
bool branchList(QStringList& branches, QStringList& activeBranches);
|
||||
bool branchNew(const QString& name, const QString& revisionBasis, bool isPrivate=false);
|
||||
bool branchMerge(QStringList& res, const QString& revision, bool integrate, bool force, bool testOnly);
|
||||
const QString &getCurrentRevision() const { return currentRevision; }
|
||||
const QStringList &getActiveTags() const { return activeTags; }
|
||||
|
||||
const QString &getCurrentRevision() const { return currentRevision; }
|
||||
const QStringList &getActiveTags() const { return activeTags; }
|
||||
// UI
|
||||
bool uiRunning() const;
|
||||
bool startUI(const QString &httpPort);
|
||||
void stopUI();
|
||||
const QString &getUIHttpPort() const { return fossilUIPort; }
|
||||
QString getUIHttpAddress() const;
|
||||
|
||||
// UI
|
||||
bool uiRunning() const;
|
||||
bool startUI(const QString &httpPort);
|
||||
void stopUI();
|
||||
const QString &getUIHttpPort() const { return fossilUIPort; }
|
||||
QString getUIHttpAddress() const;
|
||||
|
||||
// Fossil executable
|
||||
void setExePath(const QString &path) { fossilPath = path; }
|
||||
bool getExeVersion(QString &version);
|
||||
// Fossil executable
|
||||
void setExePath(const QString &path) { fossilPath = path; }
|
||||
bool getExeVersion(QString &version);
|
||||
|
||||
private:
|
||||
enum RunFlags
|
||||
{
|
||||
RUNFLAGS_NONE = 0<<0,
|
||||
RUNFLAGS_SILENT_INPUT = 1<<0,
|
||||
RUNFLAGS_SILENT_OUTPUT = 1<<1,
|
||||
RUNFLAGS_SILENT_ALL = RUNFLAGS_SILENT_INPUT | RUNFLAGS_SILENT_OUTPUT,
|
||||
RUNFLAGS_DETACHED = 1<<2,
|
||||
RUNFLAGS_DEBUG = 1<<3,
|
||||
};
|
||||
enum RunFlags
|
||||
{
|
||||
RUNFLAGS_NONE = 0 << 0,
|
||||
RUNFLAGS_SILENT_INPUT = 1 << 0,
|
||||
RUNFLAGS_SILENT_OUTPUT = 1 << 1,
|
||||
RUNFLAGS_SILENT_ALL = RUNFLAGS_SILENT_INPUT | RUNFLAGS_SILENT_OUTPUT,
|
||||
RUNFLAGS_DETACHED = 1 << 2,
|
||||
RUNFLAGS_DEBUG = 1 << 3,
|
||||
};
|
||||
|
||||
void setRepositoryFile(const QString &filename) { repositoryFile = filename; }
|
||||
bool runFossil(const QStringList &args, QStringList *output=0, int runFlags=RUNFLAGS_NONE);
|
||||
bool runFossilRaw(const QStringList &args, QStringList *output, int *exitCode, int runFlags);
|
||||
QString getFossilPath();
|
||||
void setRepositoryFile(const QString &filename) { repositoryFile = filename; }
|
||||
bool runFossil(const QStringList &args, QStringList *output = 0, int runFlags = RUNFLAGS_NONE);
|
||||
bool runFossilRaw(const QStringList &args, QStringList *output, int *exitCode, int runFlags);
|
||||
QString getFossilPath();
|
||||
|
||||
void log(const QString &text, bool isHTML=false)
|
||||
{
|
||||
if(uiCallback)
|
||||
uiCallback->logText(text, isHTML);
|
||||
}
|
||||
void log(const QString &text, bool isHTML = false)
|
||||
{
|
||||
if (uiCallback)
|
||||
uiCallback->logText(text, isHTML);
|
||||
}
|
||||
|
||||
UICallback *uiCallback;
|
||||
QString workspacePath;
|
||||
QString fossilPath; // The value from the settings
|
||||
QString repositoryFile;
|
||||
QString projectName;
|
||||
QString currentRevision;
|
||||
QStringList activeTags;
|
||||
LoggedProcess fossilUI;
|
||||
QString fossilUIPort;
|
||||
UICallback *uiCallback;
|
||||
QString workspacePath;
|
||||
QString fossilPath; // The value from the settings
|
||||
QString repositoryFile;
|
||||
QString projectName;
|
||||
QString currentRevision;
|
||||
QStringList activeTags;
|
||||
LoggedProcess fossilUI;
|
||||
QString fossilUIPort;
|
||||
};
|
||||
|
||||
|
||||
#endif // FOSSIL_H
|
||||
#endif // FOSSIL_H
|
||||
|
@ -1,70 +1,66 @@
|
||||
#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);
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->lineUIPort->setText(settings->GetFossilValue(FOSSIL_SETTING_HTTP_PORT).toString());
|
||||
ui->lineUIPort->setText(settings->GetFossilValue(FOSSIL_SETTING_HTTP_PORT).toString());
|
||||
|
||||
// Global Settings
|
||||
ui->lineGDiffCommand->setText(settings->GetFossilValue(FOSSIL_SETTING_GDIFF_CMD).toString());
|
||||
ui->lineGMergeCommand->setText(settings->GetFossilValue(FOSSIL_SETTING_GMERGE_CMD).toString());
|
||||
ui->lineProxy->setText(settings->GetFossilValue(FOSSIL_SETTING_PROXY_URL).toString());
|
||||
// Global Settings
|
||||
ui->lineGDiffCommand->setText(settings->GetFossilValue(FOSSIL_SETTING_GDIFF_CMD).toString());
|
||||
ui->lineGMergeCommand->setText(settings->GetFossilValue(FOSSIL_SETTING_GMERGE_CMD).toString());
|
||||
ui->lineProxy->setText(settings->GetFossilValue(FOSSIL_SETTING_PROXY_URL).toString());
|
||||
|
||||
// Repository Settings
|
||||
ui->lineIgnore->setText(settings->GetFossilValue(FOSSIL_SETTING_IGNORE_GLOB).toString());
|
||||
ui->lineIgnoreCRNL->setText(settings->GetFossilValue(FOSSIL_SETTING_CRNL_GLOB).toString());
|
||||
// Repository Settings
|
||||
ui->lineIgnore->setText(settings->GetFossilValue(FOSSIL_SETTING_IGNORE_GLOB).toString());
|
||||
ui->lineIgnoreCRNL->setText(settings->GetFossilValue(FOSSIL_SETTING_CRNL_GLOB).toString());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
FslSettingsDialog::~FslSettingsDialog()
|
||||
{
|
||||
delete ui;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool FslSettingsDialog::run(QWidget *parent, Settings &settings)
|
||||
{
|
||||
FslSettingsDialog dlg(parent, settings);
|
||||
return dlg.exec() == QDialog::Accepted;
|
||||
FslSettingsDialog dlg(parent, settings);
|
||||
return dlg.exec() == QDialog::Accepted;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void FslSettingsDialog::on_buttonBox_accepted()
|
||||
{
|
||||
settings->SetFossilValue(FOSSIL_SETTING_HTTP_PORT, ui->lineUIPort->text());
|
||||
settings->SetFossilValue(FOSSIL_SETTING_HTTP_PORT, ui->lineUIPort->text());
|
||||
|
||||
settings->SetFossilValue(FOSSIL_SETTING_GDIFF_CMD, ui->lineGDiffCommand->text());
|
||||
settings->SetFossilValue(FOSSIL_SETTING_GMERGE_CMD, ui->lineGMergeCommand->text());
|
||||
settings->SetFossilValue(FOSSIL_SETTING_PROXY_URL, ui->lineProxy->text());
|
||||
settings->SetFossilValue(FOSSIL_SETTING_GDIFF_CMD, ui->lineGDiffCommand->text());
|
||||
settings->SetFossilValue(FOSSIL_SETTING_GMERGE_CMD, ui->lineGMergeCommand->text());
|
||||
settings->SetFossilValue(FOSSIL_SETTING_PROXY_URL, ui->lineProxy->text());
|
||||
|
||||
settings->SetFossilValue(FOSSIL_SETTING_IGNORE_GLOB, ui->lineIgnore->text());
|
||||
settings->SetFossilValue(FOSSIL_SETTING_CRNL_GLOB, ui->lineIgnoreCRNL->text());
|
||||
settings->SetFossilValue(FOSSIL_SETTING_IGNORE_GLOB, ui->lineIgnore->text());
|
||||
settings->SetFossilValue(FOSSIL_SETTING_CRNL_GLOB, ui->lineIgnoreCRNL->text());
|
||||
|
||||
settings->ApplyEnvironment();
|
||||
settings->ApplyEnvironment();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void FslSettingsDialog::on_btnSelectFossilGDiff_clicked()
|
||||
{
|
||||
QString path = SelectExe(this, tr("Select Graphical Diff application"));
|
||||
if(!path.isEmpty())
|
||||
ui->lineGDiffCommand->setText(QDir::toNativeSeparators(path));
|
||||
QString path = SelectExe(this, tr("Select Graphical Diff application"));
|
||||
if (!path.isEmpty())
|
||||
ui->lineGDiffCommand->setText(QDir::toNativeSeparators(path));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void FslSettingsDialog::on_btnSelectGMerge_clicked()
|
||||
{
|
||||
QString path = SelectExe(this, tr("Select Graphical Merge application"));
|
||||
if(!path.isEmpty())
|
||||
ui->lineGMergeCommand->setText(path);
|
||||
QString path = SelectExe(this, tr("Select Graphical Merge application"));
|
||||
if (!path.isEmpty())
|
||||
ui->lineGMergeCommand->setText(path);
|
||||
}
|
||||
|
||||
|
@ -1,33 +1,32 @@
|
||||
#ifndef FSLSETTINGSDIALOG_H
|
||||
#define FSLSETTINGSDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "AppSettings.h"
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class FslSettingsDialog;
|
||||
namespace Ui
|
||||
{
|
||||
class FslSettingsDialog;
|
||||
}
|
||||
|
||||
class FslSettingsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FslSettingsDialog(QWidget *parent, Settings &_settings);
|
||||
~FslSettingsDialog();
|
||||
|
||||
static bool run(QWidget *parent, Settings &_settings);
|
||||
explicit FslSettingsDialog(QWidget *parent, Settings &_settings);
|
||||
~FslSettingsDialog();
|
||||
|
||||
static bool run(QWidget *parent, Settings &_settings);
|
||||
|
||||
private slots:
|
||||
void on_buttonBox_accepted();
|
||||
void on_btnSelectFossilGDiff_clicked();
|
||||
void on_btnSelectGMerge_clicked();
|
||||
void on_buttonBox_accepted();
|
||||
void on_btnSelectFossilGDiff_clicked();
|
||||
void on_btnSelectGMerge_clicked();
|
||||
|
||||
private:
|
||||
|
||||
Ui::FslSettingsDialog *ui;
|
||||
Settings *settings;
|
||||
Ui::FslSettingsDialog *ui;
|
||||
Settings *settings;
|
||||
};
|
||||
|
||||
#endif // FSLSETTINGSDIALOG_H
|
||||
#endif // FSLSETTINGSDIALOG_H
|
||||
|
@ -3,20 +3,19 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
LoggedProcess::LoggedProcess(QObject *parent) : QProcess(parent)
|
||||
{
|
||||
setProcessChannelMode(QProcess::MergedChannels);
|
||||
connect(this, SIGNAL(readyReadStandardOutput()), this, SLOT(onReadyReadStandardOutput()));
|
||||
setProcessChannelMode(QProcess::MergedChannels);
|
||||
connect(this, SIGNAL(readyReadStandardOutput()), this, SLOT(onReadyReadStandardOutput()));
|
||||
}
|
||||
|
||||
void LoggedProcess::getLogAndClear(QByteArray &buffer)
|
||||
{
|
||||
QMutexLocker lck(&mutex);
|
||||
buffer = log;
|
||||
log.clear();
|
||||
QMutexLocker lck(&mutex);
|
||||
buffer = log;
|
||||
log.clear();
|
||||
}
|
||||
|
||||
void LoggedProcess::onReadyReadStandardOutput()
|
||||
{
|
||||
QMutexLocker lck(&mutex);
|
||||
log.append(readAllStandardOutput());
|
||||
QMutexLocker lck(&mutex);
|
||||
log.append(readAllStandardOutput());
|
||||
}
|
||||
|
||||
|
@ -1,24 +1,24 @@
|
||||
#ifndef LOGGEDPROCESS_H
|
||||
#define LOGGEDPROCESS_H
|
||||
|
||||
#include <QProcess>
|
||||
#include <QMutex>
|
||||
#include <QProcess>
|
||||
|
||||
class LoggedProcess : public QProcess
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit LoggedProcess(QObject *parent = 0);
|
||||
void getLogAndClear(QByteArray &buffer);
|
||||
bool isLogEmpty() const { return log.isEmpty(); }
|
||||
qint64 logBytesAvailable() const { return log.size(); }
|
||||
explicit LoggedProcess(QObject *parent = 0);
|
||||
void getLogAndClear(QByteArray &buffer);
|
||||
bool isLogEmpty() const { return log.isEmpty(); }
|
||||
qint64 logBytesAvailable() const { return log.size(); }
|
||||
|
||||
private slots:
|
||||
void onReadyReadStandardOutput();
|
||||
void onReadyReadStandardOutput();
|
||||
|
||||
private:
|
||||
QMutex mutex;
|
||||
QByteArray log;
|
||||
QMutex mutex;
|
||||
QByteArray log;
|
||||
};
|
||||
|
||||
#endif // LOGGEDPROCESS_H
|
||||
#endif // LOGGEDPROCESS_H
|
||||
|
4002
src/MainWindow.cpp
4002
src/MainWindow.cpp
File diff suppressed because it is too large
Load Diff
340
src/MainWindow.h
340
src/MainWindow.h
@ -1,14 +1,15 @@
|
||||
#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 {
|
||||
class MainWindow;
|
||||
namespace Ui
|
||||
{
|
||||
class MainWindow;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -16,195 +17,190 @@ namespace Ui {
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
class MainWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit MainWindow(Settings &_settings, QWidget *parent = 0, QString *workspacePath = 0);
|
||||
~MainWindow();
|
||||
bool diffFile(const QString& repoFile);
|
||||
void fullRefresh();
|
||||
explicit MainWindow(Settings &_settings, QWidget *parent = 0, QString *workspacePath = 0);
|
||||
~MainWindow();
|
||||
bool diffFile(const QString &repoFile);
|
||||
void fullRefresh();
|
||||
|
||||
private:
|
||||
bool refresh();
|
||||
bool scanWorkspace();
|
||||
void applySettings();
|
||||
void updateSettings();
|
||||
void updateRevision(const QString& revision);
|
||||
void setCurrentWorkspace(const QString &workspace);
|
||||
void log(const QString &text, bool isHTML=false);
|
||||
void setStatus(const QString &text);
|
||||
bool uiRunning() const;
|
||||
void getSelectionFilenames(QStringList &filenames, int includeMask=WorkspaceFile::TYPE_ALL, bool allIfEmpty=false);
|
||||
void getFileViewSelection(QStringList &filenames, int includeMask=WorkspaceFile::TYPE_ALL, bool allIfEmpty=false);
|
||||
void getDirViewSelection(QStringList &filenames, int includeMask=WorkspaceFile::TYPE_ALL, bool allIfEmpty=false);
|
||||
void getSelectionStashes(QStringList &stashNames);
|
||||
void getSelectionPaths(stringset_t &paths);
|
||||
void getSelectionRemotes(QStringList& remoteUrls);
|
||||
void getAllFilenames(QStringList &filenames, int includeMask=WorkspaceFile::TYPE_ALL);
|
||||
bool startUI();
|
||||
void stopUI();
|
||||
void enableActions(bool on);
|
||||
void addWorkspaceHistory(const QString &dir);
|
||||
void rebuildRecent();
|
||||
bool openWorkspace(const QString &path);
|
||||
void loadFossilSettings();
|
||||
void updateWorkspaceView();
|
||||
void updateFileView();
|
||||
void selectRootDir();
|
||||
void mergeRevision(const QString& defaultRevision);
|
||||
void updateCustomActions();
|
||||
void invokeCustomAction(int actionId);
|
||||
bool refresh();
|
||||
bool scanWorkspace();
|
||||
void applySettings();
|
||||
void updateSettings();
|
||||
void updateRevision(const QString &revision);
|
||||
void setCurrentWorkspace(const QString &workspace);
|
||||
void log(const QString &text, bool isHTML = false);
|
||||
void setStatus(const QString &text);
|
||||
bool uiRunning() const;
|
||||
void getSelectionFilenames(QStringList &filenames, int includeMask = WorkspaceFile::TYPE_ALL, bool allIfEmpty = false);
|
||||
void getFileViewSelection(QStringList &filenames, int includeMask = WorkspaceFile::TYPE_ALL, bool allIfEmpty = false);
|
||||
void getDirViewSelection(QStringList &filenames, int includeMask = WorkspaceFile::TYPE_ALL, bool allIfEmpty = false);
|
||||
void getSelectionStashes(QStringList &stashNames);
|
||||
void getSelectionPaths(stringset_t &paths);
|
||||
void getSelectionRemotes(QStringList &remoteUrls);
|
||||
void getAllFilenames(QStringList &filenames, int includeMask = WorkspaceFile::TYPE_ALL);
|
||||
bool startUI();
|
||||
void stopUI();
|
||||
void enableActions(bool on);
|
||||
void addWorkspaceHistory(const QString &dir);
|
||||
void rebuildRecent();
|
||||
bool openWorkspace(const QString &path);
|
||||
void loadFossilSettings();
|
||||
void updateWorkspaceView();
|
||||
void updateFileView();
|
||||
void selectRootDir();
|
||||
void mergeRevision(const QString &defaultRevision);
|
||||
void updateCustomActions();
|
||||
void invokeCustomAction(int actionId);
|
||||
|
||||
void fossilBrowse(const QString &fossilUrl);
|
||||
void dragEnterEvent(class QDragEnterEvent *event);
|
||||
void dropEvent(class QDropEvent *event);
|
||||
void setBusy(bool busy);
|
||||
virtual QMenu *createPopupMenu();
|
||||
const QIcon& getCachedIcon(const char *name);
|
||||
const QIcon& getCachedFileIcon(const QFileInfo &finfo);
|
||||
void fossilBrowse(const QString &fossilUrl);
|
||||
void dragEnterEvent(class QDragEnterEvent *event);
|
||||
void dropEvent(class QDropEvent *event);
|
||||
void setBusy(bool busy);
|
||||
virtual QMenu *createPopupMenu();
|
||||
const QIcon &getCachedIcon(const char *name);
|
||||
const QIcon &getCachedFileIcon(const QFileInfo &finfo);
|
||||
|
||||
enum ViewMode
|
||||
{
|
||||
VIEWMODE_LIST,
|
||||
VIEWMODE_TREE
|
||||
};
|
||||
enum ViewMode
|
||||
{
|
||||
VIEWMODE_LIST,
|
||||
VIEWMODE_TREE
|
||||
};
|
||||
|
||||
private slots:
|
||||
// Manual slots.
|
||||
// Use a different naming scheme to prevent warnings from Qt's automatic signaling
|
||||
void onOpenRecent();
|
||||
void onWorkspaceTreeViewSelectionChanged(const class QItemSelection &selected, const class QItemSelection &deselected);
|
||||
void onFileViewDragOut();
|
||||
void onSearchBoxTextChanged(const QString &text);
|
||||
void onSearch();
|
||||
void onCustomActionTriggered();
|
||||
// Manual slots.
|
||||
// Use a different naming scheme to prevent warnings from Qt's automatic signaling
|
||||
void onOpenRecent();
|
||||
void onWorkspaceTreeViewSelectionChanged(const class QItemSelection &selected, const class QItemSelection &deselected);
|
||||
void onFileViewDragOut();
|
||||
void onSearchBoxTextChanged(const QString &text);
|
||||
void onSearch();
|
||||
void onCustomActionTriggered();
|
||||
|
||||
// Designer slots
|
||||
void on_actionRefresh_triggered();
|
||||
void on_actionDiff_triggered();
|
||||
void on_actionFossilUI_triggered();
|
||||
void on_actionQuit_triggered();
|
||||
void on_actionTimeline_triggered();
|
||||
void on_actionHistory_triggered();
|
||||
void on_actionClearLog_triggered();
|
||||
void on_fileTableView_doubleClicked(const QModelIndex &index);
|
||||
void on_workspaceTreeView_doubleClicked(const QModelIndex &index);
|
||||
void on_actionOpenFile_triggered();
|
||||
void on_actionPush_triggered();
|
||||
void on_actionPull_triggered();
|
||||
void on_actionPushRemote_triggered();
|
||||
void on_actionPullRemote_triggered();
|
||||
void on_actionCommit_triggered();
|
||||
void on_actionAdd_triggered();
|
||||
void on_actionDelete_triggered();
|
||||
void on_actionRevert_triggered();
|
||||
void on_actionOpenContaining_triggered();
|
||||
void on_actionRename_triggered();
|
||||
void on_actionUndo_triggered();
|
||||
void on_actionAbout_triggered();
|
||||
void on_actionUpdate_triggered();
|
||||
void on_actionSettings_triggered();
|
||||
void on_actionFossilSettings_triggered();
|
||||
void on_actionViewUnchanged_triggered();
|
||||
void on_actionViewModified_triggered();
|
||||
void on_actionViewUnknown_triggered();
|
||||
void on_actionViewIgnored_triggered();
|
||||
void on_actionViewAll_triggered();
|
||||
void on_actionViewModifedOnly_triggered();
|
||||
void on_actionViewAsList_triggered();
|
||||
void on_actionViewAsFolders_triggered();
|
||||
void on_actionOpenFolder_triggered();
|
||||
void on_actionRenameFolder_triggered();
|
||||
void on_actionNewRepository_triggered();
|
||||
void on_actionOpenRepository_triggered();
|
||||
void on_actionCloseRepository_triggered();
|
||||
void on_actionCloneRepository_triggered();
|
||||
void on_actionCreateStash_triggered();
|
||||
void on_actionApplyStash_triggered();
|
||||
void on_actionDeleteStash_triggered();
|
||||
void on_actionDiffStash_triggered();
|
||||
void on_textBrowser_customContextMenuRequested(const QPoint &pos);
|
||||
void on_fileTableView_customContextMenuRequested(const QPoint &pos);
|
||||
void on_workspaceTreeView_customContextMenuRequested(const QPoint &pos);
|
||||
void on_actionCreateTag_triggered();
|
||||
void on_actionDeleteTag_triggered();
|
||||
void on_actionCreateBranch_triggered();
|
||||
void on_actionMergeBranch_triggered();
|
||||
void on_actionEditRemote_triggered();
|
||||
void on_actionSetDefaultRemote_triggered();
|
||||
void on_actionAddRemote_triggered();
|
||||
void on_actionDeleteRemote_triggered();
|
||||
void on_actionAbortOperation_triggered();
|
||||
// Designer slots
|
||||
void on_actionRefresh_triggered();
|
||||
void on_actionDiff_triggered();
|
||||
void on_actionFossilUI_triggered();
|
||||
void on_actionQuit_triggered();
|
||||
void on_actionTimeline_triggered();
|
||||
void on_actionHistory_triggered();
|
||||
void on_actionClearLog_triggered();
|
||||
void on_fileTableView_doubleClicked(const QModelIndex &index);
|
||||
void on_workspaceTreeView_doubleClicked(const QModelIndex &index);
|
||||
void on_actionOpenFile_triggered();
|
||||
void on_actionPush_triggered();
|
||||
void on_actionPull_triggered();
|
||||
void on_actionPushRemote_triggered();
|
||||
void on_actionPullRemote_triggered();
|
||||
void on_actionCommit_triggered();
|
||||
void on_actionAdd_triggered();
|
||||
void on_actionDelete_triggered();
|
||||
void on_actionRevert_triggered();
|
||||
void on_actionOpenContaining_triggered();
|
||||
void on_actionRename_triggered();
|
||||
void on_actionUndo_triggered();
|
||||
void on_actionAbout_triggered();
|
||||
void on_actionUpdate_triggered();
|
||||
void on_actionSettings_triggered();
|
||||
void on_actionFossilSettings_triggered();
|
||||
void on_actionViewUnchanged_triggered();
|
||||
void on_actionViewModified_triggered();
|
||||
void on_actionViewUnknown_triggered();
|
||||
void on_actionViewIgnored_triggered();
|
||||
void on_actionViewAll_triggered();
|
||||
void on_actionViewModifedOnly_triggered();
|
||||
void on_actionViewAsList_triggered();
|
||||
void on_actionViewAsFolders_triggered();
|
||||
void on_actionOpenFolder_triggered();
|
||||
void on_actionRenameFolder_triggered();
|
||||
void on_actionNewRepository_triggered();
|
||||
void on_actionOpenRepository_triggered();
|
||||
void on_actionCloseRepository_triggered();
|
||||
void on_actionCloneRepository_triggered();
|
||||
void on_actionCreateStash_triggered();
|
||||
void on_actionApplyStash_triggered();
|
||||
void on_actionDeleteStash_triggered();
|
||||
void on_actionDiffStash_triggered();
|
||||
void on_textBrowser_customContextMenuRequested(const QPoint &pos);
|
||||
void on_fileTableView_customContextMenuRequested(const QPoint &pos);
|
||||
void on_workspaceTreeView_customContextMenuRequested(const QPoint &pos);
|
||||
void on_actionCreateTag_triggered();
|
||||
void on_actionDeleteTag_triggered();
|
||||
void on_actionCreateBranch_triggered();
|
||||
void on_actionMergeBranch_triggered();
|
||||
void on_actionEditRemote_triggered();
|
||||
void on_actionSetDefaultRemote_triggered();
|
||||
void on_actionAddRemote_triggered();
|
||||
void on_actionDeleteRemote_triggered();
|
||||
void on_actionAbortOperation_triggered();
|
||||
|
||||
private:
|
||||
class MainWinUICallback : public UICallback
|
||||
{
|
||||
public:
|
||||
MainWinUICallback() : mainWindow(0), aborted(false)
|
||||
{}
|
||||
class MainWinUICallback : public UICallback
|
||||
{
|
||||
public:
|
||||
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);
|
||||
virtual void updateProcess(const QString& text);
|
||||
virtual bool processAborted() const { return aborted; }
|
||||
virtual void endProcess();
|
||||
virtual QMessageBox::StandardButton Query(const QString &title, const QString &query, QMessageBox::StandardButtons buttons);
|
||||
void abortProcess() { aborted = true; }
|
||||
virtual void logText(const QString &text, bool isHTML);
|
||||
virtual void beginProcess(const QString &text);
|
||||
virtual void updateProcess(const QString &text);
|
||||
virtual bool processAborted() const { return aborted; }
|
||||
virtual void endProcess();
|
||||
virtual QMessageBox::StandardButton Query(const QString &title, const QString &query, QMessageBox::StandardButtons buttons);
|
||||
void abortProcess() { aborted = true; }
|
||||
|
||||
private:
|
||||
class MainWindow *mainWindow;
|
||||
bool aborted;
|
||||
};
|
||||
private:
|
||||
class MainWindow *mainWindow;
|
||||
bool aborted;
|
||||
};
|
||||
|
||||
friend class MainWinUICallback;
|
||||
friend class MainWinUICallback;
|
||||
|
||||
enum
|
||||
{
|
||||
MAX_RECENT=5
|
||||
};
|
||||
enum
|
||||
{
|
||||
MAX_RECENT = 5
|
||||
};
|
||||
|
||||
typedef QMap<QString, QIcon> icon_map_t;
|
||||
typedef QMap<QString, QIcon> icon_map_t;
|
||||
|
||||
Ui::MainWindow *ui;
|
||||
QFileIconProvider iconProvider;
|
||||
icon_map_t iconCache;
|
||||
class QAction *recentWorkspaceActs[MAX_RECENT];
|
||||
class QAction *customActions[MAX_CUSTOM_ACTIONS];
|
||||
class QAction *fileActionSeparator;
|
||||
class QAction *workspaceActionSeparator;
|
||||
class QProgressBar *progressBar;
|
||||
class QToolButton *abortButton;
|
||||
class QLabel *lblTags;
|
||||
class SearchBox *searchBox;
|
||||
class QShortcut *searchShortcut;
|
||||
QMenu *menuWorkspace;
|
||||
QMenu *menuStashes;
|
||||
QMenu *menuTags;
|
||||
QMenu *menuBranches;
|
||||
QMenu *menuRemotes;
|
||||
Ui::MainWindow *ui;
|
||||
QFileIconProvider iconProvider;
|
||||
icon_map_t iconCache;
|
||||
class QAction *recentWorkspaceActs[MAX_RECENT];
|
||||
class QAction *customActions[MAX_CUSTOM_ACTIONS];
|
||||
class QAction *fileActionSeparator;
|
||||
class QAction *workspaceActionSeparator;
|
||||
class QProgressBar *progressBar;
|
||||
class QToolButton *abortButton;
|
||||
class QLabel *lblTags;
|
||||
class SearchBox *searchBox;
|
||||
class QShortcut *searchShortcut;
|
||||
QMenu *menuWorkspace;
|
||||
QMenu *menuStashes;
|
||||
QMenu *menuTags;
|
||||
QMenu *menuBranches;
|
||||
QMenu *menuRemotes;
|
||||
|
||||
bool operationAborted;
|
||||
stringset_t selectedDirs; // The directory selected in the tree
|
||||
QStringList selectedTags;
|
||||
QStringList selectedBranches;
|
||||
QStringList versionList;
|
||||
bool operationAborted;
|
||||
stringset_t selectedDirs; // The directory selected in the tree
|
||||
QStringList selectedTags;
|
||||
QStringList selectedBranches;
|
||||
QStringList versionList;
|
||||
|
||||
Workspace workspace;
|
||||
Workspace & getWorkspace() { return workspace; }
|
||||
const Workspace & getWorkspace() const { return workspace; }
|
||||
Workspace workspace;
|
||||
Workspace &getWorkspace() { return workspace; }
|
||||
const Workspace &getWorkspace() const { return workspace; }
|
||||
|
||||
Settings &settings;
|
||||
QStringList workspaceHistory;
|
||||
Settings &settings;
|
||||
QStringList workspaceHistory;
|
||||
|
||||
MainWinUICallback uiCallback;
|
||||
MainWinUICallback uiCallback;
|
||||
|
||||
ViewMode viewMode;
|
||||
ViewMode viewMode;
|
||||
};
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
||||
#endif // MAINWINDOW_H
|
||||
|
@ -1,107 +1,98 @@
|
||||
#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);
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
RemoteDialog::~RemoteDialog()
|
||||
{
|
||||
delete ui;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool RemoteDialog::run(QWidget *parent, QUrl &url, QString &name)
|
||||
{
|
||||
RemoteDialog dlg(parent);
|
||||
RemoteDialog dlg(parent);
|
||||
|
||||
// Set URL components
|
||||
if(!url.isEmpty())
|
||||
{
|
||||
dlg.ui->lineName->setText(name);
|
||||
// Set URL components
|
||||
if (!url.isEmpty())
|
||||
{
|
||||
dlg.ui->lineName->setText(name);
|
||||
|
||||
if(url.isLocalFile())
|
||||
dlg.ui->lineURL->setText(QDir::toNativeSeparators(url.toLocalFile()));
|
||||
else
|
||||
{
|
||||
QString url_no_credentials = UrlToStringNoCredentials(url);
|
||||
dlg.ui->lineURL->setText(url_no_credentials);
|
||||
dlg.ui->lineUserName->setText(url.userName());
|
||||
dlg.ui->linePassword->setText(url.password());
|
||||
}
|
||||
}
|
||||
if (url.isLocalFile())
|
||||
dlg.ui->lineURL->setText(QDir::toNativeSeparators(url.toLocalFile()));
|
||||
else
|
||||
{
|
||||
QString url_no_credentials = UrlToStringNoCredentials(url);
|
||||
dlg.ui->lineURL->setText(url_no_credentials);
|
||||
dlg.ui->lineUserName->setText(url.userName());
|
||||
dlg.ui->linePassword->setText(url.password());
|
||||
}
|
||||
}
|
||||
|
||||
if(dlg.exec() != QDialog::Accepted)
|
||||
return false;
|
||||
if (dlg.exec() != QDialog::Accepted)
|
||||
return false;
|
||||
|
||||
QString urltext = dlg.ui->lineURL->text();
|
||||
QString urltext = dlg.ui->lineURL->text();
|
||||
|
||||
// Check if the url is a local file
|
||||
if(QFileInfo(urltext).exists())
|
||||
url = QUrl::fromLocalFile(urltext);
|
||||
else
|
||||
{
|
||||
url = QUrl::fromUserInput(urltext);
|
||||
if(url.isEmpty() || !url.isValid())
|
||||
{
|
||||
QMessageBox::critical(parent, tr("Error"), tr("Invalid URL."), QMessageBox::Ok );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Check if the url is a local file
|
||||
if (QFileInfo(urltext).exists())
|
||||
url = QUrl::fromLocalFile(urltext);
|
||||
else
|
||||
{
|
||||
url = QUrl::fromUserInput(urltext);
|
||||
if (url.isEmpty() || !url.isValid())
|
||||
{
|
||||
QMessageBox::critical(parent, tr("Error"), tr("Invalid URL."), QMessageBox::Ok);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!dlg.ui->lineUserName->text().trimmed().isEmpty())
|
||||
url.setUserName(dlg.ui->lineUserName->text());
|
||||
if (!dlg.ui->lineUserName->text().trimmed().isEmpty())
|
||||
url.setUserName(dlg.ui->lineUserName->text());
|
||||
|
||||
if(!dlg.ui->linePassword->text().trimmed().isEmpty())
|
||||
url.setPassword(dlg.ui->linePassword->text());
|
||||
if (!dlg.ui->linePassword->text().trimmed().isEmpty())
|
||||
url.setPassword(dlg.ui->linePassword->text());
|
||||
|
||||
name = dlg.ui->lineName->text().trimmed();
|
||||
if(name.isEmpty())
|
||||
name = UrlToStringNoCredentials(url);
|
||||
name = dlg.ui->lineName->text().trimmed();
|
||||
if (name.isEmpty())
|
||||
name = UrlToStringNoCredentials(url);
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void RemoteDialog::GetRepositoryPath(QString &pathResult)
|
||||
{
|
||||
QString filter(tr("Fossil Repository") + QString(" (*." FOSSIL_EXT ")"));
|
||||
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);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void RemoteDialog::on_btnSelectSourceRepo_clicked()
|
||||
{
|
||||
QString path = ui->lineURL->text();
|
||||
GetRepositoryPath(path);
|
||||
QString path = ui->lineURL->text();
|
||||
GetRepositoryPath(path);
|
||||
|
||||
if(path.trimmed().isEmpty())
|
||||
return;
|
||||
if (path.trimmed().isEmpty())
|
||||
return;
|
||||
|
||||
if(!QFile::exists(path))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error"), tr("Invalid Repository File."), QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
if (!QFile::exists(path))
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error"), tr("Invalid Repository File."), QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
|
||||
ui->lineURL->setText(QDir::toNativeSeparators(path));
|
||||
ui->lineURL->setText(QDir::toNativeSeparators(path));
|
||||
}
|
||||
|
||||
|
@ -3,27 +3,28 @@
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
namespace Ui
|
||||
{
|
||||
class RemoteDialog;
|
||||
}
|
||||
|
||||
class RemoteDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RemoteDialog(QWidget *parent = 0);
|
||||
~RemoteDialog();
|
||||
explicit RemoteDialog(QWidget *parent = 0);
|
||||
~RemoteDialog();
|
||||
|
||||
static bool run(QWidget *parent, class QUrl &url, QString &name);
|
||||
static bool run(QWidget *parent, class QUrl &url, QString &name);
|
||||
|
||||
private slots:
|
||||
void on_btnSelectSourceRepo_clicked();
|
||||
void on_btnSelectSourceRepo_clicked();
|
||||
|
||||
private:
|
||||
void GetRepositoryPath(QString &pathResult);
|
||||
void GetRepositoryPath(QString &pathResult);
|
||||
|
||||
Ui::RemoteDialog *ui;
|
||||
Ui::RemoteDialog *ui;
|
||||
};
|
||||
|
||||
#endif // REMOTEDIALOG_H
|
||||
#endif // REMOTEDIALOG_H
|
||||
|
@ -1,100 +1,96 @@
|
||||
#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);
|
||||
ui->setupUi(this);
|
||||
ui->cmbRevision->setCompleter(&completer);
|
||||
|
||||
ui->cmbRevision->addItems(completions);
|
||||
ui->cmbRevision->addItems(completions);
|
||||
|
||||
if(!defaultValue.isEmpty())
|
||||
{
|
||||
if (!defaultValue.isEmpty())
|
||||
{
|
||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
|
||||
int index = ui->cmbRevision->findText(defaultValue);
|
||||
if(index>=0)
|
||||
ui->cmbRevision->setCurrentIndex(index);
|
||||
int index = ui->cmbRevision->findText(defaultValue);
|
||||
if (index >= 0)
|
||||
ui->cmbRevision->setCurrentIndex(index);
|
||||
#else
|
||||
ui->cmbRevision->setCurrentText(defaultValue);
|
||||
ui->cmbRevision->setCurrentText(defaultValue);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
RevisionDialog::~RevisionDialog()
|
||||
{
|
||||
delete ui;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
QString RevisionDialog::runUpdate(QWidget *parent, const QString &title, const QStringList &completions, const QString &defaultValue)
|
||||
{
|
||||
RevisionDialog dlg(parent, completions, defaultValue);
|
||||
dlg.setWindowTitle(title);
|
||||
dlg.ui->lblName->setVisible(false);
|
||||
dlg.ui->lineName->setVisible(false);
|
||||
dlg.ui->lblIntegrate->setVisible(false);
|
||||
dlg.ui->chkIntegrate->setVisible(false);
|
||||
dlg.ui->lblForce->setVisible(false);
|
||||
dlg.ui->chkForce->setVisible(false);
|
||||
RevisionDialog dlg(parent, completions, defaultValue);
|
||||
dlg.setWindowTitle(title);
|
||||
dlg.ui->lblName->setVisible(false);
|
||||
dlg.ui->lineName->setVisible(false);
|
||||
dlg.ui->lblIntegrate->setVisible(false);
|
||||
dlg.ui->chkIntegrate->setVisible(false);
|
||||
dlg.ui->lblForce->setVisible(false);
|
||||
dlg.ui->chkForce->setVisible(false);
|
||||
|
||||
dlg.adjustSize();
|
||||
dlg.adjustSize();
|
||||
|
||||
if(dlg.exec() != QDialog::Accepted)
|
||||
return QString("");
|
||||
return dlg.ui->cmbRevision->currentText().trimmed();
|
||||
if (dlg.exec() != QDialog::Accepted)
|
||||
return QString("");
|
||||
return dlg.ui->cmbRevision->currentText().trimmed();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
QString RevisionDialog::runMerge(QWidget *parent, const QString &title, const QStringList &completions, const QString &defaultValue, bool &integrate, bool &force)
|
||||
{
|
||||
RevisionDialog dlg(parent, completions, defaultValue);
|
||||
dlg.setWindowTitle(title);
|
||||
dlg.ui->lblName->setVisible(false);
|
||||
dlg.ui->lineName->setVisible(false);
|
||||
dlg.ui->lblIntegrate->setVisible(true);
|
||||
dlg.ui->chkIntegrate->setVisible(true);
|
||||
dlg.ui->chkIntegrate->setChecked(integrate);
|
||||
dlg.ui->lblForce->setVisible(true);
|
||||
dlg.ui->chkForce->setVisible(true);
|
||||
dlg.ui->chkForce->setChecked(force);
|
||||
RevisionDialog dlg(parent, completions, defaultValue);
|
||||
dlg.setWindowTitle(title);
|
||||
dlg.ui->lblName->setVisible(false);
|
||||
dlg.ui->lineName->setVisible(false);
|
||||
dlg.ui->lblIntegrate->setVisible(true);
|
||||
dlg.ui->chkIntegrate->setVisible(true);
|
||||
dlg.ui->chkIntegrate->setChecked(integrate);
|
||||
dlg.ui->lblForce->setVisible(true);
|
||||
dlg.ui->chkForce->setVisible(true);
|
||||
dlg.ui->chkForce->setChecked(force);
|
||||
|
||||
dlg.adjustSize();
|
||||
dlg.adjustSize();
|
||||
|
||||
if(dlg.exec() != QDialog::Accepted)
|
||||
return QString("");
|
||||
if (dlg.exec() != QDialog::Accepted)
|
||||
return QString("");
|
||||
|
||||
integrate = dlg.ui->chkIntegrate->checkState() == Qt::Checked;
|
||||
force = dlg.ui->chkForce->checkState() == Qt::Checked;
|
||||
integrate = dlg.ui->chkIntegrate->checkState() == Qt::Checked;
|
||||
force = dlg.ui->chkForce->checkState() == Qt::Checked;
|
||||
|
||||
return dlg.ui->cmbRevision->currentText().trimmed();
|
||||
return dlg.ui->cmbRevision->currentText().trimmed();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool RevisionDialog::runNewTag(QWidget *parent, const QString &title, const QStringList &completions, const QString &defaultValue, QString &revision, QString &name)
|
||||
{
|
||||
RevisionDialog dlg(parent, completions, defaultValue);
|
||||
dlg.setWindowTitle(title);
|
||||
RevisionDialog dlg(parent, completions, defaultValue);
|
||||
dlg.setWindowTitle(title);
|
||||
|
||||
dlg.ui->lblName->setVisible(true);
|
||||
dlg.ui->lineName->setVisible(true);
|
||||
dlg.ui->lblIntegrate->setVisible(false);
|
||||
dlg.ui->chkIntegrate->setVisible(false);
|
||||
dlg.ui->lblForce->setVisible(false);
|
||||
dlg.ui->chkForce->setVisible(false);
|
||||
dlg.ui->lblName->setVisible(true);
|
||||
dlg.ui->lineName->setVisible(true);
|
||||
dlg.ui->lblIntegrate->setVisible(false);
|
||||
dlg.ui->chkIntegrate->setVisible(false);
|
||||
dlg.ui->lblForce->setVisible(false);
|
||||
dlg.ui->chkForce->setVisible(false);
|
||||
|
||||
dlg.adjustSize();
|
||||
dlg.adjustSize();
|
||||
|
||||
if(dlg.exec() != QDialog::Accepted)
|
||||
return false;
|
||||
if (dlg.exec() != QDialog::Accepted)
|
||||
return false;
|
||||
|
||||
revision = dlg.ui->cmbRevision->currentText().trimmed();
|
||||
name = dlg.ui->lineName->text().trimmed();
|
||||
return true;
|
||||
revision = dlg.ui->cmbRevision->currentText().trimmed();
|
||||
name = dlg.ui->lineName->text().trimmed();
|
||||
return true;
|
||||
}
|
||||
|
@ -1,28 +1,29 @@
|
||||
#ifndef REVISIONDIALOG_H
|
||||
#define REVISIONDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QCompleter>
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class RevisionDialog;
|
||||
namespace Ui
|
||||
{
|
||||
class RevisionDialog;
|
||||
}
|
||||
|
||||
class RevisionDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit RevisionDialog(QWidget *parent, const QStringList &completions, const QString &defaultValue);
|
||||
~RevisionDialog();
|
||||
explicit RevisionDialog(QWidget *parent, const QStringList &completions, const QString &defaultValue);
|
||||
~RevisionDialog();
|
||||
|
||||
static QString runUpdate(QWidget *parent, const QString &title, const QStringList &completions, const QString &defaultValue);
|
||||
static QString runMerge(QWidget* parent, const QString& title, const QStringList& completions, const QString& defaultValue, bool& integrate, bool& force);
|
||||
static bool runNewTag(QWidget *parent, const QString &title, const QStringList &completions, const QString &defaultValue, QString &revision, QString &name);
|
||||
static QString runUpdate(QWidget *parent, const QString &title, const QStringList &completions, const QString &defaultValue);
|
||||
static QString runMerge(QWidget *parent, const QString &title, const QStringList &completions, const QString &defaultValue, bool &integrate, bool &force);
|
||||
static bool runNewTag(QWidget *parent, const QString &title, const QStringList &completions, const QString &defaultValue, QString &revision, QString &name);
|
||||
|
||||
private:
|
||||
Ui::RevisionDialog *ui;
|
||||
QCompleter completer;
|
||||
Ui::RevisionDialog *ui;
|
||||
QCompleter completer;
|
||||
};
|
||||
|
||||
#endif // REVISIONDIALOG_H
|
||||
#endif // REVISIONDIALOG_H
|
||||
|
@ -1,24 +1,18 @@
|
||||
#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)
|
||||
{
|
||||
// Clear text on escape
|
||||
if(event->key() == Qt::Key_Escape)
|
||||
{
|
||||
setText("");
|
||||
clearFocus();
|
||||
}
|
||||
else
|
||||
QLineEdit::keyPressEvent(event);
|
||||
// Clear text on escape
|
||||
if (event->key() == Qt::Key_Escape)
|
||||
{
|
||||
setText("");
|
||||
clearFocus();
|
||||
}
|
||||
else
|
||||
QLineEdit::keyPressEvent(event);
|
||||
}
|
||||
|
||||
|
@ -5,19 +5,17 @@
|
||||
|
||||
class SearchBox : public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SearchBox(QWidget* parent=0);
|
||||
~SearchBox();
|
||||
explicit SearchBox(QWidget *parent = 0);
|
||||
~SearchBox();
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
protected:
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
|
||||
void keyPressEvent(QKeyEvent *event);
|
||||
};
|
||||
|
||||
|
||||
#endif // SEARCHBOX_H
|
||||
#endif // SEARCHBOX_H
|
||||
|
@ -1,210 +1,204 @@
|
||||
#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);
|
||||
ui->setupUi(this);
|
||||
|
||||
CreateLangMap();
|
||||
CreateLangMap();
|
||||
|
||||
ui->cmbDoubleClickAction->addItem(tr("Diff File"));
|
||||
ui->cmbDoubleClickAction->addItem(tr("Open File"));
|
||||
ui->cmbDoubleClickAction->addItem(tr("Open Containing Folder"));
|
||||
ui->cmbDoubleClickAction->addItem(tr("Custom Action %0").arg(1));
|
||||
ui->cmbDoubleClickAction->addItem(tr("Diff File"));
|
||||
ui->cmbDoubleClickAction->addItem(tr("Open File"));
|
||||
ui->cmbDoubleClickAction->addItem(tr("Open Containing Folder"));
|
||||
ui->cmbDoubleClickAction->addItem(tr("Custom Action %0").arg(1));
|
||||
|
||||
ui->cmbFossilBrowser->addItem(tr("System"));
|
||||
ui->cmbFossilBrowser->addItem(tr("Internal"));
|
||||
ui->cmbFossilBrowser->addItem(tr("System"));
|
||||
ui->cmbFossilBrowser->addItem(tr("Internal"));
|
||||
|
||||
// App Settings
|
||||
ui->lineFossilPath->setText(QDir::toNativeSeparators(settings->GetValue(FUEL_SETTING_FOSSIL_PATH).toString()));
|
||||
ui->cmbDoubleClickAction->setCurrentIndex(settings->GetValue(FUEL_SETTING_FILE_DBLCLICK).toInt());
|
||||
ui->cmbFossilBrowser->setCurrentIndex(settings->GetValue(FUEL_SETTING_WEB_BROWSER).toInt());
|
||||
// App Settings
|
||||
ui->lineFossilPath->setText(QDir::toNativeSeparators(settings->GetValue(FUEL_SETTING_FOSSIL_PATH).toString()));
|
||||
ui->cmbDoubleClickAction->setCurrentIndex(settings->GetValue(FUEL_SETTING_FILE_DBLCLICK).toInt());
|
||||
ui->cmbFossilBrowser->setCurrentIndex(settings->GetValue(FUEL_SETTING_WEB_BROWSER).toInt());
|
||||
|
||||
// Initialize language combo
|
||||
foreach(const LangMap &m, langMap)
|
||||
ui->cmbActiveLanguage->addItem(m.name);
|
||||
// Initialize language combo
|
||||
foreach (const LangMap &m, langMap)
|
||||
ui->cmbActiveLanguage->addItem(m.name);
|
||||
|
||||
QString lang = settings->GetValue(FUEL_SETTING_LANGUAGE).toString();
|
||||
// Select current language
|
||||
ui->cmbActiveLanguage->setCurrentIndex(
|
||||
ui->cmbActiveLanguage->findText(
|
||||
LangIdToName(lang)));
|
||||
QString lang = settings->GetValue(FUEL_SETTING_LANGUAGE).toString();
|
||||
// Select current language
|
||||
ui->cmbActiveLanguage->setCurrentIndex(ui->cmbActiveLanguage->findText(LangIdToName(lang)));
|
||||
|
||||
lastActionIndex = 0;
|
||||
currentCustomActions = settings->GetCustomActions();
|
||||
|
||||
lastActionIndex = 0;
|
||||
currentCustomActions = settings->GetCustomActions();
|
||||
ui->cmbCustomActionContext->addItem(tr("Files"));
|
||||
ui->cmbCustomActionContext->addItem(tr("Folders"));
|
||||
ui->cmbCustomActionContext->setCurrentIndex(0);
|
||||
|
||||
ui->cmbCustomActionContext->addItem(tr("Files"));
|
||||
ui->cmbCustomActionContext->addItem(tr("Folders"));
|
||||
ui->cmbCustomActionContext->setCurrentIndex(0);
|
||||
GetCustomAction(0);
|
||||
|
||||
GetCustomAction(0);
|
||||
|
||||
for(int i=0; i<currentCustomActions.size(); ++i)
|
||||
{
|
||||
CustomAction &a = currentCustomActions[i];
|
||||
ui->cmbCustomAction->addItem(a.Id);
|
||||
}
|
||||
ui->cmbCustomAction->setCurrentIndex(0);
|
||||
for (int i = 0; i < currentCustomActions.size(); ++i)
|
||||
{
|
||||
CustomAction &a = currentCustomActions[i];
|
||||
ui->cmbCustomAction->addItem(a.Id);
|
||||
}
|
||||
ui->cmbCustomAction->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
SettingsDialog::~SettingsDialog()
|
||||
{
|
||||
delete ui;
|
||||
delete ui;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool SettingsDialog::run(QWidget *parent, Settings &settings)
|
||||
{
|
||||
SettingsDialog dlg(parent, settings);
|
||||
return dlg.exec() == QDialog::Accepted;
|
||||
SettingsDialog dlg(parent, settings);
|
||||
return dlg.exec() == QDialog::Accepted;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void SettingsDialog::on_buttonBox_accepted()
|
||||
{
|
||||
settings->SetValue(FUEL_SETTING_FOSSIL_PATH, QDir::fromNativeSeparators(ui->lineFossilPath->text()));
|
||||
Q_ASSERT(ui->cmbDoubleClickAction->currentIndex()>=FILE_DLBCLICK_ACTION_DIFF && ui->cmbDoubleClickAction->currentIndex()<FILE_DLBCLICK_ACTION_MAX);
|
||||
settings->SetValue(FUEL_SETTING_FILE_DBLCLICK, ui->cmbDoubleClickAction->currentIndex());
|
||||
settings->SetValue(FUEL_SETTING_WEB_BROWSER, ui->cmbFossilBrowser->currentIndex());
|
||||
settings->SetValue(FUEL_SETTING_FOSSIL_PATH, QDir::fromNativeSeparators(ui->lineFossilPath->text()));
|
||||
Q_ASSERT(ui->cmbDoubleClickAction->currentIndex() >= FILE_DLBCLICK_ACTION_DIFF && ui->cmbDoubleClickAction->currentIndex() < FILE_DLBCLICK_ACTION_MAX);
|
||||
settings->SetValue(FUEL_SETTING_FILE_DBLCLICK, ui->cmbDoubleClickAction->currentIndex());
|
||||
settings->SetValue(FUEL_SETTING_WEB_BROWSER, ui->cmbFossilBrowser->currentIndex());
|
||||
|
||||
Q_ASSERT(settings->HasValue(FUEL_SETTING_LANGUAGE));
|
||||
QString curr_langid = settings->GetValue(FUEL_SETTING_LANGUAGE).toString();
|
||||
QString new_langid = LangNameToId(ui->cmbActiveLanguage->currentText());
|
||||
Q_ASSERT(!new_langid.isEmpty());
|
||||
settings->SetValue(FUEL_SETTING_LANGUAGE, new_langid);
|
||||
Q_ASSERT(settings->HasValue(FUEL_SETTING_LANGUAGE));
|
||||
QString curr_langid = settings->GetValue(FUEL_SETTING_LANGUAGE).toString();
|
||||
QString new_langid = LangNameToId(ui->cmbActiveLanguage->currentText());
|
||||
Q_ASSERT(!new_langid.isEmpty());
|
||||
settings->SetValue(FUEL_SETTING_LANGUAGE, new_langid);
|
||||
|
||||
if(curr_langid != new_langid)
|
||||
QMessageBox::information(this, tr("Restart required"), tr("The language change will take effect after restarting the application"), QMessageBox::Ok);
|
||||
if (curr_langid != new_langid)
|
||||
QMessageBox::information(this, tr("Restart required"), tr("The language change will take effect after restarting the application"), QMessageBox::Ok);
|
||||
|
||||
for(int i=0; i<currentCustomActions.size(); ++i)
|
||||
{
|
||||
CustomAction &a = currentCustomActions[i];
|
||||
a.Description = a.Description.trimmed();
|
||||
a.Command = a.Command.trimmed();
|
||||
}
|
||||
for (int i = 0; i < currentCustomActions.size(); ++i)
|
||||
{
|
||||
CustomAction &a = currentCustomActions[i];
|
||||
a.Description = a.Description.trimmed();
|
||||
a.Command = a.Command.trimmed();
|
||||
}
|
||||
|
||||
PutCustomAction(ui->cmbCustomAction->currentIndex());
|
||||
PutCustomAction(ui->cmbCustomAction->currentIndex());
|
||||
|
||||
settings->GetCustomActions() = currentCustomActions;
|
||||
settings->GetCustomActions() = currentCustomActions;
|
||||
|
||||
settings->ApplyEnvironment();
|
||||
settings->ApplyEnvironment();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void SettingsDialog::on_btnSelectFossil_clicked()
|
||||
{
|
||||
QString path = SelectExe(this, tr("Select Fossil executable"));
|
||||
if(!path.isEmpty())
|
||||
ui->lineFossilPath->setText(QDir::toNativeSeparators(path));
|
||||
QString path = SelectExe(this, tr("Select Fossil executable"));
|
||||
if (!path.isEmpty())
|
||||
ui->lineFossilPath->setText(QDir::toNativeSeparators(path));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void SettingsDialog::on_btnClearMessageHistory_clicked()
|
||||
{
|
||||
if(DialogQuery(this, tr("Clear Commit Message History"), tr("Are you sure you want to clear the commit message history?"))==QMessageBox::Yes)
|
||||
settings->SetValue(FUEL_SETTING_COMMIT_MSG, QStringList());
|
||||
if (DialogQuery(this, tr("Clear Commit Message History"), tr("Are you sure you want to clear the commit message history?")) == QMessageBox::Yes)
|
||||
settings->SetValue(FUEL_SETTING_COMMIT_MSG, QStringList());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void SettingsDialog::CreateLangMap()
|
||||
{
|
||||
langMap.append(LangMap("nl_NL", "Dutch (NL)"));
|
||||
langMap.append(LangMap("en_US", "English (US)"));
|
||||
langMap.append(LangMap("fr_FR", "French (FR)"));
|
||||
langMap.append(LangMap("de_DE", "German (DE)"));
|
||||
langMap.append(LangMap("el_GR", "Greek (GR)"));
|
||||
langMap.append(LangMap("it_IT", "Italian (IT)"));
|
||||
langMap.append(LangMap("ko_KR", "Korean (KO)"));
|
||||
langMap.append(LangMap("pt_PT", "Portuguese (PT)"));
|
||||
langMap.append(LangMap("ru_RU", "Russian (RU)"));
|
||||
langMap.append(LangMap("es_ES", "Spanish (ES)"));
|
||||
langMap.append(LangMap("nl_NL", "Dutch (NL)"));
|
||||
langMap.append(LangMap("en_US", "English (US)"));
|
||||
langMap.append(LangMap("fr_FR", "French (FR)"));
|
||||
langMap.append(LangMap("de_DE", "German (DE)"));
|
||||
langMap.append(LangMap("el_GR", "Greek (GR)"));
|
||||
langMap.append(LangMap("it_IT", "Italian (IT)"));
|
||||
langMap.append(LangMap("ko_KR", "Korean (KO)"));
|
||||
langMap.append(LangMap("pt_PT", "Portuguese (PT)"));
|
||||
langMap.append(LangMap("ru_RU", "Russian (RU)"));
|
||||
langMap.append(LangMap("es_ES", "Spanish (ES)"));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
QString SettingsDialog::LangIdToName(const QString &id)
|
||||
{
|
||||
foreach(const LangMap &m, langMap)
|
||||
{
|
||||
if(m.id == id)
|
||||
return m.name;
|
||||
}
|
||||
foreach (const LangMap &m, langMap)
|
||||
{
|
||||
if (m.id == id)
|
||||
return m.name;
|
||||
}
|
||||
|
||||
return "";
|
||||
return "";
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
QString SettingsDialog::LangNameToId(const QString &name)
|
||||
{
|
||||
foreach(const LangMap &m, langMap)
|
||||
{
|
||||
if(m.name == name)
|
||||
return m.id;
|
||||
}
|
||||
foreach (const LangMap &m, langMap)
|
||||
{
|
||||
if (m.name == name)
|
||||
return m.id;
|
||||
}
|
||||
|
||||
return "";
|
||||
return "";
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void SettingsDialog::on_btnSelectCustomFileActionCommand_clicked()
|
||||
{
|
||||
QString path = SelectExe(this, tr("Select command"));
|
||||
if(path.isEmpty())
|
||||
return;
|
||||
QString path = SelectExe(this, tr("Select command"));
|
||||
if (path.isEmpty())
|
||||
return;
|
||||
|
||||
// Quote path if it contains spaces
|
||||
if(path.indexOf(' ')!=-1)
|
||||
path = '"' + path + '"';
|
||||
// Quote path if it contains spaces
|
||||
if (path.indexOf(' ') != -1)
|
||||
path = '"' + path + '"';
|
||||
|
||||
ui->lineCustomActionCommand->setText(QDir::toNativeSeparators(path));
|
||||
ui->lineCustomActionCommand->setText(QDir::toNativeSeparators(path));
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void SettingsDialog::GetCustomAction(int index)
|
||||
{
|
||||
Q_ASSERT(index>=0 && index < currentCustomActions.size());
|
||||
CustomAction &action = currentCustomActions[index];
|
||||
ui->lineCustomActionDescription->setText(action.Description);
|
||||
ui->lineCustomActionCommand->setText(action.Command);
|
||||
ui->cmbCustomActionContext->setCurrentIndex(action.Context-1);
|
||||
ui->chkCustomActionMultipleSelection->setChecked(action.MultipleSelection);
|
||||
Q_ASSERT(index >= 0 && index < currentCustomActions.size());
|
||||
CustomAction &action = currentCustomActions[index];
|
||||
ui->lineCustomActionDescription->setText(action.Description);
|
||||
ui->lineCustomActionCommand->setText(action.Command);
|
||||
ui->cmbCustomActionContext->setCurrentIndex(action.Context - 1);
|
||||
ui->chkCustomActionMultipleSelection->setChecked(action.MultipleSelection);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void SettingsDialog::PutCustomAction(int index)
|
||||
{
|
||||
Q_ASSERT(index>=0 && index < currentCustomActions.size());
|
||||
CustomAction &action = currentCustomActions[index];
|
||||
action.Description = ui->lineCustomActionDescription->text().trimmed();
|
||||
action.Command = ui->lineCustomActionCommand->text().trimmed();
|
||||
action.Context = static_cast<CustomActionContext>(ui->cmbCustomActionContext->currentIndex()+1);
|
||||
action.MultipleSelection = ui->chkCustomActionMultipleSelection->isChecked();
|
||||
Q_ASSERT(index >= 0 && index < currentCustomActions.size());
|
||||
CustomAction &action = currentCustomActions[index];
|
||||
action.Description = ui->lineCustomActionDescription->text().trimmed();
|
||||
action.Command = ui->lineCustomActionCommand->text().trimmed();
|
||||
action.Context = static_cast<CustomActionContext>(ui->cmbCustomActionContext->currentIndex() + 1);
|
||||
action.MultipleSelection = ui->chkCustomActionMultipleSelection->isChecked();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void SettingsDialog::on_cmbCustomAction_currentIndexChanged(int index)
|
||||
{
|
||||
if(index != lastActionIndex)
|
||||
PutCustomAction(lastActionIndex);
|
||||
if (index != lastActionIndex)
|
||||
PutCustomAction(lastActionIndex);
|
||||
|
||||
GetCustomAction(index);
|
||||
lastActionIndex = index;
|
||||
GetCustomAction(index);
|
||||
lastActionIndex = index;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void SettingsDialog::on_cmbCustomActionContext_currentIndexChanged(int index)
|
||||
{
|
||||
int action_index = ui->cmbCustomAction->currentIndex();
|
||||
if(action_index<0)
|
||||
return;
|
||||
Q_ASSERT(action_index>=0 && action_index < currentCustomActions.size());
|
||||
currentCustomActions[action_index].Context = static_cast<CustomActionContext>(index+1);
|
||||
int action_index = ui->cmbCustomAction->currentIndex();
|
||||
if (action_index < 0)
|
||||
return;
|
||||
Q_ASSERT(action_index >= 0 && action_index < currentCustomActions.size());
|
||||
currentCustomActions[action_index].Context = static_cast<CustomActionContext>(index + 1);
|
||||
}
|
||||
|
@ -1,55 +1,52 @@
|
||||
#ifndef SETTINGSDIALOG_H
|
||||
#define SETTINGSDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include "AppSettings.h"
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class SettingsDialog;
|
||||
namespace Ui
|
||||
{
|
||||
class SettingsDialog;
|
||||
}
|
||||
|
||||
class SettingsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SettingsDialog(QWidget *parent, Settings &_settings);
|
||||
~SettingsDialog();
|
||||
|
||||
static bool run(QWidget *parent, Settings &_settings);
|
||||
explicit SettingsDialog(QWidget *parent, Settings &_settings);
|
||||
~SettingsDialog();
|
||||
|
||||
static bool run(QWidget *parent, Settings &_settings);
|
||||
|
||||
private slots:
|
||||
void on_btnSelectFossil_clicked();
|
||||
void on_buttonBox_accepted();
|
||||
void on_btnClearMessageHistory_clicked();
|
||||
void on_btnSelectCustomFileActionCommand_clicked();
|
||||
void on_cmbCustomAction_currentIndexChanged(int index);
|
||||
void on_cmbCustomActionContext_currentIndexChanged(int index);
|
||||
void on_btnSelectFossil_clicked();
|
||||
void on_buttonBox_accepted();
|
||||
void on_btnClearMessageHistory_clicked();
|
||||
void on_btnSelectCustomFileActionCommand_clicked();
|
||||
void on_cmbCustomAction_currentIndexChanged(int index);
|
||||
void on_cmbCustomActionContext_currentIndexChanged(int index);
|
||||
|
||||
private:
|
||||
QString LangIdToName(const QString &id);
|
||||
QString LangNameToId(const QString &name);
|
||||
void CreateLangMap();
|
||||
void GetCustomAction(int index);
|
||||
void PutCustomAction(int index);
|
||||
QString LangIdToName(const QString &id);
|
||||
QString LangNameToId(const QString &name);
|
||||
void CreateLangMap();
|
||||
void GetCustomAction(int index);
|
||||
void PutCustomAction(int index);
|
||||
|
||||
struct LangMap
|
||||
{
|
||||
LangMap(const QString &_id, const QString &_name)
|
||||
: id(_id), name(_name)
|
||||
{
|
||||
}
|
||||
struct LangMap
|
||||
{
|
||||
LangMap(const QString &_id, const QString &_name) : id(_id), name(_name) {}
|
||||
|
||||
QString id;
|
||||
QString name;
|
||||
};
|
||||
QString id;
|
||||
QString name;
|
||||
};
|
||||
|
||||
QList<LangMap> langMap;
|
||||
Ui::SettingsDialog *ui;
|
||||
Settings *settings;
|
||||
Settings::custom_actions_t currentCustomActions;
|
||||
int lastActionIndex;
|
||||
QList<LangMap> langMap;
|
||||
Ui::SettingsDialog *ui;
|
||||
Settings *settings;
|
||||
Settings::custom_actions_t currentCustomActions;
|
||||
int lastActionIndex;
|
||||
};
|
||||
|
||||
#endif // SETTINGSDIALOG_H
|
||||
#endif // SETTINGSDIALOG_H
|
||||
|
849
src/Utils.cpp
849
src/Utils.cpp
File diff suppressed because it is too large
Load Diff
84
src/Utils.h
84
src/Utils.h
@ -1,78 +1,68 @@
|
||||
#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_"
|
||||
#define FOSSIL_CHECKOUT2 ".fslckout"
|
||||
#define FOSSIL_EXT "fossil"
|
||||
#define PATH_SEPARATOR "/"
|
||||
#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
|
||||
#define FOSSIL_CHECKOUT1 "_FOSSIL_"
|
||||
#define FOSSIL_CHECKOUT2 ".fslckout"
|
||||
#define FOSSIL_EXT "fossil"
|
||||
#define PATH_SEPARATOR "/"
|
||||
|
||||
typedef QSet<QString> stringset_t;
|
||||
|
||||
|
||||
class UICallback
|
||||
{
|
||||
public:
|
||||
virtual void logText(const QString &text, bool isHTML)=0;
|
||||
virtual void beginProcess(const QString &text)=0;
|
||||
virtual void updateProcess(const QString &text)=0;
|
||||
virtual bool processAborted() const=0;
|
||||
virtual void endProcess()=0;
|
||||
virtual QMessageBox::StandardButton Query(const QString &title, const QString &query, QMessageBox::StandardButtons buttons)=0;
|
||||
virtual void logText(const QString &text, bool isHTML) = 0;
|
||||
virtual void beginProcess(const QString &text) = 0;
|
||||
virtual void updateProcess(const QString &text) = 0;
|
||||
virtual bool processAborted() const = 0;
|
||||
virtual void endProcess() = 0;
|
||||
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;
|
||||
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);
|
||||
|
||||
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);
|
||||
void BuildNameToModelIndex(name_modelindex_map_t &map, const QStandardItemModel &model);
|
||||
bool KeychainSet(QObject* parent, const QUrl& url, QSettings &settings);
|
||||
bool KeychainGet(QObject* parent, QUrl& url, QSettings &settings);
|
||||
bool KeychainDelete(QObject* parent, const QUrl& url, QSettings &settings);
|
||||
QString HashString(const QString &str);
|
||||
QString UrlToStringDisplay(const QUrl &url);
|
||||
QString UrlToStringNoCredentials(const QUrl& url);
|
||||
QString UrlToString(const QUrl &url);
|
||||
void SplitCommandLine(const QString &commandLine, QString &command, QString &extraParams);
|
||||
bool SpawnExternalProcess(QObject *processParent, const QString& command, const QStringList& fileList, const stringset_t& pathSet, const QString &workspaceDir, UICallback &uiCallback);
|
||||
void TrimStringList(QStringList &list);
|
||||
void GetStandardItemTextRecursive(QString &name, const QStandardItem &item, const QChar &separator = '/');
|
||||
void BuildNameToModelIndex(name_modelindex_map_t &map, const QStandardItem &item);
|
||||
void BuildNameToModelIndex(name_modelindex_map_t &map, const QStandardItemModel &model);
|
||||
bool KeychainSet(QObject *parent, const QUrl &url, QSettings &settings);
|
||||
bool KeychainGet(QObject *parent, QUrl &url, QSettings &settings);
|
||||
bool KeychainDelete(QObject *parent, const QUrl &url, QSettings &settings);
|
||||
QString HashString(const QString &str);
|
||||
QString UrlToStringDisplay(const QUrl &url);
|
||||
QString UrlToStringNoCredentials(const QUrl &url);
|
||||
QString UrlToString(const QUrl &url);
|
||||
void SplitCommandLine(const QString &commandLine, QString &command, QString &extraParams);
|
||||
bool SpawnExternalProcess(QObject *processParent, const QString &command, const QStringList &fileList, const stringset_t &pathSet, const QString &workspaceDir, UICallback &uiCallback);
|
||||
void TrimStringList(QStringList &list);
|
||||
|
||||
typedef QMap<QString, QString> QStringMap;
|
||||
void ParseProperties(QStringMap &properties, const QStringList &lines, QChar separator=' ');
|
||||
void ParseProperties(QStringMap &properties, const QStringList &lines, QChar separator = ' ');
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
bool ShowExplorerMenu(HWND hwnd, const QString &path, const QPoint &qpoint);
|
||||
bool ShowExplorerMenu(HWND hwnd, const QString &path, const QPoint &qpoint);
|
||||
#endif
|
||||
|
||||
#endif // UTILS_H
|
||||
#endif // UTILS_H
|
||||
|
@ -1,105 +1,102 @@
|
||||
#include "Workspace.h"
|
||||
#include <QCoreApplication>
|
||||
#include "Utils.h"
|
||||
#include <QCoreApplication>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
Workspace::Workspace()
|
||||
{
|
||||
}
|
||||
Workspace::Workspace() {}
|
||||
//-----------------------------------------------------------------------------
|
||||
Workspace::~Workspace()
|
||||
{
|
||||
clearState();
|
||||
remotes.clear();
|
||||
clearState();
|
||||
remotes.clear();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void Workspace::clearState()
|
||||
{
|
||||
// Dispose RepoFiles
|
||||
foreach(WorkspaceFile *r, getFiles())
|
||||
delete r;
|
||||
// Dispose RepoFiles
|
||||
foreach (WorkspaceFile *r, getFiles())
|
||||
delete r;
|
||||
|
||||
getFiles().clear();
|
||||
getPaths().clear();
|
||||
pathState.clear();
|
||||
stashMap.clear();
|
||||
branchNames.clear();
|
||||
tags.clear();
|
||||
isIntegrated = false;
|
||||
getFiles().clear();
|
||||
getPaths().clear();
|
||||
pathState.clear();
|
||||
stashMap.clear();
|
||||
branchNames.clear();
|
||||
tags.clear();
|
||||
isIntegrated = false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void Workspace::storeWorkspace(QSettings &store)
|
||||
{
|
||||
QString workspace = fossil().getWorkspacePath();
|
||||
if(workspace.isEmpty())
|
||||
return;
|
||||
QString workspace = fossil().getWorkspacePath();
|
||||
if (workspace.isEmpty())
|
||||
return;
|
||||
|
||||
store.beginGroup("Remotes");
|
||||
QString workspace_hash = HashString(QDir::toNativeSeparators(workspace));
|
||||
|
||||
store.beginWriteArray(workspace_hash);
|
||||
int index = 0;
|
||||
for(remote_map_t::iterator it=remotes.begin(); it!=remotes.end(); ++it, ++index)
|
||||
{
|
||||
store.setArrayIndex(index);
|
||||
store.setValue("Name", it->name);
|
||||
QUrl url = it->url;
|
||||
url.setPassword("");
|
||||
store.setValue("Url", url);
|
||||
if(it->isDefault)
|
||||
store.setValue("Default", it->isDefault);
|
||||
else
|
||||
store.remove("Default");
|
||||
}
|
||||
store.endArray();
|
||||
store.endGroup();
|
||||
store.beginGroup("Remotes");
|
||||
QString workspace_hash = HashString(QDir::toNativeSeparators(workspace));
|
||||
|
||||
store.beginWriteArray(workspace_hash);
|
||||
int index = 0;
|
||||
for (remote_map_t::iterator it = remotes.begin(); it != remotes.end(); ++it, ++index)
|
||||
{
|
||||
store.setArrayIndex(index);
|
||||
store.setValue("Name", it->name);
|
||||
QUrl url = it->url;
|
||||
url.setPassword("");
|
||||
store.setValue("Url", url);
|
||||
if (it->isDefault)
|
||||
store.setValue("Default", it->isDefault);
|
||||
else
|
||||
store.remove("Default");
|
||||
}
|
||||
store.endArray();
|
||||
store.endGroup();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool Workspace::switchWorkspace(const QString& workspace, QSettings &store)
|
||||
bool Workspace::switchWorkspace(const QString &workspace, QSettings &store)
|
||||
{
|
||||
// Save Remotes
|
||||
storeWorkspace(store);
|
||||
clearState();
|
||||
remotes.clear();
|
||||
// Save Remotes
|
||||
storeWorkspace(store);
|
||||
clearState();
|
||||
remotes.clear();
|
||||
|
||||
fossil().setWorkspace("");
|
||||
if(workspace.isEmpty())
|
||||
return true;
|
||||
fossil().setWorkspace("");
|
||||
if (workspace.isEmpty())
|
||||
return true;
|
||||
|
||||
QString new_workspace = QFileInfo(workspace).absoluteFilePath();
|
||||
QString new_workspace = QFileInfo(workspace).absoluteFilePath();
|
||||
|
||||
if(!QDir::setCurrent(new_workspace))
|
||||
return false;
|
||||
if (!QDir::setCurrent(new_workspace))
|
||||
return false;
|
||||
|
||||
fossil().setWorkspace(new_workspace);
|
||||
fossil().setWorkspace(new_workspace);
|
||||
|
||||
// Load Remotes
|
||||
QString workspace_hash = HashString(QDir::toNativeSeparators(new_workspace));
|
||||
// Load Remotes
|
||||
QString workspace_hash = HashString(QDir::toNativeSeparators(new_workspace));
|
||||
|
||||
QString gr = store.group();
|
||||
QString gr = store.group();
|
||||
|
||||
store.beginGroup("Remotes");
|
||||
gr = store.group();
|
||||
int num_remotes = store.beginReadArray(workspace_hash);
|
||||
for(int i=0; i<num_remotes; ++i)
|
||||
{
|
||||
store.setArrayIndex(i);
|
||||
store.beginGroup("Remotes");
|
||||
gr = store.group();
|
||||
int num_remotes = store.beginReadArray(workspace_hash);
|
||||
for (int i = 0; i < num_remotes; ++i)
|
||||
{
|
||||
store.setArrayIndex(i);
|
||||
|
||||
QString name = store.value("Name").toString();
|
||||
QUrl url = store.value("Url").toUrl();
|
||||
bool def = store.value("Default", false).toBool();
|
||||
addRemote(url, name);
|
||||
if(def)
|
||||
setRemoteDefault(url);
|
||||
}
|
||||
store.endArray();
|
||||
store.endGroup();
|
||||
QString name = store.value("Name").toString();
|
||||
QUrl url = store.value("Url").toUrl();
|
||||
bool def = store.value("Default", false).toBool();
|
||||
addRemote(url, name);
|
||||
if (def)
|
||||
setRemoteDefault(url);
|
||||
}
|
||||
store.endArray();
|
||||
store.endGroup();
|
||||
|
||||
#if 0 // FIXME: Disabled this because if fossil's remote does not match exactly what we have stored (url and username), it will be automatically added every-time
|
||||
#if 0 // FIXME: Disabled this because if fossil's remote does not match exactly what we have stored (url and username), it will be automatically added every-time
|
||||
// Add the default url from fossil
|
||||
QUrl default_remote;
|
||||
if(fossil().getRemoteUrl(default_remote) && default_remote.isValid() && !default_remote.isEmpty())
|
||||
@ -116,311 +113,309 @@ bool Workspace::switchWorkspace(const QString& workspace, QSettings &store)
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool Workspace::scanDirectory(QFileInfoList &entries, const QString& dirPath, const QString &baseDir, const QStringList &ignorePatterns, UICallback &uiCallback)
|
||||
bool Workspace::scanDirectory(QFileInfoList &entries, const QString &dirPath, const QString &baseDir, const QStringList &ignorePatterns, UICallback &uiCallback)
|
||||
{
|
||||
QDir dir(dirPath);
|
||||
QDir dir(dirPath);
|
||||
|
||||
uiCallback.updateProcess(dirPath);
|
||||
uiCallback.updateProcess(dirPath);
|
||||
|
||||
QFileInfoList list = dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot);
|
||||
for (int i=0; i<list.count(); ++i)
|
||||
{
|
||||
if(uiCallback.processAborted())
|
||||
return false;
|
||||
QFileInfoList list = dir.entryInfoList(QDir::Dirs | QDir::Files | QDir::Hidden | QDir::NoDotAndDotDot);
|
||||
for (int i = 0; i < list.count(); ++i)
|
||||
{
|
||||
if (uiCallback.processAborted())
|
||||
return false;
|
||||
|
||||
QFileInfo info = list[i];
|
||||
QString filepath = info.filePath();
|
||||
QString rel_path = filepath;
|
||||
rel_path.remove(baseDir+PATH_SEPARATOR);
|
||||
QFileInfo info = list[i];
|
||||
QString filepath = info.filePath();
|
||||
QString rel_path = filepath;
|
||||
rel_path.remove(baseDir + PATH_SEPARATOR);
|
||||
|
||||
// Skip ignored files
|
||||
if(!ignorePatterns.isEmpty() && QDir::match(ignorePatterns, rel_path))
|
||||
continue;
|
||||
// Skip ignored files
|
||||
if (!ignorePatterns.isEmpty() && QDir::match(ignorePatterns, rel_path))
|
||||
continue;
|
||||
|
||||
if (info.isDir())
|
||||
{
|
||||
if(!scanDirectory(entries, filepath, baseDir, ignorePatterns, uiCallback))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
entries.push_back(info);
|
||||
}
|
||||
return true;
|
||||
if (info.isDir())
|
||||
{
|
||||
if (!scanDirectory(entries, filepath, baseDir, ignorePatterns, uiCallback))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
entries.push_back(info);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static bool StringLengthDescending(const QString &l, const QString &r)
|
||||
{
|
||||
return l.length() > r.length();
|
||||
return l.length() > r.length();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void Workspace::scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModified, bool scanUnchanged, const QStringList &ignorePatterns, UICallback &uiCallback)
|
||||
{
|
||||
// Scan all workspace files
|
||||
QFileInfoList all_files;
|
||||
QString wkdir = fossil().getWorkspacePath();
|
||||
// Scan all workspace files
|
||||
QFileInfoList all_files;
|
||||
QString wkdir = fossil().getWorkspacePath();
|
||||
|
||||
if(wkdir.isEmpty())
|
||||
return;
|
||||
if (wkdir.isEmpty())
|
||||
return;
|
||||
|
||||
// Retrieve the status of files tracked by fossil
|
||||
QStringList res;
|
||||
if(!fossil().listFiles(res))
|
||||
return;
|
||||
// Retrieve the status of files tracked by fossil
|
||||
QStringList res;
|
||||
if (!fossil().listFiles(res))
|
||||
return;
|
||||
|
||||
bool scan_files = scanLocal;
|
||||
bool scan_files = scanLocal;
|
||||
|
||||
clearState();
|
||||
clearState();
|
||||
|
||||
QStringList paths;
|
||||
QStringList paths;
|
||||
|
||||
uiCallback.beginProcess("");
|
||||
if(scan_files)
|
||||
{
|
||||
QCoreApplication::processEvents();
|
||||
uiCallback.beginProcess("");
|
||||
if (scan_files)
|
||||
{
|
||||
QCoreApplication::processEvents();
|
||||
|
||||
QStringList ignore;
|
||||
if(!scanIgnored)
|
||||
ignore = ignorePatterns;
|
||||
QStringList ignore;
|
||||
if (!scanIgnored)
|
||||
ignore = ignorePatterns;
|
||||
|
||||
if(!scanDirectory(all_files, wkdir, wkdir, ignore, uiCallback))
|
||||
goto _done;
|
||||
if (!scanDirectory(all_files, wkdir, wkdir, ignore, uiCallback))
|
||||
goto _done;
|
||||
|
||||
for(QFileInfoList::iterator it=all_files.begin(); it!=all_files.end(); ++it)
|
||||
{
|
||||
QString filename = it->fileName();
|
||||
QString fullpath = it->absoluteFilePath();
|
||||
for (QFileInfoList::iterator it = all_files.begin(); it != all_files.end(); ++it)
|
||||
{
|
||||
QString filename = it->fileName();
|
||||
QString fullpath = it->absoluteFilePath();
|
||||
|
||||
// Skip fossil files
|
||||
if(filename == FOSSIL_CHECKOUT1 || filename == FOSSIL_CHECKOUT2 || (!fossil().getRepositoryFile().isEmpty() && QFileInfo(fullpath) == QFileInfo(fossil().getRepositoryFile())))
|
||||
continue;
|
||||
// Skip fossil files
|
||||
if (filename == FOSSIL_CHECKOUT1 || filename == FOSSIL_CHECKOUT2 || (!fossil().getRepositoryFile().isEmpty() && QFileInfo(fullpath) == QFileInfo(fossil().getRepositoryFile())))
|
||||
continue;
|
||||
|
||||
WorkspaceFile::Type type = WorkspaceFile::TYPE_UNKNOWN;
|
||||
WorkspaceFile::Type type = WorkspaceFile::TYPE_UNKNOWN;
|
||||
|
||||
WorkspaceFile *rf = new WorkspaceFile(*it, type, wkdir);
|
||||
const QString &path = rf->getPath();
|
||||
getFiles().insert(rf->getFilePath(), rf);
|
||||
getPaths().insert(path);
|
||||
WorkspaceFile *rf = new WorkspaceFile(*it, type, wkdir);
|
||||
const QString &path = rf->getPath();
|
||||
getFiles().insert(rf->getFilePath(), rf);
|
||||
getPaths().insert(path);
|
||||
|
||||
// Add or merge file state into directory state
|
||||
pathstate_map_t::iterator state_it = pathState.find(path);
|
||||
if(state_it != pathState.end())
|
||||
state_it.value() = static_cast<WorkspaceFile::Type>(state_it.value() | type);
|
||||
else
|
||||
{
|
||||
pathState.insert(path, type);
|
||||
paths.append(path); // keep path in list for depth sort
|
||||
}
|
||||
}
|
||||
}
|
||||
uiCallback.endProcess();
|
||||
// Add or merge file state into directory state
|
||||
pathstate_map_t::iterator state_it = pathState.find(path);
|
||||
if (state_it != pathState.end())
|
||||
state_it.value() = static_cast<WorkspaceFile::Type>(state_it.value() | type);
|
||||
else
|
||||
{
|
||||
pathState.insert(path, type);
|
||||
paths.append(path); // keep path in list for depth sort
|
||||
}
|
||||
}
|
||||
}
|
||||
uiCallback.endProcess();
|
||||
|
||||
uiCallback.beginProcess(QObject::tr("Updating..."));
|
||||
uiCallback.beginProcess(QObject::tr("Updating..."));
|
||||
|
||||
// Update Files and Directories
|
||||
for(QStringList::iterator line_it=res.begin(); line_it!=res.end(); ++line_it)
|
||||
{
|
||||
QString line = (*line_it).trimmed();
|
||||
if(line.length()==0)
|
||||
continue;
|
||||
// Update Files and Directories
|
||||
for (QStringList::iterator line_it = res.begin(); line_it != res.end(); ++line_it)
|
||||
{
|
||||
QString line = (*line_it).trimmed();
|
||||
if (line.length() == 0)
|
||||
continue;
|
||||
|
||||
int space_index = line.indexOf(' ');
|
||||
if(space_index==-1)
|
||||
continue;
|
||||
int space_index = line.indexOf(' ');
|
||||
if (space_index == -1)
|
||||
continue;
|
||||
|
||||
QString status_text = line.left(space_index);
|
||||
QString fname = line.right(line.length() - space_index).trimmed();
|
||||
WorkspaceFile::Type type = WorkspaceFile::TYPE_UNKNOWN;
|
||||
QString status_text = line.left(space_index);
|
||||
QString fname = line.right(line.length() - space_index).trimmed();
|
||||
WorkspaceFile::Type type = WorkspaceFile::TYPE_UNKNOWN;
|
||||
|
||||
// Generate a RepoFile for all non-existant fossil files
|
||||
// or for all files if we skipped scanning the workspace
|
||||
bool add_missing = !scan_files;
|
||||
// Generate a RepoFile for all non-existant fossil files
|
||||
// or for all files if we skipped scanning the workspace
|
||||
bool add_missing = !scan_files;
|
||||
|
||||
if(status_text=="EDITED")
|
||||
type = WorkspaceFile::TYPE_EDITTED;
|
||||
else if(status_text=="ADDED")
|
||||
type = WorkspaceFile::TYPE_ADDED;
|
||||
else if(status_text=="DELETED")
|
||||
{
|
||||
type = WorkspaceFile::TYPE_DELETED;
|
||||
add_missing = true;
|
||||
}
|
||||
else if(status_text=="MISSING")
|
||||
{
|
||||
type = WorkspaceFile::TYPE_MISSING;
|
||||
add_missing = true;
|
||||
}
|
||||
else if(status_text=="RENAMED")
|
||||
type = WorkspaceFile::TYPE_RENAMED;
|
||||
else if(status_text=="UNCHANGED")
|
||||
type = WorkspaceFile::TYPE_UNCHANGED;
|
||||
else if(status_text=="CONFLICT")
|
||||
type = WorkspaceFile::TYPE_CONFLICTED;
|
||||
else if(status_text=="UPDATED_BY_MERGE" || status_text=="ADDED_BY_MERGE" || status_text=="ADDED_BY_INTEGRATE" || status_text=="UPDATED_BY_INTEGRATE")
|
||||
type = WorkspaceFile::TYPE_MERGED;
|
||||
if (status_text == "EDITED")
|
||||
type = WorkspaceFile::TYPE_EDITTED;
|
||||
else if (status_text == "ADDED")
|
||||
type = WorkspaceFile::TYPE_ADDED;
|
||||
else if (status_text == "DELETED")
|
||||
{
|
||||
type = WorkspaceFile::TYPE_DELETED;
|
||||
add_missing = true;
|
||||
}
|
||||
else if (status_text == "MISSING")
|
||||
{
|
||||
type = WorkspaceFile::TYPE_MISSING;
|
||||
add_missing = true;
|
||||
}
|
||||
else if (status_text == "RENAMED")
|
||||
type = WorkspaceFile::TYPE_RENAMED;
|
||||
else if (status_text == "UNCHANGED")
|
||||
type = WorkspaceFile::TYPE_UNCHANGED;
|
||||
else if (status_text == "CONFLICT")
|
||||
type = WorkspaceFile::TYPE_CONFLICTED;
|
||||
else if (status_text == "UPDATED_BY_MERGE" || status_text == "ADDED_BY_MERGE" || status_text == "ADDED_BY_INTEGRATE" || status_text == "UPDATED_BY_INTEGRATE")
|
||||
type = WorkspaceFile::TYPE_MERGED;
|
||||
|
||||
// Filter unwanted file types
|
||||
if( ((type & WorkspaceFile::TYPE_MODIFIED) && !scanModified) ||
|
||||
((type & WorkspaceFile::TYPE_UNCHANGED) && !scanUnchanged))
|
||||
{
|
||||
getFiles().remove(fname);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
add_missing = true;
|
||||
// Filter unwanted file types
|
||||
if (((type & WorkspaceFile::TYPE_MODIFIED) && !scanModified) || ((type & WorkspaceFile::TYPE_UNCHANGED) && !scanUnchanged))
|
||||
{
|
||||
getFiles().remove(fname);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
add_missing = true;
|
||||
|
||||
filemap_t::iterator it = getFiles().find(fname);
|
||||
filemap_t::iterator it = getFiles().find(fname);
|
||||
|
||||
WorkspaceFile *rf = 0;
|
||||
if(add_missing && it==getFiles().end())
|
||||
{
|
||||
QFileInfo info(wkdir+QDir::separator()+fname);
|
||||
rf = new WorkspaceFile(info, type, wkdir);
|
||||
getFiles().insert(rf->getFilePath(), rf);
|
||||
}
|
||||
WorkspaceFile *rf = 0;
|
||||
if (add_missing && it == getFiles().end())
|
||||
{
|
||||
QFileInfo info(wkdir + QDir::separator() + fname);
|
||||
rf = new WorkspaceFile(info, type, wkdir);
|
||||
getFiles().insert(rf->getFilePath(), rf);
|
||||
}
|
||||
|
||||
if(!rf)
|
||||
{
|
||||
it = getFiles().find(fname);
|
||||
Q_ASSERT(it!=getFiles().end());
|
||||
rf = *it;
|
||||
}
|
||||
if (!rf)
|
||||
{
|
||||
it = getFiles().find(fname);
|
||||
Q_ASSERT(it != getFiles().end());
|
||||
rf = *it;
|
||||
}
|
||||
|
||||
rf->setType(type);
|
||||
rf->setType(type);
|
||||
|
||||
QString path = rf->getPath();
|
||||
getPaths().insert(path);
|
||||
QString path = rf->getPath();
|
||||
getPaths().insert(path);
|
||||
|
||||
// Add or merge file state into directory state
|
||||
pathstate_map_t::iterator state_it = pathState.find(path);
|
||||
if(state_it != pathState.end())
|
||||
state_it.value() = static_cast<WorkspaceFile::Type>(state_it.value() | type);
|
||||
else
|
||||
{
|
||||
pathState.insert(path, type);
|
||||
paths.append(path); // keep path in list for depth sort
|
||||
}
|
||||
}
|
||||
// Add or merge file state into directory state
|
||||
pathstate_map_t::iterator state_it = pathState.find(path);
|
||||
if (state_it != pathState.end())
|
||||
state_it.value() = static_cast<WorkspaceFile::Type>(state_it.value() | type);
|
||||
else
|
||||
{
|
||||
pathState.insert(path, type);
|
||||
paths.append(path); // keep path in list for depth sort
|
||||
}
|
||||
}
|
||||
|
||||
// Sort paths, so that children (longer path) are before parents (shorter path)
|
||||
std::sort(paths.begin(), paths.end(), StringLengthDescending);
|
||||
foreach(const QString &p, paths)
|
||||
{
|
||||
pathstate_map_t::iterator state_it = pathState.find(p);
|
||||
Q_ASSERT(state_it != pathState.end());
|
||||
WorkspaceFile::Type state = state_it.value();
|
||||
// Sort paths, so that children (longer path) are before parents (shorter path)
|
||||
std::sort(paths.begin(), paths.end(), StringLengthDescending);
|
||||
foreach (const QString &p, paths)
|
||||
{
|
||||
pathstate_map_t::iterator state_it = pathState.find(p);
|
||||
Q_ASSERT(state_it != pathState.end());
|
||||
WorkspaceFile::Type state = state_it.value();
|
||||
|
||||
// Propagate child dir state to parents
|
||||
QString parent_path = p;
|
||||
while(!parent_path.isEmpty())
|
||||
{
|
||||
// Extract parent path
|
||||
int sep_index = parent_path.lastIndexOf(PATH_SEPARATOR);
|
||||
if(sep_index>=0)
|
||||
parent_path = parent_path.left(sep_index);
|
||||
else
|
||||
parent_path = "";
|
||||
// Propagate child dir state to parents
|
||||
QString parent_path = p;
|
||||
while (!parent_path.isEmpty())
|
||||
{
|
||||
// Extract parent path
|
||||
int sep_index = parent_path.lastIndexOf(PATH_SEPARATOR);
|
||||
if (sep_index >= 0)
|
||||
parent_path = parent_path.left(sep_index);
|
||||
else
|
||||
parent_path = "";
|
||||
|
||||
// Merge path of child to parent
|
||||
pathstate_map_t::iterator state_it = pathState.find(parent_path);
|
||||
if(state_it != pathState.end())
|
||||
state_it.value() = static_cast<WorkspaceFile::Type>(state_it.value() | state);
|
||||
else
|
||||
pathState.insert(parent_path, state);
|
||||
}
|
||||
}
|
||||
// Merge path of child to parent
|
||||
pathstate_map_t::iterator state_it = pathState.find(parent_path);
|
||||
if (state_it != pathState.end())
|
||||
state_it.value() = static_cast<WorkspaceFile::Type>(state_it.value() | state);
|
||||
else
|
||||
pathState.insert(parent_path, state);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the repository needs integration
|
||||
res.clear();
|
||||
fossil().statusWorkspace(res);
|
||||
isIntegrated = false;
|
||||
foreach(const QString &l, res)
|
||||
{
|
||||
if(l.trimmed().indexOf("INTEGRATE")==0)
|
||||
{
|
||||
isIntegrated = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Check if the repository needs integration
|
||||
res.clear();
|
||||
fossil().statusWorkspace(res);
|
||||
isIntegrated = false;
|
||||
foreach (const QString &l, res)
|
||||
{
|
||||
if (l.trimmed().indexOf("INTEGRATE") == 0)
|
||||
{
|
||||
isIntegrated = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Load the stashes, branches and tags
|
||||
fossil().stashList(getStashes());
|
||||
// Load the stashes, branches and tags
|
||||
fossil().stashList(getStashes());
|
||||
|
||||
fossil().branchList(branchNames, branchNames);
|
||||
fossil().branchList(branchNames, branchNames);
|
||||
|
||||
fossil().tagList(tags);
|
||||
// Fossil includes the branches in the tag list
|
||||
// So remove them
|
||||
foreach(const QString &name, branchNames)
|
||||
tags.remove(name);
|
||||
fossil().tagList(tags);
|
||||
// Fossil includes the branches in the tag list
|
||||
// So remove them
|
||||
foreach (const QString &name, branchNames)
|
||||
tags.remove(name);
|
||||
|
||||
_done:
|
||||
uiCallback.endProcess();
|
||||
uiCallback.endProcess();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool Workspace::addRemote(const QUrl& url, const QString& name)
|
||||
bool Workspace::addRemote(const QUrl &url, const QString &name)
|
||||
{
|
||||
if(remotes.contains(url))
|
||||
return false;
|
||||
if (remotes.contains(url))
|
||||
return false;
|
||||
|
||||
Q_ASSERT(url.password().isEmpty());
|
||||
Q_ASSERT(url.password().isEmpty());
|
||||
|
||||
Remote r(name, url);
|
||||
remotes.insert(url, r);
|
||||
return true;
|
||||
Remote r(name, url);
|
||||
remotes.insert(url, r);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool Workspace::removeRemote(const QUrl& url)
|
||||
bool Workspace::removeRemote(const QUrl &url)
|
||||
{
|
||||
return remotes.remove(url) > 0;
|
||||
return remotes.remove(url) > 0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool Workspace::setRemoteDefault(const QUrl& url)
|
||||
bool Workspace::setRemoteDefault(const QUrl &url)
|
||||
{
|
||||
Q_ASSERT(url.password().isEmpty());
|
||||
Q_ASSERT(url.password().isEmpty());
|
||||
|
||||
const QString &url_str = url.toString();
|
||||
const QString &url_str = url.toString();
|
||||
|
||||
bool found = false;
|
||||
for(remote_map_t::iterator it=remotes.begin(); it!=remotes.end(); ++it)
|
||||
{
|
||||
if(it->url.toString() == url_str) // FIXME: Use strings as QUrl to QUrl comparisons sometime fail!?
|
||||
{
|
||||
it->isDefault = true;
|
||||
found = true;
|
||||
}
|
||||
else
|
||||
it->isDefault = false;
|
||||
}
|
||||
return found;
|
||||
bool found = false;
|
||||
for (remote_map_t::iterator it = remotes.begin(); it != remotes.end(); ++it)
|
||||
{
|
||||
if (it->url.toString() == url_str) // FIXME: Use strings as QUrl to QUrl comparisons sometime fail!?
|
||||
{
|
||||
it->isDefault = true;
|
||||
found = true;
|
||||
}
|
||||
else
|
||||
it->isDefault = false;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
QUrl Workspace::getRemoteDefault() const
|
||||
{
|
||||
for(remote_map_t::const_iterator it=remotes.begin(); it!=remotes.end(); ++it)
|
||||
{
|
||||
if(it->isDefault)
|
||||
return it->url;
|
||||
}
|
||||
for (remote_map_t::const_iterator it = remotes.begin(); it != remotes.end(); ++it)
|
||||
{
|
||||
if (it->isDefault)
|
||||
return it->url;
|
||||
}
|
||||
|
||||
return QUrl();
|
||||
return QUrl();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
Remote * Workspace::findRemote(const QUrl& url)
|
||||
Remote *Workspace::findRemote(const QUrl &url)
|
||||
{
|
||||
remote_map_t::iterator it = remotes.find(url);
|
||||
if(it!=remotes.end())
|
||||
return &(*it);
|
||||
return NULL;
|
||||
remote_map_t::iterator it = remotes.find(url);
|
||||
if (it != remotes.end())
|
||||
return &(*it);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
247
src/Workspace.h
247
src/Workspace.h
@ -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
|
||||
@ -17,202 +17,121 @@
|
||||
class Workspace
|
||||
{
|
||||
public:
|
||||
Workspace();
|
||||
~Workspace();
|
||||
Workspace();
|
||||
~Workspace();
|
||||
|
||||
void clearState();
|
||||
void clearState();
|
||||
|
||||
Fossil & fossil() { return bridge; }
|
||||
const Fossil & fossil() const { return bridge; }
|
||||
Fossil &fossil() { return bridge; }
|
||||
const Fossil &fossil() const { return bridge; }
|
||||
|
||||
const QString & getPath() const { return fossil().getWorkspacePath(); }
|
||||
bool switchWorkspace(const QString &workspace, QSettings &store);
|
||||
void scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModified, bool scanUnchanged, const QStringList& ignorePatterns, UICallback &uiCallback);
|
||||
const QString &getPath() const { return fossil().getWorkspacePath(); }
|
||||
bool switchWorkspace(const QString &workspace, QSettings &store);
|
||||
void scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModified, bool scanUnchanged, const QStringList &ignorePatterns, UICallback &uiCallback);
|
||||
|
||||
QStandardItemModel &getFileModel() { return repoFileModel; }
|
||||
QStandardItemModel &getTreeModel() { return repoTreeModel; }
|
||||
QStandardItemModel &getFileModel() { return repoFileModel; }
|
||||
QStandardItemModel &getTreeModel() { return repoTreeModel; }
|
||||
|
||||
filemap_t &getFiles() { return workspaceFiles; }
|
||||
stringset_t &getPaths() { return pathSet; }
|
||||
pathstate_map_t &getPathState() { return pathState; }
|
||||
stashmap_t &getStashes() { return stashMap; }
|
||||
QStringMap &getTags() { return tags; }
|
||||
QStringList &getBranches() { return branchNames; }
|
||||
bool otherChanges() const { return isIntegrated; }
|
||||
const QString &getCurrentRevision() const { return fossil().getCurrentRevision(); }
|
||||
const QStringList &getActiveTags() const { return fossil().getActiveTags(); }
|
||||
const QString &getProjectName() const { return fossil().getProjectName(); }
|
||||
filemap_t &getFiles() { return workspaceFiles; }
|
||||
stringset_t &getPaths() { return pathSet; }
|
||||
pathstate_map_t &getPathState() { return pathState; }
|
||||
stashmap_t &getStashes() { return stashMap; }
|
||||
QStringMap &getTags() { return tags; }
|
||||
QStringList &getBranches() { return branchNames; }
|
||||
bool otherChanges() const { return isIntegrated; }
|
||||
const QString &getCurrentRevision() const { return fossil().getCurrentRevision(); }
|
||||
const QStringList &getActiveTags() const { return fossil().getActiveTags(); }
|
||||
const QString &getProjectName() const { return fossil().getProjectName(); }
|
||||
|
||||
// Remotes
|
||||
const remote_map_t &getRemotes() const { return remotes; }
|
||||
bool addRemote(const QUrl &url, const QString &name);
|
||||
bool removeRemote(const QUrl &url);
|
||||
bool setRemoteDefault(const QUrl& url);
|
||||
QUrl getRemoteDefault() const;
|
||||
Remote * findRemote(const QUrl& url);
|
||||
// Remotes
|
||||
const remote_map_t &getRemotes() const { return remotes; }
|
||||
bool addRemote(const QUrl &url, const QString &name);
|
||||
bool removeRemote(const QUrl &url);
|
||||
bool setRemoteDefault(const QUrl &url);
|
||||
QUrl getRemoteDefault() const;
|
||||
Remote *findRemote(const QUrl &url);
|
||||
|
||||
void storeWorkspace(QSettings &store);
|
||||
void storeWorkspace(QSettings &store);
|
||||
|
||||
// Fossil Wrappers
|
||||
void Init(UICallback *callback, const QString &exePath)
|
||||
{
|
||||
fossil().Init(callback, exePath);
|
||||
}
|
||||
// Fossil Wrappers
|
||||
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 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);
|
||||
}
|
||||
// Stashes
|
||||
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);
|
||||
}
|
||||
// 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);
|
||||
}
|
||||
// Branches
|
||||
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);
|
||||
static bool scanDirectory(QFileInfoList &entries, const QString &dirPath, const QString &baseDir, const QStringList &ignorePatterns, UICallback &uiCallback);
|
||||
|
||||
private:
|
||||
Fossil bridge;
|
||||
filemap_t workspaceFiles;
|
||||
stringset_t pathSet;
|
||||
pathstate_map_t pathState;
|
||||
stashmap_t stashMap;
|
||||
QStringList branchNames;
|
||||
QStringMap tags;
|
||||
remote_map_t remotes;
|
||||
bool isIntegrated;
|
||||
Fossil bridge;
|
||||
filemap_t workspaceFiles;
|
||||
stringset_t pathSet;
|
||||
pathstate_map_t pathState;
|
||||
stashmap_t stashMap;
|
||||
QStringList branchNames;
|
||||
QStringMap tags;
|
||||
remote_map_t remotes;
|
||||
bool isIntegrated;
|
||||
|
||||
QStandardItemModel repoFileModel;
|
||||
QStandardItemModel repoTreeModel;
|
||||
QStandardItemModel repoFileModel;
|
||||
QStandardItemModel repoTreeModel;
|
||||
};
|
||||
|
||||
#endif // WORKSPACE_H
|
||||
#endif // WORKSPACE_H
|
||||
|
@ -1,21 +1,21 @@
|
||||
#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
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
enum WorkspaceState
|
||||
{
|
||||
WORKSPACE_STATE_OK,
|
||||
WORKSPACE_STATE_NOTFOUND,
|
||||
WORKSPACE_STATE_OLDSCHEMA
|
||||
WORKSPACE_STATE_OK,
|
||||
WORKSPACE_STATE_NOTFOUND,
|
||||
WORKSPACE_STATE_OLDSCHEMA
|
||||
};
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -23,107 +23,81 @@ enum WorkspaceState
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
struct WorkspaceFile
|
||||
{
|
||||
enum Type
|
||||
{
|
||||
TYPE_UNKNOWN = 1<<0,
|
||||
TYPE_UNCHANGED = 1<<1,
|
||||
TYPE_EDITTED = 1<<2,
|
||||
TYPE_ADDED = 1<<3,
|
||||
TYPE_DELETED = 1<<4,
|
||||
TYPE_MISSING = 1<<5,
|
||||
TYPE_RENAMED = 1<<6,
|
||||
TYPE_CONFLICTED = 1<<7,
|
||||
TYPE_MERGED = 1<<8,
|
||||
TYPE_MODIFIED = TYPE_EDITTED|TYPE_ADDED|TYPE_DELETED|TYPE_MISSING|TYPE_RENAMED|TYPE_CONFLICTED|TYPE_MERGED,
|
||||
TYPE_REPO = TYPE_UNCHANGED|TYPE_MODIFIED,
|
||||
TYPE_ALL = TYPE_UNKNOWN|TYPE_REPO
|
||||
};
|
||||
enum Type
|
||||
{
|
||||
TYPE_UNKNOWN = 1 << 0,
|
||||
TYPE_UNCHANGED = 1 << 1,
|
||||
TYPE_EDITTED = 1 << 2,
|
||||
TYPE_ADDED = 1 << 3,
|
||||
TYPE_DELETED = 1 << 4,
|
||||
TYPE_MISSING = 1 << 5,
|
||||
TYPE_RENAMED = 1 << 6,
|
||||
TYPE_CONFLICTED = 1 << 7,
|
||||
TYPE_MERGED = 1 << 8,
|
||||
TYPE_MODIFIED = TYPE_EDITTED | TYPE_ADDED | TYPE_DELETED | TYPE_MISSING | TYPE_RENAMED | TYPE_CONFLICTED | TYPE_MERGED,
|
||||
TYPE_REPO = TYPE_UNCHANGED | TYPE_MODIFIED,
|
||||
TYPE_ALL = TYPE_UNKNOWN | TYPE_REPO
|
||||
};
|
||||
|
||||
WorkspaceFile(const QFileInfo &info, Type type, const QString &repoPath)
|
||||
{
|
||||
FileInfo = info;
|
||||
FileType = type;
|
||||
FilePath = getRelativeFilename(repoPath);
|
||||
Path = FileInfo.absolutePath();
|
||||
WorkspaceFile(const QFileInfo &info, Type type, const QString &repoPath)
|
||||
{
|
||||
FileInfo = info;
|
||||
FileType = type;
|
||||
FilePath = getRelativeFilename(repoPath);
|
||||
Path = FileInfo.absolutePath();
|
||||
|
||||
// Strip the workspace path from the path
|
||||
Q_ASSERT(Path.indexOf(repoPath)==0);
|
||||
Path = Path.mid(repoPath.length()+1);
|
||||
}
|
||||
// Strip the workspace path from the path
|
||||
Q_ASSERT(Path.indexOf(repoPath) == 0);
|
||||
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)
|
||||
{
|
||||
QString abs_base_dir = QDir(path).absolutePath();
|
||||
QString getRelativeFilename(const QString &path)
|
||||
{
|
||||
QString abs_base_dir = QDir(path).absolutePath();
|
||||
|
||||
QString relative = FileInfo.absoluteFilePath();
|
||||
int index = relative.indexOf(abs_base_dir);
|
||||
if(index<0)
|
||||
return QString("");
|
||||
QString relative = FileInfo.absoluteFilePath();
|
||||
int index = relative.indexOf(abs_base_dir);
|
||||
if (index < 0)
|
||||
return QString("");
|
||||
|
||||
return relative.right(relative.length() - abs_base_dir.length()-1);
|
||||
}
|
||||
return relative.right(relative.length() - abs_base_dir.length() - 1);
|
||||
}
|
||||
|
||||
private:
|
||||
QFileInfo FileInfo;
|
||||
Type FileType;
|
||||
QString FilePath;
|
||||
QString Path;
|
||||
QFileInfo FileInfo;
|
||||
Type FileType;
|
||||
QString FilePath;
|
||||
QString Path;
|
||||
};
|
||||
|
||||
class Remote
|
||||
{
|
||||
public:
|
||||
Remote(const QString &_name, const QUrl &_url, bool _isDefault=false)
|
||||
: name(_name), url(_url), isDefault(_isDefault)
|
||||
{
|
||||
}
|
||||
|
||||
QString name;
|
||||
QUrl url;
|
||||
bool 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;
|
||||
typedef QMap<QString, WorkspaceFile::Type> pathstate_map_t;
|
||||
typedef QList<WorkspaceFile*> filelist_t;
|
||||
typedef QMap<QString, WorkspaceFile*> filemap_t;
|
||||
typedef QList<WorkspaceFile *> filelist_t;
|
||||
typedef QMap<QString, WorkspaceFile *> filemap_t;
|
||||
typedef QMap<QString, QString> stashmap_t;
|
||||
|
||||
|
||||
#endif // WORKSPACECOMMON_H
|
||||
#endif // WORKSPACECOMMON_H
|
||||
|
70
src/main.cpp
70
src/main.cpp
@ -1,46 +1,42 @@
|
||||
#include <QApplication>
|
||||
#include "MainWindow.h"
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
app.setApplicationName("Fuel");
|
||||
app.setApplicationVersion(FUEL_VERSION);
|
||||
app.setOrganizationDomain("fuel-scm.org");
|
||||
app.setOrganizationName("Fuel-SCM");
|
||||
QApplication app(argc, argv);
|
||||
app.setApplicationName("Fuel");
|
||||
app.setApplicationVersion(FUEL_VERSION);
|
||||
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);
|
||||
#endif
|
||||
{
|
||||
bool portable = false;
|
||||
QString workspace;
|
||||
|
||||
#ifdef Q_OS_MACX
|
||||
// Native OSX applications don't have menu icons
|
||||
app.setAttribute(Qt::AA_DontShowIconsInMenus);
|
||||
#endif
|
||||
{
|
||||
bool portable = false;
|
||||
QString workspace;
|
||||
Q_ASSERT(app.arguments().size() > 0);
|
||||
for (int i = 1; i < app.arguments().size(); ++i)
|
||||
{
|
||||
QString arg = app.arguments()[i];
|
||||
// Parse options
|
||||
if (arg.indexOf("--") != -1)
|
||||
{
|
||||
if (arg.indexOf("portable") != -1)
|
||||
portable = true;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
workspace = arg;
|
||||
}
|
||||
|
||||
Q_ASSERT(app.arguments().size()>0);
|
||||
for(int i=1; i<app.arguments().size(); ++i)
|
||||
{
|
||||
QString arg = app.arguments()[i];
|
||||
// Parse options
|
||||
if(arg.indexOf("--")!=-1)
|
||||
{
|
||||
if(arg.indexOf("portable")!=-1)
|
||||
portable = true;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
workspace = arg;
|
||||
}
|
||||
Settings settings(portable);
|
||||
|
||||
Settings settings(portable);
|
||||
|
||||
MainWindow mainwin(settings,
|
||||
0,
|
||||
workspace.isEmpty() ? 0 : &workspace);
|
||||
mainwin.show();
|
||||
mainwin.fullRefresh();
|
||||
return app.exec();
|
||||
|
||||
}
|
||||
MainWindow mainwin(settings, 0, workspace.isEmpty() ? 0 : &workspace);
|
||||
mainwin.show();
|
||||
mainwin.fullRefresh();
|
||||
return app.exec();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user