Even though the last alpha was .91 this one is going to be 82 as I'd like to have...
[kdevelopdvcssupport.git] / plugins / duchainviewer / duchaintree.cpp
blobb556df8bde5e030ee51bd573edc293de5442f58e
1 /*
2 * KDevelop DUChain viewer
4 * Copyright (c) 2007 Hamish Rodda <rodda@kde.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Library General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public
17 * License along with this program; if not, write to the
18 * Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 #include "duchaintree.h"
24 #include <QHeaderView>
26 #include <klocale.h>
28 #include <ktexteditor/document.h>
29 #include <ktexteditor/view.h>
31 #include <interfaces/icore.h>
32 #include <interfaces/idocumentcontroller.h>
33 #include <interfaces/idocument.h>
34 #include <language/duchain/duchainbase.h>
36 #include "duchainmodel.h"
37 #include "duchainviewplugin.h"
39 using namespace KDevelop;
41 DUChainTree::DUChainTree(QWidget* parent, DUChainViewPlugin* plugin)
42 : QTreeView(parent)
43 , mplugin(plugin)
45 setObjectName("DUChain Viewer Tree");
46 setWindowTitle(i18n("Definition-Use Chain"));
47 setModel(mplugin->model());
48 header()->hide();
50 connect(this, SIGNAL(activated(const QModelIndex&)), SLOT(contextActivated(const QModelIndex&)));
53 DUChainTree::~DUChainTree()
57 DUChainModel* DUChainTree::model()
59 return mplugin->model();
62 void DUChainTree::contextActivated(const QModelIndex& index)
64 DUChainBasePointer* base = model()->objectForIndex(index);
65 if (base && base->data()) {
66 IDocument* doc = mplugin->core()->documentController()->activeDocument();
67 doc->textDocument()->activeView()->setSelection((*base)->range().textRange());
71 // kate: space-indent on; indent-width 2; tab-width: 4; replace-tabs on; auto-insert-doxygen on
73 #include "duchaintree.moc"