kpilot

dbAppInfoEditor.cc

Go to the documentation of this file.
00001 /* dbRecordEditor.cc                KPilot
00002 **
00003 ** Copyright (C) 2003 Reinhold Kainhofer <reinhold@kainhofer.com>
00004 **
00005 **/
00006 
00007 /*
00008 ** This program is free software; you can redistribute it and/or modify
00009 ** it under the terms of the GNU General Public License as published by
00010 ** the Free Software Foundation; either version 2 of the License, or
00011 ** (at your option) any later version.
00012 **
00013 ** This program is distributed in the hope that it will be useful,
00014 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016 ** GNU General Public License for more details.
00017 **
00018 ** You should have received a copy of the GNU General Public License
00019 ** along with this program in a file called COPYING; if not, write to
00020 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00021 ** MA 02110-1301, USA.
00022 */
00023 
00024 /*
00025 ** Bug reports and questions can be sent to kde-pim@kde.org
00026 */
00027 
00028 #include "options.h"
00029 
00030 #include <qtextedit.h>
00031 #include <qlabel.h>
00032 #include <kdialogbase.h>
00033 #include <kmessagebox.h>
00034 
00035 #include "dbAppInfoEditor.h"
00036 
00037 #include <khexedit/byteseditinterface.h>
00038 using namespace KHE;
00039 
00040 
00041 /*************************************************
00042 **************************************************/
00043 
00044 DBAppInfoEditor::DBAppInfoEditor(char*appInfoData, int l, QWidget *parent) :
00045     KDialogBase(parent, "AppBlock Editor",false,
00046         i18n("Edit AppInfo Block"),
00047         Ok|Cancel), 
00048     appInfo(appInfoData), 
00049     len(l)
00050 {
00051     fAppInfoEdit = KHE::createBytesEditWidget( this, "fAppInfoEdit" );
00052     if( fAppInfoEdit )
00053     {
00054          // fetch the editor interface
00055         KHE::BytesEditInterface* fAppInfoEditIf = KHE::bytesEditInterface( fAppInfoEdit );
00056         Q_ASSERT( fAppInfoEditIf ); // This should not fail!
00057         if( fAppInfoEditIf )
00058         {
00059             fAppInfoEditIf->setData( (char*)appInfoData, l );
00060             fAppInfoEditIf->setMaxDataSize( l );
00061             // TODO_RK: Make the app info editable. I need to find a way 
00062             // to sync the appInfoBlock to the handheld
00063             fAppInfoEditIf->setReadOnly( true );
00064         }
00065     }
00066     else
00067     {
00068         QLabel*tmpW = new QLabel( i18n("To view the Application info block data, please install a hex editor (e.g. khexedit from kdeutils)."), this );
00069         tmpW->setBackgroundMode( Qt::PaletteMid );
00070         tmpW->setAlignment( Qt::AlignHCenter | Qt::AlignVCenter | Qt::WordBreak);
00071         tmpW->setFrameShape( QFrame::Panel );
00072         tmpW->setFrameShadow( QFrame::Sunken );
00073         fAppInfoEdit = tmpW;
00074     }
00075     setMainWidget( fAppInfoEdit );
00076     fillWidgets();
00077 }
00078 
00079 
00080 DBAppInfoEditor::~DBAppInfoEditor()
00081 {
00082 }
00083 
00084 void DBAppInfoEditor::slotOk()
00085 {
00086     KMessageBox::sorry(this, i18n("Changing the AppInfo block isn't yet supported by KPilot!"));
00087 /*  if (KMessageBox::questionYesNo(this, i18n("Changing the AppInfo block "
00088         "might corrupt the whole database. \n\nReally assign the new AppInfo "
00089         "block?"), i18n("Changing AppInfo Block"), i18n("Assign"), KStdGuiItem::cancel())==KMessageBox::Yes)
00090     {
00091         // TODO: Copy the data over
00092         // TODO: set the length
00093         // (*len)=..;
00094     }*/
00095     KDialogBase::slotOk();
00096 }
00097 
00098 void DBAppInfoEditor::fillWidgets()
00099 {
00100     // FUNCTIONSETUP
00101 }
00102 
00103 
00104 
00105 #include "dbAppInfoEditor.moc"