KDevelop API Documentation

bugedit.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                           bugedit.cpp  -  description
00003                              -------------------
00004     begin                : Mon Nov 13 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 "bugedit.h"
00019 #include <qmessagebox.h>
00020 #include <qpushbutton.h>
00021 #include <qlabel.h>
00022 #include <qwhatsthis.h>
00023 #include <qtabbar.h>
00024 #include <klocale.h>
00025 
00026 
00027 // Strings used for the severity of the bug.
00028 // Make this international when I figure out how.
00029 // Might even read this from the XML file in time.
00030 
00031 const char * severity_desc [] =
00032 {
00033     "critical",
00034     "grave",
00035     "crash",
00036     "normal",
00037     "low",
00038     "wishlist",
00039     0
00040 };
00041 
00042 
00043 // Strings used for the priority of the bug.
00044 // Make this international when I figure out how.
00045 // Might even read this from the XML file in time.
00046 
00047 const char * priority_desc [] =
00048 {
00049     "critical",
00050     "high",
00051     "normal",
00052     "low",
00053     0
00054 };
00055 
00056 
00057 // Convert a date to a string for editing. This is not properly internationalised, sorry guys.
00058 // I haven't got a grip on the best way to handle localisation yet :)
00059 
00060 const QString BugEdit::DateToQString (QDate InputDate)
00061 {
00062     QString     OutputString;
00063 
00064     OutputString.sprintf ("%02i/%02i/%04i", InputDate.day (), InputDate.month (), InputDate.year ());
00065 
00066     return OutputString;
00067 }
00068 
00069 
00070 // Convert a QString to a date - again, this is not localised. Sorry, coming soonish :)
00071 
00072 const QDate BugEdit::QStringToDate (QString InputString)
00073 {
00074     QDate   OutputDate;
00075     int     FirstSlash;
00076     int     LastSlash;
00077     int     Day;
00078     int     Month;
00079     int     Year;
00080 
00081     // Avoid empty strings.
00082     if (InputString.length () > 0)
00083     {
00084         // Work out the position of the delimiters.
00085         FirstSlash = InputString.find ('/');
00086         LastSlash = InputString.findRev ('/');
00087 
00088         // Date is read from file in format dd/mm/yyyy
00089         Day = InputString.left (FirstSlash).toInt ();
00090         Month = InputString.mid (FirstSlash + 1, LastSlash - FirstSlash - 1).toInt ();
00091         Year = InputString.right (InputString.length () - LastSlash - 1).toInt ();
00092 
00093         // Handle those damn two digit dates.
00094         if (Year < 100)
00095         {
00096             // Basic, cheap-ass, date windowing system.
00097             if (Year < 70)
00098                 Year += 2000;
00099             else
00100                 Year += 1900;
00101         }
00102 
00103         // Attempt to get a sensible date.
00104         OutputDate.setYMD (Year, Month, Day);
00105     }
00106 
00107     return OutputDate;
00108 }
00109 
00110 BugEdit::BugEdit (QWidget * parent, const char * name, Bug * pBug, bool AddItem, bool modal, WFlags f)
00111 : QTabDialog (parent, name, modal)
00112 {
00113     int     Count;
00114 
00115     // Let them know what we are doing.
00116     setCaption (i18n ("Add/Edit Bug Record"));
00117 
00118     // Remember which bug we are meant to edit.
00119     m_pBug = pBug;
00120     m_AddItem = AddItem;
00121 
00122     // Create the tab sheets.
00123     pSheetGeneral = new QHBox (this,"shtGeneral");
00124     pSheetNotes = new QHBox (this,"shtNotes");
00125     pSheetRepeat = new QHBox (this,"shtRepeat");
00126     pSheetWorkaround = new QHBox (this,"shtWorkaround");
00127     pSheetSysInfo = new QHBox (this,"shtSysInfo");
00128 
00129     // Place a grid on the frame.
00130     GeneralLayout = new QGrid (2,pSheetGeneral, "gridGeneral");
00131     GeneralLayout->setMargin (10);
00132     GeneralLayout->setSpacing (4);
00133 
00134     // Add in our tabs.
00135     addTab (pSheetGeneral,"General");
00136     addTab (pSheetNotes,"Notes");
00137     addTab (pSheetRepeat,"Repeat");
00138     addTab (pSheetWorkaround,"Workaround");
00139     addTab (pSheetSysInfo,"SysInfo");
00140 
00141     // LABEL: BugID
00142     QLabel *lblBugID = new QLabel (i18n ("Bug ID:"),GeneralLayout);
00143 
00144     // LINEEDIT: BugID
00145     editBugID = new QLineEdit(GeneralLayout);
00146     lblBugID->setBuddy (editBugID);
00147     editBugID->setGeometry (10,10,80,20);
00148     editBugID->setText (pBug->BugID);
00149     QWhatsThis::add (editBugID,
00150         i18n("This is used to uniquely identify the bug\n"
00151               "across the lifespan of its existence."));
00152 
00153     // LABEL: Description
00154     QLabel *lblDescription = new QLabel (i18n ("Description:"),GeneralLayout);
00155 
00156     // LINEEDIT: Description
00157     editDescription = new QLineEdit(GeneralLayout);
00158     lblDescription->setBuddy (editDescription);
00159     editDescription->setText (pBug->Description);
00160     QWhatsThis::add (editDescription,
00161         i18n("Enter a brief, one line,\n"
00162              "description of the bug."));
00163 
00164     // LABEL: Severity
00165     QLabel *lblSeverity = new QLabel (i18n ("Severity:"), GeneralLayout);
00166 
00167     // LINEEDIT: Severity
00168     cboSeverity = new QComboBox(false, GeneralLayout);
00169     lblSeverity->setBuddy (cboSeverity);
00170     cboSeverity->insertStrList (severity_desc);
00171     QWhatsThis::add (cboSeverity,
00172         i18n("CRITICAL:\n"
00173              "Makes unrelated software on the system (or the whole system) "
00174              "break, or causes serious data loss, or introduces a security hole on "
00175              "systems where you install the package.\n\n"
00176              "GRAVE:\n"
00177              "Makes the package in question unusable or mostly so, or causes "
00178              "data loss, or introduces a security hole allowing access to the "
00179              "accounts of users who use the package.\n\n"
00180              "CRASH:\n"
00181              "Indicates drkonqi reported bugs. These bugs have their own severity "
00182              "as they are very often duplicates or have no reported way to reproduce "
00183              "them. They have to be reviewed in any case.\n\n"
00184              "NORMAL:\n"
00185              "The default value, for normal bugs.\n\n"
00186              "LOW:\n"
00187              "Trivial feature fix which does not impact usage.\n\n"
00188              "WISHLIST:\n"
00189              "For any feature request, and also for any bugs that are very difficult "
00190              "to fix due to major design considerations."));
00191 
00192     // Select the correct list item for severity.
00193     cboSeverity->setCurrentItem (3);
00194     for (Count = 0;Count < cboSeverity->count ();Count++)
00195     {
00196         if (cboSeverity->text (Count) == pBug->Severity)
00197             cboSeverity->setCurrentItem (Count);
00198     }
00199 
00200     // LABEL: Priority
00201     QLabel *lblPriority = new QLabel (i18n ("Priority:"), GeneralLayout);
00202 
00203     // LINEEDIT: Priority
00204     cboPriority = new QComboBox(false, GeneralLayout);
00205     lblPriority->setBuddy (cboPriority);
00206     cboPriority->insertStrList (priority_desc);
00207     QWhatsThis::add (cboPriority,
00208         i18n("CRITICAL:\n"
00209              "This bug must be fixed in the near future.\n\n"
00210              "HIGH:\n"
00211              "This bug is serious, but not crippling\n"
00212              "to the system. It should be fixed at the\n"
00213              "first reasonable opportunity.\n\n"
00214              "NORMAL:\n"
00215              "The default value, for normal bugs.\n\n"
00216              "LOW:\n"
00217              "Trivial feature fix which does not impact usage.\n\n"));
00218 
00219     // Select the correct list item for severity.
00220     cboPriority->setCurrentItem (2);
00221     for (Count = 0;Count < cboPriority->count ();Count++)
00222     {
00223         if (cboPriority->text (Count) == pBug->Priority)
00224             cboPriority->setCurrentItem (Count);
00225     }
00226 
00227     // LABEL: Package
00228     QLabel *lblPackage = new QLabel (i18n ("Package:"), GeneralLayout);
00229 
00230     // LINEEDIT: Package
00231     editPackage = new QLineEdit(GeneralLayout);
00232     lblPackage->setBuddy (editPackage);
00233     editPackage->setText (pBug->Package);
00234     QWhatsThis::add (editPackage,
00235         i18n("Enter the name of the package this\n"
00236              "bug occurred in. Please do not enter\n"
00237              "the version number at this time."));
00238 
00239     // LABEL: VersionNo
00240     QLabel *lblVersionNo = new QLabel (i18n ("Version no:"), GeneralLayout);
00241 
00242     // LINEEDIT: VersionNo
00243     editVersionNo = new QLineEdit(GeneralLayout);
00244     lblVersionNo->setBuddy (editVersionNo);
00245     editVersionNo->setText (pBug->VersionNo);
00246     QWhatsThis::add (editVersionNo,
00247         i18n("Enter the version number of the package\n"
00248              "the bug is found in."));
00249 
00250     // LABEL: Class
00251     QLabel *lblBugClass = new QLabel (i18n ("Class:"), GeneralLayout);
00252 
00253     // LINEEDIT: Class
00254     editBugClass = new QLineEdit(GeneralLayout);
00255     lblBugClass->setBuddy (editBugClass);
00256     editBugClass->setText (pBug->BugClass);
00257     QWhatsThis::add (editBugClass,
00258         i18n("The class of bug."));
00259 
00260     // LABEL: Location
00261     QLabel *lblLocation = new QLabel (i18n ("Location:"), GeneralLayout);
00262 
00263     // LINEEDIT: Location
00264     editLocation = new QLineEdit(GeneralLayout);
00265     lblLocation->setBuddy (editLocation);
00266     editLocation->setText (pBug->Location);
00267     QWhatsThis::add (editLocation,
00268         i18n("Enter the location within the source code\n"
00269              "where the bug may be found (if known)."));
00270 
00271     // SPACER!!!
00272     new QWidget (GeneralLayout);
00273     new QWidget (GeneralLayout);
00274 
00275     // LABEL: ReportDate
00276     QLabel *lblReportDate = new QLabel (i18n ("Reported on:"), GeneralLayout);
00277 
00278     // LINEEDIT: ReportDate
00279     editReportDate = new QLineEdit(GeneralLayout);
00280     lblReportDate->setBuddy (editReportDate);
00281     if (pBug->ReportDate.isValid ())
00282         editReportDate->setText (DateToQString (pBug->ReportDate));
00283     QWhatsThis::add (editReportDate,
00284         i18n("Enter the date this bug was reported."));
00285 
00286     // LABEL: ReportUserName
00287     QLabel *lblReportUserName = new QLabel (i18n ("Reported by:"), GeneralLayout);
00288 
00289     // LINEEDIT: ReportUserName
00290     editReportUserName = new QLineEdit(GeneralLayout);
00291     lblReportUserName->setBuddy (editReportUserName);
00292     editReportUserName->setText (pBug->ReportUserName);
00293     QWhatsThis::add (editReportUserName,
00294         i18n("Enter the name of the person\n"
00295              "who reported this bug."));
00296 
00297     // LABEL: ReportEMail
00298     QLabel *lblReportEMail = new QLabel (i18n ("Reported by (Email):"), GeneralLayout);
00299 
00300     // LINEEDIT: ReportEMail
00301     editReportEMail = new QLineEdit(GeneralLayout);
00302     lblReportEMail->setBuddy (editReportEMail);
00303     editReportEMail->setText (pBug->ReportEMail);
00304     QWhatsThis::add (editReportEMail,
00305         i18n("Enter the email address of the\n"
00306              "person who reported this bug."));
00307 
00308     // SPACER!!!
00309     new QWidget (GeneralLayout);
00310     new QWidget (GeneralLayout);
00311 
00312     // LABEL: AssignedDate
00313     QLabel *lblAssignedDate = new QLabel (i18n ("Assigned on:"), GeneralLayout);
00314 
00315     // LINEEDIT: AssignedDate
00316     editAssignedDate = new QLineEdit(GeneralLayout);
00317     lblAssignedDate->setBuddy (editAssignedDate);
00318     if (pBug->AssignedDate.isValid ())
00319         editAssignedDate->setText (DateToQString (pBug->AssignedDate));
00320     QWhatsThis::add (editAssignedDate,
00321         i18n("Enter the date this bug was\n"
00322              "assigned to a person for repair."));
00323 
00324     // LABEL: AssignedTo
00325     QLabel *lblAssignedTo = new QLabel (i18n ("Assigned to:"), GeneralLayout);
00326 
00327     // LINEEDIT: AssignedTo
00328     editAssignedTo = new QLineEdit(GeneralLayout);
00329     lblAssignedTo->setBuddy (editAssignedTo);
00330     editAssignedTo->setText (pBug->AssignedTo);
00331     QWhatsThis::add (editAssignedTo,
00332         i18n("Enter the name of the person you\n"
00333              "wish to assign this bug to."));
00334 
00335     // LABEL: AssignedEMail
00336     QLabel *lblAssignedEMail = new QLabel (i18n ("Assigned to (Email):"), GeneralLayout);
00337 
00338     // LINEEDIT: AssignedEMail
00339     editAssignedEMail = new QLineEdit(GeneralLayout);
00340     lblAssignedEMail->setBuddy (editAssignedEMail);
00341     editAssignedEMail->setText (pBug->AssignedEMail);
00342     QWhatsThis::add (editAssignedEMail,
00343         i18n("Enter the email address of the person\n"
00344              "you wish to assign this bug to."));
00345 
00346     // SPACER!!!
00347     new QWidget (GeneralLayout);
00348     new QWidget (GeneralLayout);
00349 
00350     // LINEEDIT: Notes.
00351     editNotes = new QMultiLineEdit (pSheetNotes,"Notes");
00352     editNotes->setText (pBug->Notes);
00353     QWhatsThis::add (editNotes,
00354         i18n("Enter a full description of the\n"
00355              "nature of the bug."));
00356 
00357     // LINEEDIT: How to repeat
00358     editRepeat = new QMultiLineEdit(pSheetRepeat,"Repeat");
00359     editRepeat->setText (pBug->Repeat);
00360     QWhatsThis::add (editRepeat,
00361         i18n("Enter the method used to repeat this\n"
00362              "error, if there is one."));
00363 
00364     // LINEEDIT: Workaround
00365     editWorkaround = new QMultiLineEdit(pSheetWorkaround,"Workaround");
00366     editWorkaround->setText (pBug->Workaround);
00367     QWhatsThis::add (editWorkaround,
00368         i18n("Enter a workaround for the bug,\n"
00369              "if there is one."));
00370 
00371     // LINEEDIT: SysInfo
00372     editSysInfo = new QMultiLineEdit (pSheetSysInfo,"SysInfo");
00373     editSysInfo->setText (pBug->SysInfo);
00374     QWhatsThis::add (editSysInfo,
00375         i18n("Enter a full description of your OS, including\n"
00376              "distribution, Qt version, compilers, etc."));
00377 
00378     // Need a cancel button too.
00379     setOkButton (i18n("OK"));
00380     setCancelButton (i18n("Cancel"));
00381     
00382     // Get those main buttons hooked up.
00383     connect (this, SIGNAL(cancelButtonPressed()), this, SLOT(cancelClicked()));
00384     connect (this, SIGNAL(applyButtonPressed()), this, SLOT(closeClicked()));
00385 
00386     // Set the focus to the most likely entry to start with.
00387     editBugID->setFocus ();
00388 
00389     // Can't be dirty until we change something.
00390     Dirty = FALSE;
00391 }
00392 
00393 
00394 BugEdit::~BugEdit()
00395 {
00396 }
00397 
00398 
00399 // Updates the contents of the Bug record from the screen.
00400 
00401 void BugEdit::updateRecord()
00402 {
00403     m_pBug->BugID = editBugID->text ();
00404     m_pBug->Description = editDescription->text ();
00405     m_pBug->Severity = cboSeverity->currentText ();
00406     m_pBug->Priority = cboPriority->currentText ();
00407     m_pBug->BugClass = editBugClass->text ();
00408     m_pBug->Location = editLocation->text ();
00409     m_pBug->AssignedTo = editAssignedTo->text ();
00410     m_pBug->AssignedEMail = editAssignedEMail->text ();
00411     m_pBug->ReportUserName = editReportUserName->text ();
00412     m_pBug->ReportEMail = editReportEMail->text ();
00413     m_pBug->Package = editPackage->text ();
00414     m_pBug->VersionNo = editVersionNo->text ();
00415     m_pBug->Notes = editNotes->text ();
00416     m_pBug->Repeat = editRepeat->text ();
00417     m_pBug->Workaround = editWorkaround->text ();
00418     m_pBug->SysInfo = editSysInfo->text ();
00419 
00420     m_pBug->AssignedDate = QStringToDate (editAssignedDate->text ());
00421     m_pBug->ReportDate = QStringToDate (editReportDate->text ());
00422 }
00423 
00424 
00425 // They pressed the 'Close' button. We should exit and update the
00426 // file if it has changed.
00427 
00428 void BugEdit::closeClicked()
00429 {
00430     // Check to see if the file has changed.
00431 //    if (Dirty)
00432     {
00433         // Write out the changed record.
00434         updateRecord ();
00435 
00436         // Get the buglist to add/update as needed.
00437         if (m_AddItem)
00438             emit sigAddBug (m_pBug);
00439         else
00440             emit sigUpdateBug (m_pBug);
00441     }
00442 
00443     // Close this widget.
00444     close ();
00445 }
00446 
00447 
00448 // They pressed the 'Cancel' button. We should exit without saving, checking
00449 // first to ensure they want to lose all changes.
00450 
00451 void BugEdit::cancelClicked()
00452 {
00453     if (Dirty)
00454     {
00455         QMessageBox     MB;
00456 
00457         // Give them a chance to abort if the list has changed.
00458         if (MB.warning (this,
00459             i18n ("Record Changed"),
00460             i18n ("The record has been changed.\n"
00461                   "If you exit now you will lose all your changes.\n"
00462                   "Are you sure you want to exit?"),
00463             QMessageBox::Yes,QMessageBox::Cancel | QMessageBox::Default) == QMessageBox::Cancel)
00464         {
00465             // Ignore the button press.
00466             return;
00467         }
00468     }
00469 
00470     // Close this widget.
00471     close ();
00472 }
00473 
00474 void BugEdit::resizeEvent (QResizeEvent * QEvent)
00475 {
00476     // Pass the event down to our subclass.
00477     QWidget::resizeEvent (QEvent);
00478 }
00479 #include "bugedit.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 Wed Mar 23 00:03:54 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003