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:
hjk
2008-12-05 16:40:19 +01:00
22 changed files with 302 additions and 260 deletions

View File

@@ -950,24 +950,23 @@
You can start Qt Creator from a command prompt with an existing session or 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. \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 You can show and hide the the sidebar in \gui Edit and \gui Debug mode by
by clicking on the corresponding icon on the left bottom. clicking on the corresponding icon, or by pressing \key{Alt+0}.
Keyboard shortcut is \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 If you have an instance of a class that is derived from QObject, and you
want to find all other objects connected to one of its you would like to find all other objects connected to one of your object's
slots by Qt's signals-and-slots mechanism, enable slots using Qt's signals and slots mechanism -- you can enable
\gui{Debug} and \gui{Use Custom Display for Qt Objects}. \gui{Use Custom Display for Qt Objects} feature under the \gui Debug menu.
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.
\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 If the special debugging of Qt objects fails due to data
corruption within the debugged objects, you can switch the corruption within the debugged objects, you can switch the
@@ -983,33 +982,38 @@
\title Glossary \title Glossary
\bold{System Qt} \table
\header
\o Term
\o Meaning
\target glossary-system-qt \row
The version of Qt installed on your system. \o System Qt \target glossary-system-qt
This is the one whose \c qmake command is found in the \c PATH. \o The version of Qt installed on your system. This is the Qt
version for the \c qmake command found in your \c PATH.
\bold{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.
\target glossary-default-qt \row
The version of Qt configured in \gui{Tools \o Project Qt \target glossary-project-qt
-> Options -> Qt 4 -> Default Qt Version}. This is the version \o The version of Qt configured in \gui{Build&Run -> Build
used by new projects. It defaults to the System Qt. Settings -> Build Configurations}. This is the Qt version that
is actually used by a particular project. It defaults to
Default Qt.
\bold{Project Qt} \row
\o Shadow Build \target glossary-shadow-build
\target glossary-project-qt \o Shadow building means building a project in a separate
The version of Qt configured in \gui{Build&Run directory, the \e{build directory}. The build directory is
-> Build Settings -> Build Configurations}. This is the version different from the source directory. One of the benefits of
actually used by the project. It defaults to the Default Qt. shadow building is that it keeps your source directory clean.
Shadow building is the best practice if you need many build
\bold{Shadow Build} configurations for a single set of source.
\endtable
\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.
*/ */

View File

@@ -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())) if (symbol->isFunction() || (symbol->isDeclaration() && symbol->type()->isFunction()))
{ {
Function *function = symbol->asFunction(); const Function *function = symbol->asFunction();
if (!function) if (!function)
function = symbol->type()->asFunction(); function = symbol->type()->asFunction();

View File

@@ -47,7 +47,7 @@ class CPLUSPLUS_EXPORT Icons
public: public:
Icons(); Icons();
QIcon iconForSymbol(Symbol *symbol) const; QIcon iconForSymbol(const Symbol *symbol) const;
QIcon keywordIcon() const; QIcon keywordIcon() const;
QIcon macroIcon() const; QIcon macroIcon() const;

View File

@@ -30,6 +30,7 @@
** version 1.2, included in the file GPL_EXCEPTION.txt in this package. ** version 1.2, included in the file GPL_EXCEPTION.txt in this package.
** **
***************************************************************************/ ***************************************************************************/
#ifndef PATHCHOOSER_H #ifndef PATHCHOOSER_H
#define PATHCHOOSER_H #define PATHCHOOSER_H

View File

@@ -79,6 +79,7 @@
#include <QtGui/QComboBox> #include <QtGui/QComboBox>
#include <QtGui/QTreeView> #include <QtGui/QTreeView>
#include <QtGui/QHeaderView> #include <QtGui/QHeaderView>
#include <QtGui/QStringListModel>
using namespace CPlusPlus; using namespace CPlusPlus;
using namespace CppEditor::Internal; using namespace CppEditor::Internal;
@@ -202,7 +203,9 @@ void CPPEditor::createToolBar(CPPEditorEditable *editable)
m_methodCombo->setMaxVisibleItems(20); m_methodCombo->setMaxVisibleItems(20);
m_overviewModel = new OverviewModel(this); 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(m_methodCombo, SIGNAL(activated(int)), this, SLOT(jumpToMethod(int)));
connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(updateMethodBoxIndex())); connect(this, SIGNAL(cursorPositionChanged()), this, SLOT(updateMethodBoxIndex()));
@@ -315,9 +318,16 @@ void CPPEditor::onDocumentUpdated(Document::Ptr doc)
return; return;
m_overviewModel->rebuild(doc); m_overviewModel->rebuild(doc);
if (m_overviewModel->rowCount() > 0) {
if (m_methodCombo->model() != m_overviewModel)
m_methodCombo->setModel(m_overviewModel);
OverviewTreeView *treeView = static_cast<OverviewTreeView *>(m_methodCombo->view()); OverviewTreeView *treeView = static_cast<OverviewTreeView *>(m_methodCombo->view());
treeView->sync(); treeView->sync();
updateMethodBoxIndex(); updateMethodBoxIndex();
} else {
if (m_methodCombo->model() != m_noSymbolsModel)
m_methodCombo->setModel(m_noSymbolsModel);
}
} }
void CPPEditor::updateFileName() void CPPEditor::updateFileName()
@@ -325,6 +335,8 @@ void CPPEditor::updateFileName()
void CPPEditor::jumpToMethod(int) void CPPEditor::jumpToMethod(int)
{ {
if (m_methodCombo->model() != m_overviewModel)
return;
QModelIndex index = m_methodCombo->view()->currentIndex(); QModelIndex index = m_methodCombo->view()->currentIndex();
Symbol *symbol = m_overviewModel->symbolFromIndex(index); Symbol *symbol = m_overviewModel->symbolFromIndex(index);
if (! symbol) if (! symbol)
@@ -339,12 +351,14 @@ void CPPEditor::jumpToMethod(int)
void CPPEditor::updateMethodBoxIndex() void CPPEditor::updateMethodBoxIndex()
{ {
if (m_methodCombo->model() != m_overviewModel)
return;
int line = 0, column = 0; int line = 0, column = 0;
convertPosition(position(), &line, &column); convertPosition(position(), &line, &column);
QModelIndex lastIndex; QModelIndex lastIndex;
const int rc = m_overviewModel->rowCount(QModelIndex()); const int rc = m_overviewModel->rowCount();
for (int row = 0; row < rc; ++row) { for (int row = 0; row < rc; ++row) {
const QModelIndex index = m_overviewModel->index(row, 0, QModelIndex()); const QModelIndex index = m_overviewModel->index(row, 0, QModelIndex());
Symbol *symbol = m_overviewModel->symbolFromIndex(index); Symbol *symbol = m_overviewModel->symbolFromIndex(index);

View File

@@ -42,6 +42,7 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QAction; class QAction;
class QComboBox; class QComboBox;
class QStringListModel;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace Core { namespace Core {
@@ -138,6 +139,7 @@ private:
QList<int> m_contexts; QList<int> m_contexts;
QComboBox *m_methodCombo; QComboBox *m_methodCombo;
CPlusPlus::OverviewModel *m_overviewModel; CPlusPlus::OverviewModel *m_overviewModel;
QStringListModel *m_noSymbolsModel;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -42,6 +42,7 @@ CppClassesFilter::CppClassesFilter(CppModelManager *manager, Core::EditorManager
setIncludedByDefault(false); setIncludedByDefault(false);
search.setSymbolsToSearchFor(SearchSymbols::Classes); search.setSymbolsToSearchFor(SearchSymbols::Classes);
search.setSeparateScope(true);
} }
CppClassesFilter::~CppClassesFilter() CppClassesFilter::~CppClassesFilter()

View File

@@ -683,7 +683,7 @@ void CppModelManager::onDocumentUpdated(Document::Ptr doc)
sel.cursor = c; sel.cursor = c;
selections.append(sel); selections.append(sel);
} }
ed->setExtraExtraSelections(selections); ed->setExtraSelections(TextEditor::BaseTextEditor::CodeWarningsSelection, selections);
break; break;
} }
} }

View File

@@ -40,7 +40,8 @@ using namespace CPlusPlus;
using namespace CppTools::Internal; using namespace CppTools::Internal;
SearchSymbols::SearchSymbols(): SearchSymbols::SearchSymbols():
symbolsToSearchFor(Classes | Functions | Enums) symbolsToSearchFor(Classes | Functions | Enums),
separateScope(false)
{ {
} }
@@ -49,6 +50,11 @@ void SearchSymbols::setSymbolsToSearchFor(SymbolTypes types)
symbolsToSearchFor = types; symbolsToSearchFor = types;
} }
void SearchSymbols::setSeparateScope(bool separateScope)
{
this->separateScope = separateScope;
}
QList<ModelItemInfo> SearchSymbols::operator()(Document::Ptr doc, const QString &scope) QList<ModelItemInfo> SearchSymbols::operator()(Document::Ptr doc, const QString &scope)
{ {
QString previousScope = switchScope(scope); QString previousScope = switchScope(scope);
@@ -73,13 +79,12 @@ bool SearchSymbols::visit(Enum *symbol)
return false; return false;
QString name = symbolName(symbol); QString name = symbolName(symbol);
QString previousScope = switchScope(name); QString scopedName = scopedSymbolName(name);
QIcon icon = icons.iconForSymbol(symbol); QString previousScope = switchScope(scopedName);
appendItem(separateScope ? name : scopedName,
separateScope ? previousScope : QString(),
ModelItemInfo::Enum, symbol);
Scope *members = symbol->members(); 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) { for (unsigned i = 0; i < members->symbolCount(); ++i) {
accept(members->symbolAt(i)); accept(members->symbolAt(i));
} }
@@ -93,18 +98,18 @@ bool SearchSymbols::visit(Function *symbol)
return false; return false;
QString name = symbolName(symbol); QString name = symbolName(symbol);
QString type = overview.prettyType(symbol->type()); QString scopedName = scopedSymbolName(name);
QIcon icon = icons.iconForSymbol(symbol); QString type = overview.prettyType(symbol->type(),
items.append(ModelItemInfo(name, type, ModelItemInfo::Method, separateScope ? symbol->name() : 0);
QString::fromUtf8(symbol->fileName(), symbol->fileNameLength()), appendItem(separateScope ? type : scopedName,
symbol->line(), separateScope ? _scope : type,
icon)); ModelItemInfo::Method, symbol);
return false; return false;
} }
bool SearchSymbols::visit(Namespace *symbol) bool SearchSymbols::visit(Namespace *symbol)
{ {
QString name = symbolName(symbol); QString name = findOrInsert(scopedSymbolName(symbol));
QString previousScope = switchScope(name); QString previousScope = switchScope(name);
Scope *members = symbol->members(); Scope *members = symbol->members();
for (unsigned i = 0; i < members->symbolCount(); ++i) { for (unsigned i = 0; i < members->symbolCount(); ++i) {
@@ -118,12 +123,9 @@ bool SearchSymbols::visit(Namespace *symbol)
bool SearchSymbols::visit(Declaration *symbol) bool SearchSymbols::visit(Declaration *symbol)
{ {
if (symbol->type()->isFunction()) { if (symbol->type()->isFunction()) {
QString name = symbolName(symbol); QString name = scopedSymbolName(symbol);
QString type = overview.prettyType(symbol->type()); QString type = overview.prettyType(symbol->type());
//QIcon icon = ...; appendItems(name, type, ModelItemInfo::Method, symbol->fileName());
items.append(ModelItemInfo(name, type, ModelItemInfo::Method,
QString::fromUtf8(symbol->fileName(), symbol->line()),
symbol->line()));
} }
return false; return false;
} }
@@ -135,12 +137,11 @@ bool SearchSymbols::visit(Class *symbol)
return false; return false;
QString name = symbolName(symbol); QString name = symbolName(symbol);
QString previousScope = switchScope(name); QString scopedName = scopedSymbolName(name);
QIcon icon = icons.iconForSymbol(symbol); QString previousScope = switchScope(scopedName);
items.append(ModelItemInfo(name, QString(), ModelItemInfo::Class, appendItem(separateScope ? name : scopedName,
QString::fromUtf8(symbol->fileName(), symbol->fileNameLength()), separateScope ? previousScope : QString(),
symbol->line(), ModelItemInfo::Class, symbol);
icon));
Scope *members = symbol->members(); Scope *members = symbol->members();
for (unsigned i = 0; i < members->symbolCount(); ++i) { for (unsigned i = 0; i < members->symbolCount(); ++i) {
accept(members->symbolAt(i)); accept(members->symbolAt(i));
@@ -149,11 +150,22 @@ bool SearchSymbols::visit(Class *symbol)
return false; return false;
} }
QString SearchSymbols::symbolName(const Symbol *symbol) const QString SearchSymbols::scopedSymbolName(const QString &symbolName) const
{ {
QString name = _scope; QString name = _scope;
if (! name.isEmpty()) if (! name.isEmpty())
name += QLatin1String("::"); 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()); QString symbolName = overview.prettyName(symbol->name());
if (symbolName.isEmpty()) { if (symbolName.isEmpty()) {
QString type; QString type;
@@ -176,6 +188,17 @@ QString SearchSymbols::symbolName(const Symbol *symbol) const
symbolName += type; symbolName += type;
symbolName += QLatin1String(">"); symbolName += QLatin1String(">");
} }
name += symbolName; return symbolName;
return name; }
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));
} }

