author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /kaddressbook/details/detailsviewcontainer.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2 |
initial public commit of qt4 portp1
Diffstat (limited to 'kaddressbook/details/detailsviewcontainer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/details/detailsviewcontainer.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/kaddressbook/details/detailsviewcontainer.cpp b/kaddressbook/details/detailsviewcontainer.cpp index cee5886..4a86aca 100644 --- a/kaddressbook/details/detailsviewcontainer.cpp +++ b/kaddressbook/details/detailsviewcontainer.cpp | |||
@@ -1,164 +1,167 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KAddressBook. | 2 | This file is part of KAddressBook. |
3 | Copyright (c) 1996-2002 Mirko Boehm <mirko@kde.org> | 3 | Copyright (c) 1996-2002 Mirko Boehm <mirko@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 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 | 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 | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 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 | 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. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <qcombobox.h> | 24 | #include <qcombobox.h> |
25 | #include <qframe.h> | 25 | #include <q3frame.h> |
26 | #include <qlabel.h> | 26 | #include <qlabel.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qwidgetstack.h> | 28 | #include <q3widgetstack.h> |
29 | //Added by qt3to4: | ||
30 | #include <Q3HBoxLayout> | ||
31 | #include <Q3VBoxLayout> | ||
29 | 32 | ||
30 | #include <kapplication.h> | 33 | #include <kapplication.h> |
31 | #include <kdebug.h> | 34 | #include <kdebug.h> |
32 | #include <kdialog.h> | 35 | #include <kdialog.h> |
33 | 36 | ||
34 | #include "look_basic.h" | 37 | #include "look_basic.h" |
35 | //#include "look_details.h" | 38 | //#include "look_details.h" |
36 | #include "look_html.h" | 39 | #include "look_html.h" |
37 | 40 | ||
38 | #ifdef KAB_EMBEDDED | 41 | #ifdef KAB_EMBEDDED |
39 | #include "kabprefs.h" | 42 | #include "kabprefs.h" |
40 | #endif //KAB_EMBEDDED | 43 | #endif //KAB_EMBEDDED |
41 | 44 | ||
42 | 45 | ||
43 | #include "detailsviewcontainer.h" | 46 | #include "detailsviewcontainer.h" |
44 | 47 | ||
45 | ViewContainer::ViewContainer( QWidget *parent, const char* name ) | 48 | ViewContainer::ViewContainer( QWidget *parent, const char* name ) |
46 | : QWidget( parent, name ), mCurrentLook( 0 ) | 49 | : QWidget( parent, name ), mCurrentLook( 0 ) |
47 | { | 50 | { |
48 | QBoxLayout *topLayout = new QVBoxLayout( this ); | 51 | Q3BoxLayout *topLayout = new Q3VBoxLayout( this ); |
49 | //topLayout->setMargin( KDialog::marginHint() ); | 52 | //topLayout->setMargin( KDialog::marginHint() ); |
50 | //topLayout->setSpacing( KDialog::spacingHint() ); | 53 | //topLayout->setSpacing( KDialog::spacingHint() ); |
51 | topLayout->setMargin( 0 ); | 54 | topLayout->setMargin( 0 ); |
52 | topLayout->setSpacing( 0 ); | 55 | topLayout->setSpacing( 0 ); |
53 | 56 | ||
54 | QBoxLayout *styleLayout = new QHBoxLayout( topLayout ); | 57 | Q3BoxLayout *styleLayout = new Q3HBoxLayout( topLayout ); |
55 | 58 | ||
56 | QLabel *label = new QLabel( i18n("Style:"), this ); | 59 | QLabel *label = new QLabel( i18n("Style:"), this ); |
57 | styleLayout->addWidget( label ); | 60 | styleLayout->addWidget( label ); |
58 | 61 | ||
59 | mStyleCombo = new QComboBox( this ); | 62 | mStyleCombo = new QComboBox( this ); |
60 | styleLayout->addWidget( mStyleCombo ); | 63 | styleLayout->addWidget( mStyleCombo ); |
61 | 64 | ||
62 | QFrame *frameRuler = new QFrame( this ); | 65 | Q3Frame *frameRuler = new Q3Frame( this ); |
63 | //US frameRuler->setFrameShape( QFrame::HLine ); | 66 | //US frameRuler->setFrameShape( QFrame::HLine ); |
64 | //US frameRuler->setFrameShadow( QFrame::Sunken ); | 67 | //US frameRuler->setFrameShadow( QFrame::Sunken ); |
65 | //US topLayout->addWidget( frameRuler ); | 68 | //US topLayout->addWidget( frameRuler ); |
66 | 69 | ||
67 | mDetailsStack = new QWidgetStack( this ); | 70 | mDetailsStack = new Q3WidgetStack( this ); |
68 | topLayout->addWidget( mDetailsStack, 1 ); | 71 | topLayout->addWidget( mDetailsStack, 1 ); |
69 | 72 | ||
70 | registerLooks(); | 73 | registerLooks(); |
71 | 74 | ||
72 | #if 1 | 75 | #if 1 |
73 | // Hide detailed view selection combo box, because we currently have | 76 | // Hide detailed view selection combo box, because we currently have |
74 | // only one. Reenable it when there are more detailed views. | 77 | // only one. Reenable it when there are more detailed views. |
75 | label->hide(); | 78 | label->hide(); |
76 | mStyleCombo->hide(); | 79 | mStyleCombo->hide(); |
77 | frameRuler->hide(); | 80 | frameRuler->hide(); |
78 | #endif | 81 | #endif |
79 | } | 82 | } |
80 | 83 | ||
81 | void ViewContainer::printView() | 84 | void ViewContainer::printView() |
82 | { | 85 | { |
83 | mCurrentLook->printView(); | 86 | mCurrentLook->printView(); |
84 | } | 87 | } |
85 | KABBasicLook *ViewContainer::currentLook() | 88 | KABBasicLook *ViewContainer::currentLook() |
86 | { | 89 | { |
87 | return mCurrentLook; | 90 | return mCurrentLook; |
88 | } | 91 | } |
89 | 92 | ||
90 | void ViewContainer::registerLooks() | 93 | void ViewContainer::registerLooks() |
91 | { | 94 | { |
92 | mLookFactories.append( new KABHtmlViewFactory( mDetailsStack ) ); | 95 | mLookFactories.append( new KABHtmlViewFactory( mDetailsStack ) ); |
93 | // mLookFactories.append( new KABDetailedViewFactory( mDetailsStack ) ); | 96 | // mLookFactories.append( new KABDetailedViewFactory( mDetailsStack ) ); |
94 | mStyleCombo->clear(); | 97 | mStyleCombo->clear(); |
95 | 98 | ||
96 | for ( uint i = 0; i < mLookFactories.count(); ++i ) | 99 | for ( uint i = 0; i < mLookFactories.count(); ++i ) |
97 | mStyleCombo->insertItem( mLookFactories.at( i )->description() ); | 100 | mStyleCombo->insertItem( mLookFactories.at( i )->description() ); |
98 | 101 | ||
99 | if ( !mLookFactories.isEmpty() ) | 102 | if ( !mLookFactories.isEmpty() ) |
100 | slotStyleSelected( 0 ); | 103 | slotStyleSelected( 0 ); |
101 | } | 104 | } |
102 | 105 | ||
103 | void ViewContainer::slotStyleSelected( int index ) | 106 | void ViewContainer::slotStyleSelected( int index ) |
104 | { | 107 | { |
105 | #ifndef KAB_EMBEDDED | 108 | #ifndef KAB_EMBEDDED |
106 | KConfig *config = kapp->config(); | 109 | KConfig *config = kapp->config(); |
107 | #else //KAB_EMBEDDED | 110 | #else //KAB_EMBEDDED |
108 | //US I hope I got the same config object as above expected. | 111 | //US I hope I got the same config object as above expected. |
109 | KConfig *config = KABPrefs::instance()->getConfig(); | 112 | KConfig *config = KABPrefs::instance()->getConfig(); |
110 | #endif //KAB_EMBEDDED | 113 | #endif //KAB_EMBEDDED |
111 | KABC::Addressee addr; | 114 | KABC::Addressee addr; |
112 | 115 | ||
113 | if ( index >= 0 && index < mStyleCombo->count() ) { | 116 | if ( index >= 0 && index < mStyleCombo->count() ) { |
114 | if ( mCurrentLook != 0 ) { | 117 | if ( mCurrentLook != 0 ) { |
115 | mCurrentLook->saveSettings( config ); | 118 | mCurrentLook->saveSettings( config ); |
116 | addr = mCurrentLook->addressee(); | 119 | addr = mCurrentLook->addressee(); |
117 | 120 | ||
118 | delete mCurrentLook; | 121 | delete mCurrentLook; |
119 | mCurrentLook = 0; | 122 | mCurrentLook = 0; |
120 | } | 123 | } |
121 | 124 | ||
122 | KABLookFactory *factory = mLookFactories.at( index ); | 125 | KABLookFactory *factory = mLookFactories.at( index ); |
123 | 126 | ||
124 | mCurrentLook = factory->create(); | 127 | mCurrentLook = factory->create(); |
125 | mDetailsStack->raiseWidget( mCurrentLook ); | 128 | mDetailsStack->raiseWidget( mCurrentLook ); |
126 | 129 | ||
127 | connect( mCurrentLook, SIGNAL( sendEmail( const QString& ) ), this, | 130 | connect( mCurrentLook, SIGNAL( sendEmail( const QString& ) ), this, |
128 | SIGNAL( sendEmail( const QString& ) ) ); | 131 | SIGNAL( sendEmail( const QString& ) ) ); |
129 | connect( mCurrentLook, SIGNAL( browse( const QString& ) ), this, | 132 | connect( mCurrentLook, SIGNAL( browse( const QString& ) ), this, |
130 | SIGNAL( browse( const QString& ) ) ); | 133 | SIGNAL( browse( const QString& ) ) ); |
131 | } | 134 | } |
132 | 135 | ||
133 | mCurrentLook->restoreSettings( config ); | 136 | mCurrentLook->restoreSettings( config ); |
134 | mCurrentLook->setAddressee( addr ); | 137 | mCurrentLook->setAddressee( addr ); |
135 | } | 138 | } |
136 | 139 | ||
137 | void ViewContainer::setAddressee( const KABC::Addressee& addressee ) | 140 | void ViewContainer::setAddressee( const KABC::Addressee& addressee ) |
138 | { | 141 | { |
139 | if ( mCurrentLook != 0 ) { | 142 | if ( mCurrentLook != 0 ) { |
140 | mCurrentAddressee = addressee; | 143 | mCurrentAddressee = addressee; |
141 | mCurrentLook->setAddressee( mCurrentAddressee ); | 144 | mCurrentLook->setAddressee( mCurrentAddressee ); |
142 | 145 | ||
143 | } | 146 | } |
144 | } | 147 | } |
145 | 148 | ||
146 | KABC::Addressee ViewContainer::addressee() | 149 | KABC::Addressee ViewContainer::addressee() |
147 | { | 150 | { |
148 | static KABC::Addressee empty; // do not use! | 151 | static KABC::Addressee empty; // do not use! |
149 | 152 | ||
150 | if ( !mCurrentLook ) | 153 | if ( !mCurrentLook ) |
151 | return empty; | 154 | return empty; |
152 | else | 155 | else |
153 | return mCurrentLook->addressee(); | 156 | return mCurrentLook->addressee(); |
154 | } | 157 | } |
155 | 158 | ||
156 | void ViewContainer::setReadOnly( bool state ) | 159 | void ViewContainer::setReadOnly( bool state ) |
157 | { | 160 | { |
158 | if ( mCurrentLook ) | 161 | if ( mCurrentLook ) |
159 | mCurrentLook->setReadOnly( state ); | 162 | mCurrentLook->setReadOnly( state ); |
160 | } | 163 | } |
161 | 164 | ||
162 | #ifndef KAB_EMBEDDED | 165 | #ifndef KAB_EMBEDDED_ |
163 | #include "detailsviewcontainer.moc" | 166 | #include "moc_detailsviewcontainer.cpp" |
164 | #endif //KAB_EMBEDDED | 167 | #endif //KAB_EMBEDDED |