summaryrefslogtreecommitdiffabout
path: root/kaddressbook/keywidget.cpp
Side-by-side diff
Diffstat (limited to 'kaddressbook/keywidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/keywidget.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/kaddressbook/keywidget.cpp b/kaddressbook/keywidget.cpp
index c117d34..8ebee19 100644
--- a/kaddressbook/keywidget.cpp
+++ b/kaddressbook/keywidget.cpp
@@ -15,57 +15,59 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#include <qfile.h>
#include <qinputdialog.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qpushbutton.h>
+//Added by qt3to4:
+#include <Q3GridLayout>
#ifndef KAB_EMBEDDED
#include <kaccelmanager.h>
#include <kio/netaccess.h>
#include <kmessagebox.h>
#else //KAB_EMBEDDED
#include <qmap.h>
#include <qmessagebox.h>
-#include <qtextstream.h>
+#include <q3textstream.h>
#include <kurl.h>
#endif //KAB_EMBEDDED
#include <kapplication.h>
#include <kcombobox.h>
#include <kdialog.h>
#include <kfiledialog.h>
#include <klocale.h>
#include <ktempfile.h>
#include "keywidget.h"
KeyWidget::KeyWidget( QWidget *parent, const char *name )
: QWidget( parent, name )
{
- QGridLayout *layout = new QGridLayout( this, 2, 2, KDialog::marginHint(),
+ Q3GridLayout *layout = new Q3GridLayout( this, 2, 2, KDialog::marginHint(),
KDialog::spacingHint() );
QLabel *label = new QLabel( i18n( "Keys:" ), this );
layout->addWidget( label, 0, 0 );
mKeyCombo = new KComboBox( this );
layout->addWidget( mKeyCombo, 0, 1 );
mAddButton = new QPushButton( i18n( "Add" ), this );
layout->addWidget( mAddButton, 1, 0 );
mRemoveButton = new QPushButton( i18n( "Remove" ), this );
mRemoveButton->setEnabled( false );
layout->addWidget( mRemoveButton, 1, 1 );
mExportButton = new QPushButton( i18n( "Export" ), this );
@@ -123,63 +125,63 @@ void KeyWidget::addKey()
if ( !ok || name.isEmpty() )
return;
int type = keyMap[ name ];
if ( !keyTypeNames.contains( name ) )
type = KABC::Key::Custom;
#ifndef KAB_EMBEDDED
KURL url = KFileDialog::getOpenURL();
if ( url.isEmpty() )
return;
QString tmpFile;
if ( KIO::NetAccess::download( url, tmpFile ) ) {
QFile file( tmpFile );
- if ( !file.open( IO_ReadOnly ) ) {
+ if ( !file.open( QIODevice::ReadOnly ) ) {
QString text( i18n( "<qt>Unable to open file <b>%1</b>.</qt>" ) );
KMessageBox::error( this, text.arg( url.url() ) );
return;
}
#else //KAB_EMBEDDED
QString keyfile = KFileDialog::getOpenFileName( "huhu",
"Select Key", this );
if ( keyfile.isEmpty() )
return;
{
QFile file( keyfile );
- if ( !file.open( IO_ReadOnly ) ) {
+ if ( !file.open( QIODevice::ReadOnly ) ) {
QString text( i18n( "<qt>Unable to open file <b>%1</b>.</qt>" ) );
QString caption( i18n( "Error" ) );
QMessageBox::critical( this, caption, text.arg( keyfile ) );
return;
}
#endif //KAB_EMBEDDED
- QTextStream s( &file );
+ Q3TextStream s( &file );
QString data;
- s.setEncoding( QTextStream::UnicodeUTF8 );
+ s.setEncoding( Q3TextStream::UnicodeUTF8 );
s >> data;
file.close();
KABC::Key key( data, type );
if ( type == KABC::Key::Custom )
key.setCustomTypeString( name );
mKeyList.append( key );
emit changed();
#ifndef KAB_EMBEDDED
KIO::NetAccess::removeTempFile( tmpFile );
#endif //KAB_EMBEDDED
}
@@ -208,70 +210,70 @@ void KeyWidget::removeKey()
#endif //KAB_EMBEDDED
mKeyList.remove( mKeyList.at( pos ) );
emit changed();
updateKeyCombo();
}
void KeyWidget::exportKey()
{
KABC::Key key = (*mKeyList.at( mKeyCombo->currentItem() ) );
#ifndef KAB_EMBEDDED
KURL url = KFileDialog::getSaveURL();
KTempFile tempFile;
- QTextStream *s = tempFile.textStream();
- s->setEncoding( QTextStream::UnicodeUTF8 );
+ Q3TextStream *s = tempFile.textStream();
+ s->setEncoding( Q3TextStream::UnicodeUTF8 );
(*s) << key.textData();
tempFile.close();
KIO::NetAccess::upload( tempFile.name(), url, kapp->mainWidget() );
#else //KAB_EMBEDDED
QString keyfile = KFileDialog::getSaveFileName( "huhu",
"Save Key", this );
if ( keyfile.isEmpty() )
return;
QFile file( keyfile );
- if ( !file.open( IO_ReadWrite ) ) {
+ if ( !file.open( QIODevice::ReadWrite ) ) {
QString text( i18n( "<qt>Unable to open file <b>%1</b>.</qt>" ) );
QString caption( i18n( "Error" ) );
QMessageBox::critical( this, caption, text.arg( keyfile ) );
return;
}
- QTextStream s( &file );
- s.setEncoding( QTextStream::UnicodeUTF8 );
+ Q3TextStream s( &file );
+ s.setEncoding( Q3TextStream::UnicodeUTF8 );
s << key.textData();
file.close();
#endif //KAB_EMBEDDED
}
void KeyWidget::updateKeyCombo()
{
int pos = mKeyCombo->currentItem();
mKeyCombo->clear();
KABC::Key::List::Iterator it;
for ( it = mKeyList.begin(); it != mKeyList.end(); ++it ) {
if ( (*it).type() == KABC::Key::Custom )
mKeyCombo->insertItem( (*it).customTypeString() );
else
mKeyCombo->insertItem( KABC::Key::typeLabel( (*it).type() ) );
}
mKeyCombo->setCurrentItem( pos );
bool state = ( mKeyList.count() != 0 );
mRemoveButton->setEnabled( state );
mExportButton->setEnabled( state );
}
-#ifndef KAB_EMBEDDED
-#include "keywidget.moc"
+#ifndef KAB_EMBEDDED_
+#include "moc_keywidget.cpp"
#endif //KAB_EMBEDDED