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

View File

@@ -1674,7 +1674,10 @@ static void qDumpQObjectSignal(QDumper &d)
d.beginHash();
P(d, "name", "[" << i << "] slot");
P(d, "type", "");
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 << "]";

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
*/

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)

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

View File

@@ -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

View File

@@ -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

View File

@@ -57,7 +57,6 @@
#include <QtDebug>
#include <algorithm>
using namespace rpp;
using namespace CPlusPlus;
namespace {

View File

@@ -62,7 +62,7 @@ namespace CPlusPlus {
class Token;
}
namespace rpp {
namespace CPlusPlus {
struct Value
{
@@ -226,6 +226,6 @@ namespace rpp {
bool isQtReservedWord(const QByteArray &name) const;
};
} // namespace rpp
} // namespace CPlusPlus
#endif // PP_ENGINE_H

View File

@@ -54,7 +54,7 @@
#include "pp.h"
#include <cstring>
using namespace rpp;
using namespace CPlusPlus;
Environment::Environment ()
: currentLine(0),

View File

@@ -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

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

View File

@@ -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),

View File

@@ -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

View File

@@ -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

View File

@@ -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

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!
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;
}
// Must be something weird
break;
case PathChooser::Command: // fall through
default:
;
}
// 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

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();

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;

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;

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)

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

View File

@@ -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

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>

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);
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);

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

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,38 +104,86 @@ 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)
CppPreprocessor(QPointer<CppModelManager> modelManager);
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:
CPlusPlus::Document::Ptr switchDocument(CPlusPlus::Document::Ptr doc);
bool includeFile(const QString &absoluteFilePath, QByteArray *result);
QByteArray tryIncludeFile(QString &fileName, IncludeType type);
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 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;
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;
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 setWorkingCopy(const QMap<QString, QByteArray> &workingCopy)
void CppPreprocessor::setWorkingCopy(const QMap<QString, QByteArray> &workingCopy)
{ m_workingCopy = workingCopy; }
void setIncludePaths(const QStringList &includePaths)
void CppPreprocessor::setIncludePaths(const QStringList &includePaths)
{ m_includePaths = includePaths; }
void setFrameworkPaths(const QStringList &frameworkPaths)
void CppPreprocessor::setFrameworkPaths(const QStringList &frameworkPaths)
{ m_frameworkPaths = frameworkPaths; }
void addIncludePath(const QString &path)
void CppPreprocessor::addIncludePath(const QString &path)
{ m_includePaths.append(path); }
void setProjectFiles(const QStringList &files)
void CppPreprocessor::setProjectFiles(const QStringList &files)
{ m_projectFiles = files; }
void run(QString &fileName)
void CppPreprocessor::run(QString &fileName)
{ sourceNeeded(fileName, IncludeGlobal); }
void operator()(QString &fileName)
void CppPreprocessor::operator()(QString &fileName)
{ run(fileName); }
protected:
bool includeFile(const QString &absoluteFilePath, QByteArray *result)
bool CppPreprocessor::includeFile(const QString &absoluteFilePath, QByteArray *result)
{
if (absoluteFilePath.isEmpty() || m_included.contains(absoluteFilePath)) {
return true;
@@ -165,7 +212,7 @@ protected:
return false;
}
QByteArray tryIncludeFile(QString &fileName, IncludeType type)
QByteArray CppPreprocessor::tryIncludeFile(QString &fileName, IncludeType type)
{
QFileInfo fileInfo(fileName);
if (fileName == QLatin1String(pp_configuration_file) || fileInfo.isAbsolute()) {
@@ -248,7 +295,7 @@ protected:
return QByteArray();
}
virtual void macroAdded(const QByteArray &macroName, const QByteArray &macroText)
void CppPreprocessor::macroAdded(const QByteArray &macroName, const QByteArray &macroText)
{
if (! m_currentDoc)
return;
@@ -256,8 +303,8 @@ protected:
m_currentDoc->appendMacro(macroName, macroText);
}
virtual void startExpandingMacro(unsigned offset,
const rpp::Macro &,
void CppPreprocessor::startExpandingMacro(unsigned offset,
const Macro &,
const QByteArray &originalText)
{
if (! m_currentDoc)
@@ -267,7 +314,7 @@ protected:
m_currentDoc->addMacroUse(offset, originalText.length());
}
virtual void stopExpandingMacro(unsigned, const rpp::Macro &)
void CppPreprocessor::stopExpandingMacro(unsigned, const Macro &)
{
if (! m_currentDoc)
return;
@@ -275,13 +322,13 @@ protected:
//qDebug() << "stop expanding:" << macro.name;
}
void mergeEnvironment(Document::Ptr doc)
void CppPreprocessor::mergeEnvironment(Document::Ptr doc)
{
QSet<QString> processed;
mergeEnvironment(doc, &processed);
}
void mergeEnvironment(Document::Ptr doc, QSet<QString> *processed)
void CppPreprocessor::mergeEnvironment(Document::Ptr doc, QSet<QString> *processed)
{
if (! doc)
return;
@@ -303,21 +350,21 @@ protected:
m_proc(localFileName, macros, &dummy);
}
virtual void startSkippingBlocks(unsigned offset)
void CppPreprocessor::startSkippingBlocks(unsigned offset)
{
//qDebug() << "start skipping blocks:" << offset;
if (m_currentDoc)
m_currentDoc->startSkippingBlocks(offset);
}
virtual void stopSkippingBlocks(unsigned offset)
void CppPreprocessor::stopSkippingBlocks(unsigned offset)
{
//qDebug() << "stop skipping blocks:" << offset;
if (m_currentDoc)
m_currentDoc->stopSkippingBlocks(offset);
}
virtual void sourceNeeded(QString &fileName, IncludeType type)
void CppPreprocessor::sourceNeeded(QString &fileName, IncludeType type)
{
if (fileName.isEmpty())
return;
@@ -371,33 +418,14 @@ protected:
}
}
Document::Ptr switchDocument(Document::Ptr doc)
Document::Ptr CppPreprocessor::switchDocument(Document::Ptr doc)
{
Document::Ptr previousDoc = m_currentDoc;
m_currentDoc = doc;
return previousDoc;
}
private:
QPointer<CppModelManager> m_modelManager;
CppModelManager::DocumentTable m_documents;
rpp::Environment env;
rpp::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;
};
} // namespace Internal
} // namespace CppTools
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)
{
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,

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
};

View File

@@ -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

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 \

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

View File

@@ -44,6 +44,8 @@
#include <QMetaType>
#include <QString>
#include <functional>
namespace CppTools {
namespace Internal {

View File

@@ -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);

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);

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

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;

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) {

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;

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);
}
}
}

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;
};

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>

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()
{
}

View File

@@ -54,9 +54,6 @@ public:
PerforceSettings settings() const;
void setSettings(const PerforceSettings &);
private slots:;
void browseForCommand();
private:
Ui::SettingsPage m_ui;
};

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>

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
}

View File

@@ -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;

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()
{
}

View File

@@ -59,9 +59,6 @@ public:
SubversionSettings settings() const;
void setSettings(const SubversionSettings &);
private slots:;
void browseForCommand();
private:
Ui::SettingsPage m_ui;
};

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>

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();
}

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;