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
|
/* -*- C++ -*-
This file implements the method to save a file..
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.10 $
*/
#include <kmessagebox.h>
#include <klocale.h>
#include <kabapi.h>
#include "kab_topwidget.h"
#include "look_basic.h"
#include "kab_mainwidget.h"
void TopLevelWidget::save()
{
// ###########################################################################
AddressBook::Entry entry;
// ----- save the database:
AddressBook *book=api->addressbook();
if(modified)
{
// ----- put the new entry into the database:
// preload it with the old contents (just in case)
if(book->getEntry(*current, entry)!=AddressBook::NoError)
{
emit(setStatus(i18n("Internal error.")));
}
// get all values from the current view:
mainwidget->getView()->getEntry(entry);
// and store it:
switch(book->change(*current, entry))
{
case AddressBook::NoError:
emit(setStatus(i18n("Entry stored.")));
break;
case AddressBook::PermDenied:
emit(setStatus(i18n("Permission denied.")));
return;
default:
emit(setStatus(i18n("Internal error.")));
return;
}
}
if(book->save("", true)!=AddressBook::NoError)
{
KMessageBox::sorry
(this, i18n("The file could not be saved (permission denied)."),
i18n("kab: File error"));
}
// ----- finally say something and remember state:
setStatus(i18n("File saved."));
modified=false;
updateGUI(); // just in case
// ###########################################################################
}
|