kpilot Library API Documentation

dbFlagsEditor.cc

00001 /* dbFlagsEditor.cc KPilot 00002 ** 00003 ** Copyright (C) 2003 by Dan Pilone 00004 ** Writeen 2003 by Reinhold Kainhofer 00005 ** 00006 **/ 00007 00008 /* 00009 ** This program is free software; you can redistribute it and/or modify 00010 ** it under the terms of the GNU General Public License as published by 00011 ** the Free Software Foundation; either version 2 of the License, or 00012 ** (at your option) any later version. 00013 ** 00014 ** This program is distributed in the hope that it will be useful, 00015 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 ** GNU General Public License for more details. 00018 ** 00019 ** You should have received a copy of the GNU General Public License 00020 ** along with this program in a file called COPYING; if not, write to 00021 ** the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 00022 ** MA 02111-1307, USA. 00023 */ 00024 00025 /* 00026 ** Bug reports and questions can be sent to kde-pim@kde.org 00027 */ 00028 00029 #include "options.h" 00030 00031 #include <pi-dlp.h> 00032 00033 #include <qlineedit.h> 00034 #include <qcheckbox.h> 00035 #include <kdatewidget.h> 00036 #if KDE_IS_VERSION(3,1,90) 00037 #include <ktimewidget.h> 00038 #endif 00039 #include <kmessagebox.h> 00040 00041 #include "dbFlagsEditor.h" 00042 #include "dbFlagsEditor_base.h" 00043 00044 00045 DBFlagsEditor::DBFlagsEditor(DBInfo*dbinfo, QWidget *parent) 00046 : KDialogBase(parent, "FlagsEditor",false,i18n("Edit Database Flags"), 00047 Ok|Cancel), dbi(dbinfo) 00048 { 00049 widget=new DBFlagsEditorWidget(this); 00050 setMainWidget(widget); 00051 fillWidgets(); 00052 } 00053 00054 00055 DBFlagsEditor::~DBFlagsEditor() 00056 { 00057 } 00058 00059 void DBFlagsEditor::slotOk() 00060 { 00061 if (KMessageBox::questionYesNo(this, i18n("Changing the database flags might corrupt the whole database, or make the data unusable. Do not change the values unless you are absolutely sure you know what you are doing.\n\nReally assign these new flags?"), i18n("Changing database flags"))==KMessageBox::Yes) 00062 { 00063 strncpy(dbi->name, widget->fDBName->text().latin1(), 33); 00064 dbi->name[33]='\0'; 00065 00066 char buff[5]; 00067 strncpy(buff, widget->fType->text().latin1(), 4); 00068 dbi->type=get_long(buff); 00069 00070 strncpy(buff, widget->fCreator->text().latin1(), 4); 00071 dbi->creator=get_long(buff); 00072 00073 00074 #define setflag(ctrl, flag) if (widget->ctrl->isChecked()) dbi->flags |=flag;\ 00075 else dbi->flags &= ~flag; 00076 00077 setflag(fRessourceDB, dlpDBFlagResource); 00078 setflag(fReadOnly, dlpDBFlagReadOnly); 00079 setflag(fBackupDB, dlpDBFlagBackup); 00080 setflag(fCopyProtect, dlpDBFlagCopyPrevention); 00081 setflag(fReset, dlpDBFlagReset); 00082 #undef setflag 00083 00084 if (widget->fExcludeDB->isChecked()) 00085 dbi->miscFlags |= dlpDBMiscFlagExcludeFromSync; 00086 else dbi->miscFlags &= ~dlpDBMiscFlagExcludeFromSync; 00087 00088 QDateTime ttime; 00089 ttime.setDate(widget->fCreationDate->date()); 00090 #if KDE_VERSION > 0x30109 00091 ttime.setTime(widget->fCreationTime->time()); 00092 #endif 00093 dbi->createDate=ttime.toTime_t(); 00094 00095 ttime.setDate(widget->fModificationDate->date()); 00096 #if KDE_VERSION > 0x30109 00097 ttime.setTime(widget->fModificationTime->time()); 00098 #endif 00099 dbi->modifyDate=ttime.toTime_t(); 00100 00101 ttime.setDate(widget->fBackupDate->date()); 00102 #if KDE_VERSION > 0x30109 00103 ttime.setTime(widget->fBackupTime->time()); 00104 #endif 00105 dbi->backupDate=ttime.toTime_t(); 00106 00107 KDialogBase::slotOk(); 00108 } 00109 } 00110 00111 void DBFlagsEditor::slotCancel() 00112 { 00113 KDialogBase::slotCancel(); 00114 } 00115 00116 void DBFlagsEditor::fillWidgets() 00117 { 00118 // FUNCTIONSETUP 00119 00120 widget->fDBName->setText(dbi->name); 00121 00122 char buff[5]; 00123 set_long(buff, dbi->type); 00124 buff[4]='\0'; 00125 widget->fType->setText(buff); 00126 set_long(buff, dbi->creator); 00127 buff[4]='\0'; 00128 widget->fCreator->setText(buff); 00129 00130 widget->fRessourceDB->setChecked(dbi->flags & dlpDBFlagResource); 00131 widget->fReadOnly->setChecked(dbi->flags & dlpDBFlagReadOnly); 00132 widget->fBackupDB->setChecked(dbi->flags & dlpDBFlagBackup); 00133 widget->fCopyProtect->setChecked(dbi->flags & dlpDBFlagCopyPrevention); 00134 00135 widget->fReset->setChecked(dbi->flags & dlpDBFlagReset); 00136 widget->fExcludeDB->setChecked(dbi->miscFlags & dlpDBMiscFlagExcludeFromSync); 00137 00138 QDateTime ttime; 00139 ttime.setTime_t(dbi->createDate); 00140 widget->fCreationDate->setDate(ttime.date()); 00141 #if KDE_VERSION > 0x30109 00142 widget->fCreationTime->setTime(ttime.time()); 00143 #endif 00144 00145 ttime.setTime_t(dbi->modifyDate); 00146 widget->fModificationDate->setDate(ttime.date()); 00147 #if KDE_VERSION > 0x30109 00148 widget->fModificationTime->setTime(ttime.time()); 00149 #endif 00150 00151 ttime.setTime_t(dbi->backupDate); 00152 widget->fBackupDate->setDate(ttime.date()); 00153 #if KDE_VERSION > 0x30109 00154 widget->fBackupTime->setTime(ttime.time()); 00155 #endif 00156 } 00157 00158 00159 #include "dbFlagsEditor.moc"
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 Wed Jul 28 23:57:48 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003