Fixes: Console wizard has finalPage set, wrong options for wizard, quieten p4 when quering the project directory

This commit is contained in:
Friedemann Kleint
2008-12-04 16:24:15 +01:00
parent 5f17e0b206
commit f59964d19c
4 changed files with 55 additions and 41 deletions

View File

@@ -405,17 +405,17 @@ void PerforcePlugin::extensionsInitialized()
void PerforcePlugin::openCurrentFile() void PerforcePlugin::openCurrentFile()
{ {
runP4Cmd(QStringList() << QLatin1String("edit") << currentFileName(), QStringList(), true); vcsOpen(currentFileName());
} }
void PerforcePlugin::addCurrentFile() void PerforcePlugin::addCurrentFile()
{ {
runP4Cmd(QStringList() << QLatin1String("add") << currentFileName(), QStringList(), true); vcsAdd(currentFileName());
} }
void PerforcePlugin::deleteCurrentFile() void PerforcePlugin::deleteCurrentFile()
{ {
runP4Cmd(QStringList() << QLatin1String("delete") << currentFileName(), QStringList(), true); vcsDelete(currentFileName());
} }
void PerforcePlugin::revertCurrentFile() void PerforcePlugin::revertCurrentFile()
@@ -426,7 +426,7 @@ void PerforcePlugin::revertCurrentFile()
QTextCodec *codec = VCSBase::VCSBaseEditor::getCodec(m_coreInstance, fileName); QTextCodec *codec = VCSBase::VCSBaseEditor::getCodec(m_coreInstance, fileName);
QStringList args; QStringList args;
args << QLatin1String("diff") << QLatin1String("-sa"); args << QLatin1String("diff") << QLatin1String("-sa");
PerforceResponse result = runP4Cmd(args, QStringList(), false, true, codec); PerforceResponse result = runP4Cmd(args, QStringList(), CommandToWindow|StdErrToWindow|ErrorToWindow, codec);
if (result.error) if (result.error)
return; return;
@@ -444,7 +444,7 @@ void PerforcePlugin::revertCurrentFile()
foreach (Core::IFile *file, files) { foreach (Core::IFile *file, files) {
fm->blockFileChange(file); fm->blockFileChange(file);
} }
PerforceResponse result2 = runP4Cmd(QStringList() << QLatin1String("revert") << fileName, QStringList(), true); PerforceResponse result2 = runP4Cmd(QStringList() << QLatin1String("revert") << fileName, QStringList(), CommandToWindow|StdOutToWindow|StdErrToWindow|ErrorToWindow);
Core::IFile::ReloadBehavior tempBehavior = Core::IFile::ReloadBehavior tempBehavior =
Core::IFile::ReloadAll; Core::IFile::ReloadAll;
foreach (Core::IFile *file, files) { foreach (Core::IFile *file, files) {
@@ -489,7 +489,7 @@ void PerforcePlugin::printOpenedFileList()
Core::IEditor *e = m_coreInstance->editorManager()->currentEditor(); Core::IEditor *e = m_coreInstance->editorManager()->currentEditor();
if (e) if (e)
e->widget()->setFocus(); e->widget()->setFocus();
PerforceResponse result = runP4Cmd(QStringList() << QLatin1String("opened"), QStringList(), true); PerforceResponse result = runP4Cmd(QStringList() << QLatin1String("opened"), QStringList(), CommandToWindow|StdOutToWindow|StdErrToWindow|ErrorToWindow);
} }
#ifdef USE_P4_API #ifdef USE_P4_API
@@ -522,7 +522,8 @@ void PerforcePlugin::submit()
return; return;
} }
PerforceResponse result = runP4Cmd(QStringList()<< QLatin1String("change") << QLatin1String("-o"), QStringList(), false); PerforceResponse result = runP4Cmd(QStringList()<< QLatin1String("change") << QLatin1String("-o"), QStringList(),
CommandToWindow|StdErrToWindow|ErrorToWindow);
if (result.error) { if (result.error) {
delete m_changeTmpFile; delete m_changeTmpFile;
m_changeTmpFile = 0; m_changeTmpFile = 0;
@@ -550,7 +551,8 @@ void PerforcePlugin::submit()
foreach (const QString &f, files) foreach (const QString &f, files)
nativeFiles << QDir::toNativeSeparators(f); nativeFiles << QDir::toNativeSeparators(f);
PerforceResponse result2 = runP4Cmd(QStringList(QLatin1String("fstat")), nativeFiles, false); PerforceResponse result2 = runP4Cmd(QStringList(QLatin1String("fstat")), nativeFiles,
CommandToWindow|StdErrToWindow|ErrorToWindow);
if (result2.error) { if (result2.error) {
delete m_changeTmpFile; delete m_changeTmpFile;
m_changeTmpFile = 0; m_changeTmpFile = 0;
@@ -597,8 +599,10 @@ void PerforcePlugin::printPendingChanges()
PendingChangesDialog dia(pendingChangesData(), m_coreInstance->mainWindow()); PendingChangesDialog dia(pendingChangesData(), m_coreInstance->mainWindow());
qApp->restoreOverrideCursor(); qApp->restoreOverrideCursor();
if (dia.exec() == QDialog::Accepted) { if (dia.exec() == QDialog::Accepted) {
int i = dia.changeNumber(); const int i = dia.changeNumber();
PerforceResponse result = runP4Cmd(QStringList()<<"submit"<<"-c"<<QString::number(i), QStringList(), true); QStringList args(QLatin1String("submit"));
args << QLatin1String("-c") << QString::number(i);
runP4Cmd(args, QStringList(), CommandToWindow|StdOutToWindow|StdErrToWindow|ErrorToWindow);
} }
} }
@@ -628,7 +632,8 @@ void PerforcePlugin::annotate(const QString &fileName)
QTextCodec *codec = VCSBase::VCSBaseEditor::getCodec(m_coreInstance, fileName); QTextCodec *codec = VCSBase::VCSBaseEditor::getCodec(m_coreInstance, fileName);
QStringList args; QStringList args;
args << QLatin1String("annotate") << QLatin1String("-cqi") << fileName; args << QLatin1String("annotate") << QLatin1String("-cqi") << fileName;
const PerforceResponse result = runP4Cmd(args, QStringList(), false, true, codec); const PerforceResponse result = runP4Cmd(args, QStringList(),
CommandToWindow|StdErrToWindow|ErrorToWindow, codec);
if (!result.error) { if (!result.error) {
const QFileInfo fi(fileName); const QFileInfo fi(fileName);
showOutputInEditor(tr("p4 annotate %1").arg(fi.fileName()), result.stdOut, VCSBase::AnnotateOutput, codec); showOutputInEditor(tr("p4 annotate %1").arg(fi.fileName()), result.stdOut, VCSBase::AnnotateOutput, codec);
@@ -654,7 +659,8 @@ void PerforcePlugin::filelog(const QString &fileName)
QTextCodec *codec = VCSBase::VCSBaseEditor::getCodec(m_coreInstance, fileName); QTextCodec *codec = VCSBase::VCSBaseEditor::getCodec(m_coreInstance, fileName);
QStringList args; QStringList args;
args << QLatin1String("filelog") << QLatin1String("-li") << fileName; args << QLatin1String("filelog") << QLatin1String("-li") << fileName;
const PerforceResponse result = runP4Cmd(args, QStringList(), false, true, codec); const PerforceResponse result = runP4Cmd(args, QStringList(),
CommandToWindow|StdErrToWindow|ErrorToWindow, codec);
if (!result.error) { if (!result.error) {
const QFileInfo fi(fileName); const QFileInfo fi(fileName);
showOutputInEditor(tr("p4 filelog %1").arg(fi.fileName()), result.stdOut, VCSBase::LogOutput, codec); showOutputInEditor(tr("p4 filelog %1").arg(fi.fileName()), result.stdOut, VCSBase::LogOutput, codec);
@@ -718,18 +724,19 @@ bool PerforcePlugin::managesDirectory(const QString &directory) const
QStringList args; QStringList args;
args << QLatin1String("fstat") << QLatin1String("-m1") << p4Path; args << QLatin1String("fstat") << QLatin1String("-m1") << p4Path;
const PerforceResponse result = runP4Cmd(args, QStringList(), false, false); const PerforceResponse result = runP4Cmd(args, QStringList(), 0u);
return result.stdOut.contains("depotFile") || result.stdErr.contains("... - no such file(s)"); return result.stdOut.contains("depotFile") || result.stdErr.contains("... - no such file(s)");
} }
QString PerforcePlugin::findTopLevelForDirectory(const QString & /* dir */) const QString PerforcePlugin::findTopLevelForDirectory(const QString & /* dir */) const
{ {
// First check with p4 client -o // First check with p4 client -o
PerforceResponse result = runP4Cmd(QStringList() << QLatin1String("client") << QLatin1String("-o"), QStringList(), false, false); PerforceResponse result = runP4Cmd(QStringList() << QLatin1String("client") << QLatin1String("-o"), QStringList(), 0u);
if (result.error) if (result.error)
return QString::null; return QString::null;
QRegExp regExp(QLatin1String("(\\n|\\r\\n|\\r)Root:\\s*(.*)(\\n|\\r\\n|\\r)")); QRegExp regExp(QLatin1String("(\\n|\\r\\n|\\r)Root:\\s*(.*)(\\n|\\r\\n|\\r)"));
Q_ASSERT(regExp.isValid());
regExp.setMinimal(true); regExp.setMinimal(true);
if (regExp.indexIn(result.stdOut) != -1) { if (regExp.indexIn(result.stdOut) != -1) {
QString file = regExp.cap(2).trimmed(); QString file = regExp.cap(2).trimmed();
@@ -741,20 +748,24 @@ QString PerforcePlugin::findTopLevelForDirectory(const QString & /* dir */) cons
bool PerforcePlugin::vcsOpen(const QString &fileName) bool PerforcePlugin::vcsOpen(const QString &fileName)
{ {
PerforceResponse result = runP4Cmd(QStringList() << QLatin1String("edit") << QDir::toNativeSeparators(fileName), QStringList(), true); PerforceResponse result = runP4Cmd(QStringList() << QLatin1String("edit") << QDir::toNativeSeparators(fileName), QStringList(),
CommandToWindow|StdOutToWindow|StdErrToWindow|ErrorToWindow);
return !result.error; return !result.error;
} }
bool PerforcePlugin::vcsAdd(const QString &fileName) bool PerforcePlugin::vcsAdd(const QString &fileName)
{ {
PerforceResponse result = runP4Cmd(QStringList() << QLatin1String("add") << fileName, QStringList(), true); PerforceResponse result = runP4Cmd(QStringList() << QLatin1String("add") << fileName, QStringList(),
CommandToWindow|StdOutToWindow|StdErrToWindow|ErrorToWindow);
return !result.error; return !result.error;
} }
bool PerforcePlugin::vcsDelete(const QString &fileName) bool PerforcePlugin::vcsDelete(const QString &fileName)
{ {
PerforceResponse result = runP4Cmd(QStringList() << QLatin1String("revert") << fileName, QStringList(), true); PerforceResponse result = runP4Cmd(QStringList() << QLatin1String("revert") << fileName, QStringList(),
PerforceResponse result2 = runP4Cmd(QStringList() << QLatin1String("delete") << fileName, QStringList(), true); CommandToWindow|StdOutToWindow|StdErrToWindow|ErrorToWindow);
PerforceResponse result2 = runP4Cmd(QStringList() << QLatin1String("delete") << fileName, QStringList(),
CommandToWindow|StdOutToWindow|StdErrToWindow|ErrorToWindow);
// TODO need to carefully parse the actual messages from perforce // TODO need to carefully parse the actual messages from perforce
// or do a fstat before to decide what to do // or do a fstat before to decide what to do
@@ -767,8 +778,7 @@ bool PerforcePlugin::vcsDelete(const QString &fileName)
PerforceResponse PerforcePlugin::runP4Cmd(const QStringList &args, PerforceResponse PerforcePlugin::runP4Cmd(const QStringList &args,
const QStringList &extraArgs, const QStringList &extraArgs,
bool showStdOutInOutputWindow, unsigned logFlags,
bool showStdErrInOutputWindow,
QTextCodec *outputCodec) const QTextCodec *outputCodec) const
{ {
if (Perforce::Constants::debug) if (Perforce::Constants::debug)
@@ -801,12 +811,14 @@ PerforceResponse PerforcePlugin::runP4Cmd(const QStringList &args,
} }
actualArgs << args; actualArgs << args;
response.command = m_settings.p4Command; if (logFlags & CommandToWindow) {
response.command += blank; QString command = m_settings.p4Command;
response.command += actualArgs.join(QString(blank)); command += blank;
const QString timeStamp = QTime::currentTime().toString(QLatin1String("HH:mm")); command += actualArgs.join(QString(blank));
const QString outputText = tr("%1 Executing: %2\n").arg(timeStamp, response.command); const QString timeStamp = QTime::currentTime().toString(QLatin1String("HH:mm"));
showOutput(outputText, false); const QString outputText = tr("%1 Executing: %2\n").arg(timeStamp, command);
showOutput(outputText, false);
}
// Run, connect stderr to the output window // Run, connect stderr to the output window
Core::Utils::SynchronousProcess process; Core::Utils::SynchronousProcess process;
@@ -815,13 +827,13 @@ PerforceResponse PerforcePlugin::runP4Cmd(const QStringList &args,
process.setEnvironment(environment()); process.setEnvironment(environment());
// connect stderr to the output window if desired // connect stderr to the output window if desired
if (showStdErrInOutputWindow) { if (logFlags & StdErrToWindow) {
process.setStdErrBufferedSignalsEnabled(true); process.setStdErrBufferedSignalsEnabled(true);
connect(&process, SIGNAL(stdErrBuffered(QString,bool)), m_perforceOutputWindow, SLOT(append(QString,bool))); connect(&process, SIGNAL(stdErrBuffered(QString,bool)), m_perforceOutputWindow, SLOT(append(QString,bool)));
} }
// connect stdout to the output window if desired // connect stdout to the output window if desired
if (showStdOutInOutputWindow) { if (logFlags & StdOutToWindow) {
process.setStdOutBufferedSignalsEnabled(true); process.setStdOutBufferedSignalsEnabled(true);
connect(&process, SIGNAL(stdOutBuffered(QString,bool)), m_perforceOutputWindow, SLOT(append(QString,bool))); connect(&process, SIGNAL(stdOutBuffered(QString,bool)), m_perforceOutputWindow, SLOT(append(QString,bool)));
} }
@@ -847,13 +859,15 @@ PerforceResponse PerforcePlugin::runP4Cmd(const QStringList &args,
response.message = tr("Could not start perforce '%1'. Please check your settings in the preferences.").arg(m_settings.p4Command); response.message = tr("Could not start perforce '%1'. Please check your settings in the preferences.").arg(m_settings.p4Command);
break; break;
case Core::Utils::SynchronousProcessResponse::Hang: case Core::Utils::SynchronousProcessResponse::Hang:
response.message = tr("Subversion did not respond within timeout limit (%1 ms).").arg(p4Timeout ); response.message = tr("Perforce did not respond within timeout limit (%1 ms).").arg(p4Timeout );
break; break;
} }
if (response.error) if (response.error) {
m_perforceOutputWindow->append(response.message, true); if (Perforce::Constants::debug)
qDebug() << response.message;
if (logFlags & ErrorToWindow)
m_perforceOutputWindow->append(response.message, true);
}
return response; return response;
} }
@@ -923,7 +937,7 @@ void PerforcePlugin::p4Diff(const QStringList &files, QString diffname)
} }
} }
const PerforceResponse result = runP4Cmd(QStringList() << QLatin1String("diff") << QLatin1String("-du"), files, false, codec); const PerforceResponse result = runP4Cmd(QStringList() << QLatin1String("diff") << QLatin1String("-du"), files, CommandToWindow|StdErrToWindow|ErrorToWindow, codec);
if (result.error) if (result.error)
return; return;
@@ -948,7 +962,7 @@ void PerforcePlugin::describe(const QString & source, const QString &n)
QTextCodec *codec = source.isEmpty() ? static_cast<QTextCodec *>(0) : VCSBase::VCSBaseEditor::getCodec(m_coreInstance, source); QTextCodec *codec = source.isEmpty() ? static_cast<QTextCodec *>(0) : VCSBase::VCSBaseEditor::getCodec(m_coreInstance, source);
QStringList args; QStringList args;
args << QLatin1String("describe") << QLatin1String("-du") << n; args << QLatin1String("describe") << QLatin1String("-du") << n;
const PerforceResponse result = runP4Cmd(args, QStringList(), codec); const PerforceResponse result = runP4Cmd(args, QStringList(), CommandToWindow|StdErrToWindow|ErrorToWindow, codec);
if (!result.error) if (!result.error)
showOutputInEditor(tr("p4 describe %1").arg(n), result.stdOut, VCSBase::DiffOutput, codec); showOutputInEditor(tr("p4 describe %1").arg(n), result.stdOut, VCSBase::DiffOutput, codec);
} }

View File

@@ -86,7 +86,6 @@ private:
struct PerforceResponse struct PerforceResponse
{ {
bool error; bool error;
QString command;
QString stdOut; QString stdOut;
QString stdErr; QString stdErr;
QString message; QString message;
@@ -161,12 +160,15 @@ private:
Core::IEditor *showOutputInEditor(const QString& title, const QString output, Core::IEditor *showOutputInEditor(const QString& title, const QString output,
int editorType, int editorType,
QTextCodec *codec = 0); QTextCodec *codec = 0);
// Verbosity flags for runP4Cmd.
enum RunLogFlags { CommandToWindow = 0x1, StdOutToWindow = 0x2, StdErrToWindow = 0x4, ErrorToWindow = 0x8 };
// args are passed as command line arguments // args are passed as command line arguments
// extra args via a tempfile and the option -x "temp-filename" // extra args via a tempfile and the option -x "temp-filename"
PerforceResponse runP4Cmd(const QStringList &args, PerforceResponse runP4Cmd(const QStringList &args,
const QStringList &extraArgs = QStringList(), const QStringList &extraArgs = QStringList(),
bool showStdOutInOutputWindow = false, unsigned logFlags = CommandToWindow|StdErrToWindow|ErrorToWindow,
bool showStdErrInOutputWindow = true,
QTextCodec *outputCodec = 0) const; QTextCodec *outputCodec = 0) const;
void openFiles(const QStringList &files); void openFiles(const QStringList &files);

View File

@@ -35,6 +35,7 @@
#include "consoleappwizard.h" #include "consoleappwizard.h"
#include "modulespage.h" #include "modulespage.h"
#include <QtCore/QDebug>
#include <utils/projectintropage.h> #include <utils/projectintropage.h>
namespace Qt4ProjectManager { namespace Qt4ProjectManager {
@@ -51,13 +52,11 @@ ConsoleAppWizardDialog::ConsoleAppWizardDialog(const QString &templateName,
setWindowIcon(icon); setWindowIcon(icon);
setWindowTitle(templateName); setWindowTitle(templateName);
Core::BaseFileWizard::setupWizard(this); Core::BaseFileWizard::setupWizard(this);
setOptions(QWizard::IndependentPages | QWizard::HaveNextButtonOnLastPage);
m_introPage->setDescription(tr("This wizard generates a Qt4 console application " m_introPage->setDescription(tr("This wizard generates a Qt4 console application "
"project. The application derives from QCoreApplication and does not " "project. The application derives from QCoreApplication and does not "
"present a GUI. You can press 'Finish' at any point in time.")); "present a GUI. You can press 'Finish' at any point in time."));
m_introPage->setFinalPage(true);
addPage(m_introPage); addPage(m_introPage);
m_modulesPage->setModuleSelected(QLatin1String("core")); m_modulesPage->setModuleSelected(QLatin1String("core"));

View File

@@ -63,7 +63,6 @@ GuiAppWizardDialog::GuiAppWizardDialog(const QString &templateName,
setWindowIcon(icon); setWindowIcon(icon);
setWindowTitle(templateName); setWindowTitle(templateName);
Core::BaseFileWizard::setupWizard(this); Core::BaseFileWizard::setupWizard(this);
setOptions(QWizard::IndependentPages);
m_introPage->setDescription(tr("This wizard generates a Qt4 GUI application " m_introPage->setDescription(tr("This wizard generates a Qt4 GUI application "
"project. The application derives by default from QApplication " "project. The application derives by default from QApplication "