1.1.1
by Christopher L Cheney
Import upstream version 3.2.2 |
1 |
/*
|
2 |
This file is part of KAddressBook.
|
|
3 |
Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
|
|
4 |
||
5 |
This program is free software; you can redistribute it and/or modify
|
|
6 |
it under the terms of the GNU General Public License as published by
|
|
7 |
the Free Software Foundation; either version 2 of the License, or
|
|
8 |
(at your option) any later version.
|
|
9 |
||
10 |
This program is distributed in the hope that it will be useful,
|
|
11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
GNU General Public License for more details.
|
|
14 |
||
15 |
You should have received a copy of the GNU General Public License
|
|
16 |
along with this program; if not, write to the Free Software
|
|
1.1.4
by Jonathan Riddell
Import upstream version 3.5.0 |
17 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
1.1.1
by Christopher L Cheney
Import upstream version 3.2.2 |
18 |
|
19 |
As a special exception, permission is given to link this program
|
|
20 |
with any edition of Qt, and distribute the resulting executable,
|
|
21 |
without including the source code for Qt in the source distribution.
|
|
22 |
*/
|
|
23 |
||
1.1.32
by Steve Stalcup
Import upstream version 4.1.96 |
24 |
#include "addviewdialog.h" |
25 |
||
1.1.29
by Jonathan Riddell
Import upstream version 4.1.73 |
26 |
#include <QtGui/QButtonGroup> |
27 |
#include <QtGui/QGridLayout> |
|
28 |
#include <QtGui/QGroupBox> |
|
29 |
#include <QtGui/QLabel> |
|
30 |
#include <QtGui/QRadioButton> |
|
1.1.1
by Christopher L Cheney
Import upstream version 3.2.2 |
31 |
|
1.1.32
by Steve Stalcup
Import upstream version 4.1.96 |
32 |
#include <klocale.h> |
33 |
#include <klineedit.h> |
|
1.1.1
by Christopher L Cheney
Import upstream version 3.2.2 |
34 |
|
35 |
#include "kaddressbookview.h" |
|
36 |
||
1.1.22
by Jonathan Riddell
Import upstream version 4.0.80 |
37 |
AddViewDialog::AddViewDialog( QHash<QString, ViewFactory*> *viewFactoryDict, |
38 |
QWidget *parent ) |
|
39 |
: KDialog( parent), |
|
40 |
mViewFactoryDict( viewFactoryDict ) |
|
1.1.1
by Christopher L Cheney
Import upstream version 3.2.2 |
41 |
{
|
1.1.22
by Jonathan Riddell
Import upstream version 4.0.80 |
42 |
setCaption( i18n( "Add View" ) ); |
43 |
setButtons( KDialog::Ok | KDialog::Cancel ); |
|
44 |
setDefaultButton( KDialog::Ok ); |
|
45 |
||
1.1.1
by Christopher L Cheney
Import upstream version 3.2.2 |
46 |
mTypeId = 0; |
47 |
||
1.1.22
by Jonathan Riddell
Import upstream version 4.0.80 |
48 |
QWidget *page = new QWidget(this); |
49 |
setMainWidget( page ); |
|
1.1.1
by Christopher L Cheney
Import upstream version 3.2.2 |
50 |
|
1.1.22
by Jonathan Riddell
Import upstream version 4.0.80 |
51 |
QGridLayout *layout = new QGridLayout( page ); |
52 |
layout->setMargin( 0 ); |
|
1.1.1
by Christopher L Cheney
Import upstream version 3.2.2 |
53 |
layout->setSpacing( spacingHint() ); |
54 |
layout->setRowStretch( 1, 1 ); |
|
1.1.22
by Jonathan Riddell
Import upstream version 4.0.80 |
55 |
layout->setColumnStretch( 1, 1 ); |
1.1.1
by Christopher L Cheney
Import upstream version 3.2.2 |
56 |
|
57 |
QLabel *label = new QLabel( i18n( "View name:" ), page ); |
|
58 |
layout->addWidget( label, 0, 0 ); |
|
59 |
||
1.1.32
by Steve Stalcup
Import upstream version 4.1.96 |
60 |
mViewNameEdit = new KLineEdit( page ); |
1.1.1
by Christopher L Cheney
Import upstream version 3.2.2 |
61 |
connect( mViewNameEdit, SIGNAL( textChanged( const QString& ) ), |
62 |
SLOT( textChanged( const QString& ) ) ); |
|
63 |
layout->addWidget( mViewNameEdit, 0, 1 ); |
|
64 |
||
1.1.22
by Jonathan Riddell
Import upstream version 4.0.80 |
65 |
QGroupBox *group = new QGroupBox( i18n( "View Type" ), page ); |
66 |
mTypeGroup = new QButtonGroup; |
|
67 |
mTypeGroup->setExclusive( true ); |
|
68 |
connect( mTypeGroup, SIGNAL( buttonClicked( int ) ), |
|
69 |
this, SLOT( clicked( int ) ) ); |
|
70 |
layout->addWidget( group, 1, 0, 1, 2 ); |
|
71 |
QGridLayout *groupLayout = new QGridLayout(); |
|
72 |
groupLayout->setMargin( KDialog::marginHint() ); |
|
73 |
groupLayout->setSpacing( KDialog::spacingHint() ); |
|
74 |
group->setLayout( groupLayout ); |
|
1.1.1
by Christopher L Cheney
Import upstream version 3.2.2 |
75 |
|
1.1.2
by Jonathan Riddell
Import upstream version 3.4.0 |
76 |
int row = 0; |
1.1.22
by Jonathan Riddell
Import upstream version 4.0.80 |
77 |
QHashIterator<QString, ViewFactory*> iter( *mViewFactoryDict ); |
78 |
while ( iter.hasNext() ) { |
|
79 |
iter.next(); |
|
80 |
QRadioButton *button = new QRadioButton( i18n( iter.value()->type().toUtf8() ), |
|
81 |
group ); |
|
82 |
button->setObjectName( iter.value()->type().toLatin1() ); |
|
83 |
mTypeGroup->addButton( button, row ); |
|
84 |
label = new QLabel( iter.value()->description(), group ); |
|
85 |
label->setWordWrap( true ); |
|
1.1.2
by Jonathan Riddell
Import upstream version 3.4.0 |
86 |
|
87 |
groupLayout->addWidget( button, row, 0, Qt::AlignTop ); |
|
88 |
groupLayout->addWidget( label, row, 1, Qt::AlignTop ); |
|
89 |
||
90 |
row++; |
|
1.1.1
by Christopher L Cheney
Import upstream version 3.2.2 |
91 |
}
|
92 |
||
1.1.22
by Jonathan Riddell
Import upstream version 4.0.80 |
93 |
mTypeGroup->button( 0 )->setChecked( true ); |
1.1.1
by Christopher L Cheney
Import upstream version 3.2.2 |
94 |
mViewNameEdit->setFocus(); |
1.1.22
by Jonathan Riddell
Import upstream version 4.0.80 |
95 |
enableButton( KDialog::Ok, false ); |
1.1.1
by Christopher L Cheney
Import upstream version 3.2.2 |
96 |
}
|
97 |
||
98 |
AddViewDialog::~AddViewDialog() |
|
99 |
{
|
|
100 |
}
|
|
101 |
||
102 |
QString AddViewDialog::viewName()const |
|
103 |
{
|
|
104 |
return mViewNameEdit->text(); |
|
105 |
}
|
|
106 |
||
107 |
QString AddViewDialog::viewType()const |
|
108 |
{
|
|
109 |
// we missuse the name property for storing the type
|
|
1.1.22
by Jonathan Riddell
Import upstream version 4.0.80 |
110 |
return mTypeGroup->button( mTypeId )->objectName(); |
1.1.1
by Christopher L Cheney
Import upstream version 3.2.2 |
111 |
}
|
112 |
||
113 |
void AddViewDialog::clicked( int id ) |
|
114 |
{
|
|
115 |
mTypeId = id; |
|
116 |
}
|
|
117 |
||
118 |
void AddViewDialog::textChanged( const QString &text ) |
|
119 |
{
|
|
1.1.22
by Jonathan Riddell
Import upstream version 4.0.80 |
120 |
enableButton( KDialog::Ok, !text.isEmpty() ); |
1.1.1
by Christopher L Cheney
Import upstream version 3.2.2 |
121 |
}
|
122 |
||
123 |
#include "addviewdialog.moc" |