Diffstat (limited to 'kaddressbook/addviewdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/addviewdialog.cpp | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/kaddressbook/addviewdialog.cpp b/kaddressbook/addviewdialog.cpp new file mode 100644 index 0000000..6def26b --- a/dev/null +++ b/kaddressbook/addviewdialog.cpp | |||
@@ -0,0 +1,118 @@ | |||
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 | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
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 | |||
24 | #ifndef KAB_EMBEDDED | ||
25 | #endif //KAB_EMBEDDED | ||
26 | |||
27 | #include <qradiobutton.h> | ||
28 | #include <qbuttongroup.h> | ||
29 | #include <qlabel.h> | ||
30 | #include <qlineedit.h> | ||
31 | #include <qlayout.h> | ||
32 | |||
33 | #include <klocale.h> | ||
34 | #include <kglobal.h> | ||
35 | #include "kaddressbookview.h" | ||
36 | #include "addviewdialog.h" | ||
37 | |||
38 | AddViewDialog::AddViewDialog( QDict<ViewFactory> *viewFactoryDict, | ||
39 | QWidget *parent, const char *name ) | ||
40 | : KDialogBase( KDialogBase::Plain, i18n( "Add View" ), | ||
41 | KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, | ||
42 | parent, name ), | ||
43 | mViewFactoryDict( viewFactoryDict ) | ||
44 | { | ||
45 | //US setMinimumSize( KMIN(KGlobal::getDesktopWidth(), 300), KMIN(KGlobal::getDesktopHeight(), 300)); | ||
46 | |||
47 | mTypeId = 0; | ||
48 | |||
49 | QWidget *page = plainPage(); | ||
50 | |||
51 | QGridLayout *layout = new QGridLayout( page, 2, 2 ); | ||
52 | layout->setSpacing( spacingHint() ); | ||
53 | layout->setRowStretch( 1, 1 ); | ||
54 | layout->setColStretch( 1, 1 ); | ||
55 | |||
56 | QLabel *label = new QLabel( i18n( "View name:" ), page ); | ||
57 | layout->addWidget( label, 0, 0 ); | ||
58 | |||
59 | mViewNameEdit = new QLineEdit( page ); | ||
60 | connect( mViewNameEdit, SIGNAL( textChanged( const QString& ) ), | ||
61 | SLOT( textChanged( const QString& ) ) ); | ||
62 | layout->addWidget( mViewNameEdit, 0, 1 ); | ||
63 | |||
64 | mTypeGroup = new QButtonGroup( 2, Qt::Horizontal, i18n( "View Type" ), page ); | ||
65 | connect( mTypeGroup, SIGNAL( clicked( int ) ), this, SLOT( clicked( int ) ) ); | ||
66 | layout->addMultiCellWidget( mTypeGroup, 1, 1, 0, 1 ); | ||
67 | |||
68 | // Now create the radio buttons. This needs some layout work. | ||
69 | QDictIterator<ViewFactory> iter( *mViewFactoryDict ); | ||
70 | for ( iter.toFirst(); iter.current(); ++iter ) { | ||
71 | //US i am not quit sure, why I can nopt use (*iter)-> here | ||
72 | //US new QRadioButton( (*iter)->type(), mTypeGroup ); | ||
73 | //US label = new QLabel( (*iter)->description(), mTypeGroup ); | ||
74 | #ifdef DESKTOP_VERSION | ||
75 | new QRadioButton( (*iter)->type(), mTypeGroup ); | ||
76 | label = new QLabel( (*iter)->description(), mTypeGroup ); | ||
77 | #else | ||
78 | new QRadioButton( (*iter).type(), mTypeGroup ); | ||
79 | label = new QLabel( (*iter).description(), mTypeGroup ); | ||
80 | |||
81 | #endif | ||
82 | label->setAlignment( Qt::AlignLeft | Qt::AlignTop | Qt::WordBreak ); | ||
83 | } | ||
84 | |||
85 | mTypeGroup->setButton( 0 ); | ||
86 | mViewNameEdit->setFocus(); | ||
87 | enableButton( KDialogBase::Ok, false ); | ||
88 | |||
89 | |||
90 | } | ||
91 | |||
92 | AddViewDialog::~AddViewDialog() | ||
93 | { | ||
94 | } | ||
95 | |||
96 | QString AddViewDialog::viewName()const | ||
97 | { | ||
98 | return mViewNameEdit->text(); | ||
99 | } | ||
100 | |||
101 | QString AddViewDialog::viewType()const | ||
102 | { | ||
103 | return mTypeGroup->find( mTypeId )->text(); | ||
104 | } | ||
105 | |||
106 | void AddViewDialog::clicked( int id ) | ||
107 | { | ||
108 | mTypeId = id; | ||
109 | } | ||
110 | |||
111 | void AddViewDialog::textChanged( const QString &text ) | ||
112 | { | ||
113 | enableButton( KDialogBase::Ok, !text.isEmpty() ); | ||
114 | } | ||
115 | |||
116 | #ifndef KAB_EMBEDDED | ||
117 | #include "addviewdialog.moc" | ||
118 | #endif //KAB_EMBEDDED | ||