View File

@@ -92,6 +92,7 @@ public:
SearchSymbols(); SearchSymbols();
void setSymbolsToSearchFor(SymbolTypes types); void setSymbolsToSearchFor(SymbolTypes types);
void setSeparateScope(bool separateScope);
QList<ModelItemInfo> operator()(CPlusPlus::Document::Ptr doc) QList<ModelItemInfo> operator()(CPlusPlus::Document::Ptr doc)
{ return operator()(doc, QString()); } { return operator()(doc, QString()); }
@@ -113,14 +114,27 @@ protected:
virtual bool visit(CPlusPlus::Declaration *symbol); virtual bool visit(CPlusPlus::Declaration *symbol);
#endif #endif
virtual bool visit(CPlusPlus::Class *symbol); 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; QString symbolName(const CPlusPlus::Symbol *symbol) const;
void appendItem(const QString &name,
const QString &info,
ModelItemInfo::ItemType type,
const CPlusPlus::Symbol *symbol);
private: private:
QString findOrInsert(const QString &s)
{ return *strings.insert(s); }
QSet<QString> strings; // Used to avoid QString duplication
QString _scope; QString _scope;
CPlusPlus::Overview overview; CPlusPlus::Overview overview;
CPlusPlus::Icons icons; CPlusPlus::Icons icons;
QList<ModelItemInfo> items; QList<ModelItemInfo> items;
SymbolTypes symbolsToSearchFor; SymbolTypes symbolsToSearchFor;
bool separateScope;
}; };
Q_DECLARE_OPERATORS_FOR_FLAGS(SearchSymbols::SymbolTypes) Q_DECLARE_OPERATORS_FOR_FLAGS(SearchSymbols::SymbolTypes)

