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

This commit is contained in:
mae
2008-12-10 11:50:35 +01:00
31 changed files with 355 additions and 83 deletions

View File

@@ -164,7 +164,15 @@ protected:
bool process_primary()
{
if ((*_lex)->is(T_INT_LITERAL)) {
_value.set_long(tokenSpell().toLong());
int base = 10;
const QByteArray spell = tokenSpell();
if (spell.at(0) == '0') {
if (spell.size() > 1 && (spell.at(1) == 'x' || spell.at(1) == 'X'))
base = 16;
else
base = 8;
}
_value.set_long(tokenSpell().toLong(0, base));
++(*_lex);
return true;
} else if (isTokenDefined()) {
@@ -367,7 +375,7 @@ protected:
{
process_xor();
while ((*_lex)->is(T_CARET)) {
while ((*_lex)->is(T_PIPE)) {
const Token op = *(*_lex);
++(*_lex);
@@ -481,12 +489,12 @@ void pp::operator () (const QByteArray &filename,
const QByteArray &source,
QByteArray *result)
{
const QByteArray previousFile = env.current_file;
env.current_file = filename;
const QByteArray previousFile = env.currentFile;
env.currentFile = filename;
operator () (source, result);
env.current_file = previousFile;
env.currentFile = previousFile;
}
pp::State pp::createStateFromSource(const QByteArray &source) const
@@ -518,7 +526,7 @@ void pp::operator()(const QByteArray &source, QByteArray *result)
result->append(QByteArray::number(_dot->lineno));
result->append(' ');
result->append('"');
result->append(env.current_file);
result->append(env.currentFile);
result->append('"');
result->append('\n');
} else {
@@ -844,6 +852,8 @@ void pp::processDefine(TokenIterator firstToken, TokenIterator lastToken)
}
Macro macro;
macro.fileName = env.currentFile;
macro.line = env.currentLine;
macro.name = tokenText(*tk);
++tk; // skip T_IDENTIFIER

View File

@@ -97,8 +97,6 @@ Macro *Environment::bind(const Macro &__macro)
Macro *m = new Macro (__macro);
m->hashcode = hash_code(m->name);
m->fileName = current_file;
m->line = currentLine;
if (++_macro_count == _allocated_macros) {
if (! _allocated_macros)
@@ -122,11 +120,13 @@ Macro *Environment::bind(const Macro &__macro)
return m;
}
Macro *Environment::remove (const QByteArray &name)
Macro *Environment::remove(const QByteArray &name)
{
Macro macro;
macro.name = name;
macro.hidden = true;
macro.fileName = currentFile;
macro.line = currentLine;
return bind(macro);
}

View File

@@ -94,7 +94,7 @@ private:
void rehash();
public:
QByteArray current_file;
QByteArray currentFile;
unsigned currentLine;
bool hide_next;

View File

@@ -73,7 +73,7 @@ const char *MacroExpander::operator () (const char *__first, const char *__last,
__result->append(QByteArray::number(env.currentLine));
__result->append(' ');
__result->append('"');
__result->append(env.current_file);
__result->append(env.currentFile);
__result->append('"');
__result->append('\n');
++lines;
@@ -218,7 +218,7 @@ const char *MacroExpander::operator () (const char *__first, const char *__last,
else if (fast_name == "__FILE__")
{
__result->append('"');
__result->append(env.current_file);
__result->append(env.currentFile);
__result->append('"');
continue;
}

View File

@@ -111,7 +111,7 @@ public:
}
if (variadics)
text += QLatin1String("...");
text += QLatin1Char(' ');
text += QLatin1Char(')');
}
text += QLatin1Char(' ');
text += QString::fromUtf8(definition.constData(), definition.size());

View File

@@ -36,13 +36,11 @@
#include <QtCore/QDebug>
#ifdef Q_OS_UNIX
// we do not use the 'do {...} while (0)' idiom here to be able to use
// 'break' and 'continue' as 'actions'.
#define QTC_ASSERT(cond, action) \
if(cond){}else{qDebug()<<"ASSERTION"<<#cond<<"FAILED"<<__FILE__<<__LINE__;action;}
#else
#define QTC_ASSERT(cond, action) \
if(cond){}else{qDebug()<<"ASSERTION"<<#cond<<"FAILED";action;}
#endif
#endif // QTC_ASSERT_H

View File

@@ -520,6 +520,15 @@ void CPPEditor::jumpToDefinition()
#endif
}
} else {
foreach (const Document::MacroUse use, doc->macroUses()) {
if (use.contains(endOfName - 1)) {
const Macro &macro = use.macro();
const QString fileName = QString::fromUtf8(macro.fileName);
if (TextEditor::BaseTextEditor::openEditorAt(fileName, macro.line, 0))
return; // done
}
}
qDebug() << "No results for expression:" << expression;
}
}

View File

@@ -0,0 +1,50 @@
/***************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
**
** Non-Open Source Usage
**
** Licensees may use this file in accordance with the Qt Beta Version
** License Agreement, Agreement version 2.2 provided with the Software or,
** alternatively, in accordance with the terms contained in a written
** agreement between you and Nokia.
**
** GNU General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the packaging
** of this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
**
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt GPL Exception
** version 1.2, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/
#include "cppfunctionsfilter.h"
using namespace CppTools::Internal;
CppFunctionsFilter::CppFunctionsFilter(CppModelManager *manager, Core::EditorManager *editorManager)
: CppQuickOpenFilter(manager, editorManager)
{
setShortcutString("m");
setIncludedByDefault(false);
search.setSymbolsToSearchFor(SearchSymbols::Functions);
search.setSeparateScope(true);
}
CppFunctionsFilter::~CppFunctionsFilter()
{
}

View File

@@ -0,0 +1,58 @@
/***************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Qt Software Information (qt-info@nokia.com)
**
**
** Non-Open Source Usage
**
** Licensees may use this file in accordance with the Qt Beta Version
** License Agreement, Agreement version 2.2 provided with the Software or,
** alternatively, in accordance with the terms contained in a written
** agreement between you and Nokia.
**
** GNU General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU General
** Public License versions 2.0 or 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the packaging
** of this file. Please review the following information to ensure GNU
** General Public Licensing requirements will be met:
**
** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
** http://www.gnu.org/copyleft/gpl.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt GPL Exception
** version 1.2, included in the file GPL_EXCEPTION.txt in this package.
**
***************************************************************************/
#ifndef CPPFUNCTIONSFILTER_H
#define CPPFUNCTIONSFILTER_H
#include <cppquickopenfilter.h>
namespace CppTools {
namespace Internal {
class CppFunctionsFilter : public CppQuickOpenFilter
{
Q_OBJECT
public:
CppFunctionsFilter(CppModelManager *manager, Core::EditorManager *editorManager);
~CppFunctionsFilter();
QString trName() const { return tr("Methods"); }
QString name() const { return QLatin1String("Methods"); }
Priority priority() const { return Medium; }
};
} // namespace Internal
} // namespace CppTools
#endif // CPPFUNCTIONSFILTER_H

View File

@@ -390,17 +390,17 @@ void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type)
} else {
Document::Ptr previousDoc = switchDocument(Document::create(fileName));
const QByteArray previousFile = env.current_file;
const QByteArray previousFile = env.currentFile;
const unsigned previousLine = env.currentLine;
env.current_file = QByteArray(m_currentDoc->translationUnit()->fileName(),
m_currentDoc->translationUnit()->fileNameLength());
env.currentFile = QByteArray(m_currentDoc->translationUnit()->fileName(),
m_currentDoc->translationUnit()->fileNameLength());
QByteArray preprocessedCode;
m_proc(contents, &preprocessedCode);
//qDebug() << preprocessedCode;
env.current_file = previousFile;
env.currentFile = previousFile;
env.currentLine = previousLine;
m_currentDoc->setSource(preprocessedCode);

View File

@@ -75,6 +75,12 @@ void CppQuickOpenFilter::refresh(QFutureInterface<void> &future)
Q_UNUSED(future);
}
static bool compareLexigraphically(const QuickOpen::FilterEntry &a,
const QuickOpen::FilterEntry &b)
{
return a.displayName < b.displayName;
}
QList<QuickOpen::FilterEntry> CppQuickOpenFilter::matchesFor(const QString &origEntry)
{
QString entry = trimWildcards(origEntry);
@@ -109,6 +115,9 @@ QList<QuickOpen::FilterEntry> CppQuickOpenFilter::matchesFor(const QString &orig
}
}
if (entries.size() < 1000)
qSort(entries.begin(), entries.end(), compareLexigraphically);
return entries;
}

