forked from qt-creator/qt-creator
ClassView: Remove unnecessary private class
Change-Id: Ib0b67b01604d3abc7d2a30dd3841fa4a46775a4e Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
@@ -28,8 +28,6 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "classviewnavigationwidget.h"
|
#include "classviewnavigationwidget.h"
|
||||||
#include "ui_classviewnavigationwidget.h"
|
|
||||||
#include "classviewtreeitemmodel.h"
|
|
||||||
#include "classviewmanager.h"
|
#include "classviewmanager.h"
|
||||||
#include "classviewsymbollocation.h"
|
#include "classviewsymbollocation.h"
|
||||||
#include "classviewsymbolinformation.h"
|
#include "classviewsymbolinformation.h"
|
||||||
@@ -39,37 +37,12 @@
|
|||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QPointer>
|
|
||||||
|
|
||||||
enum { debug = false };
|
enum { debug = false };
|
||||||
|
|
||||||
namespace ClassView {
|
namespace ClassView {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
///////////////////////////////// NavigationWidgetPrivate //////////////////////////////////
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\class NavigationWidgetPrivate
|
|
||||||
|
|
||||||
The NavigationWidgetPrivate class provides internal data structures and
|
|
||||||
functions for NavigationWidget.
|
|
||||||
*/
|
|
||||||
|
|
||||||
class NavigationWidgetPrivate
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
NavigationWidgetPrivate() : ui(0) {}
|
|
||||||
|
|
||||||
//! Ui generated by Designer
|
|
||||||
Ui::NavigationWidget *ui;
|
|
||||||
|
|
||||||
//! current tree model
|
|
||||||
QPointer<TreeItemModel> treeModel;
|
|
||||||
|
|
||||||
//! full projects mode
|
|
||||||
QPointer<QToolButton> fullProjectsModeButton;
|
|
||||||
};
|
|
||||||
|
|
||||||
///////////////////////////////// NavigationWidget //////////////////////////////////
|
///////////////////////////////// NavigationWidget //////////////////////////////////
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -115,19 +88,18 @@ public:
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
NavigationWidget::NavigationWidget(QWidget *parent) :
|
NavigationWidget::NavigationWidget(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent)
|
||||||
d(new NavigationWidgetPrivate())
|
|
||||||
{
|
{
|
||||||
d->ui = new Ui::NavigationWidget;
|
ui = new Ui::NavigationWidget;
|
||||||
d->ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
// tree model
|
// tree model
|
||||||
d->treeModel = new TreeItemModel(this);
|
treeModel = new TreeItemModel(this);
|
||||||
d->ui->treeView->setModel(d->treeModel);
|
ui->treeView->setModel(treeModel);
|
||||||
|
|
||||||
// connect signal/slots
|
// connect signal/slots
|
||||||
// selected item
|
// selected item
|
||||||
connect(d->ui->treeView, SIGNAL(activated(QModelIndex)), SLOT(onItemActivated(QModelIndex)));
|
connect(ui->treeView, SIGNAL(activated(QModelIndex)), SLOT(onItemActivated(QModelIndex)));
|
||||||
|
|
||||||
// connections to the manager
|
// connections to the manager
|
||||||
Manager *manager = Manager::instance();
|
Manager *manager = Manager::instance();
|
||||||
@@ -150,9 +122,7 @@ NavigationWidget::NavigationWidget(QWidget *parent) :
|
|||||||
|
|
||||||
NavigationWidget::~NavigationWidget()
|
NavigationWidget::~NavigationWidget()
|
||||||
{
|
{
|
||||||
delete d->fullProjectsModeButton;
|
delete ui;
|
||||||
delete d->ui;
|
|
||||||
delete d;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavigationWidget::hideEvent(QHideEvent *event)
|
void NavigationWidget::hideEvent(QHideEvent *event)
|
||||||
@@ -184,23 +154,23 @@ QList<QToolButton *> NavigationWidget::createToolButtons()
|
|||||||
QList<QToolButton *> list;
|
QList<QToolButton *> list;
|
||||||
|
|
||||||
// full projects mode
|
// full projects mode
|
||||||
if (!d->fullProjectsModeButton) {
|
if (!fullProjectsModeButton) {
|
||||||
// create a button
|
// create a button
|
||||||
d->fullProjectsModeButton = new QToolButton();
|
fullProjectsModeButton = new QToolButton();
|
||||||
d->fullProjectsModeButton->setIcon(
|
fullProjectsModeButton->setIcon(
|
||||||
QIcon(QLatin1String(":/classview/images/hierarchicalmode.png")));
|
QIcon(QLatin1String(":/classview/images/hierarchicalmode.png")));
|
||||||
d->fullProjectsModeButton->setCheckable(true);
|
fullProjectsModeButton->setCheckable(true);
|
||||||
d->fullProjectsModeButton->setToolTip(tr("Show Subprojects"));
|
fullProjectsModeButton->setToolTip(tr("Show Subprojects"));
|
||||||
|
|
||||||
// by default - not a flat mode
|
// by default - not a flat mode
|
||||||
setFlatMode(false);
|
setFlatMode(false);
|
||||||
|
|
||||||
// connections
|
// connections
|
||||||
connect(d->fullProjectsModeButton, SIGNAL(toggled(bool)),
|
connect(fullProjectsModeButton, SIGNAL(toggled(bool)),
|
||||||
this, SLOT(onFullProjectsModeToggled(bool)));
|
this, SLOT(onFullProjectsModeToggled(bool)));
|
||||||
}
|
}
|
||||||
|
|
||||||
list << d->fullProjectsModeButton;
|
list << fullProjectsModeButton;
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
@@ -211,10 +181,10 @@ QList<QToolButton *> NavigationWidget::createToolButtons()
|
|||||||
|
|
||||||
bool NavigationWidget::flatMode() const
|
bool NavigationWidget::flatMode() const
|
||||||
{
|
{
|
||||||
QTC_ASSERT(d->fullProjectsModeButton, return false);
|
QTC_ASSERT(fullProjectsModeButton, return false);
|
||||||
|
|
||||||
// button is 'full projects mode' - so it has to be inverted
|
// button is 'full projects mode' - so it has to be inverted
|
||||||
return !d->fullProjectsModeButton->isChecked();
|
return !fullProjectsModeButton->isChecked();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -223,10 +193,10 @@ bool NavigationWidget::flatMode() const
|
|||||||
|
|
||||||
void NavigationWidget::setFlatMode(bool flatMode)
|
void NavigationWidget::setFlatMode(bool flatMode)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(d->fullProjectsModeButton, return);
|
QTC_ASSERT(fullProjectsModeButton, return);
|
||||||
|
|
||||||
// button is 'full projects mode' - so it has to be inverted
|
// button is 'full projects mode' - so it has to be inverted
|
||||||
d->fullProjectsModeButton->setChecked(!flatMode);
|
fullProjectsModeButton->setChecked(!flatMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -249,7 +219,7 @@ void NavigationWidget::onItemActivated(const QModelIndex &index)
|
|||||||
if (!index.isValid())
|
if (!index.isValid())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QList<QVariant> list = d->treeModel->data(index, Constants::SymbolLocationsRole).toList();
|
QList<QVariant> list = treeModel->data(index, Constants::SymbolLocationsRole).toList();
|
||||||
|
|
||||||
emit requestGotoLocations(list);
|
emit requestGotoLocations(list);
|
||||||
}
|
}
|
||||||
@@ -271,15 +241,15 @@ void NavigationWidget::onDataUpdate(QSharedPointer<QStandardItem> result)
|
|||||||
// might be just a root - if a lazy data population is enabled.
|
// might be just a root - if a lazy data population is enabled.
|
||||||
// so expanded items must be parsed and 'fetched'
|
// so expanded items must be parsed and 'fetched'
|
||||||
|
|
||||||
fetchExpandedItems(result.data(), d->treeModel->invisibleRootItem());
|
fetchExpandedItems(result.data(), treeModel->invisibleRootItem());
|
||||||
|
|
||||||
d->treeModel->moveRootToTarget(result.data());
|
treeModel->moveRootToTarget(result.data());
|
||||||
|
|
||||||
// expand top level projects
|
// expand top level projects
|
||||||
QModelIndex sessionIndex;
|
QModelIndex sessionIndex;
|
||||||
|
|
||||||
for (int i = 0; i < d->treeModel->rowCount(sessionIndex); ++i)
|
for (int i = 0; i < treeModel->rowCount(sessionIndex); ++i)
|
||||||
d->ui->treeView->expand(d->treeModel->index(i, 0, sessionIndex));
|
ui->treeView->expand(treeModel->index(i, 0, sessionIndex));
|
||||||
|
|
||||||
if (debug)
|
if (debug)
|
||||||
qDebug() << "Class View:" << QDateTime::currentDateTime().toString()
|
qDebug() << "Class View:" << QDateTime::currentDateTime().toString()
|
||||||
@@ -296,8 +266,8 @@ void NavigationWidget::fetchExpandedItems(QStandardItem *item, const QStandardIt
|
|||||||
if (!item || !target)
|
if (!item || !target)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const QModelIndex &parent = d->treeModel->indexFromItem(target);
|
const QModelIndex &parent = treeModel->indexFromItem(target);
|
||||||
if (d->ui->treeView->isExpanded(parent) && Manager::instance()->canFetchMore(item, true))
|
if (ui->treeView->isExpanded(parent) && Manager::instance()->canFetchMore(item, true))
|
||||||
Manager::instance()->fetchMore(item, true);
|
Manager::instance()->fetchMore(item, true);
|
||||||
|
|
||||||
int itemIndex = 0;
|
int itemIndex = 0;
|
||||||
|
|||||||
@@ -30,9 +30,13 @@
|
|||||||
#ifndef CLASSVIEWNAVIGATIONWIDGET_H
|
#ifndef CLASSVIEWNAVIGATIONWIDGET_H
|
||||||
#define CLASSVIEWNAVIGATIONWIDGET_H
|
#define CLASSVIEWNAVIGATIONWIDGET_H
|
||||||
|
|
||||||
|
#include "classviewtreeitemmodel.h"
|
||||||
|
#include "ui_classviewnavigationwidget.h"
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
|
|
||||||
|
#include <QPointer>
|
||||||
#include <QStandardItem>
|
#include <QStandardItem>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
@@ -82,8 +86,9 @@ protected:
|
|||||||
void showEvent(QShowEvent *event);
|
void showEvent(QShowEvent *event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//! Private class data pointer
|
Ui::NavigationWidget *ui;
|
||||||
NavigationWidgetPrivate *d;
|
TreeItemModel *treeModel;
|
||||||
|
QPointer<QToolButton> fullProjectsModeButton;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
Reference in New Issue
Block a user