View File

@@ -104,8 +104,9 @@
<widget class="QLabel" name="filesLabel"> <widget class="QLabel" name="filesLabel">
<property name="text"> <property name="text">
<string>The following files will be added: <string>The following files will be added:
f1
f2
</string> </string>
</property> </property>
<property name="textInteractionFlags"> <property name="textInteractionFlags">

View File

@@ -61,14 +61,6 @@ void ProFileReader::setQtVersion(QtVersion *qtVersion) {
bool ProFileReader::readProFile(const QString &fileName) bool ProFileReader::readProFile(const QString &fileName)
{ {
//disable caching -> list of include files is not updated otherwise //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(); QString fn = QFileInfo(fileName).filePath();
ProFile *pro = new ProFile(fn); ProFile *pro = new ProFile(fn);
if (!queryProFile(pro)) { if (!queryProFile(pro)) {
@@ -82,9 +74,6 @@ bool ProFileReader::readProFile(const QString &fileName)
ProFile *ProFileReader::parsedProFile(const QString &fileName) ProFile *ProFileReader::parsedProFile(const QString &fileName)
{ {
// ProFile *pro = proFileFromCache(fileName);
// if (pro)
// return pro;
QString fn = QFileInfo(fileName).filePath(); QString fn = QFileInfo(fileName).filePath();
ProFile *pro = ProFileEvaluator::parsedProFile(fn); ProFile *pro = ProFileEvaluator::parsedProFile(fn);
if (pro) { if (pro) {
@@ -99,16 +88,6 @@ void ProFileReader::releaseParsedProFile(ProFile *)
return; 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 QList<ProFile*> ProFileReader::includeFiles() const
{ {
QString qmakeMkSpecDir = propertyValue("QMAKE_MKSPECS"); QString qmakeMkSpecDir = propertyValue("QMAKE_MKSPECS");
@@ -196,3 +175,14 @@ void ProFileReader::errorMessage(const QString &message)
{ {
emit errorFound(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();
}

View File

@@ -63,7 +63,7 @@ public:
const QString &baseDirectory, const QString &baseDirectory,
PathValuesMode mode, PathValuesMode mode,
const ProFile *pro = 0) const; const ProFile *pro = 0) const;
ProFile *proFileFromCache(const QString &fileName) const; ProFile *proFileFor(const QString &name);
signals: signals:
void errorFound(const QString &error); void errorFound(const QString &error);

View File

@@ -79,35 +79,22 @@ namespace {
Implements abstract ProjectNode class Implements abstract ProjectNode class
*/ */
Qt4PriFileNode::Qt4PriFileNode(Qt4Project *project, Qt4PriFileNode::Qt4PriFileNode(Qt4Project *project, Qt4ProFileNode* qt4ProFileNode, const QString &filePath)
const QString &filePath)
: ProjectNode(filePath), : ProjectNode(filePath),
m_core(project->qt4ProjectManager()->core()),
m_project(project), m_project(project),
m_qt4ProFileNode(qt4ProFileNode),
m_projectFilePath(QDir::fromNativeSeparators(filePath)), m_projectFilePath(QDir::fromNativeSeparators(filePath)),
m_projectDir(QFileInfo(filePath).absolutePath()), m_projectDir(QFileInfo(filePath).absolutePath())
m_includeFile(0),
m_saveTimer(new QTimer(this)),
m_reader(0)
{ {
Q_ASSERT(project); Q_ASSERT(project);
setFolderName(QFileInfo(filePath).baseName()); setFolderName(QFileInfo(filePath).baseName());
setIcon(QIcon(":/qt4projectmanager/images/qt_project.png")); 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) void Qt4PriFileNode::update(ProFile *includeFile, ProFileReader *reader)
{ {
Q_ASSERT(includeFile); Q_ASSERT(includeFile);
Q_ASSERT(reader); Q_ASSERT(reader);
m_reader = reader;
m_includeFile = includeFile;
// add project file node // add project file node
if (m_fileNodes.isEmpty()) if (m_fileNodes.isEmpty())
@@ -175,7 +162,7 @@ void Qt4PriFileNode::update(ProFile *includeFile, ProFileReader *reader)
QList<ProjectNode::ProjectAction> Qt4PriFileNode::supportedActions() const QList<ProjectNode::ProjectAction> Qt4PriFileNode::supportedActions() const
{ {
QList<ProjectAction> actions; QList<ProjectAction> actions;
if (m_includeFile) {
const FolderNode *folderNode = this; const FolderNode *folderNode = this;
const Qt4ProFileNode *proFileNode; const Qt4ProFileNode *proFileNode;
while (!(proFileNode = qobject_cast<const Qt4ProFileNode*>(folderNode))) while (!(proFileNode = qobject_cast<const Qt4ProFileNode*>(folderNode)))
@@ -193,29 +180,24 @@ QList<ProjectNode::ProjectAction> Qt4PriFileNode::supportedActions() const
default: default:
break; break;
} }
}
return actions; return actions;
} }
bool Qt4PriFileNode::addSubProjects(const QStringList &proFilePaths) bool Qt4PriFileNode::addSubProjects(const QStringList &proFilePaths)
{ {
if (!m_includeFile) Q_UNUSED(proFilePaths);
return false; return false; //changeIncludes(m_includeFile, proFilePaths, AddToProFile);
return changeIncludes(m_includeFile, proFilePaths, AddToProFile);
} }
bool Qt4PriFileNode::removeSubProjects(const QStringList &proFilePaths) bool Qt4PriFileNode::removeSubProjects(const QStringList &proFilePaths)
{ {
if (!m_includeFile) Q_UNUSED(proFilePaths);
return false; return false; //changeIncludes(m_includeFile, proFilePaths, RemoveFromProFile);
return changeIncludes(m_includeFile, proFilePaths, RemoveFromProFile);
} }
bool Qt4PriFileNode::addFiles(const FileType fileType, const QStringList &filePaths, bool Qt4PriFileNode::addFiles(const FileType fileType, const QStringList &filePaths,
QStringList *notAdded) QStringList *notAdded)
{ {
if (!m_includeFile)
return false;
QStringList failedFiles; QStringList failedFiles;
changeFiles(fileType, filePaths, &failedFiles, AddToProFile); 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, bool Qt4PriFileNode::removeFiles(const FileType fileType, const QStringList &filePaths,
QStringList *notRemoved) QStringList *notRemoved)
{ {
if (!m_includeFile)
return false;
QStringList failedFiles; QStringList failedFiles;
changeFiles(fileType, filePaths, &failedFiles, RemoveFromProFile); changeFiles(fileType, filePaths, &failedFiles, RemoveFromProFile);
if (notRemoved) if (notRemoved)
@@ -239,7 +219,7 @@ bool Qt4PriFileNode::removeFiles(const FileType fileType, const QStringList &fil
bool Qt4PriFileNode::renameFile(const FileType fileType, const QString &filePath, bool Qt4PriFileNode::renameFile(const FileType fileType, const QString &filePath,
const QString &newFilePath) const QString &newFilePath)
{ {
if (!m_includeFile || newFilePath.isEmpty()) if (newFilePath.isEmpty())
return false; return false;
if (!QFile::rename(filePath, newFilePath)) if (!QFile::rename(filePath, newFilePath))
@@ -268,18 +248,19 @@ bool Qt4PriFileNode::changeIncludes(ProFile *includeFile, const QStringList &pro
bool Qt4PriFileNode::priFileWritable(const QString &path) bool Qt4PriFileNode::priFileWritable(const QString &path)
{ {
const QString dir = QFileInfo(path).dir().path(); const QString dir = QFileInfo(path).dir().path();
Core::IVersionControl *versionControl = m_core->vcsManager()->findVersionControlForDirectory(dir); Core::ICore *core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>();
switch (Core::EditorManager::promptReadOnlyFile(path, versionControl, m_core->mainWindow(), false)) { Core::IVersionControl *versionControl = core->vcsManager()->findVersionControlForDirectory(dir);
switch (Core::EditorManager::promptReadOnlyFile(path, versionControl, core->mainWindow(), false)) {
case Core::EditorManager::RO_OpenVCS: case Core::EditorManager::RO_OpenVCS:
if (!versionControl->vcsOpen(path)) { if (!versionControl->vcsOpen(path)) {
QMessageBox::warning(m_core->mainWindow(), tr("Failed!"), tr("Could not open the file for edit with SCC.")); QMessageBox::warning(core->mainWindow(), tr("Failed!"), tr("Could not open the file for edit with SCC."));
return false; return false;
} }
break; break;
case Core::EditorManager::RO_MakeWriteable: { case Core::EditorManager::RO_MakeWriteable: {
const bool permsOk = QFile::setPermissions(path, QFile::permissions(path) | QFile::WriteUser); const bool permsOk = QFile::setPermissions(path, QFile::permissions(path) | QFile::WriteUser);
if (!permsOk) { if (!permsOk) {
QMessageBox::warning(m_core->mainWindow(), tr("Failed!"), tr("Could not set permissions to writable.")); QMessageBox::warning(core->mainWindow(), tr("Failed!"), tr("Could not set permissions to writable."));
return false; return false;
} }
break; break;
@@ -296,11 +277,13 @@ bool Qt4PriFileNode::saveModifiedEditors(const QString &path)
QList<Core::IFile*> allFileHandles; QList<Core::IFile*> allFileHandles;
QList<Core::IFile*> modifiedFileHandles; QList<Core::IFile*> modifiedFileHandles;
foreach (Core::IFile *file, m_core->fileManager()->managedFiles(path)) { Core::ICore *core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>();
foreach (Core::IFile *file, core->fileManager()->managedFiles(path)) {
allFileHandles << file; allFileHandles << file;
} }
foreach (Core::IEditor *editor, m_core->editorManager()->editorsForFileName(path)) { foreach (Core::IEditor *editor, core->editorManager()->editorsForFileName(path)) {
if (Core::IFile *editorFile = editor->file()) { if (Core::IFile *editorFile = editor->file()) {
if (editorFile->isModified()) if (editorFile->isModified())
modifiedFileHandles << editorFile; modifiedFileHandles << editorFile;
@@ -309,7 +292,7 @@ bool Qt4PriFileNode::saveModifiedEditors(const QString &path)
if (!modifiedFileHandles.isEmpty()) { if (!modifiedFileHandles.isEmpty()) {
bool cancelled; bool cancelled;
m_core->fileManager()->saveModifiedFiles(modifiedFileHandles, &cancelled, core->fileManager()->saveModifiedFiles(modifiedFileHandles, &cancelled,
tr("There are unsaved changes for project file %1.").arg(path)); tr("There are unsaved changes for project file %1.").arg(path));
if (cancelled) if (cancelled)
return false; return false;
@@ -330,6 +313,18 @@ void Qt4PriFileNode::changeFiles(const FileType fileType,
if (filePaths.isEmpty()) if (filePaths.isEmpty())
return; return;
ProFileReader *reader = m_qt4ProFileNode->createProFileReader();
if (!reader->readProFile(m_qt4ProFileNode->path())) {
m_project->proFileParseError(tr("Error while parsing file %1. Giving up.").arg(m_projectFilePath));
delete reader;
return;
}
ProFile *includeFile = reader->proFileFor(m_projectFilePath);
if(!includeFile) {
m_project->proFileParseError(tr("Error while changing pro file %1.").arg(m_projectFilePath));
}
*notChanged = filePaths; *notChanged = filePaths;
// Check for modified editors // Check for modified editors
@@ -338,7 +333,7 @@ void Qt4PriFileNode::changeFiles(const FileType fileType,
// Check if file is readonly // Check if file is readonly
ProEditorModel proModel; ProEditorModel proModel;
proModel.setProFiles(QList<ProFile*>() << m_includeFile); proModel.setProFiles(QList<ProFile*>() << includeFile);
const QStringList vars = varNames(fileType); const QStringList vars = varNames(fileType);
QDir priFileDir = QDir(m_projectDir); QDir priFileDir = QDir(m_projectDir);
@@ -413,26 +408,27 @@ void Qt4PriFileNode::changeFiles(const FileType fileType,
} }
// save file // save file
if (!m_saveTimer->isActive()) save(includeFile);
m_saveTimer->start(); delete reader;
} }
void Qt4PriFileNode::save() void Qt4PriFileNode::save(ProFile *includeFile)
{ {
Core::FileManager *fileManager = m_core->fileManager(); Core::ICore *core = ExtensionSystem::PluginManager::instance()->getObject<Core::ICore>();
QList<Core::IFile *> allFileHandles = fileManager->managedFiles(m_includeFile->fileName()); Core::FileManager *fileManager = core->fileManager();
QList<Core::IFile *> allFileHandles = fileManager->managedFiles(includeFile->fileName());
Core::IFile *modifiedFileHandle = 0; Core::IFile *modifiedFileHandle = 0;
foreach(Core::IFile *file, allFileHandles) foreach(Core::IFile *file, allFileHandles)
if (file->fileName() == m_includeFile->fileName()) if (file->fileName() == includeFile->fileName())
modifiedFileHandle = file; modifiedFileHandle = file;
if (modifiedFileHandle) if (modifiedFileHandle)
fileManager->blockFileChange(modifiedFileHandle); fileManager->blockFileChange(modifiedFileHandle);
ProWriter pw; ProWriter pw;
const bool ok = pw.write(m_includeFile, m_includeFile->fileName()); const bool ok = pw.write(includeFile, includeFile->fileName());
Q_UNUSED(ok) Q_UNUSED(ok)
m_includeFile->setModified(false); includeFile->setModified(false);
m_project->qt4ProjectManager()->notifyChanged(m_includeFile->fileName()); m_project->qt4ProjectManager()->notifyChanged(includeFile->fileName());
if (modifiedFileHandle) if (modifiedFileHandle)
fileManager->unblockFileChange(modifiedFileHandle); fileManager->unblockFileChange(modifiedFileHandle);
@@ -487,12 +483,11 @@ QStringList Qt4PriFileNode::varNames(FileType type)
Qt4ProFileNode::Qt4ProFileNode(Qt4Project *project, Qt4ProFileNode::Qt4ProFileNode(Qt4Project *project,
const QString &filePath, const QString &filePath,
QObject *parent) QObject *parent)
: Qt4PriFileNode(project, filePath), : Qt4PriFileNode(project, this, filePath),
// own stuff // own stuff
m_projectType(InvalidProject), m_projectType(InvalidProject),
m_isQBuildProject(false), m_isQBuildProject(false),
m_dirWatcher(new DirectoryWatcher(this)), m_dirWatcher(new DirectoryWatcher(this))
m_reader(0)
{ {
if (parent) if (parent)
setParent(parent); setParent(parent);
@@ -507,7 +502,7 @@ Qt4ProFileNode::Qt4ProFileNode(Qt4Project *project,
Qt4ProFileNode::~Qt4ProFileNode() Qt4ProFileNode::~Qt4ProFileNode()
{ {
delete m_reader;
} }
bool Qt4ProFileNode::hasTargets() const bool Qt4ProFileNode::hasTargets() const
@@ -527,11 +522,10 @@ QStringList Qt4ProFileNode::variableValue(const Qt4Variable var) const
void Qt4ProFileNode::update() void Qt4ProFileNode::update()
{ {
delete m_reader; ProFileReader *reader = createProFileReader();
m_reader = createProFileReader(); if (!reader->readProFile(m_projectFilePath)) {
if (!m_reader->readProFile(m_projectFilePath)) {
m_project->proFileParseError(tr("Error while parsing file %1. Giving up.").arg(m_projectFilePath)); m_project->proFileParseError(tr("Error while parsing file %1. Giving up.").arg(m_projectFilePath));
delete m_reader; delete reader;
invalidate(); invalidate();
return; return;
} }
@@ -546,7 +540,7 @@ void Qt4ProFileNode::update()
#endif #endif
Qt4ProjectType projectType = InvalidProject; Qt4ProjectType projectType = InvalidProject;
switch (m_reader->templateType()) { switch (reader->templateType()) {
case ProFileEvaluator::TT_Unknown: case ProFileEvaluator::TT_Unknown:
case ProFileEvaluator::TT_Application: { case ProFileEvaluator::TT_Application: {
projectType = ApplicationTemplate; projectType = ApplicationTemplate;
@@ -585,11 +579,11 @@ void Qt4ProFileNode::update()
ProFile *fileForCurrentProject = 0; ProFile *fileForCurrentProject = 0;
{ {
if (projectType == SubDirsTemplate) { if (projectType == SubDirsTemplate) {
foreach (const QString &subDirProject, subDirsPaths(m_reader)) foreach (const QString &subDirProject, subDirsPaths(reader))
newProjectFiles << subDirProject; newProjectFiles << subDirProject;
} }
foreach (ProFile *includeFile, m_reader->includeFiles()) { foreach (ProFile *includeFile, reader->includeFiles()) {
if (includeFile->fileName() == m_projectFilePath) { // this file if (includeFile->fileName() == m_projectFilePath) { // this file
fileForCurrentProject = includeFile; fileForCurrentProject = includeFile;
} else { } else {
@@ -616,9 +610,9 @@ void Qt4ProFileNode::update()
} else if ((*existingNodeIter)->path() > *newProjectFileIter) { } else if ((*existingNodeIter)->path() > *newProjectFileIter) {
if (ProFile *file = includeFiles.value(*newProjectFileIter)) { if (ProFile *file = includeFiles.value(*newProjectFileIter)) {
Qt4PriFileNode *priFileNode Qt4PriFileNode *priFileNode
= new Qt4PriFileNode(m_project, = new Qt4PriFileNode(m_project, this,
*newProjectFileIter); *newProjectFileIter);
priFileNode->update(file, m_reader); priFileNode->update(file, reader);
toAdd << priFileNode; toAdd << priFileNode;
} else { } else {
toAdd << createSubProFileNode(*newProjectFileIter); toAdd << createSubProFileNode(*newProjectFileIter);
@@ -627,7 +621,7 @@ void Qt4ProFileNode::update()
} else { // *existingNodeIter->path() == *newProjectFileIter } else { // *existingNodeIter->path() == *newProjectFileIter
if (ProFile *file = includeFiles.value(*newProjectFileIter)) { if (ProFile *file = includeFiles.value(*newProjectFileIter)) {
Qt4PriFileNode *priFileNode = static_cast<Qt4PriFileNode*>(*existingNodeIter); Qt4PriFileNode *priFileNode = static_cast<Qt4PriFileNode*>(*existingNodeIter);
priFileNode->update(file, m_reader); priFileNode->update(file, reader);
} }
++existingNodeIter; ++existingNodeIter;
@@ -641,9 +635,9 @@ void Qt4ProFileNode::update()
while (newProjectFileIter != newProjectFiles.constEnd()) { while (newProjectFileIter != newProjectFiles.constEnd()) {
if (ProFile *file = includeFiles.value(*newProjectFileIter)) { if (ProFile *file = includeFiles.value(*newProjectFileIter)) {
Qt4PriFileNode *priFileNode Qt4PriFileNode *priFileNode
= new Qt4PriFileNode(m_project, = new Qt4PriFileNode(m_project, this,
*newProjectFileIter); *newProjectFileIter);
priFileNode->update(file, m_reader); priFileNode->update(file, reader);
toAdd << priFileNode; toAdd << priFileNode;
} else { } else {
toAdd << createSubProFileNode(*newProjectFileIter); toAdd << createSubProFileNode(*newProjectFileIter);
@@ -656,15 +650,15 @@ void Qt4ProFileNode::update()
if (!toAdd.isEmpty()) if (!toAdd.isEmpty())
addProjectNodes(toAdd); addProjectNodes(toAdd);
Qt4PriFileNode::update(fileForCurrentProject, m_reader); Qt4PriFileNode::update(fileForCurrentProject, reader);
// update other variables // update other variables
QHash<Qt4Variable, QStringList> newVarValues; QHash<Qt4Variable, QStringList> newVarValues;
newVarValues[CxxCompilerVar] << m_reader->value(QLatin1String("QMAKE_CXX")); newVarValues[CxxCompilerVar] << reader->value(QLatin1String("QMAKE_CXX"));
newVarValues[DefinesVar] = m_reader->values(QLatin1String("DEFINES")); newVarValues[DefinesVar] = reader->values(QLatin1String("DEFINES"));
newVarValues[IncludePathVar] = includePaths(m_reader); newVarValues[IncludePathVar] = includePaths(reader);
newVarValues[UiDirVar] = uiDirPaths(m_reader); newVarValues[UiDirVar] = uiDirPaths(reader);
newVarValues[MocDirVar] = mocDirPaths(m_reader); newVarValues[MocDirVar] = mocDirPaths(reader);
if (m_varValues != newVarValues) { if (m_varValues != newVarValues) {
m_varValues = newVarValues; m_varValues = newVarValues;
@@ -678,12 +672,14 @@ void Qt4ProFileNode::update()
foreach (NodesWatcher *watcher, watchers()) foreach (NodesWatcher *watcher, watchers())
if (Qt4NodesWatcher *qt4Watcher = qobject_cast<Qt4NodesWatcher*>(watcher)) if (Qt4NodesWatcher *qt4Watcher = qobject_cast<Qt4NodesWatcher*>(watcher))
emit qt4Watcher->proFileUpdated(this); emit qt4Watcher->proFileUpdated(this);
delete reader;
} }
void Qt4ProFileNode::fileChanged(const QString &filePath) void Qt4ProFileNode::fileChanged(const QString &filePath)
{ {
CppTools::CppModelManagerInterface *modelManager = CppTools::CppModelManagerInterface *modelManager =
m_core->pluginManager()->getObject<CppTools::CppModelManagerInterface>(); ExtensionSystem::PluginManager::instance()->getObject<CppTools::CppModelManagerInterface>();
modelManager->updateSourceFiles(QStringList() << filePath); modelManager->updateSourceFiles(QStringList() << filePath);
} }
@@ -789,7 +785,7 @@ void Qt4ProFileNode::updateGeneratedFiles()
} }
} }
ProFileReader *Qt4ProFileNode::createProFileReader() const ProFileReader *Qt4PriFileNode::createProFileReader() const
{ {
ProFileReader *reader = new ProFileReader(); ProFileReader *reader = new ProFileReader();
connect(reader, SIGNAL(errorFound(const QString &)), connect(reader, SIGNAL(errorFound(const QString &)),
@@ -801,7 +797,7 @@ ProFileReader *Qt4ProFileNode::createProFileReader() const
} }
QHash<QString,QStringList> variables; QHash<QString,QStringList> variables;
variables.insert(QLatin1String("OUT_PWD"), QStringList(buildDir())); variables.insert(QLatin1String("OUT_PWD"), QStringList(m_qt4ProFileNode->buildDir()));
reader->addVariables(variables); reader->addVariables(variables);
return reader; return reader;
@@ -916,7 +912,7 @@ QStringList Qt4ProFileNode::qBuildSubDirsPaths(const QString &scanDir) const
return subProjectPaths; return subProjectPaths;
} }
QString Qt4ProFileNode::buildDir() const QString Qt4PriFileNode::buildDir() const
{ {
const QDir srcDirRoot = QFileInfo(m_project->rootProjectNode()->path()).absoluteDir(); const QDir srcDirRoot = QFileInfo(m_project->rootProjectNode()->path()).absoluteDir();
const QString relativeDir = srcDirRoot.relativeFilePath(m_projectDir); const QString relativeDir = srcDirRoot.relativeFilePath(m_projectDir);
@@ -951,11 +947,6 @@ void Qt4ProFileNode::invalidate()
} }
ProFile *Qt4ProFileNode::proFileFromCache(const QString &fileName)
{
return m_reader->proFileFromCache(fileName);
}
Qt4NodesWatcher::Qt4NodesWatcher(QObject *parent) Qt4NodesWatcher::Qt4NodesWatcher(QObject *parent)
: NodesWatcher(parent) : NodesWatcher(parent)
{ {

View File

@@ -102,8 +102,7 @@ class Qt4PriFileNode : public ProjectExplorer::ProjectNode {
Q_OBJECT Q_OBJECT
Q_DISABLE_COPY(Qt4PriFileNode) Q_DISABLE_COPY(Qt4PriFileNode)
public: public:
Qt4PriFileNode(Qt4Project *project, Qt4PriFileNode(Qt4Project *project, Qt4ProFileNode* qt4ProFileNode, const QString &filePath);
const QString &filePath);
void update(ProFile *includeFile, ProFileReader *reader); void update(ProFile *includeFile, ProFileReader *reader);
@@ -122,9 +121,6 @@ public:
bool renameFile(const FileType fileType, bool renameFile(const FileType fileType,
const QString &filePath, const QString &newFilePath); const QString &filePath, const QString &newFilePath);
private slots:
void save();
protected: protected:
void clear(); void clear();
static QStringList varNames(FileType type); static QStringList varNames(FileType type);
@@ -143,17 +139,19 @@ protected:
QStringList *notChanged, QStringList *notChanged,
ChangeType change); ChangeType change);
QString buildDir() const;
ProFileReader *createProFileReader() const;
private: private:
void save(ProFile *includeFile);
bool priFileWritable(const QString &path); bool priFileWritable(const QString &path);
bool saveModifiedEditors(const QString &path); bool saveModifiedEditors(const QString &path);
Core::ICore *m_core;
Qt4Project *m_project; Qt4Project *m_project;
Qt4ProFileNode *m_qt4ProFileNode;
QString m_projectFilePath; QString m_projectFilePath;
QString m_projectDir; QString m_projectDir;
ProFile *m_includeFile;
QTimer *m_saveTimer; QTimer *m_saveTimer;
ProFileReader *m_reader;
// managed by Qt4ProFileNode // managed by Qt4ProFileNode
friend class Qt4ProFileNode; friend class Qt4ProFileNode;
@@ -174,7 +172,6 @@ public:
Qt4ProjectType projectType() const; Qt4ProjectType projectType() const;
QStringList variableValue(const Qt4Variable var) const; QStringList variableValue(const Qt4Variable var) const;
ProFile *proFileFromCache(const QString &fileName);
public slots: public slots:
void update(); void update();
@@ -185,7 +182,6 @@ private slots:
private: private:
void updateGeneratedFiles(); void updateGeneratedFiles();
ProFileReader *createProFileReader() const;
Qt4ProFileNode *createSubProFileNode(const QString &path); Qt4ProFileNode *createSubProFileNode(const QString &path);
QStringList uiDirPaths(ProFileReader *reader) const; QStringList uiDirPaths(ProFileReader *reader) const;
@@ -194,7 +190,7 @@ private:
QStringList subDirsPaths(ProFileReader *reader) const; QStringList subDirsPaths(ProFileReader *reader) const;
QStringList qBuildSubDirsPaths(const QString &scanDir) const; QStringList qBuildSubDirsPaths(const QString &scanDir) const;
QString buildDir() const;
void invalidate(); void invalidate();
@@ -203,7 +199,6 @@ private:
bool m_isQBuildProject; bool m_isQBuildProject;
DirectoryWatcher *m_dirWatcher; DirectoryWatcher *m_dirWatcher;
ProFileReader *m_reader;
friend class Qt4NodeHierarchy; friend class Qt4NodeHierarchy;
}; };

View File

@@ -179,12 +179,8 @@ Qt4ProjectFile::Qt4ProjectFile(Qt4Project *project, const QString &filePath, QOb
bool Qt4ProjectFile::save(const QString &) bool Qt4ProjectFile::save(const QString &)
{ {
ProFile *file = m_project->proFileFromCache(m_filePath); // This is never used
ProWriter pw; return false;
bool ok = pw.write(file, file->fileName());
file->setModified(false);
m_project->qt4ProjectManager()->notifyChanged(file->fileName());
return ok;
} }
QString Qt4ProjectFile::fileName() const QString Qt4ProjectFile::fileName() const
@@ -209,7 +205,7 @@ QString Qt4ProjectFile::mimeType() const
bool Qt4ProjectFile::isModified() const bool Qt4ProjectFile::isModified() const
{ {
return m_project->proFileFromCache(m_filePath)->isModified(); return false; // we save after changing anyway
} }
bool Qt4ProjectFile::isReadOnly() const bool Qt4ProjectFile::isReadOnly() const
@@ -895,16 +891,24 @@ MakeStep *Qt4Project::makeStep() const
return 0; return 0;
} }
ProFile *Qt4Project::proFileFromCache(const QString &fileName) bool Qt4Project::hasSubNode(Qt4PriFileNode *root, const QString &path)
{ {
return rootProjectNode()->proFileFromCache(fileName); if (root->path() == path)
return true;
foreach (FolderNode *fn, root->subFolderNodes()) {
if (qobject_cast<Qt4ProFileNode *>(fn)) {
// we aren't interested in pro file nodes
} else if(Qt4PriFileNode *qt4prifilenode = qobject_cast<Qt4PriFileNode *>(fn)) {
if (hasSubNode(qt4prifilenode, path))
return true;
}
}
return false;
} }
void Qt4Project::findProFile(const QString& fileName, Qt4ProFileNode *root, QList<Qt4ProFileNode *> &list) void Qt4Project::findProFile(const QString& fileName, Qt4ProFileNode *root, QList<Qt4ProFileNode *> &list)
{ {
if (root->path() == fileName) if (hasSubNode(root, fileName))
list.append(root);
else if (root->proFileFromCache(fileName))
list.append(root); list.append(root);
foreach (FolderNode *fn, root->subFolderNodes()) foreach (FolderNode *fn, root->subFolderNodes())
@@ -914,9 +918,10 @@ void Qt4Project::findProFile(const QString& fileName, Qt4ProFileNode *root, QLis
void Qt4Project::notifyChanged(const QString &name) void Qt4Project::notifyChanged(const QString &name)
{ {
if (files(Qt4Project::ExcludeGeneratedFiles).contains(name)) {
QList<Qt4ProFileNode *> list; QList<Qt4ProFileNode *> list;
findProFile(name, rootProjectNode(), list); findProFile(name, rootProjectNode(), list);
foreach(Qt4ProFileNode *node, list) foreach(Qt4ProFileNode *node, list)
node->update(); node->update();
}
} }

View File

@@ -180,7 +180,6 @@ public:
QMakeStep *qmakeStep() const; QMakeStep *qmakeStep() const;
MakeStep *makeStep() const; MakeStep *makeStep() const;
ProFile *proFileFromCache(const QString &fileName);
void notifyChanged(const QString &name); void notifyChanged(const QString &name);
public slots: public slots:
@@ -209,6 +208,7 @@ protected:
private: private:
static void collectApplicationProFiles(QList<Internal::Qt4ProFileNode *> &list, Internal::Qt4ProFileNode *node); static void collectApplicationProFiles(QList<Internal::Qt4ProFileNode *> &list, Internal::Qt4ProFileNode *node);
static void findProFile(const QString& fileName, Internal::Qt4ProFileNode *root, QList<Internal::Qt4ProFileNode *> &list); static void findProFile(const QString& fileName, Internal::Qt4ProFileNode *root, QList<Internal::Qt4ProFileNode *> &list);
static bool hasSubNode(Internal::Qt4PriFileNode *root, const QString &path);
QList<Internal::Qt4ProFileNode *> m_applicationProFileChange; QList<Internal::Qt4ProFileNode *> m_applicationProFileChange;
ProjectExplorer::ProjectExplorerPlugin *projectExplorer() const; ProjectExplorer::ProjectExplorerPlugin *projectExplorer() const;

View File

@@ -963,7 +963,7 @@ void QtVersion::updateVersionInfo() const
QString line = stream.readLine(); QString line = stream.readLine();
int index = line.indexOf(":"); int index = line.indexOf(":");
if (index != -1) if (index != -1)
m_versionInfo.insert(line.left(index), line.mid(index+1)); m_versionInfo.insert(line.left(index), QDir::fromNativeSeparators(line.mid(index+1)));
} }
} }
@@ -1035,6 +1035,7 @@ void QtVersion::updateMkSpec() const
mkspec = mkspec.mid(QString("$$QT_BUILD_TREE/mkspecs/").length()); mkspec = mkspec.mid(QString("$$QT_BUILD_TREE/mkspecs/").length());
else if (mkspec.startsWith("$$QT_BUILD_TREE\\mkspecs\\")) else if (mkspec.startsWith("$$QT_BUILD_TREE\\mkspecs\\"))
mkspec = mkspec.mid(QString("$$QT_BUILD_TREE\\mkspecs\\").length()); mkspec = mkspec.mid(QString("$$QT_BUILD_TREE\\mkspecs\\").length());
mkspec = QDir::fromNativeSeparators(mkspec);
} }
break; break;
} }
@@ -1100,7 +1101,8 @@ void QtVersion::updateMkSpec() const
int index = mkspec.lastIndexOf('/'); int index = mkspec.lastIndexOf('/');
if(index == -1) if(index == -1)
index = mkspec.lastIndexOf('\\'); index = mkspec.lastIndexOf('\\');
if (index >= 0 && QDir(mkspec.left(index)).canonicalPath() == QDir(m_path + "/mkspecs/").canonicalPath()) QString mkspecDir = QDir(m_path + "/mkspecs/").canonicalPath();
if (index >= 0 && QDir(mkspec.left(index)).canonicalPath() == mkspecDir)
mkspec = mkspec.mid(index+1).trimmed(); mkspec = mkspec.mid(index+1).trimmed();
m_mkspec = mkspec; m_mkspec = mkspec;
@@ -1112,7 +1114,7 @@ QString QtVersion::makeCommand() const
{ {
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
const QString &spec = mkspec(); const QString &spec = mkspec();
if (spec.startsWith("win32-msvc") || spec == QLatin1String("win32-icc")) if (spec.contains("win32-msvc") || spec.contains(QLatin1String("win32-icc")))
return "nmake.exe"; return "nmake.exe";
else if(spec.startsWith("wince")) else if(spec.startsWith("wince"))
return "nmake.exe"; return "nmake.exe";
@@ -1149,7 +1151,7 @@ QtVersion::ToolchainType QtVersion::toolchainType() const
if (!isValid()) if (!isValid())
return INVALID; return INVALID;
const QString &spec = mkspec(); const QString &spec = mkspec();
if(spec.startsWith("win32-msvc") || spec == QLatin1String("win32-icc")) if(spec.contains("win32-msvc") || spec.contains(QLatin1String("win32-icc")))
return MSVC; return MSVC;
else if(spec == "win32-g++") else if(spec == "win32-g++")
return MinGW; return MinGW;

View File

@@ -2477,6 +2477,9 @@ void BaseTextEditor::extraAreaMouseEvent(QMouseEvent *e)
void BaseTextEditor::slotCursorPositionChanged() void BaseTextEditor::slotCursorPositionChanged()
{ {
QList<QTextEdit::ExtraSelection> extraSelections; QList<QTextEdit::ExtraSelection> extraSelections;
setExtraSelections(ParenthesesMatchingSelection, extraSelections); // clear
if (d->m_parenthesesMatchingEnabled)
d->m_parenthesesMatchingTimer->start(50);
if (d->m_highlightCurrentLine) { if (d->m_highlightCurrentLine) {
QTextEdit::ExtraSelection sel; QTextEdit::ExtraSelection sel;
@@ -2487,11 +2490,7 @@ void BaseTextEditor::slotCursorPositionChanged()
extraSelections.append(sel); extraSelections.append(sel);
} }
if (d->m_parenthesesMatchingEnabled) setExtraSelections(CurrentLineSelection, extraSelections);
d->m_parenthesesMatchingTimer->start(50);
d->m_extraSelections = extraSelections;
setExtraSelections(d->m_extraSelections + d->m_extraExtraSelections);
} }
QTextBlock TextBlockUserData::testCollapse(const QTextBlock& block) QTextBlock TextBlockUserData::testCollapse(const QTextBlock& block)
@@ -3133,7 +3132,7 @@ void BaseTextEditor::_q_matchParentheses()
if (backwardMatchType == TextBlockUserData::NoMatch && forwardMatchType == TextBlockUserData::NoMatch) if (backwardMatchType == TextBlockUserData::NoMatch && forwardMatchType == TextBlockUserData::NoMatch)
return; return;
QList<QTextEdit::ExtraSelection> extraSelections = d->m_extraSelections; QList<QTextEdit::ExtraSelection> extraSelections;
if (backwardMatch.hasSelection()) { if (backwardMatch.hasSelection()) {
QTextEdit::ExtraSelection sel; QTextEdit::ExtraSelection sel;
@@ -3186,8 +3185,7 @@ void BaseTextEditor::_q_matchParentheses()
} }
extraSelections.append(sel); extraSelections.append(sel);
} }
d->m_extraSelections = extraSelections; setExtraSelections(ParenthesesMatchingSelection, extraSelections);
setExtraSelections(d->m_extraSelections + d->m_extraExtraSelections);
} }
void BaseTextEditor::setActionHack(QObject *hack) void BaseTextEditor::setActionHack(QObject *hack)
@@ -3234,15 +3232,21 @@ void BaseTextEditor::deleteLine()
cut(); cut();
} }
void BaseTextEditor::setExtraExtraSelections(const QList<QTextEdit::ExtraSelection> &selections) void BaseTextEditor::setExtraSelections(ExtraSelectionKind kind, const QList<QTextEdit::ExtraSelection> &selections)
{ {
d->m_extraExtraSelections = selections; if (selections.isEmpty() && d->m_extraSelections[kind].isEmpty())
setExtraSelections(d->m_extraSelections + d->m_extraExtraSelections); return;
d->m_extraSelections[kind] = selections;
QList<QTextEdit::ExtraSelection> all;
for (int i = 0; i < NExtraSelectionKinds; ++i)
all += d->m_extraSelections[i];
QPlainTextEdit::setExtraSelections(all);
} }
QList<QTextEdit::ExtraSelection> BaseTextEditor::extraExtraSelections() const QList<QTextEdit::ExtraSelection> BaseTextEditor::extraSelections(ExtraSelectionKind kind) const
{ {
return d->m_extraExtraSelections; return d->m_extraSelections[kind];
} }

View File

@@ -369,7 +369,6 @@ private:
Internal::BaseTextEditorPrivate *d; Internal::BaseTextEditorPrivate *d;
friend class Internal::BaseTextEditorPrivate; friend class Internal::BaseTextEditorPrivate;
public: public:
QWidget *extraArea() const; QWidget *extraArea() const;
virtual int extraAreaWidth(int *markWidthPtr = 0) const; virtual int extraAreaWidth(int *markWidthPtr = 0) const;
@@ -385,8 +384,16 @@ public:
void ensureCursorVisible(); void ensureCursorVisible();
void setExtraExtraSelections(const QList<QTextEdit::ExtraSelection> &selections); enum ExtraSelectionKind {
QList<QTextEdit::ExtraSelection> extraExtraSelections() const; CurrentLineSelection,
ParenthesesMatchingSelection,
CodeWarningsSelection,
CodeSemanticsSelection,
OtherSelection,
NExtraSelectionKinds
};
void setExtraSelections(ExtraSelectionKind kind, const QList<QTextEdit::ExtraSelection> &selections);
QList<QTextEdit::ExtraSelection> extraSelections(ExtraSelectionKind kind) const;
struct BlockRange { struct BlockRange {
BlockRange():first(0), last(-1){} BlockRange():first(0), last(-1){}

View File

@@ -204,8 +204,7 @@ public:
QObject *m_actionHack; QObject *m_actionHack;
QList<QTextEdit::ExtraSelection> m_extraSelections; QList<QTextEdit::ExtraSelection> m_extraSelections[BaseTextEditor::NExtraSelectionKinds];
QList<QTextEdit::ExtraSelection> m_extraExtraSelections;
// block selection mode // block selection mode
bool m_inBlockSelectionMode; bool m_inBlockSelectionMode;

View File

@@ -225,24 +225,13 @@ void VCSBaseEditor::mouseMoveEvent(QMouseEvent *e)
sel.format.setFontUnderline(true); sel.format.setFontUnderline(true);
change = changeUnderCursor(cursor); change = changeUnderCursor(cursor);
sel.format.setProperty(QTextFormat::UserProperty, change); sel.format.setProperty(QTextFormat::UserProperty, change);
bool found = false; setExtraSelections(OtherSelection, QList<QTextEdit::ExtraSelection>() << sel);
foreach (QTextEdit::ExtraSelection es, extraSelections()) {
if (es.format.stringProperty(QTextFormat::UserProperty) == sel.format.stringProperty(QTextFormat::UserProperty)) {
found = true;
break;
}
}
if (!found) {
setExtraSelections(QList<QTextEdit::ExtraSelection>() << sel);
viewport()->setCursor(Qt::PointingHandCursor); viewport()->setCursor(Qt::PointingHandCursor);
} }
} else { } else {
if (!extraSelections().isEmpty()) { setExtraSelections(OtherSelection, QList<QTextEdit::ExtraSelection>());
setExtraSelections(QList<QTextEdit::ExtraSelection>());
viewport()->setCursor(Qt::IBeamCursor); viewport()->setCursor(Qt::IBeamCursor);
} }
}
}
TextEditor::BaseTextEditor::mouseMoveEvent(e); TextEditor::BaseTextEditor::mouseMoveEvent(e);
} }