dbFlagsEditor.cc
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
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
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"
This file is part of the documentation for kpilot Library Version 3.2.2.