Commit 84261f00 authored by hjk's avatar hjk
Browse files

Merge branch '0.9.1-beta' of git@scm.dev.nokia.troll.no:creator/mainline into 0.9.1-beta

parents 0e8d02aa 1b33b75f
......@@ -950,24 +950,23 @@
You can start Qt Creator from a command prompt with an existing session or
\c{.pro} file by giving the name as argument on the command line.
\bold{Sidebar}
\bold{Show and Hide the Sidebar}
You can hide/unhide the sidebar in the edit and debug mode
by clicking on the corresponding icon on the left bottom.
Keyboard shortcut is \key{Alt+0}.
You can show and hide the the sidebar in \gui Edit and \gui Debug mode by
clicking on the corresponding icon, or by pressing \key{Alt+0}.
\bold{Display signals and slots}
\bold{Display Signals and Slots}
If you have an instance of a class derived from QObject and
want to find all other objects connected to one of its
slots by Qt's signals-and-slots mechanism, enable
\gui{Debug} and \gui{Use Custom Display for Qt Objects}.
In the \gui{Locals and Watchers View}, expand the object's
entry and open the wanted slot in the "slots" subitem. The
objects connect to this slot are exposed as children of
this slot. The same works with signals.
If you have an instance of a class that is derived from QObject, and you
you would like to find all other objects connected to one of your object's
slots using Qt's signals and slots mechanism -- you can enable
\gui{Use Custom Display for Qt Objects} feature under the \gui Debug menu.
\bold{Low level display}
In the \gui{Locals and Watchers} view, expand the object's entry and open
the slot in the \e slots subitem. The objects connected to this slot are
exposed as children of the slot. This method works with signals too.
\bold{Display Low Level Data}
If the special debugging of Qt objects fails due to data
corruption within the debugged objects, you can switch the
......@@ -983,33 +982,38 @@
\title Glossary
\bold{System Qt}
\target glossary-system-qt
The version of Qt installed on your system.
This is the one whose \c qmake command is found in the \c PATH.
\bold{Default Qt}
\target glossary-default-qt
The version of Qt configured in \gui{Tools
-> Options -> Qt 4 -> Default Qt Version}. This is the version
used by new projects. It defaults to the System Qt.
\table
\header
\o Term
\o Meaning
\bold{Project Qt}
\row
\o System Qt \target glossary-system-qt
\o The version of Qt installed on your system. This is the Qt
version for the \c qmake command found in your \c PATH.
\target glossary-project-qt
The version of Qt configured in \gui{Build&Run
-> Build Settings -> Build Configurations}. This is the version
actually used by the project. It defaults to the Default Qt.
\row
\o Default Qt \target glossary-default-qt
\o The version of Qt configured in \gui{Tools -> Options -> Qt 4
-> Default Qt Version}. This is the Qt version used by your
new projects. It defaults to System Qt.
\bold{Shadow Build}
\row
\o Project Qt \target glossary-project-qt
\o The version of Qt configured in \gui{Build&Run -> Build
Settings -> Build Configurations}. This is the Qt version that
is actually used by a particular project. It defaults to
Default Qt.
\target glossary-shadow-build
Shadow building means building the project not in the source directory,
but in a seperate \bold{build directory}. This has the benefit of keeping
the source directory clean. It is also considered "best practice" if
you need many build configurations for a single set of sources.
\row
\o Shadow Build \target glossary-shadow-build
\o Shadow building means building a project in a separate
directory, the \e{build directory}. The build directory is
different from the source directory. One of the benefits of
shadow building is that it keeps your source directory clean.
Shadow building is the best practice if you need many build
configurations for a single set of source.
\endtable
*/
......
......@@ -61,11 +61,11 @@ Icons::Icons()
{
}
QIcon Icons::iconForSymbol(Symbol *symbol) const
QIcon Icons::iconForSymbol(const Symbol *symbol) const
{
if (symbol->isFunction() || (symbol->isDeclaration() && symbol->type()->isFunction()))
{
Function *function = symbol->asFunction();
const Function *function = symbol->asFunction();
if (!function)
function = symbol->type()->asFunction();
......
......@@ -47,7 +47,7 @@ class CPLUSPLUS_EXPORT Icons
public:
Icons();
QIcon iconForSymbol(Symbol *symbol) const;
QIcon iconForSymbol(const Symbol *symbol) const;
QIcon keywordIcon() const;
QIcon macroIcon() const;
......
......@@ -30,6 +30,7 @@
** version 1.2, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/
#ifndef PATHCHOOSER_H
#define PATHCHOOSER_H
......
......@@ -79,6 +79,7 @@
#include <QtGui/QComboBox>
#include <QtGui/QTreeView>
#include <QtGui/QHeaderView>
#include <QtGui/QStringListModel>
using namespace CPlusPlus;
using namespace CppEditor::Internal;
......@@ -202,7 +203,9 @@ void CPPEditor::createToolBar(CPPEditorEditable *editable)
m_methodCombo->setMaxVisibleItems(20);
m_overviewModel = new OverviewModel(this);
m_methodCombo->setModel(m_overviewModel);
m_noSymbolsModel = new QStringListModel(this);
m_noSymbolsModel->setStringList(QStringList() << tr("<no symbols>"));
m_methodCombo->setModel(m_noSymbolsModel);
connect(m_methodCombo, SIGNAL(activated(int)), this, SLOT(jumpToMethod(int)));
connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(updateMethodBoxIndex()));
......@@ -315,9 +318,16 @@ void CPPEditor::onDocumentUpdated(Document::Ptr doc)
return;
m_overviewModel->rebuild(doc);
OverviewTreeView *treeView = static_cast<OverviewTreeView *>(m_methodCombo->view());
treeView->sync();
updateMethodBoxIndex();
if (m_overviewModel->rowCount() > 0) {
if (m_methodCombo->model() != m_overviewModel)
m_methodCombo->setModel(m_overviewModel);
OverviewTreeView *treeView = static_cast<OverviewTreeView *>(m_methodCombo->view());
treeView->sync();
updateMethodBoxIndex();
} else {
if (m_methodCombo->model() != m_noSymbolsModel)
m_methodCombo->setModel(m_noSymbolsModel);
}
}
void CPPEditor::updateFileName()
......@@ -325,6 +335,8 @@ void CPPEditor::updateFileName()
void CPPEditor::jumpToMethod(int)
{
if (m_methodCombo->model() != m_overviewModel)
return;
QModelIndex index = m_methodCombo->view()->currentIndex();
Symbol *symbol = m_overviewModel->symbolFromIndex(index);
if (! symbol)
......@@ -339,12 +351,14 @@ void CPPEditor::jumpToMethod(int)
void CPPEditor::updateMethodBoxIndex()
{
if (m_methodCombo->model() != m_overviewModel)
return;
int line = 0, column = 0;
convertPosition(position(), &line, &column);
QModelIndex lastIndex;
const int rc = m_overviewModel->rowCount(QModelIndex());
const int rc = m_overviewModel->rowCount();
for (int row = 0; row < rc; ++row) {
const QModelIndex index = m_overviewModel->index(row, 0, QModelIndex());
Symbol *symbol = m_overviewModel->symbolFromIndex(index);
......
......@@ -42,6 +42,7 @@
QT_BEGIN_NAMESPACE
class QAction;
class QComboBox;
class QStringListModel;
QT_END_NAMESPACE
namespace Core {
......@@ -138,6 +139,7 @@ private:
QList<int> m_contexts;
QComboBox *m_methodCombo;
CPlusPlus::OverviewModel *m_overviewModel;
QStringListModel *m_noSymbolsModel;
};
} // namespace Internal
......
......@@ -42,6 +42,7 @@ CppClassesFilter::CppClassesFilter(CppModelManager *manager, Core::EditorManager
setIncludedByDefault(false);
search.setSymbolsToSearchFor(SearchSymbols::Classes);
search.setSeparateScope(true);
}
CppClassesFilter::~CppClassesFilter()
......
......@@ -683,7 +683,7 @@ void CppModelManager::onDocumentUpdated(Document::Ptr doc)
sel.cursor = c;
selections.append(sel);
}
ed->setExtraExtraSelections(selections);
ed->setExtraSelections(TextEditor::BaseTextEditor::CodeWarningsSelection, selections);
break;
}
}
......
......@@ -40,7 +40,8 @@ using namespace CPlusPlus;
using namespace CppTools::Internal;
SearchSymbols::SearchSymbols():
symbolsToSearchFor(Classes | Functions | Enums)
symbolsToSearchFor(Classes | Functions | Enums),
separateScope(false)
{
}
......@@ -49,6 +50,11 @@ void SearchSymbols::setSymbolsToSearchFor(SymbolTypes types)
symbolsToSearchFor = types;
}
void SearchSymbols::setSeparateScope(bool separateScope)
{
this->separateScope = separateScope;
}
QList<ModelItemInfo> SearchSymbols::operator()(Document::Ptr doc, const QString &scope)
{
QString previousScope = switchScope(scope);
......@@ -73,13 +79,12 @@ bool SearchSymbols::visit(Enum *symbol)
return false;
QString name = symbolName(symbol);
QString previousScope = switchScope(name);
QIcon icon = icons.iconForSymbol(symbol);
QString scopedName = scopedSymbolName(name);
QString previousScope = switchScope(scopedName);
appendItem(separateScope ? name : scopedName,
separateScope ? previousScope : QString(),
ModelItemInfo::Enum, symbol);
Scope *members = symbol->members();
items.append(ModelItemInfo(name, QString(), ModelItemInfo::Enum,
QString::fromUtf8(symbol->fileName(), symbol->fileNameLength()),
symbol->line(),
icon));
for (unsigned i = 0; i < members->symbolCount(); ++i) {
accept(members->symbolAt(i));
}
......@@ -93,18 +98,18 @@ bool SearchSymbols::visit(Function *symbol)
return false;
QString name = symbolName(symbol);
QString type = overview.prettyType(symbol->type());
QIcon icon = icons.iconForSymbol(symbol);
items.append(ModelItemInfo(name, type, ModelItemInfo::Method,
QString::fromUtf8(symbol->fileName(), symbol->fileNameLength()),
symbol->line(),
icon));
QString scopedName = scopedSymbolName(name);
QString type = overview.prettyType(symbol->type(),
separateScope ? symbol->name() : 0);
appendItem(separateScope ? type : scopedName,
separateScope ? _scope : type,
ModelItemInfo::Method, symbol);
return false;
}
bool SearchSymbols::visit(Namespace *symbol)
{
QString name = symbolName(symbol);
QString name = findOrInsert(scopedSymbolName(symbol));
QString previousScope = switchScope(name);
Scope *members = symbol->members();
for (unsigned i = 0; i < members->symbolCount(); ++i) {
......@@ -118,12 +123,9 @@ bool SearchSymbols::visit(Namespace *symbol)
bool SearchSymbols::visit(Declaration *symbol)
{
if (symbol->type()->isFunction()) {
QString name = symbolName(symbol);
QString name = scopedSymbolName(symbol);
QString type = overview.prettyType(symbol->type());
//QIcon icon = ...;
items.append(ModelItemInfo(name, type, ModelItemInfo::Method,
QString::fromUtf8(symbol->fileName(), symbol->line()),
symbol->line()));
appendItems(name, type, ModelItemInfo::Method, symbol->fileName());
}
return false;
}
......@@ -135,12 +137,11 @@ bool SearchSymbols::visit(Class *symbol)
return false;
QString name = symbolName(symbol);
QString previousScope = switchScope(name);
QIcon icon = icons.iconForSymbol(symbol);
items.append(ModelItemInfo(name, QString(), ModelItemInfo::Class,
QString::fromUtf8(symbol->fileName(), symbol->fileNameLength()),
symbol->line(),
icon));
QString scopedName = scopedSymbolName(name);
QString previousScope = switchScope(scopedName);
appendItem(separateScope ? name : scopedName,
separateScope ? previousScope : QString(),
ModelItemInfo::Class, symbol);
Scope *members = symbol->members();
for (unsigned i = 0; i < members->symbolCount(); ++i) {
accept(members->symbolAt(i));
......@@ -149,11 +150,22 @@ bool SearchSymbols::visit(Class *symbol)
return false;
}
QString SearchSymbols::symbolName(const Symbol *symbol) const
QString SearchSymbols::scopedSymbolName(const QString &symbolName) const
{
QString name = _scope;
if (! name.isEmpty())
name += QLatin1String("::");
name += symbolName;
return name;
}
QString SearchSymbols::scopedSymbolName(const Symbol *symbol) const
{
return scopedSymbolName(symbolName(symbol));
}
QString SearchSymbols::symbolName(const Symbol *symbol) const
{
QString symbolName = overview.prettyName(symbol->name());
if (symbolName.isEmpty()) {
QString type;
......@@ -176,6 +188,17 @@ QString SearchSymbols::symbolName(const Symbol *symbol) const
symbolName += type;
symbolName += QLatin1String(">");
}
name += symbolName;
return name;
return symbolName;
}
void SearchSymbols::appendItem(const QString &name,
const QString &info,
ModelItemInfo::ItemType type,
const CPlusPlus::Symbol *symbol)
{
const QIcon icon = icons.iconForSymbol(symbol);
items.append(ModelItemInfo(name, info, type,
QString::fromUtf8(symbol->fileName(), symbol->fileNameLength()),
symbol->line(),
icon));
}
......@@ -92,6 +92,7 @@ public:
SearchSymbols();
void setSymbolsToSearchFor(SymbolTypes types);
void setSeparateScope(bool separateScope);
QList<ModelItemInfo> operator()(CPlusPlus::Document::Ptr doc)
{ return operator()(doc, QString()); }
......@@ -113,14 +114,27 @@ protected:
virtual bool visit(CPlusPlus::Declaration *symbol);
#endif
virtual bool visit(CPlusPlus::Class *symbol);
QString scopedSymbolName(const QString &symbolName) const;
QString scopedSymbolName(const CPlusPlus::Symbol *symbol) const;
QString symbolName(const CPlusPlus::Symbol *symbol) const;
void appendItem(const QString &name,
const QString &info,
ModelItemInfo::ItemType type,
const CPlusPlus::Symbol *symbol);
private:
QString findOrInsert(const QString &s)
{ return *strings.insert(s); }
QSet<QString> strings; // Used to avoid QString duplication
QString _scope;
CPlusPlus::Overview overview;
CPlusPlus::Icons icons;
QList<ModelItemInfo> items;
SymbolTypes symbolsToSearchFor;
bool separateScope;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(SearchSymbols::SymbolTypes)
......
......@@ -104,8 +104,9 @@
<widget class="QLabel" name="filesLabel">
<property name="text">
<string>The following files will be added:
f1
f2
</string>
</property>
<property name="textInteractionFlags">
......
......@@ -61,14 +61,6 @@ void ProFileReader::setQtVersion(QtVersion *qtVersion) {
bool ProFileReader::readProFile(const QString &fileName)
{
//disable caching -> list of include files is not updated otherwise
// ProFile *pro = proFileFromCache(fileName);
// if (!pro) {
// pro = new ProFile(fileName);
// if (!queryProFile(pro)) {
// delete pro;
// return false;
// }
// }
QString fn = QFileInfo(fileName).filePath();
ProFile *pro = new ProFile(fn);
if (!queryProFile(pro)) {
......@@ -82,9 +74,6 @@ bool ProFileReader::readProFile(const QString &fileName)
ProFile *ProFileReader::parsedProFile(const QString &fileName)
{
// ProFile *pro = proFileFromCache(fileName);
// if (pro)
// return pro;
QString fn = QFileInfo(fileName).filePath();
ProFile *pro = ProFileEvaluator::parsedProFile(fn);
if (pro) {
......@@ -99,16 +88,6 @@ void ProFileReader::releaseParsedProFile(ProFile *)
return;
}
ProFile *ProFileReader::proFileFromCache(const QString &fileName) const
{
QString fn = QFileInfo(fileName).filePath();
ProFile *pro = 0;
if (m_includeFiles.contains(fn))
pro = m_includeFiles.value(fn);
return pro;
}
QList<ProFile*> ProFileReader::includeFiles() const
{
QString qmakeMkSpecDir = propertyValue("QMAKE_MKSPECS");
......@@ -196,3 +175,14 @@ void ProFileReader::errorMessage(const QString &message)
{
emit errorFound(message);
}
ProFile *ProFileReader::proFileFor(const QString &name)
{
qDebug()<<"Asking for "<<name;
qDebug()<<"in "<<m_includeFiles.keys();
QMap<QString, ProFile *>::const_iterator it = m_includeFiles.constFind(name);
if (it == m_includeFiles.constEnd())
return 0;
else
return it.value();
}
......@@ -63,7 +63,7 @@ public:
const QString &baseDirectory,
PathValuesMode mode,
const ProFile *pro = 0) const;
ProFile *proFileFromCache(const QString &fileName) const;
ProFile *proFileFor(const QString &name);
signals:
void errorFound(const QString &error);
......
......@@ -79,35 +79,22 @@ namespace {
Implements abstract ProjectNode class
*/
Qt4PriFileNode::Qt4PriFileNode(Qt4Project *project,
const QString &filePath)
Qt4PriFileNode::Qt4PriFileNode(Qt4Project *project, Qt4ProFileNode* qt4ProFileNode, const QString &filePath)
: ProjectNode(filePath),
m_core(project->qt4ProjectManager()->core()),
m_project(project),
m_qt4ProFileNode(qt4ProFileNode),
m_projectFilePath(QDir::fromNativeSeparators(filePath)),
m_projectDir(QFileInfo(filePath).absolutePath()),
m_includeFile(0),
m_saveTimer(new QTimer(this)),
m_reader(0)
m_projectDir(QFileInfo(filePath).absolutePath())
{
Q_ASSERT(project);
setFolderName(QFileInfo(filePath).baseName());
setIcon(QIcon(":/qt4projectmanager/images/qt_project.png"));
// m_saveTimer is used for the delayed saving of the pro file
// so that multiple insert/remove calls in one event loop run
// trigger just one save call.
m_saveTimer->setSingleShot(true);
connect(m_saveTimer, SIGNAL(timeout()), this, SLOT(save()));
}
void Qt4PriFileNode::update(ProFile *includeFile, ProFileReader *reader)
{
Q_ASSERT(includeFile);
Q_ASSERT(reader);
m_reader = reader;
m_includeFile = includeFile;
// add project file node
if (m_fileNodes.isEmpty())
......@@ -175,47 +162,42 @@ void Qt4PriFileNode::update(ProFile *includeFile, ProFileReader *reader)
QList<ProjectNode::ProjectAction> Qt4PriFileNode::supportedActions() const
{
QList<ProjectAction> actions;
if (m_includeFile) {
const FolderNode *folderNode = this;
const Qt4ProFileNode *proFileNode;
while (!(proFileNode = qobject_cast<const Qt4ProFileNode*>(folderNode)))
folderNode = folderNode->parentFolderNode();
Q_ASSERT(proFileNode);
switch (proFileNode->projectType()) {
case ApplicationTemplate:
case LibraryTemplate:
actions << AddFile << RemoveFile;
break;
case SubDirsTemplate:
actions << AddSubProject << RemoveSubProject;
break;
default:
break;
}
const FolderNode *folderNode = this;
const Qt4ProFileNode *proFileNode;
while (!(proFileNode = qobject_cast<const Qt4ProFileNode*>(folderNode)))
folderNode = folderNode->parentFolderNode();
Q_ASSERT(proFileNode);
switch (proFileNode->projectType()) {
case ApplicationTemplate:
case LibraryTemplate:
actions << AddFile << RemoveFile;
break;
case SubDirsTemplate:
actions << AddSubProject << RemoveSubProject;
break;
default:
break;
}
return actions;
}
bool Qt4PriFileNode::addSubProjects(const QStringList &proFilePaths)
{
if (!m_includeFile)
return false;
return changeIncludes(m_includeFile, proFilePaths, AddToProFile);
Q_UNUSED(proFilePaths);
return false; //changeIncludes(m_includeFile, proFilePaths, AddToProFile);
}
bool Qt4PriFileNode::removeSubProjects(const QStringList &proFilePaths)
{
if (!m_includeFile)
return false;
return changeIncludes(m_includeFile, proFilePaths, RemoveFromProFile);
Q_UNUSED(proFilePaths);
return false; //changeIncludes(m_includeFile, proFilePaths, RemoveFromProFile);
}
bool Qt4PriFileNode::addFiles(const FileType fileType, const QStringList &filePaths,
QStringList *notAdded)
{
if (!m_includeFile)
return false;
QStringList failedFiles;
changeFiles(fileType, filePaths, &failedFiles, AddToProFile);
......@@ -227,8 +209,6 @@ bool Qt4PriFileNode::addFiles(const FileType fileType, const QStringList &filePa
bool Qt4PriFileNode::removeFiles(const FileType fileType, const QStringList &filePaths,
QStringList *notRemoved)
{
if (!m_includeFile)
return false;
QStringList failedFiles;
changeFiles(fileType, filePaths, &failedFiles, RemoveFromProFile);
if (notRemoved)
......@@ -239,7 +219,7 @@ bool Qt4PriFileNode::removeFiles(const FileType fileType, const QStringList &fil
bool Qt4PriFileNode::renameFile(const FileType fileType, const QString &filePath,