View File

@@ -34,6 +34,7 @@
#include "cpptools.h"
#include "cppclassesfilter.h"
#include "cppcodecompletion.h"
#include "cppfunctionsfilter.h"
#include "cpphoverhandler.h"
#include "cppmodelmanager.h"
#include "cpptoolsconstants.h"
@@ -89,6 +90,7 @@ bool CppToolsPlugin::initialize(const QStringList & /*arguments*/, QString *)
m_core->editorManager());
addAutoReleasedObject(quickOpenFilter);
addAutoReleasedObject(new CppClassesFilter(m_modelManager, m_core->editorManager()));
addAutoReleasedObject(new CppFunctionsFilter(m_modelManager, m_core->editorManager()));
// Menus
Core::IActionContainer *mtools = am->actionContainer(Core::Constants::M_TOOLS);

View File

@@ -10,15 +10,16 @@ unix:QMAKE_CXXFLAGS_DEBUG += -O3
INCLUDEPATH += .
DEFINES += CPPTOOLS_LIBRARY
CONFIG += help
HEADERS += cpptools_global.h \
cppquickopenfilter.h \
cppclassesfilter.h \
searchsymbols.h
searchsymbols.h \
cppfunctionsfilter.h
SOURCES += cppquickopenfilter.cpp \
cpptoolseditorsupport.cpp \
cppclassesfilter.cpp \
searchsymbols.cpp
searchsymbols.cpp \
cppfunctionsfilter.cpp
# Input
SOURCES += cpptools.cpp \

