kpilot/kpilot

dbAppInfoEditor.cc

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 #ifdef USE_KHEXEDIT
00038 #include <khexedit/byteseditinterface.h>
00039 using namespace KHE;
00040 #endif
00041 
00042 
00043 /*************************************************
00044 **************************************************/
00045 
00046 DBAppInfoEditor::DBAppInfoEditor(char*appInfoData, int l, QWidget *parent) :
00047     KDialogBase(parent, "AppBlock Editor",false,
00048         i18n("Edit AppInfo Block"),
00049         Ok|Cancel), 
00050     appInfo(appInfoData), 
00051     len(l)
00052 {
00053 #ifdef USE_KHEXEDIT
00054     fAppInfoEdit = KHE::createBytesEditWidget( this, "fAppInfoEdit" );
00055     if( fAppInfoEdit )
00056     {
00057          // fetch the editor interface
00058         KHE::BytesEditInterface* fAppInfoEditIf = KHE::bytesEditInterface( fAppInfoEdit );
00059         Q_ASSERT( fAppInfoEditIf ); // This should not fail!
00060         if( fAppInfoEditIf )
00061         {
00062             fAppInfoEditIf->setData( (char*)appInfoData, l );
00063             fAppInfoEditIf->setMaxDataSize( l );
00064             // TODO_RK: Make the app info editable. I need to find a way 
00065             // to sync the appInfoBlock to the handheld
00066             fAppInfoEditIf->setReadOnly( true );
00067         }
00068     }
00069     else
00070     {
00071         QLabel*tmpW = new QLabel( i18n("To view the Application info block data, please install a hex editor (e.g. khexedit from kdeutils)."), this );
00072         tmpW->setBackgroundMode( Qt::PaletteMid );
00073         tmpW->setAlignment( Qt::AlignHCenter | Qt::AlignVCenter | Qt::WordBreak);
00074         tmpW->setFrameShape( QFrame::Panel );
00075         tmpW->setFrameShadow( QFrame::Sunken );
00076         fAppInfoEdit = tmpW;
00077     }
00078     setMainWidget( fAppInfoEdit );
00079 #endif
00080     fillWidgets();
00081 }
00082 
00083 
00084 DBAppInfoEditor::~DBAppInfoEditor()
00085 {
00086 }
00087 
00088 void DBAppInfoEditor::slotOk()
00089 {
00090     KMessageBox::sorry(this, i18n("Changing the AppInfo block isn't yet supported by KPilot!"));
00091 /*  if (KMessageBox::questionYesNo(this, i18n("Changing the AppInfo block "
00092         "might corrupt the whole database. \n\nReally assign the new AppInfo "
00093         "block?"), i18n("Changing AppInfo Block"), i18n("Assign"), KStdGuiItem::cancel())==KMessageBox::Yes)
00094     {
00095         // TODO: Copy the data over
00096         // TODO: set the length
00097         // (*len)=..;
00098 //#ifdef USE_KHEXEDIT
00099 //      len = fAppInfoEdit->dataSize();
00100 //      appInfo = fAppInfoEdit->data();
00101 //      // don't delete the buffer. It will be used in the database!
00102 //      fAppInfoEdit->setAutoDelete( false );
00103 //#endif
00104     }*/
00105     KDialogBase::slotOk();
00106 }
00107 
00108 void DBAppInfoEditor::fillWidgets()
00109 {
00110     // FUNCTIONSETUP
00111 }
00112 
00113 
00114 
00115 #include "dbAppInfoEditor.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys