kpilot Library API Documentation

todoEditor.cc

00001 // -*- C++ -*-
00002 /* todoEditor.cc        KPilot
00003 **
00004 ** Copyright (C) 2000 by Dan Pilone
00005 **
00006 ** This is a dialog window that edits one single todo record.
00007 */
00008 
00009 /*
00010 ** This program is free software; you can redistribute it and/or modify
00011 ** it under the terms of the GNU General Public License as published by
00012 ** the Free Software Foundation; either version 2 of the License, or
00013 ** (at your option) any later version.
00014 **
00015 ** This program is distributed in the hope that it will be useful,
00016 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00018 ** GNU General Public License for more details.
00019 **
00020 ** You should have received a copy of the GNU General Public License
00021 ** along with this program in a file called COPYING; if not, write to
00022 ** the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00023 ** MA 02111-1307, USA.
00024 */
00025 
00026 /*
00027 ** Bug reports and questions can be sent to kde-pim@kde.org
00028 */
00029 
00030 
00031 #include "options.h"
00032 
00033 #include <qcombobox.h>
00034 #include <qlayout.h>
00035 #include <qlabel.h>
00036 #include <qtextedit.h>
00037 #include <qcheckbox.h>
00038 
00039 #include <kdatewidget.h>
00040 
00041 #include "pilotTodoEntry.h"
00042 #include "todoEditor_base.h"
00043 #include "todoEditor.moc"
00044 
00045 static const char *todoEditor_id =
00046     "$Id: todoEditor.cc,v 1.5 2003/07/27 21:26:43 kainhofe Exp $";
00047 
00048 TodoEditor::TodoEditor(PilotTodoEntry * p, struct ToDoAppInfo *appInfo,
00049     QWidget * parent, const char *name) :
00050     KDialogBase(parent, name, false, i18n("Todo Editor"), Ok|Cancel),
00051     fDeleteOnCancel(p == 0L),
00052     fTodo(p),
00053     fAppInfo(appInfo)
00054 {
00055     FUNCTIONSETUP;
00056 
00057     fWidget=new TodoEditorBase(this);
00058     setMainWidget(fWidget);
00059     fillFields();
00060 
00061     connect(parent, SIGNAL(recordChanged(PilotTodoEntry *)),
00062         this, SLOT(updateRecord(PilotTodoEntry *)));
00063 
00064     (void) todoEditor_id;
00065 }
00066 
00067 TodoEditor::~TodoEditor()
00068 {
00069     FUNCTIONSETUP;
00070 
00071     if (fDeleteOnCancel && fTodo)
00072     {
00073 #ifdef DEBUG
00074         DEBUGKPILOT << fname
00075             << ": Deleting private todo record." << endl;
00076 #endif
00077         delete fTodo;
00078         fTodo = 0L;
00079     }
00080 
00081 #ifdef DEBUG
00082     DEBUGKPILOT << fname << ": Help! I'm deleting!" << endl;
00083 #endif
00084 }
00085 
00086 
00087 
00088 void TodoEditor::fillFields()
00089 {
00090     FUNCTIONSETUP;
00091 
00092     if (fTodo == 0L)
00093     {
00094         fTodo = new PilotTodoEntry(*fAppInfo);
00095         fDeleteOnCancel = true;
00096     }
00097 
00098     fWidget->fDescription->setText(fTodo->getDescription());
00099     fWidget->fCompleted->setChecked(fTodo->getComplete());
00100     if (fTodo->getIndefinite())
00101     {
00102         fWidget->fHasEndDate->setChecked(false);
00103     }
00104     else
00105     {
00106         fWidget->fHasEndDate->setChecked(true);
00107         fWidget->fEndDate->setDate(readTm(fTodo->getDueDate()).date());
00108     }
00109     fWidget->fPriority->setCurrentItem(fTodo->getPriority());
00110 //  fCategory->setCurrentItem(fTodo->getCategory()));
00111     fWidget->fNote->setText(fTodo->getNote());
00112 }
00113 
00114 
00115 
00116 /* slot */ void TodoEditor::slotCancel()
00117 {
00118     FUNCTIONSETUP;
00119 
00120     if (fDeleteOnCancel && fTodo)
00121     {
00122         delete fTodo;
00123 
00124         fTodo = 0L;
00125     }
00126     KDialogBase::slotCancel();
00127 }
00128 
00129 /* slot */ void TodoEditor::slotOk()
00130 {
00131     FUNCTIONSETUP;
00132 
00133     // Commit changes here
00134     fTodo->setDescription(fWidget->fDescription->text());
00135     fTodo->setComplete(fWidget->fCompleted->isChecked());
00136     if (fWidget->fHasEndDate->isChecked())
00137     {
00138         fTodo->setIndefinite(false);
00139         struct tm duedate=writeTm(fWidget->fEndDate->date());
00140         fTodo->setDueDate(duedate);
00141     }
00142     else
00143     {
00144         fTodo->setIndefinite(true);
00145     }
00146     fTodo->setPriority(fWidget->fPriority->currentItem());
00147 //  fTodo->setCategory(fWidget->fCategory->currentItem());
00148     fTodo->setNote(fWidget->fNote->text());
00149 
00150     emit(recordChangeComplete(fTodo));
00151     KDialogBase::slotOk();
00152 }
00153 
00154 /* slot */ void TodoEditor::updateRecord(PilotTodoEntry * p)
00155 {
00156     FUNCTIONSETUP;
00157     if (p != fTodo)
00158     {
00159         // Not meant for me
00160         //
00161         //
00162         return;
00163     }
00164 
00165     if (p->isDeleted())
00166     {
00167         delayedDestruct();
00168         return;
00169     }
00170     else
00171     {
00172         fillFields();
00173     }
00174 }
00175 
KDE Logo
This file is part of the documentation for kpilot Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat May 1 11:36:50 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003