libkcal
calselectdialog.cpp
Go to the documentation of this file.
00001 /* 00002 This file is part of libkcal. 00003 00004 Copyright (c) 2008 Kevin Ottens <ervin@kde.org> 00005 Copyright (c) 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.net> 00006 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Library General Public 00009 License as published by the Free Software Foundation; either 00010 version 2 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Library General Public License for more details. 00016 00017 You should have received a copy of the GNU Library General Public License 00018 along with this library; see the file COPYING.LIB. If not, write to 00019 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00020 Boston, MA 02110-1301, USA. 00021 00022 In addition, as a special exception, the copyright holders give 00023 permission to link the code of this program with any edition of 00024 the TQt library by Trolltech AS, Norway (or with modified versions 00025 of TQt that use the same license as TQt), and distribute linked 00026 combinations including the two. You must obey the GNU General 00027 Public License in all respects for all of the code used other than 00028 TQt. If you modify this file, you may extend this exception to 00029 your version of the file, but you are not obligated to do so. If 00030 you do not wish to do so, delete this exception statement from 00031 your version. 00032 */ 00045 #include "calselectdialog.h" 00046 00047 #include <tqlabel.h> 00048 #include <tqlayout.h> 00049 00050 using namespace KCal; 00051 00052 CalSelectDialog::CalSelectDialog( const TQString &caption, const TQString &label, 00053 const TQStringList &list ) 00054 : KDialogBase( 0, 0, true, caption, Ok|Cancel, Ok, true ) 00055 { 00056 TQFrame *frame = makeMainWidget(); 00057 TQVBoxLayout *layout = new TQVBoxLayout( frame, 0, spacingHint() ); 00058 00059 TQLabel *labelWidget = new TQLabel( label, frame ); 00060 layout->addWidget( labelWidget ); 00061 00062 mListBox = new KListBox( frame ); 00063 mListBox->insertStringList( list ); 00064 mListBox->setSelected( 0, true ); 00065 mListBox->ensureCurrentVisible(); 00066 layout->addWidget( mListBox, 10 ); 00067 00068 connect( mListBox, TQT_SIGNAL(doubleClicked(TQListBoxItem *)), 00069 TQT_SLOT(slotOk()) ); 00070 connect( mListBox, TQT_SIGNAL(returnPressed(TQListBoxItem *)), 00071 TQT_SLOT(slotOk()) ); 00072 00073 mListBox->setFocus(); 00074 00075 layout->addStretch(); 00076 00077 setMinimumWidth( 320 ); 00078 } 00079 00080 TQString CalSelectDialog::getItem( const TQString &caption, const TQString &label, 00081 const TQStringList &list ) 00082 { 00083 CalSelectDialog dlg( caption, label, list ); 00084 00085 TQString result; 00086 if ( dlg.exec() == Accepted ) { 00087 result = dlg.mListBox->currentText(); 00088 } 00089 00090 return result; 00091 } 00092 00093 void CalSelectDialog::closeEvent( TQCloseEvent *event ) 00094 { 00095 event->ignore(); 00096 } 00097 00098 void CalSelectDialog::reject() 00099 { 00100 } 00101