Even though the last alpha was .91 this one is going to be 82 as I'd like to have...
[kdevelopdvcssupport.git] / plugins / duchainviewer / duchainviewplugin.cpp
blob9bea56958b9143b339aaa286ac9bba78d961325f
1 /*
2 * This file is part of KDevelop
4 * Copyright 2006 Adam Treat <treat@kde.org>
5 * Copyright 2006 Hamish Rodda <rodda@kde.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU Library General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public
18 * License along with this program; if not, write to the
19 * Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 #include "duchainviewplugin.h"
24 #include "duchainmodel.h"
25 #include "duchaintree.h"
27 #include <klocale.h>
28 #include <kpluginfactory.h>
29 #include <kpluginloader.h>
30 #include <kaboutdata.h>
32 #include <interfaces/icore.h>
33 #include <interfaces/iuicontroller.h>
34 #include <interfaces/idocumentcontroller.h>
36 K_PLUGIN_FACTORY(KDevDUChainViewFactory, registerPlugin<DUChainViewPlugin>(); )
37 K_EXPORT_PLUGIN(KDevDUChainViewFactory(KAboutData("kdevduchainview","kdevduchainview",ki18n("DUChain View"), "0.1", ki18n("A simple tool to view the raw DUChain"), KAboutData::License_GPL)))
39 class DUChainViewFactory: public KDevelop::IToolViewFactory
41 public:
42 DUChainViewFactory(DUChainViewPlugin *plugin): mplugin(plugin) {}
44 virtual QWidget* create(QWidget *parent = 0)
46 QTreeView* view = new DUChainTree(parent, mplugin);
47 QObject::connect(view, SIGNAL(doubleClicked(const QModelIndex &)), mplugin->model(), SLOT(doubleClicked(const QModelIndex &)));
48 return view;
51 virtual Qt::DockWidgetArea defaultPosition()
53 return Qt::RightDockWidgetArea;
56 virtual QString id() const
58 return "org.kdevelop.DUChainView";
61 private:
62 DUChainViewPlugin *mplugin;
65 DUChainViewPlugin::DUChainViewPlugin(QObject *parent,
66 const QVariantList&)
67 : KDevelop::IPlugin(KDevDUChainViewFactory::componentData(), parent)
68 , m_model(new DUChainModel(this))
69 , m_factory(new DUChainViewFactory(this))
71 core()->uiController()->addToolView(i18n("DUChain Viewer"), m_factory);
72 setXMLFile( "kdevduchainview.rc" );
74 connect(core()->documentController(), SIGNAL(documentActivated(KDevelop::IDocument*)), m_model, SLOT(documentActivated(KDevelop::IDocument*)));
77 DUChainViewPlugin::~DUChainViewPlugin()
81 void DUChainViewPlugin::unload()
83 core()->uiController()->removeToolView(m_factory);
86 DUChainModel* DUChainViewPlugin::model() const
88 return m_model;
91 #include "duchainviewplugin.moc"
93 // kate: space-indent on; indent-width 2; tab-width 4; replace-tabs on; auto-insert-doxygen on