libkcal

calselectdialog.cpp
Go to the documentation of this file.
1 /*
2  This file is part of libkcal.
3 
4  Copyright (c) 2008 Kevin Ottens <ervin@kde.org>
5  Copyright (c) 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.net>
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License as published by the Free Software Foundation; either
10  version 2 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to
19  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA.
21 
22  In addition, as a special exception, the copyright holders give
23  permission to link the code of this program with any edition of
24  the TQt library by Trolltech AS, Norway (or with modified versions
25  of TQt that use the same license as TQt), and distribute linked
26  combinations including the two. You must obey the GNU General
27  Public License in all respects for all of the code used other than
28  TQt. If you modify this file, you may extend this exception to
29  your version of the file, but you are not obligated to do so. If
30  you do not wish to do so, delete this exception statement from
31  your version.
32 */
45 #include "calselectdialog.h"
46 
47 #include <tqlabel.h>
48 #include <tqlayout.h>
49 
50 using namespace KCal;
51 
52 CalSelectDialog::CalSelectDialog( const TQString &caption, const TQString &label,
53  const TQStringList &list )
54  : KDialogBase( 0, 0, true, caption, Ok|Cancel, Ok, true )
55 {
56  TQFrame *frame = makeMainWidget();
57  TQVBoxLayout *layout = new TQVBoxLayout( frame, 0, spacingHint() );
58 
59  TQLabel *labelWidget = new TQLabel( label, frame );
60  layout->addWidget( labelWidget );
61 
62  mListBox = new TDEListBox( frame );
63  mListBox->insertStringList( list );
64  mListBox->setSelected( 0, true );
65  mListBox->ensureCurrentVisible();
66  layout->addWidget( mListBox, 10 );
67 
68  connect( mListBox, TQ_SIGNAL(doubleClicked(TQListBoxItem *)),
69  TQ_SLOT(slotOk()) );
70  connect( mListBox, TQ_SIGNAL(returnPressed(TQListBoxItem *)),
71  TQ_SLOT(slotOk()) );
72 
73  mListBox->setFocus();
74 
75  layout->addStretch();
76 
77  setMinimumWidth( 320 );
78 }
79 
80 TQString CalSelectDialog::getItem( const TQString &caption, const TQString &label,
81  const TQStringList &list )
82 {
83  CalSelectDialog dlg( caption, label, list );
84 
85  TQString result;
86  if ( dlg.exec() == Accepted ) {
87  result = dlg.mListBox->currentText();
88  }
89 
90  return result;
91 }
92 
93 void CalSelectDialog::closeEvent( TQCloseEvent *event )
94 {
95  event->ignore();
96 }
97 
98 void CalSelectDialog::reject()
99 {
100 }
101 
This file is part of the API for handling calendar data and provides a dialog for asking the user to ...
Namespace KCal is for global classes, objects and/or functions in libkcal.
Definition: alarm.h:38