View File

@@ -35,6 +35,7 @@
#include <Literals.h>
#include <Scope.h>
#include <Names.h>
using namespace CPlusPlus;
using namespace CppTools::Internal;
@@ -97,12 +98,24 @@ bool SearchSymbols::visit(Function *symbol)
if (!(symbolsToSearchFor & Functions))
return false;
QString extraScope;
if (Name *name = symbol->name()) {
if (QualifiedNameId *nameId = name->asQualifiedNameId()) {
if (nameId->nameCount() > 1) {
extraScope = overview.prettyName(nameId->nameAt(nameId->nameCount() - 2));
}
}
}
QString fullScope = _scope;
if (!_scope.isEmpty() && !extraScope.isEmpty())
fullScope += QLatin1String("::");
fullScope += extraScope;
QString name = symbolName(symbol);
QString scopedName = scopedSymbolName(name);
QString type = overview.prettyType(symbol->type(),
separateScope ? symbol->name() : 0);
separateScope ? symbol->identity() : 0);
appendItem(separateScope ? type : scopedName,
separateScope ? _scope : type,
separateScope ? fullScope : type,
ModelItemInfo::Method, symbol);
return false;
}
@@ -153,7 +166,7 @@ bool SearchSymbols::visit(Class *symbol)
QString SearchSymbols::scopedSymbolName(const QString &symbolName) const
{
QString name = _scope;
if (! name.isEmpty())
if (!name.isEmpty())
name += QLatin1String("::");
name += symbolName;
return name;
@@ -196,6 +209,9 @@ void SearchSymbols::appendItem(const QString &name,
ModelItemInfo::ItemType type,
const Symbol *symbol)
{
if (!symbol->name())
return;
const QIcon icon = icons.iconForSymbol(symbol);
items.append(ModelItemInfo(name, info, type,
QString::fromUtf8(symbol->fileName(), symbol->fileNameLength()),

View File

@@ -34,7 +34,8 @@
#include "breakhandler.h"
#include "imports.h" // TextEditor::BaseTextMark
#include "qtcassert.h"
#include <utils/qtcassert.h>
#include <QtCore/QDebug>
#include <QtCore/QFileInfo>

View File

@@ -10,8 +10,6 @@ include(../../plugins/texteditor/texteditor.pri)
include(../../plugins/cpptools/cpptools.pri)
include(../../libs/cplusplus/cplusplus.pri)
INCLUDEPATH += ../../libs/utils
# DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII
QT += gui network script

View File

@@ -39,7 +39,6 @@
#include "gdboptionpage.h"
#include "gdbengine.h"
#include "mode.h"
#include "qtcassert.h"
#include <coreplugin/actionmanager/actionmanagerinterface.h>
#include <coreplugin/coreconstants.h>
@@ -48,20 +47,27 @@
#include <coreplugin/messagemanager.h>
#include <coreplugin/modemanager.h>
#include <coreplugin/uniqueidmanager.h>
#include <cplusplus/ExpressionUnderCursor.h>
#include <cppeditor/cppeditorconstants.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/session.h>
#include <texteditor/basetexteditor.h>
#include <texteditor/basetextmark.h>
#include <texteditor/itexteditor.h>
#include <texteditor/texteditorconstants.h>
#include <texteditor/basetexteditor.h>
#include <utils/qtcassert.h>
#include <QtCore/QDebug>
#include <QtCore/qplugin.h>
#include <QtCore/QObject>
#include <QtCore/QPoint>
#include <QtCore/QSettings>
#include <QtGui/QPlainTextEdit>
#include <QtGui/QTextBlock>
#include <QtGui/QTextCursor>

View File

@@ -37,7 +37,6 @@
#include "debuggermanager.h"
#include "gdbmi.h"
#include "procinterrupt.h"
#include "qtcassert.h"
#include "disassemblerhandler.h"
#include "breakhandler.h"
@@ -49,6 +48,8 @@
#include "startexternaldialog.h"
#include "attachexternaldialog.h"
#include <utils/qtcassert.h>
#include <QtCore/QDebug>
#include <QtCore/QDir>
#include <QtCore/QFileInfo>

View File

@@ -32,10 +32,10 @@
***************************************************************************/
#include "gdbmi.h"
#include "qtcassert.h"
#include <utils/qtcassert.h>
#include <QtCore/QByteArray>
#include <QtCore/QDebug>
#include <QtCore/QTextStream>
namespace Debugger {

View File

@@ -35,7 +35,6 @@
#include "debuggerconstants.h"
#include "debuggermanager.h"
#include "qtcassert.h"
#include <coreplugin/coreconstants.h>
#include <coreplugin/icore.h>
@@ -48,10 +47,14 @@
#include <coreplugin/outputpane.h>
#include <coreplugin/navigationwidget.h>
#include <coreplugin/rightpane.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <utils/qtcassert.h>
#include <QtCore/QDebug>
#include <QtCore/QSettings>
#include <QtGui/QDockWidget>
#include <QtGui/QLabel>
#include <QtGui/QMainWindow>

View File

@@ -33,19 +33,18 @@
#include "scriptengine.h"
#include "qtcassert.h"
#include "attachexternaldialog.h"
#include "breakhandler.h"
#include "debuggerconstants.h"
#include "debuggermanager.h"
#include "disassemblerhandler.h"
#include "breakhandler.h"
#include "moduleshandler.h"
#include "registerhandler.h"
#include "stackhandler.h"
#include "startexternaldialog.h"
#include "watchhandler.h"
#include "startexternaldialog.h"
#include "attachexternaldialog.h"
#include <utils/qtcassert.h>
#include <QtCore/QDateTime>
#include <QtCore/QDebug>

View File

@@ -33,7 +33,7 @@
#include "stackhandler.h"
#include "qtcassert.h"
#include <utils/qtcassert.h>
#include <QtCore/QAbstractTableModel>
#include <QtCore/QDebug>

View File

@@ -37,7 +37,7 @@
#include "modeltest.h"
#endif
#include "qtcassert.h"
#include <utils/qtcassert.h>
#include <QtCore/QDebug>
#include <QtCore/QEvent>
@@ -118,7 +118,7 @@ static QByteArray quoteUnprintable(const QByteArray &ba)
QByteArray res;
char buf[10];
for (int i = 0, n = ba.size(); i != n; ++i) {
char c = ba.at(i);
unsigned char c = ba.at(i);
if (isprint(c)) {
res += c;
} else {

View File

@@ -314,8 +314,8 @@ void ProjectNode::addProjectNodes(const QList<ProjectNode*> &subProjects)
emit watcher->foldersAboutToBeAdded(this, folderNodes);
foreach (ProjectNode *project, subProjects) {
Q_ASSERT_X(!project->parentFolderNode(), "addProjectNodes",
"Project node has already a parent");
QTC_ASSERT(!project->parentFolderNode(),
qDebug("Project node has already a parent"));
project->setParentFolderNode(this);
foreach (NodesWatcher *watcher, m_watchers)
project->registerWatcher(watcher);
@@ -353,13 +353,13 @@ void ProjectNode::removeProjectNodes(const QList<ProjectNode*> &subProjects)
for (; toRemoveIter != toRemove.constEnd(); ++toRemoveIter) {
while ((*projectIter)->path() != (*toRemoveIter)->path()) {
++projectIter;
Q_ASSERT_X(projectIter != m_subProjectNodes.end(), "removeProjectNodes",
"Project to remove is not part of specified folder!");
QTC_ASSERT(projectIter != m_subProjectNodes.end(),
qDebug("Project to remove is not part of specified folder!"));
}
while ((*folderIter)->path() != (*toRemoveIter)->path()) {
++folderIter;
Q_ASSERT_X(folderIter != m_subFolderNodes.end(), "removeProjectNodes",
"Project to remove is not part of specified folder!");
QTC_ASSERT(folderIter != m_subFolderNodes.end(),
qDebug("Project to remove is not part of specified folder!"));
}
delete *projectIter;
projectIter = m_subProjectNodes.erase(projectIter);
@@ -386,15 +386,15 @@ void ProjectNode::addFolderNodes(const QList<FolderNode*> &subFolders, FolderNod
watcher->foldersAboutToBeAdded(parentFolder, subFolders);
foreach (FolderNode *folder, subFolders) {
Q_ASSERT_X(!folder->parentFolderNode(), "addFolderNodes",
"Project node has already a parent folder");
QTC_ASSERT(!folder->parentFolderNode(),
qDebug("Project node has already a parent folder"));
folder->setParentFolderNode(parentFolder);
folder->setProjectNode(this);
parentFolder->m_subFolderNodes.append(folder);
// project nodes have to be added via addProjectNodes
Q_ASSERT_X(folder->nodeType() != ProjectNodeType, "addFolderNodes",
"project nodes have to be added via addProjectNodes");
QTC_ASSERT(folder->nodeType() != ProjectNodeType,
qDebug("project nodes have to be added via addProjectNodes"));
}
qSort(parentFolder->m_subFolderNodes.begin(), parentFolder->m_subFolderNodes.end(),
sortNodesByPath);
@@ -427,12 +427,12 @@ void ProjectNode::removeFolderNodes(const QList<FolderNode*> &subFolders,
QList<FolderNode*>::const_iterator toRemoveIter = toRemove.constBegin();
QList<FolderNode*>::iterator folderIter = parentFolder->m_subFolderNodes.begin();
for (; toRemoveIter != toRemove.constEnd(); ++toRemoveIter) {
Q_ASSERT_X(((*toRemoveIter)->nodeType() != ProjectNodeType), "removeFolderNodes",
"project nodes have to be removed via removeProjectNodes");
QTC_ASSERT((*toRemoveIter)->nodeType() != ProjectNodeType,
qDebug("project nodes have to be removed via removeProjectNodes"));
while ((*folderIter)->path() != (*toRemoveIter)->path()) {
++folderIter;
Q_ASSERT_X(folderIter != parentFolder->m_subFolderNodes.end(), "removeFileNodes",
"Folder to remove is not part of specified folder!");
QTC_ASSERT(folderIter != parentFolder->m_subFolderNodes.end(),
qDebug("Folder to remove is not part of specified folder!"));
}
delete *folderIter;
folderIter = parentFolder->m_subFolderNodes.erase(folderIter);
@@ -460,8 +460,8 @@ void ProjectNode::addFileNodes(const QList<FileNode*> &files, FolderNode *folder
emit watcher->filesAboutToBeAdded(folder, files);
foreach (FileNode *file, files) {
Q_ASSERT_X(!file->parentFolderNode(), "addFileNodes",
"File node has already a parent folder");
QTC_ASSERT(!file->parentFolderNode(),
qDebug("File node has already a parent folder"));
file->setParentFolderNode(folder);
file->setProjectNode(this);
@@ -499,8 +499,8 @@ void ProjectNode::removeFileNodes(const QList<FileNode*> &files, FolderNode *fol
for (; toRemoveIter != toRemove.constEnd(); ++toRemoveIter) {
while ((*filesIter)->path() != (*toRemoveIter)->path()) {
++filesIter;
Q_ASSERT_X(filesIter != folder->m_fileNodes.end(), "removeFileNodes",
"File to remove is not part of specified folder!");
QTC_ASSERT(filesIter != folder->m_fileNodes.end(),
qDebug("File to remove is not part of specified folder!"));
}
delete *filesIter;
filesIter = folder->m_fileNodes.erase(filesIter);
@@ -591,8 +591,8 @@ void SessionNode::addProjectNodes(const QList<ProjectNode*> &projectNodes)
emit watcher->foldersAboutToBeAdded(this, folderNodes);
foreach (ProjectNode *project, projectNodes) {
Q_ASSERT_X(!project->parentFolderNode(), "addProjectNodes",
"Project node has already a parent folder");
QTC_ASSERT(!project->parentFolderNode(),
qDebug("Project node has already a parent folder"));
project->setParentFolderNode(this);
foreach (NodesWatcher *watcher, m_watchers)
project->registerWatcher(watcher);
@@ -621,13 +621,13 @@ void SessionNode::removeProjectNodes(const QList<ProjectNode*> &projectNodes)
for (; toRemoveIter != toRemove.constEnd(); ++toRemoveIter) {
while ((*projectIter)->path() != (*toRemoveIter)->path()) {
++projectIter;
Q_ASSERT_X(projectIter != m_projectNodes.end(), "removeProjectNodes",
"Project to remove is not part of specified folder!");
QTC_ASSERT(projectIter != m_projectNodes.end(),
qDebug("Project to remove is not part of specified folder!"));
}
while ((*folderIter)->path() != (*toRemoveIter)->path()) {
++folderIter;
Q_ASSERT_X(folderIter != m_subFolderNodes.end(), "removeProjectNodes",
"Project to remove is not part of specified folder!");
QTC_ASSERT(folderIter != m_subFolderNodes.end(),
qDebug("Project to remove is not part of specified folder!"));
}
projectIter = m_projectNodes.erase(projectIter);
folderIter = m_subFolderNodes.erase(folderIter);

View File

@@ -257,7 +257,7 @@ TaskWindow::TaskWindow()
m_listview->setModel(m_model);
m_listview->setFrameStyle(QFrame::NoFrame);
m_listview->setWindowTitle(tr("Problems"));
m_listview->setWindowTitle(tr("Build Issues"));
m_listview->setSelectionMode(QAbstractItemView::SingleSelection);
TaskDelegate *tld = new TaskDelegate(this);
m_listview->setItemDelegate(tld);

View File

@@ -63,7 +63,7 @@ public:
QWidget *outputWidget(QWidget *);
QList<QWidget*> toolBarWidgets(void) const;
QString name() const { return tr("Problems"); }
QString name() const { return tr("Build Issues"); }
int priorityInStatusBar() const;
void clearContents();
void visibilityChanged(bool visible);

View File

@@ -203,5 +203,59 @@ void DirectoryWatcher::updateFileList(const QString &dir)
}
}
int FileWatcher::m_objectCount = 0;
QHash<QString,int> FileWatcher::m_fileCount;
QFileSystemWatcher *FileWatcher::m_watcher = 0;
FileWatcher::FileWatcher(QObject *parent)
{
if (!m_watcher)
m_watcher = new QFileSystemWatcher();
++m_objectCount;
connect(m_watcher, SIGNAL(fileChanged(QString)),
this, SLOT(slotFileChanged(QString)));
}
FileWatcher::~FileWatcher()
{
foreach (const QString &file, m_files)
removeFile(file);
if (--m_objectCount == 0) {
delete m_watcher;
m_watcher = 0;
}
}
void FileWatcher::slotFileChanged(const QString &file)
{
if (m_files.contains(file))
emit fileChanged(file);
}
QStringList FileWatcher::files()
{
return m_files;
}
void FileWatcher::addFile(const QString &file)
{
if (m_files.contains(file))
return;
m_files += file;
if (m_fileCount[file] == 0)
m_watcher->addPath(file);
m_fileCount[file] += 1;
}
void FileWatcher::removeFile(const QString &file)
{
m_files.removeOne(file);
m_fileCount[file] -= 1;
if (m_fileCount[file] == 0)
m_watcher->removePath(file);
}
} // namespace Internal
} // namespace Qt4ProjectManager

View File

@@ -87,6 +87,31 @@ private:
FileModificationTimeMap m_files;
};
class FileWatcher : public QObject
{
Q_DISABLE_COPY(FileWatcher)
Q_OBJECT
public:
explicit FileWatcher(QObject *parent = 0);
virtual ~FileWatcher();
QStringList files();
void addFile(const QString &file);
void removeFile(const QString &file);
signals:
void fileChanged(const QString &path);
void debugOutout(const QString &path);
private slots:
void slotFileChanged(const QString&);
private:
static int m_objectCount;
static QHash<QString, int> m_fileCount;
static QFileSystemWatcher *m_watcher;
QStringList m_files;
};
} // namespace Internal
} // namespace Qt4ProjectManager

View File

@@ -87,11 +87,20 @@ Qt4PriFileNode::Qt4PriFileNode(Qt4Project *project, Qt4ProFileNode* qt4ProFileNo
m_project(project),
m_qt4ProFileNode(qt4ProFileNode),
m_projectFilePath(QDir::fromNativeSeparators(filePath)),
m_projectDir(QFileInfo(filePath).absolutePath())
m_projectDir(QFileInfo(filePath).absolutePath()),
m_fileWatcher(new FileWatcher(this))
{
QTC_ASSERT(project, return);
setFolderName(QFileInfo(filePath).baseName());
setIcon(QIcon(":/qt4projectmanager/images/qt_project.png"));
m_fileWatcher->addFile(filePath);
connect(m_fileWatcher, SIGNAL(fileChanged(QString)),
this, SLOT(scheduleUpdate()));
}
void Qt4PriFileNode::scheduleUpdate()
{
m_qt4ProFileNode->scheduleUpdate();
}
void Qt4PriFileNode::update(ProFile *includeFile, ProFileReader *reader)
@@ -495,12 +504,17 @@ Qt4ProFileNode::Qt4ProFileNode(Qt4Project *project,
if (parent)
setParent(parent);
m_updateTimer.setInterval(100);
m_updateTimer.setSingleShot(true);
connect(m_dirWatcher, SIGNAL(directoryChanged(const QString&)),
this, SLOT(update()));
this, SLOT(updateGeneratedFiles()));
connect(m_dirWatcher, SIGNAL(fileChanged(const QString&)),
this, SLOT(fileChanged(const QString&)));
connect(m_project, SIGNAL(activeBuildConfigurationChanged()),
this, SLOT(update()));
connect(&m_updateTimer, SIGNAL(timeout()),
this, SLOT(update()));
}
Qt4ProFileNode::~Qt4ProFileNode()
@@ -523,6 +537,11 @@ QStringList Qt4ProFileNode::variableValue(const Qt4Variable var) const
return m_varValues.value(var);
}
void Qt4ProFileNode::scheduleUpdate()
{
m_updateTimer.start();
}
void Qt4ProFileNode::update()
{
ProFileReader *reader = createProFileReader();
@@ -681,9 +700,11 @@ void Qt4ProFileNode::update()
void Qt4ProFileNode::fileChanged(const QString &filePath)
{
qDebug()<<"+++++"<<filePath;
CppTools::CppModelManagerInterface *modelManager =
ExtensionSystem::PluginManager::instance()->getObject<CppTools::CppModelManagerInterface>();
// TODO compress
modelManager->updateSourceFiles(QStringList() << filePath);
}
@@ -731,11 +752,16 @@ void Qt4ProFileNode::updateGeneratedFiles()
// update generated files
// Already existing FileNodes
QList<FileNode*> existingFileNodes;
foreach (FileNode *file, fileNodes()) {
if (file->isGenerated())
existingFileNodes << file;
}
// Convert uiFile to uiHeaderFilePath, find all headers that correspond
// and try to find them in uicDirs
QStringList newFilePaths;
foreach (const QString &uicDir, m_varValues[UiDirVar]) {
foreach (FileNode *uiFile, uiFiles) {

View File

@@ -75,6 +75,7 @@ using ProjectExplorer::FileType;
class ProFileReader;
class DirectoryWatcher;
class FileWatcher;
// Type of projects
enum Qt4ProjectType {
@@ -142,6 +143,9 @@ protected:
QString buildDir() const;
ProFileReader *createProFileReader() const;
private slots:
void scheduleUpdate();
private:
void save(ProFile *includeFile);
bool priFileWritable(const QString &path);
@@ -151,7 +155,10 @@ private:
Qt4ProFileNode *m_qt4ProFileNode;
QString m_projectFilePath;
QString m_projectDir;
QTimer *m_saveTimer;
// TODO we might be better off using an IFile* and the FileManager for
// watching changes to the .pro and .pri files on disk
FileWatcher *m_fileWatcher;
// managed by Qt4ProFileNode
friend class Qt4ProFileNode;
@@ -174,14 +181,13 @@ public:
QStringList variableValue(const Qt4Variable var) const;
public slots:
void scheduleUpdate();
void update();
private slots:
void fileChanged(const QString &filePath);
private:
void updateGeneratedFiles();
private:
Qt4ProFileNode *createSubProFileNode(const QString &path);
QStringList uiDirPaths(ProFileReader *reader) const;
@@ -197,9 +203,9 @@ private:
Qt4ProjectType m_projectType;
QHash<Qt4Variable, QStringList> m_varValues;
bool m_isQBuildProject;
QTimer m_updateTimer;
DirectoryWatcher *m_dirWatcher;
friend class Qt4NodeHierarchy;
};

View File

@@ -265,7 +265,7 @@ Qt4Project::~Qt4Project()
void Qt4Project::defaultQtVersionChanged()
{
if (qtVersionId(activeBuildConfiguration()) == 0)
update();
m_rootProjectNode->update();
}
void Qt4Project::qtVersionsChanged()
@@ -274,7 +274,7 @@ void Qt4Project::qtVersionsChanged()
if (!qt4ProjectManager()->versionManager()->version(qtVersionId(bc))->isValid()) {
setQtVersion(bc, 0);
if (bc == activeBuildConfiguration())
update();
m_rootProjectNode->update();
}
}
}
@@ -507,9 +507,9 @@ void Qt4Project::updateCodeModel()
}
/*!
Updates complete project
*/
///*!
// Updates complete project
// */
void Qt4Project::update()
{
// TODO Maybe remove this method completely?