Doc: move Class View plugin docs to .cpp files.

QDoc does not find docs in the .h files.
Use \brief only for namespaces, classes, enums, and properties.
Use standard wording for \brief and \fn.
Use \a and \c according to guidelines.

Fix grammar and style.

Change-Id: Ib685a03c97ef38661ecc156f61d70085514357fc
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
Leena Miettinen
2013-05-24 17:35:14 +02:00
committed by Erik Verbruggen
parent 5b268822cf
commit 3f843aca67
20 changed files with 610 additions and 492 deletions

View File

@@ -58,11 +58,89 @@ namespace Internal {
static Manager *managerInstance = 0; static Manager *managerInstance = 0;
/*! /*!
\struct ManagerPrivate \class ClassView::Internal::Manager
\brief The Manager class implements a class view manager that interacts with
other \QC plugins and acts as a proxy between them and the parser.
The parser is moved to a separate thread and is connected to the manager by
using signals and slots. Manager's signals starting with 'request' are for
the parser.
*/
/*!
\fn explicit ClassView::Internal::Manager(QObject *parent = 0)
Creates a shared instance of a \a parent object.
*/
/*!
\fn void ClassView::Internal::Manager::stateChanged(bool state)
Changes the internal manager state. \a state returns true if manager is
enabled, otherwise false.
\sa setState, state
*/
/*!
\fn void ClassView::Internal::Manager::treeDataUpdate(QSharedPointer<QStandardItem> result)
Emits a signal about a tree data update (to tree view). \a result holds the
item with the current tree.
*/
/*!
\fn void ClassView::Internal::Manager::requestTreeDataUpdate()
Emits a signal that a request for sending the tree view has to be handled by
listeners (the parser).
\sa onRequestTreeDataUpdate
*/
/*!
\fn void ClassView::Internal::Manager::requestDocumentUpdated(CPlusPlus::Document::Ptr doc)
Emits a signal that \a doc was updated and has to be reparsed.
\sa onDocumentUpdated
*/
/*!
\fn void ClassView::Internal::Manager::requestResetCurrentState()
Emits a signal that the parser has to reset its internal state to the
current state from the code manager.
*/
/*!
\fn void ClassView::Internal::Manager::requestClearCache()
Requests the parser to clear a cache.
*/
/*!
\fn void ClassView::Internal::Manager::requestClearCacheAll()
Requests the parser to clear a full cache.
*/
/*!
\fn void ClassView::Internal::Manager::requestSetFlatMode(bool flat)
Requests the manager to set the flat mode without subprojects. Set \a flat
to \c true to enable flat mode and to false to disable it.
*/
/*!
\class ManagerPrivate
\internal \internal
\brief Private class data for \a Manager \brief The ManagerPrivate class contains private class data for the Manager
class.
\sa Manager \sa Manager
*/ */
class ManagerPrivate class ManagerPrivate
{ {
public: public:
@@ -118,11 +196,20 @@ Manager *Manager::instance()
return managerInstance; return managerInstance;
} }
/*!
Checks \a item for lazy data population of a QStandardItemModel.
*/
bool Manager::canFetchMore(QStandardItem *item) const bool Manager::canFetchMore(QStandardItem *item) const
{ {
return d->parser.canFetchMore(item); return d->parser.canFetchMore(item);
} }
/*!
Checks \a item for lazy data population of a QStandardItemModel.
\a skipRoot item is needed for the manual update, call not from model.
*/
void Manager::fetchMore(QStandardItem *item, bool skipRoot) void Manager::fetchMore(QStandardItem *item, bool skipRoot)
{ {
d->parser.fetchMore(item, skipRoot); d->parser.fetchMore(item, skipRoot);
@@ -193,11 +280,27 @@ void Manager::initialize()
&d->parser, SLOT(removeFiles(QStringList)), Qt::QueuedConnection); &d->parser, SLOT(removeFiles(QStringList)), Qt::QueuedConnection);
} }
/*!
Gets the internal manager state. If it is disabled, does not emit signals
about parsing requests. If enabled, does parsing in the background even if
the navigation pane is not visible. Returns true if the manager is enabled,
false otherwise.
\sa setState, stateChanged
*/
bool Manager::state() const bool Manager::state() const
{ {
return d->state; return d->state;
} }
/*!
Sets the internal manager \a state to \c true if the manager has to be
enabled, otherwise sets it to \c false.
\sa state, stateChanged
*/
void Manager::setState(bool state) void Manager::setState(bool state)
{ {
QMutexLocker locker(&d->mutexState); QMutexLocker locker(&d->mutexState);
@@ -211,11 +314,24 @@ void Manager::setState(bool state)
emit stateChanged(d->state); emit stateChanged(d->state);
} }
/*!
Reacts to the widget factory creating a widget.
\sa setState, state
*/
void Manager::onWidgetIsCreated() void Manager::onWidgetIsCreated()
{ {
// do nothing - continue to sleep // do nothing - continue to sleep
} }
/*!
Reacts to the \a visibility of one navigation pane widget being changed
(there might be a lot of them).
\sa setState, state
*/
void Manager::onWidgetVisibilityIsChanged(bool visibility) void Manager::onWidgetVisibilityIsChanged(bool visibility)
{ {
// activate data handling - when 1st time 'Class View' will be open // activate data handling - when 1st time 'Class View' will be open
@@ -223,6 +339,13 @@ void Manager::onWidgetVisibilityIsChanged(bool visibility)
setState(true); setState(true);
} }
/*!
Reacts to the state changed signal for the current manager \a state.
For example, requests the currect code snapshot if needed.
\sa setState, state, stateChanged
*/
void Manager::onStateChanged(bool state) void Manager::onStateChanged(bool state)
{ {
if (state) { if (state) {
@@ -234,6 +357,11 @@ void Manager::onStateChanged(bool state)
} }
} }
/*!
Reacts to the project list being changed by updating the navigation pane
visibility if necessary.
*/
void Manager::onProjectListChanged() void Manager::onProjectListChanged()
{ {
// do nothing if Manager is disabled // do nothing if Manager is disabled
@@ -244,6 +372,13 @@ void Manager::onProjectListChanged()
requestTreeDataUpdate(); requestTreeDataUpdate();
} }
/*!
Handles parse tasks started by the progress manager. \a type holds the
task index, which should be \c CppTools::Constants::TASK_INDEX.
\sa CppTools::Constants::TASK_INDEX
*/
void Manager::onTaskStarted(const QString &type) void Manager::onTaskStarted(const QString &type)
{ {
if (type != QLatin1String(CppTools::Constants::TASK_INDEX)) if (type != QLatin1String(CppTools::Constants::TASK_INDEX))
@@ -253,6 +388,13 @@ void Manager::onTaskStarted(const QString &type)
d->disableCodeParser = true; d->disableCodeParser = true;
} }
/*!
Handles parse tasks finished by the progress manager.\a type holds the
task index, which should be \c CppTools::Constants::TASK_INDEX.
\sa CppTools::Constants::TASK_INDEX
*/
void Manager::onAllTasksFinished(const QString &type) void Manager::onAllTasksFinished(const QString &type)
{ {
if (type != QLatin1String(CppTools::Constants::TASK_INDEX)) if (type != QLatin1String(CppTools::Constants::TASK_INDEX))
@@ -272,6 +414,13 @@ void Manager::onAllTasksFinished(const QString &type)
emit requestResetCurrentState(); emit requestResetCurrentState();
} }
/*!
Emits the signal \c documentUpdated when the code model manager state is
changed for \a doc.
\sa documentUpdated
*/
void Manager::onDocumentUpdated(CPlusPlus::Document::Ptr doc) void Manager::onDocumentUpdated(CPlusPlus::Document::Ptr doc)
{ {
// do nothing if Manager is disabled // do nothing if Manager is disabled
@@ -285,6 +434,11 @@ void Manager::onDocumentUpdated(CPlusPlus::Document::Ptr doc)
emit requestDocumentUpdated(doc); emit requestDocumentUpdated(doc);
} }
/*!
Opens the text editor for the file \a fileName on \a line (1-based) and
\a column (1-based).
*/
void Manager::gotoLocation(const QString &fileName, int line, int column) void Manager::gotoLocation(const QString &fileName, int line, int column)
{ {
bool newEditor = false; bool newEditor = false;
@@ -293,6 +447,12 @@ void Manager::gotoLocation(const QString &fileName, int line, int column)
&newEditor); &newEditor);
} }
/*!
Opens the text editor for any of the symbol locations in the \a list.
\sa Manager::gotoLocations
*/
void Manager::gotoLocations(const QList<QVariant> &list) void Manager::gotoLocations(const QList<QVariant> &list)
{ {
QSet<SymbolLocation> locations = Utils::roleToLocations(list); QSet<SymbolLocation> locations = Utils::roleToLocations(list);
@@ -344,6 +504,13 @@ void Manager::gotoLocations(const QList<QVariant> &list)
gotoLocation(loc.fileName(), loc.line(), loc.column()); gotoLocation(loc.fileName(), loc.line(), loc.column());
} }
/*!
Emits the signal \c requestTreeDataUpdate if the latest tree info is
requested and if parsing is enabled.
\sa requestTreeDataUpdate, NavigationWidget::requestDataUpdate
*/
void Manager::onRequestTreeDataUpdate() void Manager::onRequestTreeDataUpdate()
{ {
// do nothing if Manager is disabled // do nothing if Manager is disabled
@@ -353,11 +520,20 @@ void Manager::onRequestTreeDataUpdate()
emit requestTreeDataUpdate(); emit requestTreeDataUpdate();
} }
/*!
Switches to flat mode (without subprojects) if \a flat is set to \c true.
*/
void Manager::setFlatMode(bool flat) void Manager::setFlatMode(bool flat)
{ {
emit requestSetFlatMode(flat); emit requestSetFlatMode(flat);
} }
/*!
Sends a new tree data update to a tree view. \a result holds the item with
the current tree.
*/
void Manager::onTreeDataUpdate(QSharedPointer<QStandardItem> result) void Manager::onTreeDataUpdate(QSharedPointer<QStandardItem> result)
{ {
// do nothing if Manager is disabled // do nothing if Manager is disabled

View File

@@ -41,25 +41,11 @@ namespace Internal {
class ManagerPrivate; class ManagerPrivate;
/*!
\class Manager
\brief Class View manager
Class View Manager. Interacts with other Qt Creator plugins - this is a proxy between them and
parser.
\a Parser is moved to a separate thread and is connected to \a Manager by signal/slots.
Manager's signals starting with 'request' are for Parser.
*/
class Manager : public QObject class Manager : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
/*!
\brief Creates shared instance
\param parent Parent object
*/
explicit Manager(QObject *parent = 0); explicit Manager(QObject *parent = 0);
virtual ~Manager(); virtual ~Manager();
@@ -67,169 +53,59 @@ public:
//! Get an instance of Manager //! Get an instance of Manager
static Manager *instance(); static Manager *instance();
/*!
\brief Lazy data population for a \a QStandardItemModel
\param item Item with has to be checked
*/
bool canFetchMore(QStandardItem *item) const; bool canFetchMore(QStandardItem *item) const;
/*!
\brief Lazy data population for a \a QStandardItemModel
\param item Item with has to be checked
\param skipRoot Skip root item (is needed for the manual update, call not from model)
*/
void fetchMore(QStandardItem *item, bool skipRoot = false); void fetchMore(QStandardItem *item, bool skipRoot = false);
signals: signals:
/*!
\brief Internal Manager state is changed.
\param state true if Manager is enabled, false otherwise
\sa setState, state
*/
void stateChanged(bool state); void stateChanged(bool state);
/*!
\brief Signal about a tree data update (to tree view).
\param result Item with the current tree
*/
void treeDataUpdate(QSharedPointer<QStandardItem> result); void treeDataUpdate(QSharedPointer<QStandardItem> result);
/*!
\brief Signal that a request for sending tree view has to be handled by listeners (parser).
\sa onRequestTreeDataUpdate
*/
void requestTreeDataUpdate(); void requestTreeDataUpdate();
/*!
\brief Signal that document is updated (and has to be reparsed)
\param doc Updated document
\sa onDocumentUpdated
*/
void requestDocumentUpdated(CPlusPlus::Document::Ptr doc); void requestDocumentUpdated(CPlusPlus::Document::Ptr doc);
/*!
\brief Signal that parser has to reset its internal state to the current (from code manager).
*/
void requestResetCurrentState(); void requestResetCurrentState();
/*!
\brief Request to clear a cache by parser.
*/
void requestClearCache(); void requestClearCache();
/*!
\brief Request to clear a full cache by parser.
*/
void requestClearCacheAll(); void requestClearCacheAll();
/*!
\brief Request to set the flat mode (without subprojects)
\param flat True to enable flat mode, false to disable
*/
void requestSetFlatMode(bool flat); void requestSetFlatMode(bool flat);
public slots: public slots:
/*!
\brief Open text editor for file \a fileName on line \a lineNumber and column \a column.
\param fileName File which has to be open
\param line Line number, 1-based
\param column Column, 1-based
*/
void gotoLocation(const QString &fileName, int line = 0, int column = 0); void gotoLocation(const QString &fileName, int line = 0, int column = 0);
/*!
\brief Open text editor for any of location in the list (correctly)
\param locations Symbol locations
\sa Manager::gotoLocations
*/
void gotoLocations(const QList<QVariant> &locations); void gotoLocations(const QList<QVariant> &locations);
/*!
\brief If somebody wants to receive the latest tree info, if a parsing is enabled then
a signal \a requestTreeDataUpdate will be emitted.
\sa requestTreeDataUpdate, NavigationWidget::requestDataUpdate
*/
void onRequestTreeDataUpdate(); void onRequestTreeDataUpdate();
/*!
\brief Switch to flat mode (without subprojects)
\param flat True to enable flat mode, false to disable
*/
void setFlatMode(bool flat); void setFlatMode(bool flat);
protected slots: protected slots:
/*!
\brief Widget factory creates a widget, handle this situation.
\sa setState, state
*/
void onWidgetIsCreated(); void onWidgetIsCreated();
/*!
\brief Widget visibility is changed
\param visibility Visibility (for just 1 navi pane widget, there might be a lot of them)
\sa setState, state
*/
void onWidgetVisibilityIsChanged(bool visibility); void onWidgetVisibilityIsChanged(bool visibility);
/*!
\brief Reacts to the state changed signal, e.g. request currect code snapshot if needed etc.
\param state Current Manager state
\sa setState, state, stateChanged
*/
void onStateChanged(bool state); void onStateChanged(bool state);
/*!
\brief Project list is changed (navigation pane visibility might be needed to update).
*/
void onProjectListChanged(); void onProjectListChanged();
/*!
\brief This slot should called when the code model manager state is changed for \a doc.
It will emit a signal \a documentUpdated if
\param doc Updated document.
\sa documentUpdated
*/
void onDocumentUpdated(CPlusPlus::Document::Ptr doc); void onDocumentUpdated(CPlusPlus::Document::Ptr doc);
/*!
\brief Progress manager started a task. Do what is needed if it is a parse task.
\param type Task index, should be CppTools::Constants::TASK_INDEX for us
\sa CppTools::Constants::TASK_INDEX
*/
void onTaskStarted(const QString &type); void onTaskStarted(const QString &type);
/*!
\brief Progress manager finished all task with specified type.
Do what is needed if it is a parse task.
\param type Task index, should be CppTools::Constants::TASK_INDEX for us
\sa CppTools::Constants::TASK_INDEX
*/
void onAllTasksFinished(const QString &type); void onAllTasksFinished(const QString &type);
/*!
\brief New tree data update (has to be sent to a tree view).
\param result Item with the current tree
*/
void onTreeDataUpdate(QSharedPointer<QStandardItem> result); void onTreeDataUpdate(QSharedPointer<QStandardItem> result);
protected: protected:
//! Perform an initialization //! Perform an initialization
void initialize(); void initialize();
/*!
\brief Get internal Manager state. If it is disabled, signals about parsing request has not
to be emitted at all, if enabled - do parsing in the background even if navi pane
is not visible.
\return true if Manager is enabled, false otherwise
\sa setState, stateChanged
*/
inline bool state() const; inline bool state() const;
/*!
\brief Set internal Manager state.
\param state true if Manager has to be enabled, false otherwise
\sa state, stateChanged
*/
void setState(bool state); void setState(bool state);
private: private:

View File

@@ -49,8 +49,10 @@ namespace Internal {
///////////////////////////////// NavigationWidgetPrivate ////////////////////////////////// ///////////////////////////////// NavigationWidgetPrivate //////////////////////////////////
/*! /*!
\struct NavigationWidgetPrivate \class NavigationWidgetPrivate
\brief Internal data structures / methods for NavigationWidget
The NavigationWidgetPrivate class provides internal data structures and
methods for NavigationWidget.
*/ */
class NavigationWidgetPrivate class NavigationWidgetPrivate
@@ -70,6 +72,47 @@ public:
///////////////////////////////// NavigationWidget ////////////////////////////////// ///////////////////////////////// NavigationWidget //////////////////////////////////
/*!
\class NavigationWidget
The NavigationWidget class is a widget for the class view tree.
*/
/*!
\fn void NavigationWidget::visibilityChanged(bool visibility)
Emits a signal when the widget visibility is changed. \a visibility returns
true if plugin becames visible, otherwise it returns false.
*/
/*!
\fn void NavigationWidget::requestGotoLocation(const QString &name,
int line,
int column)
Emits a signal that requests to open the file with \a name at \a line
and \a column.
\sa Manager::gotoLocation
*/
/*!
\fn void NavigationWidget::requestGotoLocations(const QList<QVariant> &locations)
Emits a signal to request to go to any of the Symbol \a locations in the
list.
\sa Manager::gotoLocations
*/
/*!
\fn void NavigationWidget::requestTreeDataUpdate()
Emits a signal that the widget wants to receive the latest tree info.
\sa Manager::onRequestTreeDataUpdate
*/
NavigationWidget::NavigationWidget(QWidget *parent) : NavigationWidget::NavigationWidget(QWidget *parent) :
QWidget(parent), QWidget(parent),
@@ -128,6 +171,14 @@ void NavigationWidget::showEvent(QShowEvent *event)
QWidget::showEvent(event); QWidget::showEvent(event);
} }
/*!
Creates QToolbuttons for the Navigation Pane widget.
Returns the list of created QToolButtons.
\sa NavigationWidgetFactory::createWidget
*/
QList<QToolButton *> NavigationWidget::createToolButtons() QList<QToolButton *> NavigationWidget::createToolButtons()
{ {
QList<QToolButton *> list; QList<QToolButton *> list;
@@ -154,6 +205,10 @@ QList<QToolButton *> NavigationWidget::createToolButtons()
return list; return list;
} }
/*!
Returns flat mode state.
*/
bool NavigationWidget::flatMode() const bool NavigationWidget::flatMode() const
{ {
QTC_ASSERT(d->fullProjectsModeButton, return false); QTC_ASSERT(d->fullProjectsModeButton, return false);
@@ -162,6 +217,10 @@ bool NavigationWidget::flatMode() const
return !d->fullProjectsModeButton->isChecked(); return !d->fullProjectsModeButton->isChecked();
} }
/*!
Sets the flat mode state to \a flatMode.
*/
void NavigationWidget::setFlatMode(bool flatMode) void NavigationWidget::setFlatMode(bool flatMode)
{ {
QTC_ASSERT(d->fullProjectsModeButton, return); QTC_ASSERT(d->fullProjectsModeButton, return);
@@ -170,12 +229,21 @@ void NavigationWidget::setFlatMode(bool flatMode)
d->fullProjectsModeButton->setChecked(!flatMode); d->fullProjectsModeButton->setChecked(!flatMode);
} }
/*!
Full projects mode button has been toggled. \a state holds the full
projects mode.
*/
void NavigationWidget::onFullProjectsModeToggled(bool state) void NavigationWidget::onFullProjectsModeToggled(bool state)
{ {
// button is 'full projects mode' - so it has to be inverted // button is 'full projects mode' - so it has to be inverted
Manager::instance()->setFlatMode(!state); Manager::instance()->setFlatMode(!state);
} }
/*!
Activates the item with the \a index in the tree view.
*/
void NavigationWidget::onItemActivated(const QModelIndex &index) void NavigationWidget::onItemActivated(const QModelIndex &index)
{ {
if (!index.isValid()) if (!index.isValid())
@@ -186,6 +254,11 @@ void NavigationWidget::onItemActivated(const QModelIndex &index)
emit requestGotoLocations(list); emit requestGotoLocations(list);
} }
/*!
Receives new data for the tree. \a result is a pointer to the Class View
model root item. The method does nothing if null is passed.
*/
void NavigationWidget::onDataUpdate(QSharedPointer<QStandardItem> result) void NavigationWidget::onDataUpdate(QSharedPointer<QStandardItem> result)
{ {
if (result.isNull()) if (result.isNull())
@@ -213,6 +286,11 @@ void NavigationWidget::onDataUpdate(QSharedPointer<QStandardItem> result)
<< "TreeView is updated in" << timer.elapsed() << "msecs"; << "TreeView is updated in" << timer.elapsed() << "msecs";
} }
/*!
Fetches data for expanded items to make sure that the content will exist.
\a item and \a target do nothing if null is passed.
*/
void NavigationWidget::fetchExpandedItems(QStandardItem *item, const QStandardItem *target) const void NavigationWidget::fetchExpandedItems(QStandardItem *item, const QStandardItem *target) const
{ {
if (!item || !target) if (!item || !target)

View File

@@ -42,11 +42,6 @@ namespace Internal {
class NavigationWidgetPrivate; class NavigationWidgetPrivate;
/*!
\class NavigationWidget
\brief A widget for the class view tree
*/
class NavigationWidget : public QWidget class NavigationWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT
@@ -55,79 +50,29 @@ public:
explicit NavigationWidget(QWidget *parent = 0); explicit NavigationWidget(QWidget *parent = 0);
~NavigationWidget(); ~NavigationWidget();
/*!
\brief Create QToolbuttons for Navigation Pane Widget
\return List with created QToolButtons
\sa NavigationWidgetFactory::createWidget
*/
QList<QToolButton *> createToolButtons(); QList<QToolButton *> createToolButtons();
/*!
\brief Get flat mode state
\return Flat mode state
*/
bool flatMode() const; bool flatMode() const;
/*!
\brief Set flat mode state
\param flatMode Flat mode state
*/
void setFlatMode(bool flatMode); void setFlatMode(bool flatMode);
signals: signals:
/*!
\brief Widget visibility is changed
\param visibility true is plugin becames visible, false otherwise
*/
void visibilityChanged(bool visibility); void visibilityChanged(bool visibility);
/*!
\brief Signal to request to go to location
\param name File which has to be open
\param line Line
\param column Column
\sa Manager::gotoLocation
*/
void requestGotoLocation(const QString &name, int line, int column); void requestGotoLocation(const QString &name, int line, int column);
/*!
\brief Signal to request to go to any of location in the list
\param locations Symbol locations
\sa Manager::gotoLocations
*/
void requestGotoLocations(const QList<QVariant> &locations); void requestGotoLocations(const QList<QVariant> &locations);
/*!
\brief Signal that the widget wants to receive the latest tree info
\sa Manager::onRequestTreeDataUpdate
*/
void requestTreeDataUpdate(); void requestTreeDataUpdate();
public slots: public slots:
/*!
\brief Item is activated in the tree view
\param index Item index
*/
void onItemActivated(const QModelIndex &index); void onItemActivated(const QModelIndex &index);
/*!
\brief Receive a new data for the tree
\param result Pointer to the Class View model root item, method does nothing if null passed
*/
void onDataUpdate(QSharedPointer<QStandardItem> result); void onDataUpdate(QSharedPointer<QStandardItem> result);
/*!
\brief Full projects' mode button has been toggled
\param state Full projects' mode
*/
void onFullProjectsModeToggled(bool state); void onFullProjectsModeToggled(bool state);
protected: protected:
/*!
\brief Fetch data for expanded items - to be sure that content will exist
\param item - does nothing if null
\param target - does nothing if null
*/
void fetchExpandedItems(QStandardItem *item, const QStandardItem *target) const; void fetchExpandedItems(QStandardItem *item, const QStandardItem *target) const;
//! implements QWidget::hideEvent //! implements QWidget::hideEvent

View File

@@ -45,6 +45,23 @@ static NavigationWidgetFactory *factoryInstance;
///////////////////////////////// NavigationWidgetFactory ////////////////////////////////// ///////////////////////////////// NavigationWidgetFactory //////////////////////////////////
/*!
\class NavigationWidgetFactory
\brief The NavigationWidgetFactory class implements a singleton instance of
the INavigationWidgetFactory for the Class View.
Supports the \c setState public slot for adding the widget factory to or
removing it from \c ExtensionSystem::PluginManager.
Also supports the \c widgetIsCreated and \c stateChanged signals.
*/
/*!
\fn void NavigationWidgetFactory::widgetIsCreated()
Informs that the widget factory created a widget.
*/
NavigationWidgetFactory::NavigationWidgetFactory() NavigationWidgetFactory::NavigationWidgetFactory()
{ {
factoryInstance = this; factoryInstance = this;
@@ -92,10 +109,8 @@ Core::NavigationView NavigationWidgetFactory::createWidget()
/*! /*!
\brief Get a settings prefix for the specified position Returns a settings prefix for \a position.
\param position Position */
\return Settings prefix
*/
static QString settingsPrefix(int position) static QString settingsPrefix(int position)
{ {
return QString::fromLatin1("ClassView/Treewidget.%1/FlatMode").arg(position); return QString::fromLatin1("ClassView/Treewidget.%1/FlatMode").arg(position);

View File

@@ -35,15 +35,6 @@
namespace ClassView { namespace ClassView {
namespace Internal { namespace Internal {
/*!
\class NavigationWidgetFactory
\brief INavigationWidgetFactory implementation for Class View
INavigationWidgetFactory implementation for Class View. Singleton instance.
Supports \a setState publc slot to add/remove factory to \a ExtensionSystem::PluginManager.
Also supports some additional signals, \a widgetIsCreated and \a stateChanged.
*/
class NavigationWidgetFactory : public Core::INavigationWidgetFactory class NavigationWidgetFactory : public Core::INavigationWidgetFactory
{ {
Q_OBJECT Q_OBJECT
@@ -81,9 +72,6 @@ public:
void restoreSettings(int position, QWidget *widget); void restoreSettings(int position, QWidget *widget);
signals: signals:
/*!
\brief Signal which informs that the widget factory creates a widget.
*/
void widgetIsCreated(); void widgetIsCreated();
}; };

View File

@@ -65,10 +65,31 @@ namespace Internal {
// ----------------------------- ParserPrivate --------------------------------- // ----------------------------- ParserPrivate ---------------------------------
/*! /*!
\struct ParserPrivate \class ParserPrivate
\brief Private class data for \a Parser \brief The ParserPrivate class defines private class data for the Parser
class.
\sa Parser \sa Parser
*/ */
/*!
\class Parser
\brief The Parser class parses C++ information. Multithreading is supported.
*/
/*!
\fn void Parser::treeDataUpdate(QSharedPointer<QStandardItem> result)
Emits a signal about a tree data update.
*/
/*!
\fn void Parser::resetDataDone()
Emits a signal that internal data is reset.
\sa resetData, resetDataToCurrentState
*/
class ParserPrivate class ParserPrivate
{ {
public: public:
@@ -132,6 +153,10 @@ CPlusPlus::Document::Ptr ParserPrivate::document(const QString &fileName) const
// ----------------------------- Parser --------------------------------- // ----------------------------- Parser ---------------------------------
/*!
Constructs the parser object.
*/
Parser::Parser(QObject *parent) Parser::Parser(QObject *parent)
: QObject(parent), : QObject(parent),
d(new ParserPrivate()) d(new ParserPrivate())
@@ -147,11 +172,19 @@ Parser::Parser(QObject *parent)
connect(d->timer, SIGNAL(timeout()), SLOT(requestCurrentState()), Qt::QueuedConnection); connect(d->timer, SIGNAL(timeout()), SLOT(requestCurrentState()), Qt::QueuedConnection);
} }
/*!
Destructs the parser object.
*/
Parser::~Parser() Parser::~Parser()
{ {
delete d; delete d;
} }
/*!
Checks \a item for lazy data population of a QStandardItemModel.
*/
bool Parser::canFetchMore(QStandardItem *item) const bool Parser::canFetchMore(QStandardItem *item) const
{ {
ParserTreeItem::ConstPtr ptr = findItemByRoot(item); ParserTreeItem::ConstPtr ptr = findItemByRoot(item);
@@ -160,6 +193,11 @@ bool Parser::canFetchMore(QStandardItem *item) const
return ptr->canFetchMore(item); return ptr->canFetchMore(item);
} }
/*!
Checks \a item for lazy data population of a QStandardItemModel.
\a skipRoot skips the root item.
*/
void Parser::fetchMore(QStandardItem *item, bool skipRoot) const void Parser::fetchMore(QStandardItem *item, bool skipRoot) const
{ {
ParserTreeItem::ConstPtr ptr = findItemByRoot(item, skipRoot); ParserTreeItem::ConstPtr ptr = findItemByRoot(item, skipRoot);
@@ -168,6 +206,10 @@ void Parser::fetchMore(QStandardItem *item, bool skipRoot) const
ptr->fetchMore(item); ptr->fetchMore(item);
} }
/*!
Switches to flat mode (without subprojects) if \a flat returns \c true.
*/
void Parser::setFlatMode(bool flatMode) void Parser::setFlatMode(bool flatMode)
{ {
if (flatMode == d->flatMode) if (flatMode == d->flatMode)
@@ -180,6 +222,11 @@ void Parser::setFlatMode(bool flatMode)
emitCurrentTree(); emitCurrentTree();
} }
/*!
Returns the internal tree item for \a item. \a skipRoot skips the root
item.
*/
ParserTreeItem::ConstPtr Parser::findItemByRoot(const QStandardItem *item, bool skipRoot) const ParserTreeItem::ConstPtr Parser::findItemByRoot(const QStandardItem *item, bool skipRoot) const
{ {
if (!item) if (!item)
@@ -213,6 +260,12 @@ ParserTreeItem::ConstPtr Parser::findItemByRoot(const QStandardItem *item, bool
return internal; return internal;
} }
/*!
Parses the class and produces a new tree.
\sa addProject
*/
ParserTreeItem::ConstPtr Parser::parse() ParserTreeItem::ConstPtr Parser::parse()
{ {
QTime time; QTime time;
@@ -257,6 +310,11 @@ ParserTreeItem::ConstPtr Parser::parse()
return rootItem; return rootItem;
} }
/*!
Parses the project with the \a projectId and adds the documents
from the \a fileList to the tree item \a item.
*/
void Parser::addProject(const ParserTreeItem::Ptr &item, const QStringList &fileList, void Parser::addProject(const ParserTreeItem::Ptr &item, const QStringList &fileList,
const QString &projectId) const QString &projectId)
{ {
@@ -269,6 +327,10 @@ void Parser::addProject(const ParserTreeItem::Ptr &item, const QStringList &file
item->copy(prj); item->copy(prj);
} }
/*!
Parses \a symbol and adds the results to \a item (as a parent).
*/
void Parser::addSymbol(const ParserTreeItem::Ptr &item, const CPlusPlus::Symbol *symbol) void Parser::addSymbol(const ParserTreeItem::Ptr &item, const CPlusPlus::Symbol *symbol)
{ {
if (item.isNull() || !symbol) if (item.isNull() || !symbol)
@@ -350,6 +412,10 @@ void Parser::addSymbol(const ParserTreeItem::Ptr &item, const CPlusPlus::Symbol
item->appendChild(itemAdd, information); item->appendChild(itemAdd, information);
} }
/*!
Creates a flat tree from the list of projects specified by \a projectList.
*/
ParserTreeItem::Ptr Parser::createFlatTree(const QStringList &projectList) ParserTreeItem::Ptr Parser::createFlatTree(const QStringList &projectList)
{ {
QReadLocker locker(&d->prjLocker); QReadLocker locker(&d->prjLocker);
@@ -364,6 +430,12 @@ ParserTreeItem::Ptr Parser::createFlatTree(const QStringList &projectList)
return item; return item;
} }
/*!
Parses the project with the \a projectId and adds the documents from the
\a fileList to the project. Updates the internal cached tree for this
project.
*/
ParserTreeItem::Ptr Parser::getParseProjectTree(const QStringList &fileList, ParserTreeItem::Ptr Parser::getParseProjectTree(const QStringList &fileList,
const QString &projectId) const QString &projectId)
{ {
@@ -397,6 +469,12 @@ ParserTreeItem::Ptr Parser::getParseProjectTree(const QStringList &fileList,
return item; return item;
} }
/*!
Gets the project with \a projectId from the cache if it is valid or parses
the project and adds the documents from the \a fileList to the project.
Updates the internal cached tree for this project.
*/
ParserTreeItem::Ptr Parser::getCachedOrParseProjectTree(const QStringList &fileList, ParserTreeItem::Ptr Parser::getCachedOrParseProjectTree(const QStringList &fileList,
const QString &projectId) const QString &projectId)
{ {
@@ -424,6 +502,13 @@ ParserTreeItem::Ptr Parser::getCachedOrParseProjectTree(const QStringList &fileL
return getParseProjectTree(fileList, projectId); return getParseProjectTree(fileList, projectId);
} }
/*!
Parses the document \a doc if it is in the project files and adds a tree to
the internal storage. Updates the internal cached tree for this document.
\sa parseDocument
*/
ParserTreeItem::ConstPtr Parser::getParseDocumentTree(const CPlusPlus::Document::Ptr &doc) ParserTreeItem::ConstPtr Parser::getParseDocumentTree(const CPlusPlus::Document::Ptr &doc)
{ {
if (doc.isNull()) if (doc.isNull())
@@ -448,6 +533,13 @@ ParserTreeItem::ConstPtr Parser::getParseDocumentTree(const CPlusPlus::Document:
return itemPtr; return itemPtr;
} }
/*!
Gets the document \a doc from the cache or parses it if it is in the project
files and adds a tree to the internal storage.
\sa parseDocument
*/
ParserTreeItem::ConstPtr Parser::getCachedOrParseDocumentTree(const CPlusPlus::Document::Ptr &doc) ParserTreeItem::ConstPtr Parser::getCachedOrParseDocumentTree(const CPlusPlus::Document::Ptr &doc)
{ {
if (doc.isNull()) if (doc.isNull())
@@ -465,6 +557,11 @@ ParserTreeItem::ConstPtr Parser::getCachedOrParseDocumentTree(const CPlusPlus::D
return getParseDocumentTree(doc); return getParseDocumentTree(doc);
} }
/*!
Parses the document \a doc if it is in the project files and adds a tree to
the internal storage.
*/
void Parser::parseDocument(const CPlusPlus::Document::Ptr &doc) void Parser::parseDocument(const CPlusPlus::Document::Ptr &doc)
{ {
if (doc.isNull()) if (doc.isNull())
@@ -485,6 +582,10 @@ void Parser::parseDocument(const CPlusPlus::Document::Ptr &doc)
return; return;
} }
/*!
Requests to clear full internal stored data.
*/
void Parser::clearCacheAll() void Parser::clearCacheAll()
{ {
d->docLocker.lockForWrite(); d->docLocker.lockForWrite();
@@ -498,6 +599,11 @@ void Parser::clearCacheAll()
clearCache(); clearCache();
} }
/*!
Requests to clear internal stored data. The data has to be regenerated on
the next request.
*/
void Parser::clearCache() void Parser::clearCache()
{ {
QWriteLocker locker(&d->prjLocker); QWriteLocker locker(&d->prjLocker);
@@ -511,12 +617,21 @@ void Parser::clearCache()
d->cachedPrjTreesRevision.clear(); d->cachedPrjTreesRevision.clear();
} }
/*!
Specifies the files that must be allowed for the parsing as a \a fileList.
Files outside of this list will not be in any tree.
*/
void Parser::setFileList(const QStringList &fileList) void Parser::setFileList(const QStringList &fileList)
{ {
d->fileList.clear(); d->fileList.clear();
d->fileList = QSet<QString>::fromList(fileList); d->fileList = QSet<QString>::fromList(fileList);
} }
/*!
Removes the files defined in the \a fileList from the parsing.
*/
void Parser::removeFiles(const QStringList &fileList) void Parser::removeFiles(const QStringList &fileList)
{ {
if (fileList.count() == 0) if (fileList.count() == 0)
@@ -536,6 +651,10 @@ void Parser::removeFiles(const QStringList &fileList)
emit filesAreRemoved(); emit filesAreRemoved();
} }
/*!
Fully resets the internal state of the code parser to \a snapshot.
*/
void Parser::resetData(const CPlusPlus::Snapshot &snapshot) void Parser::resetData(const CPlusPlus::Snapshot &snapshot)
{ {
// clear internal cache // clear internal cache
@@ -565,6 +684,12 @@ void Parser::resetData(const CPlusPlus::Snapshot &snapshot)
emit resetDataDone(); emit resetDataDone();
} }
/*!
Fully resets the internal state of the code parser to the current state.
\sa resetData
*/
void Parser::resetDataToCurrentState() void Parser::resetDataToCurrentState()
{ {
// get latest data // get latest data
@@ -573,17 +698,31 @@ void Parser::resetDataToCurrentState()
resetData(codeModel->snapshot()); resetData(codeModel->snapshot());
} }
/*!
Regenerates the tree when internal data changes.
\sa resetDataDone
*/
void Parser::onResetDataDone() void Parser::onResetDataDone()
{ {
// internal data is reset, update a tree and send it back // internal data is reset, update a tree and send it back
emitCurrentTree(); emitCurrentTree();
} }
/*!
Requests to emit a signal with the current tree state.
*/
void Parser::requestCurrentState() void Parser::requestCurrentState()
{ {
emitCurrentTree(); emitCurrentTree();
} }
/*!
Sends the current tree to listeners.
*/
void Parser::emitCurrentTree() void Parser::emitCurrentTree()
{ {
// stop timer if it is active right now // stop timer if it is active right now
@@ -601,6 +740,10 @@ void Parser::emitCurrentTree()
emit treeDataUpdate(std); emit treeDataUpdate(std);
} }
/*!
Generates a project node file list for the root node \a node.
*/
QStringList Parser::projectNodeFileList(const ProjectExplorer::FolderNode *node) const QStringList Parser::projectNodeFileList(const ProjectExplorer::FolderNode *node) const
{ {
QStringList list; QStringList list;
@@ -627,6 +770,13 @@ QStringList Parser::projectNodeFileList(const ProjectExplorer::FolderNode *node)
return list; return list;
} }
/*!
Generates projects like the Project Explorer.
\a item specifies the item and \a node specifies the root node.
Returns a list of projects which were added to the item.
*/
QStringList Parser::addProjectNode(const ParserTreeItem::Ptr &item, QStringList Parser::addProjectNode(const ParserTreeItem::Ptr &item,
const ProjectExplorer::ProjectNode *node) const ProjectExplorer::ProjectNode *node)
{ {
@@ -670,6 +820,10 @@ QStringList Parser::addProjectNode(const ParserTreeItem::Ptr &item,
return projectList; return projectList;
} }
/*!
Returns the current project list.
*/
QList<ProjectExplorer::Project *> Parser::getProjectList() const QList<ProjectExplorer::Project *> Parser::getProjectList() const
{ {
QList<ProjectExplorer::Project *> list; QList<ProjectExplorer::Project *> list;

View File

@@ -50,208 +50,76 @@ namespace Internal {
class ParserPrivate; class ParserPrivate;
/*!
\class Parser
\brief Parse cpp information. Multithreading is supported.
*/
class Parser : public QObject class Parser : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
/*!
\brief Constructor
*/
explicit Parser(QObject *parent = 0); explicit Parser(QObject *parent = 0);
~Parser(); ~Parser();
/*!
\brief Lazy data population for a \a QStandardItemModel
\param item Item which has to be checked
*/
bool canFetchMore(QStandardItem *item) const; bool canFetchMore(QStandardItem *item) const;
/*!
\brief Lazy data population for a \a QStandardItemModel
\param item Item which will be populated (if needed)
\param skipRoot Skip root item
*/
void fetchMore(QStandardItem *item, bool skipRoot = false) const; void fetchMore(QStandardItem *item, bool skipRoot = false) const;
signals: signals:
//! File list is changed //! File list is changed
void filesAreRemoved(); void filesAreRemoved();
/*!
\brief Signal about a tree data update
*/
void treeDataUpdate(QSharedPointer<QStandardItem> result); void treeDataUpdate(QSharedPointer<QStandardItem> result);
/*!
\brief Signal that internal data
\sa resetData, resetDataToCurrentState
*/
void resetDataDone(); void resetDataDone();
public slots: public slots:
/*!
\brief Request to clear full internal stored data.
*/
void clearCacheAll(); void clearCacheAll();
/*!
\brief Request to clear internal stored data, it has to be regenerated on the next request.
*/
void clearCache(); void clearCache();
/*!
\brief Request to emit a signal with the current tree state
*/
void requestCurrentState(); void requestCurrentState();
/*!
\brief Set file list for the parsing, files outside of this list will not be in any tree.
\param fileList Files which must be allowed for the parsing
*/
void setFileList(const QStringList &fileList); void setFileList(const QStringList &fileList);
/*!
\brief Remove some files from the file list for the parsing.
\param fileList Files which must be removed from the parsing
*/
void removeFiles(const QStringList &fileList); void removeFiles(const QStringList &fileList);
/*!
\brief Fully reset internal state
\param snapshot Code parser snapshot
*/
void resetData(const CPlusPlus::Snapshot &snapshot); void resetData(const CPlusPlus::Snapshot &snapshot);
/*!
\brief Fully reset internal state - to the current state
\sa resetData
*/
void resetDataToCurrentState(); void resetDataToCurrentState();
/*!
\brief Parse document if it is in the project files and add a tree to the internal storage
\param doc Document which has to be parsed
*/
void parseDocument(const CPlusPlus::Document::Ptr &doc); void parseDocument(const CPlusPlus::Document::Ptr &doc);
/*!
\brief Switch to flat mode (without subprojects)
\param flat True to enable flat mode, false to disable
*/
void setFlatMode(bool flat); void setFlatMode(bool flat);
protected slots: protected slots:
/*!
\brief Internal data is changed, regenerate the tree
\sa resetDataDone
*/
void onResetDataDone(); void onResetDataDone();
protected: protected:
/*!
\brief Parse one particular project and add result to the tree item
\param item Item where parsed project has to be stored
\param fileList Files
\param projectId Project id, is needed for prj cache
*/
void addProject(const ParserTreeItem::Ptr &item, const QStringList &fileList, void addProject(const ParserTreeItem::Ptr &item, const QStringList &fileList,
const QString &projectId = QString()); const QString &projectId = QString());
/*!
\brief Parse one particular symbol and add result to the tree item (as a parent)
\param item Item where parsed symbol has to be stored
\param symbol Symbol which has to be used as a source
*/
void addSymbol(const ParserTreeItem::Ptr &item, const CPlusPlus::Symbol *symbol); void addSymbol(const ParserTreeItem::Ptr &item, const CPlusPlus::Symbol *symbol);
/*!
\brief Parse document if it is in the project files and add a tree to the internal storage.
Update internal cached tree for this document.
\param doc Document which has to be parsed
\return A tree
\sa parseDocument
*/
ParserTreeItem::ConstPtr getParseDocumentTree(const CPlusPlus::Document::Ptr &doc); ParserTreeItem::ConstPtr getParseDocumentTree(const CPlusPlus::Document::Ptr &doc);
/*!
\brief Get from the cache or parse document if it is in the project files
and add a tree to the internal storage
\param doc Document which has to be parsed
\return A tree
\sa parseDocument
*/
ParserTreeItem::ConstPtr getCachedOrParseDocumentTree(const CPlusPlus::Document::Ptr &doc); ParserTreeItem::ConstPtr getCachedOrParseDocumentTree(const CPlusPlus::Document::Ptr &doc);
/*!
\brief Parse project and add a tree to the internal storage.
Update internal cached tree for this project.
\param fileList Documents which has to be added to the project
\param projectId Project id
\return A tree
*/
ParserTreeItem::Ptr getParseProjectTree(const QStringList &fileList, const QString &projectId); ParserTreeItem::Ptr getParseProjectTree(const QStringList &fileList, const QString &projectId);
/*!
\brief Get from the cache (if valid) or parse project and add a tree to the internal storage.
Update internal cached tree for this project.
\param fileList Documents which has to be added to the project
\param projectId Project id
\return A tree
*/
ParserTreeItem::Ptr getCachedOrParseProjectTree(const QStringList &fileList, ParserTreeItem::Ptr getCachedOrParseProjectTree(const QStringList &fileList,
const QString &projectId); const QString &projectId);
/*!
\brief Send a current tree to listeners
*/
void emitCurrentTree(); void emitCurrentTree();
/*!
\brief Parse the class and produce a new tree
\sa addProject
*/
ParserTreeItem::ConstPtr parse(); ParserTreeItem::ConstPtr parse();
/*!
\brief Find internal node for the specified UI item
\param item Item which has to be found
\param skipRoot Skip root item
\return Found internal node
*/
ParserTreeItem::ConstPtr findItemByRoot(const QStandardItem *item, bool skipRoot = false) const; ParserTreeItem::ConstPtr findItemByRoot(const QStandardItem *item, bool skipRoot = false) const;
/*!
\brief Generate projects like Project Explorer
\param item Item
\param node Root node
\return List of projects which were added to the item
*/
QStringList addProjectNode(const ParserTreeItem::Ptr &item, QStringList addProjectNode(const ParserTreeItem::Ptr &item,
const ProjectExplorer::ProjectNode *node); const ProjectExplorer::ProjectNode *node);
/*!
\brief Generate project node file list
\param node Root node
*/
QStringList projectNodeFileList(const ProjectExplorer::FolderNode *node) const; QStringList projectNodeFileList(const ProjectExplorer::FolderNode *node) const;
/*!
\brief Get the current project list
\return Project list
*/
QList<ProjectExplorer::Project *> getProjectList() const; QList<ProjectExplorer::Project *> getProjectList() const;
/*!
\brief Create flat tree from different projects
\param projectList List of projects
\return Flat tree
*/
ParserTreeItem::Ptr createFlatTree(const QStringList &projectList); ParserTreeItem::Ptr createFlatTree(const QStringList &projectList);
private: private:

View File

@@ -49,8 +49,9 @@ namespace Internal {
///////////////////////////////// ParserTreeItemPrivate ////////////////////////////////// ///////////////////////////////// ParserTreeItemPrivate //////////////////////////////////
/*! /*!
\struct ParserTreeItemPrivate \class ParserTreeItemPrivate
\brief Private class data for \a ParserTreeItem \brief The ParserTreeItemPrivate class defines private class data for
the ParserTreeItem class.
\sa ParserTreeItem \sa ParserTreeItem
*/ */
class ParserTreeItemPrivate class ParserTreeItemPrivate
@@ -68,6 +69,13 @@ public:
///////////////////////////////// ParserTreeItem ////////////////////////////////// ///////////////////////////////// ParserTreeItem //////////////////////////////////
/*!
\class ParserTreeItem
\brief The ParserTreeItem class is an item for the internal Class View tree.
Not virtual - to speed up its work.
*/
ParserTreeItem::ParserTreeItem() : ParserTreeItem::ParserTreeItem() :
d(new ParserTreeItemPrivate()) d(new ParserTreeItemPrivate())
{ {
@@ -86,6 +94,11 @@ ParserTreeItem &ParserTreeItem::operator=(const ParserTreeItem &other)
return *this; return *this;
} }
/*!
Copies a parser tree item from the location specified by \a from to this
item.
*/
void ParserTreeItem::copy(const ParserTreeItem::ConstPtr &from) void ParserTreeItem::copy(const ParserTreeItem::ConstPtr &from)
{ {
if (from.isNull()) if (from.isNull())
@@ -96,6 +109,12 @@ void ParserTreeItem::copy(const ParserTreeItem::ConstPtr &from)
d->symbolInformations = from->d->symbolInformations; d->symbolInformations = from->d->symbolInformations;
} }
/*!
\fn void copyTree(const ParserTreeItem::ConstPtr &from)
Copies a parser tree item with children from the location specified by
\a from to this item.
*/
void ParserTreeItem::copyTree(const ParserTreeItem::ConstPtr &target) void ParserTreeItem::copyTree(const ParserTreeItem::ConstPtr &target)
{ {
if (target.isNull()) if (target.isNull())
@@ -123,31 +142,60 @@ void ParserTreeItem::copyTree(const ParserTreeItem::ConstPtr &target)
} }
} }
/*!
Adds information about symbol location from a \location.
\sa SymbolLocation, removeSymbolLocation, symbolLocations
*/
void ParserTreeItem::addSymbolLocation(const SymbolLocation &location) void ParserTreeItem::addSymbolLocation(const SymbolLocation &location)
{ {
d->symbolLocations.insert(location); d->symbolLocations.insert(location);
} }
/*!
Adds information about symbol locations from \a locations.
\sa SymbolLocation, removeSymbolLocation, symbolLocations
*/
void ParserTreeItem::addSymbolLocation(const QSet<SymbolLocation> &locations) void ParserTreeItem::addSymbolLocation(const QSet<SymbolLocation> &locations)
{ {
d->symbolLocations.unite(locations); d->symbolLocations.unite(locations);
} }
/*!
Removes information about \a location.
\sa SymbolLocation, addSymbolLocation, symbolLocations
*/
void ParserTreeItem::removeSymbolLocation(const SymbolLocation &location) void ParserTreeItem::removeSymbolLocation(const SymbolLocation &location)
{ {
d->symbolLocations.remove(location); d->symbolLocations.remove(location);
} }
/*!
Removes information about \a locations.
\sa SymbolLocation, addSymbolLocation, symbolLocations
*/
void ParserTreeItem::removeSymbolLocations(const QSet<SymbolLocation> &locations) void ParserTreeItem::removeSymbolLocations(const QSet<SymbolLocation> &locations)
{ {
d->symbolLocations.subtract(locations); d->symbolLocations.subtract(locations);
} }
/*!
Gets information about symbol positions.
\sa SymbolLocation, addSymbolLocation, removeSymbolLocation
*/
QSet<SymbolLocation> ParserTreeItem::symbolLocations() const QSet<SymbolLocation> ParserTreeItem::symbolLocations() const
{ {
return d->symbolLocations; return d->symbolLocations;
} }
/*!
Appends the child item \a item to \a inf symbol information.
*/
void ParserTreeItem::appendChild(const ParserTreeItem::Ptr &item, const SymbolInformation &inf) void ParserTreeItem::appendChild(const ParserTreeItem::Ptr &item, const SymbolInformation &inf)
{ {
// removeChild must be used to remove an item // removeChild must be used to remove an item
@@ -157,11 +205,19 @@ void ParserTreeItem::appendChild(const ParserTreeItem::Ptr &item, const SymbolIn
d->symbolInformations[inf] = item; d->symbolInformations[inf] = item;
} }
/*!
Removes the \a inf symbol information.
*/
void ParserTreeItem::removeChild(const SymbolInformation &inf) void ParserTreeItem::removeChild(const SymbolInformation &inf)
{ {
d->symbolInformations.remove(inf); d->symbolInformations.remove(inf);
} }
/*!
Returns the child item specified by \a inf symbol information.
*/
ParserTreeItem::Ptr ParserTreeItem::child(const SymbolInformation &inf) const ParserTreeItem::Ptr ParserTreeItem::child(const SymbolInformation &inf) const
{ {
if (!d->symbolInformations.contains(inf)) if (!d->symbolInformations.contains(inf))
@@ -169,21 +225,38 @@ ParserTreeItem::Ptr ParserTreeItem::child(const SymbolInformation &inf) const
return d->symbolInformations[inf]; return d->symbolInformations[inf];
} }
/*!
Returns the amount of children of the tree item.
*/
int ParserTreeItem::childCount() const int ParserTreeItem::childCount() const
{ {
return d->symbolInformations.count(); return d->symbolInformations.count();
} }
/*!
\property QIcon::icon
\brief the icon assigned to the tree item
*/
QIcon ParserTreeItem::icon() const QIcon ParserTreeItem::icon() const
{ {
return d->icon; return d->icon;
} }
/*!
Sets the \a icon for the tree item.
*/
void ParserTreeItem::setIcon(const QIcon &icon) void ParserTreeItem::setIcon(const QIcon &icon)
{ {
d->icon = icon; d->icon = icon;
} }
/*!
Adds an internal state with \a target, which contains the correct current
state.
*/
void ParserTreeItem::add(const ParserTreeItem::ConstPtr &target) void ParserTreeItem::add(const ParserTreeItem::ConstPtr &target)
{ {
if (target.isNull()) if (target.isNull())
@@ -221,6 +294,10 @@ void ParserTreeItem::add(const ParserTreeItem::ConstPtr &target)
} }
} }
/*!
Subtracts an internal state with \a target, which contains the subtrahend.
*/
void ParserTreeItem::subtract(const ParserTreeItem::ConstPtr &target) void ParserTreeItem::subtract(const ParserTreeItem::ConstPtr &target)
{ {
if (target.isNull()) if (target.isNull())
@@ -246,6 +323,12 @@ void ParserTreeItem::subtract(const ParserTreeItem::ConstPtr &target)
} }
} }
/*!
Appends this item to the QStandardIten item \a item.
\a recursive does it recursively for the tree items (might be needed for
lazy data population.
*/
void ParserTreeItem::convertTo(QStandardItem *item, bool recursive) const void ParserTreeItem::convertTo(QStandardItem *item, bool recursive) const
{ {
if (!item) if (!item)
@@ -288,6 +371,10 @@ void ParserTreeItem::convertTo(QStandardItem *item, bool recursive) const
} }
} }
/*!
Checks \a item in a QStandardItemModel for lazy data population.
*/
bool ParserTreeItem::canFetchMore(QStandardItem *item) const bool ParserTreeItem::canFetchMore(QStandardItem *item) const
{ {
if (!item) if (!item)
@@ -327,6 +414,10 @@ bool ParserTreeItem::canFetchMore(QStandardItem *item) const
return false; return false;
} }
/*!
Performs lazy data population for \a item in a QStandardItemModel if needed.
*/
void ParserTreeItem::fetchMore(QStandardItem *item) const void ParserTreeItem::fetchMore(QStandardItem *item) const
{ {
if (!item) if (!item)
@@ -353,6 +444,10 @@ void ParserTreeItem::fetchMore(QStandardItem *item) const
} }
} }
/*!
Debug dump.
*/
void ParserTreeItem::debugDump(int ident) const void ParserTreeItem::debugDump(int ident) const
{ {
QHash<SymbolInformation, ParserTreeItem::Ptr>::const_iterator curHash = QHash<SymbolInformation, ParserTreeItem::Ptr>::const_iterator curHash =

View File

@@ -42,14 +42,6 @@ namespace Internal {
class ParserTreeItemPrivate; class ParserTreeItemPrivate;
/*!
\class ParserTreeItem
\brief Item for the internal Class View Tree
Item for Class View Tree.
Not virtual - to speed up its work.
*/
class ParserTreeItem class ParserTreeItem
{ {
public: public:
@@ -60,85 +52,28 @@ public:
ParserTreeItem(); ParserTreeItem();
~ParserTreeItem(); ~ParserTreeItem();
/*!
\brief Copy content of \a from item with children to this one.
\param from 'From' item
*/
void copyTree(const ParserTreeItem::ConstPtr &from); void copyTree(const ParserTreeItem::ConstPtr &from);
/*!
\brief Copy of \a from item to this one.
\param from 'From' item
*/
void copy(const ParserTreeItem::ConstPtr &from); void copy(const ParserTreeItem::ConstPtr &from);
/*!
\brief Add information about symbol location
\param location Filled \a SymbolLocation struct with a correct information
\sa SymbolLocation, removeSymbolLocation, symbolLocations
*/
void addSymbolLocation(const SymbolLocation &location); void addSymbolLocation(const SymbolLocation &location);
/*!
\brief Add information about symbol locations
\param locations Filled \a SymbolLocation struct with a correct information
\sa SymbolLocation, removeSymbolLocation, symbolLocations
*/
void addSymbolLocation(const QSet<SymbolLocation> &locations); void addSymbolLocation(const QSet<SymbolLocation> &locations);
/*!
\brief Remove information about symbol location
\param location Filled \a SymbolLocation struct with a correct information
\sa SymbolLocation, addSymbolLocation, symbolLocations
*/
void removeSymbolLocation(const SymbolLocation &location); void removeSymbolLocation(const SymbolLocation &location);
/*!
\brief Remove information about symbol locations
\param locations Filled \a SymbolLocation struct with a correct information
\sa SymbolLocation, addSymbolLocation, symbolLocations
*/
void removeSymbolLocations(const QSet<SymbolLocation> &locations); void removeSymbolLocations(const QSet<SymbolLocation> &locations);
/*!
\brief Get information about symbol positions
\sa SymbolLocation, addSymbolLocation, removeSymbolLocation
*/
QSet<SymbolLocation> symbolLocations() const; QSet<SymbolLocation> symbolLocations() const;
/*!
\brief Append child
\param item Child item
\param inf Symbol information
*/
void appendChild(const ParserTreeItem::Ptr &item, const SymbolInformation &inf); void appendChild(const ParserTreeItem::Ptr &item, const SymbolInformation &inf);
/*!
\brief Remove child
\param inf SymbolInformation which has to be removed
*/
void removeChild(const SymbolInformation &inf); void removeChild(const SymbolInformation &inf);
/*!
\brief Get an item
\param inf Symbol information about needed child
\return Found child
*/
ParserTreeItem::Ptr child(const SymbolInformation &inf) const; ParserTreeItem::Ptr child(const SymbolInformation &inf) const;
/*!
\brief How many children
\return Amount of chilren
*/
int childCount() const; int childCount() const;
/*!
\brief Append this item to the \a QStandardIten item
\param item QStandardItem
\param recursive Do it recursively for the tree items or not (might be needed for
the lazy data population
*/
void convertTo(QStandardItem *item, bool recursive = true) const; void convertTo(QStandardItem *item, bool recursive = true) const;
// additional properties // additional properties
@@ -148,33 +83,14 @@ public:
//! Set an icon for this tree node //! Set an icon for this tree node
void setIcon(const QIcon &icon); void setIcon(const QIcon &icon);
/*!
\brief Add an internal state with \a target.
\param target Item which contains the correct current state
*/
void add(const ParserTreeItem::ConstPtr &target); void add(const ParserTreeItem::ConstPtr &target);
/*!
\brief Subtract an internal state with \a target.
\param target Item which contains the subtrahend
*/
void subtract(const ParserTreeItem::ConstPtr &target); void subtract(const ParserTreeItem::ConstPtr &target);
/*!
\brief Lazy data population for a \a QStandardItemModel
\param item Item which has to be checked
*/
bool canFetchMore(QStandardItem *item) const; bool canFetchMore(QStandardItem *item) const;
/*!
\brief Lazy data population for a \a QStandardItemModel
\param item Item which will be populated (if needed)
*/
void fetchMore(QStandardItem *item) const; void fetchMore(QStandardItem *item) const;
/*!
\brief Debug dump
*/
void debugDump(int ident = 0) const; void debugDump(int ident = 0) const;
protected: protected:

View File

@@ -38,6 +38,14 @@ namespace Internal {
///////////////////////////////// Plugin ////////////////////////////////// ///////////////////////////////// Plugin //////////////////////////////////
/*!
\class Plugin
\brief The Plugin class is the base class for the Class View plugin.
The Class View shows the namespace and class hierarchy of the currently open
projects in the sidebar.
*/
bool Plugin::initialize(const QStringList &arguments, QString *errorMessage) bool Plugin::initialize(const QStringList &arguments, QString *errorMessage)
{ {
Q_UNUSED(arguments) Q_UNUSED(arguments)

View File

@@ -35,11 +35,6 @@
namespace ClassView { namespace ClassView {
namespace Internal { namespace Internal {
/*!
\class Plugin
\brief Base class for Class View plugin (class/namespaces in the navigation pane)
*/
class Plugin : public ExtensionSystem::IPlugin class Plugin : public ExtensionSystem::IPlugin
{ {
Q_OBJECT Q_OBJECT

View File

@@ -36,6 +36,12 @@
namespace ClassView { namespace ClassView {
namespace Internal { namespace Internal {
/*!
\class SymbolInformation
\brief The SymbolInformation class provides the name, type, and icon for a
single item in the Class View tree.
*/
SymbolInformation::SymbolInformation() : SymbolInformation::SymbolInformation() :
m_iconType(INT_MIN), m_iconType(INT_MIN),
m_hash(0) m_hash(0)
@@ -52,6 +58,11 @@ SymbolInformation::SymbolInformation(const QString &valueName, const QString &va
m_hash = qHash(qMakePair(m_iconType, qMakePair(m_name, m_type))); m_hash = qHash(qMakePair(m_iconType, qMakePair(m_name, m_type)));
} }
/*!
Returns an icon type sort order number. It is not pre-calculated, as it is
needed for converting to standard item only.
*/
int SymbolInformation::iconTypeSortOrder() const int SymbolInformation::iconTypeSortOrder() const
{ {
return Utils::iconTypeSortOrder(m_iconType); return Utils::iconTypeSortOrder(m_iconType);

View File

@@ -38,11 +38,6 @@
namespace ClassView { namespace ClassView {
namespace Internal { namespace Internal {
/*!
\class SymbolInformation
\brief Provides name, type and icon for single item in Class View tree
*/
class SymbolInformation class SymbolInformation
{ {
public: public:
@@ -61,11 +56,6 @@ public:
&& type() == other.type(); && type() == other.type();
} }
/*!
\brief Get an icon type sort order. Not pre-calculated - is needed for converting
to Standard Item only.
\return Sort order number.
*/
int iconTypeSortOrder() const; int iconTypeSortOrder() const;
private: private:

View File

@@ -34,6 +34,14 @@
namespace ClassView { namespace ClassView {
namespace Internal { namespace Internal {
/*!
\class SymbolLocation
\brief The SymbolLocation class stores information about symbol location
to know the exact location to open when the user clicks on a tree item.
This class might be used in QSet and QHash.
*/
SymbolLocation::SymbolLocation() : SymbolLocation::SymbolLocation() :
m_line(0), m_line(0),
m_column(0), m_column(0),

View File

@@ -36,11 +36,6 @@
namespace ClassView { namespace ClassView {
namespace Internal { namespace Internal {
/*!
\class SymbolLocation
\brief Special struct to store information about symbol location (to find which exactly location
has to be open when the user clicks on any tree item. It might be used in QSet/QHash.
*/
class SymbolLocation class SymbolLocation
{ {
public: public:

View File

@@ -40,8 +40,9 @@ namespace Internal {
///////////////////////////////// TreeItemModelPrivate ////////////////////////////////// ///////////////////////////////// TreeItemModelPrivate //////////////////////////////////
/*! /*!
\struct TreeItemModelPrivate \class TreeItemModelPrivate
\brief Private class data for \a TreeItemModel \brief The TreeItemModelPrivate class contains private class data for
the TreeItemModel class.
\sa TreeItemModel \sa TreeItemModel
*/ */
class TreeItemModelPrivate class TreeItemModelPrivate
@@ -53,6 +54,11 @@ public:
///////////////////////////////// TreeItemModel ////////////////////////////////// ///////////////////////////////// TreeItemModel //////////////////////////////////
/*!
\class TreeItemModel
\brief The TreeItemModel class provides a model for the Class View tree.
*/
TreeItemModel::TreeItemModel(QObject *parent) TreeItemModel::TreeItemModel(QObject *parent)
: QStandardItemModel(parent), : QStandardItemModel(parent),
d(new TreeItemModelPrivate()) d(new TreeItemModelPrivate())
@@ -118,6 +124,10 @@ void TreeItemModel::fetchMore(const QModelIndex &parent)
return Manager::instance()->fetchMore(itemFromIndex(parent)); return Manager::instance()->fetchMore(itemFromIndex(parent));
} }
/*!
Moves the root item to the \a target item.
*/
void TreeItemModel::moveRootToTarget(const QStandardItem *target) void TreeItemModel::moveRootToTarget(const QStandardItem *target)
{ {
emit layoutAboutToBeChanged(); emit layoutAboutToBeChanged();

View File

@@ -37,11 +37,6 @@ namespace Internal {
class TreeItemModelPrivate; class TreeItemModelPrivate;
/*!
\class TreeItemModel
\brief Model for Class View Tree
*/
class TreeItemModel : public QStandardItemModel class TreeItemModel : public QStandardItemModel
{ {
Q_OBJECT Q_OBJECT
@@ -50,10 +45,6 @@ public:
explicit TreeItemModel(QObject *parent=0); explicit TreeItemModel(QObject *parent=0);
virtual ~TreeItemModel(); virtual ~TreeItemModel();
/*!
\brief move root item to the target
\param target Target item
*/
void moveRootToTarget(const QStandardItem *target); void moveRootToTarget(const QStandardItem *target);
//! \implements QStandardItemModel::data //! \implements QStandardItemModel::data

View File

@@ -40,6 +40,11 @@
namespace ClassView { namespace ClassView {
namespace Constants { namespace Constants {
/*!
\class Utils
\brief The Utils class provides some common utilities.
*/
//! Default icon sort order //! Default icon sort order
const int IconSortOrder[] = { const int IconSortOrder[] = {
CPlusPlus::Icons::NamespaceIconType, CPlusPlus::Icons::NamespaceIconType,
@@ -69,6 +74,13 @@ Utils::Utils()
{ {
} }
/*!
Converts internal location container to QVariant compatible.
\a locations specifies a set of symbol locations.
Returns a list of variant locations that can be added to the data of an
item.
*/
QList<QVariant> Utils::locationsToRole(const QSet<SymbolLocation> &locations) QList<QVariant> Utils::locationsToRole(const QSet<SymbolLocation> &locations)
{ {
QList<QVariant> locationsVar; QList<QVariant> locationsVar;
@@ -78,6 +90,13 @@ QList<QVariant> Utils::locationsToRole(const QSet<SymbolLocation> &locations)
return locationsVar; return locationsVar;
} }
/*!
Converts QVariant location container to internal.
\a locationsVar contains a list of variant locations from the data of an
item.
Returns a set of symbol locations.
*/
QSet<SymbolLocation> Utils::roleToLocations(const QList<QVariant> &locationsVar) QSet<SymbolLocation> Utils::roleToLocations(const QList<QVariant> &locationsVar)
{ {
QSet<SymbolLocation> locations; QSet<SymbolLocation> locations;
@@ -89,6 +108,10 @@ QSet<SymbolLocation> Utils::roleToLocations(const QList<QVariant> &locationsVar)
return locations; return locations;
} }
/*!
Returns sort order value for the \a icon.
*/
int Utils::iconTypeSortOrder(int icon) int Utils::iconTypeSortOrder(int icon)
{ {
static QHash<int, int> sortOrder; static QHash<int, int> sortOrder;
@@ -107,6 +130,12 @@ int Utils::iconTypeSortOrder(int icon)
return sortOrder[icon]; return sortOrder[icon];
} }
/*!
Sets symbol information specified by \a information to \a item.
\a information provides the name, type, and icon for the item.
Returns the filled item.
*/
QStandardItem *Utils::setSymbolInformationToItem(const SymbolInformation &information, QStandardItem *Utils::setSymbolInformationToItem(const SymbolInformation &information,
QStandardItem *item) QStandardItem *item)
{ {
@@ -119,6 +148,10 @@ QStandardItem *Utils::setSymbolInformationToItem(const SymbolInformation &inform
return item; return item;
} }
/*!
Returns symbol information for \a item.
*/
SymbolInformation Utils::symbolInformationFromItem(const QStandardItem *item) SymbolInformation Utils::symbolInformationFromItem(const QStandardItem *item)
{ {
Q_ASSERT(item); Q_ASSERT(item);
@@ -141,6 +174,10 @@ SymbolInformation Utils::symbolInformationFromItem(const QStandardItem *item)
return SymbolInformation(name, type, iconType); return SymbolInformation(name, type, iconType);
} }
/*!
Updates \a item to \a target, so that it is sorted and can be fetched.
*/
void Utils::fetchItemToTarget(QStandardItem *item, const QStandardItem *target) void Utils::fetchItemToTarget(QStandardItem *item, const QStandardItem *target)
{ {
if (!item || !target) if (!item || !target)
@@ -178,6 +215,9 @@ void Utils::fetchItemToTarget(QStandardItem *item, const QStandardItem *target)
} }
} }
/*!
Moves \a item to \a target (sorted).
*/
void Utils::moveItemToTarget(QStandardItem *item, const QStandardItem *target) void Utils::moveItemToTarget(QStandardItem *item, const QStandardItem *target)
{ {
if (!item || !target) if (!item || !target)

View File

@@ -41,66 +41,25 @@ QT_FORWARD_DECLARE_CLASS(QStandardItem)
namespace ClassView { namespace ClassView {
namespace Internal { namespace Internal {
/*!
\class Utils
\brief Some common utils
*/
class Utils class Utils
{ {
//! Private constructor //! Private constructor
Utils(); Utils();
public: public:
/*!
\brief convert internal location container to QVariant compatible
\param locations Set of SymbolLocations
\return List of variant locations (can be added to an item's data)
*/
static QList<QVariant> locationsToRole(const QSet<SymbolLocation> &locations); static QList<QVariant> locationsToRole(const QSet<SymbolLocation> &locations);
/*!
\brief convert QVariant location container to internal
\param locations List of variant locations (from an item's data)
\return Set of SymbolLocations
*/
static QSet<SymbolLocation> roleToLocations(const QList<QVariant> &locations); static QSet<SymbolLocation> roleToLocations(const QList<QVariant> &locations);
/*!
\brief Returns sort order value for the icon type
\param iconType Icon type
\return Sort order value for the provided icon type
*/
static int iconTypeSortOrder(int iconType); static int iconTypeSortOrder(int iconType);
/*!
\brief Get symbol information for the \a QStandardItem
\param item Item
\return Filled symbol information.
*/
static SymbolInformation symbolInformationFromItem(const QStandardItem *item); static SymbolInformation symbolInformationFromItem(const QStandardItem *item);
/*!
\brief Set symbol information to the \a QStandardItem
\param information Provides name, type and icon
\param item Item
\return Filled item
*/
static QStandardItem *setSymbolInformationToItem(const SymbolInformation &information, static QStandardItem *setSymbolInformationToItem(const SymbolInformation &information,
QStandardItem *item); QStandardItem *item);
/*!
\brief Update an item to the target. (sorted, for fetching)
\param item Source item
\param target Target item
*/
static void fetchItemToTarget(QStandardItem *item, const QStandardItem *target); static void fetchItemToTarget(QStandardItem *item, const QStandardItem *target);
/*!
\brief Move an item to the target. (sorted)
\param item Source item
\param target Target item
*/
static void moveItemToTarget(QStandardItem *item, const QStandardItem *target); static void moveItemToTarget(QStandardItem *item, const QStandardItem *target);
}; };