-rw-r--r-- | kaddressbook/details/detailsviewcontainer.cpp | 11 | ||||
-rw-r--r-- | kaddressbook/details/detailsviewcontainer.h | 1 |
2 files changed, 1 insertions, 11 deletions
diff --git a/kaddressbook/details/detailsviewcontainer.cpp b/kaddressbook/details/detailsviewcontainer.cpp index ceffc77..229cce0 100644 --- a/kaddressbook/details/detailsviewcontainer.cpp +++ b/kaddressbook/details/detailsviewcontainer.cpp | |||
@@ -1,169 +1,160 @@ | |||
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 <qframe.h> |
26 | #include <qlabel.h> | 26 | #include <qlabel.h> |
27 | #include <qlayout.h> | 27 | #include <qlayout.h> |
28 | #include <qwidgetstack.h> | 28 | #include <qwidgetstack.h> |
29 | 29 | ||
30 | #include <kapplication.h> | 30 | #include <kapplication.h> |
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <kdialog.h> | 32 | #include <kdialog.h> |
33 | 33 | ||
34 | #include "look_basic.h" | 34 | #include "look_basic.h" |
35 | //#include "look_details.h" | 35 | //#include "look_details.h" |
36 | #include "look_html.h" | 36 | #include "look_html.h" |
37 | 37 | ||
38 | #ifdef KAB_EMBEDDED | 38 | #ifdef KAB_EMBEDDED |
39 | #include "kabprefs.h" | 39 | #include "kabprefs.h" |
40 | #endif //KAB_EMBEDDED | 40 | #endif //KAB_EMBEDDED |
41 | 41 | ||
42 | 42 | ||
43 | #include "detailsviewcontainer.h" | 43 | #include "detailsviewcontainer.h" |
44 | 44 | ||
45 | ViewContainer::ViewContainer( QWidget *parent, const char* name ) | 45 | ViewContainer::ViewContainer( QWidget *parent, const char* name ) |
46 | : QWidget( parent, name ), mCurrentLook( 0 ) | 46 | : QWidget( parent, name ), mCurrentLook( 0 ) |
47 | { | 47 | { |
48 | QBoxLayout *topLayout = new QVBoxLayout( this ); | 48 | QBoxLayout *topLayout = new QVBoxLayout( this ); |
49 | //topLayout->setMargin( KDialog::marginHint() ); | 49 | //topLayout->setMargin( KDialog::marginHint() ); |
50 | //topLayout->setSpacing( KDialog::spacingHint() ); | 50 | //topLayout->setSpacing( KDialog::spacingHint() ); |
51 | topLayout->setMargin( 0 ); | 51 | topLayout->setMargin( 0 ); |
52 | topLayout->setSpacing( 0 ); | 52 | topLayout->setSpacing( 0 ); |
53 | 53 | ||
54 | QBoxLayout *styleLayout = new QHBoxLayout( topLayout ); | 54 | QBoxLayout *styleLayout = new QHBoxLayout( topLayout ); |
55 | 55 | ||
56 | QLabel *label = new QLabel( i18n("Style:"), this ); | 56 | QLabel *label = new QLabel( i18n("Style:"), this ); |
57 | styleLayout->addWidget( label ); | 57 | styleLayout->addWidget( label ); |
58 | 58 | ||
59 | mStyleCombo = new QComboBox( this ); | 59 | mStyleCombo = new QComboBox( this ); |
60 | styleLayout->addWidget( mStyleCombo ); | 60 | styleLayout->addWidget( mStyleCombo ); |
61 | 61 | ||
62 | QFrame *frameRuler = new QFrame( this ); | 62 | QFrame *frameRuler = new QFrame( this ); |
63 | //US frameRuler->setFrameShape( QFrame::HLine ); | 63 | //US frameRuler->setFrameShape( QFrame::HLine ); |
64 | //US frameRuler->setFrameShadow( QFrame::Sunken ); | 64 | //US frameRuler->setFrameShadow( QFrame::Sunken ); |
65 | //US topLayout->addWidget( frameRuler ); | 65 | //US topLayout->addWidget( frameRuler ); |
66 | 66 | ||
67 | mDetailsStack = new QWidgetStack( this ); | 67 | mDetailsStack = new QWidgetStack( this ); |
68 | topLayout->addWidget( mDetailsStack, 1 ); | 68 | topLayout->addWidget( mDetailsStack, 1 ); |
69 | 69 | ||
70 | registerLooks(); | 70 | registerLooks(); |
71 | 71 | ||
72 | #if 1 | 72 | #if 1 |
73 | // Hide detailed view selection combo box, because we currently have | 73 | // Hide detailed view selection combo box, because we currently have |
74 | // only one. Reenable it when there are more detailed views. | 74 | // only one. Reenable it when there are more detailed views. |
75 | label->hide(); | 75 | label->hide(); |
76 | mStyleCombo->hide(); | 76 | mStyleCombo->hide(); |
77 | frameRuler->hide(); | 77 | frameRuler->hide(); |
78 | #endif | 78 | #endif |
79 | } | 79 | } |
80 | 80 | ||
81 | KABBasicLook *ViewContainer::currentLook() | 81 | KABBasicLook *ViewContainer::currentLook() |
82 | { | 82 | { |
83 | return mCurrentLook; | 83 | return mCurrentLook; |
84 | } | 84 | } |
85 | 85 | ||
86 | void ViewContainer::registerLooks() | 86 | void ViewContainer::registerLooks() |
87 | { | 87 | { |
88 | mLookFactories.append( new KABHtmlViewFactory( mDetailsStack ) ); | 88 | mLookFactories.append( new KABHtmlViewFactory( mDetailsStack ) ); |
89 | // mLookFactories.append( new KABDetailedViewFactory( mDetailsStack ) ); | 89 | // mLookFactories.append( new KABDetailedViewFactory( mDetailsStack ) ); |
90 | mStyleCombo->clear(); | 90 | mStyleCombo->clear(); |
91 | 91 | ||
92 | for ( uint i = 0; i < mLookFactories.count(); ++i ) | 92 | for ( uint i = 0; i < mLookFactories.count(); ++i ) |
93 | mStyleCombo->insertItem( mLookFactories.at( i )->description() ); | 93 | mStyleCombo->insertItem( mLookFactories.at( i )->description() ); |
94 | 94 | ||
95 | if ( !mLookFactories.isEmpty() ) | 95 | if ( !mLookFactories.isEmpty() ) |
96 | slotStyleSelected( 0 ); | 96 | slotStyleSelected( 0 ); |
97 | } | 97 | } |
98 | 98 | ||
99 | void ViewContainer::slotStyleSelected( int index ) | 99 | void ViewContainer::slotStyleSelected( int index ) |
100 | { | 100 | { |
101 | #ifndef KAB_EMBEDDED | 101 | #ifndef KAB_EMBEDDED |
102 | KConfig *config = kapp->config(); | 102 | KConfig *config = kapp->config(); |
103 | #else //KAB_EMBEDDED | 103 | #else //KAB_EMBEDDED |
104 | //US I hope I got the same config object as above expected. | 104 | //US I hope I got the same config object as above expected. |
105 | KConfig *config = KABPrefs::instance()->getConfig(); | 105 | KConfig *config = KABPrefs::instance()->getConfig(); |
106 | #endif //KAB_EMBEDDED | 106 | #endif //KAB_EMBEDDED |
107 | KABC::Addressee addr; | 107 | KABC::Addressee addr; |
108 | 108 | ||
109 | if ( index >= 0 && index < mStyleCombo->count() ) { | 109 | if ( index >= 0 && index < mStyleCombo->count() ) { |
110 | if ( mCurrentLook != 0 ) { | 110 | if ( mCurrentLook != 0 ) { |
111 | mCurrentLook->saveSettings( config ); | 111 | mCurrentLook->saveSettings( config ); |
112 | addr = mCurrentLook->addressee(); | 112 | addr = mCurrentLook->addressee(); |
113 | 113 | ||
114 | delete mCurrentLook; | 114 | delete mCurrentLook; |
115 | mCurrentLook = 0; | 115 | mCurrentLook = 0; |
116 | } | 116 | } |
117 | 117 | ||
118 | KABLookFactory *factory = mLookFactories.at( index ); | 118 | KABLookFactory *factory = mLookFactories.at( index ); |
119 | 119 | ||
120 | mCurrentLook = factory->create(); | 120 | mCurrentLook = factory->create(); |
121 | mDetailsStack->raiseWidget( mCurrentLook ); | 121 | mDetailsStack->raiseWidget( mCurrentLook ); |
122 | 122 | ||
123 | connect( mCurrentLook, SIGNAL( sendEmail( const QString& ) ), this, | 123 | connect( mCurrentLook, SIGNAL( sendEmail( const QString& ) ), this, |
124 | SIGNAL( sendEmail( const QString& ) ) ); | 124 | SIGNAL( sendEmail( const QString& ) ) ); |
125 | connect( mCurrentLook, SIGNAL( browse( const QString& ) ), this, | 125 | connect( mCurrentLook, SIGNAL( browse( const QString& ) ), this, |
126 | SIGNAL( browse( const QString& ) ) ); | 126 | SIGNAL( browse( const QString& ) ) ); |
127 | } | 127 | } |
128 | 128 | ||
129 | mCurrentLook->restoreSettings( config ); | 129 | mCurrentLook->restoreSettings( config ); |
130 | mCurrentLook->setAddressee( addr ); | 130 | mCurrentLook->setAddressee( addr ); |
131 | } | 131 | } |
132 | void ViewContainer::refreshView() | ||
133 | { | ||
134 | if ( mCurrentLook ) { | ||
135 | mCurrentLook->setAddressee( mCurrentAddressee ); | ||
136 | } | ||
137 | } | ||
138 | 132 | ||
139 | void ViewContainer::setAddressee( const KABC::Addressee& addressee ) | 133 | void ViewContainer::setAddressee( const KABC::Addressee& addressee ) |
140 | { | 134 | { |
141 | if ( mCurrentLook != 0 ) { | 135 | if ( mCurrentLook != 0 ) { |
142 | if ( addressee == mCurrentAddressee ) | ||
143 | return; | ||
144 | else { | ||
145 | mCurrentAddressee = addressee; | 136 | mCurrentAddressee = addressee; |
146 | mCurrentLook->setAddressee( mCurrentAddressee ); | 137 | mCurrentLook->setAddressee( mCurrentAddressee ); |
147 | } | 138 | |
148 | } | 139 | } |
149 | } | 140 | } |
150 | 141 | ||
151 | KABC::Addressee ViewContainer::addressee() | 142 | KABC::Addressee ViewContainer::addressee() |
152 | { | 143 | { |
153 | static KABC::Addressee empty; // do not use! | 144 | static KABC::Addressee empty; // do not use! |
154 | 145 | ||
155 | if ( !mCurrentLook ) | 146 | if ( !mCurrentLook ) |
156 | return empty; | 147 | return empty; |
157 | else | 148 | else |
158 | return mCurrentLook->addressee(); | 149 | return mCurrentLook->addressee(); |
159 | } | 150 | } |
160 | 151 | ||
161 | void ViewContainer::setReadOnly( bool state ) | 152 | void ViewContainer::setReadOnly( bool state ) |
162 | { | 153 | { |
163 | if ( mCurrentLook ) | 154 | if ( mCurrentLook ) |
164 | mCurrentLook->setReadOnly( state ); | 155 | mCurrentLook->setReadOnly( state ); |
165 | } | 156 | } |
166 | 157 | ||
167 | #ifndef KAB_EMBEDDED | 158 | #ifndef KAB_EMBEDDED |
168 | #include "detailsviewcontainer.moc" | 159 | #include "detailsviewcontainer.moc" |
169 | #endif //KAB_EMBEDDED | 160 | #endif //KAB_EMBEDDED |
diff --git a/kaddressbook/details/detailsviewcontainer.h b/kaddressbook/details/detailsviewcontainer.h index b561d12..667f0cb 100644 --- a/kaddressbook/details/detailsviewcontainer.h +++ b/kaddressbook/details/detailsviewcontainer.h | |||
@@ -1,103 +1,102 @@ | |||
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 | #ifndef DETAILSVIEWCONTAINER_H | 24 | #ifndef DETAILSVIEWCONTAINER_H |
25 | #define DETAILSVIEWCONTAINER_H | 25 | #define DETAILSVIEWCONTAINER_H |
26 | 26 | ||
27 | #include <qptrlist.h> | 27 | #include <qptrlist.h> |
28 | 28 | ||
29 | #include "look_basic.h" | 29 | #include "look_basic.h" |
30 | 30 | ||
31 | class QComboBox; | 31 | class QComboBox; |
32 | class QWidgetStack; | 32 | class QWidgetStack; |
33 | 33 | ||
34 | class ViewContainer : public QWidget | 34 | class ViewContainer : public QWidget |
35 | { | 35 | { |
36 | Q_OBJECT | 36 | Q_OBJECT |
37 | 37 | ||
38 | public: | 38 | public: |
39 | ViewContainer( QWidget *parent = 0, const char* name = 0 ); | 39 | ViewContainer( QWidget *parent = 0, const char* name = 0 ); |
40 | 40 | ||
41 | /** | 41 | /** |
42 | Return the look currently selected. If there is none, it | 42 | Return the look currently selected. If there is none, it |
43 | returns zero. Do not use this pointer to store a reference | 43 | returns zero. Do not use this pointer to store a reference |
44 | to a look, the user might select another one (e.g., create | 44 | to a look, the user might select another one (e.g., create |
45 | a new object) at any time. | 45 | a new object) at any time. |
46 | */ | 46 | */ |
47 | KABBasicLook *currentLook(); | 47 | KABBasicLook *currentLook(); |
48 | void refreshView(); | ||
49 | /** | 48 | /** |
50 | Return the contact currently displayed. | 49 | Return the contact currently displayed. |
51 | */ | 50 | */ |
52 | KABC::Addressee addressee(); | 51 | KABC::Addressee addressee(); |
53 | 52 | ||
54 | public slots: | 53 | public slots: |
55 | /** | 54 | /** |
56 | Set the contact currently displayed. | 55 | Set the contact currently displayed. |
57 | */ | 56 | */ |
58 | void setAddressee( const KABC::Addressee& addressee ); | 57 | void setAddressee( const KABC::Addressee& addressee ); |
59 | 58 | ||
60 | /** | 59 | /** |
61 | Set read-write state. | 60 | Set read-write state. |
62 | */ | 61 | */ |
63 | void setReadOnly( bool state ); | 62 | void setReadOnly( bool state ); |
64 | 63 | ||
65 | signals: | 64 | signals: |
66 | /** | 65 | /** |
67 | The contact has been changed. | 66 | The contact has been changed. |
68 | */ | 67 | */ |
69 | void addresseeChanged(); | 68 | void addresseeChanged(); |
70 | 69 | ||
71 | /** | 70 | /** |
72 | The user acticated the email address displayed. This may happen | 71 | The user acticated the email address displayed. This may happen |
73 | by, for example, clicking on the displayed mailto-URL. | 72 | by, for example, clicking on the displayed mailto-URL. |
74 | */ | 73 | */ |
75 | void sendEmail( const QString& ); | 74 | void sendEmail( const QString& ); |
76 | 75 | ||
77 | /** | 76 | /** |
78 | The user activated one of the displayed HTTP URLs. For example | 77 | The user activated one of the displayed HTTP URLs. For example |
79 | by clicking on the displayed homepage address. | 78 | by clicking on the displayed homepage address. |
80 | */ | 79 | */ |
81 | void browse( const QString& ); | 80 | void browse( const QString& ); |
82 | 81 | ||
83 | protected: | 82 | protected: |
84 | /** | 83 | /** |
85 | A style has been selected. Overloaded from base class. | 84 | A style has been selected. Overloaded from base class. |
86 | */ | 85 | */ |
87 | void slotStyleSelected( int ); | 86 | void slotStyleSelected( int ); |
88 | 87 | ||
89 | /** | 88 | /** |
90 | Register the available looks. | 89 | Register the available looks. |
91 | */ | 90 | */ |
92 | void registerLooks(); | 91 | void registerLooks(); |
93 | 92 | ||
94 | private: | 93 | private: |
95 | KABC::Addressee mCurrentAddressee; | 94 | KABC::Addressee mCurrentAddressee; |
96 | KABBasicLook *mCurrentLook; | 95 | KABBasicLook *mCurrentLook; |
97 | QPtrList<KABLookFactory> mLookFactories; | 96 | QPtrList<KABLookFactory> mLookFactories; |
98 | 97 | ||
99 | QComboBox *mStyleCombo; | 98 | QComboBox *mStyleCombo; |
100 | QWidgetStack *mDetailsStack; | 99 | QWidgetStack *mDetailsStack; |
101 | }; | 100 | }; |
102 | 101 | ||
103 | #endif | 102 | #endif |