pastedialog.cpp
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2005 David Faure <faure@kde.org> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License version 2 as published by the Free Software Foundation. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 along with this library; see the file COPYING.LIB. If not, write to 00015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00016 Boston, MA 02110-1301, USA. 00017 */ 00018 00019 #include "pastedialog.h" 00020 00021 #include <klineedit.h> 00022 #include <kmimetype.h> 00023 #include <klocale.h> 00024 00025 #include <qlayout.h> 00026 #include <qlabel.h> 00027 #include <qcombobox.h> 00028 #include <qapplication.h> 00029 #include <qclipboard.h> 00030 00031 KIO::PasteDialog::PasteDialog( const QString &caption, const QString &label, 00032 const QString &value, const QStringList& items, 00033 QWidget *parent, 00034 bool clipboard ) 00035 : KDialogBase( parent, 0 /*name*/, true, caption, Ok|Cancel, Ok, true ) 00036 { 00037 QFrame *frame = makeMainWidget(); 00038 QVBoxLayout *layout = new QVBoxLayout( frame, 0, spacingHint() ); 00039 00040 m_label = new QLabel( label, frame ); 00041 layout->addWidget( m_label ); 00042 00043 m_lineEdit = new KLineEdit( value, frame ); 00044 layout->addWidget( m_lineEdit ); 00045 00046 m_lineEdit->setFocus(); 00047 m_label->setBuddy( m_lineEdit ); 00048 00049 layout->addWidget( new QLabel( i18n( "Data format:" ), frame ) ); 00050 m_comboBox = new QComboBox( frame ); 00051 m_comboBox->insertStringList( items ); 00052 layout->addWidget( m_comboBox ); 00053 00054 layout->addStretch(); 00055 00056 //connect( m_lineEdit, SIGNAL( textChanged( const QString & ) ), 00057 // SLOT( slotEditTextChanged( const QString & ) ) ); 00058 //connect( this, SIGNAL( user1Clicked() ), m_lineEdit, SLOT( clear() ) ); 00059 00060 //slotEditTextChanged( value ); 00061 setMinimumWidth( 350 ); 00062 00063 m_clipboardChanged = false; 00064 if ( clipboard ) 00065 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 00066 this, SLOT( slotClipboardDataChanged() ) ); 00067 } 00068 00069 void KIO::PasteDialog::slotClipboardDataChanged() 00070 { 00071 m_clipboardChanged = true; 00072 } 00073 00074 QString KIO::PasteDialog::lineEditText() const 00075 { 00076 return m_lineEdit->text(); 00077 } 00078 00079 int KIO::PasteDialog::comboItem() const 00080 { 00081 return m_comboBox->currentItem(); 00082 } 00083 00084 #include "pastedialog.moc"