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