author | ulf69 <ulf69> | 2004-08-04 22:45:22 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-08-04 22:45:22 (UTC) |
commit | c3a704f5acda9cf9fee66e5c0b1b864f3b7dd852 (patch) (unidiff) | |
tree | dc59744a6d59ba241e793ce051da485d0bf16d06 /microkde/kresources/configdialog.cpp | |
parent | b83866e08ddcc5cb2734801977927f48b53a2e1c (diff) | |
download | kdepimpi-c3a704f5acda9cf9fee66e5c0b1b864f3b7dd852.zip kdepimpi-c3a704f5acda9cf9fee66e5c0b1b864f3b7dd852.tar.gz kdepimpi-c3a704f5acda9cf9fee66e5c0b1b864f3b7dd852.tar.bz2 |
final changes for addressbook sync config dialog
Diffstat (limited to 'microkde/kresources/configdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/kresources/configdialog.cpp | 78 |
1 files changed, 62 insertions, 16 deletions
diff --git a/microkde/kresources/configdialog.cpp b/microkde/kresources/configdialog.cpp index 90febca..f8240f9 100644 --- a/microkde/kresources/configdialog.cpp +++ b/microkde/kresources/configdialog.cpp | |||
@@ -20,54 +20,61 @@ | |||
20 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 20 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
21 | Boston, MA 02111-1307, USA. | 21 | Boston, MA 02111-1307, USA. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <klocale.h> | 24 | #include <klocale.h> |
25 | #include <kglobal.h> | 25 | #include <kglobal.h> |
26 | #include <kmessagebox.h> | 26 | #include <kmessagebox.h> |
27 | 27 | ||
28 | #include <qgroupbox.h> | 28 | #include <qgroupbox.h> |
29 | #include <qlabel.h> | 29 | #include <qlabel.h> |
30 | #include <qlayout.h> | 30 | #include <qlayout.h> |
31 | #include <qpushbutton.h> | 31 | #include <qpushbutton.h> |
32 | #include <qvbox.h> | ||
32 | 33 | ||
33 | #include <qcheckbox.h> | 34 | #include <qcheckbox.h> |
35 | #include <qscrollview.h> | ||
34 | 36 | ||
35 | #include <kbuttonbox.h> | 37 | #include <kbuttonbox.h> |
36 | #include <kdialog.h> | 38 | #include <kdialog.h> |
37 | #include <klineedit.h> | 39 | #include <klineedit.h> |
38 | 40 | ||
39 | #include "factory.h" | 41 | #include "factory.h" |
40 | #include "configwidget.h" | 42 | #include "configwidget.h" |
41 | #include "configdialog.h" | 43 | #include "configdialog.h" |
42 | #include "syncwidget.h" | 44 | #include "syncwidget.h" |
43 | 45 | ||
44 | using namespace KRES; | 46 | using namespace KRES; |
45 | 47 | ||
46 | ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily, | 48 | ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily, |
47 | Resource* resource, const char *name ) | 49 | Resource* resource, const char *name ) |
48 | : KDialogBase( parent, name, true, resource->isSyncable()?i18n( "Sync Profile Configuration" ):i18n( "Resource Configuration" ), | 50 | : KDialogBase( parent, name, true, resource->isSyncable()?i18n( "Sync Profile Configuration" ):i18n( "Resource Configuration" ), |
49 | Ok|Cancel, Ok, true )/*, mConfig( config )*/, mSyncWidget(0), mResource( resource ), mPersistentReadOnly(false) | 51 | Ok|Cancel, Ok, true )/*, mConfig( config )*/, mSyncWidget_Settings(0), mSyncWidget_Conflicts(0),mSyncWidget_Remote(0), mResource( resource ), mPersistentReadOnly(false) |
50 | { | 52 | { |
51 | 53 | ||
52 | Factory *factory = Factory::self( resourceFamily ); | 54 | Factory *factory = Factory::self( resourceFamily ); |
53 | 55 | ||
54 | //US resize( 250, 240 ); | 56 | //US resize( 250, 240 ); |
55 | resize( KMIN(KGlobal::getDesktopWidth(), 250), KMIN(KGlobal::getDesktopHeight(), 240)); | 57 | resize( KMIN(KGlobal::getDesktopWidth(), 250), KMIN(KGlobal::getDesktopHeight(), 240)); |
56 | 58 | ||
57 | //US QFrame *main = makeMainWidget(); | 59 | QFrame *main; |
58 | QFrame *main = plainPage(); | 60 | |
61 | if (!mResource->isSyncable()) | ||
62 | main = plainPage(); | ||
63 | else | ||
64 | main = addPage("Profile"); | ||
59 | 65 | ||
60 | QVBoxLayout *mainLayout = new QVBoxLayout( main, 0, spacingHint() ); | 66 | QVBoxLayout *mainLayout = new QVBoxLayout( main, 0, spacingHint() ); |
61 | 67 | ||
68 | |||
62 | QGroupBox *generalGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); | 69 | QGroupBox *generalGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); |
63 | generalGroupBox->layout()->setSpacing( spacingHint() ); | 70 | generalGroupBox->layout()->setSpacing( spacingHint() ); |
64 | generalGroupBox->setTitle( i18n( "General Settings" ) ); | 71 | generalGroupBox->setTitle( i18n( "General Settings" ) ); |
65 | 72 | ||
66 | new QLabel( mResource->isSyncable()?i18n( "Profile Name:" ):i18n( "Name:" ), generalGroupBox ); | 73 | new QLabel( mResource->isSyncable()?i18n( "Profile Name:" ):i18n( "Name:" ), generalGroupBox ); |
67 | 74 | ||
68 | mName = new KLineEdit( generalGroupBox ); | 75 | mName = new KLineEdit( generalGroupBox ); |
69 | 76 | ||
70 | if (!mResource->isSyncable()) { | 77 | if (!mResource->isSyncable()) { |
71 | mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox ); | 78 | mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox ); |
72 | mReadOnly->setChecked( mResource->readOnly() ); | 79 | mReadOnly->setChecked( mResource->readOnly() ); |
73 | } | 80 | } |
@@ -89,59 +96,97 @@ ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily, | |||
89 | connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ), | 96 | connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ), |
90 | SLOT( setReadOnly( bool ) ) ); | 97 | SLOT( setReadOnly( bool ) ) ); |
91 | connect( mConfigWidget, SIGNAL( setPersistentReadOnly( bool ) ), | 98 | connect( mConfigWidget, SIGNAL( setPersistentReadOnly( bool ) ), |
92 | SLOT( setPersistentReadOnly( bool ) ) ); | 99 | SLOT( setPersistentReadOnly( bool ) ) ); |
93 | mConfigWidget->setInEditMode( false ); | 100 | mConfigWidget->setInEditMode( false ); |
94 | mConfigWidget->loadSettings( mResource ); | 101 | mConfigWidget->loadSettings( mResource ); |
95 | mConfigWidget->show(); | 102 | mConfigWidget->show(); |
96 | 103 | ||
97 | } | 104 | } |
98 | 105 | ||
99 | if (mResource->isSyncable()) | 106 | if (mResource->isSyncable()) |
100 | { | 107 | { |
101 | QGroupBox *syncGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); | 108 | SyncWidgetContainer* c = factory->syncWidgetContainer( resource->type() ); |
102 | syncGroupBox->layout()->setSpacing( spacingHint()); | 109 | |
103 | syncGroupBox->setTitle( i18n( "Syncronize Preferences" ) ); | 110 | QFrame* syncPage = addPage("Settings"); |
104 | mainLayout->addWidget( syncGroupBox ); | 111 | QVBoxLayout *syncLayout = new QVBoxLayout( syncPage, 0, spacingHint() ); |
112 | mSyncWidget_Settings = c->generateSettingsTab(syncPage); | ||
113 | syncLayout->addWidget( mSyncWidget_Settings ); | ||
114 | |||
115 | syncPage = addPage("Conflicts"); | ||
116 | syncLayout = new QVBoxLayout( syncPage, 0, spacingHint() ); | ||
117 | mSyncWidget_Conflicts = c->generateConflictsTab(syncPage); | ||
118 | syncLayout->addWidget( mSyncWidget_Conflicts ); | ||
119 | |||
120 | syncPage = addPage("Remote"); | ||
121 | syncLayout = new QVBoxLayout( syncPage, 0, spacingHint() ); | ||
122 | mSyncWidget_Remote = c->generateRemoteTab(syncPage); | ||
123 | syncLayout->addWidget( mSyncWidget_Remote ); | ||
124 | |||
105 | 125 | ||
106 | mainLayout->addStretch(); | 126 | mSyncWidget_Settings->setInEditMode( false ); |
127 | mSyncWidget_Settings->loadSettings( mResource ); | ||
128 | mSyncWidget_Settings->show(); | ||
107 | 129 | ||
108 | mSyncWidget = factory->syncWidget( resource->type(), syncGroupBox ); | 130 | mSyncWidget_Conflicts->setInEditMode( false ); |
131 | mSyncWidget_Conflicts->loadSettings( mResource ); | ||
132 | mSyncWidget_Conflicts->show(); | ||
133 | |||
134 | mSyncWidget_Remote->setInEditMode( false ); | ||
135 | mSyncWidget_Remote->loadSettings( mResource ); | ||
136 | mSyncWidget_Remote->show(); | ||
137 | |||
138 | delete c; | ||
139 | |||
140 | // QGroupBox *syncGroupBox = new QGroupBox( 2, Qt::Horizontal, syncPage ); | ||
141 | // syncGroupBox->layout()->setSpacing( spacingHint()); | ||
142 | // syncGroupBox->setTitle( i18n( "Syncronize Preferences" ) ); | ||
143 | // syncLayout->addWidget( syncGroupBox ); | ||
144 | |||
145 | // syncLayout->addStretch(); | ||
146 | /*US | ||
147 | mSyncWidget = factory->syncWidget( resource->type(), syncPage ); | ||
148 | syncLayout->addWidget( mSyncWidget ); | ||
109 | if ( mSyncWidget ) { | 149 | if ( mSyncWidget ) { |
110 | mSyncWidget->setInEditMode( false ); | 150 | mSyncWidget->setInEditMode( false ); |
111 | mSyncWidget->loadSettings( mResource ); | 151 | mSyncWidget->loadSettings( mResource ); |
112 | mSyncWidget->show(); | 152 | mSyncWidget->show(); |
113 | } | 153 | } |
154 | */ | ||
114 | } | 155 | } |
115 | 156 | ||
116 | 157 | ||
117 | 158 | ||
118 | 159 | ||
119 | connect( mName, SIGNAL( textChanged(const QString &)), | 160 | connect( mName, SIGNAL( textChanged(const QString &)), |
120 | SLOT( slotNameChanged(const QString &))); | 161 | SLOT( slotNameChanged(const QString &))); |
121 | 162 | ||
122 | slotNameChanged( mName->text() ); | 163 | slotNameChanged( mName->text() ); |
123 | 164 | ||
124 | //US setMinimumSize( 400, 250 ); | 165 | //US setMinimumSize( 400, 250 ); |
125 | setMinimumSize( KMIN(KGlobal::getDesktopWidth(), 400), KMIN(KGlobal::getDesktopHeight(), 250)); | 166 | setMinimumSize( KMIN(KGlobal::getDesktopWidth(), 400), KMIN(KGlobal::getDesktopHeight(), 250)); |
126 | 167 | ||
127 | } | 168 | } |
128 | 169 | ||
129 | void ConfigDialog::setInEditMode( bool value ) | 170 | void ConfigDialog::setInEditMode( bool value ) |
130 | { | 171 | { |
131 | if ( mConfigWidget ) | 172 | if ( mConfigWidget ) |
132 | mConfigWidget->setInEditMode( value ); | 173 | mConfigWidget->setInEditMode( value ); |
133 | 174 | ||
134 | if ( mSyncWidget ) | 175 | if ( mSyncWidget_Settings ) |
135 | mSyncWidget->setInEditMode( value ); | 176 | mSyncWidget_Settings->setInEditMode( value ); |
177 | if ( mSyncWidget_Conflicts ) | ||
178 | mSyncWidget_Conflicts->setInEditMode( value ); | ||
179 | if ( mSyncWidget_Remote ) | ||
180 | mSyncWidget_Remote->setInEditMode( value ); | ||
136 | 181 | ||
137 | } | 182 | } |
138 | 183 | ||
139 | void ConfigDialog::slotNameChanged( const QString &text) | 184 | void ConfigDialog::slotNameChanged( const QString &text) |
140 | { | 185 | { |
141 | enableButtonOK( !text.isEmpty() ); | 186 | enableButtonOK( !text.isEmpty() ); |
142 | } | 187 | } |
143 | 188 | ||
144 | void ConfigDialog::setReadOnly( bool value ) | 189 | void ConfigDialog::setReadOnly( bool value ) |
145 | { | 190 | { |
146 | if (!mResource->isSyncable()) { | 191 | if (!mResource->isSyncable()) { |
147 | 192 | ||
@@ -173,23 +218,24 @@ void ConfigDialog::accept() | |||
173 | } | 218 | } |
174 | 219 | ||
175 | mResource->setResourceName( mName->text() ); | 220 | mResource->setResourceName( mName->text() ); |
176 | if (!mResource->isSyncable()) | 221 | if (!mResource->isSyncable()) |
177 | mResource->setReadOnly( mReadOnly->isChecked() ); | 222 | mResource->setReadOnly( mReadOnly->isChecked() ); |
178 | 223 | ||
179 | if ( mConfigWidget ) { | 224 | if ( mConfigWidget ) { |
180 | // First save generic information | 225 | // First save generic information |
181 | // Also save setting of specific resource type | 226 | // Also save setting of specific resource type |
182 | mConfigWidget->saveSettings( mResource ); | 227 | mConfigWidget->saveSettings( mResource ); |
183 | } | 228 | } |
184 | 229 | ||
185 | if ( mSyncWidget ) { | 230 | if ( mSyncWidget_Settings ) |
186 | // First save generic information | 231 | mSyncWidget_Settings->saveSettings( mResource ); |
187 | // Also save setting of specific resource type | 232 | if ( mSyncWidget_Conflicts ) |
188 | mSyncWidget->saveSettings( mResource ); | 233 | mSyncWidget_Conflicts->saveSettings( mResource ); |
189 | } | 234 | if ( mSyncWidget_Remote ) |
235 | mSyncWidget_Remote->saveSettings( mResource ); | ||
190 | 236 | ||
191 | 237 | ||
192 | KDialog::accept(); | 238 | KDialog::accept(); |
193 | } | 239 | } |
194 | 240 | ||
195 | //US #include "configdialog.moc" | 241 | //US #include "configdialog.moc" |