Commit 00a3b537 authored by hjk's avatar hjk
Browse files

Merge branch 'master' of git@scm.dev.nokia.troll.no:creator/mainline

parents 220cf0d2 4db2f998
......@@ -98,12 +98,12 @@ static void displayError(const QString &t) // No console on Windows.
static void displayHelpText(const QString &t)
{
qWarning(t.toUtf8().constData());
qWarning("%s", qPrintable(t));
}
static void displayError(const QString &t)
{
qCritical(t.toUtf8().constData());
qCritical("%s", qPrintable(t));
}
#endif
......
......@@ -99,7 +99,7 @@ QString CMakeBuildStepConfigWidget::displayName() const
return "CMake";
}
void CMakeBuildStepConfigWidget::init(const QString &buildConfiguration)
void CMakeBuildStepConfigWidget::init(const QString & /*buildConfiguration */)
{
// TODO
}
......@@ -121,12 +121,12 @@ ProjectExplorer::BuildStep *CMakeBuildStepFactory::create(ProjectExplorer::Proje
return new CMakeStep(pro);
}
QStringList CMakeBuildStepFactory::canCreateForProject(ProjectExplorer::Project *pro) const
QStringList CMakeBuildStepFactory::canCreateForProject(ProjectExplorer::Project * /* pro */) const
{
return QStringList();
}
QString CMakeBuildStepFactory::displayNameForName(const QString &name) const
QString CMakeBuildStepFactory::displayNameForName(const QString & /* name */) const
{
return "CMake";
}
......
......@@ -93,7 +93,7 @@ QString MakeBuildStepConfigWidget::displayName() const
return "Make";
}
void MakeBuildStepConfigWidget::init(const QString &buildConfiguration)
void MakeBuildStepConfigWidget::init(const QString & /* buildConfiguration */)
{
// TODO
}
......@@ -115,12 +115,12 @@ ProjectExplorer::BuildStep *MakeBuildStepFactory::create(ProjectExplorer::Projec
return new MakeStep(pro);
}
QStringList MakeBuildStepFactory::canCreateForProject(ProjectExplorer::Project *pro) const
QStringList MakeBuildStepFactory::canCreateForProject(ProjectExplorer::Project * /* pro */) const
{
return QStringList();
}
QString MakeBuildStepFactory::displayNameForName(const QString &name) const
QString MakeBuildStepFactory::displayNameForName(const QString & /* name */) const
{
return "Make";
}
......
......@@ -49,12 +49,12 @@ QKeySequence INavigationWidgetFactory::activationSequence()
}
void INavigationWidgetFactory::saveSettings(int position, QWidget *widget)
void INavigationWidgetFactory::saveSettings(int /* position */, QWidget * /* widget */)
{
}
void INavigationWidgetFactory::restoreSettings(int position, QWidget *widget)
void INavigationWidgetFactory::restoreSettings(int /* position */, QWidget * /* widget */)
{
}
......@@ -62,8 +62,15 @@ bool FormClassWizardParameters::generateCpp(QString *header, QString *source, in
return false;
}
// Build the ui class (Ui::Foo) name relative to the namespace (which is the same):
const QString colonColon = QLatin1String("::");
const int lastSeparator = uiClassName.lastIndexOf(colonColon);
if (lastSeparator != -1)
uiClassName.remove(0, lastSeparator + colonColon.size());
uiClassName.insert(0, QLatin1String(uiNamespaceC) + colonColon);
// Do we have namespaces?
QStringList namespaceList = className.split(QLatin1String("::"));
QStringList namespaceList = className.split(colonColon);
if (namespaceList.empty()) // Paranoia!
return false;
......@@ -94,18 +101,21 @@ bool FormClassWizardParameters::generateCpp(QString *header, QString *source, in
}
}
const QString namespaceIndent = Core::Utils::writeOpeningNameSpaces(namespaceList, indent, headerStr);
// Forward-declare the UI class
if (embedding == PointerAggregatedUiClass) {
headerStr << "\nnamespace " << uiNamespaceC << " {\n"
<< indent << "class " << uiClassName << ";\n}\n";
headerStr << '\n'
<< namespaceIndent << "namespace " << uiNamespaceC << " {\n"
<< namespaceIndent << indent << "class " << FormTemplateWizardPagePage::stripNamespaces(uiClassName) << ";\n"
<< namespaceIndent << "}\n";
}
const QString namespaceIndent = Core::Utils::writeOpeningNameSpaces(namespaceList, indent, headerStr);
// Class declaration
headerStr << '\n' << namespaceIndent << "class " << unqualifiedClassName
<< " : public " << formBaseClass;
if (embedding == InheritedUiClass) {
headerStr << ", private " << uiNamespaceC << "::" << uiClassName;
headerStr << ", private " << uiClassName;
}
headerStr << " {\n" << namespaceIndent << indent << "Q_OBJECT\n"
<< namespaceIndent << indent << "Q_DISABLE_COPY(" << unqualifiedClassName << ")\n"
......@@ -120,7 +130,7 @@ bool FormClassWizardParameters::generateCpp(QString *header, QString *source, in
// Member variable
if (embedding != InheritedUiClass) {
headerStr << '\n' << namespaceIndent << "private:\n"
<< namespaceIndent << indent << uiNamespaceC << "::" << uiClassName << ' ';
<< namespaceIndent << indent << uiClassName << ' ';
if (embedding == PointerAggregatedUiClass)
headerStr << '*';
headerStr << uiMemberC << ";\n";
......@@ -140,7 +150,7 @@ bool FormClassWizardParameters::generateCpp(QString *header, QString *source, in
sourceStr << '\n' << namespaceIndent << unqualifiedClassName << "::" << unqualifiedClassName << "(QWidget *parent) :\n"
<< namespaceIndent << indent << formBaseClass << "(parent)";
if (embedding == PointerAggregatedUiClass)
sourceStr << ",\n" << namespaceIndent << indent << uiMemberC << "(new " << uiNamespaceC << "::" << uiClassName << ")\n";
sourceStr << ",\n" << namespaceIndent << indent << uiMemberC << "(new " << uiClassName << ")\n";
sourceStr << namespaceIndent << "{\n" << namespaceIndent << indent;
if (embedding != InheritedUiClass)
sourceStr << uiMemberC << (embedding == PointerAggregatedUiClass ? "->" : ".");
......
......@@ -379,6 +379,23 @@ bool GitClient::synchronousCheckout(const QString &workingDirectory,
return true;
}
bool GitClient::synchronousStash(const QString &workingDirectory, QString *errorMessage)
{
if (Git::Constants::debug)
qDebug() << Q_FUNC_INFO << workingDirectory;
QByteArray outputText;
QByteArray errorText;
QStringList arguments;
arguments << QLatin1String("stash");
const bool rc = synchronousGit(workingDirectory, arguments, &outputText, &errorText);
if (!rc) {
*errorMessage = tr("Unable stash in %1: %2").arg(workingDirectory, QString::fromLocal8Bit(errorText));
return false;
}
return true;
}
void GitClient::executeGit(const QString &workingDirectory, const QStringList &arguments,
VCSBase::VCSBaseEditor* editor,
bool outputToWindow)
......@@ -467,6 +484,60 @@ bool GitClient::synchronousGit(const QString &workingDirectory,
return process.exitCode() == 0;
}
static inline int
askWithDetailedText(QWidget *parent,
const QString &title, const QString &msg,
const QString &inf,
QMessageBox::StandardButton defaultButton,
QMessageBox::StandardButtons buttons = QMessageBox::Yes|QMessageBox::No)
{
QMessageBox msgBox(QMessageBox::Question, title, msg, buttons, parent);
msgBox.setDetailedText(inf);
msgBox.setDefaultButton(defaultButton);
return msgBox.exec();
}
// Convenience that pops up an msg box.
GitClient::StashResult GitClient::ensureStash(const QString &workingDirectory)
{
QString errorMessage;
const StashResult sr = ensureStash(workingDirectory, &errorMessage);
if (sr == StashFailed) {
m_plugin->outputWindow()->append(errorMessage);
m_plugin->outputWindow()->popup();
}
return sr;
}
// Ensure that changed files are stashed before a pull or similar
GitClient::StashResult GitClient::ensureStash(const QString &workingDirectory, QString *errorMessage)
{
QString statusOutput;
switch (gitStatus(workingDirectory, false, &statusOutput, errorMessage)) {
case StatusChanged:
break;
case StatusUnchanged:
return StashUnchanged;
case StatusFailed:
return StashFailed;
}
const int answer = askWithDetailedText(m_core->mainWindow(), tr("Changes"),
tr("You have modified files. Would you like to stash your changes?"),
statusOutput, QMessageBox::Yes, QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel);
switch (answer) {
case QMessageBox::Cancel:
return StashCanceled;
case QMessageBox::Yes:
if (!synchronousStash(workingDirectory, errorMessage))
return StashFailed;
break;
case QMessageBox::No: // At your own risk, so.
return NotStashed;
}
return Stashed;
}
// Trim a git status file spec: "modified: foo .cpp" -> "modified: foo .cpp"
static inline QString trimFileSpecification(QString fileSpec)
......@@ -476,7 +547,7 @@ static inline QString trimFileSpecification(QString fileSpec)
// Collapse the sequence of spaces
const int filePos = colonIndex + 2;
int nonBlankPos = filePos;
for ( ; fileSpec.at(nonBlankPos).isSpace(); nonBlankPos++);
for ( ; fileSpec.at(nonBlankPos).isSpace(); nonBlankPos++) ;
if (nonBlankPos > filePos)
fileSpec.remove(filePos, nonBlankPos - filePos);
}
......@@ -703,18 +774,6 @@ bool GitClient::addAndCommit(const QString &repositoryDirectory,
return rc;
}
static inline bool askWithInformativeText(QWidget *parent,
const QString &title,
const QString &msg,
const QString &inf,
bool defaultValue)
{
QMessageBox msgBox(QMessageBox::Question, title, msg, QMessageBox::Yes|QMessageBox::No, parent);
msgBox.setInformativeText(inf);
msgBox.setDefaultButton(defaultValue ? QMessageBox::Yes : QMessageBox::No);
return msgBox.exec() == QMessageBox::Yes;
}
/* Revert: This function can be called with a file list (to revert single
* files) or a single directory (revert all). Qt Creator currently has only
* 'revert single' in its VCS menus, but the code is prepared to deal with
......
......@@ -92,6 +92,7 @@ public:
bool synchronousReset(const QString &workingDirectory, const QStringList &files);
bool synchronousReset(const QString &workingDirectory, const QStringList &files, QString *errorMessage);
bool synchronousCheckout(const QString &workingDirectory, const QStringList &files, QString *errorMessage);
bool synchronousStash(const QString &workingDirectory, QString *errorMessage);
void pull(const QString &workingDirectory);
void push(const QString &workingDirectory);
......@@ -105,6 +106,11 @@ public:
QString readConfigValue(const QString &workingDirectory, const QString &configVar);
enum StashResult { StashUnchanged, StashCanceled, StashFailed,
Stashed, NotStashed /* User did not want it */ };
StashResult ensureStash(const QString &workingDirectory, QString *errorMessage);
StashResult ensureStash(const QString &workingDirectory);
bool getCommitData(const QString &workingDirectory,
QString *commitTemplate,
CommitData *d,
......@@ -118,7 +124,7 @@ public:
enum StatusResult { StatusChanged, StatusUnchanged, StatusFailed };
StatusResult gitStatus(const QString &workingDirectory,
bool untracked,
bool untracked = false,
QString *output = 0,
QString *errorMessage = 0);
......
......@@ -703,8 +703,17 @@ bool GitPlugin::editorAboutToClose(Core::IEditor *iEditor)
void GitPlugin::pull()
{
const QString workingDirectory = getWorkingDirectory();
if (!workingDirectory.isEmpty())
m_gitClient->pull(workingDirectory);
if (workingDirectory.isEmpty())
return;
switch (m_gitClient->ensureStash(workingDirectory)) {
case GitClient::StashUnchanged:
case GitClient::Stashed:
case GitClient::NotStashed:
m_gitClient->pull(workingDirectory);
default:
break;
}
}
void GitPlugin::push()
......
......@@ -97,6 +97,7 @@ public:
GitOutputWindow *outputWindow() const;
GitSettings settings() const;
void setSettings(const GitSettings &s);
......
......@@ -151,7 +151,7 @@ QString PerforceEditor::fileNameFromDiffSpecification(const QTextBlock &inBlock)
// Ask plugin to map back
const QString fileName = m_plugin->fileNameFromPerforceName(diffFileName.trimmed(), &errorMessage);
if (fileName.isEmpty())
qWarning(errorMessage.toUtf8().constData());
qWarning("%s", qPrintable(errorMessage));
return fileName;
}
}
......
......@@ -207,7 +207,8 @@ int FileWatcher::m_objectCount = 0;
QHash<QString,int> FileWatcher::m_fileCount;
QFileSystemWatcher *FileWatcher::m_watcher = 0;
FileWatcher::FileWatcher(QObject *parent)
FileWatcher::FileWatcher(QObject *parent) :
QObject(parent)
{
if (!m_watcher)
m_watcher = new QFileSystemWatcher();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment