Commit fe5f159e authored by Eike Ziller's avatar Eike Ziller
Browse files

ClassView: Remove unnecessary private class



Change-Id: Ib0b67b01604d3abc7d2a30dd3841fa4a46775a4e
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@digia.com>
parent 7addeb00
......@@ -28,8 +28,6 @@
****************************************************************************/
#include "classviewnavigationwidget.h"
#include "ui_classviewnavigationwidget.h"
#include "classviewtreeitemmodel.h"
#include "classviewmanager.h"
#include "classviewsymbollocation.h"
#include "classviewsymbolinformation.h"
......@@ -39,37 +37,12 @@
#include <utils/qtcassert.h>
#include <QDebug>
#include <QPointer>
enum { debug = false };
namespace ClassView {
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 //////////////////////////////////
/*!
......@@ -115,19 +88,18 @@ public:
*/
NavigationWidget::NavigationWidget(QWidget *parent) :
QWidget(parent),
d(new NavigationWidgetPrivate())
QWidget(parent)
{
d->ui = new Ui::NavigationWidget;
d->ui->setupUi(this);
ui = new Ui::NavigationWidget;
ui->setupUi(this);
// tree model
d->treeModel = new TreeItemModel(this);
d->ui->treeView->setModel(d->treeModel);
treeModel = new TreeItemModel(this);
ui->treeView->setModel(treeModel);
// connect signal/slots
// 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
Manager *manager = Manager::instance();
......@@ -150,9 +122,7 @@ NavigationWidget::NavigationWidget(QWidget *parent) :
NavigationWidget::~NavigationWidget()
{
delete d->fullProjectsModeButton;
delete d->ui;
delete d;
delete ui;
}
void NavigationWidget::hideEvent(QHideEvent *event)
......@@ -184,23 +154,23 @@ QList<QToolButton *> NavigationWidget::createToolButtons()
QList<QToolButton *> list;
// full projects mode
if (!d->fullProjectsModeButton) {
if (!fullProjectsModeButton) {
// create a button
d->fullProjectsModeButton = new QToolButton();
d->fullProjectsModeButton->setIcon(
fullProjectsModeButton = new QToolButton();
fullProjectsModeButton->setIcon(
QIcon(QLatin1String(":/classview/images/hierarchicalmode.png")));
d->fullProjectsModeButton->setCheckable(true);
d->fullProjectsModeButton->setToolTip(tr("Show Subprojects"));
fullProjectsModeButton->setCheckable(true);
fullProjectsModeButton->setToolTip(tr("Show Subprojects"));
// by default - not a flat mode
setFlatMode(false);
// connections
connect(d->fullProjectsModeButton, SIGNAL(toggled(bool)),
connect(fullProjectsModeButton, SIGNAL(toggled(bool)),
this, SLOT(onFullProjectsModeToggled(bool)));
}
list << d->fullProjectsModeButton;
list << fullProjectsModeButton;
return list;
}
......@@ -211,10 +181,10 @@ QList<QToolButton *> NavigationWidget::createToolButtons()
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
return !d->fullProjectsModeButton->isChecked();
return !fullProjectsModeButton->isChecked();
}
/*!
......@@ -223,10 +193,10 @@ bool NavigationWidget::flatMode() const
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
d->fullProjectsModeButton->setChecked(!flatMode);
fullProjectsModeButton->setChecked(!flatMode);
}
/*!
......@@ -249,7 +219,7 @@ void NavigationWidget::onItemActivated(const QModelIndex &index)
if (!index.isValid())
return;
QList<QVariant> list = d->treeModel->data(index, Constants::SymbolLocationsRole).toList();
QList<QVariant> list = treeModel->data(index, Constants::SymbolLocationsRole).toList();
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.
// 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
QModelIndex sessionIndex;
for (int i = 0; i < d->treeModel->rowCount(sessionIndex); ++i)
d->ui->treeView->expand(d->treeModel->index(i, 0, sessionIndex));
for (int i = 0; i < treeModel->rowCount(sessionIndex); ++i)
ui->treeView->expand(treeModel->index(i, 0, sessionIndex));
if (debug)
qDebug() << "Class View:" << QDateTime::currentDateTime().toString()
......@@ -296,8 +266,8 @@ void NavigationWidget::fetchExpandedItems(QStandardItem *item, const QStandardIt
if (!item || !target)
return;
const QModelIndex &parent = d->treeModel->indexFromItem(target);
if (d->ui->treeView->isExpanded(parent) && Manager::instance()->canFetchMore(item, true))
const QModelIndex &parent = treeModel->indexFromItem(target);
if (ui->treeView->isExpanded(parent) && Manager::instance()->canFetchMore(item, true))
Manager::instance()->fetchMore(item, true);
int itemIndex = 0;
......
......@@ -30,9 +30,13 @@
#ifndef CLASSVIEWNAVIGATIONWIDGET_H
#define CLASSVIEWNAVIGATIONWIDGET_H
#include "classviewtreeitemmodel.h"
#include "ui_classviewnavigationwidget.h"
#include <QList>
#include <QSharedPointer>
#include <QPointer>
#include <QStandardItem>
#include <QToolButton>
#include <QWidget>
......@@ -82,8 +86,9 @@ protected:
void showEvent(QShowEvent *event);
private:
//! Private class data pointer
NavigationWidgetPrivate *d;
Ui::NavigationWidget *ui;
TreeItemModel *treeModel;
QPointer<QToolButton> fullProjectsModeButton;
};
} // namespace Internal
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment