KIO
pastedialog.cpp
Go to the documentation of this file.
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 <kcombobox.h> 00022 #include <klineedit.h> 00023 #include <klocale.h> 00024 00025 #include <QApplication> 00026 #include <QLabel> 00027 #include <QLayout> 00028 #include <QClipboard> 00029 00030 KIO::PasteDialog::PasteDialog( const QString &caption, const QString &label, 00031 const QString &value, const QStringList& items, 00032 QWidget *parent, 00033 bool clipboard ) 00034 : KDialog( parent ) 00035 { 00036 setCaption( caption ); 00037 setButtons( Ok | Cancel ); 00038 setModal( true ); 00039 setDefaultButton( Ok ); 00040 00041 QFrame *frame = new QFrame; 00042 setMainWidget( frame ); 00043 00044 QVBoxLayout *layout = new QVBoxLayout( frame ); 00045 00046 m_label = new QLabel( label, frame ); 00047 layout->addWidget( m_label ); 00048 00049 m_lineEdit = new KLineEdit( value, frame ); 00050 layout->addWidget( m_lineEdit ); 00051 00052 m_lineEdit->setFocus(); 00053 m_label->setBuddy( m_lineEdit ); 00054 00055 layout->addWidget( new QLabel( i18n( "Data format:" ), frame ) ); 00056 m_comboBox = new KComboBox( frame ); 00057 m_comboBox->addItems( items ); 00058 layout->addWidget( m_comboBox ); 00059 00060 layout->addStretch(); 00061 00062 //connect( m_lineEdit, SIGNAL( textChanged( const QString & ) ), 00063 // SLOT( slotEditTextChanged( const QString & ) ) ); 00064 //connect( this, SIGNAL( user1Clicked() ), m_lineEdit, SLOT( clear() ) ); 00065 00066 //slotEditTextChanged( value ); 00067 setMinimumWidth( 350 ); 00068 00069 m_clipboardChanged = false; 00070 if ( clipboard ) 00071 connect( QApplication::clipboard(), SIGNAL( dataChanged() ), 00072 this, SLOT( slotClipboardDataChanged() ) ); 00073 } 00074 00075 void KIO::PasteDialog::slotClipboardDataChanged() 00076 { 00077 m_clipboardChanged = true; 00078 } 00079 00080 QString KIO::PasteDialog::lineEditText() const 00081 { 00082 return m_lineEdit->text(); 00083 } 00084 00085 int KIO::PasteDialog::comboItem() const 00086 { 00087 return m_comboBox->currentIndex(); 00088 } 00089 00090 #include "pastedialog.moc"
KDE 4.6 API Reference