🎨 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,9 +2,7 @@
|
|||||||
#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());
|
||||||
@ -17,12 +15,12 @@ AboutDialog::AboutDialog(QWidget *parent, const QString &fossilVersion) :
|
|||||||
|
|
||||||
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));
|
||||||
@ -34,18 +32,18 @@ AboutDialog::AboutDialog(QWidget *parent, const QString &fossilVersion) :
|
|||||||
|
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui
|
||||||
|
{
|
||||||
class AboutDialog;
|
class AboutDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
#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)
|
||||||
@ -20,7 +20,7 @@ Settings::Settings(bool portableMode) : store(0)
|
|||||||
|
|
||||||
// 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
|
||||||
{
|
{
|
||||||
@ -30,18 +30,17 @@ Settings::Settings(bool portableMode) : store(0)
|
|||||||
}
|
}
|
||||||
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)
|
||||||
for(int i=0; i<MAX_CUSTOM_ACTIONS; ++i)
|
|
||||||
{
|
{
|
||||||
CustomAction action;
|
CustomAction action;
|
||||||
action.Id = QObject::tr("Custom Action %0").arg(i+1);
|
action.Id = QObject::tr("Custom Action %0").arg(i + 1);
|
||||||
customActions.append(action);
|
customActions.append(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,27 +61,26 @@ void Settings::ApplyEnvironment()
|
|||||||
#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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,7 +93,7 @@ bool Settings::HasValue(const QString &name) const
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
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);
|
||||||
}
|
}
|
||||||
@ -109,16 +107,16 @@ void Settings::SetValue(const QString &name, const QVariant &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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
#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"
|
||||||
@ -19,7 +19,6 @@
|
|||||||
#define FOSSIL_SETTING_CRNL_GLOB "crnl-glob"
|
#define FOSSIL_SETTING_CRNL_GLOB "crnl-glob"
|
||||||
#define FOSSIL_SETTING_HTTP_PORT "http-port"
|
#define FOSSIL_SETTING_HTTP_PORT "http-port"
|
||||||
|
|
||||||
|
|
||||||
enum FileDblClickAction
|
enum FileDblClickAction
|
||||||
{
|
{
|
||||||
FILE_DLBCLICK_ACTION_DIFF,
|
FILE_DLBCLICK_ACTION_DIFF,
|
||||||
@ -29,15 +28,13 @@ enum FileDblClickAction
|
|||||||
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
|
||||||
@ -51,20 +48,11 @@ struct CustomAction
|
|||||||
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()
|
||||||
{
|
{
|
||||||
@ -85,35 +73,34 @@ struct Settings
|
|||||||
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(bool portableMode = false);
|
||||||
~Settings();
|
~Settings();
|
||||||
|
|
||||||
void ApplyEnvironment();
|
void ApplyEnvironment();
|
||||||
|
|
||||||
// App configuration access
|
// App configuration access
|
||||||
class QSettings * GetStore() { return store; }
|
class QSettings *GetStore() { return store; }
|
||||||
bool HasValue(const QString &name) const; // store->contains(FUEL_SETTING_FOSSIL_PATH)
|
bool HasValue(const QString &name) const; // store->contains(FUEL_SETTING_FOSSIL_PATH)
|
||||||
const QVariant GetValue(const QString &name); // settings.store->value
|
const QVariant GetValue(const QString &name); // settings.store->value
|
||||||
void SetValue(const QString &name, const QVariant &value); // settings.store->value
|
void SetValue(const QString &name, const QVariant &value); // settings.store->value
|
||||||
|
|
||||||
// Fossil configuration access
|
// Fossil configuration access
|
||||||
QVariant & GetFossilValue(const QString &name);
|
QVariant &GetFossilValue(const QString &name);
|
||||||
void SetFossilValue(const QString &name, const QVariant &value);
|
void SetFossilValue(const QString &name, const QVariant &value);
|
||||||
mappings_t & GetMappings() { return Mappings; }
|
mappings_t &GetMappings() { return Mappings; }
|
||||||
|
|
||||||
bool SupportsLang(const QString &langId) const;
|
bool SupportsLang(const QString &langId) const;
|
||||||
bool InstallLang(const QString &langId);
|
bool InstallLang(const QString &langId);
|
||||||
|
|
||||||
custom_actions_t &GetCustomActions() { return customActions; }
|
custom_actions_t &GetCustomActions() { return customActions; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mappings_t Mappings;
|
mappings_t Mappings;
|
||||||
class QSettings *store;
|
class QSettings *store;
|
||||||
@ -122,5 +109,4 @@ private:
|
|||||||
custom_actions_t customActions;
|
custom_actions_t customActions;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // APPSETTINGS_H
|
#endif // APPSETTINGS_H
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
#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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,28 +28,26 @@ void BrowserWidget::on_webView_urlChanged(const QUrl &url)
|
|||||||
|
|
||||||
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();
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
#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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
#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);
|
||||||
}
|
}
|
||||||
@ -28,12 +26,12 @@ bool CloneDialog::run(QWidget *parent, QUrl &url, QString &repository, QUrl &url
|
|||||||
|
|
||||||
// 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());
|
||||||
@ -44,40 +42,40 @@ bool CloneDialog::run(QWidget *parent, QUrl &url, QString &repository, QUrl &url
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,18 +88,12 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,10 +103,10 @@ 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;
|
||||||
@ -129,10 +121,10 @@ 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;
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui
|
||||||
|
{
|
||||||
class CloneDialog;
|
class CloneDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15,7 +16,7 @@ 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();
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
#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();
|
||||||
@ -25,20 +23,20 @@ CommitDialog::CommitDialog(QWidget *parent, const QString &title, QStringList &f
|
|||||||
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);
|
||||||
@ -46,7 +44,7 @@ CommitDialog::CommitDialog(QWidget *parent, const QString &title, QStringList &f
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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);
|
||||||
@ -54,10 +52,9 @@ CommitDialog::CommitDialog(QWidget *parent, const QString &title, QStringList &f
|
|||||||
itemModel.appendRow(si);
|
itemModel.appendRow(si);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Trigger commit with a Ctrl-Return from the comment box
|
// Trigger commit with a Ctrl-Return from the comment box
|
||||||
QAction* action = new QAction(ui->plainTextEdit);
|
QAction *action = new QAction(ui->plainTextEdit);
|
||||||
QShortcut* shortcut = new QShortcut(QKeySequence("Ctrl+Return"), ui->plainTextEdit);
|
QShortcut *shortcut = new QShortcut(QKeySequence("Ctrl+Return"), 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::Ok), SLOT(click()));
|
||||||
|
|
||||||
@ -75,27 +72,27 @@ CommitDialog::~CommitDialog()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
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();
|
||||||
@ -105,21 +102,21 @@ bool CommitDialog::runCommit(QWidget* parent, QStringList& files, QString& commi
|
|||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
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());
|
||||||
}
|
}
|
||||||
@ -133,10 +130,10 @@ 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]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,21 +142,21 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
@ -4,8 +4,9 @@
|
|||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui
|
||||||
class CommitDialog;
|
{
|
||||||
|
class CommitDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
class CommitDialog : public QDialog
|
class CommitDialog : public QDialog
|
||||||
@ -16,8 +17,8 @@ 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);
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
#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"));
|
||||||
}
|
}
|
||||||
@ -10,9 +9,9 @@ CustomWebView::CustomWebView(QWidget *parent) :
|
|||||||
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);
|
||||||
|
@ -15,7 +15,6 @@ public slots:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void mousePressEvent(QMouseEvent *event);
|
virtual void mousePressEvent(QMouseEvent *event);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CUSTOMWEBVIEW_H
|
#endif // CUSTOMWEBVIEW_H
|
||||||
|
@ -1,18 +1,16 @@
|
|||||||
#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);
|
||||||
@ -22,11 +20,11 @@ FileActionDialog::FileActionDialog(QWidget *parent, const QString &title, const
|
|||||||
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -41,7 +39,7 @@ bool FileActionDialog::run(QWidget *parent, const QString &title, const QString
|
|||||||
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;
|
||||||
@ -61,4 +59,3 @@ 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,28 +2,28 @@
|
|||||||
#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);
|
||||||
|
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
#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)
|
||||||
@ -27,5 +24,4 @@ void FileTableView::mouseMoveEvent(QMouseEvent *event)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
QTableView::mouseMoveEvent(event);
|
QTableView::mouseMoveEvent(event);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#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
|
||||||
{
|
{
|
||||||
|
431
src/Fossil.cpp
431
src/Fossil.cpp
File diff suppressed because it is too large
Load Diff
72
src/Fossil.h
72
src/Fossil.h
@ -2,17 +2,16 @@
|
|||||||
#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();
|
Fossil();
|
||||||
void Init(UICallback *callback, const QString &exePath);
|
void Init(UICallback *callback, const QString &exePath);
|
||||||
|
|
||||||
@ -21,14 +20,14 @@ public:
|
|||||||
bool cloneRepository(const QString &repository, const QUrl &url, const QUrl &proxyUrl);
|
bool cloneRepository(const QString &repository, const QUrl &url, const QUrl &proxyUrl);
|
||||||
|
|
||||||
// Workspace
|
// Workspace
|
||||||
bool createWorkspace(const QString &repositoryPath, const QString& workspacePath);
|
bool createWorkspace(const QString &repositoryPath, const QString &workspacePath);
|
||||||
bool closeWorkspace(bool force=false);
|
bool closeWorkspace(bool force = false);
|
||||||
void setWorkspace(const QString &_workspacePath);
|
void setWorkspace(const QString &_workspacePath);
|
||||||
bool pushWorkspace(const QUrl& url);
|
bool pushWorkspace(const QUrl &url);
|
||||||
bool pullWorkspace(const QUrl& url);
|
bool pullWorkspace(const QUrl &url);
|
||||||
bool undoWorkspace(QStringList& result, bool explainOnly);
|
bool undoWorkspace(QStringList &result, bool explainOnly);
|
||||||
bool updateWorkspace(QStringList& result, const QString& revision, bool explainOnly);
|
bool updateWorkspace(QStringList &result, const QString &revision, bool explainOnly);
|
||||||
bool statusWorkspace(QStringList& result);
|
bool statusWorkspace(QStringList &result);
|
||||||
WorkspaceState getWorkspaceState();
|
WorkspaceState getWorkspaceState();
|
||||||
static bool isWorkspace(const QString &path);
|
static bool isWorkspace(const QString &path);
|
||||||
|
|
||||||
@ -40,36 +39,36 @@ public:
|
|||||||
// Files
|
// Files
|
||||||
bool listFiles(QStringList &files);
|
bool listFiles(QStringList &files);
|
||||||
bool diffFile(const QString &repoFile, bool graphical);
|
bool diffFile(const QString &repoFile, bool 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);
|
||||||
bool addFiles(const QStringList& fileList);
|
bool addFiles(const QStringList &fileList);
|
||||||
bool removeFiles(const QStringList& fileList, bool deleteLocal);
|
bool removeFiles(const QStringList &fileList, bool deleteLocal);
|
||||||
bool revertFiles(const QStringList& fileList);
|
bool revertFiles(const QStringList &fileList);
|
||||||
bool renameFile(const QString& beforePath, const QString& afterPath, bool renameLocal);
|
bool renameFile(const QString &beforePath, const QString &afterPath, bool renameLocal);
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
bool getSettings(QStringList& result);
|
bool getSettings(QStringList &result);
|
||||||
bool setSetting(const QString &name, const QString &value, bool global);
|
bool setSetting(const QString &name, const QString &value, bool global);
|
||||||
|
|
||||||
// Remotes
|
// Remotes
|
||||||
bool setRemoteUrl(const QUrl& url);
|
bool setRemoteUrl(const QUrl &url);
|
||||||
bool getRemoteUrl(QUrl &url);
|
bool getRemoteUrl(QUrl &url);
|
||||||
|
|
||||||
// Stashes
|
// Stashes
|
||||||
bool stashNew(const QStringList& fileList, const QString& name, bool revert);
|
bool stashNew(const QStringList &fileList, const QString &name, bool revert);
|
||||||
bool stashList(stashmap_t &stashes);
|
bool stashList(stashmap_t &stashes);
|
||||||
bool stashApply(const QString& name);
|
bool stashApply(const QString &name);
|
||||||
bool stashDrop(const QString& name);
|
bool stashDrop(const QString &name);
|
||||||
bool stashDiff(const QString& name);
|
bool stashDiff(const QString &name);
|
||||||
|
|
||||||
// Tags
|
// Tags
|
||||||
bool tagList(QStringMap& tags);
|
bool tagList(QStringMap &tags);
|
||||||
bool tagNew(const QString& name, const QString& revision);
|
bool tagNew(const QString &name, const QString &revision);
|
||||||
bool tagDelete(const QString& name, const QString& revision);
|
bool tagDelete(const QString &name, const QString &revision);
|
||||||
|
|
||||||
// Branches
|
// Branches
|
||||||
bool branchList(QStringList& branches, QStringList& activeBranches);
|
bool branchList(QStringList &branches, QStringList &activeBranches);
|
||||||
bool branchNew(const QString& name, const QString& revisionBasis, bool isPrivate=false);
|
bool branchNew(const QString &name, const QString &revisionBasis, bool isPrivate = false);
|
||||||
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);
|
||||||
|
|
||||||
const QString &getCurrentRevision() const { return currentRevision; }
|
const QString &getCurrentRevision() const { return currentRevision; }
|
||||||
const QStringList &getActiveTags() const { return activeTags; }
|
const QStringList &getActiveTags() const { return activeTags; }
|
||||||
@ -88,22 +87,22 @@ public:
|
|||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,5 +117,4 @@ private:
|
|||||||
QString fossilUIPort;
|
QString fossilUIPort;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // FOSSIL_H
|
#endif // FOSSIL_H
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
#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);
|
||||||
|
|
||||||
@ -56,7 +53,7 @@ void FslSettingsDialog::on_buttonBox_accepted()
|
|||||||
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +61,6 @@ void FslSettingsDialog::on_btnSelectFossilGDiff_clicked()
|
|||||||
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,11 +1,12 @@
|
|||||||
#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
|
||||||
@ -18,14 +19,12 @@ public:
|
|||||||
|
|
||||||
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;
|
||||||
};
|
};
|
||||||
|
@ -19,4 +19,3 @@ void LoggedProcess::onReadyReadStandardOutput()
|
|||||||
QMutexLocker lck(&mutex);
|
QMutexLocker lck(&mutex);
|
||||||
log.append(readAllStandardOutput());
|
log.append(readAllStandardOutput());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#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
|
||||||
{
|
{
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
@ -21,7 +22,7 @@ class MainWindow : public QMainWindow
|
|||||||
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:
|
||||||
@ -29,18 +30,18 @@ private:
|
|||||||
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);
|
||||||
@ -51,7 +52,7 @@ private:
|
|||||||
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);
|
||||||
|
|
||||||
@ -60,8 +61,8 @@ private:
|
|||||||
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
|
||||||
{
|
{
|
||||||
@ -140,17 +141,13 @@ 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);
|
||||||
@ -165,7 +162,7 @@ private:
|
|||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
MAX_RECENT=5
|
MAX_RECENT = 5
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef QMap<QString, QIcon> icon_map_t;
|
typedef QMap<QString, QIcon> icon_map_t;
|
||||||
@ -195,8 +192,8 @@ private:
|
|||||||
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;
|
||||||
@ -207,4 +204,3 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
#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);
|
||||||
}
|
}
|
||||||
@ -27,11 +25,11 @@ 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
|
||||||
{
|
{
|
||||||
@ -42,32 +40,32 @@ bool RemoteDialog::run(QWidget *parent, QUrl &url, QString &name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
@ -78,13 +76,7 @@ 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -93,10 +85,10 @@ 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;
|
||||||
@ -104,4 +96,3 @@ void RemoteDialog::on_btnSelectSourceRepo_clicked()
|
|||||||
|
|
||||||
ui->lineURL->setText(QDir::toNativeSeparators(path));
|
ui->lineURL->setText(QDir::toNativeSeparators(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,8 @@
|
|||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui
|
||||||
|
{
|
||||||
class RemoteDialog;
|
class RemoteDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,23 +1,20 @@
|
|||||||
#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);
|
||||||
@ -45,7 +42,7 @@ QString RevisionDialog::runUpdate(QWidget *parent, const QString &title, const Q
|
|||||||
|
|
||||||
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();
|
||||||
}
|
}
|
||||||
@ -66,7 +63,7 @@ QString RevisionDialog::runMerge(QWidget *parent, const QString &title, const QS
|
|||||||
|
|
||||||
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;
|
||||||
@ -75,7 +72,6 @@ QString RevisionDialog::runMerge(QWidget *parent, const QString &title, const QS
|
|||||||
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)
|
||||||
{
|
{
|
||||||
@ -91,7 +87,7 @@ bool RevisionDialog::runNewTag(QWidget *parent, const QString &title, const QStr
|
|||||||
|
|
||||||
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();
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
#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
|
||||||
@ -17,7 +18,7 @@ public:
|
|||||||
~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:
|
||||||
|
@ -1,19 +1,14 @@
|
|||||||
#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();
|
||||||
@ -21,4 +16,3 @@ void SearchBox::keyPressEvent(QKeyEvent *event)
|
|||||||
else
|
else
|
||||||
QLineEdit::keyPressEvent(event);
|
QLineEdit::keyPressEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ class SearchBox : public QLineEdit
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit SearchBox(QWidget* parent=0);
|
explicit SearchBox(QWidget *parent = 0);
|
||||||
~SearchBox();
|
~SearchBox();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@ -16,8 +16,6 @@ public slots:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void keyPressEvent(QKeyEvent *event);
|
void keyPressEvent(QKeyEvent *event);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // SEARCHBOX_H
|
#endif // SEARCHBOX_H
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
#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);
|
||||||
|
|
||||||
@ -28,15 +25,12 @@ SettingsDialog::SettingsDialog(QWidget *parent, Settings &_settings) :
|
|||||||
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;
|
lastActionIndex = 0;
|
||||||
currentCustomActions = settings->GetCustomActions();
|
currentCustomActions = settings->GetCustomActions();
|
||||||
@ -47,7 +41,7 @@ SettingsDialog::SettingsDialog(QWidget *parent, Settings &_settings) :
|
|||||||
|
|
||||||
GetCustomAction(0);
|
GetCustomAction(0);
|
||||||
|
|
||||||
for(int i=0; i<currentCustomActions.size(); ++i)
|
for (int i = 0; i < currentCustomActions.size(); ++i)
|
||||||
{
|
{
|
||||||
CustomAction &a = currentCustomActions[i];
|
CustomAction &a = currentCustomActions[i];
|
||||||
ui->cmbCustomAction->addItem(a.Id);
|
ui->cmbCustomAction->addItem(a.Id);
|
||||||
@ -72,7 +66,7 @@ bool SettingsDialog::run(QWidget *parent, Settings &settings)
|
|||||||
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());
|
||||||
|
|
||||||
@ -82,10 +76,10 @@ void SettingsDialog::on_buttonBox_accepted()
|
|||||||
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();
|
||||||
@ -103,14 +97,14 @@ void SettingsDialog::on_buttonBox_accepted()
|
|||||||
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());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,9 +126,9 @@ void SettingsDialog::CreateLangMap()
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,9 +138,9 @@ QString SettingsDialog::LangIdToName(const QString &id)
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,11 +151,11 @@ QString SettingsDialog::LangNameToId(const QString &name)
|
|||||||
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));
|
||||||
@ -170,29 +164,29 @@ void SettingsDialog::on_btnSelectCustomFileActionCommand_clicked()
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
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);
|
||||||
@ -203,8 +197,8 @@ void SettingsDialog::on_cmbCustomAction_currentIndexChanged(int 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,11 +1,12 @@
|
|||||||
#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
|
||||||
@ -18,7 +19,6 @@ public:
|
|||||||
|
|
||||||
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();
|
||||||
@ -36,10 +36,7 @@ private:
|
|||||||
|
|
||||||
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;
|
||||||
|
221
src/Utils.cpp
221
src/Utils.cpp
@ -1,17 +1,17 @@
|
|||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QDialogButtonBox>
|
|
||||||
#include <QFileDialog>
|
|
||||||
#include <QEventLoop>
|
|
||||||
#include <QUrl>
|
|
||||||
#include <QProcess>
|
|
||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
#include <QEventLoop>
|
||||||
|
#include <QFileDialog>
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QProcess>
|
||||||
|
#include <QUrl>
|
||||||
#include <qt5keychain/keychain.h>
|
#include <qt5keychain/keychain.h>
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
QMessageBox::StandardButton DialogQuery(QWidget *parent, const QString &title, const QString &query, QMessageBox::StandardButtons buttons)
|
QMessageBox::StandardButton DialogQuery(QWidget *parent, const QString &title, const QString &query, QMessageBox::StandardButtons buttons)
|
||||||
{
|
{
|
||||||
QMessageBox mb(QMessageBox::Question, title, query, buttons, parent, Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint | Qt::Sheet );
|
QMessageBox mb(QMessageBox::Question, title, query, buttons, parent, Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint | Qt::Sheet);
|
||||||
mb.setDefaultButton(QMessageBox::No);
|
mb.setDefaultButton(QMessageBox::No);
|
||||||
mb.setWindowModality(Qt::WindowModal);
|
mb.setWindowModality(Qt::WindowModal);
|
||||||
mb.setModal(true);
|
mb.setModal(true);
|
||||||
@ -30,7 +30,7 @@ QString QuotePath(const QString &path)
|
|||||||
QStringList QuotePaths(const QStringList &paths)
|
QStringList QuotePaths(const QStringList &paths)
|
||||||
{
|
{
|
||||||
QStringList res;
|
QStringList res;
|
||||||
for(int i=0; i<paths.size(); ++i)
|
for (int i = 0; i < paths.size(); ++i)
|
||||||
res.append(QuotePath(paths[i]));
|
res.append(QuotePath(paths[i]));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -44,24 +44,19 @@ QString SelectExe(QWidget *parent, const QString &description)
|
|||||||
#else
|
#else
|
||||||
filter += " (*)";
|
filter += " (*)";
|
||||||
#endif
|
#endif
|
||||||
QString path = QFileDialog::getOpenFileName(
|
QString path = QFileDialog::getOpenFileName(parent, description, QString(), filter, &filter);
|
||||||
parent,
|
|
||||||
description,
|
|
||||||
QString(),
|
|
||||||
filter,
|
|
||||||
&filter);
|
|
||||||
|
|
||||||
if(!QFile::exists(path))
|
if (!QFile::exists(path))
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
#ifdef Q_OS_MACX
|
#ifdef Q_OS_MACX
|
||||||
// Guess actual executable from bundle dir
|
// Guess actual executable from bundle dir
|
||||||
QFileInfo fi(path);
|
QFileInfo fi(path);
|
||||||
if(fi.isDir() && path.indexOf(".app")!=-1)
|
if (fi.isDir() && path.indexOf(".app") != -1)
|
||||||
{
|
{
|
||||||
path += "/Contents/MacOS/" + fi.baseName();
|
path += "/Contents/MacOS/" + fi.baseName();
|
||||||
|
|
||||||
if(!QFile::exists(path))
|
if (!QFile::exists(path))
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -70,7 +65,7 @@ QString SelectExe(QWidget *parent, const QString &description)
|
|||||||
}
|
}
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
#if 0 // Unused
|
#if 0 // Unused
|
||||||
#include <QInputDialog>
|
# include <QInputDialog>
|
||||||
|
|
||||||
static bool DialogQueryText(QWidget *parent, const QString &title, const QString &query, QString &text, bool isPassword=false)
|
static bool DialogQueryText(QWidget *parent, const QString &title, const QString &query, QString &text, bool isPassword=false)
|
||||||
{
|
{
|
||||||
@ -92,10 +87,9 @@ static bool DialogQueryText(QWidget *parent, const QString &title, const QString
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
// Explorer File Context Menu support. Based on http://www.microsoft.com/msj/0497/wicked/wicked0497.aspx
|
// Explorer File Context Menu support. Based on http://www.microsoft.com/msj/0497/wicked/wicked0497.aspx
|
||||||
#include <shlobj.h>
|
# include <shlobj.h>
|
||||||
|
|
||||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
//
|
//
|
||||||
@ -128,14 +122,14 @@ bool ShowExplorerMenu(HWND hwnd, const QString &path, const QPoint &qpoint)
|
|||||||
// INPUT: pidl = Pointer to an item ID list.
|
// INPUT: pidl = Pointer to an item ID list.
|
||||||
// RETURNS: Pointer to the next item.
|
// RETURNS: Pointer to the next item.
|
||||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
static LPITEMIDLIST GetNextItem (LPITEMIDLIST pidl)
|
static LPITEMIDLIST GetNextItem(LPITEMIDLIST pidl)
|
||||||
{
|
{
|
||||||
USHORT nLen;
|
USHORT nLen;
|
||||||
|
|
||||||
if ((nLen = pidl->mkid.cb) == 0)
|
if ((nLen = pidl->mkid.cb) == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return (LPITEMIDLIST) (((LPBYTE) pidl) + nLen);
|
return (LPITEMIDLIST)(((LPBYTE)pidl) + nLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
@ -144,14 +138,15 @@ bool ShowExplorerMenu(HWND hwnd, const QString &path, const QPoint &qpoint)
|
|||||||
// INPUT: pidl = Pointer to an item ID list.
|
// INPUT: pidl = Pointer to an item ID list.
|
||||||
// RETURNS: Number of item IDs in the list.
|
// RETURNS: Number of item IDs in the list.
|
||||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
static UINT GetItemCount (LPITEMIDLIST pidl)
|
static UINT GetItemCount(LPITEMIDLIST pidl)
|
||||||
{
|
{
|
||||||
USHORT nLen;
|
USHORT nLen;
|
||||||
UINT nCount;
|
UINT nCount;
|
||||||
|
|
||||||
nCount = 0;
|
nCount = 0;
|
||||||
while ((nLen = pidl->mkid.cb) != 0) {
|
while ((nLen = pidl->mkid.cb) != 0)
|
||||||
pidl = GetNextItem (pidl);
|
{
|
||||||
|
pidl = GetNextItem(pidl);
|
||||||
nCount++;
|
nCount++;
|
||||||
}
|
}
|
||||||
return nCount;
|
return nCount;
|
||||||
@ -174,7 +169,7 @@ bool ShowExplorerMenu(HWND hwnd, const QString &path, const QPoint &qpoint)
|
|||||||
// Failure to free the ITEMIDLIST will result in memory
|
// Failure to free the ITEMIDLIST will result in memory
|
||||||
// leaks.
|
// leaks.
|
||||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
static LPITEMIDLIST DuplicateItem (LPMALLOC pMalloc, LPITEMIDLIST pidl)
|
static LPITEMIDLIST DuplicateItem(LPMALLOC pMalloc, LPITEMIDLIST pidl)
|
||||||
{
|
{
|
||||||
USHORT nLen;
|
USHORT nLen;
|
||||||
LPITEMIDLIST pidlNew;
|
LPITEMIDLIST pidlNew;
|
||||||
@ -183,19 +178,17 @@ bool ShowExplorerMenu(HWND hwnd, const QString &path, const QPoint &qpoint)
|
|||||||
if (nLen == 0)
|
if (nLen == 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
pidlNew = (LPITEMIDLIST) pMalloc->Alloc (
|
pidlNew = (LPITEMIDLIST)pMalloc->Alloc(nLen + sizeof(USHORT));
|
||||||
nLen + sizeof (USHORT));
|
|
||||||
if (pidlNew == NULL)
|
if (pidlNew == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
CopyMemory (pidlNew, pidl, nLen);
|
CopyMemory(pidlNew, pidl, nLen);
|
||||||
*((USHORT*) (((LPBYTE) pidlNew) + nLen)) = 0;
|
*((USHORT *)(((LPBYTE)pidlNew) + nLen)) = 0;
|
||||||
|
|
||||||
return pidlNew;
|
return pidlNew;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
LPITEMIDLIST pidlMain, pidlItem, pidlNextItem, *ppidl;
|
LPITEMIDLIST pidlMain, pidlItem, pidlNextItem, *ppidl;
|
||||||
UINT nCount;
|
UINT nCount;
|
||||||
POINT point;
|
POINT point;
|
||||||
@ -204,7 +197,7 @@ bool ShowExplorerMenu(HWND hwnd, const QString &path, const QPoint &qpoint)
|
|||||||
|
|
||||||
WCHAR wchPath[MAX_PATH];
|
WCHAR wchPath[MAX_PATH];
|
||||||
memset(wchPath, 0, sizeof(wchPath));
|
memset(wchPath, 0, sizeof(wchPath));
|
||||||
Q_ASSERT(path.length()<MAX_PATH);
|
Q_ASSERT(path.length() < MAX_PATH);
|
||||||
path.toWCharArray(wchPath);
|
path.toWCharArray(wchPath);
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -214,11 +207,12 @@ bool ShowExplorerMenu(HWND hwnd, const QString &path, const QPoint &qpoint)
|
|||||||
bool bResult = false;
|
bool bResult = false;
|
||||||
|
|
||||||
LPMALLOC pMalloc;
|
LPMALLOC pMalloc;
|
||||||
if (!SUCCEEDED (SHGetMalloc (&pMalloc)))
|
if (!SUCCEEDED(SHGetMalloc(&pMalloc)))
|
||||||
return bResult;
|
return bResult;
|
||||||
|
|
||||||
LPSHELLFOLDER psfFolder;
|
LPSHELLFOLDER psfFolder;
|
||||||
if (!SUCCEEDED (SHGetDesktopFolder (&psfFolder))) {
|
if (!SUCCEEDED(SHGetDesktopFolder(&psfFolder)))
|
||||||
|
{
|
||||||
pMalloc->Release();
|
pMalloc->Release();
|
||||||
return bResult;
|
return bResult;
|
||||||
}
|
}
|
||||||
@ -227,10 +221,11 @@ bool ShowExplorerMenu(HWND hwnd, const QString &path, const QPoint &qpoint)
|
|||||||
// Convert the path name into a pointer to an item ID list (pidl).
|
// Convert the path name into a pointer to an item ID list (pidl).
|
||||||
//
|
//
|
||||||
ULONG ulCount, ulAttr;
|
ULONG ulCount, ulAttr;
|
||||||
if (SUCCEEDED (psfFolder->ParseDisplayName (hwnd,
|
if (SUCCEEDED(psfFolder->ParseDisplayName(hwnd, NULL, wchPath, &ulCount, &pidlMain, &ulAttr)) && (pidlMain != NULL))
|
||||||
NULL, wchPath, &ulCount, &pidlMain, &ulAttr)) && (pidlMain != NULL)) {
|
{
|
||||||
|
|
||||||
if ( (nCount = Util::GetItemCount (pidlMain))>0) { // nCount must be > 0
|
if ((nCount = Util::GetItemCount(pidlMain)) > 0)
|
||||||
|
{ // nCount must be > 0
|
||||||
//
|
//
|
||||||
// Initialize psfFolder with a pointer to the IShellFolder
|
// Initialize psfFolder with a pointer to the IShellFolder
|
||||||
// interface of the folder that contains the item whose context
|
// interface of the folder that contains the item whose context
|
||||||
@ -241,15 +236,17 @@ bool ShowExplorerMenu(HWND hwnd, const QString &path, const QPoint &qpoint)
|
|||||||
//
|
//
|
||||||
pidlItem = pidlMain;
|
pidlItem = pidlMain;
|
||||||
|
|
||||||
while (--nCount) {
|
while (--nCount)
|
||||||
|
{
|
||||||
//
|
//
|
||||||
// Create a 1-item item ID list for the next item in pidlMain.
|
// Create a 1-item item ID list for the next item in pidlMain.
|
||||||
//
|
//
|
||||||
pidlNextItem = Util::DuplicateItem (pMalloc, pidlItem);
|
pidlNextItem = Util::DuplicateItem(pMalloc, pidlItem);
|
||||||
if (pidlNextItem == NULL) {
|
if (pidlNextItem == NULL)
|
||||||
|
{
|
||||||
pMalloc->Free(pidlMain);
|
pMalloc->Free(pidlMain);
|
||||||
psfFolder->Release ();
|
psfFolder->Release();
|
||||||
pMalloc->Release ();
|
pMalloc->Release();
|
||||||
return bResult;
|
return bResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,12 +254,12 @@ bool ShowExplorerMenu(HWND hwnd, const QString &path, const QPoint &qpoint)
|
|||||||
// Bind to the folder specified in the new item ID list.
|
// Bind to the folder specified in the new item ID list.
|
||||||
//
|
//
|
||||||
LPSHELLFOLDER psfNextFolder;
|
LPSHELLFOLDER psfNextFolder;
|
||||||
if (!SUCCEEDED (psfFolder->BindToObject (
|
if (!SUCCEEDED(psfFolder->BindToObject(pidlNextItem, NULL, IID_IShellFolder, (void **)&psfNextFolder)))
|
||||||
pidlNextItem, NULL, IID_IShellFolder, (void**)&psfNextFolder))) {
|
{
|
||||||
pMalloc->Free (pidlNextItem);
|
pMalloc->Free(pidlNextItem);
|
||||||
pMalloc->Free (pidlMain);
|
pMalloc->Free(pidlMain);
|
||||||
psfFolder->Release ();
|
psfFolder->Release();
|
||||||
pMalloc->Release ();
|
pMalloc->Release();
|
||||||
return bResult;
|
return bResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,7 +268,7 @@ bool ShowExplorerMenu(HWND hwnd, const QString &path, const QPoint &qpoint)
|
|||||||
// and set psfFolder equal to the IShellFolder pointer for
|
// and set psfFolder equal to the IShellFolder pointer for
|
||||||
// the current folder.
|
// the current folder.
|
||||||
//
|
//
|
||||||
psfFolder->Release ();
|
psfFolder->Release();
|
||||||
psfFolder = psfNextFolder;
|
psfFolder = psfNextFolder;
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -280,7 +277,7 @@ bool ShowExplorerMenu(HWND hwnd, const QString &path, const QPoint &qpoint)
|
|||||||
// to the next item in pidlMain.
|
// to the next item in pidlMain.
|
||||||
//
|
//
|
||||||
pMalloc->Free(pidlNextItem);
|
pMalloc->Free(pidlNextItem);
|
||||||
pidlItem = Util::GetNextItem (pidlItem);
|
pidlItem = Util::GetNextItem(pidlItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -289,56 +286,51 @@ bool ShowExplorerMenu(HWND hwnd, const QString &path, const QPoint &qpoint)
|
|||||||
//
|
//
|
||||||
ppidl = &pidlItem;
|
ppidl = &pidlItem;
|
||||||
LPCONTEXTMENU pContextMenu;
|
LPCONTEXTMENU pContextMenu;
|
||||||
if (SUCCEEDED (psfFolder->GetUIObjectOf (
|
if (SUCCEEDED(psfFolder->GetUIObjectOf(hwnd, 1, (const ITEMIDLIST **)ppidl, IID_IContextMenu, NULL, (void **)&pContextMenu)))
|
||||||
hwnd, 1, (const ITEMIDLIST **)ppidl, IID_IContextMenu, NULL, (void**)&pContextMenu))) {
|
{
|
||||||
|
|
||||||
HMENU hMenu = CreatePopupMenu ();
|
|
||||||
if (SUCCEEDED (pContextMenu->QueryContextMenu (
|
|
||||||
hMenu, 0, 1, 0x7FFF, CMF_EXPLORE))) {
|
|
||||||
|
|
||||||
|
HMENU hMenu = CreatePopupMenu();
|
||||||
|
if (SUCCEEDED(pContextMenu->QueryContextMenu(hMenu, 0, 1, 0x7FFF, CMF_EXPLORE)))
|
||||||
|
{
|
||||||
|
|
||||||
//
|
//
|
||||||
// Display the context menu.
|
// Display the context menu.
|
||||||
//
|
//
|
||||||
UINT nCmd = TrackPopupMenu (hMenu, TPM_LEFTALIGN |
|
UINT nCmd = TrackPopupMenu(hMenu, TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RETURNCMD, point.x, point.y, 0, hwnd, NULL);
|
||||||
TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RETURNCMD,
|
|
||||||
point.x, point.y, 0, hwnd, NULL);
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// If a command was selected from the menu, execute it.
|
// If a command was selected from the menu, execute it.
|
||||||
//
|
//
|
||||||
if (nCmd) {
|
if (nCmd)
|
||||||
|
{
|
||||||
CMINVOKECOMMANDINFO ici;
|
CMINVOKECOMMANDINFO ici;
|
||||||
memset(&ici, 0, sizeof(ici) );
|
memset(&ici, 0, sizeof(ici));
|
||||||
ici.cbSize = sizeof (CMINVOKECOMMANDINFO);
|
ici.cbSize = sizeof(CMINVOKECOMMANDINFO);
|
||||||
ici.fMask = 0;
|
ici.fMask = 0;
|
||||||
ici.hwnd = hwnd;
|
ici.hwnd = hwnd;
|
||||||
ici.lpVerb = MAKEINTRESOURCEA (nCmd - 1);
|
ici.lpVerb = MAKEINTRESOURCEA(nCmd - 1);
|
||||||
ici.lpParameters = NULL;
|
ici.lpParameters = NULL;
|
||||||
ici.lpDirectory = NULL;
|
ici.lpDirectory = NULL;
|
||||||
ici.nShow = SW_SHOWNORMAL;
|
ici.nShow = SW_SHOWNORMAL;
|
||||||
ici.dwHotKey = 0;
|
ici.dwHotKey = 0;
|
||||||
ici.hIcon = NULL;
|
ici.hIcon = NULL;
|
||||||
|
|
||||||
if (SUCCEEDED (
|
if (SUCCEEDED(pContextMenu->InvokeCommand((CMINVOKECOMMANDINFO *)&ici)))
|
||||||
pContextMenu->InvokeCommand (
|
|
||||||
(CMINVOKECOMMANDINFO*)&ici)))
|
|
||||||
bResult = true;
|
bResult = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DestroyMenu (hMenu);
|
DestroyMenu(hMenu);
|
||||||
pContextMenu->Release ();
|
pContextMenu->Release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pMalloc->Free (pidlMain);
|
pMalloc->Free(pidlMain);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Clean up and return.
|
// Clean up and return.
|
||||||
//
|
//
|
||||||
psfFolder->Release ();
|
psfFolder->Release();
|
||||||
pMalloc->Release ();
|
pMalloc->Release();
|
||||||
|
|
||||||
return bResult;
|
return bResult;
|
||||||
}
|
}
|
||||||
@ -349,17 +341,17 @@ bool ShowExplorerMenu(HWND hwnd, const QString &path, const QPoint &qpoint)
|
|||||||
void ParseProperties(QStringMap &properties, const QStringList &lines, QChar separator)
|
void ParseProperties(QStringMap &properties, const QStringList &lines, QChar separator)
|
||||||
{
|
{
|
||||||
properties.clear();
|
properties.clear();
|
||||||
foreach(QString l, lines)
|
foreach (QString l, lines)
|
||||||
{
|
{
|
||||||
l = l.trimmed();
|
l = l.trimmed();
|
||||||
int index = l.indexOf(separator);
|
int index = l.indexOf(separator);
|
||||||
|
|
||||||
QString key;
|
QString key;
|
||||||
QString value;
|
QString value;
|
||||||
if(index!=-1)
|
if (index != -1)
|
||||||
{
|
{
|
||||||
key = l.left(index).trimmed();
|
key = l.left(index).trimmed();
|
||||||
value = l.mid(index+1).trimmed();
|
value = l.mid(index + 1).trimmed();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
key = l;
|
key = l;
|
||||||
@ -368,11 +360,10 @@ void ParseProperties(QStringMap &properties, const QStringList &lines, QChar sep
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void GetStandardItemTextRecursive(QString &name, const QStandardItem &item, const QChar &separator)
|
void GetStandardItemTextRecursive(QString &name, const QStandardItem &item, const QChar &separator)
|
||||||
{
|
{
|
||||||
if(item.parent())
|
if (item.parent())
|
||||||
{
|
{
|
||||||
GetStandardItemTextRecursive(name, *item.parent());
|
GetStandardItemTextRecursive(name, *item.parent());
|
||||||
name.append(separator);
|
name.append(separator);
|
||||||
@ -388,7 +379,7 @@ void BuildNameToModelIndex(name_modelindex_map_t &map, const QStandardItem &item
|
|||||||
GetStandardItemTextRecursive(name, item);
|
GetStandardItemTextRecursive(name, item);
|
||||||
map.insert(name, item.index());
|
map.insert(name, item.index());
|
||||||
|
|
||||||
for(int i=0; i<item.rowCount(); ++i)
|
for (int i = 0; i < item.rowCount(); ++i)
|
||||||
{
|
{
|
||||||
const QStandardItem *child = item.child(i);
|
const QStandardItem *child = item.child(i);
|
||||||
Q_ASSERT(child);
|
Q_ASSERT(child);
|
||||||
@ -399,7 +390,7 @@ 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)
|
||||||
{
|
{
|
||||||
for(int i=0; i<model.rowCount(); ++i)
|
for (int i = 0; i < model.rowCount(); ++i)
|
||||||
{
|
{
|
||||||
const QStandardItem *item = model.item(i);
|
const QStandardItem *item = model.item(i);
|
||||||
Q_ASSERT(item);
|
Q_ASSERT(item);
|
||||||
@ -420,8 +411,8 @@ bool KeychainSet(QObject *parent, const QUrl &url, QSettings &settings)
|
|||||||
Q_UNUSED(settings)
|
Q_UNUSED(settings)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
job.connect( &job, SIGNAL(finished(QKeychain::Job*)), &loop, SLOT(quit()) );
|
job.connect(&job, SIGNAL(finished(QKeychain::Job *)), &loop, SLOT(quit()));
|
||||||
job.setAutoDelete( false );
|
job.setAutoDelete(false);
|
||||||
job.setInsecureFallback(false);
|
job.setInsecureFallback(false);
|
||||||
job.setKey(url.userName());
|
job.setKey(url.userName());
|
||||||
job.setTextData(url.password());
|
job.setTextData(url.password());
|
||||||
@ -448,10 +439,10 @@ bool KeychainGet(QObject *parent, QUrl &url, QSettings &settings)
|
|||||||
Q_UNUSED(settings)
|
Q_UNUSED(settings)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
job.connect( &job, SIGNAL(finished(QKeychain::Job*)), &loop, SLOT(quit()));
|
job.connect(&job, SIGNAL(finished(QKeychain::Job *)), &loop, SLOT(quit()));
|
||||||
job.setAutoDelete( false );
|
job.setAutoDelete(false);
|
||||||
job.setInsecureFallback(false);
|
job.setInsecureFallback(false);
|
||||||
job.setAutoDelete( false );
|
job.setAutoDelete(false);
|
||||||
job.setKey(url.userName());
|
job.setKey(url.userName());
|
||||||
job.start();
|
job.start();
|
||||||
loop.exec();
|
loop.exec();
|
||||||
@ -460,7 +451,7 @@ bool KeychainGet(QObject *parent, QUrl &url, QSettings &settings)
|
|||||||
settings.endGroup();
|
settings.endGroup();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(job.error() != QKeychain::NoError)
|
if (job.error() != QKeychain::NoError)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
url.setUserName(job.key());
|
url.setUserName(job.key());
|
||||||
@ -469,7 +460,7 @@ 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)
|
||||||
{
|
{
|
||||||
QEventLoop loop(parent);
|
QEventLoop loop(parent);
|
||||||
QKeychain::DeletePasswordJob job(UrlToStringNoCredentials(url));
|
QKeychain::DeletePasswordJob job(UrlToStringNoCredentials(url));
|
||||||
@ -481,10 +472,10 @@ bool KeychainDelete(QObject* parent, const QUrl& url, QSettings &settings)
|
|||||||
Q_UNUSED(settings)
|
Q_UNUSED(settings)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
job.connect( &job, SIGNAL(finished(QKeychain::Job*)), &loop, SLOT(quit()));
|
job.connect(&job, SIGNAL(finished(QKeychain::Job *)), &loop, SLOT(quit()));
|
||||||
job.setAutoDelete( false );
|
job.setAutoDelete(false);
|
||||||
job.setInsecureFallback(false);
|
job.setInsecureFallback(false);
|
||||||
job.setAutoDelete( false );
|
job.setAutoDelete(false);
|
||||||
job.setKey(url.userName());
|
job.setKey(url.userName());
|
||||||
job.start();
|
job.start();
|
||||||
loop.exec();
|
loop.exec();
|
||||||
@ -497,7 +488,7 @@ bool KeychainDelete(QObject* parent, const QUrl& url, QSettings &settings)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
QString HashString(const QString& str)
|
QString HashString(const QString &str)
|
||||||
{
|
{
|
||||||
QCryptographicHash hash(QCryptographicHash::Sha1);
|
QCryptographicHash hash(QCryptographicHash::Sha1);
|
||||||
const QByteArray ba(str.toUtf8());
|
const QByteArray ba(str.toUtf8());
|
||||||
@ -507,7 +498,7 @@ QString HashString(const QString& str)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
QString UrlToStringDisplay(const QUrl& url)
|
QString UrlToStringDisplay(const QUrl &url)
|
||||||
{
|
{
|
||||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
|
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
|
||||||
return url.toString(QUrl::RemovePassword);
|
return url.toString(QUrl::RemovePassword);
|
||||||
@ -517,12 +508,12 @@ QString UrlToStringDisplay(const QUrl& url)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
QString UrlToStringNoCredentials(const QUrl& url)
|
QString UrlToStringNoCredentials(const QUrl &url)
|
||||||
{
|
{
|
||||||
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
|
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
|
||||||
return url.toString(QUrl::RemoveUserInfo);
|
return url.toString(QUrl::RemoveUserInfo);
|
||||||
#else
|
#else
|
||||||
return url.toString(QUrl::PrettyDecoded|QUrl::RemoveUserInfo);
|
return url.toString(QUrl::PrettyDecoded | QUrl::RemoveUserInfo);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -532,9 +523,9 @@ QString UrlToString(const QUrl &url)
|
|||||||
{
|
{
|
||||||
QString username = url.userName();
|
QString username = url.userName();
|
||||||
// QUrl generates bad local file url for Windows local paths with drive letters
|
// QUrl generates bad local file url for Windows local paths with drive letters
|
||||||
if(url.isLocalFile())
|
if (url.isLocalFile())
|
||||||
return url.toLocalFile();
|
return url.toLocalFile();
|
||||||
else if(username.isEmpty()) // QUrl generates an invalid url like http://@host.domain/path
|
else if (username.isEmpty()) // QUrl generates an invalid url like http://@host.domain/path
|
||||||
return UrlToStringNoCredentials(url);
|
return UrlToStringNoCredentials(url);
|
||||||
else
|
else
|
||||||
return url.toEncoded();
|
return url.toEncoded();
|
||||||
@ -557,7 +548,7 @@ void SplitCommandLine(const QString &commandLine, QString &command, QString &ext
|
|||||||
int backtrack = 0;
|
int backtrack = 0;
|
||||||
|
|
||||||
// ...unless it is a quoted command
|
// ...unless it is a quoted command
|
||||||
if(command[0]=='"')
|
if (command[0] == '"')
|
||||||
{
|
{
|
||||||
cmd_char_end = '"';
|
cmd_char_end = '"';
|
||||||
cmd_start = 1;
|
cmd_start = 1;
|
||||||
@ -565,10 +556,10 @@ void SplitCommandLine(const QString &commandLine, QString &command, QString &ext
|
|||||||
}
|
}
|
||||||
|
|
||||||
int cmd_end = command.indexOf(cmd_char_end, cmd_start);
|
int cmd_end = command.indexOf(cmd_char_end, cmd_start);
|
||||||
if(cmd_end > 0)
|
if (cmd_end > 0)
|
||||||
{
|
{
|
||||||
extraParams = command.mid(cmd_end+1);
|
extraParams = command.mid(cmd_end + 1);
|
||||||
command = command.mid(cmd_start, cmd_end-backtrack);
|
command = command.mid(cmd_start, cmd_end - backtrack);
|
||||||
}
|
}
|
||||||
|
|
||||||
command = command.trimmed();
|
command = command.trimmed();
|
||||||
@ -576,11 +567,11 @@ void SplitCommandLine(const QString &commandLine, QString &command, QString &ext
|
|||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
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)
|
||||||
{
|
{
|
||||||
static const char* MACRO_FILE = "%FILE";
|
static const char *MACRO_FILE = "%FILE";
|
||||||
static const char* MACRO_FOLDER = "%FOLDER";
|
static const char *MACRO_FOLDER = "%FOLDER";
|
||||||
static const char* MACRO_WORKSPACE = "%WORKSPACE";
|
static const char *MACRO_WORKSPACE = "%WORKSPACE";
|
||||||
|
|
||||||
QStringList params;
|
QStringList params;
|
||||||
|
|
||||||
@ -591,23 +582,23 @@ bool SpawnExternalProcess(QObject *processParent, const QString& command, const
|
|||||||
QString macro_file;
|
QString macro_file;
|
||||||
QString macro_folder;
|
QString macro_folder;
|
||||||
|
|
||||||
if(!extra_params.isEmpty())
|
if (!extra_params.isEmpty())
|
||||||
{
|
{
|
||||||
QStringList extra_param_list = extra_params.split(' ');
|
QStringList extra_param_list = extra_params.split(' ');
|
||||||
|
|
||||||
foreach(const QString &p, extra_param_list)
|
foreach (const QString &p, extra_param_list)
|
||||||
{
|
{
|
||||||
if(p.indexOf(MACRO_FILE)!=-1)
|
if (p.indexOf(MACRO_FILE) != -1)
|
||||||
{
|
{
|
||||||
macro_file = p;
|
macro_file = p;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if(p.indexOf(MACRO_FOLDER)!=-1)
|
else if (p.indexOf(MACRO_FOLDER) != -1)
|
||||||
{
|
{
|
||||||
macro_folder = p;
|
macro_folder = p;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if(p.indexOf(MACRO_WORKSPACE)!=-1)
|
else if (p.indexOf(MACRO_WORKSPACE) != -1)
|
||||||
{
|
{
|
||||||
// Add in-place
|
// Add in-place
|
||||||
QString n = p;
|
QString n = p;
|
||||||
@ -621,9 +612,9 @@ bool SpawnExternalProcess(QObject *processParent, const QString& command, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build file params
|
// Build file params
|
||||||
if(!macro_file.isEmpty())
|
if (!macro_file.isEmpty())
|
||||||
{
|
{
|
||||||
foreach(const QString &f, fileList)
|
foreach (const QString &f, fileList)
|
||||||
{
|
{
|
||||||
QString path = QDir::toNativeSeparators(QFileInfo(workspaceDir + PATH_SEPARATOR + f).absoluteFilePath());
|
QString path = QDir::toNativeSeparators(QFileInfo(workspaceDir + PATH_SEPARATOR + f).absoluteFilePath());
|
||||||
|
|
||||||
@ -634,9 +625,9 @@ bool SpawnExternalProcess(QObject *processParent, const QString& command, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build folder params
|
// Build folder params
|
||||||
if(!macro_folder.isEmpty())
|
if (!macro_folder.isEmpty())
|
||||||
{
|
{
|
||||||
foreach(const QString &f, pathSet)
|
foreach (const QString &f, pathSet)
|
||||||
{
|
{
|
||||||
QString path = QDir::toNativeSeparators(QFileInfo(workspaceDir + PATH_SEPARATOR + f).absoluteFilePath());
|
QString path = QDir::toNativeSeparators(QFileInfo(workspaceDir + PATH_SEPARATOR + f).absoluteFilePath());
|
||||||
|
|
||||||
@ -646,15 +637,15 @@ bool SpawnExternalProcess(QObject *processParent, const QString& command, const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uiCallback.logText("<b>"+cmd + " "+params.join(" ")+"</b><br>", true);
|
uiCallback.logText("<b>" + cmd + " " + params.join(" ") + "</b><br>", true);
|
||||||
|
|
||||||
QProcess proc(processParent);
|
QProcess proc(processParent);
|
||||||
return proc.startDetached(cmd, params);
|
return proc.startDetached(cmd, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
void TrimStringList(QStringList& list)
|
void TrimStringList(QStringList &list)
|
||||||
{
|
{
|
||||||
for(int i=0; i<list.length(); ++i)
|
for (int i = 0; i < list.length(); ++i)
|
||||||
list[i] = list[i].trimmed();
|
list[i] = list[i].trimmed();
|
||||||
}
|
}
|
||||||
|
52
src/Utils.h
52
src/Utils.h
@ -1,14 +1,14 @@
|
|||||||
#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"
|
||||||
@ -16,63 +16,53 @@
|
|||||||
|
|
||||||
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,11 +1,9 @@
|
|||||||
#include "Workspace.h"
|
#include "Workspace.h"
|
||||||
#include <QCoreApplication>
|
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
#include <QCoreApplication>
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
Workspace::Workspace()
|
Workspace::Workspace() {}
|
||||||
{
|
|
||||||
}
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
Workspace::~Workspace()
|
Workspace::~Workspace()
|
||||||
{
|
{
|
||||||
@ -17,7 +15,7 @@ Workspace::~Workspace()
|
|||||||
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();
|
||||||
@ -33,7 +31,7 @@ void Workspace::clearState()
|
|||||||
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");
|
||||||
@ -41,25 +39,24 @@ void Workspace::storeWorkspace(QSettings &store)
|
|||||||
|
|
||||||
store.beginWriteArray(workspace_hash);
|
store.beginWriteArray(workspace_hash);
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for(remote_map_t::iterator it=remotes.begin(); it!=remotes.end(); ++it, ++index)
|
for (remote_map_t::iterator it = remotes.begin(); it != remotes.end(); ++it, ++index)
|
||||||
{
|
{
|
||||||
store.setArrayIndex(index);
|
store.setArrayIndex(index);
|
||||||
store.setValue("Name", it->name);
|
store.setValue("Name", it->name);
|
||||||
QUrl url = it->url;
|
QUrl url = it->url;
|
||||||
url.setPassword("");
|
url.setPassword("");
|
||||||
store.setValue("Url", url);
|
store.setValue("Url", url);
|
||||||
if(it->isDefault)
|
if (it->isDefault)
|
||||||
store.setValue("Default", it->isDefault);
|
store.setValue("Default", it->isDefault);
|
||||||
else
|
else
|
||||||
store.remove("Default");
|
store.remove("Default");
|
||||||
}
|
}
|
||||||
store.endArray();
|
store.endArray();
|
||||||
store.endGroup();
|
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);
|
||||||
@ -67,12 +64,12 @@ bool Workspace::switchWorkspace(const QString& workspace, QSettings &store)
|
|||||||
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);
|
||||||
@ -85,7 +82,7 @@ bool Workspace::switchWorkspace(const QString& workspace, QSettings &store)
|
|||||||
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);
|
||||||
|
|
||||||
@ -93,7 +90,7 @@ bool Workspace::switchWorkspace(const QString& workspace, QSettings &store)
|
|||||||
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();
|
||||||
@ -120,30 +117,30 @@ bool Workspace::switchWorkspace(const QString& workspace, QSettings &store)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
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
|
||||||
@ -165,12 +162,12 @@ void Workspace::scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModifie
|
|||||||
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;
|
||||||
@ -180,24 +177,24 @@ void Workspace::scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModifie
|
|||||||
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;
|
||||||
@ -209,7 +206,7 @@ void Workspace::scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModifie
|
|||||||
|
|
||||||
// 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
|
||||||
{
|
{
|
||||||
@ -223,14 +220,14 @@ void Workspace::scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModifie
|
|||||||
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);
|
||||||
@ -241,32 +238,31 @@ void Workspace::scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModifie
|
|||||||
// 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;
|
||||||
@ -277,17 +273,17 @@ void Workspace::scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModifie
|
|||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,7 +294,7 @@ void Workspace::scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModifie
|
|||||||
|
|
||||||
// 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
|
||||||
{
|
{
|
||||||
@ -309,7 +305,7 @@ void Workspace::scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModifie
|
|||||||
|
|
||||||
// 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());
|
||||||
@ -317,18 +313,18 @@ void Workspace::scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModifie
|
|||||||
|
|
||||||
// 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);
|
||||||
@ -339,9 +335,9 @@ void Workspace::scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModifie
|
|||||||
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;
|
||||||
@ -356,7 +352,7 @@ void Workspace::scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModifie
|
|||||||
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:
|
||||||
@ -364,9 +360,9 @@ _done:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
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());
|
||||||
@ -377,22 +373,22 @@ bool Workspace::addRemote(const QUrl& url, const QString& name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
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;
|
||||||
@ -406,9 +402,9 @@ bool Workspace::setRemoteDefault(const QUrl& url)
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -416,11 +412,10 @@ QUrl Workspace::getRemoteDefault() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
165
src/Workspace.h
165
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
|
||||||
@ -22,12 +22,12 @@ public:
|
|||||||
|
|
||||||
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; }
|
||||||
@ -47,158 +47,77 @@ public:
|
|||||||
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;
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
#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
|
||||||
@ -25,18 +25,18 @@ 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)
|
||||||
@ -47,44 +47,23 @@ struct WorkspaceFile
|
|||||||
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)
|
||||||
{
|
{
|
||||||
@ -92,10 +71,10 @@ struct WorkspaceFile
|
|||||||
|
|
||||||
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:
|
||||||
@ -108,22 +87,17 @@ private:
|
|||||||
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;
|
QString name;
|
||||||
QUrl url;
|
QUrl url;
|
||||||
bool isDefault;
|
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
|
||||||
|
20
src/main.cpp
20
src/main.cpp
@ -1,5 +1,5 @@
|
|||||||
#include <QApplication>
|
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -9,23 +9,22 @@ int main(int argc, char *argv[])
|
|||||||
app.setOrganizationDomain("fuel-scm.org");
|
app.setOrganizationDomain("fuel-scm.org");
|
||||||
app.setOrganizationName("Fuel-SCM");
|
app.setOrganizationName("Fuel-SCM");
|
||||||
|
|
||||||
|
#ifdef Q_OS_MACX
|
||||||
#ifdef Q_OS_MACX
|
|
||||||
// Native OSX applications don't have menu icons
|
// Native OSX applications don't have menu icons
|
||||||
app.setAttribute(Qt::AA_DontShowIconsInMenus);
|
app.setAttribute(Qt::AA_DontShowIconsInMenus);
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
bool portable = false;
|
bool portable = false;
|
||||||
QString workspace;
|
QString workspace;
|
||||||
|
|
||||||
Q_ASSERT(app.arguments().size()>0);
|
Q_ASSERT(app.arguments().size() > 0);
|
||||||
for(int i=1; i<app.arguments().size(); ++i)
|
for (int i = 1; i < app.arguments().size(); ++i)
|
||||||
{
|
{
|
||||||
QString arg = app.arguments()[i];
|
QString arg = app.arguments()[i];
|
||||||
// Parse options
|
// Parse options
|
||||||
if(arg.indexOf("--")!=-1)
|
if (arg.indexOf("--") != -1)
|
||||||
{
|
{
|
||||||
if(arg.indexOf("portable")!=-1)
|
if (arg.indexOf("portable") != -1)
|
||||||
portable = true;
|
portable = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -35,12 +34,9 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
Settings settings(portable);
|
Settings settings(portable);
|
||||||
|
|
||||||
MainWindow mainwin(settings,
|
MainWindow mainwin(settings, 0, workspace.isEmpty() ? 0 : &workspace);
|
||||||
0,
|
|
||||||
workspace.isEmpty() ? 0 : &workspace);
|
|
||||||
mainwin.show();
|
mainwin.show();
|
||||||
mainwin.fullRefresh();
|
mainwin.fullRefresh();
|
||||||
return app.exec();
|
return app.exec();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user