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

Conflicts:
	src/plugins/qt4projectmanager/qtversionmanager.cpp
This commit is contained in:
dt
2008-12-08 12:47:15 +01:00
55 changed files with 972 additions and 638 deletions
+15 -4
View File
@@ -1674,7 +1674,10 @@ static void qDumpQObjectSignal(QDumper &d)
d.beginHash();
P(d, "name", "[" << i << "] slot");
P(d, "type", "");
P(d, "value", conn.receiver->metaObject()->method(conn.method).signature());
if (conn.receiver)
P(d, "value", conn.receiver->metaObject()->method(conn.method).signature());
else
P(d, "value", "<invalid receiver>");
P(d, "numchild", "0");
d.endHash();
d.beginHash();
@@ -1861,17 +1864,25 @@ static void qDumpQSet(QDumper &d)
n = 100;
d << ",children=[";
int i = 0;
for (int bucket = 0; bucket != hd->numBuckets; ++bucket) {
for (int bucket = 0; bucket != hd->numBuckets && i <= 10000; ++bucket) {
for (node = hd->buckets[bucket]; node->next; node = node->next) {
d.beginHash();
P(d, "name", "[" << i << "]");
P(d, "type", d.innertype);
P(d, "exp", "(('QHashNode<" << d.innertype
<< ",QHashDummyValue>'*)"
P(d, "exp", "(('"NS"QHashNode<" << d.innertype
<< ","NS"QHashDummyValue>'*)"
<< static_cast<const void*>(node) << ")->key"
);
d.endHash();
++i;
if (i > 10000) {
d.beginHash();
P(d, "name", "Warning:");
P(d, "value", "<incomplete>");
P(d, "type", "");
d.endHash();
break;
}
}
}
d << "]";
+41 -37
View File
@@ -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}
\table
\header
\o Term
\o Meaning
\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.
\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.
\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
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.
\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.
\bold{Project Qt}
\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.
\bold{Shadow Build}
\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
*/
+9 -7
View File
@@ -95,8 +95,10 @@ private:
QSortFilterProxyModel *proxyModel;
};
class TreeView : public QTreeView {
class TreeView : public QTreeView
{
Q_OBJECT
public:
TreeView(QWidget* parent = 0) : QTreeView(parent) {}
void subclassKeyPressEvent(QKeyEvent* event)
@@ -159,18 +161,18 @@ class BookmarkManager : public QObject
Q_OBJECT
public:
BookmarkManager(QHelpEngineCore* helpEngine);
BookmarkManager(QHelpEngineCore *helpEngine);
~BookmarkManager();
BookmarkModel* treeBookmarkModel();
BookmarkModel* listBookmarkModel();
BookmarkModel *treeBookmarkModel();
BookmarkModel *listBookmarkModel();
void saveBookmarks();
QStringList bookmarkFolders() const;
QModelIndex addNewFolder(const QModelIndex& index);
QModelIndex addNewFolder(const QModelIndex &index);
void removeBookmarkItem(QTreeView *treeView, const QModelIndex& index);
void showBookmarkDialog(QWidget* parent, const QString &name, const QString &url);
void addNewBookmark(const QModelIndex& index, const QString &name, const QString &url);
void showBookmarkDialog(QWidget *parent, const QString &name, const QString &url);
void addNewBookmark(const QModelIndex &index, const QString &name, const QString &url);
void setupBookmarkModels();
private slots:
+2 -2
View File
@@ -212,9 +212,9 @@ int main(int argc, char **argv)
pluginManager.setPluginPaths(pluginPaths);
const QStringList arguments = app.arguments();
QMap<QString,QString> foundAppOptions;
QMap<QString, QString> foundAppOptions;
if (arguments.size() > 1) {
QMap<QString,bool> appOptions;
QMap<QString, bool> appOptions;
appOptions.insert(QLatin1String(HELP_OPTION1), false);
appOptions.insert(QLatin1String(HELP_OPTION2), false);
appOptions.insert(QLatin1String(HELP_OPTION3), false);
+14 -2
View File
@@ -21,7 +21,16 @@ HEADERS += \
TypeOfExpression.h \
TypePrettyPrinter.h \
ResolveExpression.h \
LookupContext.h
LookupContext.h \
pp-cctype.h \
pp-engine.h \
pp-fwd.h \
pp-macro-expander.h \
pp-scanner.h \
pp-client.h \
pp-environment.h \
pp-internal.h \
pp-macro.h
SOURCES += \
SimpleLexer.cpp \
@@ -35,6 +44,9 @@ SOURCES += \
TypeOfExpression.cpp \
TypePrettyPrinter.cpp \
ResolveExpression.cpp \
LookupContext.cpp
LookupContext.cpp \
pp-engine.cpp \
pp-environment.cpp \
pp-macro-expander.cpp
RESOURCES += cplusplus.qrc
@@ -55,7 +55,7 @@
#include <cctype>
namespace rpp {
namespace CPlusPlus {
inline bool pp_isalpha (int __ch)
{ return std::isalpha ((unsigned char) __ch) != 0; }
@@ -69,6 +69,6 @@ inline bool pp_isdigit (int __ch)
inline bool pp_isspace (int __ch)
{ return std::isspace ((unsigned char) __ch) != 0; }
} // namespace rpp
} // namespace CPlusPlus
#endif // PP_CCTYPE_H
@@ -38,7 +38,7 @@
#include <QString>
#include <QFile>
namespace rpp {
namespace CPlusPlus {
class Macro;
@@ -74,6 +74,6 @@ public:
virtual void stopSkippingBlocks(unsigned offset) = 0;
};
} // namespace rpp
} // namespace CPlusPlus
#endif // PP_CLIENT_H
@@ -57,7 +57,6 @@
#include <QtDebug>
#include <algorithm>
using namespace rpp;
using namespace CPlusPlus;
namespace {
@@ -62,7 +62,7 @@ namespace CPlusPlus {
class Token;
}
namespace rpp {
namespace CPlusPlus {
struct Value
{
@@ -200,7 +200,7 @@ namespace rpp {
Value evalExpression(TokenIterator firstToken,
TokenIterator lastToken,
const QByteArray &source) const;
const QByteArray &source) const;
QVector<CPlusPlus::Token> tokenize(const QByteArray &text) const;
@@ -226,6 +226,6 @@ namespace rpp {
bool isQtReservedWord(const QByteArray &name) const;
};
} // namespace rpp
} // namespace CPlusPlus
#endif // PP_ENGINE_H
@@ -54,7 +54,7 @@
#include "pp.h"
#include <cstring>
using namespace rpp;
using namespace CPlusPlus;
Environment::Environment ()
: currentLine(0),
@@ -56,7 +56,7 @@
#include <QVector>
#include <QByteArray>
namespace rpp {
namespace CPlusPlus {
struct Macro;
@@ -104,6 +104,6 @@ private:
int _hash_count;
};
} // namespace rpp
} // namespace CPlusPlus
#endif // PP_ENVIRONMENT_H
View File
@@ -55,7 +55,7 @@
#include <QByteArray>
namespace rpp {
namespace CPlusPlus {
namespace _PP_internal {
inline bool comment_p (const char *__first, const char *__last)
@@ -73,6 +73,6 @@ inline bool comment_p (const char *__first, const char *__last)
}
} // _PP_internal
} // namespace rpp
} // namespace CPlusPlus
#endif // PP_INTERNAL_H
@@ -35,7 +35,7 @@
#include "pp-macro-expander.h"
#include <QDateTime>
using namespace rpp;
using namespace CPlusPlus;
MacroExpander::MacroExpander (Environment &env, pp_frame *frame)
: env(env), frame(frame),
@@ -53,7 +53,7 @@
#ifndef PP_MACRO_EXPANDER_H
#define PP_MACRO_EXPANDER_H
namespace rpp {
namespace CPlusPlus {
struct pp_frame
{
@@ -97,7 +97,7 @@ namespace rpp {
int generated_lines;
};
} // namespace rpp
} // namespace CPlusPlus
#endif // PP_MACRO_EXPANDER_H
@@ -56,7 +56,7 @@
#include <QByteArray>
#include <QVector>
namespace rpp {
namespace CPlusPlus {
struct Macro
{
@@ -90,6 +90,6 @@ namespace rpp {
{ }
};
} // namespace rpp
} // namespace CPlusPlus
#endif // PP_MACRO_H
@@ -53,7 +53,7 @@
#ifndef PP_SCANNER_H
#define PP_SCANNER_H
namespace rpp {
namespace CPlusPlus {
struct pp_skip_blanks
{
@@ -373,7 +373,7 @@ struct pp_skip_argument
}
};
} // namespace rpp
} // namespace CPlusPlus
#endif // PP_SCANNER_H
+109 -24
View File
@@ -48,40 +48,54 @@
namespace Core {
namespace Utils {
#ifdef Q_OS_OSX
/*static*/ const char * const PathChooser::browseButtonLabel = "Choose...";
#else
/*static*/ const char * const PathChooser::browseButtonLabel = "Browse...";
#endif
// ------------------ PathValidatingLineEdit
class PathValidatingLineEdit : public BaseValidatingLineEdit {
public:
explicit PathValidatingLineEdit(QWidget *parent = 0);
explicit PathValidatingLineEdit(PathChooser *chooser, QWidget *parent = 0);
protected:
virtual bool validate(const QString &value, QString *errorMessage) const;
private:
PathChooser *m_chooser;
};
PathValidatingLineEdit::PathValidatingLineEdit(QWidget *parent) :
BaseValidatingLineEdit(parent)
PathValidatingLineEdit::PathValidatingLineEdit(PathChooser *chooser, QWidget *parent) :
BaseValidatingLineEdit(parent),
m_chooser(chooser)
{
Q_ASSERT(chooser != NULL);
}
bool PathValidatingLineEdit::validate(const QString &value, QString *errorMessage) const
{
return PathChooser::validatePath(value, errorMessage);
return m_chooser->validatePath(value, errorMessage);
}
// ------------------ PathChooserPrivate
struct PathChooserPrivate {
PathChooserPrivate();
PathChooserPrivate(PathChooser *chooser);
PathValidatingLineEdit *m_lineEdit;
PathChooser::Kind m_acceptingKind;
QString m_dialogTitleOverride;
};
PathChooserPrivate::PathChooserPrivate() :
m_lineEdit(new PathValidatingLineEdit)
PathChooserPrivate::PathChooserPrivate(PathChooser *chooser) :
m_lineEdit(new PathValidatingLineEdit(chooser)),
m_acceptingKind(PathChooser::Directory)
{
}
PathChooser::PathChooser(QWidget *parent) :
QWidget(parent),
m_d(new PathChooserPrivate)
m_d(new PathChooserPrivate(this))
{
QHBoxLayout *hLayout = new QHBoxLayout;
hLayout->setContentsMargins(0, 0, 0, 0);
@@ -90,11 +104,12 @@ PathChooser::PathChooser(QWidget *parent) :
connect(m_d->m_lineEdit, SIGNAL(textChanged(QString)), this, SIGNAL(changed()));
connect(m_d->m_lineEdit, SIGNAL(validChanged()), this, SIGNAL(validChanged()));
m_d->m_lineEdit->setMinimumWidth(300);
m_d->m_lineEdit->setMinimumWidth(260);
hLayout->addWidget(m_d->m_lineEdit);
hLayout->setSizeConstraint(QLayout::SetMinimumSize);
QToolButton *browseButton = new QToolButton;
browseButton->setText(tr("..."));
browseButton->setText(tr(browseButtonLabel));
connect(browseButton, SIGNAL(clicked()), this, SLOT(slotBrowse()));
hLayout->addWidget(browseButton);
@@ -123,8 +138,28 @@ void PathChooser::slotBrowse()
QString predefined = path();
if (!predefined.isEmpty() && !QFileInfo(predefined).isDir())
predefined.clear();
// Prompt for a directory, delete trailing slashes unless it is "/", only
QString newPath = QFileDialog::getExistingDirectory(this, tr("Choose a path"), predefined);
// Prompt for a file/dir
QString dialogTitle;
QString newPath;
switch (m_d->m_acceptingKind) {
case PathChooser::Directory:
newPath = QFileDialog::getExistingDirectory(this,
makeDialogTitle(tr("Choose a directory")), predefined);
break;
case PathChooser::File: // fall through
case PathChooser::Command:
newPath = QFileDialog::getOpenFileName(this,
makeDialogTitle(tr("Choose a file")), predefined);
break;
default:
;
}
// TODO make cross-platform
// Delete trailing slashes unless it is "/", only
if (!newPath .isEmpty()) {
if (newPath .size() > 1 && newPath .endsWith(QDir::separator()))
newPath .truncate(newPath .size() - 1);
@@ -149,20 +184,52 @@ bool PathChooser::validatePath(const QString &path, QString *errorMessage)
*errorMessage = tr("The path must not be empty.");
return false;
}
// Must be a directory?
const QFileInfo fi(path);
if (fi.isDir())
return true; // Happy!
if (!fi.exists()) {
if (errorMessage)
*errorMessage = tr("The path '%1' does not exist.").arg(path);
return false;
const QFileInfo fi(path);
const bool isDir = fi.isDir();
// Check if existing
switch (m_d->m_acceptingKind) {
case PathChooser::Directory: // fall through
case PathChooser::File:
if (!fi.exists()) {
if (errorMessage)
*errorMessage = tr("The path '%1' does not exist.").arg(path);
return false;
}
break;
case PathChooser::Command: // fall through
default:
;
}
// Must be something weird
if (errorMessage)
*errorMessage = tr("The path '%1' is not a directory.").arg(path);
return false;
// Check expected kind
switch (m_d->m_acceptingKind) {
case PathChooser::Directory:
if (!isDir)
if (errorMessage)
*errorMessage = tr("The path '%1' is not a directory.").arg(path);
return false;
break;
case PathChooser::File:
if (isDir)
if (errorMessage)
*errorMessage = tr("The path '%1' is not a file.").arg(path);
return false;
break;
case PathChooser::Command:
// TODO do proper command validation
// i.e. search $PATH for a matching file
break;
default:
;
}
return true;
}
QString PathChooser::label()
@@ -182,5 +249,23 @@ QString PathChooser::homePath()
#endif
}
void PathChooser::setExpectedKind(Kind expected)
{
m_d->m_acceptingKind = expected;
}
void PathChooser::setPromptDialogTitle(const QString &title)
{
m_d->m_dialogTitleOverride = title;
}
QString PathChooser::makeDialogTitle(const QString &title)
{
if (m_d->m_dialogTitleOverride.isNull())
return title;
else
return m_d->m_dialogTitleOverride;
}
} // namespace Utils
} // namespace Core
+19 -1
View File
@@ -54,9 +54,23 @@ class QWORKBENCH_UTILS_EXPORT PathChooser : public QWidget
Q_PROPERTY(QString path READ path WRITE setPath DESIGNABLE true)
public:
static const char * const browseButtonLabel;
explicit PathChooser(QWidget *parent = 0);
virtual ~PathChooser();
enum Kind {
Directory,
File,
Command,
// ,Any
};
// Default is <Directory>
void setExpectedKind(Kind expected);
void setPromptDialogTitle(const QString &title);
bool isValid() const;
QString errorMessage() const;
@@ -65,11 +79,15 @@ public:
// Returns the suggested label title when used in a form layout
static QString label();
static bool validatePath(const QString &path, QString *errorMessage = 0);
bool validatePath(const QString &path, QString *errorMessage = 0);
// Return the home directory, which needs some fixing under Windows.
static QString homePath();
private:
// Returns overridden title or the one from <title>
QString makeDialogTitle(const QString &title);
signals:
void validChanged();
void changed();
+8 -3
View File
@@ -396,11 +396,16 @@ void BookmarkManager::toggleBookmark()
if (!editor)
return;
const QFileInfo fi(editor->file()->fileName());
const int editorLine = editor->currentLine();
toggleBookmark(editor->file()->fileName(), editor->currentLine());
}
void BookmarkManager::toggleBookmark(const QString &fileName, int lineNumber)
{
const QFileInfo fi(fileName);
const int editorLine = lineNumber;
// Remove any existing bookmark on this line
if (Bookmark *mark = findBookmark(fi.path(), fi.fileName(), editorLine)) {
if (Bookmark *mark = findBookmark(fi.path(), fi.fileName(), lineNumber)) {
// TODO check if the bookmark is really on the same markable Interface
removeBookmark(mark);
return;
+18 -11
View File
@@ -34,15 +34,15 @@
#ifndef BOOKMARKMANAGER_H
#define BOOKMARKMANAGER_H
#include <QtCore/QAbstractItemModel>
#include <QtGui/QListView>
#include <QtCore/QList>
#include <QtGui/QPixmap>
#include <QtGui/QStyledItemDelegate>
#include <coreplugin/icontext.h>
#include <coreplugin/inavigationwidgetfactory.h>
#include <QtCore/QAbstractItemModel>
#include <QtCore/QList>
#include <QtGui/QListView>
#include <QtGui/QPixmap>
#include <QtGui/QStyledItemDelegate>
namespace ProjectExplorer {
class SessionManager;
}
@@ -89,10 +89,16 @@ public:
// this QItemSelectionModel is shared by all views
QItemSelectionModel *selectionModel() const;
enum Roles {Filename = Qt::UserRole, LineNumber = Qt::UserRole + 1, Directory = Qt::UserRole + 2, LineText = Qt::UserRole + 3};
enum Roles {
Filename = Qt::UserRole,
LineNumber = Qt::UserRole + 1,
Directory = Qt::UserRole + 2,
LineText = Qt::UserRole + 3
};
public slots:
void toggleBookmark();
void toggleBookmark(const QString &fileName, int lineNumber);
void nextInDocument();
void prevInDocument();
void next();
@@ -108,6 +114,7 @@ private slots:
void updateActionStatus();
void gotoBookmark(Bookmark *bookmark);
void loadBookmarks();
private:
TextEditor::ITextEditor *currentTextEditor() const;
ProjectExplorer::SessionManager* sessionManager() const;
@@ -120,8 +127,8 @@ private:
static QString bookmarkToString(const Bookmark *b);
void saveBookmarks();
typedef QMultiMap<QString, Bookmark*> FileNameBookmarksMap;
typedef QMap<QString, FileNameBookmarksMap*> DirectoryFileBookmarksMap;
typedef QMultiMap<QString, Bookmark *> FileNameBookmarksMap;
typedef QMap<QString, FileNameBookmarksMap *> DirectoryFileBookmarksMap;
DirectoryFileBookmarksMap m_bookmarksMap;
Core::ICore *m_core;
@@ -138,7 +145,7 @@ class BookmarkView : public QListView
public:
BookmarkView(QWidget *parent = 0);
~BookmarkView();
void setModel(QAbstractItemModel * model);
void setModel(QAbstractItemModel *model);
public slots:
void gotoBookmark(const QModelIndex &index);
protected slots:
@@ -146,7 +153,7 @@ protected slots:
void removeAll();
protected:
void contextMenuEvent(QContextMenuEvent *event);
void removeBookmark(const QModelIndex& index);
void removeBookmark(const QModelIndex &index);
private:
BookmarkContext *m_bookmarkContext;
QModelIndex m_contextMenuIndex;
+47 -2
View File
@@ -36,17 +36,22 @@
#include "bookmarks_global.h"
#include <texteditor/texteditorconstants.h>
#include <texteditor/itexteditor.h>
#include <coreplugin/icore.h>
#include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/uniqueidmanager.h>
#include <coreplugin/actionmanager/actionmanagerinterface.h>
#include <QtCore/qplugin.h>
#include <QtCore/QDebug>
#include <QtGui/QMenu>
#include <QDebug>
using namespace Bookmarks::Constants;
using namespace Bookmarks::Internal;
using namespace TextEditor;
BookmarksPlugin *BookmarksPlugin::m_instance = 0;
@@ -159,6 +164,19 @@ bool BookmarksPlugin::initialize(const QStringList & /*arguments*/, QString *)
updateActions(m_bookmarkManager->state());
addAutoReleasedObject(new BookmarkViewFactory(m_bookmarkManager));
m_bookmarkMarginAction = new QAction(this);
m_bookmarkMarginAction->setText("Toggle Bookmark");
//m_bookmarkAction->setIcon(QIcon(":/gdbdebugger/images/breakpoint.svg"));
connect(m_bookmarkMarginAction, SIGNAL(triggered()),
this, SLOT(bookmarkMarginActionTriggered()));
// EditorManager
QObject *editorManager = m_core->editorManager();
connect(editorManager, SIGNAL(editorAboutToClose(Core::IEditor*)),
this, SLOT(editorAboutToClose(Core::IEditor*)));
connect(editorManager, SIGNAL(editorOpened(Core::IEditor*)),
this, SLOT(editorOpened(Core::IEditor*)));
return true;
}
@@ -169,7 +187,6 @@ BookmarksPlugin::~BookmarksPlugin()
void BookmarksPlugin::updateActions(int state)
{
const bool hasbm = state >= BookmarkManager::HasBookMarks;
const bool hasdocbm = state == BookmarkManager::HasBookmarksInDocument;
@@ -182,4 +199,32 @@ void BookmarksPlugin::updateActions(int state)
m_moveDownAction->setEnabled(hasbm);
}
void BookmarksPlugin::editorOpened(Core::IEditor *editor)
{
connect(editor, SIGNAL(markContextMenuRequested(TextEditor::ITextEditor*,int,QMenu*)),
this, SLOT(requestContextMenu(TextEditor::ITextEditor*,int,QMenu*)));
}
void BookmarksPlugin::editorAboutToClose(Core::IEditor *editor)
{
disconnect(editor, SIGNAL(markContextMenuRequested(TextEditor::ITextEditor*,int,QMenu*)),
this, SLOT(requestContextMenu(TextEditor::ITextEditor*,int,QMenu*)));
}
void BookmarksPlugin::requestContextMenu(TextEditor::ITextEditor *editor,
int lineNumber, QMenu *menu)
{
m_bookmarkMarginActionLineNumber = lineNumber;
m_bookmarkMarginActionFileName = editor->file()->fileName();
menu->addAction(m_bookmarkMarginAction);
}
void BookmarksPlugin::bookmarkMarginActionTriggered()
{
m_bookmarkManager->toggleBookmark(
m_bookmarkMarginActionFileName,
m_bookmarkMarginActionLineNumber
);
}
Q_EXPORT_PLUGIN(BookmarksPlugin)
+24 -5
View File
@@ -31,18 +31,26 @@
**
***************************************************************************/
#ifndef BOOKMARKS_H
#define BOOKMARKS_H
#ifndef BOOKMARKSPLUGIN_H
#define BOOKMARKSPLUGIN_H
#include <extensionsystem/iplugin.h>
#include <QtCore/QObject>
#include <QtCore/QMultiMap>
#include <extensionsystem/iplugin.h>
QT_FORWARD_DECLARE_CLASS(QAction)
QT_BEGIN_NAMESPACE
class QAction;
class QMenu;
QT_END_NAMESPACE
namespace Core {
class ICore;
class IEditor;
}
namespace TextEditor {
class ITextEditor;
}
namespace Bookmarks {
@@ -67,6 +75,13 @@ public:
public slots:
void updateActions(int stateMask);
private slots:
void editorOpened(Core::IEditor *editor);
void editorAboutToClose(Core::IEditor *editor);
void requestContextMenu(TextEditor::ITextEditor *editor,
int lineNumber, QMenu *menu);
void bookmarkMarginActionTriggered();
private:
static BookmarksPlugin *m_instance;
BookmarkManager *m_bookmarkManager;
@@ -79,6 +94,10 @@ private:
QAction *m_docNextAction;
QAction *m_moveUpAction;
QAction *m_moveDownAction;
QAction *m_bookmarkMarginAction;
int m_bookmarkMarginActionLineNumber;
QString m_bookmarkMarginActionFileName;
};
} // namespace Internal
@@ -64,11 +64,12 @@ CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName)
CppTools::CppModelManagerInterface *modelmanager = ExtensionSystem::PluginManager::instance()->getObject<CppTools::CppModelManagerInterface>();
if (modelmanager) {
CppTools::CppModelManagerInterface::ProjectInfo *pinfo = modelmanager->projectInfo(this);
pinfo->includePaths = cbpparser.includeFiles();
CppTools::CppModelManagerInterface::ProjectInfo pinfo = modelmanager->projectInfo(this);
pinfo.includePaths = cbpparser.includeFiles();
// TODO we only want C++ files, not all other stuff that might be in the project
pinfo->sourceFiles = m_files;
pinfo.sourceFiles = m_files;
// TODO defines
modelmanager->updateProjectInfo(pinfo);
}
} else {
// TODO report error
@@ -100,4 +100,4 @@ signals:
} // namespace Core
#endif //IEDITOR_H
#endif // IEDITOR_H
+6 -6
View File
@@ -63,7 +63,7 @@ ViewManager::ViewManager(MainWindow *mainWnd) :
ViewManagerInterface(mainWnd),
m_mainWnd(mainWnd)
{
for(int i = 0; i< 3; ++i) {
for (int i = 0; i < 3; ++i) {
QWidget *w = new QWidget();
m_mainWnd->statusBar()->insertPermanentWidget(i, w);
w->setLayout(new QHBoxLayout);
@@ -89,7 +89,7 @@ void ViewManager::init()
void ViewManager::objectAdded(QObject *obj)
{
IView * view = Aggregation::query<IView>(obj);
IView *view = Aggregation::query<IView>(obj);
if (!view)
return;
@@ -104,8 +104,8 @@ void ViewManager::objectAdded(QObject *obj)
void ViewManager::aboutToRemoveObject(QObject *obj)
{
IView * view = Aggregation::query<IView>(obj);
if(!view)
IView *view = Aggregation::query<IView>(obj);
if (!view)
return;
m_mainWnd->removeContextObject(view);
}
@@ -121,10 +121,10 @@ void ViewManager::saveSettings(QSettings *settings)
settings->setValue(QLatin1String("ViewGroup_Default"), m_mainWnd->saveState());
}
IView * ViewManager::view(const QString & id)
IView *ViewManager::view(const QString &id)
{
QList<IView *> list = m_mainWnd->pluginManager()->getObjects<IView>();
foreach (IView * view, list) {
foreach (IView *view, list) {
if (view->uniqueViewName() == id)
return view;
}
+1 -1
View File
@@ -1,4 +1,4 @@
<plugin name="CodePaster" version="0.1" compatVersion="0.1">
<plugin name="CodePaster" version="0.9.1" compatVersion="0.9.1">
<vendor>Nokia Corporation</vendor>
<copyright>(C) 2008 Nokia Corporation</copyright>
<license>Nokia Technology Preview License Agreement</license>
+19 -5
View File
@@ -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);
+2
View File
@@ -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
+353 -279
View File
@@ -31,7 +31,6 @@
**
***************************************************************************/
#define _SCL_SECURE_NO_WARNINGS 1
#include "pp.h"
#include "cppmodelmanager.h"
@@ -66,14 +65,14 @@
#include <Token.h>
#include <QPlainTextEdit>
#include <QMutexLocker>
#include <QTime>
#include <QDebug>
using namespace CppTools;
using namespace CppTools::Internal;
using namespace CPlusPlus;
namespace CppTools {
namespace Internal {
static const char pp_configuration_file[] = "<configuration>";
static const char pp_configuration[] =
@@ -105,299 +104,328 @@ static const char pp_configuration[] =
"#define __declspec(a)\n"
"#define STDMETHOD(method) virtual HRESULT STDMETHODCALLTYPE method\n";
class CppPreprocessor: public rpp::Client
namespace CppTools {
namespace Internal {
class CppPreprocessor: public CPlusPlus::Client
{
public:
CppPreprocessor(QPointer<CppModelManager> modelManager)
: m_modelManager(modelManager),
m_documents(modelManager->documents()),
m_proc(this, env)
{ }
CppPreprocessor(QPointer<CppModelManager> modelManager);
void setWorkingCopy(const QMap<QString, QByteArray> &workingCopy)
{ m_workingCopy = workingCopy; }
void setIncludePaths(const QStringList &includePaths)
{ m_includePaths = includePaths; }
void setFrameworkPaths(const QStringList &frameworkPaths)
{ m_frameworkPaths = frameworkPaths; }
void addIncludePath(const QString &path)
{ m_includePaths.append(path); }
void setProjectFiles(const QStringList &files)
{ m_projectFiles = files; }
void run(QString &fileName)
{ sourceNeeded(fileName, IncludeGlobal); }
void operator()(QString &fileName)
{ run(fileName); }
void setWorkingCopy(const QMap<QString, QByteArray> &workingCopy);
void setIncludePaths(const QStringList &includePaths);
void setFrameworkPaths(const QStringList &frameworkPaths);
void addIncludePath(const QString &path);
void setProjectFiles(const QStringList &files);
void run(QString &fileName);
void operator()(QString &fileName);
protected:
bool includeFile(const QString &absoluteFilePath, QByteArray *result)
{
if (absoluteFilePath.isEmpty() || m_included.contains(absoluteFilePath)) {
return true;
}
CPlusPlus::Document::Ptr switchDocument(CPlusPlus::Document::Ptr doc);
if (m_workingCopy.contains(absoluteFilePath)) {
m_included.insert(absoluteFilePath);
*result = m_workingCopy.value(absoluteFilePath);
return true;
}
bool includeFile(const QString &absoluteFilePath, QByteArray *result);
QByteArray tryIncludeFile(QString &fileName, IncludeType type);
QFileInfo fileInfo(absoluteFilePath);
if (! fileInfo.isFile())
return false;
QFile file(absoluteFilePath);
if (file.open(QFile::ReadOnly)) {
m_included.insert(absoluteFilePath);
QTextStream stream(&file);
const QString contents = stream.readAll();
*result = contents.toUtf8();
file.close();
return true;
}
return false;
}
QByteArray tryIncludeFile(QString &fileName, IncludeType type)
{
QFileInfo fileInfo(fileName);
if (fileName == QLatin1String(pp_configuration_file) || fileInfo.isAbsolute()) {
QByteArray contents;
includeFile(fileName, &contents);
return contents;
}
if (type == IncludeLocal && m_currentDoc) {
QFileInfo currentFileInfo(m_currentDoc->fileName());
QString path = currentFileInfo.absolutePath();
path += QLatin1Char('/');
path += fileName;
path = QDir::cleanPath(path);
QByteArray contents;
if (includeFile(path, &contents)) {
fileName = path;
return contents;
}
}
foreach (const QString &includePath, m_includePaths) {
QString path = includePath;
path += QLatin1Char('/');
path += fileName;
path = QDir::cleanPath(path);
QByteArray contents;
if (includeFile(path, &contents)) {
fileName = path;
return contents;
}
}
// look in the system include paths
foreach (const QString &includePath, m_systemIncludePaths) {
QString path = includePath;
path += QLatin1Char('/');
path += fileName;
path = QDir::cleanPath(path);
QByteArray contents;
if (includeFile(path, &contents)) {
fileName = path;
return contents;
}
}
int index = fileName.indexOf(QLatin1Char('/'));
if (index != -1) {
QString frameworkName = fileName.left(index);
QString name = fileName.mid(index + 1);
foreach (const QString &frameworkPath, m_frameworkPaths) {
QString path = frameworkPath;
path += QLatin1Char('/');
path += frameworkName;
path += QLatin1String(".framework/Headers/");
path += name;
QByteArray contents;
if (includeFile(path, &contents)) {
fileName = path;
return contents;
}
}
}
QString path = fileName;
if (path.at(0) != QLatin1Char('/'))
path.prepend(QLatin1Char('/'));
foreach (const QString &projectFile, m_projectFiles) {
if (projectFile.endsWith(path)) {
fileName = projectFile;
QByteArray contents;
includeFile(fileName, &contents);
return contents;
}
}
//qDebug() << "**** file" << fileName << "not found!";
return QByteArray();
}
virtual void macroAdded(const QByteArray &macroName, const QByteArray &macroText)
{
if (! m_currentDoc)
return;
m_currentDoc->appendMacro(macroName, macroText);
}
void mergeEnvironment(CPlusPlus::Document::Ptr doc);
void mergeEnvironment(CPlusPlus::Document::Ptr doc, QSet<QString> *processed);
virtual void macroAdded(const QByteArray &macroName,
const QByteArray &macroText);
virtual void startExpandingMacro(unsigned offset,
const rpp::Macro &,
const QByteArray &originalText)
{
if (! m_currentDoc)
return;
//qDebug() << "start expanding:" << macro.name << "text:" << originalText;
m_currentDoc->addMacroUse(offset, originalText.length());
}
virtual void stopExpandingMacro(unsigned, const rpp::Macro &)
{
if (! m_currentDoc)
return;
//qDebug() << "stop expanding:" << macro.name;
}
void mergeEnvironment(Document::Ptr doc)
{
QSet<QString> processed;
mergeEnvironment(doc, &processed);
}
void mergeEnvironment(Document::Ptr doc, QSet<QString> *processed)
{
if (! doc)
return;
const QString fn = doc->fileName();
if (processed->contains(fn))
return;
processed->insert(fn);
foreach (QString includedFile, doc->includedFiles())
mergeEnvironment(m_documents.value(includedFile), processed);
const QByteArray macros = doc->definedMacros();
QByteArray localFileName = doc->fileName().toUtf8();
QByteArray dummy;
m_proc(localFileName, macros, &dummy);
}
virtual void startSkippingBlocks(unsigned offset)
{
//qDebug() << "start skipping blocks:" << offset;
if (m_currentDoc)
m_currentDoc->startSkippingBlocks(offset);
}
virtual void stopSkippingBlocks(unsigned offset)
{
//qDebug() << "stop skipping blocks:" << offset;
if (m_currentDoc)
m_currentDoc->stopSkippingBlocks(offset);
}
virtual void sourceNeeded(QString &fileName, IncludeType type)
{
if (fileName.isEmpty())
return;
QByteArray contents = tryIncludeFile(fileName, type);
if (m_currentDoc) {
m_currentDoc->addIncludeFile(fileName);
if (contents.isEmpty() && ! QFileInfo(fileName).isAbsolute()) {
QString msg;
msg += fileName;
msg += QLatin1String(": No such file or directory");
Document::DiagnosticMessage d(Document::DiagnosticMessage::Warning,
m_currentDoc->fileName(),
env.currentLine, /*column = */ 0,
msg);
m_currentDoc->addDiagnosticMessage(d);
//qWarning() << "file not found:" << fileName << m_currentDoc->fileName() << env.current_line;
}
}
if (! contents.isEmpty()) {
Document::Ptr cachedDoc = m_documents.value(fileName);
if (cachedDoc && m_currentDoc) {
mergeEnvironment(cachedDoc);
} else {
Document::Ptr previousDoc = switchDocument(Document::create(fileName));
const QByteArray previousFile = env.current_file;
const unsigned previousLine = env.currentLine;
env.current_file = QByteArray(m_currentDoc->translationUnit()->fileName(),
m_currentDoc->translationUnit()->fileNameLength());
QByteArray preprocessedCode;
m_proc(contents, &preprocessedCode);
//qDebug() << preprocessedCode;
env.current_file = previousFile;
env.currentLine = previousLine;
m_currentDoc->setSource(preprocessedCode);
m_currentDoc->parse();
m_currentDoc->check();
m_currentDoc->releaseTranslationUnit(); // release the AST and the token stream.
if (m_modelManager)
m_modelManager->emitDocumentUpdated(m_currentDoc);
(void) switchDocument(previousDoc);
}
}
}
Document::Ptr switchDocument(Document::Ptr doc)
{
Document::Ptr previousDoc = m_currentDoc;
m_currentDoc = doc;
return previousDoc;
}
const Macro &macro,
const QByteArray &originalText);
virtual void stopExpandingMacro(unsigned offset, const Macro &macro);
virtual void startSkippingBlocks(unsigned offset);
virtual void stopSkippingBlocks(unsigned offset);
virtual void sourceNeeded(QString &fileName, IncludeType type);
private:
QPointer<CppModelManager> m_modelManager;
CppModelManager::DocumentTable m_documents;
rpp::Environment env;
rpp::pp m_proc;
Environment env;
pp m_proc;
QStringList m_includePaths;
QStringList m_systemIncludePaths;
QMap<QString, QByteArray> m_workingCopy;
QStringList m_projectFiles;
QStringList m_frameworkPaths;
QSet<QString> m_included;
Document::Ptr m_currentDoc;
CPlusPlus::Document::Ptr m_currentDoc;
};
} // namespace Internal
} // namespace CppTools
CppPreprocessor::CppPreprocessor(QPointer<CppModelManager> modelManager)
: m_modelManager(modelManager),
m_documents(modelManager->documents()),
m_proc(this, env)
{ }
void CppPreprocessor::setWorkingCopy(const QMap<QString, QByteArray> &workingCopy)
{ m_workingCopy = workingCopy; }
void CppPreprocessor::setIncludePaths(const QStringList &includePaths)
{ m_includePaths = includePaths; }
void CppPreprocessor::setFrameworkPaths(const QStringList &frameworkPaths)
{ m_frameworkPaths = frameworkPaths; }
void CppPreprocessor::addIncludePath(const QString &path)
{ m_includePaths.append(path); }
void CppPreprocessor::setProjectFiles(const QStringList &files)
{ m_projectFiles = files; }
void CppPreprocessor::run(QString &fileName)
{ sourceNeeded(fileName, IncludeGlobal); }
void CppPreprocessor::operator()(QString &fileName)
{ run(fileName); }
bool CppPreprocessor::includeFile(const QString &absoluteFilePath, QByteArray *result)
{
if (absoluteFilePath.isEmpty() || m_included.contains(absoluteFilePath)) {
return true;
}
if (m_workingCopy.contains(absoluteFilePath)) {
m_included.insert(absoluteFilePath);
*result = m_workingCopy.value(absoluteFilePath);
return true;
}
QFileInfo fileInfo(absoluteFilePath);
if (! fileInfo.isFile())
return false;
QFile file(absoluteFilePath);
if (file.open(QFile::ReadOnly)) {
m_included.insert(absoluteFilePath);
QTextStream stream(&file);
const QString contents = stream.readAll();
*result = contents.toUtf8();
file.close();
return true;
}
return false;
}
QByteArray CppPreprocessor::tryIncludeFile(QString &fileName, IncludeType type)
{
QFileInfo fileInfo(fileName);
if (fileName == QLatin1String(pp_configuration_file) || fileInfo.isAbsolute()) {
QByteArray contents;
includeFile(fileName, &contents);
return contents;
}
if (type == IncludeLocal && m_currentDoc) {
QFileInfo currentFileInfo(m_currentDoc->fileName());
QString path = currentFileInfo.absolutePath();
path += QLatin1Char('/');
path += fileName;
path = QDir::cleanPath(path);
QByteArray contents;
if (includeFile(path, &contents)) {
fileName = path;
return contents;
}
}
foreach (const QString &includePath, m_includePaths) {
QString path = includePath;
path += QLatin1Char('/');
path += fileName;
path = QDir::cleanPath(path);
QByteArray contents;
if (includeFile(path, &contents)) {
fileName = path;
return contents;
}
}
// look in the system include paths
foreach (const QString &includePath, m_systemIncludePaths) {
QString path = includePath;
path += QLatin1Char('/');
path += fileName;
path = QDir::cleanPath(path);
QByteArray contents;
if (includeFile(path, &contents)) {
fileName = path;
return contents;
}
}
int index = fileName.indexOf(QLatin1Char('/'));
if (index != -1) {
QString frameworkName = fileName.left(index);
QString name = fileName.mid(index + 1);
foreach (const QString &frameworkPath, m_frameworkPaths) {
QString path = frameworkPath;
path += QLatin1Char('/');
path += frameworkName;
path += QLatin1String(".framework/Headers/");
path += name;
QByteArray contents;
if (includeFile(path, &contents)) {
fileName = path;
return contents;
}
}
}
QString path = fileName;
if (path.at(0) != QLatin1Char('/'))
path.prepend(QLatin1Char('/'));
foreach (const QString &projectFile, m_projectFiles) {
if (projectFile.endsWith(path)) {
fileName = projectFile;
QByteArray contents;
includeFile(fileName, &contents);
return contents;
}
}
//qDebug() << "**** file" << fileName << "not found!";
return QByteArray();
}
void CppPreprocessor::macroAdded(const QByteArray &macroName, const QByteArray &macroText)
{
if (! m_currentDoc)
return;
m_currentDoc->appendMacro(macroName, macroText);
}
void CppPreprocessor::startExpandingMacro(unsigned offset,
const Macro &,
const QByteArray &originalText)
{
if (! m_currentDoc)
return;
//qDebug() << "start expanding:" << macro.name << "text:" << originalText;
m_currentDoc->addMacroUse(offset, originalText.length());
}
void CppPreprocessor::stopExpandingMacro(unsigned, const Macro &)
{
if (! m_currentDoc)
return;
//qDebug() << "stop expanding:" << macro.name;
}
void CppPreprocessor::mergeEnvironment(Document::Ptr doc)
{
QSet<QString> processed;
mergeEnvironment(doc, &processed);
}
void CppPreprocessor::mergeEnvironment(Document::Ptr doc, QSet<QString> *processed)
{
if (! doc)
return;
const QString fn = doc->fileName();
if (processed->contains(fn))
return;
processed->insert(fn);
foreach (QString includedFile, doc->includedFiles())
mergeEnvironment(m_documents.value(includedFile), processed);
const QByteArray macros = doc->definedMacros();
QByteArray localFileName = doc->fileName().toUtf8();
QByteArray dummy;
m_proc(localFileName, macros, &dummy);
}
void CppPreprocessor::startSkippingBlocks(unsigned offset)
{
//qDebug() << "start skipping blocks:" << offset;
if (m_currentDoc)
m_currentDoc->startSkippingBlocks(offset);
}
void CppPreprocessor::stopSkippingBlocks(unsigned offset)
{
//qDebug() << "stop skipping blocks:" << offset;
if (m_currentDoc)
m_currentDoc->stopSkippingBlocks(offset);
}
void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type)
{
if (fileName.isEmpty())
return;
QByteArray contents = tryIncludeFile(fileName, type);
if (m_currentDoc) {
m_currentDoc->addIncludeFile(fileName);
if (contents.isEmpty() && ! QFileInfo(fileName).isAbsolute()) {
QString msg;
msg += fileName;
msg += QLatin1String(": No such file or directory");
Document::DiagnosticMessage d(Document::DiagnosticMessage::Warning,
m_currentDoc->fileName(),
env.currentLine, /*column = */ 0,
msg);
m_currentDoc->addDiagnosticMessage(d);
//qWarning() << "file not found:" << fileName << m_currentDoc->fileName() << env.current_line;
}
}
if (! contents.isEmpty()) {
Document::Ptr cachedDoc = m_documents.value(fileName);
if (cachedDoc && m_currentDoc) {
mergeEnvironment(cachedDoc);
} else {
Document::Ptr previousDoc = switchDocument(Document::create(fileName));
const QByteArray previousFile = env.current_file;
const unsigned previousLine = env.currentLine;
env.current_file = QByteArray(m_currentDoc->translationUnit()->fileName(),
m_currentDoc->translationUnit()->fileNameLength());
QByteArray preprocessedCode;
m_proc(contents, &preprocessedCode);
//qDebug() << preprocessedCode;
env.current_file = previousFile;
env.currentLine = previousLine;
m_currentDoc->setSource(preprocessedCode);
m_currentDoc->parse();
m_currentDoc->check();
m_currentDoc->releaseTranslationUnit(); // release the AST and the token stream.
if (m_modelManager)
m_modelManager->emitDocumentUpdated(m_currentDoc);
(void) switchDocument(previousDoc);
}
}
}
Document::Ptr CppPreprocessor::switchDocument(Document::Ptr doc)
{
Document::Ptr previousDoc = m_currentDoc;
m_currentDoc = doc;
return previousDoc;
}
using namespace CppTools;
using namespace CppTools::Internal;
/*!
\class CppTools::CppModelManager
@@ -450,12 +478,25 @@ CppModelManager::CppModelManager(QObject *parent) :
CppModelManager::~CppModelManager()
{ }
Document::Ptr CppModelManager::document(const QString &fileName)
Document::Ptr CppModelManager::document(const QString &fileName) const
{ return m_documents.value(fileName); }
CppModelManager::DocumentTable CppModelManager::documents()
CppModelManager::DocumentTable CppModelManager::documents() const
{ return m_documents; }
void CppModelManager::ensureUpdated()
{
QMutexLocker locker(&mutex);
if (! m_dirty)
return;
m_projectFiles = updateProjectFiles();
m_includePaths = updateIncludePaths();
m_frameworkPaths = updateFrameworkPaths();
m_definedMacros = updateDefinedMacros();
m_dirty = false;
}
QStringList CppModelManager::updateProjectFiles() const
{
QStringList files;
@@ -527,8 +568,29 @@ QMap<QString, QByteArray> CppModelManager::buildWorkingCopyList()
void CppModelManager::updateSourceFiles(const QStringList &sourceFiles)
{ (void) refreshSourceFiles(sourceFiles); }
CppModelManager::ProjectInfo *CppModelManager::projectInfo(ProjectExplorer::Project *project)
{ return &m_projects[project]; }
QList<CppModelManager::ProjectInfo> CppModelManager::projectInfos() const
{
QMutexLocker locker(&mutex);
return m_projects.values();
}
CppModelManager::ProjectInfo CppModelManager::projectInfo(ProjectExplorer::Project *project) const
{
QMutexLocker locker(&mutex);
return m_projects.value(project, ProjectInfo(project));
}
void CppModelManager::updateProjectInfo(const ProjectInfo &pinfo)
{
QMutexLocker locker(&mutex);
if (! pinfo.isValid())
return;
m_projects.insert(pinfo.project, pinfo);
}
QFuture<void> CppModelManager::refreshSourceFiles(const QStringList &sourceFiles)
{
@@ -691,13 +753,18 @@ void CppModelManager::onDocumentUpdated(Document::Ptr doc)
void CppModelManager::onProjectAdded(ProjectExplorer::Project *)
{
QMutexLocker locker(&mutex);
m_dirty = true;
}
void CppModelManager::onAboutToRemoveProject(ProjectExplorer::Project *project)
{
m_dirty = true;
m_projects.remove(project);
do {
QMutexLocker locker(&mutex);
m_dirty = true;
m_projects.remove(project);
} while (0);
GC();
}
@@ -705,8 +772,15 @@ void CppModelManager::onSessionUnloaded()
{
if (m_core->progressManager()) {
m_core->progressManager()->cancelTasks(CppTools::Constants::TASK_INDEX);
m_dirty = true;
}
do {
QMutexLocker locker(&mutex);
m_projects.clear();
m_dirty = true;
} while (0);
GC();
}
void CppModelManager::parse(QFutureInterface<void> &future,
+11 -14
View File
@@ -40,6 +40,7 @@
#include <QMap>
#include <QFutureInterface>
#include <QMutex>
namespace Core {
class ICore;
@@ -70,9 +71,13 @@ public:
virtual ~CppModelManager();
virtual void updateSourceFiles(const QStringList &sourceFiles);
virtual ProjectInfo *projectInfo(ProjectExplorer::Project *project);
virtual CPlusPlus::Document::Ptr document(const QString &fileName);
virtual DocumentTable documents();
virtual QList<ProjectInfo> projectInfos() const;
virtual ProjectInfo projectInfo(ProjectExplorer::Project *project) const;
virtual void updateProjectInfo(const ProjectInfo &pinfo);
virtual CPlusPlus::Document::Ptr document(const QString &fileName) const;
virtual DocumentTable documents() const;
virtual void GC();
QFuture<void> refreshSourceFiles(const QStringList &sourceFiles);
@@ -127,22 +132,12 @@ private:
return m_definedMacros;
}
void ensureUpdated();
QStringList updateProjectFiles() const;
QStringList updateIncludePaths() const;
QStringList updateFrameworkPaths() const;
QByteArray updateDefinedMacros() const;
void ensureUpdated() {
if (! m_dirty)
return;
m_projectFiles = updateProjectFiles();
m_includePaths = updateIncludePaths();
m_frameworkPaths = updateFrameworkPaths();
m_definedMacros = updateDefinedMacros();
m_dirty = false;
}
static void parse(QFutureInterface<void> &future,
CppPreprocessor *preproc,
QStringList files);
@@ -166,6 +161,8 @@ private:
// project integration
QMap<ProjectExplorer::Project *, ProjectInfo> m_projects;
mutable QMutex mutex;
enum {
MAX_SELECTION_COUNT = 5
};
@@ -38,6 +38,7 @@
#include <cplusplus/CppDocument.h>
#include <QtCore/QObject>
#include <QtCore/QMap>
#include <QtCore/QPointer>
namespace ProjectExplorer {
class Project;
@@ -51,10 +52,29 @@ class CPPTOOLS_EXPORT CppModelManagerInterface
Q_OBJECT
public:
typedef QMap<QString, CPlusPlus::Document::Ptr> DocumentTable;
typedef QMap<QString, CPlusPlus::Document::Ptr> DocumentTable; // ### remove me
struct ProjectInfo
class ProjectInfo
{
public:
ProjectInfo()
{ }
ProjectInfo(QPointer<ProjectExplorer::Project> project)
: project(project)
{ }
operator bool() const
{ return ! project.isNull(); }
bool isValid() const
{ return ! project.isNull(); }
bool isNull() const
{ return project.isNull(); }
public: // attributes
QPointer<ProjectExplorer::Project> project;
QString projectPath;
QByteArray defines;
QStringList sourceFiles;
@@ -69,10 +89,12 @@ public:
virtual void GC() = 0;
virtual void updateSourceFiles(const QStringList &sourceFiles) = 0;
virtual CPlusPlus::Document::Ptr document(const QString &fileName) = 0;
virtual DocumentTable documents() = 0;
virtual CPlusPlus::Document::Ptr document(const QString &fileName) const = 0;
virtual DocumentTable documents() const = 0;
virtual ProjectInfo *projectInfo(ProjectExplorer::Project *project) = 0;
virtual QList<ProjectInfo> projectInfos() const = 0;
virtual ProjectInfo projectInfo(ProjectExplorer::Project *project) const = 0;
virtual void updateProjectInfo(const ProjectInfo &pinfo) = 0;
};
} // namespace CppTools
+1 -1
View File
@@ -10,7 +10,7 @@ unix:QMAKE_CXXFLAGS_DEBUG += -O3
INCLUDEPATH += .
DEFINES += CPPTOOLS_LIBRARY
CONFIG += help
include(rpp/rpp.pri)|error("Can't find RPP")
HEADERS += cpptools_global.h \
cppquickopenfilter.h \
cppclassesfilter.h \
-18
View File
@@ -1,18 +0,0 @@
DEPENDPATH += $$PWD
INCLUDEPATH += $$PWD
HEADERS += $$PWD/pp-cctype.h \
$$PWD/pp-engine.h \
$$PWD/pp-environment.h \
$$PWD/pp-internal.h \
$$PWD/pp-macro-expander.h \
$$PWD/pp-macro.h \
$$PWD/pp-scanner.h \
$$PWD/pp.h \
$$PWD/pp-client.h
SOURCES += $$PWD/pp-engine.cpp \
$$PWD/pp-environment.cpp \
$$PWD/pp-macro-expander.cpp
+2
View File
@@ -44,6 +44,8 @@
#include <QMetaType>
#include <QString>
#include <functional>
namespace CppTools {
namespace Internal {
@@ -285,6 +285,7 @@ void DebuggerOutputWindow::showOutput(const QString &prefix, const QString &outp
void DebuggerOutputWindow::showInput(const QString &prefix, const QString &input)
{
Q_UNUSED(prefix);
m_inputText->append(input);
QTextCursor cursor = m_inputText->textCursor();
cursor.movePosition(QTextCursor::End);
+26
View File
@@ -250,6 +250,12 @@ bool DebuggerPlugin::initialize(const QStringList &arguments, QString *error_mes
m_gdbRunningContext = uidm->uniqueIdentifier(Constants::GDBRUNNING);
m_breakpointMarginAction = new QAction(this);
m_breakpointMarginAction->setText("Toggle Breakpoint");
//m_breakpointMarginAction->setIcon(QIcon(":/gdbdebugger/images/breakpoint.svg"));
connect(m_breakpointMarginAction, SIGNAL(triggered()),
this, SLOT(breakpointMarginActionTriggered()));
//Core::IActionContainer *mcppcontext =
// actionManager->actionContainer(CppEditor::Constants::M_CONTEXT);
@@ -502,6 +508,8 @@ void DebuggerPlugin::editorOpened(Core::IEditor *editor)
this, SLOT(requestMark(TextEditor::ITextEditor*,int)));
connect(editor, SIGNAL(tooltipRequested(TextEditor::ITextEditor*,QPoint,int)),
this, SLOT(showToolTip(TextEditor::ITextEditor*,QPoint,int)));
connect(textEditor, SIGNAL(markContextMenuRequested(TextEditor::ITextEditor*,int,QMenu*)),
this, SLOT(requestContextMenu(TextEditor::ITextEditor*,int,QMenu*)));
}
}
@@ -512,9 +520,27 @@ void DebuggerPlugin::editorAboutToClose(Core::IEditor *editor)
this, SLOT(requestMark(TextEditor::ITextEditor*,int)));
disconnect(editor, SIGNAL(tooltipRequested(TextEditor::ITextEditor*,QPoint,int)),
this, SLOT(showToolTip(TextEditor::ITextEditor*,QPoint,int)));
disconnect(textEditor, SIGNAL(markContextMenuRequested(TextEditor::ITextEditor*,int,QMenu*)),
this, SLOT(requestContextMenu(TextEditor::ITextEditor*,int,QMenu*)));
}
}
void DebuggerPlugin::requestContextMenu(TextEditor::ITextEditor *editor,
int lineNumber, QMenu *menu)
{
m_breakpointMarginActionLineNumber = lineNumber;
m_breakpointMarginActionFileName = editor->file()->fileName();
menu->addAction(m_breakpointMarginAction);
}
void DebuggerPlugin::breakpointMarginActionTriggered()
{
m_manager->toggleBreakpoint(
m_breakpointMarginActionFileName,
m_breakpointMarginActionLineNumber
);
}
void DebuggerPlugin::requestMark(TextEditor::ITextEditor *editor, int lineNumber)
{
m_manager->toggleBreakpoint(editor->file()->fileName(), lineNumber);
+8
View File
@@ -84,10 +84,14 @@ private slots:
void setSessionValue(const QString &name, const QVariant &value);
void queryConfigValue(const QString &name, QVariant *value);
void setConfigValue(const QString &name, const QVariant &value);
void requestContextMenu(TextEditor::ITextEditor *editor,
int lineNumber, QMenu *menu);
void resetLocation();
void gotoLocation(const QString &fileName, int line, bool setMarker);
void breakpointMarginActionTriggered();
private:
friend class DebuggerManager;
friend class DebugMode; // FIXME: Just a hack now so that it can access the views
@@ -104,6 +108,10 @@ private:
QString m_previousMode;
LocationMark *m_locationMark;
int m_gdbRunningContext;
QAction *m_breakpointMarginAction;
int m_breakpointMarginActionLineNumber;
QString m_breakpointMarginActionFileName;
};
} // namespace Internal
+2
View File
@@ -1271,6 +1271,7 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data)
if (isStoppedReason(reason) || reason.isEmpty()) {
// Need another round trip
if (reason == "breakpoint-hit") {
q->showStatusMessage(tr("Stopped at breakpoint."), -1);
GdbMi frame = data.findChild("frame");
//qDebug() << frame.toString();
m_currentFrame = frame.findChild("addr").data() + '%' +
@@ -1282,6 +1283,7 @@ void GdbEngine::handleAsyncOutput(const GdbMi &data)
QVariant var = QVariant::fromValue<GdbMi>(data);
sendCommand("p 0", GdbAsyncOutput2, var); // dummy
} else {
q->showStatusMessage(tr("Stopped. %1").arg(reason), -1);
handleAsyncOutput2(data);
}
return;
+78 -57
View File
@@ -320,6 +320,51 @@ static WatchData take(const QString &iname, QList<WatchData> *list)
}
static QList<WatchData> initialSet()
{
QList<WatchData> result;
WatchData root;
root.state = 0;
root.level = 0;
root.row = 0;
root.name = "Root";
root.parentIndex = -1;
root.childIndex.append(1);
root.childIndex.append(2);
root.childIndex.append(3);
result.append(root);
WatchData local;
local.iname = "local";
local.name = "Locals";
local.state = 0;
local.level = 1;
local.row = 0;
local.parentIndex = 0;
result.append(local);
WatchData tooltip;
tooltip.iname = "tooltip";
tooltip.name = "Tooltip";
tooltip.state = 0;
tooltip.level = 1;
tooltip.row = 1;
tooltip.parentIndex = 0;
result.append(tooltip);
WatchData watch;
watch.iname = "watch";
watch.name = "Watchers";
watch.state = 0;
watch.level = 1;
watch.row = 2;
watch.parentIndex = 0;
result.append(watch);
return result;
}
///////////////////////////////////////////////////////////////////////
//
// WatchHandler
@@ -332,7 +377,8 @@ WatchHandler::WatchHandler()
m_inFetchMore = false;
m_inChange = false;
cleanModel();
m_completeSet = initialSet();
m_incompleteSet.clear();
m_displaySet = m_completeSet;
}
@@ -380,6 +426,7 @@ QVariant WatchHandler::data(const QModelIndex &idx, int role) const
int node = idx.internalId();
if (node < 0)
return QVariant();
QWB_ASSERT(node < m_displaySet.size(), return QVariant());
const WatchData &data = m_displaySet.at(node);
@@ -441,6 +488,13 @@ QVariant WatchHandler::data(const QModelIndex &idx, int role) const
case VisualRole:
return m_displayedINames.contains(data.iname);
case ExpandedRole:
//qDebug() << " FETCHING: " << data.iname
// << m_expandedINames.contains(data.iname)
// << m_expandedINames;
// Level 0 and 1 are always expanded
return node < 4 || m_expandedINames.contains(data.iname);
default:
break;
}
@@ -558,10 +612,13 @@ void WatchHandler::rebuildModel()
MODEL_DEBUG("RECREATE MODEL, CURRENT SET:\n" << toString());
#endif
QHash<QString, int> oldTopINames;
QHash<QString, QString> oldValues;
for (int i = 0, n = m_oldSet.size(); i != n; ++i) {
WatchData &data = m_oldSet[i];
oldValues[data.iname] = data.value;
if (data.level == 2)
++oldTopINames[data.iname];
}
#ifdef DEBUG_PENDING
MODEL_DEBUG("OLD VALUES: " << oldValues);
@@ -575,6 +632,9 @@ void WatchHandler::rebuildModel()
qSort(m_completeSet.begin(), m_completeSet.end(), &iNameSorter);
// This helps to decide whether the view has completely changed or not.
QHash<QString, int> topINames;
QHash<QString, int> iname2idx;
for (int i = m_completeSet.size(); --i > 0; ) {
@@ -582,7 +642,10 @@ void WatchHandler::rebuildModel()
data.parentIndex = 0;
data.childIndex.clear();
iname2idx[data.iname] = i;
if (data.level == 2)
++topINames[data.iname];
}
//qDebug() << "TOPINAMES: " << topINames << "\nOLD: " << oldTopINames;
for (int i = 1; i < m_completeSet.size(); ++i) {
WatchData &data = m_completeSet[i];
@@ -603,7 +666,13 @@ void WatchHandler::rebuildModel()
&& data.value != strNotInScope;
}
//emit layoutAboutToBeChanged();
emit layoutAboutToBeChanged();
if (oldTopINames != topINames) {
m_displaySet = initialSet();
m_expandedINames.clear();
emit reset();
}
m_displaySet = m_completeSet;
@@ -668,11 +737,6 @@ void WatchHandler::rebuildModel()
emit reset();
//qDebug() << "WATCHHANDLER: RESET EMITTED";
m_inChange = false;
//emit layoutChanged();
//QSet<QString> einames = m_expandedINames;
//einames.insert("local");
//einames.insert("watch");
//emit expandedItems(einames);
#if DEBUG_MODEL
#if USE_MODEL_TEST
@@ -691,8 +755,11 @@ void WatchHandler::cleanup()
m_oldSet.clear();
m_expandedINames.clear();
m_displayedINames.clear();
cleanModel();
m_incompleteSet.clear();
m_completeSet = initialSet();
m_displaySet = m_completeSet;
#if 0
for (EditWindows::ConstIterator it = m_editWindows.begin();
it != m_editWindows.end(); ++it) {
@@ -707,7 +774,7 @@ void WatchHandler::cleanup()
void WatchHandler::collapseChildren(const QModelIndex &idx)
{
if (m_inChange || m_completeSet.isEmpty()) {
//qDebug() << "WATCHHANDLER: COLLAPSE IGNORED" << idx;
qDebug() << "WATCHHANDLER: COLLAPSE IGNORED" << idx;
return;
}
QWB_ASSERT(checkIndex(idx.internalId()), return);
@@ -879,56 +946,10 @@ void WatchHandler::removeWatchExpression(const QString &iname)
emit watchModelUpdateRequested();
}
void WatchHandler::cleanModel()
{
// This uses data stored in m_oldSet to re-create a new set
// one-by-one
m_completeSet.clear();
m_incompleteSet.clear();
WatchData root;
root.state = 0;
root.level = 0;
root.row = 0;
root.name = "Root";
root.parentIndex = -1;
root.childIndex.append(1);
root.childIndex.append(2);
root.childIndex.append(3);
m_completeSet.append(root);
WatchData local;
local.iname = "local";
local.name = "Locals";
local.state = 0;
local.level = 1;
local.row = 0;
local.parentIndex = 0;
m_completeSet.append(local);
WatchData tooltip;
tooltip.iname = "tooltip";
tooltip.name = "Tooltip";
tooltip.state = 0;
tooltip.level = 1;
tooltip.row = 1;
tooltip.parentIndex = 0;
m_completeSet.append(tooltip);
WatchData watch;
watch.iname = "watch";
watch.name = "Watchers";
watch.state = 0;
watch.level = 1;
watch.row = 2;
watch.parentIndex = 0;
m_completeSet.append(watch);
}
void WatchHandler::reinitializeWatchers()
{
cleanModel();
m_completeSet = initialSet();
m_incompleteSet.clear();
// copy over all watchers and mark all watchers as incomplete
for (int i = 0, n = m_oldSet.size(); i < n; ++i) {
+1 -2
View File
@@ -135,7 +135,7 @@ public:
bool changed;
};
enum { INameRole = Qt::UserRole, VisualRole };
enum { INameRole = Qt::UserRole, VisualRole, ExpandedRole };
class WatchHandler : public QAbstractItemModel
@@ -192,7 +192,6 @@ signals:
private:
WatchData takeData(const QString &iname);
QString toString() const;
void cleanModel();
bool m_expandPointers;
bool m_inChange;
+5 -53
View File
@@ -46,7 +46,7 @@
using namespace Debugger::Internal;
enum { INameRole = Qt::UserRole, VisualRole };
enum { INameRole = Qt::UserRole, VisualRole, ExpandedRole };
/////////////////////////////////////////////////////////////////////
//
@@ -57,7 +57,6 @@ enum { INameRole = Qt::UserRole, VisualRole };
WatchWindow::WatchWindow(Type type, QWidget *parent)
: QTreeView(parent), m_type(type)
{
m_blocked = false;
setWindowTitle(tr("Locals and Watchers"));
setAlternatingRowColors(true);
setIndentation(indentation() * 9/10);
@@ -76,12 +75,6 @@ void WatchWindow::expandNode(const QModelIndex &idx)
//QModelIndex mi0 = idx.sibling(idx.row(), 0);
//QString iname = model()->data(mi0, INameRole).toString();
//QString name = model()->data(mi0, Qt::DisplayRole).toString();
//qDebug() << "\n\nEXPAND NODE " // << iname << name
// << idx << (m_blocked ? "blocked" : "passed");
//if (isExpanded(idx))
// return;
//if (m_blocked)
// return;
emit requestExpandChildren(idx);
}
@@ -91,8 +84,6 @@ void WatchWindow::collapseNode(const QModelIndex &idx)
//QString iname = model()->data(mi0, INameRole).toString();
//QString name = model()->data(mi0, Qt::DisplayRole).toString();
//qDebug() << "COLLAPSE NODE " << idx;
if (m_blocked)
return;
emit requestCollapseChildren(idx);
}
@@ -181,6 +172,7 @@ void WatchWindow::reset()
QTreeView::reset();
setRootIndex(model()->index(row, 0, model()->index(0, 0)));
//setRootIndex(model()->index(0, 0));
resetHelper(model()->index(0, 0));
}
void WatchWindow::setModel(QAbstractItemModel *model)
@@ -192,55 +184,15 @@ void WatchWindow::setModel(QAbstractItemModel *model)
header()->setResizeMode(QHeaderView::ResizeToContents);
if (m_type != LocalsType)
header()->hide();
connect(model, SIGNAL(modelAboutToBeReset()),
this, SLOT(modelAboutToBeReset()));
connect(model, SIGNAL(modelReset()),
this, SLOT(modelReset()));
}
void WatchWindow::modelAboutToBeReset()
void WatchWindow::resetHelper(const QModelIndex &idx)
{
m_blocked = true;
//qDebug() << "Model about to be reset";
m_expandedItems.clear();
m_expandedItems.insert("local");
m_expandedItems.insert("watch");
modelAboutToBeResetHelper(model()->index(0, 0));
//qDebug() << " expanded: " << m_expandedItems;
}
void WatchWindow::modelAboutToBeResetHelper(const QModelIndex &idx)
{
QString iname = model()->data(idx, INameRole).toString();
//qDebug() << "Model about to be reset helper" << iname << idx
// << isExpanded(idx);
if (isExpanded(idx))
m_expandedItems.insert(iname);
for (int i = 0, n = model()->rowCount(idx); i != n; ++i) {
QModelIndex idx1 = model()->index(i, 0, idx);
modelAboutToBeResetHelper(idx1);
}
}
void WatchWindow::modelReset()
{
//qDebug() << "Model reset";
expand(model()->index(0, 0));
modelResetHelper(model()->index(0, 0));
m_blocked = false;
}
void WatchWindow::modelResetHelper(const QModelIndex &idx)
{
QString name = model()->data(idx, Qt::DisplayRole).toString();
QString iname = model()->data(idx, INameRole).toString();
//qDebug() << "Model reset helper" << iname << name;
if (m_expandedItems.contains(iname)) {
if (model()->data(idx, ExpandedRole).toBool()) {
expand(idx);
for (int i = 0, n = model()->rowCount(idx); i != n; ++i) {
QModelIndex idx1 = model()->index(i, 0, idx);
modelResetHelper(idx1);
resetHelper(idx1);
}
}
}
+1 -6
View File
@@ -72,21 +72,16 @@ private slots:
void handleChangedItem(QWidget *);
void expandNode(const QModelIndex &index);
void collapseNode(const QModelIndex &index);
void modelAboutToBeReset();
void modelReset();
private:
void contextMenuEvent(QContextMenuEvent *ev);
void editItem(const QModelIndex &idx);
void reset(); /* reimpl */
void modelAboutToBeResetHelper(const QModelIndex &idx);
void modelResetHelper(const QModelIndex &idx);
void resetHelper(const QModelIndex &idx);
bool m_alwaysResizeColumnsToContents;
Type m_type;
bool m_blocked;
QSet<QString> m_expandedItems;
};
+1 -1
View File
@@ -1,4 +1,4 @@
<plugin name="ScmGit" version="0.1" compatVersion="0.1">
<plugin name="ScmGit" version="0.9.1" compatVersion="0.9.1">
<vendor>Nokia Corporation</vendor>
<copyright>(C) 2008 Nokia Corporation</copyright>
<license>Nokia Technology Preview License Agreement</license>
+5 -11
View File
@@ -39,18 +39,20 @@
#include <QtGui/QFileDialog>
using namespace Perforce::Internal;
using namespace Core::Utils;
SettingsPageWidget::SettingsPageWidget(QWidget *parent) :
QWidget(parent)
{
m_ui.setupUi(this);
connect(m_ui.browseButton, SIGNAL(clicked()), this, SLOT(browseForCommand()));
m_ui.pathChooser->setPromptDialogTitle(tr("Perforce Command"));
m_ui.pathChooser->setExpectedKind(PathChooser::Command);
}
PerforceSettings SettingsPageWidget::settings() const
{
PerforceSettings rc;
rc.p4Command = m_ui.p4CmdLineEdit->text();
rc.p4Command = m_ui.pathChooser->path();
rc.defaultEnv = m_ui.defaultCheckBox->isChecked();
rc.p4Port = m_ui.portLineEdit->text();
rc.p4Client = m_ui.clientLineEdit->text();
@@ -60,21 +62,13 @@ PerforceSettings SettingsPageWidget::settings() const
void SettingsPageWidget::setSettings(const PerforceSettings &s)
{
m_ui.p4CmdLineEdit->setText(s.p4Command);
m_ui.pathChooser->setPath(s.p4Command);
m_ui.defaultCheckBox->setChecked(s.defaultEnv);
m_ui.portLineEdit->setText(s.p4Port);
m_ui.clientLineEdit->setText(s.p4Client);
m_ui.userLineEdit->setText(s.p4User);
}
void SettingsPageWidget::browseForCommand()
{
const QString cmd = QFileDialog::getOpenFileName(window(), tr("Perforce Command"));
if (!cmd.isEmpty())
m_ui.p4CmdLineEdit->setText(cmd);
}
SettingsPage::SettingsPage()
{
}
-3
View File
@@ -54,9 +54,6 @@ public:
PerforceSettings settings() const;
void setSettings(const PerforceSettings &);
private slots:;
void browseForCommand();
private:
Ui::SettingsPage m_ui;
};
+9 -9
View File
@@ -36,14 +36,7 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="p4CmdLineEdit"/>
</item>
<item>
<widget class="QToolButton" name="browseButton">
<property name="text">
<string>...</string>
</property>
</widget>
<widget class="Core::Utils::PathChooser" name="pathChooser" native="true"/>
</item>
</layout>
</item>
@@ -120,11 +113,18 @@
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Core::Utils::PathChooser</class>
<extends>QWidget</extends>
<header location="global">utils/pathchooser.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>portLineEdit</tabstop>
<tabstop>clientLineEdit</tabstop>
<tabstop>userLineEdit</tabstop>
<tabstop>p4CmdLineEdit</tabstop>
</tabstops>
<resources/>
<connections>
+15 -11
View File
@@ -483,23 +483,27 @@ void Qt4Project::updateCodeModel()
files += m_projectFiles->files[SourceType];
files += m_projectFiles->generatedFiles[SourceType];
CppTools::CppModelManagerInterface::ProjectInfo *pinfo = modelmanager->projectInfo(this);
CppTools::CppModelManagerInterface::ProjectInfo pinfo = modelmanager->projectInfo(this);
if (pinfo->defines == predefinedMacros &&
pinfo->includePaths == allIncludePaths &&
pinfo->frameworkPaths == allFrameworkPaths &&
pinfo->sourceFiles == files) {
// Nothing to update...
if (pinfo.defines == predefinedMacros &&
pinfo.includePaths == allIncludePaths &&
pinfo.frameworkPaths == allFrameworkPaths &&
pinfo.sourceFiles == files) {
modelmanager->updateProjectInfo(pinfo);
} else {
pinfo->defines = predefinedMacros;
pinfo.defines = predefinedMacros;
// pinfo->defines += definedMacros; // ### FIXME: me
pinfo->includePaths = allIncludePaths;
pinfo->frameworkPaths = allFrameworkPaths;
pinfo->sourceFiles = files;
pinfo.includePaths = allIncludePaths;
pinfo.frameworkPaths = allFrameworkPaths;
pinfo.sourceFiles = files;
modelmanager->updateProjectInfo(pinfo);
modelmanager->GC();
modelmanager->updateSourceFiles(pinfo->sourceFiles);
modelmanager->updateSourceFiles(pinfo.sourceFiles);
}
// update info
}
@@ -969,7 +969,7 @@ void QtVersion::updateVersionInfo() const
QString line = stream.readLine();
int index = line.indexOf(":");
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)));
}
}
@@ -1041,6 +1041,7 @@ void QtVersion::updateMkSpec() const
// mkspec = mkspec.mid(QString("$$QT_BUILD_TREE/mkspecs/").length());
// else if (mkspec.startsWith("$$QT_BUILD_TREE\\mkspecs\\"))
// mkspec = mkspec.mid(QString("$$QT_BUILD_TREE\\mkspecs\\").length());
// mkspec = QDir::fromNativeSeparators(mkspec);
// }
// break;
// }
@@ -1107,7 +1108,8 @@ void QtVersion::updateMkSpec() const
int index = mkspec.lastIndexOf('/');
if(index == -1)
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();
m_mkspec = mkspec;
@@ -1119,7 +1121,7 @@ QString QtVersion::makeCommand() const
{
#ifdef Q_OS_WIN
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";
else if(spec.startsWith("wince"))
return "nmake.exe";
@@ -1156,7 +1158,7 @@ QtVersion::ToolchainType QtVersion::toolchainType() const
if (!isValid())
return INVALID;
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;
else if(spec == "win32-g++")
return MinGW;
+7 -10
View File
@@ -39,20 +39,24 @@
#include <extensionsystem/pluginmanager.h>
#include <QtGui/QFileDialog>
#include <utils/pathchooser.h>
using namespace Subversion::Internal;
using namespace Core::Utils;
SettingsPageWidget::SettingsPageWidget(QWidget *parent) :
QWidget(parent)
{
m_ui.setupUi(this);
connect(m_ui.browseButton, SIGNAL(clicked()), this, SLOT(browseForCommand()));
m_ui.pathChooser->setExpectedKind(PathChooser::Command);
m_ui.pathChooser->setPromptDialogTitle(tr("Subversion Command"));
}
SubversionSettings SettingsPageWidget::settings() const
{
SubversionSettings rc;
rc.svnCommand = m_ui.svnCmdLineEdit->text();
rc.svnCommand = m_ui.pathChooser->path();
rc.useAuthentication = m_ui.userGroupBox->isChecked();
rc.user = m_ui.usernameLineEdit->text();
rc.password = m_ui.passwordLineEdit->text();
@@ -63,19 +67,12 @@ SubversionSettings SettingsPageWidget::settings() const
void SettingsPageWidget::setSettings(const SubversionSettings &s)
{
m_ui.svnCmdLineEdit->setText(s.svnCommand);
m_ui.pathChooser->setPath(s.svnCommand);
m_ui.usernameLineEdit->setText(s.user);
m_ui.passwordLineEdit->setText(s.password);
m_ui.userGroupBox->setChecked(s.useAuthentication);
}
void SettingsPageWidget::browseForCommand()
{
QString cmd = QFileDialog::getOpenFileName(window(), tr("Subversion Command"));
if (!cmd.isEmpty())
m_ui.svnCmdLineEdit->setText(cmd);
}
SettingsPage::SettingsPage()
{
}
-3
View File
@@ -59,9 +59,6 @@ public:
SubversionSettings settings() const;
void setSettings(const SubversionSettings &);
private slots:;
void browseForCommand();
private:
Ui::SettingsPage m_ui;
};
+9 -11
View File
@@ -32,14 +32,7 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="svnCmdLineEdit"/>
</item>
<item>
<widget class="QToolButton" name="browseButton">
<property name="text">
<string>...</string>
</property>
</widget>
<widget class="Core::Utils::PathChooser" name="pathChooser" native="true"/>
</item>
</layout>
</item>
@@ -109,9 +102,14 @@
</item>
</layout>
</widget>
<tabstops>
<tabstop>svnCmdLineEdit</tabstop>
</tabstops>
<customwidgets>
<customwidget>
<class>Core::Utils::PathChooser</class>
<extends>QWidget</extends>
<header location="global">utils/pathchooser.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
+23 -6
View File
@@ -602,29 +602,44 @@ void BaseTextEditor::slotSelectionChanged()
void BaseTextEditor::gotoBlockStart()
{
QTextCursor cursor = textCursor();
if (TextBlockUserData::findPreviousOpenParenthesis(&cursor, false))
if (TextBlockUserData::findPreviousOpenParenthesis(&cursor, false)) {
setTextCursor(cursor);
_q_matchParentheses();
}
}
void BaseTextEditor::gotoBlockEnd()
{
QTextCursor cursor = textCursor();
if (TextBlockUserData::findNextClosingParenthesis(&cursor, false))
if (TextBlockUserData::findNextClosingParenthesis(&cursor, false)) {
setTextCursor(cursor);
_q_matchParentheses();
}
}
void BaseTextEditor::gotoBlockStartWithSelection()
{
QTextCursor cursor = textCursor();
if (TextBlockUserData::findPreviousOpenParenthesis(&cursor, true))
if (TextBlockUserData::findPreviousOpenParenthesis(&cursor, true)) {
setTextCursor(cursor);
_q_matchParentheses();
}
}
void BaseTextEditor::gotoBlockEndWithSelection()
{
QTextCursor cursor = textCursor();
if (TextBlockUserData::findNextClosingParenthesis(&cursor, true))
if (TextBlockUserData::findNextClosingParenthesis(&cursor, true)) {
setTextCursor(cursor);
_q_matchParentheses();
}
}
static QTextCursor flippedCursor(const QTextCursor &cursor) {
QTextCursor flipped = cursor;
flipped.clearSelection();
flipped.setPosition(cursor.anchor(), QTextCursor::KeepAnchor);
return flipped;
}
void BaseTextEditor::selectBlockUp()
@@ -640,7 +655,8 @@ void BaseTextEditor::selectBlockUp()
return;
if (!TextBlockUserData::findNextClosingParenthesis(&cursor, true))
return;
setTextCursor(cursor);
setTextCursor(flippedCursor(cursor));
_q_matchParentheses();
}
void BaseTextEditor::selectBlockDown()
@@ -663,7 +679,8 @@ void BaseTextEditor::selectBlockDown()
if ( cursor != d->m_selectBlockAnchor)
TextBlockUserData::findNextClosingParenthesis(&cursor, true);
setTextCursor(cursor);
setTextCursor(flippedCursor(cursor));
_q_matchParentheses();
}
+23
View File
@@ -351,6 +351,23 @@ void testPlugin()
}
}
void testSet()
{
QSet<int> hgg0;
hgg0.insert(11);
hgg0.insert(22);
QSet<QString> hgg1;
hgg1.insert("22.0");
QObject ob;
QSet<QPointer<QObject> > hash;
QPointer<QObject> ptr(&ob);
//hash.insert(ptr);
//hash.insert(ptr);
//hash.insert(ptr);
}
void stringRefTest(const QString &refstring)
{
Q_UNUSED(refstring);
@@ -759,6 +776,7 @@ int main(int argc, char *argv[])
testImage();
testMap();
testString();
testSet();
testStringList();
testStruct();
//testThreads();
@@ -767,8 +785,13 @@ int main(int argc, char *argv[])
testVariant3();
testVector();
testVectorOfList();
*(int *)0 = 0;
testObject(argc, argv);
//QColor color(255,128,10);
//QFont font;