diff options
author | hjk <qtc-committer@nokia.com> | 2011-07-06 17:40:54 +0200 |
---|---|---|
committer | hjk <qthjk@ovi.com> | 2011-07-14 17:43:03 +0200 |
commit | 51d83e4ce64ea9928189415a8a6e062aa5e7a1be (patch) | |
tree | ff579b5326db6c12d6e070e2c4f01b1d0afa2484 /src/plugins/classview | |
parent | 2bdc5c79c6b1193b6fb2e70a8ba24b7306c0121f (diff) | |
download | qt-creator-51d83e4ce64ea9928189415a8a6e062aa5e7a1be.tar.gz |
classview: adjust to d-pointer style rules
Change-Id: Ie413a7336ef4bde5dcf1b43b6832167742608a83
Reviewed-on: http://codereview.qt.nokia.com/1296
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: hjk <qthjk@ovi.com>
Diffstat (limited to 'src/plugins/classview')
-rw-r--r-- | src/plugins/classview/classviewconstants.h | 21 | ||||
-rw-r--r-- | src/plugins/classview/classviewmanager.cpp | 73 | ||||
-rw-r--r-- | src/plugins/classview/classviewmanager.h | 13 | ||||
-rw-r--r-- | src/plugins/classview/classviewnavigationwidget.cpp | 58 | ||||
-rw-r--r-- | src/plugins/classview/classviewnavigationwidget.h | 13 | ||||
-rw-r--r-- | src/plugins/classview/classviewnavigationwidgetfactory.cpp | 54 | ||||
-rw-r--r-- | src/plugins/classview/classviewnavigationwidgetfactory.h | 28 | ||||
-rw-r--r-- | src/plugins/classview/classviewparser.cpp | 148 | ||||
-rw-r--r-- | src/plugins/classview/classviewparser.h | 13 | ||||
-rw-r--r-- | src/plugins/classview/classviewparsertreeitem.cpp | 98 | ||||
-rw-r--r-- | src/plugins/classview/classviewparsertreeitem.h | 5 | ||||
-rw-r--r-- | src/plugins/classview/classviewplugin.cpp | 34 | ||||
-rw-r--r-- | src/plugins/classview/classviewplugin.h | 13 | ||||
-rw-r--r-- | src/plugins/classview/classviewtreeitemmodel.cpp | 8 | ||||
-rw-r--r-- | src/plugins/classview/classviewtreeitemmodel.h | 7 |
15 files changed, 250 insertions, 336 deletions
diff --git a/src/plugins/classview/classviewconstants.h b/src/plugins/classview/classviewconstants.h index c86b57f99d..372060d343 100644 --- a/src/plugins/classview/classviewconstants.h +++ b/src/plugins/classview/classviewconstants.h @@ -36,26 +36,9 @@ namespace ClassView { namespace Constants { -//! Navi Widget Factory id -const char * const CLASSVIEWNAVIGATION_ID = "Class View"; - -//! Navi Widget Factory priority -const int CLASSVIEWNAVIGATION_PRIORITY = 500; - -//! Settings' group -const char * const CLASSVIEW_SETTINGS_GROUP = "ClassView"; - -//! Settings' prefix for the tree widget -const char * const CLASSVIEW_SETTINGS_TREEWIDGET_PREFIX = "TreeWidget."; - -//! Flat mode settings -const char * const CLASSVIEW_SETTINGS_FLATMODE = "FlatMode"; - -//! Delay in msecs before an update -const int CLASSVIEW_EDITINGTREEUPDATE_DELAY = 400; - //! QStandardItem roles -enum ItemRole { +enum ItemRole +{ SymbolLocationsRole = Qt::UserRole + 1, //!< Symbol locations IconTypeRole, //!< Icon type (integer) SymbolNameRole, //!< Symbol name diff --git a/src/plugins/classview/classviewmanager.cpp b/src/plugins/classview/classviewmanager.cpp index e7966ac273..a8ad2ffe8c 100644 --- a/src/plugins/classview/classviewmanager.cpp +++ b/src/plugins/classview/classviewmanager.cpp @@ -57,22 +57,20 @@ namespace Internal { ///////////////////////////////// ManagerPrivate ////////////////////////////////// +// static variable initialization +static Manager *managerInstance = 0; + /*! \struct ManagerPrivate \internal \brief Private class data for \a Manager \sa Manager */ -struct ManagerPrivate +class ManagerPrivate { +public: ManagerPrivate() : state(false), disableCodeParser(false) {} - //! instance - static Manager *instance; - - //! Pointer to widget factory - QPointer<NavigationWidgetFactory> widgetFactory; - //! State mutex QMutex mutexState; @@ -89,16 +87,13 @@ struct ManagerPrivate bool disableCodeParser; }; -// static variable initialization -Manager *ManagerPrivate::instance = 0; - ///////////////////////////////// Manager ////////////////////////////////// Manager::Manager(QObject *parent) : QObject(parent), - d_ptr(new ManagerPrivate()) + d(new ManagerPrivate()) { - d_ptr->widgetFactory = NavigationWidgetFactory::instance(); + managerInstance = this; // register - to be able send between signal/slots qRegisterMetaType<QSharedPointer<QStandardItem> >("QSharedPointer<QStandardItem>"); @@ -106,8 +101,8 @@ Manager::Manager(QObject *parent) initialize(); // start a separate thread for the parser - d_ptr->parser.moveToThread(&d_ptr->parserThread); - d_ptr->parserThread.start(); + d->parser.moveToThread(&d->parserThread); + d->parserThread.start(); // initial setup onProjectListChanged(); @@ -115,25 +110,25 @@ Manager::Manager(QObject *parent) Manager::~Manager() { - d_ptr->parserThread.quit(); - d_ptr->parserThread.wait(); + d->parserThread.quit(); + d->parserThread.wait(); + delete d; + managerInstance = 0; } -Manager *Manager::instance(QObject *parent) +Manager *Manager::instance() { - if (!ManagerPrivate::instance) - ManagerPrivate::instance = new Manager(parent); - return ManagerPrivate::instance; + return managerInstance; } bool Manager::canFetchMore(QStandardItem *item) const { - return d_ptr->parser.canFetchMore(item); + return d->parser.canFetchMore(item); } void Manager::fetchMore(QStandardItem *item, bool skipRoot) { - d_ptr->parser.fetchMore(item, skipRoot); + d->parser.fetchMore(item, skipRoot); } void Manager::initialize() @@ -141,7 +136,7 @@ void Manager::initialize() // use Qt::QueuedConnection everywhere // widget factory signals - connect(d_ptr->widgetFactory, SIGNAL(widgetIsCreated()), + connect(NavigationWidgetFactory::instance(), SIGNAL(widgetIsCreated()), SLOT(onWidgetIsCreated()), Qt::QueuedConnection); // internal manager state is changed @@ -165,31 +160,31 @@ void Manager::initialize() // when we signals that really document is updated - sent it to the parser connect(this, SIGNAL(requestDocumentUpdated(CPlusPlus::Document::Ptr)), - &d_ptr->parser, SLOT(parseDocument(CPlusPlus::Document::Ptr)), Qt::QueuedConnection); + &d->parser, SLOT(parseDocument(CPlusPlus::Document::Ptr)), Qt::QueuedConnection); // translate data update from the parser to listeners - connect(&d_ptr->parser, SIGNAL(treeDataUpdate(QSharedPointer<QStandardItem>)), + connect(&d->parser, SIGNAL(treeDataUpdate(QSharedPointer<QStandardItem>)), this, SLOT(onTreeDataUpdate(QSharedPointer<QStandardItem>)), Qt::QueuedConnection); // requet current state - immediately after a notification connect(this, SIGNAL(requestTreeDataUpdate()), - &d_ptr->parser, SLOT(requestCurrentState()), Qt::QueuedConnection); + &d->parser, SLOT(requestCurrentState()), Qt::QueuedConnection); // full reset request to parser connect(this, SIGNAL(requestResetCurrentState()), - &d_ptr->parser, SLOT(resetDataToCurrentState()), Qt::QueuedConnection); + &d->parser, SLOT(resetDataToCurrentState()), Qt::QueuedConnection); // clear cache request connect(this, SIGNAL(requestClearCache()), - &d_ptr->parser, SLOT(clearCache()), Qt::QueuedConnection); + &d->parser, SLOT(clearCache()), Qt::QueuedConnection); // clear full cache request connect(this, SIGNAL(requestClearCacheAll()), - &d_ptr->parser, SLOT(clearCacheAll()), Qt::QueuedConnection); + &d->parser, SLOT(clearCacheAll()), Qt::QueuedConnection); // flat mode request connect(this, SIGNAL(requestSetFlatMode(bool)), - &d_ptr->parser, SLOT(setFlatMode(bool)), Qt::QueuedConnection); + &d->parser, SLOT(setFlatMode(bool)), Qt::QueuedConnection); // connect to the cpp model manager for signals about document updates CPlusPlus::CppModelManagerInterface *codeModelManager @@ -200,25 +195,25 @@ void Manager::initialize() SLOT(onDocumentUpdated(CPlusPlus::Document::Ptr)), Qt::QueuedConnection); // connect(codeModelManager, SIGNAL(aboutToRemoveFiles(QStringList)), - &d_ptr->parser, SLOT(removeFiles(QStringList)), Qt::QueuedConnection); + &d->parser, SLOT(removeFiles(QStringList)), Qt::QueuedConnection); } bool Manager::state() const { - return d_ptr->state; + return d->state; } void Manager::setState(bool state) { - QMutexLocker locker(&d_ptr->mutexState); + QMutexLocker locker(&d->mutexState); // boolean comparsion - should be done correctly by any compiler - if (state == d_ptr->state) + if (state == d->state) return; - d_ptr->state = state; + d->state = state; - emit stateChanged(d_ptr->state); + emit stateChanged(d->state); } void Manager::onWidgetIsCreated() @@ -260,7 +255,7 @@ void Manager::onTaskStarted(const QString &type) return; // disable tree updates to speed up - d_ptr->disableCodeParser = true; + d->disableCodeParser = true; } void Manager::onAllTasksFinished(const QString &type) @@ -269,7 +264,7 @@ void Manager::onAllTasksFinished(const QString &type) return; // parsing is finished, enable tree updates - d_ptr->disableCodeParser = false; + d->disableCodeParser = false; // do nothing if Manager is disabled if (!state()) @@ -289,7 +284,7 @@ void Manager::onDocumentUpdated(CPlusPlus::Document::Ptr doc) return; // do nothing if updates are disabled - if (d_ptr->disableCodeParser) + if (d->disableCodeParser) return; emit requestDocumentUpdated(doc); diff --git a/src/plugins/classview/classviewmanager.h b/src/plugins/classview/classviewmanager.h index 26fe7cc4ea..6915969f23 100644 --- a/src/plugins/classview/classviewmanager.h +++ b/src/plugins/classview/classviewmanager.h @@ -34,7 +34,6 @@ #define CLASSVIEWMANAGER_H #include <QtCore/QObject> -#include <QtCore/QScopedPointer> #include <QtCore/QSharedPointer> #include <QtGui/QStandardItem> @@ -43,7 +42,7 @@ namespace ClassView { namespace Internal { -class NavigationWidgetFactory; +class ManagerPrivate; /*! \class Manager @@ -62,13 +61,14 @@ class Manager : public QObject public: /*! \brief - \param widgetFactory NavigationWidgetFactory \param parent Parent object */ + explicit Manager(QObject *parent = 0); + virtual ~Manager(); //! Get an instance of Manager - static Manager *instance(QObject *parent = 0); + static Manager *instance(); /*! \brief Lazy data population for a \a QStandardItemModel @@ -236,11 +236,8 @@ protected: void setState(bool state); private: - explicit Manager(QObject *parent = 0); - -private: //! private class data pointer - QScopedPointer<struct ManagerPrivate> d_ptr; + ManagerPrivate *d; }; } // namespace Internal diff --git a/src/plugins/classview/classviewnavigationwidget.cpp b/src/plugins/classview/classviewnavigationwidget.cpp index 094f4de195..a88fccdb64 100644 --- a/src/plugins/classview/classviewnavigationwidget.cpp +++ b/src/plugins/classview/classviewnavigationwidget.cpp @@ -56,8 +56,9 @@ namespace Internal { \brief Internal data structures / methods for NavigationWidget */ -struct NavigationWidgetPrivate +class NavigationWidgetPrivate { +public: NavigationWidgetPrivate() : ui(0) {} //! Ui generated by Designer @@ -75,18 +76,18 @@ struct NavigationWidgetPrivate NavigationWidget::NavigationWidget(QWidget *parent) : QWidget(parent), - d_ptr(new NavigationWidgetPrivate()) + d(new NavigationWidgetPrivate()) { - d_ptr->ui = new Ui::NavigationWidget; - d_ptr->ui->setupUi(this); + d->ui = new Ui::NavigationWidget; + d->ui->setupUi(this); // tree model - d_ptr->treeModel = new TreeItemModel(this); - d_ptr->ui->treeView->setModel(d_ptr->treeModel); + d->treeModel = new TreeItemModel(this); + d->ui->treeView->setModel(d->treeModel); // connect signal/slots // selected item - connect(d_ptr->ui->treeView, SIGNAL(activated(QModelIndex)), SLOT(onItemActivated(QModelIndex))); + connect(d->ui->treeView, SIGNAL(activated(QModelIndex)), SLOT(onItemActivated(QModelIndex))); // connections to the manager Manager *manager = Manager::instance(); @@ -109,8 +110,9 @@ NavigationWidget::NavigationWidget(QWidget *parent) : NavigationWidget::~NavigationWidget() { - delete d_ptr->fullProjectsModeButton; - delete d_ptr->ui; + delete d->fullProjectsModeButton; + delete d->ui; + delete d; } void NavigationWidget::hideEvent(QHideEvent *event) @@ -134,41 +136,41 @@ QList<QToolButton *> NavigationWidget::createToolButtons() QList<QToolButton *> list; // full projects mode - if (!d_ptr->fullProjectsModeButton) { + if (!d->fullProjectsModeButton) { // create a button - d_ptr->fullProjectsModeButton = new QToolButton(); - d_ptr->fullProjectsModeButton->setIcon( + d->fullProjectsModeButton = new QToolButton(); + d->fullProjectsModeButton->setIcon( QIcon(QLatin1String(":/classview/images/hierarchicalmode.png"))); - d_ptr->fullProjectsModeButton->setCheckable(true); - d_ptr->fullProjectsModeButton->setToolTip(tr("Show Subprojects")); + d->fullProjectsModeButton->setCheckable(true); + d->fullProjectsModeButton->setToolTip(tr("Show Subprojects")); // by default - not a flat mode setFlatMode(false); // connections - connect(d_ptr->fullProjectsModeButton, SIGNAL(toggled(bool)), + connect(d->fullProjectsModeButton, SIGNAL(toggled(bool)), this, SLOT(onFullProjectsModeToggled(bool))); } - list << d_ptr->fullProjectsModeButton; + list << d->fullProjectsModeButton; return list; } bool NavigationWidget::flatMode() const { - QTC_ASSERT(d_ptr->fullProjectsModeButton, return false); + QTC_ASSERT(d->fullProjectsModeButton, return false); // button is 'full projects mode' - so it has to be inverted - return !d_ptr->fullProjectsModeButton->isChecked(); + return !d->fullProjectsModeButton->isChecked(); } void NavigationWidget::setFlatMode(bool flatMode) { - QTC_ASSERT(d_ptr->fullProjectsModeButton, return); + QTC_ASSERT(d->fullProjectsModeButton, return); // button is 'full projects mode' - so it has to be inverted - d_ptr->fullProjectsModeButton->setChecked(!flatMode); + d->fullProjectsModeButton->setChecked(!flatMode); } void NavigationWidget::onFullProjectsModeToggled(bool state) @@ -182,7 +184,7 @@ void NavigationWidget::onItemActivated(const QModelIndex &index) if (!index.isValid()) return; - QList<QVariant> list = d_ptr->treeModel->data(index, Constants::SymbolLocationsRole).toList(); + QList<QVariant> list = d->treeModel->data(index, Constants::SymbolLocationsRole).toList(); emit requestGotoLocations(list); } @@ -194,7 +196,7 @@ void NavigationWidget::onDataUpdate(QSharedPointer<QStandardItem> result) // if this is 1st call bool expandRootItems = false; - if (d_ptr->treeModel->invisibleRootItem()->rowCount() == 0) + if (d->treeModel->invisibleRootItem()->rowCount() == 0) expandRootItems = true; QTime timer; @@ -204,15 +206,15 @@ void NavigationWidget::onDataUpdate(QSharedPointer<QStandardItem> result) // might be just a root - if a lazy data population is enabled. // so expanded items must be parsed and 'fetched' - fetchExpandedItems(result.data(), d_ptr->treeModel->invisibleRootItem()); + fetchExpandedItems(result.data(), d->treeModel->invisibleRootItem()); - d_ptr->treeModel->moveRootToTarget(result.data()); + d->treeModel->moveRootToTarget(result.data()); // expand top level projects QModelIndex sessionIndex; - for (int i = 0; i < d_ptr->treeModel->rowCount(sessionIndex); ++i) - d_ptr->ui->treeView->expand(d_ptr->treeModel->index(i, 0, sessionIndex)); + for (int i = 0; i < d->treeModel->rowCount(sessionIndex); ++i) + d->ui->treeView->expand(d->treeModel->index(i, 0, sessionIndex)); if (debug) qDebug() << "Class View:" << QDateTime::currentDateTime().toString() @@ -224,8 +226,8 @@ void NavigationWidget::fetchExpandedItems(QStandardItem *item, const QStandardIt if (!item || !target) return; - const QModelIndex &parent = d_ptr->treeModel->indexFromItem(target); - if (d_ptr->ui->treeView->isExpanded(parent)) + const QModelIndex &parent = d->treeModel->indexFromItem(target); + if (d->ui->treeView->isExpanded(parent)) Manager::instance()->fetchMore(item, true); int itemIndex = 0; diff --git a/src/plugins/classview/classviewnavigationwidget.h b/src/plugins/classview/classviewnavigationwidget.h index d2450162ca..24d9af1594 100644 --- a/src/plugins/classview/classviewnavigationwidget.h +++ b/src/plugins/classview/classviewnavigationwidget.h @@ -33,18 +33,19 @@ #ifndef CLASSVIEWNAVIGATIONWIDGET_H #define CLASSVIEWNAVIGATIONWIDGET_H -#include <QtGui/QWidget> -#include <QtGui/QToolButton> -#include <QtGui/QStandardItem> +#include <QtCore/QList> #include <QtCore/QScopedPointer> #include <QtCore/QSharedPointer> -#include <QtCore/QList> -QT_FORWARD_DECLARE_CLASS(QModelIndex) +#include <QtGui/QStandardItem> +#include <QtGui/QToolButton> +#include <QtGui/QWidget> namespace ClassView { namespace Internal { +class NavigationWidgetPrivate; + /*! \class NavigationWidget \brief A widget for the class view tree @@ -141,7 +142,7 @@ protected: private: //! Private class data pointer - QScopedPointer<struct NavigationWidgetPrivate> d_ptr; + NavigationWidgetPrivate *d; }; } // namespace Internal diff --git a/src/plugins/classview/classviewnavigationwidgetfactory.cpp b/src/plugins/classview/classviewnavigationwidgetfactory.cpp index 411b60506d..4c4ae07f36 100644 --- a/src/plugins/classview/classviewnavigationwidgetfactory.cpp +++ b/src/plugins/classview/classviewnavigationwidgetfactory.cpp @@ -44,45 +44,23 @@ namespace ClassView { namespace Internal { -///////////////////////////////// NavigationWidget ////////////////////////////////// - -/*! - \struct NavigationWidgetFactoryPrivate - \brief Private class data for \a NavigationWidgetFactory - \sa NavigationWidgetFactory - */ -struct NavigationWidgetFactoryPrivate -{ - //! constructor - NavigationWidgetFactoryPrivate() : naviPaneEnabled(false) {} - - //! NavigationWidgetFactory instance - static NavigationWidgetFactory *instance; - - //! Navigation pane visibility - bool naviPaneEnabled; -}; - -// static variable initialization -NavigationWidgetFactory *NavigationWidgetFactoryPrivate::instance = 0; +static NavigationWidgetFactory *factoryInstance; ///////////////////////////////// NavigationWidgetFactory ////////////////////////////////// NavigationWidgetFactory::NavigationWidgetFactory() - : d_ptr(new NavigationWidgetFactoryPrivate()) { + factoryInstance = this; } NavigationWidgetFactory::~NavigationWidgetFactory() { - NavigationWidgetFactoryPrivate::instance = 0; + factoryInstance = 0; } NavigationWidgetFactory *NavigationWidgetFactory::instance() { - if (!NavigationWidgetFactoryPrivate::instance) - NavigationWidgetFactoryPrivate::instance = new NavigationWidgetFactory(); - return NavigationWidgetFactoryPrivate::instance; + return factoryInstance; } QString NavigationWidgetFactory::displayName() const @@ -92,12 +70,12 @@ QString NavigationWidgetFactory::displayName() const int NavigationWidgetFactory::priority() const { - return Constants::CLASSVIEWNAVIGATION_PRIORITY; + return 500; } QString NavigationWidgetFactory::id() const { - return QLatin1String(Constants::CLASSVIEWNAVIGATION_ID); + return QLatin1String("Class View"); } QKeySequence NavigationWidgetFactory::activationSequence() const @@ -115,15 +93,19 @@ Core::NavigationView NavigationWidgetFactory::createWidget() return navigationView; } -QString NavigationWidgetFactory::settingsPrefix(int position) const + +/*! + \brief Get a settings prefix for the specified position + \param position Position + \return Settings prefix + */ +static QString settingsPrefix(int position) { - QChar sep('/'); - QString group = QLatin1String(Constants::CLASSVIEW_SETTINGS_GROUP) + sep; - group += QLatin1String(Constants::CLASSVIEW_SETTINGS_TREEWIDGET_PREFIX) - + QString::number(position) + sep; - return group; + return QString::fromLatin1("ClassView/Treewidget.%1/FlatMode").arg(position); } +//! Flat mode settings + void NavigationWidgetFactory::saveSettings(int position, QWidget *widget) { NavigationWidget *pw = qobject_cast<NavigationWidget *>(widget); @@ -136,7 +118,7 @@ void NavigationWidgetFactory::saveSettings(int position, QWidget *widget) QString group = settingsPrefix(position); // save settings - settings->setValue(group + Constants::CLASSVIEW_SETTINGS_FLATMODE, pw->flatMode()); + settings->setValue(group, pw->flatMode()); } void NavigationWidgetFactory::restoreSettings(int position, QWidget *widget) @@ -151,7 +133,7 @@ void NavigationWidgetFactory::restoreSettings(int position, QWidget *widget) QString group = settingsPrefix(position); // load settings - pw->setFlatMode(settings->value(group + Constants::CLASSVIEW_SETTINGS_FLATMODE, false).toBool()); + pw->setFlatMode(settings->value(group, false).toBool()); } } // namespace Internal diff --git a/src/plugins/classview/classviewnavigationwidgetfactory.h b/src/plugins/classview/classviewnavigationwidgetfactory.h index 2160373016..260ac67427 100644 --- a/src/plugins/classview/classviewnavigationwidgetfactory.h +++ b/src/plugins/classview/classviewnavigationwidgetfactory.h @@ -35,8 +35,6 @@ #include <coreplugin/inavigationwidgetfactory.h> -#include <QtCore/QScopedPointer> - namespace ClassView { namespace Internal { @@ -54,10 +52,13 @@ class NavigationWidgetFactory : public Core::INavigationWidgetFactory Q_OBJECT public: - //! destructor - virtual ~NavigationWidgetFactory(); + //! Constructor + NavigationWidgetFactory(); - //! get an instance + //! Destructor + ~NavigationWidgetFactory(); + + //! Access to static instance static NavigationWidgetFactory *instance(); // Core::INavigationWidgetFactory @@ -82,28 +83,11 @@ public: //! \implements Core::INavigationWidgetFactory::restoreSettings void restoreSettings(int position, QWidget *widget); - // own functionality - signals: /*! \brief Signal which informs that the widget factory creates a widget. */ void widgetIsCreated(); - -private: - //! Constructor - NavigationWidgetFactory(); - - /*! - \brief Get a settings prefix for the specified position - \param position Position - \return Settings prefix - */ - QString settingsPrefix(int position) const; - -private: - //! private class data pointer - QScopedPointer<struct NavigationWidgetFactoryPrivate> d_ptr; }; } // namespace Internal diff --git a/src/plugins/classview/classviewparser.cpp b/src/plugins/classview/classviewparser.cpp index 9ef18f19fd..8aa1978c5f 100644 --- a/src/plugins/classview/classviewparser.cpp +++ b/src/plugins/classview/classviewparser.cpp @@ -72,8 +72,9 @@ namespace Internal { \brief Private class data for \a Parser \sa Parser */ -struct ParserPrivate +class ParserPrivate { +public: //! Constructor ParserPrivate() : flatMode(false) {} @@ -136,21 +137,22 @@ CPlusPlus::Document::Ptr ParserPrivate::document(const QString &fileName) const Parser::Parser(QObject *parent) : QObject(parent), - d_ptr(new ParserPrivate()) + d(new ParserPrivate()) { - d_ptr->timer = new QTimer(this); - d_ptr->timer->setSingleShot(true); + d->timer = new QTimer(this); + d->timer->setSingleShot(true); // connect signal/slots // internal data reset connect(this, SIGNAL(resetDataDone()), SLOT(onResetDataDone()), Qt::QueuedConnection); // timer for emitting changes - connect(d_ptr->timer, SIGNAL(timeout()), SLOT(requestCurrentState()), Qt::QueuedConnection); + connect(d->timer, SIGNAL(timeout()), SLOT(requestCurrentState()), Qt::QueuedConnection); } Parser::~Parser() { + delete d; } bool Parser::canFetchMore(QStandardItem *item) const @@ -171,11 +173,11 @@ void Parser::fetchMore(QStandardItem *item, bool skipRoot) const void Parser::setFlatMode(bool flatMode) { - if (flatMode == d_ptr->flatMode) + if (flatMode == d->flatMode) return; // change internal - d_ptr->flatMode = flatMode; + d->flatMode = flatMode; // regenerate and resend current tree emitCurrentTree(); @@ -197,10 +199,10 @@ ParserTreeItem::ConstPtr Parser::findItemByRoot(const QStandardItem *item, bool if (skipRoot && uiList.count() > 0) uiList.removeLast(); - QReadLocker locker(&d_ptr->rootItemLocker); + QReadLocker locker(&d->rootItemLocker); // using internal root - search correct item - ParserTreeItem::ConstPtr internal = d_ptr->rootItem; + ParserTreeItem::ConstPtr internal = d->rootItem; while(uiList.count() > 0) { cur = uiList.last(); @@ -229,7 +231,7 @@ ParserTreeItem::ConstPtr Parser::parse() continue; ParserTreeItem::Ptr item; - if (!d_ptr->flatMode) + if (!d->flatMode) item = ParserTreeItem::Ptr(new ParserTreeItem()); QString prjName(prj->displayName()); @@ -240,7 +242,7 @@ ParserTreeItem::ConstPtr Parser::parse() QStringList projectList = addProjectNode(item, prj->rootProjectNode()); - if (d_ptr->flatMode) { + if (d->flatMode) { // use prj path (prjType) as a project id // addProject(item, prj->files(ProjectExplorer::Project::ExcludeGeneratedFiles), prjType); //! \todo return back, works too long @@ -301,8 +303,8 @@ void Parser::addSymbol(const ParserTreeItem::Ptr &item, const CPlusPlus::Symbol if (symbolName && symbolName->isQualifiedNameId()) return; - QString name = d_ptr->overview.prettyName(symbol->name()).trimmed(); - QString type = d_ptr->overview.prettyType(symbol->type()).trimmed(); + QString name = d->overview.prettyName(symbol->name()).trimmed(); + QString type = d->overview.prettyType(symbol->type()).trimmed(); int iconType = CPlusPlus::Icons::iconTypeForSymbol(symbol); SymbolInformation information(name, type, iconType); @@ -352,13 +354,13 @@ void Parser::addSymbol(const ParserTreeItem::Ptr &item, const CPlusPlus::Symbol ParserTreeItem::Ptr Parser::createFlatTree(const QStringList &projectList) { - QReadLocker locker(&d_ptr->prjLocker); + QReadLocker locker(&d->prjLocker); ParserTreeItem::Ptr item(new ParserTreeItem()); foreach(const QString &project, projectList) { - if (!d_ptr->cachedPrjTrees.contains(project)) + if (!d->cachedPrjTrees.contains(project)) continue; - ParserTreeItem::ConstPtr list = d_ptr->cachedPrjTrees[project]; + ParserTreeItem::ConstPtr list = d->cachedPrjTrees[project]; item->add(list); } return item; @@ -373,7 +375,7 @@ ParserTreeItem::Ptr Parser::getParseProjectTree(const QStringList &fileList, unsigned revision = 0; foreach(const QString &file, fileList) { // ? locker for document?.. - const CPlusPlus::Document::Ptr &doc = d_ptr->document(file); + const CPlusPlus::Document::Ptr &doc = d->document(file); if (doc.isNull()) continue; @@ -389,10 +391,10 @@ ParserTreeItem::Ptr Parser::getParseProjectTree(const QStringList &fileList, // update the cache if (!projectId.isEmpty()) { - QWriteLocker locker(&d_ptr->prjLocker); + QWriteLocker locker(&d->prjLocker); - d_ptr->cachedPrjTrees[projectId] = item; - d_ptr->cachedPrjTreesRevision[projectId] = revision; + d->cachedPrjTrees[projectId] = item; + d->cachedPrjTreesRevision[projectId] = revision; } return item; } @@ -400,27 +402,27 @@ ParserTreeItem::Ptr Parser::getParseProjectTree(const QStringList &fileList, ParserTreeItem::Ptr Parser::getCachedOrParseProjectTree(const QStringList &fileList, const QString &projectId) { - d_ptr->prjLocker.lockForRead(); + d->prjLocker.lockForRead(); // calculate current revision - if (!projectId.isEmpty() && d_ptr->cachedPrjTrees.contains(projectId)) { + if (!projectId.isEmpty() && d->cachedPrjTrees.contains(projectId)) { // calculate project's revision unsigned revision = 0; foreach(const QString &file, fileList) { - const CPlusPlus::Document::Ptr &doc = d_ptr->document(file); + const CPlusPlus::Document::Ptr &doc = d->document(file); if (doc.isNull()) continue; revision += doc->revision(); } // if even revision is the same, return cached project - if (revision == d_ptr->cachedPrjTreesRevision[projectId]) { - d_ptr->prjLocker.unlock(); - return d_ptr->cachedPrjTrees[projectId]; + if (revision == d->cachedPrjTreesRevision[projectId]) { + d->prjLocker.unlock(); + return d->cachedPrjTrees[projectId]; } } - d_ptr->prjLocker.unlock(); + d->prjLocker.unlock(); return getParseProjectTree(fileList, projectId); } @@ -430,7 +432,7 @@ ParserTreeItem::ConstPtr Parser::getParseDocumentTree(const CPlusPlus::Document: return ParserTreeItem::ConstPtr(); const QString &fileName = doc->fileName(); - if (!d_ptr->fileList.contains(fileName)) + if (!d->fileList.contains(fileName)) return ParserTreeItem::ConstPtr(); ParserTreeItem::Ptr itemPtr(new ParserTreeItem()); @@ -439,11 +441,11 @@ ParserTreeItem::ConstPtr Parser::getParseDocumentTree(const CPlusPlus::Document: for (unsigned i = 0; i < total; ++i) addSymbol(itemPtr, doc->globalSymbolAt(i)); - QWriteLocker locker(&d_ptr->docLocker); + QWriteLocker locker(&d->docLocker); - d_ptr->cachedDocTrees[fileName] = itemPtr; - d_ptr->cachedDocTreesRevision[fileName] = doc->revision(); - d_ptr->documentList[fileName] = doc; + d->cachedDocTrees[fileName] = itemPtr; + d->cachedDocTreesRevision[fileName] = doc->revision(); + d->documentList[fileName] = doc; return itemPtr; } @@ -454,14 +456,14 @@ ParserTreeItem::ConstPtr Parser::getCachedOrParseDocumentTree(const CPlusPlus::D return ParserTreeItem::ConstPtr(); const QString &fileName = doc->fileName(); - d_ptr->docLocker.lockForRead(); - if (d_ptr->cachedDocTrees.contains(fileName) - && d_ptr->cachedDocTreesRevision.contains(fileName) - && d_ptr->cachedDocTreesRevision[fileName] == doc->revision()) { - d_ptr->docLocker.unlock(); - return d_ptr->cachedDocTrees[fileName]; + d->docLocker.lockForRead(); + if (d->cachedDocTrees.contains(fileName) + && d->cachedDocTreesRevision.contains(fileName) + && d->cachedDocTreesRevision[fileName] == doc->revision()) { + d->docLocker.unlock(); + return d->cachedDocTrees[fileName]; } else { - d_ptr->docLocker.unlock(); + d->docLocker.unlock(); return getParseDocumentTree(doc); } } @@ -474,48 +476,48 @@ void Parser::parseDocument(const CPlusPlus::Document::Ptr &doc) const QString &name = doc->fileName(); // if it is external file (not in any of our projects) - if (!d_ptr->fileList.contains(name)) + if (!d->fileList.contains(name)) return; getParseDocumentTree(doc); - QTC_ASSERT(d_ptr->timer, return); + QTC_ASSERT(d->timer, return); - if (!d_ptr->timer->isActive()) - d_ptr->timer->start(Constants::CLASSVIEW_EDITINGTREEUPDATE_DELAY); + if (!d->timer->isActive()) + d->timer->start(400); //! Delay in msecs before an update return; } void Parser::clearCacheAll() { - d_ptr->docLocker.lockForWrite(); + d->docLocker.lockForWrite(); - d_ptr->cachedDocTrees.clear(); - d_ptr->cachedDocTreesRevision.clear(); - d_ptr->documentList.clear(); + d->cachedDocTrees.clear(); + d->cachedDocTreesRevision.clear(); + d->documentList.clear(); - d_ptr->docLocker.unlock(); + d->docLocker.unlock(); clearCache(); } void Parser::clearCache() { - QWriteLocker locker(&d_ptr->prjLocker); + QWriteLocker locker(&d->prjLocker); // remove cached trees - d_ptr->cachedPrjFileLists.clear(); + d->cachedPrjFileLists.clear(); //! \todo where better to clear project's trees? //! When file is add/removed from a particular project?.. - d_ptr->cachedPrjTrees.clear(); - d_ptr->cachedPrjTreesRevision.clear(); + d->cachedPrjTrees.clear(); + d->cachedPrjTreesRevision.clear(); } void Parser::setFileList(const QStringList &fileList) { - d_ptr->fileList.clear(); - d_ptr->fileList = QSet<QString>::fromList(fileList); + d->fileList.clear(); + d->fileList = QSet<QString>::fromList(fileList); } void Parser::removeFiles(const QStringList &fileList) @@ -523,15 +525,15 @@ void Parser::removeFiles(const QStringList &fileList) if (fileList.count() == 0) return; - QWriteLocker lockerPrj(&d_ptr->prjLocker); - QWriteLocker lockerDoc(&d_ptr->docLocker); + QWriteLocker lockerPrj(&d->prjLocker); + QWriteLocker lockerDoc(&d->docLocker); foreach(const QString &name, fileList) { - d_ptr->fileList.remove(name); - d_ptr->cachedDocTrees.remove(name); - d_ptr->cachedDocTreesRevision.remove(name); - d_ptr->documentList.remove(name); - d_ptr->cachedPrjTrees.remove(name); - d_ptr->cachedPrjFileLists.clear(); + d->fileList.remove(name); + d->cachedDocTrees.remove(name); + d->cachedDocTreesRevision.remove(name); + d->documentList.remove(name); + d->cachedPrjTrees.remove(name); + d->cachedPrjFileLists.clear(); } emit filesAreRemoved(); @@ -542,15 +544,15 @@ void Parser::resetData(const CPlusPlus::Snapshot &snapshot) // clear internal cache clearCache(); - d_ptr->docLocker.lockForWrite(); + d->docLocker.lockForWrite(); // copy snapshot's documents CPlusPlus::Snapshot::const_iterator cur = snapshot.begin(); CPlusPlus::Snapshot::const_iterator end = snapshot.end(); for(; cur != end; cur++) - d_ptr->documentList[cur.key()] = cur.value(); + d->documentList[cur.key()] = cur.value(); - d_ptr->docLocker.unlock(); + d->docLocker.unlock(); // recalculate file list QStringList fileList; @@ -588,16 +590,16 @@ void Parser::requestCurrentState() void Parser::emitCurrentTree() { // stop timer if it is active right now - d_ptr->timer->stop(); + d->timer->stop(); - d_ptr->rootItemLocker.lockForWrite(); - d_ptr->rootItem = parse(); - d_ptr->rootItemLocker.unlock(); + d->rootItemLocker.lockForWrite(); + d->rootItem = parse(); + d->rootItemLocker.unlock(); // convert QSharedPointer<QStandardItem> std(new QStandardItem()); - d_ptr->rootItem->convertTo(std.data()); + d->rootItem->convertTo(std.data()); emit treeDataUpdate(std); } @@ -640,11 +642,11 @@ QStringList Parser::addProjectNode(const ParserTreeItem::Ptr &item, QStringList fileList; // try to improve parsing speed by internal cache - if (d_ptr->cachedPrjFileLists.contains(nodePath)) { - fileList = d_ptr->cachedPrjFileLists[nodePath]; + if (d->cachedPrjFileLists.contains(nodePath)) { + fileList = d->cachedPrjFileLists[nodePath]; } else { fileList = projectNodeFileList(node); - d_ptr->cachedPrjFileLists[nodePath] = fileList; + d->cachedPrjFileLists[nodePath] = fileList; } if (fileList.count() > 0) { addProject(item, fileList, node->path()); diff --git a/src/plugins/classview/classviewparser.h b/src/plugins/classview/classviewparser.h index ecefc1bb2c..8549b27cd9 100644 --- a/src/plugins/classview/classviewparser.h +++ b/src/plugins/classview/classviewparser.h @@ -37,11 +37,6 @@ #include "classviewparsertreeitem.h" -#include <QtCore/QList> -#include <QtGui/QStandardItem> -#include <QtCore/QScopedPointer> -#include <QtCore/QSharedPointer> - #include <CPlusPlusForwardDeclarations.h> #include <cplusplus/ModelManagerInterface.h> #include <cplusplus/CppDocument.h> @@ -50,9 +45,15 @@ #include <projectexplorer/projectnodes.h> #include <projectexplorer/project.h> +#include <QtCore/QList> +#include <QtCore/QSharedPointer> +#include <QtGui/QStandardItem> + namespace ClassView { namespace Internal { +class ParserPrivate; + /*! \class Parser \brief Parse cpp information. Multithreading is supported. @@ -259,7 +260,7 @@ protected: private: //! Private class data pointer - QScopedPointer<struct ParserPrivate> d_ptr; + ParserPrivate *d; }; } // namespace Internal diff --git a/src/plugins/classview/classviewparsertreeitem.cpp b/src/plugins/classview/classviewparsertreeitem.cpp index ebb6d706c0..c8474ecf28 100644 --- a/src/plugins/classview/classviewparsertreeitem.cpp +++ b/src/plugins/classview/classviewparsertreeitem.cpp @@ -56,8 +56,9 @@ namespace Internal { \brief Private class data for \a ParserTreeItem \sa ParserTreeItem */ -struct ParserTreeItemPrivate +class ParserTreeItemPrivate { +public: //! symbol locations QSet<SymbolLocation> symbolLocations; @@ -71,19 +72,20 @@ struct ParserTreeItemPrivate ///////////////////////////////// ParserTreeItem ////////////////////////////////// ParserTreeItem::ParserTreeItem() : - d_ptr(new ParserTreeItemPrivate()) + d(new ParserTreeItemPrivate()) { } ParserTreeItem::~ParserTreeItem() { + delete d; } ParserTreeItem &ParserTreeItem::operator=(const ParserTreeItem &other) { - d_ptr->symbolLocations = other.d_ptr->symbolLocations; - d_ptr->icon = other.d_ptr->icon; - d_ptr->symbolInformations.clear(); + d->symbolLocations = other.d->symbolLocations; + d->icon = other.d->icon; + d->symbolInformations.clear(); return *this; } @@ -92,9 +94,9 @@ void ParserTreeItem::copy(const ParserTreeItem::ConstPtr &from) if (from.isNull()) return; - d_ptr->symbolLocations = from->d_ptr->symbolLocations; - d_ptr->icon = from->d_ptr->icon; - d_ptr->symbolInformations = from->d_ptr->symbolInformations; + d->symbolLocations = from->d->symbolLocations; + d->icon = from->d->icon; + d->symbolInformations = from->d->symbolInformations; } void ParserTreeItem::copyTree(const ParserTreeItem::ConstPtr &target) @@ -103,9 +105,9 @@ void ParserTreeItem::copyTree(const ParserTreeItem::ConstPtr &target) return; // copy content - d_ptr->symbolLocations = target->d_ptr->symbolLocations; - d_ptr->icon = target->d_ptr->icon; - d_ptr->symbolInformations.clear(); + d->symbolLocations = target->d->symbolLocations; + d->icon = target->d->icon; + d->symbolInformations.clear(); // reserve memory // int amount = qMin(100 , target->d_ptr->symbolInformations.count() * 2); @@ -113,9 +115,9 @@ void ParserTreeItem::copyTree(const ParserTreeItem::ConstPtr &target) // every child QHash<SymbolInformation, ParserTreeItem::Ptr>::const_iterator cur = - target->d_ptr->symbolInformations.constBegin(); + target->d->symbolInformations.constBegin(); QHash<SymbolInformation, ParserTreeItem::Ptr>::const_iterator end = - target->d_ptr->symbolInformations.constEnd(); + target->d->symbolInformations.constEnd(); for(; cur != end; cur++) { ParserTreeItem::Ptr item(new ParserTreeItem()); @@ -126,27 +128,27 @@ void ParserTreeItem::copyTree(const ParserTreeItem::ConstPtr &target) void ParserTreeItem::addSymbolLocation(const SymbolLocation &location) { - d_ptr->symbolLocations.insert(location); + d->symbolLocations.insert(location); } void ParserTreeItem::addSymbolLocation(const QSet<SymbolLocation> &locations) { - d_ptr->symbolLocations.unite(locations); + d->symbolLocations.unite(locations); } void ParserTreeItem::removeSymbolLocation(const SymbolLocation &location) { - d_ptr->symbolLocations.remove(location); + d->symbolLocations.remove(location); } void ParserTreeItem::removeSymbolLocations(const QSet<SymbolLocation> &locations) { - d_ptr->symbolLocations.subtract(locations); + d->symbolLocations.subtract(locations); } QSet<SymbolLocation> ParserTreeItem::symbolLocations() const { - return d_ptr->symbolLocations; + return d->symbolLocations; } void ParserTreeItem::appendChild(const ParserTreeItem::Ptr &item, const SymbolInformation &inf) @@ -155,34 +157,34 @@ void ParserTreeItem::appendChild(const ParserTreeItem::Ptr &item, const SymbolIn if (item.isNull()) return; - d_ptr->symbolInformations[inf] = item; + d->symbolInformations[inf] = item; } void ParserTreeItem::removeChild(const SymbolInformation &inf) { - d_ptr->symbolInformations.remove(inf); + d->symbolInformations.remove(inf); } ParserTreeItem::Ptr ParserTreeItem::child(const SymbolInformation &inf) const { - if (!d_ptr->symbolInformations.contains(inf)) + if (!d->symbolInformations.contains(inf)) return ParserTreeItem::Ptr(); - return d_ptr->symbolInformations[inf]; + return d->symbolInformations[inf]; } int ParserTreeItem::childCount() const { - return d_ptr->symbolInformations.count(); + return d->symbolInformations.count(); } QIcon ParserTreeItem::icon() const { - return d_ptr->icon; + return d->icon; } void ParserTreeItem::setIcon(const QIcon &icon) { - d_ptr->icon = icon; + d->icon = icon; } void ParserTreeItem::add(const ParserTreeItem::ConstPtr &target) @@ -191,31 +193,31 @@ void ParserTreeItem::add(const ParserTreeItem::ConstPtr &target) return; // add locations - d_ptr->symbolLocations = d_ptr->symbolLocations.unite(target->d_ptr->symbolLocations); + d->symbolLocations = d->symbolLocations.unite(target->d->symbolLocations); // add children // every target child QHash<SymbolInformation, ParserTreeItem::Ptr>::const_iterator cur = - target->d_ptr->symbolInformations.constBegin(); + target->d->symbolInformations.constBegin(); QHash<SymbolInformation, ParserTreeItem::Ptr>::const_iterator end = - target->d_ptr->symbolInformations.constEnd(); + target->d->symbolInformations.constEnd(); while(cur != end) { const SymbolInformation &inf = cur.key(); const ParserTreeItem::Ptr &targetChild = cur.value(); - if (d_ptr->symbolInformations.contains(inf)) { + if (d->symbolInformations.contains(inf)) { // this item has the same child node - const ParserTreeItem::Ptr &child = d_ptr->symbolInformations[inf]; + const ParserTreeItem::Ptr &child = d->symbolInformations[inf]; if (!child.isNull()) { child->add(targetChild); } else { ParserTreeItem::Ptr add(new ParserTreeItem()); add->copyTree(targetChild); - d_ptr->symbolInformations[inf] = add; + d->symbolInformations[inf] = add; } } else { ParserTreeItem::Ptr add(new ParserTreeItem()); add->copyTree(targetChild); - d_ptr->symbolInformations[inf] = add; + d->symbolInformations[inf] = add; } // next item ++cur; @@ -229,18 +231,18 @@ void ParserTreeItem::subtract(const ParserTreeItem::ConstPtr &target) // every target child QHash<SymbolInformation, ParserTreeItem::Ptr>::const_iterator cur = - target->d_ptr->symbolInformations.constBegin(); + target->d->symbolInformations.constBegin(); QHash<SymbolInformation, ParserTreeItem::Ptr>::const_iterator end = - target->d_ptr->symbolInformations.constEnd(); + target->d->symbolInformations.constEnd(); while(cur != end) { const SymbolInformation &inf = cur.key(); - if (d_ptr->symbolInformations.contains(inf)) { + if (d->symbolInformations.contains(inf)) { // this item has the same child node - if (!d_ptr->symbolInformations[inf].isNull()) - d_ptr->symbolInformations[inf]->subtract(cur.value()); - if (d_ptr->symbolInformations[inf].isNull() - || d_ptr->symbolInformations[inf]->childCount() == 0) - d_ptr->symbolInformations.remove(inf); + if (!d->symbolInformations[inf].isNull()) + d->symbolInformations[inf]->subtract(cur.value()); + if (d->symbolInformations[inf].isNull() + || d->symbolInformations[inf]->childCount() == 0) + d->symbolInformations.remove(inf); } // next item ++cur; @@ -256,9 +258,9 @@ void ParserTreeItem::convertTo(QStandardItem *item, bool recursive) const // convert to map - to sort it QHash<SymbolInformation, ParserTreeItem::Ptr>::const_iterator curHash = - d_ptr->symbolInformations.constBegin(); + d->symbolInformations.constBegin(); QHash<SymbolInformation, ParserTreeItem::Ptr>::const_iterator endHash = - d_ptr->symbolInformations.constEnd(); + d->symbolInformations.constEnd(); while(curHash != endHash) { map.insert(curHash.key(), curHash.value()); ++curHash; @@ -308,9 +310,9 @@ bool ParserTreeItem::canFetchMore(QStandardItem *item) const // children for the internal state int internalChildren = 0; QHash<SymbolInformation, ParserTreeItem::Ptr>::const_iterator curHash = - d_ptr->symbolInformations.constBegin(); + d->symbolInformations.constBegin(); QHash<SymbolInformation, ParserTreeItem::Ptr>::const_iterator endHash = - d_ptr->symbolInformations.constEnd(); + d->symbolInformations.constEnd(); while(curHash != endHash) { const ParserTreeItem::Ptr &child = curHash.value(); if (!child.isNull()) { @@ -340,8 +342,8 @@ void ParserTreeItem::fetchMore(QStandardItem *item) const const SymbolInformation &childInf = Utils::symbolInformationFromItem(child); - if (d_ptr->symbolInformations.contains(childInf)) { - const ParserTreeItem::Ptr &childPtr = d_ptr->symbolInformations[childInf]; + if (d->symbolInformations.contains(childInf)) { + const ParserTreeItem::Ptr &childPtr = d->symbolInformations[childInf]; if (childPtr.isNull()) continue; @@ -357,9 +359,9 @@ void ParserTreeItem::fetchMore(QStandardItem *item) const void ParserTreeItem::debugDump(int ident) const { QHash<SymbolInformation, ParserTreeItem::Ptr>::const_iterator curHash = - d_ptr->symbolInformations.constBegin(); + d->symbolInformations.constBegin(); QHash<SymbolInformation, ParserTreeItem::Ptr>::const_iterator endHash = - d_ptr->symbolInformations.constEnd(); + d->symbolInformations.constEnd(); while(curHash != endHash) { const SymbolInformation &inf = curHash.key(); qDebug() << QString(2*ident, QChar(' ')) << inf.iconType() << inf.name() << inf.type() diff --git a/src/plugins/classview/classviewparsertreeitem.h b/src/plugins/classview/classviewparsertreeitem.h index 485573f4f7..fb386deba3 100644 --- a/src/plugins/classview/classviewparsertreeitem.h +++ b/src/plugins/classview/classviewparsertreeitem.h @@ -37,13 +37,14 @@ #include "classviewsymbolinformation.h" #include <QtCore/QSharedPointer> -#include <QtCore/QScopedPointer> QT_FORWARD_DECLARE_CLASS(QStandardItem) namespace ClassView { namespace Internal { +class ParserTreeItemPrivate; + /*! \class ParserTreeItem \brief Item for the internal Class View Tree @@ -184,7 +185,7 @@ protected: private: //! Private class data pointer - QScopedPointer<struct ParserTreeItemPrivate> d_ptr; + ParserTreeItemPrivate *d; }; } // namespace Internal diff --git a/src/plugins/classview/classviewplugin.cpp b/src/plugins/classview/classviewplugin.cpp index 992db4f16c..0b3f360132 100644 --- a/src/plugins/classview/classviewplugin.cpp +++ b/src/plugins/classview/classviewplugin.cpp @@ -39,53 +39,25 @@ namespace ClassView { namespace Internal { -///////////////////////////////// PluginPrivate ////////////////////////////////// -/*! - \struct PluginPrivate - \brief Private class data for \a Plugin - \sa Plugin - */ -struct PluginPrivate -{ - //! Pointer to Navi Widget Factory - QPointer<NavigationWidgetFactory> navigationWidgetFactory; - - //! Pointer to Manager - QPointer<Manager> manager; -}; - ///////////////////////////////// Plugin ////////////////////////////////// -Plugin::Plugin() - : d_ptr(new PluginPrivate()) -{ -} - -Plugin::~Plugin() -{ -} - bool Plugin::initialize(const QStringList &arguments, QString *errorMessage) { Q_UNUSED(arguments) Q_UNUSED(errorMessage) // create a navigation widget factory - d_ptr->navigationWidgetFactory = NavigationWidgetFactory::instance(); + (void) new NavigationWidgetFactory; // add to ExtensionSystem - addAutoReleasedObject(d_ptr->navigationWidgetFactory); + addAutoReleasedObject(NavigationWidgetFactory::instance()); // create manager - d_ptr->manager = Manager::instance(this); + (void) new Manager(this); return true; } -void Plugin::extensionsInitialized() -{ -} - } // namespace Internal } // namespace ClassView diff --git a/src/plugins/classview/classviewplugin.h b/src/plugins/classview/classviewplugin.h index e386da66ae..351f91ca52 100644 --- a/src/plugins/classview/classviewplugin.h +++ b/src/plugins/classview/classviewplugin.h @@ -35,8 +35,6 @@ #include <extensionsystem/iplugin.h> -#include <QtCore/QScopedPointer> - namespace ClassView { namespace Internal { @@ -51,20 +49,13 @@ class Plugin : public ExtensionSystem::IPlugin public: //! Constructor - Plugin(); - - //! Destructor - virtual ~Plugin(); + Plugin() {} //! \implements ExtensionSystem::IPlugin::initialize bool initialize(const QStringList &arguments, QString *error_message = 0); //! \implements ExtensionSystem::IPlugin::extensionsInitialized - void extensionsInitialized(); - -private: - //! private class data pointer - QScopedPointer<struct PluginPrivate> d_ptr; + void extensionsInitialized() {} }; } // namespace Internal diff --git a/src/plugins/classview/classviewtreeitemmodel.cpp b/src/plugins/classview/classviewtreeitemmodel.cpp index 4ba284111f..d767a84c64 100644 --- a/src/plugins/classview/classviewtreeitemmodel.cpp +++ b/src/plugins/classview/classviewtreeitemmodel.cpp @@ -47,8 +47,9 @@ namespace Internal { \brief Private class data for \a TreeItemModel \sa TreeItemModel */ -struct TreeItemModelPrivate +class TreeItemModelPrivate { +public: //! icon provider CPlusPlus::Icons icons; }; @@ -57,12 +58,13 @@ struct TreeItemModelPrivate TreeItemModel::TreeItemModel(QObject *parent) : QStandardItemModel(parent), - d_ptr(new TreeItemModelPrivate()) + d(new TreeItemModelPrivate()) { } TreeItemModel::~TreeItemModel() { + delete d; } QVariant TreeItemModel::data(const QModelIndex &index, int role) const @@ -77,7 +79,7 @@ QVariant TreeItemModel::data(const QModelIndex &index, int role) const bool ok = false; int type = iconType.toInt(&ok); if (ok && type >= 0) - return d_ptr->icons.iconForType(static_cast<CPlusPlus::Icons::IconType>(type)); + return d->icons.iconForType(static_cast<CPlusPlus::Icons::IconType>(type)); } } break; diff --git a/src/plugins/classview/classviewtreeitemmodel.h b/src/plugins/classview/classviewtreeitemmodel.h index 1ad1dd2c67..4f041b2754 100644 --- a/src/plugins/classview/classviewtreeitemmodel.h +++ b/src/plugins/classview/classviewtreeitemmodel.h @@ -34,13 +34,12 @@ #define CLASSVIEWTREEITEMMODEL_H #include <QtGui/QStandardItemModel> -#include <QtCore/QModelIndex> -#include <QtCore/QScopedPointer> -#include <QtCore/QSet> namespace ClassView { namespace Internal { +class TreeItemModelPrivate; + /*! \class TreeItemModel \brief Model for Class View Tree @@ -71,7 +70,7 @@ public: private: //! private class data pointer - QScopedPointer<struct TreeItemModelPrivate> d_ptr; + TreeItemModelPrivate *d; }; } // namespace Internal |