Commit 51d83e4c authored by hjk's avatar hjk Committed by hjk

classview: adjust to d-pointer style rules

Change-Id: Ie413a7336ef4bde5dcf1b43b6832167742608a83
Reviewed-on: http://codereview.qt.nokia.com/1296Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent 2bdc5c79
......@@ -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
......
......@@ -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);
......
......@@ -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
......@@ -235,12 +235,9 @@ 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
......
......@@ -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;
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
This diff is collapsed.
......@@ -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
......
......@@ -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;