#include "myplugin.h" #include #include #include #include #include #include #include #include #include "trace.h" #include "traceview.h" /* ----------------------------------------------------------------------- */ namespace MyModule { /* ----------------------------------------------------------------------- */ KAboutData aboutData ("myplugin", "myplugin", ki18n("MyPlugin"), "0.1", ki18n("Simple KDevelop plugin"), KAboutData::License_GPL); K_PLUGIN_FACTORY ( MyPluginFactory, registerPlugin (); ) K_EXPORT_PLUGIN (MyPluginFactory (aboutData)) /* ----------------------------------------------------------------------- */ QWidget * MyViewFactory::create (QWidget * parent) { return new MyView (m_plugin, parent); } Qt::DockWidgetArea MyViewFactory::defaultPosition() { return Qt::BottomDockWidgetArea; } QString MyViewFactory::id() const { return "org.kdevelop.MyPlugin"; } MyViewFactory::MyViewFactory (MyPlugin * plugin) : m_plugin (plugin) { } /* ----------------------------------------------------------------------- */ MyPlugin::MyPlugin (QObject *parent, const QVariantList & args) : KDevelop::IPlugin (MyPluginFactory::componentData(), parent), m_view_factory (NULL) #ifdef TRACEVIEW , m_trace_factory (NULL) #endif { Q_UNUSED(args) std::cout << std::endl; std::cout << " **** MY PLUGIN **** " << std::endl; std::cout << std::endl; setXMLFile ("myplugin.rc"); m_view_factory = new MyViewFactory (this); core()->uiController()->addToolView ("MyPlugin", m_view_factory); #ifdef TRACEVIEW m_trace_factory = new TraceViewFactory (); core()->uiController()->addToolView ("My Plugin Trace", m_trace_factory); #endif KActionCollection* actions = actionCollection (); KAction *action = actions->addAction ("myplugin_run"); action->setText (i18n ("My Plugin")); // action->setShortcut (Qt::CTRL | Qt::ALT | Qt::Key_1); connect (action, SIGNAL (triggered (bool)), this, SLOT (run ())); } MyPlugin::~MyPlugin() { } void MyPlugin::unload() { core()->uiController()->removeToolView (m_view_factory); #ifdef TRACEVIEW core()->uiController()->removeToolView (m_trace_factory); #endif } void MyPlugin::run () { std::cout << std::endl; std::cout << " **** MYPLUGIN RUN **** " << std::endl; std::cout << std::endl; kDebug () << " ---- MYPLUGIN RUN ---- "; #if 1 kDebug (8000) << " .... MYPLUGIN RUN 8000 .... "; kDebug (8001) << " .... MYPLUGIN RUN 8001 .... "; kDebug (8002) << " .... MYPLUGIN RUN 8002 .... "; kDebug (8003) << " .... MYPLUGIN RUN 8003 .... "; kDebug (8004) << " .... MYPLUGIN RUN 8004 .... "; #endif trace ("run"); } /* ----------------------------------------------------------------------- */ MyView::MyView (MyPlugin *plugin, QWidget* parent) : QWidget (parent) { setObjectName (i18n( "MyPlugin")); setWhatsThis (i18n ("MyPlugin

" "This window contains an view.

" ) ); setWindowIcon (KIcon ("tux")); setWindowTitle (i18n ("MyPlugin" ) ); QVBoxLayout * layout = new QVBoxLayout(this); m_button = new QPushButton ("My Plugin", this); connect (m_button, SIGNAL (clicked ()), this, SLOT (click ())); layout->addWidget (m_button, 0); m_tree = new QTreeWidget (this); connect (m_tree, SIGNAL (itemDoubleClicked (QTreeWidgetItem *, int)), this, SLOT (doubleClick (QTreeWidgetItem *, int))); layout->addWidget (m_tree, 1); } void MyView::click () { put ("click"); trace ("click"); } void MyView::put (QString txt) { QTreeWidgetItem * item = new QTreeWidgetItem (m_tree); item->setText (0, txt); } /* ----------------------------------------------------------------------- */ } // end of namespace #include "myplugin.moc" /* ----------------------------------------------------------------------- */ /* Required items in .desktop */ /* [Desktop Entry] Type=Service ServiceTypes=KDevelop/Plugin X-KDE-Library=myplugin X-KDE-PluginInfo-Name=myplugin X-KDevelop-Version=16 X-KDevelop-Category=Global X-KDevelop-Mode=GUI */