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 #include "options.h"
00029
00030 #include <pi-dlp.h>
00031
00032 #include <qlineedit.h>
00033 #include <qcheckbox.h>
00034 #include <kdatewidget.h>
00035 #include <ktimewidget.h>
00036 #include <kmessagebox.h>
00037
00038 #include "pilotRecord.h"
00039 #include "dbFlagsEditor.h"
00040 #include "dbFlagsEditor_base.h"
00041
00042
00043 DBFlagsEditor::DBFlagsEditor(DBInfo*dbinfo, QWidget *parent) :
00044 KDialogBase(parent, "FlagsEditor",false,
00045 i18n("Edit Database Flags"), Ok|Cancel),
00046 dbi(dbinfo)
00047 {
00048 widget=new DBFlagsEditorWidget(this);
00049 setMainWidget(widget);
00050 fillWidgets();
00051 }
00052
00053
00054 DBFlagsEditor::~DBFlagsEditor()
00055 {
00056 }
00057
00058 void DBFlagsEditor::slotOk()
00059 {
00060 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"),i18n("Assign"),KStdGuiItem::cancel())==KMessageBox::Yes)
00061 {
00062 Pilot::toPilot(widget->fDBName->text(),dbi->name,33);
00063
00064 char buff[5];
00065 strlcpy(buff, widget->fType->text().latin1(), 5);
00066 dbi->type=get_long(buff);
00067
00068 strlcpy(buff, widget->fCreator->text().latin1(), 5);
00069 dbi->creator=get_long(buff);
00070
00071
00072 #define setflag(ctrl, flag) if (widget->ctrl->isChecked()) dbi->flags |=flag;\
00073 else dbi->flags &= ~flag;
00074
00075 setflag(fRessourceDB, dlpDBFlagResource);
00076 setflag(fReadOnly, dlpDBFlagReadOnly);
00077 setflag(fBackupDB, dlpDBFlagBackup);
00078 setflag(fCopyProtect, dlpDBFlagCopyPrevention);
00079 setflag(fReset, dlpDBFlagReset);
00080 #undef setflag
00081
00082 if (widget->fExcludeDB->isChecked())
00083 dbi->miscFlags |= dlpDBMiscFlagExcludeFromSync;
00084 else dbi->miscFlags &= ~dlpDBMiscFlagExcludeFromSync;
00085
00086 QDateTime ttime;
00087 ttime.setDate(widget->fCreationDate->date());
00088 #if KDE_IS_VERSION(3,1,9)
00089 ttime.setTime(widget->fCreationTime->time());
00090 #endif
00091 dbi->createDate=ttime.toTime_t();
00092
00093 ttime.setDate(widget->fModificationDate->date());
00094 #if KDE_IS_VERSION(3,1,9)
00095 ttime.setTime(widget->fModificationTime->time());
00096 #endif
00097 dbi->modifyDate=ttime.toTime_t();
00098
00099 ttime.setDate(widget->fBackupDate->date());
00100 #if KDE_IS_VERSION(3,1,9)
00101 ttime.setTime(widget->fBackupTime->time());
00102 #endif
00103 dbi->backupDate=ttime.toTime_t();
00104
00105 KDialogBase::slotOk();
00106 }
00107 }
00108
00109 void DBFlagsEditor::slotCancel()
00110 {
00111 KDialogBase::slotCancel();
00112 }
00113
00114 void DBFlagsEditor::fillWidgets()
00115 {
00116
00117
00118 widget->fDBName->setText(QString::fromLatin1(dbi->name));
00119
00120 char buff[5];
00121 set_long(buff, dbi->type);
00122 buff[4]='\0';
00123 widget->fType->setText(QString::fromLatin1(buff));
00124 set_long(buff, dbi->creator);
00125 buff[4]='\0';
00126 widget->fCreator->setText(QString::fromLatin1(buff));
00127
00128 widget->fRessourceDB->setChecked(dbi->flags & dlpDBFlagResource);
00129 widget->fReadOnly->setChecked(dbi->flags & dlpDBFlagReadOnly);
00130 widget->fBackupDB->setChecked(dbi->flags & dlpDBFlagBackup);
00131 widget->fCopyProtect->setChecked(dbi->flags & dlpDBFlagCopyPrevention);
00132
00133 widget->fReset->setChecked(dbi->flags & dlpDBFlagReset);
00134 widget->fExcludeDB->setChecked(dbi->miscFlags & dlpDBMiscFlagExcludeFromSync);
00135
00136 QDateTime ttime;
00137 ttime.setTime_t(dbi->createDate);
00138 widget->fCreationDate->setDate(ttime.date());
00139 #if KDE_IS_VERSION(3,1,9)
00140 widget->fCreationTime->setTime(ttime.time());
00141 #endif
00142
00143 ttime.setTime_t(dbi->modifyDate);
00144 widget->fModificationDate->setDate(ttime.date());
00145 #if KDE_IS_VERSION(3,1,9)
00146 widget->fModificationTime->setTime(ttime.time());
00147 #endif
00148
00149 ttime.setTime_t(dbi->backupDate);
00150 widget->fBackupDate->setDate(ttime.date());
00151 #if KDE_IS_VERSION(3,1,9)
00152 widget->fBackupTime->setTime(ttime.time());
00153 #endif
00154 }
00155
00156
00157 #include "dbFlagsEditor.moc"