KDevelop API Documentation

buglistcomponent.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                           buglistcomponent.cpp  -  description
00003                              -------------------
00004     begin                : Sun Dec 10 2000
00005     copyright            : (C) 2000 by Ivan Hawkes
00006     email                : blackhawk@ivanhawkes.com
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #include "buglistcomponent.h"
00019 #include "buglist.h"
00020 
00021 #include <qvbox.h>
00022 #include <qwhatsthis.h>
00023 #include <kdebug.h>
00024 #include <klocale.h>
00025 #include <kiconloader.h>
00026 #include <kdialogbase.h>
00027 
00028 //#include "kdeveditormanager.h"
00029 //#include "KDevComponentManager.h"
00030 
00031 typedef KGenericFactory<BugListComponent> BugListFactory;
00032 K_EXPORT_COMPONENT_FACTORY( libkdevbuglist, BugListFactory( "kdevbuglist" ) );
00033 
00034 
00035 BugListComponent::BugListComponent (QObject *parent, const char *name, const QStringList &)
00036   : KDevPlugin ("BugList", "buglist", parent, name ? name : "BugListComponent")
00037 {
00038     setInstance(BugListFactory::instance());
00039     setXMLFile("kdevbuglist.rc");
00040 
00041     // Ensure it is NULL.
00042     m_pBugList = NULL;
00043 
00044     setupGUI();
00045 }
00046 
00047 BugListComponent::~BugListComponent()
00048 {
00049     // Down she downs.
00050     if (m_pBugList)
00051         delete m_pBugList;
00052 }
00053 
00054 /*
00055 ProjectSpace* BugListComponent::projectSpace(){
00056     return static_cast<ProjectSpace*>(componentManager()->component("ProjectSpace"));
00057 }
00058 
00059 KDevEditorManager* BugListComponent::editorManager(){
00060     return static_cast<KDevEditorManager*>(componentManager()->component("KDevEditorManager"));
00061 }*/
00062 
00063 
00064 // Presumably, they pressed the stop button.
00065 void BugListComponent::slotStopButtonClicked()
00066 {
00067     kdDebug(9040) << "BugList::stopButtonClicked()" << endl;
00068 
00069     // Down she goes.
00070 //    if (m_pBugList)
00071 //    {
00072 //        m_pBugList->slotCancelClicked ();
00073 //        m_pBugList = NULL;
00074 //    }
00075 }
00076 
00077 
00078 void BugListComponent::setupGUI()
00079 {
00080     kdDebug(9040) << "SetupGUI BugList" << endl;
00081 
00082     m_pMenuAction = new KAction(i18n("&Bug Tracking"), CTRL+ALT+Key_B, this,  SLOT(slotActivate()),
00083                          actionCollection(), "bug_tracking");
00084     m_pMenuAction->setStatusText (i18n("Provides bug tracking features for your project."));
00085     m_pMenuAction->setWhatsThis (i18n("Provides bug tracking features for your project."));
00086     core()->insertNewItem( m_pMenuAction );
00087 
00088     // Bug tracking is only valid with a project.
00089     m_pMenuAction->setEnabled (FALSE);
00090 }
00091 
00092 
00093 void BugListComponent::slotProjectSpaceOpened()
00094 {
00095     uint        Count;
00096     QString     LastProject;
00097 
00098     kdDebug(9040) << "BugList::projectSpaceOpened()" << endl;
00099 
00100     // Bug tracking is only valid with a project.
00101     m_pMenuAction->setEnabled (TRUE);
00102 
00103     // Grab the user details from the projectspace.
00104 //    m_pProjectSpace = projectSpace();
00105 //    m_Initials = m_pProjectSpace->initials ();
00106 //    m_UserName = m_pProjectSpace->author ();
00107 //    m_UserEMail = m_pProjectSpace->email ();
00108 
00109     // Get the Projectspace
00110     QDomDocument doc ;//= *m_pProjectSpace->readGlobalDocument();
00111     QDomElement psElement = doc.documentElement();
00112 
00113     // Get the list of projects.
00114     QDomNodeList projNodes = doc.elementsByTagName("Project");
00115     if (projNodes.count () > 1)
00116     {
00117         // Several projects - get details for last used project.
00118         LastProject = psElement.attribute("lastActiveProject");
00119         for (Count = 0;Count < projNodes.count ();Count++)
00120         {
00121             QDomElement projElement = projNodes.item(Count).toElement();
00122             if (LastProject == projElement.attribute("name"))
00123             {
00124                 // Found the right project - grab what we need from it.
00125 //                m_FileName = m_pProjectSpace->absolutePath () + "/" + projElement.attribute("relativePath") + projElement.attribute("bugfile");
00126             }
00127         }
00128     }
00129     else
00130     {
00131         // Just one project, use the bug file from that one.
00132         QDomElement projElement = projNodes.item(0).toElement();
00133 //        m_FileName = m_pProjectSpace->absolutePath () + "/" + projElement.attribute("relativePath") + projElement.attribute("bugfile");
00134     }
00135 
00136 //    kdDebug(9040) << "BugList::AbsPath = " << m_pProjectSpace->absolutePath () << endl;
00137     kdDebug(9040) << "BugList::BugFile = " << m_FileName << endl;
00138     kdDebug(9040) << "BugList::m_Initials = " << m_Initials << endl;
00139     kdDebug(9040) << "BugList::m_UserName = " << m_UserName << endl;
00140     kdDebug(9040) << "BugList::m_UserEMail = " << m_UserEMail << endl;
00141 
00142     // HACK: ProjectSpace not providing this stuff yet!!!
00143     m_Initials = "ILH";
00144     m_UserName = "Ivan Hawkes";
00145     m_UserEMail = "linuxgroupie@ivanhawkes.com";
00146 
00147     // Update the attributes if the component is currently running.
00148     if (m_pBugList)
00149     {
00150         m_pBugList->m_FileName = m_FileName;
00151         m_pBugList->m_Initials = m_Initials;
00152         m_pBugList->m_UserName = m_UserName;
00153         m_pBugList->m_UserEMail = m_UserEMail;
00154     }
00155 }
00156 
00157 
00158 
00159 //   Notification that the project space has now closed.
00160 
00161 
00162 void BugListComponent::slotProjectSpaceClosed()
00163 {
00164     kdDebug(9040) << "BugList::closeProjectSpace" << endl;
00165 
00166     // Bug tracking is only valid with a project.
00167     m_pMenuAction->setEnabled (FALSE);
00168 
00169     // Close down the tracking - warn of change lose.
00170     if (m_pBugList)
00171     {
00172         m_pBugList->slotCloseClicked ();
00173         m_pBugList = NULL;
00174     }
00175 
00176 //    m_pProjectSpace = NULL;
00177 }
00178 
00179 
00180 //  The sub project has changed. Update the filename we will use for
00181 //  the XML file.
00182 
00183 void BugListComponent::slotProjectChanged()
00184 {
00185     kdDebug(9040) << "BugList::projectChanged" << endl;
00186 
00187     // Parse the project space for the details we need on the new
00188     // subproject that we changed to.
00189 
00190 // FIXME: Not in every change in project is the projectspace changed.
00191 //        note that sigProjectChanged is generated also by others e.g. appwizard, though sigProjectSpaceOpened
00192 //        only by the core.
00193 //
00194 
00195 //    slotProjectSpaceOpened ();
00196 }
00197 
00198 
00199 //
00200 //  Use this slot to create an instance of the bug tracking object, or
00201 //  bring the current instance to the fore if it is already loaded.
00202 //
00203 
00204 void BugListComponent::slotActivate()
00205 {
00206     kdDebug(9040) << "BugList Activated" << endl;
00207 
00208     if (!m_pBugList)
00209     {
00210         m_pBugList = new BugList (NULL,"BugList",m_FileName,m_Initials,m_UserName,m_UserEMail);
00211         connect (m_pBugList, SIGNAL(signalDeactivate()), this, SLOT(slotWidgetClosed()));
00212         m_pBugList->show ();
00213     }
00214     else
00215     {
00216         m_pBugList->setActiveWindow ();
00217     }
00218 }
00219 
00220 //
00221 //  Used to respond to the signal from our widget that it is closing down.
00222 //  This gives us a chance to dispose of the widget and NULL it's pointer.
00223 //
00224 
00225 void BugListComponent::slotWidgetClosed ()
00226 {
00227     kdDebug(9040) << "BugList Deactivate" << endl;
00228 
00229     // Clean up as required.
00230     if (m_pBugList)
00231     {
00232         delete m_pBugList;
00233         m_pBugList = NULL;
00234     }
00235 }
00236 
00237 #include "buglistcomponent.moc"
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Feb 22 09:22:38 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003