KDevelop API Documentation

buglist.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                           buglist.cpp  -  description
00003                              -------------------
00004     begin                : Sat Nov 11 22:19:31 GMT 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 "buglist.h"
00019 #include "bugedit.h"
00020 #include <qdatetime.h>
00021 #include <qdom.h>
00022 #include <qfile.h>
00023 #include <qmessagebox.h>
00024 #include <qsortedlist.h>
00025 #include <qxml.h>
00026 #include <fstream.h>
00027 #include <klocale.h>
00028 #include <kpushbutton.h>
00029 #include <kstdguiitem.h>
00030 
00031 // Column identifiers for the listbox.
00032 #define LST_ID          0
00033 #define LST_DESC        1
00034 #define LST_SEVERITY    2
00035 #define LST_PRIORITY    3
00036 #define LST_AGE         4
00037 #define LST_PACKAGE     5
00038 #define LST_ASSIGNEDTO  6
00039 
00040 
00041 BugList::BugList(QWidget *parent, const char *name, QString FileName,
00042                  QString Initials, QString UserName, QString UserEMail)
00043 : QWidget(parent, name)
00044 {
00045     // Grab our members from the constructor.
00046     m_FileName = FileName;
00047     m_Initials = Initials;
00048     m_UserName = UserName;
00049     m_UserEMail = UserEMail;
00050 
00051     // Don't let it get too small.
00052     this->setMinimumSize (500,300);
00053 
00054     // Create a bounding box for the listbox
00055     pBugListBox = new QHBox(this);
00056     pBugListBox->setMinimumSize (300,200);
00057 
00058     // Create the list for displaying bugs.
00059     pMainBugList = new QListView (pBugListBox, "mainbuglist");
00060     pMainBugList->addColumn (i18n("Bug ID"),72);
00061     pMainBugList->addColumn (i18n("Description"),190);
00062     pMainBugList->addColumn (i18n("Severity"),60);
00063     pMainBugList->addColumn (i18n("Priority"),60);
00064     pMainBugList->addColumn (i18n("Days Old"),60);
00065     pMainBugList->addColumn (i18n("Package"),120);
00066     pMainBugList->addColumn (i18n("Assigned To"),100);
00067 //    pMainBugList->setColumnAlignment (3,Qt::AlignRight);
00068 
00069     // Make the list use all columns for showing focus.
00070     pMainBugList->setAllColumnsShowFocus (TRUE);
00071 
00072     // Double click on listnox is same as pressing edit buttton.
00073     connect (pMainBugList, SIGNAL(doubleClicked (QListViewItem * )), this, SLOT(slotListDoubleClicked (QListViewItem *)));
00074 
00075     // Create a bounding box for the maintenance controls
00076     pMaintenanceBox = new QVBox(this);
00077     pMaintenanceBox->setMinimumSize (100,200);
00078     pMaintenanceBox->setMaximumSize (100,200);
00079     pMaintenanceBox->setSpacing (10);
00080     pMaintenanceBox->setMargin (0);
00081 
00082     // Create the add button.
00083     QPushButton *Add = new QPushButton( i18n("Add"), pMaintenanceBox, "add" );
00084     connect (Add, SIGNAL(clicked()), this, SLOT(slotAddClicked()));
00085     Add->setMinimumSize (100,25);
00086     Add->setMaximumSize (100,25);
00087 
00088     // Create the edit button.
00089     QPushButton *Edit = new QPushButton( i18n("Edit"), pMaintenanceBox, "edit");
00090     connect (Edit, SIGNAL(clicked()), this, SLOT(slotEditClicked()));
00091     Edit->setMinimumSize (100,25);
00092     Edit->setMaximumSize (100,25);
00093 
00094     // Create the delete button.
00095     QPushButton *Delete = new QPushButton( i18n("Delete"), pMaintenanceBox, "delete" );
00096     connect (Delete, SIGNAL(clicked()), this, SLOT(slotRemoveClicked()));
00097     Delete->setMinimumSize (100,25);
00098     Delete->setMaximumSize (100,25);
00099 
00100     // Create the completed button.
00101     QPushButton *Completed = new QPushButton( i18n("Completed"), pMaintenanceBox, "completed");
00102     connect (Completed, SIGNAL(clicked()), this, SLOT(slotCompletedClicked()));
00103     Completed->setMinimumSize (100,25);
00104     Completed->setMaximumSize (100,25);
00105 
00106     // Create the Filter button.
00107     QPushButton *Filter = new QPushButton( i18n("Filter"), pMaintenanceBox, "filter");
00108     connect (Filter, SIGNAL(clicked()), this, SLOT(slotFilter ()));
00109     Filter->setMinimumSize (100,25);
00110     Filter->setMaximumSize (100,25);
00111 
00112     // Create the Ownership button.
00113     QPushButton *Ownership = new QPushButton( i18n("My Bug"), pMaintenanceBox, "Ownership");
00114     connect (Ownership, SIGNAL(clicked()), this, SLOT(slotOwnership ()));
00115     Ownership->setMinimumSize (100,25);
00116     Ownership->setMaximumSize (100,25);
00117 
00118     // Create a bounding box for the exit controls
00119     pExitBox = new QVBox(this);
00120     pExitBox->setMinimumSize (100,60);
00121     pExitBox->setMaximumSize (100,60);
00122     pExitBox->setSpacing (10);
00123     pExitBox->setMargin (0);
00124 
00125     // Create the cancel button.
00126     QPushButton *Cancel = new KPushButton( KStdGuiItem::cancel(), pExitBox, "cancel" );
00127     connect (Cancel, SIGNAL(clicked()), this, SLOT(slotCancelClicked()));
00128     Cancel->setMinimumSize (100,25);
00129     Cancel->setMaximumSize (100,25);
00130 
00131     // Create the close button.
00132     QPushButton *Close = new KPushButton( KStdGuiItem::close(), pExitBox, "close");
00133     connect (Close, SIGNAL(clicked()), this, SLOT(slotCloseClicked()));
00134     Close->setMinimumSize (100,25);
00135     Close->setMaximumSize (100,25);
00136 
00137     // Can't be dirty until we change something.
00138     Dirty = FALSE;
00139 
00140     // Get the dictionary object to clear out the entries on deletion.
00141     BugDictionary.setAutoDelete (TRUE);
00142 
00143     // Get the dictionary object to clear out the entries on deletion.
00144     Developers.setAutoDelete (TRUE);
00145 
00146     // Parse the contents of the XML file into memory.
00147     ParseFile ();
00148 
00149     // Make sure at least we are in there.
00150     if (!Developers [m_Initials])
00151     {
00152         BugCounter *    pBugCounter;
00153 
00154         // Add the current developer settings into the dictionary.
00155         pBugCounter = new BugCounter;
00156         pBugCounter->Initials = m_Initials;
00157         pBugCounter->LastBugNumber = 0;
00158         Developers.insert (pBugCounter->Initials, pBugCounter);
00159     }
00160 }
00161 
00162 
00163 BugList::~BugList()
00164 {
00165 }
00166 
00167 
00168 void BugList::ParseFile ()
00169 {
00170     QFile           file (m_FileName);
00171     QDomDocument    xmlDocument;
00172     uint            Count;
00173 
00174     // Try to open our bug tracking file.
00175     if (!file.open (IO_ReadOnly))
00176     {
00177         QMessageBox (NULL, i18n("Unable to read the bug tracking file %1").arg(m_FileName));
00178         return;
00179     }
00180 
00181     // Try to associate the file with the XML document.
00182     if (!xmlDocument.setContent(&file))
00183     {
00184         QMessageBox (NULL, i18n("The file %1 does not contain valid XML").arg(m_FileName));
00185         return;
00186     }
00187 
00188     // Get the main space of the document.
00189     kdDebug(9040) << "BugList::Parsing the bug list" << endl;
00190     QDomElement elmMain = xmlDocument.documentElement();
00191 
00192     // Get the list of developers.
00193     QDomNodeList nodeDevelopers = xmlDocument.elementsByTagName("Developer");
00194     for (Count = 0;Count < nodeDevelopers.count ();Count++)
00195     {
00196         BugCounter *    pBugCounter;
00197 
00198         // Retrieve the developer element.
00199         QDomElement elmDeveloper = nodeDevelopers.item(Count).toElement();
00200 
00201         // Add the current developer settings into the dictionary.
00202         pBugCounter = new BugCounter;
00203         pBugCounter->Initials = elmDeveloper.attribute("Initials");
00204         pBugCounter->LastBugNumber = elmDeveloper.attribute("Counter").toInt ();
00205         Developers.insert (pBugCounter->Initials, pBugCounter);
00206     }
00207 
00208     // Get the list of bugs.
00209     QDomNodeList nodeBugs = xmlDocument.elementsByTagName("Bug");
00210     for (Count = 0;Count < nodeBugs.count ();Count++)
00211     {
00212         Bug *   pBug;
00213 
00214         // Retrieve the developer element.
00215         QDomElement elmBug = nodeBugs.item(Count).toElement();
00216 
00217         // Grab the basic attributes.
00218         pBug = new Bug;
00219         pBug->BugID = elmBug.attribute("BugID");
00220         pBug->Description = elmBug.attribute("Description");
00221 
00222         // Work through all the elements.
00223         QDomNode    nodeChild = elmBug.firstChild ();
00224         while (!nodeChild.isNull ())
00225         {
00226             // Turn the node into an element.
00227             QDomElement elmSubBug = nodeChild.toElement();
00228 
00229             // Severity
00230             if (elmSubBug.nodeName () == "Severity")
00231                 pBug->Severity = elmSubBug.text ();
00232 
00233             // BugClass
00234             if (elmSubBug.nodeName () == "BugClass")
00235                 pBug->BugClass = elmSubBug.text ();
00236 
00237             // Location
00238             if (elmSubBug.nodeName () == "Location")
00239                 pBug->Location = elmSubBug.text ();
00240 
00241             // AssignedTo
00242             if (elmSubBug.nodeName () == "AssignedTo")
00243                 pBug->AssignedTo = elmSubBug.text ();
00244 
00245             // AssignedEMail
00246             if (elmSubBug.nodeName () == "AssignedEMail")
00247                 pBug->AssignedEMail = elmSubBug.text ();
00248 
00249             // ReportUserName
00250             if (elmSubBug.nodeName () == "ReportUserName")
00251                 pBug->ReportUserName = elmSubBug.text ();
00252 
00253             // ReportEMail
00254             if (elmSubBug.nodeName () == "ReportEMail")
00255                 pBug->ReportEMail = elmSubBug.text ();
00256 
00257             // Package
00258             if (elmSubBug.nodeName () == "Package")
00259                 pBug->Package = elmSubBug.text ();
00260 
00261             // VersionNo
00262             if (elmSubBug.nodeName () == "VersionNo")
00263                 pBug->VersionNo = elmSubBug.text ();
00264 
00265             // Notes
00266             if (elmSubBug.nodeName () == "Notes")
00267                 pBug->Notes = elmSubBug.text ();
00268 
00269             // Workaround
00270             if (elmSubBug.nodeName () == "Workaround")
00271                 pBug->Workaround = elmSubBug.text ();
00272 
00273             // SysInfo
00274             if (elmSubBug.nodeName () == "SysInfo")
00275                 pBug->SysInfo = elmSubBug.text ();
00276 
00277             // Priority
00278             if (elmSubBug.nodeName () == "Priority")
00279                 pBug->Priority = elmSubBug.text ();
00280 
00281             // Repeat
00282             if (elmSubBug.nodeName () == "Repeat")
00283                 pBug->Repeat = elmSubBug.text ();
00284 
00285             // AssignedDate
00286             if (elmSubBug.nodeName () == "AssignedDate")
00287                 pBug->AssignedDate.setYMD (elmSubBug.text ().right (4).toInt (),elmSubBug.text ().mid (elmSubBug.text ().find ('/') + 1,elmSubBug.text ().findRev ('/') - elmSubBug.text ().find ('/') - 1).toInt (),elmSubBug.text ().left (elmSubBug.text ().find ('/')).toInt ());
00288 
00289             // ReportDate
00290             if (elmSubBug.nodeName () == "ReportDate")
00291                 pBug->ReportDate.setYMD (elmSubBug.text ().right (4).toInt (),elmSubBug.text ().mid (elmSubBug.text ().find ('/') + 1,elmSubBug.text ().findRev ('/') - elmSubBug.text ().find ('/') - 1).toInt (),elmSubBug.text ().left (elmSubBug.text ().find ('/')).toInt ());
00292 
00293             // FixScheduled
00294             if (elmSubBug.nodeName () == "FixScheduled")
00295                 pBug->FixScheduled.setYMD (elmSubBug.text ().right (4).toInt (),elmSubBug.text ().mid (elmSubBug.text ().find ('/') + 1,elmSubBug.text ().findRev ('/') - elmSubBug.text ().find ('/') - 1).toInt (),elmSubBug.text ().left (elmSubBug.text ().find ('/')).toInt ());
00296 
00297             //pBug->BugClass = elmBug.attribute("BugClass");
00298             nodeChild = nodeChild.nextSibling ();
00299         }
00300 
00301         InsertBug (pBug);
00302     }
00303 }
00304 
00305 
00313 void BugList::WriteXMLFile ()
00314 {
00315     QSortedList     <QString> SortedBugList;
00316     QSortedList     <QString> SortedDeveloperList;
00317     QDictIterator   <Bug> BugIterator (BugDictionary);
00318     QDictIterator   <BugCounter> DevIterator (Developers);
00319     QString *       pEntry;
00320     Bug *           pBug;
00321     BugCounter *    pBugCounter;
00322     QString         TheDate;
00323 
00324     // We make a sorted list of the bug ID's - why don't QT provide a sort on
00325     // their dictionary object?
00326     while (BugIterator.current())
00327     {
00328         SortedBugList.append (&BugIterator.current ()->BugID);
00329         ++BugIterator;
00330     }
00331     SortedBugList.sort ();
00332 
00333     // And a sorted list of developers too.
00334     while (DevIterator.current())
00335     {
00336         SortedDeveloperList.append (&DevIterator.current ()->Initials);
00337         ++DevIterator;
00338     }
00339     SortedDeveloperList.sort ();
00340 
00341     QDomDocument    xmlDocument ("BugTracking");
00342     xmlDocument.appendChild (xmlDocument.createProcessingInstruction ("xml", "version=\"1.0\" encoding=\"UTF-8\""));
00343 
00344     // The main document space.
00345     QDomElement elmMain = xmlDocument.appendChild (xmlDocument.createElement("BugData")).toElement();
00346 
00347     // Write out the developer list.
00348     QDomElement elmDevelopers = elmMain.appendChild (xmlDocument.createElement("Developers")).toElement();
00349     for (pEntry = SortedDeveloperList.first(); pEntry != NULL; pEntry = SortedDeveloperList.next ())
00350     {
00351         // Get a pointer to our object.
00352         pBugCounter = Developers [*pEntry];
00353 
00354         // Pump it out.
00355         QDomElement elmDeveloper = elmDevelopers.appendChild (xmlDocument.createElement("Developer")).toElement();
00356         elmDeveloper.setAttribute ("Initials",pBugCounter->Initials);
00357         elmDeveloper.setAttribute ("Counter",pBugCounter->LastBugNumber);
00358     }
00359 
00360     // Output the bug list.
00361     QDomElement elmBugs = elmMain.appendChild(xmlDocument.createElement("Bugs")).toElement();
00362     for (pEntry = SortedBugList.first(); pEntry != NULL; pEntry = SortedBugList.next ())
00363     {
00364         // Get a pointer to our object.
00365         pBug = BugDictionary [*pEntry];
00366         QDomElement elmBug = elmBugs.appendChild (xmlDocument.createElement("Bug")).toElement();
00367 
00368         // BugID
00369         if (pBug->BugID)
00370             elmBug.setAttribute ("BugID",pBug->BugID);
00371 
00372         // Description
00373         if (pBug->Description)
00374             elmBug.setAttribute ("Description",pBug->Description);
00375 
00376          // Severity
00377         if (pBug->Severity)
00378         {
00379             QDomElement elmSeverity = elmBug.appendChild (xmlDocument.createElement("Severity")).toElement();
00380             elmSeverity.appendChild (xmlDocument.createTextNode(pBug->Severity)).toElement();
00381         }
00382 
00383         // Priority
00384         if (pBug->Priority)
00385         {
00386             QDomElement elmPriority = elmBug.appendChild (xmlDocument.createElement("Priority")).toElement();
00387             elmPriority.appendChild (xmlDocument.createTextNode(pBug->Priority)).toElement();
00388         }
00389 
00390         // BugClass
00391         if (pBug->BugClass)
00392         {
00393             QDomElement elmBugClass = elmBug.appendChild (xmlDocument.createElement("BugClass")).toElement();
00394             elmBugClass.appendChild (xmlDocument.createTextNode(pBug->BugClass)).toElement();
00395         }
00396 
00397         // Location
00398         if (pBug->Location)
00399         {
00400             QDomElement elmLocation = elmBug.appendChild (xmlDocument.createElement("Location")).toElement();
00401             elmLocation.appendChild (xmlDocument.createTextNode(pBug->Location)).toElement();
00402         }
00403 
00404         // AssignedTo
00405         if (pBug->AssignedTo)
00406         {
00407             QDomElement elmAssignedTo = elmBug.appendChild (xmlDocument.createElement("AssignedTo")).toElement();
00408             elmAssignedTo.appendChild (xmlDocument.createTextNode(pBug->AssignedTo)).toElement();
00409         }
00410 
00411         // AssignedEMail
00412         if (pBug->AssignedEMail)
00413         {
00414             QDomElement elmAssignedEMail = elmBug.appendChild (xmlDocument.createElement("AssignedEMail")).toElement();
00415             elmAssignedEMail.appendChild (xmlDocument.createTextNode(pBug->AssignedEMail)).toElement();
00416         }
00417 
00418         // ReportUserName
00419         if (pBug->ReportUserName)
00420         {
00421             QDomElement elmReportUserName = elmBug.appendChild (xmlDocument.createElement("ReportUserName")).toElement();
00422             elmReportUserName.appendChild (xmlDocument.createTextNode(pBug->ReportUserName)).toElement();
00423         }
00424 
00425         // ReportEMail
00426         if (pBug->ReportEMail)
00427         {
00428             QDomElement elmReportEMail = elmBug.appendChild (xmlDocument.createElement("ReportEMail")).toElement();
00429             elmReportEMail.appendChild (xmlDocument.createTextNode(pBug->ReportEMail)).toElement();
00430         }
00431 
00432         // Package
00433         if (pBug->Package)
00434         {
00435             QDomElement elmPackage = elmBug.appendChild (xmlDocument.createElement("Package")).toElement();
00436             elmPackage.appendChild (xmlDocument.createTextNode(pBug->Package)).toElement();
00437         }
00438 
00439         // VersionNo
00440         if (pBug->VersionNo)
00441         {
00442             QDomElement elmVersionNo = elmBug.appendChild (xmlDocument.createElement("VersionNo")).toElement();
00443             elmVersionNo.appendChild (xmlDocument.createTextNode(pBug->VersionNo)).toElement();
00444         }
00445 
00446         // Notes
00447         if (pBug->Notes)
00448         {
00449             QDomElement elmNotes = elmBug.appendChild (xmlDocument.createElement("Notes")).toElement();
00450             elmNotes.appendChild (xmlDocument.createTextNode(pBug->Notes)).toElement();
00451         }
00452 
00453         // Workaround
00454         if (pBug->Workaround)
00455         {
00456             QDomElement elmWorkaround = elmBug.appendChild (xmlDocument.createElement("Workaround")).toElement();
00457             elmWorkaround.appendChild (xmlDocument.createTextNode(pBug->Workaround)).toElement();
00458         }
00459 
00460         // Repeat
00461         if (pBug->Repeat)
00462         {
00463             QDomElement elmRepeat = elmBug.appendChild (xmlDocument.createElement("Repeat")).toElement();
00464             elmRepeat.appendChild (xmlDocument.createTextNode(pBug->Repeat)).toElement();
00465         }
00466 
00467         // SysInfo
00468         if (pBug->SysInfo)
00469         {
00470             QDomElement elmSysInfo = elmBug.appendChild (xmlDocument.createElement("SysInfo")).toElement();
00471             elmSysInfo.appendChild (xmlDocument.createTextNode(pBug->SysInfo)).toElement();
00472         }
00473 
00474         // AssignedDate
00475         if (!pBug->AssignedDate.isNull ())
00476         {
00477             QDomElement elmAssignedDate = elmBug.appendChild (xmlDocument.createElement("AssignedDate")).toElement();
00478             TheDate.sprintf ("%i/%i/%i",pBug->AssignedDate.day (), pBug->AssignedDate.month (), pBug->AssignedDate.year ());
00479             elmAssignedDate.appendChild (xmlDocument.createTextNode(TheDate)).toElement();
00480         }
00481 
00482         // ReportDate
00483         if (!pBug->ReportDate.isNull ())
00484         {
00485             QDomElement elmReportDate = elmBug.appendChild (xmlDocument.createElement("ReportDate")).toElement();
00486             TheDate.sprintf ("%i/%i/%i",pBug->ReportDate.day (), pBug->ReportDate.month (), pBug->ReportDate.year ());
00487             elmReportDate.appendChild (xmlDocument.createTextNode(TheDate)).toElement();
00488         }
00489 
00490         // FixScheduled
00491         if (!pBug->FixScheduled.isNull ())
00492         {
00493             QDomElement elmFixScheduled = elmBug.appendChild (xmlDocument.createElement("FixScheduled")).toElement();
00494             TheDate.sprintf ("%i/%i/%i",pBug->FixScheduled.day (), pBug->FixScheduled.month (), pBug->FixScheduled.year ());
00495             elmFixScheduled.appendChild (xmlDocument.createTextNode(TheDate)).toElement();
00496         }
00497 
00498         ++BugIterator;
00499     }
00500 
00501     // Save the document to a file.
00502     QFile file (m_FileName);
00503     if (!file.open (IO_WriteOnly))
00504     {
00505         QMessageBox (NULL, i18n("Unable to save the bug tracking file"));
00506         return;
00507     }
00508     QTextStream s(&file);
00509     xmlDocument.save (s,4);
00510     file.close();
00511 }
00512 
00513 
00514 // Add the bug passed as a parameter to our listbox and dictionary.
00515 
00516 void BugList::InsertBug (Bug * pBug)
00517 {
00518     QString     Age;
00519     char        tmp [10];
00520 
00521     // Work out the age of the request and zero pad it so it sorts in the list.
00522     if (!pBug->ReportDate.isNull ())
00523     {
00524         sprintf (tmp,"%03i",pBug->ReportDate.daysTo (QDate::currentDate ()));
00525         Age = tmp;
00526     }
00527     else
00528     {
00529         // Age unknown...
00530         Age = " - ";
00531     }
00532 
00533     // Add the bug to the dictionary.
00534     BugDictionary.insert (pBug->BugID,pBug);
00535 
00536     // Add the current bug item to the list.
00537     (void) new QListViewItem (pMainBugList, pBug->BugID, pBug->Description, pBug->Severity, pBug->Priority, Age, pBug->Package, pBug->AssignedTo);
00538 }
00539 
00540 
00541 // Add the bug passed as a parameter to our listbox and dictionary.
00542 // NOTE: This does not mark the buffer as dirty because I use this method
00543 // from the structure parser to load the listbox on startup.
00544 
00545 void BugList::slotAddBug (Bug * pBug)
00546 {
00547     // Do the insertion.
00548     InsertBug (pBug);
00549 
00550     // Mark the buffer as being dirty now.
00551     Dirty = TRUE;
00552 }
00553 
00554 
00555 void BugList::slotUpdateBug (Bug * pBug)
00556 {
00557     QListViewItem *     pItem;
00558     QString             Age;
00559     char                tmp [10];
00560 
00561     // Work out the age of the request and zero pad it so it sorts in the list.
00562     if (!pBug->ReportDate.isNull ())
00563     {
00564         sprintf (tmp,"%03i",pBug->ReportDate.daysTo (QDate::currentDate ()));
00565         Age = tmp;
00566     }
00567     else
00568     {
00569         // Age unknown...
00570         Age = " - ";
00571     }
00572 
00573     pItem = pMainBugList->currentItem ();
00574     if (pItem != NULL)
00575     {
00576         // Update the text in the listbox.
00577         pItem->setText (LST_DESC,pBug->Description);
00578         pItem->setText (LST_SEVERITY,pBug->Severity);
00579         pItem->setText (LST_AGE,Age);
00580         pItem->setText (LST_PACKAGE,pBug->Package);
00581         pItem->setText (LST_ASSIGNEDTO,pBug->AssignedTo);
00582         pItem->setText (LST_PRIORITY,pBug->Priority);
00583 
00584         // Let them know when they exit that changes have occured.
00585         Dirty = TRUE;
00586     }
00587 }
00588 
00589 
00590 // They pressed the 'Add' button.
00591 
00592 void BugList::slotAddClicked()
00593 {
00594     Bug *           pBug;
00595     BugCounter *    pBugCounter;
00596 
00597     // Create a bug for the editor to work on.
00598     pBug = new Bug;
00599 
00600     // Try to grab a developer's bug counter.
00601     pBugCounter = Developers [m_Initials];
00602 
00603     // They didn't have a matching set of initials. We better add it now.
00604     if (!pBugCounter)
00605     {
00606         BugCounter *    pBugCounter;
00607 
00608         // Add the current developer settings into the dictionary.
00609         pBugCounter = new BugCounter;
00610         pBugCounter->Initials = m_Initials;
00611         pBugCounter->LastBugNumber = 0;
00612         Developers.insert (pBugCounter->Initials, pBugCounter);
00613 
00614         // And get that counter again.
00615         pBugCounter = Developers [m_Initials];
00616     }
00617 
00618     // Get a suitable ID.
00619     pBug->BugID = pBugCounter->GetNextID ();
00620 
00621     // Fire up the bug editor on the new bug we created.
00622     BugEdit * pBugEdit = new BugEdit (this,"bugedit",pBug,TRUE,TRUE);
00623     pBugEdit->setGeometry (0,0,400,400);
00624 
00625     // Allow the editor to signal when we should add an item to our list.
00626     connect (pBugEdit, SIGNAL(sigAddBug (Bug *)), this, SLOT(slotAddBug (Bug *)));
00627 
00628     // Show the edit screen.
00629     pBugEdit->show();
00630 }
00631 
00632 
00633 // They pressed the 'Edit' button
00634 
00635 void BugList::slotEditClicked()
00636 {
00637         Bug *           pBug;
00638 
00639     // Make sure there is an entry selected and then delete.
00640     if (pMainBugList->currentItem () != NULL)
00641     {
00642         // Get a pointer to the entry they want to edit.
00643         pBug = BugDictionary [pMainBugList->currentItem ()->text (0)];
00644 
00645         // Fire up the bug editor on this existing bug.
00646         BugEdit * pBugEdit = new BugEdit (this,"bugedit",pBug,FALSE,TRUE);
00647         pBugEdit->setGeometry (0,0,400,400);
00648 
00649         // Allow the editor to signal when we should update our item.
00650         connect (pBugEdit, SIGNAL(sigUpdateBug (Bug *)), this, SLOT(slotUpdateBug (Bug *)));
00651 
00652         // Show the edit screen.
00653         pBugEdit->show();
00654     }
00655 }
00656 
00657 
00658 // They double clicked the listbox. Same effect as clicking the edit button.
00659 
00660 void BugList::slotListDoubleClicked (QListViewItem *)
00661 {
00662     slotEditClicked ();
00663 }
00664 
00665 
00666 // They pressed the 'Remove' button.
00667 
00668 void BugList::slotRemoveClicked()
00669 {
00670     QMessageBox     MB;
00671 
00672     // Make sure there is an entry selected and then delete.
00673     if (pMainBugList->currentItem () != NULL)
00674     {
00675         // Give them a chance to abort if the list has changed.
00676         if (MB.warning (this,
00677             i18n ("Delete Bug Report"),
00678             i18n ("When you delete a bug instead of closing\n"
00679                   "it, there will no notification sent to\n"
00680                   "the person who reported the bug or to\n"
00681                   "any relevant newsgroups.\n\n"
00682                   "Are you sure you want to do this?"),
00683             QMessageBox::Yes,QMessageBox::Cancel | QMessageBox::Default) == QMessageBox::Yes)
00684         {
00685             // Delete the current item from the list and dictionary.
00686             BugDictionary.remove (pMainBugList->currentItem ()->text (0));
00687             delete pMainBugList->currentItem ();
00688 
00689             // Let them know when they exit that changes have occured.
00690             Dirty = TRUE;
00691         }
00692     }
00693 }
00694 
00695 
00696 // They pressed the 'Completed' button. This means they want to mark this
00697 // item as being completed. In this implementation, this is the same as
00698 // pressing the delete button. I intend to expand this to send a bug
00699 // completion notification mail in a later version to the group
00700 // and the origninator.
00701 
00702 void BugList::slotCompletedClicked()
00703 {
00704     // Should perhaps check to delete first?
00705 
00706     // Make sure there is an entry selected and then delete.
00707     if (pMainBugList->currentItem () != NULL)
00708     {
00709         // Delete the current item from the list and dictionary.
00710         BugDictionary.remove (pMainBugList->currentItem ()->text (0));
00711         delete pMainBugList->currentItem ();
00712 
00713         // Let them know when they exit that changes have occured.
00714         Dirty = TRUE;
00715     }
00716 }
00717 
00718 
00719 // They pressed the 'Close' button. We should exit and update the
00720 // file if it has changed.
00721 
00722 void BugList::slotCloseClicked()
00723 {
00724     // Check to see if the file has changed.
00725     if (Dirty)
00726     {
00727         QMessageBox     MB;
00728         int             Result;
00729 
00730         Result = MB.warning (this,
00731             i18n ("The Bug List has Changed"),
00732             i18n ("The bug list has been changed.\n"
00733                   "Do you want to save your changes?"),
00734             QMessageBox::Yes | QMessageBox::Default,QMessageBox::No,QMessageBox::Cancel);
00735         if (Result == QMessageBox::Yes)
00736         {
00737             // Save the contents out to a file.
00738             WriteXMLFile ();
00739         }
00740 
00741         // They decided not to exit after all.
00742         if (Result == QMessageBox::Cancel)
00743             return;
00744     }
00745 
00746     // Shut down.
00747     close ();
00748     emit signalDeactivate ();
00749 }
00750 
00751 
00752 // They pressed the 'Cancel' button. We should exit without saving, checking
00753 // first to ensure they want to lose all changes.
00754 
00755 void BugList::slotCancelClicked()
00756 {
00757     if (Dirty)
00758     {
00759         QMessageBox     MB;
00760 
00761         // Give them a chance to abort if the list has changed.
00762         if (MB.warning (this,
00763             i18n ("The Bug List has Changed"),
00764             i18n ("The bug list has been changed.\n"
00765                   "If you exit now you will lose all your changes.\n"
00766                   "Are you sure you want to exit?"),
00767             QMessageBox::Yes,QMessageBox::Cancel | QMessageBox::Default) == QMessageBox::Cancel)
00768         {
00769             // Ignore the button press.
00770             return;
00771         }
00772     }
00773 
00774     // Shut down.
00775     close ();
00776     emit signalDeactivate ();
00777 }
00778 
00779 
00780 void BugList::resizeEvent ( QResizeEvent * QEvent)
00781 {
00782     // Resize the layout of the screen.
00783     pBugListBox->setGeometry (10, 10, this->width () - 130, this->height () - 20);
00784     pMaintenanceBox->setGeometry (this->width () - 110, 10, 100, 200);
00785     pExitBox->setGeometry (this->width () - 110, this->height () - 70, 100, 60);
00786 
00787     // Proportionally change the width of the columns in the listbox.
00788 //    BugListBox
00789 
00790     // Pass the event down to our subclass.
00791     QWidget::resizeEvent (QEvent);
00792 }
00793 
00794 
00795 void BugList::slotFilter ()
00796 {
00797 
00798 }
00799 
00800 /*  Allows the current user to take ownership of this bug, if it is not
00801     currently assigned to anyone else. */
00802 
00803 void BugList::slotOwnership ()
00804 {
00805     QMessageBox     MB;
00806     Bug *           pBug;
00807 
00808     // Make sure there is an entry selected and then delete.
00809     if (pMainBugList->currentItem () != NULL)
00810     {
00811         // Get a pointer to the entry they want to edit.
00812         pBug = BugDictionary [pMainBugList->currentItem ()->text (0)];
00813 
00814         if ((pBug->AssignedTo != m_UserName) && (pBug->AssignedTo.length () > 0))
00815         {
00816             if (MB.warning (this,
00817                 i18n ("Bug Owner Already Set"),
00818                 i18n ("The owner information for this bug\n"
00819                       "has already been set. Are you\n"
00820                       "sure you want to change it?"),
00821                 QMessageBox::Yes | QMessageBox::Default,QMessageBox::No) != QMessageBox::Yes)
00822             {
00823                 return;
00824             }
00825         }
00826 
00827         // Update the fields to our settings.
00828         pBug->AssignedTo = m_UserName;
00829         pBug->AssignedDate = QDateTime::currentDateTime ().date ();
00830         pBug->AssignedEMail = m_UserEMail;
00831 
00832         // Update the list.
00833         slotUpdateBug (pBug);
00834     }
00835 }
00836 #include "buglist.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