source: trunk/tools/assistant/topicchooserimpl.cpp@ 203

Last change on this file since 203 was 191, checked in by rudi, 14 years ago

Qt Assistant added

File size: 2.2 KB
Line 
1/**********************************************************************
2** Copyright (C) 2000-2007 Trolltech ASA. All rights reserved.
3**
4** This file is part of Qt Assistant.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
12** licenses may use this file in accordance with the Qt Commercial License
13** Agreement provided with the Software.
14**
15** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17**
18** See http://www.trolltech.com/gpl/ for GPL licensing information.
19** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
20** information about Qt Commercial License Agreements.
21**
22** Contact info@trolltech.com if any conditions of this licensing are
23** not clear to you.
24**
25**********************************************************************/
26
27#include "topicchooserimpl.h"
28
29#include <qlabel.h>
30#include <qlistbox.h>
31#include <qpushbutton.h>
32
33TopicChooser::TopicChooser( QWidget *parent, const QStringList &lnkNames,
34 const QStringList &lnks, const QString &title )
35 : TopicChooserBase( parent, 0, TRUE ), links( lnks ), linkNames( lnkNames )
36{
37 label->setText( tr( "Choose a topic for <b>%1</b>" ).arg( title ) );
38 listbox->insertStringList( linkNames );
39 listbox->setCurrentItem( listbox->firstItem() );
40 listbox->setFocus();
41}
42
43QString TopicChooser::link() const
44{
45 if ( listbox->currentItem() == -1 )
46 return QString::null;
47 QString s = listbox->currentText();
48 if ( s.isEmpty() )
49 return s;
50 int i = linkNames.findIndex( s );
51 return links[ i ];
52}
53
54QString TopicChooser::getLink( QWidget *parent, const QStringList &lnkNames,
55 const QStringList &lnks, const QString &title )
56{
57 TopicChooser *dlg = new TopicChooser( parent, lnkNames, lnks, title );
58 QString lnk;
59 if ( dlg->exec() == QDialog::Accepted )
60 lnk = dlg->link();
61 delete dlg;
62 return lnk;
63}
Note: See TracBrowser for help on using the repository browser.