Commit 61906046 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

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

parents cd3a0236 e60befd6
......@@ -63,10 +63,6 @@ int qtGhVersion = QT_VERSION;
#include <set>
#include <vector>
#include <ctype.h>
#include <stdio.h>
#include <unistd.h>
/*!
\class QDumper
\brief Helper class for producing "nice" output in Qt Creator's debugger.
......@@ -246,7 +242,7 @@ static const void *addOffset(const void *p, int offset)
static const void *skipvtable(const void *p)
{
return sizeof(void*) + reinterpret_cast<const char *>(p);
return sizeof(void *) + reinterpret_cast<const char *>(p);
}
static const void *deref(const void *p)
......@@ -266,7 +262,7 @@ static bool isEqual(const char *s, const char *t)
static bool startsWith(const char *s, const char *t)
{
return qstrncmp(s, t, strlen(t)) == 0;
return qstrncmp(s, t, qstrlen(t)) == 0;
}
// provoke segfault when address is not readable
......@@ -277,7 +273,7 @@ static bool startsWith(const char *s, const char *t)
const char *stripNamespace(const char *type)
{
static const size_t nslen = strlen(NS);
static const size_t nslen = qstrlen(NS);
return startsWith(type, NS) ? type + nslen : type;
}
......
......@@ -2,7 +2,7 @@
#include "%UI_HDR%"
%CLASS%::%CLASS%(QWidget *parent)
: %BASECLASS%(parent), ui(new Ui::%CLASS%Class)
: %BASECLASS%(parent), ui(new Ui::%CLASS%)
{
ui->setupUi(this);
}
......
......@@ -5,7 +5,7 @@
namespace Ui
{
class %CLASS%Class;
class %CLASS%;
}
class %CLASS% : public %BASECLASS%
......@@ -17,7 +17,7 @@ public:
~%CLASS%();
private:
Ui::%CLASS%Class *ui;
Ui::%CLASS% *ui;
};
#endif // %PRE_DEF%
<ui version="4.0" stdsetdef="1" >
<ui version="4.0">
<class>%CLASS%Class</class>
<widget class="%BASECLASS%" name="%CLASS%Class" >
<property name="objectName" >
<cstring>%CLASS%Class</cstring>
</property>
<widget class="%BASECLASS%" name="%CLASS%" >
<property name="geometry" >
<rect>
<x>0</x>
......
......@@ -97,7 +97,10 @@ bool MakeStep::init(const QString &buildConfiguration)
#else // Q_OS_WIN
setCommand(buildConfiguration, "make"); // TODO give full path here?
#endif // Q_OS_WIN
setArguments(buildConfiguration, value(buildConfiguration, "buildTargets").toStringList()); // TODO
QStringList arguments = value(buildConfiguration, "buildTargets").toStringList();
arguments << additionalArguments(buildConfiguration);
setArguments(buildConfiguration, arguments); // TODO
setEnvironment(buildConfiguration, m_pro->environment(buildConfiguration));
return AbstractProcessStep::init(buildConfiguration);
}
......@@ -219,15 +222,31 @@ void MakeStep::setBuildTarget(const QString &buildConfiguration, const QString &
setValue(buildConfiguration, "buildTargets", old.removeOne(target));
}
QStringList MakeStep::additionalArguments(const QString &buildConfiguration) const
{
return value(buildConfiguration, "additionalArguments").toStringList();
}
void MakeStep::setAdditionalArguments(const QString &buildConfiguration, const QStringList &list)
{
setValue(buildConfiguration, "additionalArguments", list);
}
//
// CMakeBuildStepConfigWidget
//
MakeBuildStepConfigWidget::MakeBuildStepConfigWidget(MakeStep *makeStep)
: m_makeStep(makeStep)
{
QFormLayout *fl = new QFormLayout(this);
setLayout(fl);
m_additionalArguments = new QLineEdit(this);
fl->addRow("Additional arguments:", m_additionalArguments);
connect(m_additionalArguments, SIGNAL(textEdited(const QString &)), this, SLOT(additionalArgumentsEdited()));
m_targetsList = new QListWidget;
fl->addRow("Targets:", m_targetsList);
......@@ -238,9 +257,15 @@ MakeBuildStepConfigWidget::MakeBuildStepConfigWidget(MakeStep *makeStep)
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
item->setCheckState(Qt::Unchecked);
}
connect(m_targetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*)));
}
void MakeBuildStepConfigWidget::additionalArgumentsEdited()
{
m_makeStep->setAdditionalArguments(m_buildConfiguration, ProjectExplorer::Environment::parseCombinedArgString(m_additionalArguments->text()));
}
void MakeBuildStepConfigWidget::itemChanged(QListWidgetItem *item)
{
m_makeStep->setBuildTarget(m_buildConfiguration, item->text(), item->checkState() & Qt::Checked);
......@@ -253,8 +278,6 @@ QString MakeBuildStepConfigWidget::displayName() const
void MakeBuildStepConfigWidget::init(const QString &buildConfiguration)
{
// TODO
// disconnect to make the changes to the items
disconnect(m_targetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*)));
m_buildConfiguration = buildConfiguration;
......@@ -265,6 +288,8 @@ void MakeBuildStepConfigWidget::init(const QString &buildConfiguration)
}
// and connect again
connect(m_targetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*)));
m_additionalArguments->setText(ProjectExplorer::Environment::joinArgumentList(m_makeStep->additionalArguments(m_buildConfiguration)));
}
//
......
......@@ -60,6 +60,8 @@ public:
CMakeProject *project() const;
bool buildsTarget(const QString &buildConfiguration, const QString &target) const;
void setBuildTarget(const QString &buildConfiguration, const QString &target, bool on);
QStringList additionalArguments(const QString &buildConfiguration) const;
void setAdditionalArguments(const QString &buildConfiguration, const QStringList &list);
private slots:
void slotAddToTaskWindow(const QString & fn, int type, int linenumber, const QString & description);
void addDirectory(const QString &dir);
......@@ -82,10 +84,12 @@ public:
virtual void init(const QString &buildConfiguration);
private slots:
void itemChanged(QListWidgetItem*);
void additionalArgumentsEdited();
private:
QString m_buildConfiguration;
MakeStep * m_makeStep;
QListWidget *m_targetsList;
QLineEdit *m_additionalArguments;
};
class MakeBuildStepFactory : public ProjectExplorer::IBuildStepFactory
......
......@@ -65,6 +65,7 @@
#include "basefilewizard.h"
#include <coreplugin/findplaceholder.h>
#include <utils/pathchooser.h>
#include <extensionsystem/pluginmanager.h>
#include <QtCore/QDebug>
......@@ -836,10 +837,10 @@ QStringList MainWindow::showNewItemDialog(const QString &title,
const QString &defaultLocation)
{
QString defaultDir = defaultLocation;
if (defaultDir.isEmpty()) {
if (!m_coreImpl->fileManager()->currentFile().isEmpty())
defaultDir = QFileInfo(m_coreImpl->fileManager()->currentFile()).absolutePath();
}
if (defaultDir.isEmpty() && !m_coreImpl->fileManager()->currentFile().isEmpty())
defaultDir = QFileInfo(m_coreImpl->fileManager()->currentFile()).absolutePath();
if (defaultDir.isEmpty())
defaultDir = Core::Utils::PathChooser::homePath();
// Scan for wizards matching the filter and pick one. Don't show
// dialog if there is only one.
......
......@@ -262,6 +262,8 @@ void DebuggerManager::init()
this, SLOT(loadAllSymbols()));
connect(modulesView, SIGNAL(fileOpenRequested(QString)),
this, SLOT(fileOpen(QString)));
connect(modulesView, SIGNAL(newDockRequested(QWidget*)),
this, SLOT(createNewDock(QWidget*)));
// Source Files
//m_sourceFilesHandler = new SourceFilesHandler;
......@@ -508,6 +510,16 @@ void DebuggerManager::createDockWidgets()
m_watchDock = createDockForWidget(localsAndWatchers);
}
void DebuggerManager::createNewDock(QWidget *widget)
{
QDockWidget *dockWidget = new QDockWidget(widget->windowTitle(), m_mainWindow);
dockWidget->setObjectName(widget->windowTitle());
dockWidget->setFeatures(QDockWidget::DockWidgetClosable);
dockWidget->setWidget(widget);
m_mainWindow->addDockWidget(Qt::TopDockWidgetArea, dockWidget);
dockWidget->show();
}
QDockWidget *DebuggerManager::createDockForWidget(QWidget *widget)
{
QDockWidget *dockWidget = new QDockWidget(widget->windowTitle(), m_mainWindow);
......
......@@ -402,6 +402,7 @@ private:
void init();
void setDebuggerType(DebuggerType type);
QDockWidget *createDockForWidget(QWidget *widget);
Q_SLOT void createNewDock(QWidget *widget);
void shutdown();
......
......@@ -2428,6 +2428,8 @@ void GdbEngine::handleModulesList(const GdbResultRecord &record)
{
QList<Module> modules;
if (record.resultClass == GdbResultDone) {
// that's console-based output, likely Linux or Windows,
// but we can avoid the #ifdef here
QString data = record.data.findChild("consolestreamoutput").data();
QTextStream ts(&data, QIODevice::ReadOnly);
while (!ts.atEnd()) {
......@@ -2442,6 +2444,21 @@ void GdbEngine::handleModulesList(const GdbResultRecord &record)
module.symbolsRead = (symbolsRead == "Yes");
modules.append(module);
}
if (modules.isEmpty()) {
// Mac has^done,shlib-info={num="1",name="dyld",kind="-",
// dyld-addr="0x8fe00000",reason="dyld",requested-state="Y",
// state="Y",path="/usr/lib/dyld",description="/usr/lib/dyld",
// loaded_addr="0x8fe00000",slide="0x0",prefix="__dyld_"},
// shlib-info={...}...
foreach (const GdbMi &item, record.data.children()) {
Module module;
module.moduleName = item.findChild("path").data();
module.symbolsRead = (item.findChild("state").data() == "Y");
module.startAddress = item.findChild("loaded_addr").data();
module.endAddress = "<unknown>";
modules.append(module);
}
}
}
qq->modulesHandler()->setModules(modules);
}
......
......@@ -30,13 +30,23 @@
#include "moduleswindow.h"
#include "moduleshandler.h" // for model roles
#include <QAction>
#include <QDebug>
#include <QHeaderView>
#include <QMenu>
#include <QResizeEvent>
#include <QToolButton>
#include <QtCore/QDebug>
#include <QtCore/QProcess>
#include <QtCore/QRegExp>
#include <QtGui/QAction>
#include <QtGui/QHeaderView>
#include <QtGui/QMenu>
#include <QtGui/QResizeEvent>
#include <QtGui/QToolButton>
#include <QtGui/QTreeWidget>
///////////////////////////////////////////////////////////////////////////
//
// ModulesWindow
//
///////////////////////////////////////////////////////////////////////////
using Debugger::Internal::ModulesWindow;
......@@ -93,20 +103,28 @@ void ModulesWindow::contextMenuEvent(QContextMenuEvent *ev)
QAction *act4 = new QAction(tr("Load symbols for all modules"), &menu);
QAction *act5 = 0;
QAction *act6 = 0;
QAction *act7 = 0;
if (name.isEmpty()) {
act5 = new QAction(tr("Load symbols for module"), &menu);
act6 = new QAction(tr("Edit file"), &menu);
act7 = new QAction(tr("Show symbols"), &menu);
} else {
act5 = new QAction(tr("Load symbols for module \"%1\"").arg(name), &menu);
act6 = new QAction(tr("Edit file \"%1\"").arg(name), &menu);
act7 = new QAction(tr("Show symbols in file \"%1\"").arg(name), &menu);
}
act5->setDisabled(name.isEmpty());
act6->setDisabled(name.isEmpty());
act7->setDisabled(name.isEmpty());
#ifndef Q_OS_LINUX
act7->setDisabled(true);
#endif
menu.addAction(act0);
menu.addAction(act4);
menu.addAction(act5);
menu.addAction(act6);
menu.addAction(act7);
menu.addSeparator();
menu.addAction(act1);
menu.addAction(act2);
......@@ -127,6 +145,8 @@ void ModulesWindow::contextMenuEvent(QContextMenuEvent *ev)
emit loadSymbolsRequested(name);
else if (act == act6)
emit fileOpenRequested(name);
else if (act == act7)
showSymbols(name);
}
void ModulesWindow::resizeColumnsToContents()
......@@ -154,3 +174,32 @@ void ModulesWindow::setModel(QAbstractItemModel *model)
setAlwaysResizeColumnsToContents(true);
}
void ModulesWindow::showSymbols(const QString &name)
{
if (name.isEmpty())
return;
QProcess proc;
proc.start("nm", QStringList() << "-D" << name);
proc.waitForFinished();
QTreeWidget *w = new QTreeWidget;
w->setColumnCount(3);
w->setRootIsDecorated(false);
w->setAlternatingRowColors(true);
//w->header()->hide();
w->setHeaderLabels(QStringList() << tr("Address") << tr("Code") << tr("Symbol"));
w->setWindowTitle(tr("Symbols in \"%1\"").arg(name));
QString contents = QString::fromLocal8Bit(proc.readAllStandardOutput());
QRegExp re("([0-9a-f]+)?\\s+([^\\s]+)\\s+([^\\s]+)");
foreach (QString line, contents.split('\n')) {
if (re.indexIn(line) != -1) {
QTreeWidgetItem *it = new QTreeWidgetItem;
it->setData(0, Qt::DisplayRole, re.cap(1));
it->setData(1, Qt::DisplayRole, re.cap(2));
it->setData(2, Qt::DisplayRole, re.cap(3));
w->addTopLevelItem(it);
} else {
qDebug() << "UNHANDLED LINE" << line;
}
}
emit newDockRequested(w);
}
......@@ -48,11 +48,13 @@ signals:
void loadSymbolsRequested(const QString &modulesName);
void loadAllSymbolsRequested();
void fileOpenRequested(QString);
void newDockRequested(QWidget *w);
public slots:
void resizeColumnsToContents();
void setAlwaysResizeColumnsToContents(bool on);
void moduleActivated(const QModelIndex &);
void showSymbols(const QString &name);
private:
void resizeEvent(QResizeEvent *ev);
......
......@@ -29,6 +29,7 @@
#include "formtemplatewizardpage.h"
#include "formeditorw.h"
#include "designerconstants.h"
#include <qt_private/abstractnewformwidget_p.h>
......@@ -278,6 +279,8 @@ namespace {
QString FormTemplateWizardPage::changeUiClassName(const QString &uiXml, const QString &newUiClassName)
{
if (Designer::Constants::Internal::debug)
qDebug() << '>' << Q_FUNC_INFO << newUiClassName;
QDomDocument domUi;
if (!domUi.setContent(uiXml)) {
qWarning("Failed to parse:\n%s", uiXml.toUtf8().constData());
......@@ -320,6 +323,8 @@ QString FormTemplateWizardPage::changeUiClassName(const QString &uiXml, const QS
}
}
const QString rc = domUi.toString();
if (Designer::Constants::Internal::debug > 1)
qDebug() << '<' << Q_FUNC_INFO << newUiClassName << rc;
return rc;
}
#endif // USE_XSLT
......
......@@ -36,14 +36,14 @@ using namespace Designer::Internal;
void SettingsManager::beginGroup(const QString &prefix)
{
if (Designer::Constants::Internal::debug)
if (Designer::Constants::Internal::debug > 1)
qDebug() << Q_FUNC_INFO << addPrefix(prefix);
m_settings.beginGroup(addPrefix(prefix));
}
void SettingsManager::endGroup()
{
if (Designer::Constants::Internal::debug)
if (Designer::Constants::Internal::debug > 1)
qDebug() << Q_FUNC_INFO;
m_settings.endGroup();
}
......@@ -55,7 +55,7 @@ bool SettingsManager::contains(const QString &key) const
void SettingsManager::setValue(const QString &key, const QVariant &value)
{
if (Designer::Constants::Internal::debug)
if (Designer::Constants::Internal::debug > 1)
qDebug() << Q_FUNC_INFO << addPrefix(key) << ": " << value;
m_settings.setValue(addPrefix(key), value);
}
......@@ -63,7 +63,7 @@ void SettingsManager::setValue(const QString &key, const QVariant &value)
QVariant SettingsManager::value(const QString &key, const QVariant &defaultValue) const
{
QVariant result = m_settings.value(addPrefix(key), defaultValue);
if (Designer::Constants::Internal::debug)
if (Designer::Constants::Internal::debug > 1)
qDebug() << Q_FUNC_INFO << addPrefix(key) << ": " << result;
return result;
}
......
......@@ -125,6 +125,16 @@ static QList<Document::Ptr> findDocumentsIncluding(const CPlusPlus::Snapshot &do
return docList;
}
// Does klass inherit baseClass?
static bool inherits(const Overview &o, const Class *klass, const QString &baseClass)
{
const int baseClassCount = klass->baseClassCount();
for (int b = 0; b < baseClassCount; b++)
if (o.prettyName(klass->baseClassAt(b)->name()) == baseClass)
return true;
return false;
}
// Check for a class name where haystack is a member class of an object.
// So, haystack can be shorter (can have some namespaces omitted because of a
// "using namespace" declaration, for example, comparing
......@@ -141,7 +151,9 @@ static bool matchMemberClassName(const QString &needle, const QString &hayStack)
return separatorPos > 1 && needle.at(separatorPos) == QLatin1Char(':');
}
// Find class definition in namespace
// Find class definition in namespace (that is, the outer class
// containing a member of the desired class type) or inheriting the desired class
// in case of forms using the Multiple Inheritance approach
static const Class *findClass(const Namespace *parentNameSpace, const QString &className, QString *namespaceName)
{
if (Designer::Constants::Internal::debug)
......@@ -153,8 +165,9 @@ static const Class *findClass(const Namespace *parentNameSpace, const QString &c
const Symbol *sym = parentNameSpace->memberAt(i);
// we have found a class - we are interested in classes only
if (const Class *cl = sym->asClass()) {
// 1) we go through class members
const unsigned classMemberCount = cl->memberCount();
for (unsigned j = 0; j < classMemberCount; j++) // we go through class members
for (unsigned j = 0; j < classMemberCount; j++)
if (const Declaration *decl = cl->memberAt(j)->asDeclaration()) {
// we want to know if the class contains a member (so we look into
// a declaration) of uiClassName type
......@@ -166,6 +179,9 @@ static const Class *findClass(const Namespace *parentNameSpace, const QString &c
if (nt && matchMemberClassName(className, o.prettyName(nt->name())))
return cl;
} // decl
// 2) does it inherit the desired class
if (inherits(o, cl, className))
return cl;
} else {
// Check namespaces
if (const Namespace *ns = sym->asNamespace()) {
......@@ -386,8 +402,15 @@ static void addDeclaration(const QString &docFileName, const Class *cl, const QS
// fun->column() returns always 0, what can cause trouble in case in one
// line if there is: "private slots: void foo();"
if (fun->isSlot() && fun->isPrivate()) {
if (ITextEditable *editable = editableAt(docFileName, fun->line(), fun->column()))
editable->insert(declaration + QLatin1String(" "));
const int line = fun->line(); // [1..n]
const int column = fun->column();
if (ITextEditable *editable = editableAt(docFileName, line, column)) {
// Figure out indentation (symbol - len("void ")) and insert after
editable->gotoLine(line + 1, 1);
editable->position(ITextEditor::StartOfLine);
const QString indentation = QString(qMax(0, column - 6), QLatin1Char(' '));
editable->insert(indentation + declaration);
}
return;
}
}
......@@ -483,7 +506,7 @@ static ClassDocumentPtrPair
unsigned maxIncludeDepth, QString *namespaceName)
{
if (Designer::Constants::Internal::debug)
qDebug() << Q_FUNC_INFO << doc->fileName() << maxIncludeDepth;
qDebug() << Q_FUNC_INFO << doc->fileName() << className << maxIncludeDepth;
// Check document
if (const Class *cl = findClass(doc->globalNamespace(), className, namespaceName))
return ClassDocumentPtrPair(cl, doc);
......@@ -523,6 +546,9 @@ static inline QString uiClassName(QString formObjectName)
return formObjectName;
}
// Goto slot invoked by the designer context menu. Either navigates
// to an existing slot function or create a new one.
bool WorkbenchIntegration::navigateToSlot(const QString &objectName,
const QString &signalSignature,
const QStringList &parameterNames,
......@@ -538,7 +564,7 @@ bool WorkbenchIntegration::navigateToSlot(const QString &objectName,
const QFileInfo fi(currentUiFile);
const QString uicedName = QLatin1String("ui_") + fi.baseName() + QLatin1String(".h");
// take all docs
// take all docs, find the ones that include the ui_xx.h.
const CPlusPlus::Snapshot docTable = cppModelManagerInstance()->snapshot();
QList<Document::Ptr> docList = findDocumentsIncluding(docTable, uicedName, true); // change to false when we know the absolute path to generated ui_<>.h file
......@@ -546,7 +572,7 @@ bool WorkbenchIntegration::navigateToSlot(const QString &objectName,
if (Designer::Constants::Internal::debug)
qDebug() << Q_FUNC_INFO << objectName << signalSignature << "Looking for " << uicedName << " returned " << docList.size();
if (docList.isEmpty()) {
*errorMessage = tr("No documents matching %1 could be found.").arg(uicedName);
*errorMessage = tr("No documents matching '%1' could be found.\nRebuilding the project might help.").arg(uicedName);
return false;
}
......@@ -557,8 +583,8 @@ bool WorkbenchIntegration::navigateToSlot(const QString &objectName,
if (Designer::Constants::Internal::debug)
qDebug() << "Checking docs for " << uiClass;
// Find the class definition in the file itself or in the directly
// included files (order 1).
// Find the class definition (ui class defined as member or base class)
// in the file itself or in the directly included files (order 1).
QString namespaceName;
const Class *cl = 0;
Document::Ptr doc;
......@@ -578,6 +604,8 @@ bool WorkbenchIntegration::navigateToSlot(const QString &objectName,
Overview o;
const QString className = namespaceName + o.prettyName(cl->name());
if (Designer::Constants::Internal::debug)
qDebug() << "Found class " << className << doc->fileName();
const QString functionName = QLatin1String("on_") + objectName + QLatin1Char('_') + signalSignature;
const QString functionNameWithParameterNames = addParameterNames(functionName, parameterNames);
......
......@@ -36,12 +36,13 @@ namespace Constants {
const char * const ConfigOn = "on";
const char * const ConfigOff = "off";
const char * const ConfigAutoIndent = "autoindent";
const char * const ConfigExpandTab = "expandtab";
const char * const ConfigHlSearch = "hlsearch";
const char * const ConfigShiftWidth = "shiftwidth";
const char * const ConfigSmartTab = "smarttab";
const char * const ConfigStartOfLine = "startofline";
const char * const ConfigTabStop = "tabstop";
const char * const ConfigSmartTab = "smarttab";
const char * const ConfigShiftWidth = "shiftwidth";
const char * const ConfigExpandTab = "expandtab";
const char * const ConfigAutoIndent = "autoindent";
} // namespace Constants
} // namespace FakeVim
......
......@@ -177,7 +177,7 @@ QDebug &operator<<(QDebug &ts, const EditOperation &op)
ts << "\n EDIT BLOCK WITH " << op.itemCount << " ITEMS";
} else {
ts << "\n EDIT AT " << op.position
<< "\n FROM " << op.from << "\n TO " << op.to;
<< " FROM " << op.from << " TO " << op.to;
}
return ts;
}
......@@ -227,6 +227,7 @@ private:
EventResult handleMiniBufferModes(int key, int unmodified, const QString &text);
void finishMovement(const QString &text = QString());
void search(const QString &needle, bool forward);
void highlightMatches(const QString &needle);