1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
/* -*- C++ -*-
This file implements the dialog that is used to edit an entry.
the KDE addressbook
$ Author: Mirko Boehm $
$ Copyright: (C) 1996-2000, Mirko Boehm $
$ Contact: mirko@kde.org
http://www.kde.org $
$ License: GPL with the following explicit clarification:
This code may be linked against any version of the Qt toolkit
from Troll Tech, Norway. $
$Revision: 1.15 $
*/
#ifndef DIALOG_EDIT_ENTRY_H
#define DIALOG_EDIT_ENTRY_H
#include <kdialogbase.h>
#include <klocale.h>
#include "look_edit.h"
#include "kab_topwidget.h"
#include "kab_mainwidget.h"
#include <kdebug.h>
void TopLevelWidget::editEntrySlot()
{
editCurrentEntry();
}
bool TopLevelWidget::editCurrentEntry()
{
// it must be ensured that all other changes are committed to the database
// before calling this method since it uses the entry as it is found into
// the database
AddressBook::Entry entry;
// WORK_TO_DO: handle size
// ----- get the entry from the view:
mainwidget->getView()->getEntry(entry);
if(editEntry(entry))
{
emit(setStatus(i18n("Accepted.")));
mainwidget->getView()->setEntry(entry);
if(api->addressbook()->change(*current, entry)!=AddressBook::NoError)
{
emit(setStatus(i18n("Error changing the entry.")));
} else {
save();
}
updateGUI();
return true;
} else {
emit(setStatus(i18n("Rejected.")));
return false;
}
}
bool TopLevelWidget::editEntry(AddressBook::Entry& entry)
{
// ----- create a KDialogBase dialog containing a KABEditLook widget:
KDialogBase dialog(this);
KABEditLook *look=new KABEditLook(api, &dialog);
look->setMinimumSize(look->minimumSizeHint());
dialog.showButtonApply(false);
dialog.enableButtonSeparator(true);
dialog.setMainWidget(look);
dialog.setCaption(i18n("Edit entry"));
// ----- display the editing dialog:
look->setEntry(entry);
if(dialog.exec())
{
emit(setStatus(i18n("Accepted.")));
look->getEntry(entry);
return true;
} else {
emit(setStatus(i18n("Rejected.")));
return false;
}
}
#endif // DIALOG_EDIT_ENTRY_H
|