diff --git a/share/qtcreator/gdbmacros/gdbmacros.cpp b/share/qtcreator/gdbmacros/gdbmacros.cpp index b93bb69a4a3e1f3443d2963307ba3118d3e8d5ab..9a92062d243a48db26fae1493398310cd5b72719 100644 --- a/share/qtcreator/gdbmacros/gdbmacros.cpp +++ b/share/qtcreator/gdbmacros/gdbmacros.cpp @@ -2744,6 +2744,9 @@ static void qDumpQTextCodec(QDumper &d) static void qDumpQVector(QDumper &d) { + QVectorTypedData<int> *dummy = 0; + const unsigned typeddatasize = (char*)(&dummy->array) - (char*)dummy; + QVectorData *v = *reinterpret_cast<QVectorData *const*>(d.data); // Try to provoke segfaults early to prevent the frontend @@ -2756,8 +2759,7 @@ static void qDumpQVector(QDumper &d) //qCheckAccess(&vec.back()); } - unsigned innersize = d.extraInt[0]; - unsigned typeddatasize = d.extraInt[1]; + const unsigned innersize = d.extraInt[0]; int n = nn; d.putItemCount("value", n); @@ -3348,7 +3350,8 @@ void *watchPoint(int x, int y) } #endif -// Helper to write out common expression values for CDB: +// Helpers to write out common expression values for CDB +#ifdef Q_CC_MSVC // Offsets of a map node value which looks like // "(size_t)&(('QMapNode<QString,QString >'*)0)->value")" in gdb syntax @@ -3394,6 +3397,8 @@ template <class Key, class Value> return d; } +#endif // Q_CC_MSVC + extern "C" Q_DECL_EXPORT void *qDumpObjectData440( int protocolVersion, @@ -3515,6 +3520,7 @@ void *qDumpObjectData440( .put(NS"QMapNode<"NS"QString,"NS"QVariant>=\"").put(sizeof(QMapNode<QString, QVariant>)) .put("\"}"); // Write out common expression values for CDB +#ifdef Q_CC_MSVC d.put(",expressions={"); putQMapNodeOffsetExpression<int,int>("int", "int", d).put(','); putQMapNodeOffsetExpression<int,QString>("int", NS"QString", d).put(','); @@ -3534,6 +3540,7 @@ void *qDumpObjectData440( putStdPairValueOffsetExpression<int,std::wstring>("int", stdWideStringTypeUShortC, d).put(','); putStdPairValueOffsetExpression<std::wstring,int>(stdWideStringTypeUShortC, "int", d); d.put('}'); +#endif // Q_CC_MSVC d.disarm(); } diff --git a/share/qtcreator/gdbmacros/test/main.cpp b/share/qtcreator/gdbmacros/test/main.cpp index 8b24d55aca60fbfe7c081c8ea84f9f3e84a2d6b8..22f68e1a3c6044e9f2731a34a2776fb2128018df 100644 --- a/share/qtcreator/gdbmacros/test/main.cpp +++ b/share/qtcreator/gdbmacros/test/main.cpp @@ -140,7 +140,7 @@ static int dumpQIntList() static int dumpQIntVector() { - QVector<int> test = QVector<int>() << 1 << 2; + QVector<int> test = QVector<int>() << 42 << 43; prepareInBuffer("QVector", "local.qintvector", "local.qintvector", "int"); qDumpObjectData440(2, 42, testAddress(&test), 1, sizeof(int), 0, 0, 0); fputs(qDumpOutBuffer, stdout); diff --git a/src/plugins/debugger/watchutils.cpp b/src/plugins/debugger/watchutils.cpp index d6daad15514058301f36b854229619f7df71d303..490fd2a64a89a35c3bbd392eb140a54541570a44 100644 --- a/src/plugins/debugger/watchutils.cpp +++ b/src/plugins/debugger/watchutils.cpp @@ -798,7 +798,6 @@ QtDumperHelper::ExpressionRequirement QtDumperHelper::expressionRequirements(Typ switch (t) { case QAbstractItemType: - case QVectorType: return NeedsComplexExpression; case QMapType: case QMultiMapType: @@ -1353,14 +1352,6 @@ void QtDumperHelper::evaluationParameters(const WatchData &data, case QAbstractItemType: inner = data.addr.mid(1); break; - case QVectorType: - if (m_qtVersion >= 0x040600) - extraArgs[1] = QString("(char*)&((%1).p->array)-(char*)((%2).p)") - .arg(data.exp).arg(data.exp); - else - extraArgs[1] = QString("(char*)&((%1).d->array)-(char*)((%2).d)") - .arg(data.exp).arg(data.exp); - break; case QObjectSlotType: case QObjectSignalType: { // we need the number out of something like @@ -1453,6 +1444,7 @@ void QtDumperHelper::evaluationParameters(const WatchData &data, qWarning("Unknown type encountered in %s.\n", Q_FUNC_INFO); break; case SupportedType: + case QVectorType: case QObjectType: case QWidgetType: break; diff --git a/src/plugins/genericprojectmanager/genericprojectnodes.cpp b/src/plugins/genericprojectmanager/genericprojectnodes.cpp index d9e4d3155c9e3b4a3b8424e16ee85192594adb63..c40b8e42fc818c9079d9304b6b31e362ff123aea 100644 --- a/src/plugins/genericprojectmanager/genericprojectnodes.cpp +++ b/src/plugins/genericprojectmanager/genericprojectnodes.cpp @@ -95,7 +95,7 @@ void GenericProjectNode::refresh() QFileInfo fileInfo(absoluteFileName); const QString absoluteFilePath = fileInfo.path(); - QString baseDir(QFileInfo(path()).absolutePath()); + QString baseDir = QFileInfo(path()).absolutePath(); if (! absoluteFilePath.startsWith(baseDir)) continue; // `file' is not part of the project. diff --git a/src/plugins/projectexplorer/taskwindow.cpp b/src/plugins/projectexplorer/taskwindow.cpp index 9f3780d9a95f0bbda8073a9c0ed833af3b7c229c..3a8b84d4c5bbc740757e5d30b67b335cc8f76bb4 100644 --- a/src/plugins/projectexplorer/taskwindow.cpp +++ b/src/plugins/projectexplorer/taskwindow.cpp @@ -46,6 +46,7 @@ #include <QtGui/QListView> #include <QtGui/QPainter> #include <QtCore/QAbstractItemModel> +#include <QtGui/QSortFilterProxyModel> #include <QtGui/QApplication> #include <QtGui/QClipboard> #include <QtGui/QFont> @@ -93,6 +94,32 @@ private: QIcon m_unspecifiedIcon; }; +class ProjectExplorer::Internal::TaskFilterModel : public QSortFilterProxyModel +{ +public: + TaskFilterModel(TaskModel *sourceModel, QObject *parent = 0); + + TaskModel *taskModel() const; + + bool filterIncludesUnknowns() const { return m_includeUnknowns; } + void setFilterIncludesUnknowns(bool b) { m_includeUnknowns = b; invalidateFilter(); } + + bool filterIncludesWarnings() const { return m_includeWarnings; } + void setFilterIncludesWarnings(bool b) { m_includeWarnings = b; invalidateFilter(); } + + bool filterIncludesErrors() const { return m_includeErrors; } + void setFilterIncludesErrors(bool b) { m_includeErrors = b; invalidateFilter(); } + +protected: + bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const; + +private: + // These correspond to ProjectExplorer::BuildParserInterface::PatternType. + bool m_includeUnknowns; + bool m_includeWarnings; + bool m_includeErrors; +}; + //// // TaskView //// @@ -241,18 +268,71 @@ void TaskModel::setFileNotFound(const QModelIndex &idx, bool b) } } +///// +// TaskFilterModel +///// + +TaskFilterModel::TaskFilterModel(TaskModel *sourceModel, QObject *parent) + : QSortFilterProxyModel(parent) +{ + setSourceModel(sourceModel); + setDynamicSortFilter(true); + m_includeUnknowns = m_includeWarnings = m_includeErrors = true; +} + +TaskModel *TaskFilterModel::taskModel() const +{ + return static_cast<TaskModel*>(sourceModel()); +} + +bool TaskFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const +{ + QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent); + ProjectExplorer::BuildParserInterface::PatternType type = ProjectExplorer::BuildParserInterface::PatternType(index.data(TaskModel::Type).toInt()); + switch (type) { + case ProjectExplorer::BuildParserInterface::Unknown: + return m_includeUnknowns; + + case ProjectExplorer::BuildParserInterface::Warning: + return m_includeWarnings; + + case ProjectExplorer::BuildParserInterface::Error: + return m_includeErrors; + } + + // Not one of the three supported types -- shouldn't happen, but we'll let it slide. + return true; +} + ///// // TaskWindow ///// +static QToolButton *createFilterButton(ProjectExplorer::BuildParserInterface::PatternType type, + const QString &toolTip, TaskModel *model, + QObject *receiver, const char *slot) +{ + QToolButton *button = new QToolButton; + button->setIcon(model->iconFor(type)); + button->setProperty("type", "dockbutton"); + button->setToolTip(toolTip); + button->setCheckable(true); + button->setChecked(true); + button->setAutoRaise(true); + button->setEnabled(true); + QObject::connect(button, SIGNAL(toggled(bool)), receiver, slot); + return button; +} + TaskWindow::TaskWindow() { Core::ICore *core = Core::ICore::instance(); m_model = new TaskModel; + m_filter = new TaskFilterModel(m_model); m_listview = new TaskView; - m_listview->setModel(m_model); + m_listview->setModel(m_filter); m_listview->setFrameStyle(QFrame::NoFrame); m_listview->setWindowTitle(tr("Build Issues")); m_listview->setSelectionMode(QAbstractItemView::SingleSelection); @@ -280,6 +360,10 @@ TaskWindow::TaskWindow() connect(m_copyAction, SIGNAL(triggered()), SLOT(copy())); + m_filterWarningsButton = createFilterButton(ProjectExplorer::BuildParserInterface::Warning, + tr("Show Warnings"), m_model, + this, SLOT(setShowWarnings(bool))); + m_errorCount = 0; m_currentTask = -1; } @@ -287,13 +371,15 @@ TaskWindow::TaskWindow() TaskWindow::~TaskWindow() { Core::ICore::instance()->removeContextObject(m_taskWindowContext); + delete m_filterWarningsButton; delete m_listview; + delete m_filter; delete m_model; } QList<QWidget*> TaskWindow::toolBarWidgets() const { - return QList<QWidget*>(); + return QList<QWidget*>() << m_filterWarningsButton; } QWidget *TaskWindow::outputWidget(QWidget *) @@ -366,6 +452,12 @@ void TaskWindow::copy() QApplication::clipboard()->setText(file + ':' + line + ": " + type + description); } +void TaskWindow::setShowWarnings(bool show) +{ + m_filter->setFilterIncludesWarnings(show); + m_filter->setFilterIncludesUnknowns(show); // "Unknowns" are often associated with warnings +} + int TaskWindow::numberOfTasks() const { return m_model->rowCount(QModelIndex()); @@ -388,41 +480,41 @@ bool TaskWindow::hasFocus() bool TaskWindow::canFocus() { - return m_model->rowCount(); + return m_filter->rowCount(); } void TaskWindow::setFocus() { - if (m_model->rowCount()) { + if (m_filter->rowCount()) { m_listview->setFocus(); if (m_listview->currentIndex() == QModelIndex()) { - m_listview->setCurrentIndex(m_model->index(0,0, QModelIndex())); + m_listview->setCurrentIndex(m_filter->index(0,0, QModelIndex())); } } } bool TaskWindow::canNext() { - return m_model->rowCount(); + return m_filter->rowCount(); } bool TaskWindow::canPrevious() { - return m_model->rowCount(); + return m_filter->rowCount(); } void TaskWindow::goToNext() { - if (!m_model->rowCount()) + if (!m_filter->rowCount()) return; QModelIndex currentIndex = m_listview->currentIndex(); if (currentIndex.isValid()) { int row = currentIndex.row() + 1; - if (row == m_model->rowCount()) + if (row == m_filter->rowCount()) row = 0; - currentIndex = m_model->index(row, 0); + currentIndex = m_filter->index(row, 0); } else { - currentIndex = m_model->index(0, 0); + currentIndex = m_filter->index(0, 0); } m_listview->setCurrentIndex(currentIndex); showTaskInFile(currentIndex); @@ -430,16 +522,16 @@ void TaskWindow::goToNext() void TaskWindow::goToPrev() { - if (!m_model->rowCount()) + if (!m_filter->rowCount()) return; QModelIndex currentIndex = m_listview->currentIndex(); if (currentIndex.isValid()) { int row = currentIndex.row() -1; if (row < 0) - row = m_model->rowCount() - 1; - currentIndex = m_model->index(row, 0); + row = m_filter->rowCount() - 1; + currentIndex = m_filter->index(row, 0); } else { - currentIndex = m_model->index(m_model->rowCount()-1, 0); + currentIndex = m_filter->index(m_filter->rowCount()-1, 0); } m_listview->setCurrentIndex(currentIndex); showTaskInFile(currentIndex); @@ -475,7 +567,7 @@ QSize TaskDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelInd QSize s; s.setWidth(option.rect.width()); const QAbstractItemView * view = qobject_cast<const QAbstractItemView *>(opt.widget); - TaskModel *model = static_cast<TaskModel *>(view->model()); + TaskModel *model = static_cast<TaskFilterModel *>(view->model())->taskModel(); int width = opt.rect.width() - model->sizeOfFile() - model->sizeOfLineNumber() - 12 - 22; if (view->selectionModel()->currentIndex() == index) { QString description = index.data(TaskModel::Description).toString(); @@ -544,7 +636,7 @@ void TaskDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, painter->setPen(textColor); - TaskModel *model = static_cast<TaskModel *>(view->model()); + TaskModel *model = static_cast<TaskFilterModel *>(view->model())->taskModel(); ProjectExplorer::BuildParserInterface::PatternType type = ProjectExplorer::BuildParserInterface::PatternType(index.data(TaskModel::Type).toInt()); QIcon icon = model->iconFor(type); painter->drawPixmap(2, opt.rect.top() + 2, icon.pixmap(16, 16)); diff --git a/src/plugins/projectexplorer/taskwindow.h b/src/plugins/projectexplorer/taskwindow.h index 7d4500677663c8ac674302f9682fa0a80be25b91..809b7efe82e8d060c6ac6814acc2c598dcd54f36 100644 --- a/src/plugins/projectexplorer/taskwindow.h +++ b/src/plugins/projectexplorer/taskwindow.h @@ -44,6 +44,7 @@ namespace ProjectExplorer { namespace Internal { class TaskModel; +class TaskFilterModel; class TaskView; class TaskWindowContext; @@ -85,6 +86,7 @@ signals: private slots: void showTaskInFile(const QModelIndex &index); void copy(); + void setShowWarnings(bool); private: int sizeHintForColumn(int column) const; @@ -93,9 +95,11 @@ private: int m_currentTask; TaskModel *m_model; + TaskFilterModel *m_filter; TaskView *m_listview; TaskWindowContext *m_taskWindowContext; QAction *m_copyAction; + QToolButton *m_filterWarningsButton; }; class TaskView : public QListView