VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/networkmanager/UIDetailsWidgetCloudNetwork.cpp

Last change on this file was 104223, checked in by vboxsync, 6 weeks ago

FE/Qt. bugref:10622. Using new UITranslationEventListener in metwork manager classes.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 22.7 KB
Line 
1/* $Id: UIDetailsWidgetCloudNetwork.cpp 104223 2024-04-08 10:30:04Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIDetailsWidgetCloudNetwork class implementation.
4 */
5
6/*
7 * Copyright (C) 2009-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28/* Qt includes: */
29#include <QCheckBox>
30#include <QComboBox>
31#include <QFontMetrics>
32#include <QGroupBox>
33#include <QLabel>
34#include <QPushButton>
35#include <QRadioButton>
36#include <QStyleOption>
37#include <QVBoxLayout>
38
39/* GUI includes: */
40#include "QIDialogButtonBox.h"
41#include "QILineEdit.h"
42#include "QITabWidget.h"
43#include "QIToolButton.h"
44#include "UICloudNetworkingStuff.h"
45#include "UIDetailsWidgetCloudNetwork.h"
46#include "UIFormEditorWidget.h"
47#include "UIIconPool.h"
48#include "UIMessageCenter.h"
49#include "UINetworkManager.h"
50#include "UINetworkManagerUtils.h"
51#include "UINotificationCenter.h"
52#include "UITranslationEventListener.h"
53
54UISubnetSelectionDialog::UISubnetSelectionDialog(QWidget *pParent,
55 const QString &strShortProviderName,
56 const QString &strProfileName,
57 const QString &strSubnetId)
58 : QDialog(pParent)
59 , m_strProviderShortName(strShortProviderName)
60 , m_strProfileName(strProfileName)
61 , m_strSubnetId(strSubnetId)
62 , m_pFormEditor(0)
63 , m_pButtonBox(0)
64 , m_pNotificationCenter(0)
65{
66 prepare();
67}
68
69UISubnetSelectionDialog::~UISubnetSelectionDialog()
70{
71 cleanup();
72}
73
74void UISubnetSelectionDialog::accept()
75{
76 /* Get altered description back: */
77 m_comForm.GetVirtualSystemDescription();
78 QVector<KVirtualSystemDescriptionType> aTypes;
79 QVector<QString> aRefs, aOVFValues, aVBoxValues, aExtraConfigValues;
80 m_comDescription.GetDescriptionByType(KVirtualSystemDescriptionType_CloudOCISubnet,
81 aTypes, aRefs, aOVFValues, aVBoxValues, aExtraConfigValues);
82 if (!m_comDescription.isOk())
83 {
84 UINotificationMessage::cannotAcquireVirtualSystemDescriptionParameter(m_comDescription,
85 m_pNotificationCenter);
86 return;
87 }
88 AssertReturnVoid(!aVBoxValues.isEmpty());
89 m_strSubnetId = aVBoxValues.first();
90
91 /* Call to base-class: */
92 return QDialog::accept();
93}
94
95int UISubnetSelectionDialog::exec()
96{
97 /* Request to init dialog _after_ being executed: */
98 QMetaObject::invokeMethod(this, "sltInit", Qt::QueuedConnection);
99
100 /* Call to base-class: */
101 return QDialog::exec();
102}
103
104void UISubnetSelectionDialog::sltRetranslateUI()
105{
106 setWindowTitle(UINetworkManager::tr("Select Subnet"));
107}
108
109void UISubnetSelectionDialog::sltInit()
110{
111 /* Create description: */
112 m_comDescription = createVirtualSystemDescription(m_pNotificationCenter);
113 if (m_comDescription.isNull())
114 return;
115 /* Update it with current subnet value: */
116 m_comDescription.AddDescription(KVirtualSystemDescriptionType_CloudOCISubnet, m_strSubnetId, QString());
117
118 /* Create cloud client: */
119 CCloudClient comCloudClient = cloudClientByName(m_strProviderShortName, m_strProfileName, m_pNotificationCenter);
120 if (comCloudClient.isNull())
121 return;
122
123 /* Create subnet selection VSD form: */
124 UINotificationProgressSubnetSelectionVSDFormCreate *pNotification = new UINotificationProgressSubnetSelectionVSDFormCreate(comCloudClient,
125 m_comDescription,
126 m_strProviderShortName,
127 m_strProfileName);
128 connect(pNotification, &UINotificationProgressSubnetSelectionVSDFormCreate::sigVSDFormCreated,
129 this, &UISubnetSelectionDialog::sltHandleVSDFormCreated);
130 m_pNotificationCenter->append(pNotification);
131}
132
133void UISubnetSelectionDialog::sltHandleVSDFormCreated(const CVirtualSystemDescriptionForm &comForm)
134{
135 m_comForm = comForm;
136 m_pFormEditor->setVirtualSystemDescriptionForm(m_comForm);
137}
138
139void UISubnetSelectionDialog::prepare()
140{
141 /* Prepare main layout: */
142 QVBoxLayout *pLayoutMain = new QVBoxLayout(this);
143 if (pLayoutMain)
144 {
145 /* Prepare form editor: */
146 m_pFormEditor = new UIFormEditorWidget(this);
147 if (m_pFormEditor)
148 pLayoutMain->addWidget(m_pFormEditor);
149
150 /* Prepare button-box: */
151 m_pButtonBox = new QIDialogButtonBox(this);
152 if (m_pButtonBox)
153 {
154 m_pButtonBox->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
155 connect(m_pButtonBox, &QIDialogButtonBox::accepted, this, &QDialog::accept);
156 connect(m_pButtonBox, &QIDialogButtonBox::rejected, this, &QDialog::reject);
157
158 pLayoutMain->addWidget(m_pButtonBox);
159 }
160 }
161
162 /* Prepare local notification-center: */
163 m_pNotificationCenter = new UINotificationCenter(this);
164 if (m_pNotificationCenter && m_pFormEditor)
165 m_pFormEditor->setNotificationCenter(m_pNotificationCenter);
166
167 /* Apply language settings: */
168 sltRetranslateUI();
169
170 connect(&translationEventListener(), &UITranslationEventListener::sigRetranslateUI,
171 this, &UISubnetSelectionDialog::sltRetranslateUI);
172}
173
174void UISubnetSelectionDialog::cleanup()
175{
176 /* Cleanup local notification-center: */
177 delete m_pNotificationCenter;
178 m_pNotificationCenter = 0;
179}
180
181
182UIDetailsWidgetCloudNetwork::UIDetailsWidgetCloudNetwork(EmbedTo enmEmbedding, QWidget *pParent /* = 0 */)
183 : QWidget(pParent)
184 , m_enmEmbedding(enmEmbedding)
185 , m_pLabelNetworkName(0)
186 , m_pEditorNetworkName(0)
187 , m_pLabelProviderName(0)
188 , m_pComboProviderName(0)
189 , m_pLabelProfileName(0)
190 , m_pComboProfileName(0)
191 , m_pLabelNetworkId(0)
192 , m_pEditorNetworkId(0)
193 , m_pButtonNetworkId(0)
194 , m_pButtonBoxOptions(0)
195{
196 prepare();
197}
198
199void UIDetailsWidgetCloudNetwork::setData(const UIDataCloudNetwork &data,
200 const QStringList &busyNames /* = QStringList() */)
201{
202 /* Cache old/new data: */
203 m_oldData = data;
204 m_newData = m_oldData;
205 m_busyNames = busyNames;
206
207 /* Load data: */
208 loadData();
209}
210
211bool UIDetailsWidgetCloudNetwork::revalidate() const
212{
213 /* Make sure network name isn't empty: */
214 if (m_newData.m_strName.isEmpty())
215 {
216 UINotificationMessage::warnAboutNoNameSpecified(m_oldData.m_strName);
217 return false;
218 }
219 else
220 {
221 /* Make sure item names are unique: */
222 if (m_busyNames.contains(m_newData.m_strName))
223 {
224 UINotificationMessage::warnAboutNameAlreadyBusy(m_newData.m_strName);
225 return false;
226 }
227 }
228
229 return true;
230}
231
232void UIDetailsWidgetCloudNetwork::updateButtonStates()
233{
234// if (m_oldData != m_newData)
235// printf("Network: %s, %s, %s, %d, %d, %d\n",
236// m_newData.m_strName.toUtf8().constData(),
237// m_newData.m_strPrefixIPv4.toUtf8().constData(),
238// m_newData.m_strPrefixIPv6.toUtf8().constData(),
239// m_newData.m_fSupportsDHCP,
240// m_newData.m_fSupportsIPv6,
241// m_newData.m_fAdvertiseDefaultIPv6Route);
242
243 /* Update 'Apply' / 'Reset' button states: */
244 if (m_pButtonBoxOptions)
245 {
246 m_pButtonBoxOptions->button(QDialogButtonBox::Cancel)->setEnabled(m_oldData != m_newData);
247 m_pButtonBoxOptions->button(QDialogButtonBox::Ok)->setEnabled(m_oldData != m_newData);
248 }
249
250 /* Notify listeners as well: */
251 emit sigDataChanged(m_oldData != m_newData);
252}
253
254void UIDetailsWidgetCloudNetwork::sltRetranslateUI()
255{
256 if (m_pLabelNetworkName)
257 m_pLabelNetworkName->setText(UINetworkManager::tr("N&ame:"));
258 if (m_pEditorNetworkName)
259 m_pEditorNetworkName->setToolTip(UINetworkManager::tr("Holds the name for this network."));
260 if (m_pLabelProviderName)
261 m_pLabelProviderName->setText(UINetworkManager::tr("&Provider:"));
262 if (m_pComboProviderName)
263 m_pComboProviderName->setToolTip(UINetworkManager::tr("Holds the cloud provider for this network."));
264 if (m_pLabelProfileName)
265 m_pLabelProfileName->setText(UINetworkManager::tr("P&rofile:"));
266 if (m_pComboProfileName)
267 m_pComboProfileName->setToolTip(UINetworkManager::tr("Holds the cloud profile for this network."));
268 if (m_pLabelNetworkId)
269 m_pLabelNetworkId->setText(UINetworkManager::tr("&Id:"));
270 if (m_pEditorNetworkId)
271 m_pEditorNetworkId->setToolTip(UINetworkManager::tr("Holds the id for this network."));
272 if (m_pButtonNetworkId)
273 m_pButtonNetworkId->setToolTip(UINetworkManager::tr("Selects the id for this network."));
274 if (m_pButtonBoxOptions)
275 {
276 m_pButtonBoxOptions->button(QDialogButtonBox::Cancel)->setText(UINetworkManager::tr("Reset"));
277 m_pButtonBoxOptions->button(QDialogButtonBox::Ok)->setText(UINetworkManager::tr("Apply"));
278 m_pButtonBoxOptions->button(QDialogButtonBox::Cancel)->setShortcut(Qt::Key_Escape);
279 m_pButtonBoxOptions->button(QDialogButtonBox::Ok)->setShortcut(QString("Ctrl+Return"));
280 m_pButtonBoxOptions->button(QDialogButtonBox::Cancel)->setStatusTip(UINetworkManager::tr("Reset changes in current "
281 "interface details"));
282 m_pButtonBoxOptions->button(QDialogButtonBox::Ok)->setStatusTip(UINetworkManager::tr("Apply changes in current "
283 "interface details"));
284 m_pButtonBoxOptions->button(QDialogButtonBox::Cancel)->
285 setToolTip(UINetworkManager::tr("Reset Changes (%1)").arg(m_pButtonBoxOptions->button(QDialogButtonBox::Cancel)->shortcut().toString()));
286 m_pButtonBoxOptions->button(QDialogButtonBox::Ok)->
287 setToolTip(UINetworkManager::tr("Apply Changes (%1)").arg(m_pButtonBoxOptions->button(QDialogButtonBox::Ok)->shortcut().toString()));
288 }
289}
290
291void UIDetailsWidgetCloudNetwork::sltNetworkNameChanged(const QString &strText)
292{
293 m_newData.m_strName = strText;
294 updateButtonStates();
295}
296
297void UIDetailsWidgetCloudNetwork::sltCloudProviderNameChanged(int iIndex)
298{
299 /* Store provider: */
300 m_newData.m_strProvider = m_pComboProviderName->itemData(iIndex).toString();
301
302 /* Update profiles: */
303 prepareProfiles();
304 /* And store selected profile: */
305 sltCloudProfileNameChanged(m_pComboProfileName->currentIndex());
306
307 /* Update button states finally: */
308 updateButtonStates();
309}
310
311void UIDetailsWidgetCloudNetwork::sltCloudProfileNameChanged(int iIndex)
312{
313 /* Store profile: */
314 m_newData.m_strProfile = m_pComboProfileName->itemData(iIndex).toString();
315
316 /* Update button states finally: */
317 updateButtonStates();
318}
319
320void UIDetailsWidgetCloudNetwork::sltNetworkIdChanged(const QString &strText)
321{
322 m_newData.m_strId = strText;
323 updateButtonStates();
324}
325
326void UIDetailsWidgetCloudNetwork::sltNetworkIdListRequested()
327{
328 /* Create subnet selection dialog: */
329 QPointer<UISubnetSelectionDialog> pDialog = new UISubnetSelectionDialog(this,
330 m_pComboProviderName->currentData().toString(),
331 m_pComboProfileName->currentData().toString(),
332 m_pEditorNetworkId->text());
333
334 /* Execute dialog to ask user for subnet: */
335 if (pDialog->exec() == QDialog::Accepted)
336 m_pEditorNetworkId->setText(pDialog->subnetId());
337
338 /* Cleanup subnet dialog finally: */
339 delete pDialog;
340}
341
342void UIDetailsWidgetCloudNetwork::sltHandleButtonBoxClick(QAbstractButton *pButton)
343{
344 /* Make sure button-box exist: */
345 if (!m_pButtonBoxOptions)
346 return;
347
348 /* Disable buttons first of all: */
349 m_pButtonBoxOptions->button(QDialogButtonBox::Cancel)->setEnabled(false);
350 m_pButtonBoxOptions->button(QDialogButtonBox::Ok)->setEnabled(false);
351
352 /* Compare with known buttons: */
353 if (pButton == m_pButtonBoxOptions->button(QDialogButtonBox::Cancel))
354 emit sigDataChangeRejected();
355 else
356 if (pButton == m_pButtonBoxOptions->button(QDialogButtonBox::Ok))
357 emit sigDataChangeAccepted();
358}
359
360void UIDetailsWidgetCloudNetwork::prepare()
361{
362 /* Prepare everything: */
363 prepareThis();
364 prepareProviders();
365 prepareProfiles();
366
367 /* Apply language settings: */
368 sltRetranslateUI();
369
370 connect(&translationEventListener(), &UITranslationEventListener::sigRetranslateUI,
371 this, &UIDetailsWidgetCloudNetwork::sltRetranslateUI);
372
373 /* Update button states finally: */
374 updateButtonStates();
375}
376
377void UIDetailsWidgetCloudNetwork::prepareThis()
378{
379 /* Prepare options widget layout: */
380 QGridLayout *pLayout = new QGridLayout(this);
381 if (pLayout)
382 {
383#ifdef VBOX_WS_MAC
384 pLayout->setSpacing(10);
385 pLayout->setContentsMargins(10, 10, 10, 10);
386#endif
387
388 /* Prepare network name label: */
389 m_pLabelNetworkName = new QLabel(this);
390 if (m_pLabelNetworkName)
391 {
392 m_pLabelNetworkName->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
393 pLayout->addWidget(m_pLabelNetworkName, 0, 0);
394 }
395 /* Prepare network name editor: */
396 m_pEditorNetworkName = new QLineEdit(this);
397 if (m_pEditorNetworkName)
398 {
399 if (m_pLabelNetworkName)
400 m_pLabelNetworkName->setBuddy(m_pEditorNetworkName);
401 connect(m_pEditorNetworkName, &QLineEdit::textEdited,
402 this, &UIDetailsWidgetCloudNetwork::sltNetworkNameChanged);
403 pLayout->addWidget(m_pEditorNetworkName, 0, 1, 1, 2);
404 }
405
406 /* Prepare cloud provider name label: */
407 m_pLabelProviderName = new QLabel(this);
408 if (m_pLabelProviderName)
409 {
410 m_pLabelProviderName->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
411 pLayout->addWidget(m_pLabelProviderName, 1, 0);
412 }
413 /* Prepare cloud provider name combo: */
414 m_pComboProviderName = new QComboBox(this);
415 if (m_pComboProviderName)
416 {
417 if (m_pLabelProviderName)
418 m_pLabelProviderName->setBuddy(m_pComboProviderName);
419 connect(m_pComboProviderName, &QComboBox::currentIndexChanged,
420 this, &UIDetailsWidgetCloudNetwork::sltCloudProviderNameChanged);
421 pLayout->addWidget(m_pComboProviderName, 1, 1, 1, 2);
422 }
423
424 /* Prepare cloud profile name label: */
425 m_pLabelProfileName = new QLabel(this);
426 if (m_pLabelProfileName)
427 {
428 m_pLabelProfileName->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
429 pLayout->addWidget(m_pLabelProfileName, 2, 0);
430 }
431 /* Prepare cloud profile name combo: */
432 m_pComboProfileName = new QComboBox(this);
433 if (m_pComboProfileName)
434 {
435 if (m_pLabelProfileName)
436 m_pLabelProfileName->setBuddy(m_pComboProfileName);
437 connect(m_pComboProfileName, &QComboBox::currentIndexChanged,
438 this, &UIDetailsWidgetCloudNetwork::sltCloudProfileNameChanged);
439 pLayout->addWidget(m_pComboProfileName, 2, 1, 1, 2);
440 }
441
442 /* Prepare network id label: */
443 m_pLabelNetworkId = new QLabel(this);
444 if (m_pLabelNetworkId)
445 {
446 m_pLabelNetworkId->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
447 pLayout->addWidget(m_pLabelNetworkId, 3, 0);
448 }
449 /* Prepare network id editor: */
450 m_pEditorNetworkId = new QLineEdit(this);
451 if (m_pEditorNetworkId)
452 {
453 if (m_pLabelNetworkId)
454 m_pLabelNetworkId->setBuddy(m_pEditorNetworkId);
455 connect(m_pEditorNetworkId, &QLineEdit::textChanged,
456 this, &UIDetailsWidgetCloudNetwork::sltNetworkIdChanged);
457 pLayout->addWidget(m_pEditorNetworkId, 3, 1);
458 }
459 /* Prepare network id button: */
460 m_pButtonNetworkId = new QIToolButton(this);
461 if (m_pButtonNetworkId)
462 {
463 m_pButtonNetworkId->setIcon(UIIconPool::iconSet(":/subnet_16px.png"));
464 connect(m_pButtonNetworkId, &QIToolButton::clicked,
465 this, &UIDetailsWidgetCloudNetwork::sltNetworkIdListRequested);
466 pLayout->addWidget(m_pButtonNetworkId, 3, 2);
467 }
468
469 /* If parent embedded into stack: */
470 if (m_enmEmbedding == EmbedTo_Stack)
471 {
472 /* Prepare button-box: */
473 m_pButtonBoxOptions = new QIDialogButtonBox(this);
474 if (m_pButtonBoxOptions)
475 {
476 m_pButtonBoxOptions->setStandardButtons(QDialogButtonBox::Cancel | QDialogButtonBox::Ok);
477 connect(m_pButtonBoxOptions, &QIDialogButtonBox::clicked, this, &UIDetailsWidgetCloudNetwork::sltHandleButtonBoxClick);
478 pLayout->addWidget(m_pButtonBoxOptions, 4, 0, 1, 2);
479 }
480 }
481 }
482}
483
484void UIDetailsWidgetCloudNetwork::prepareProviders()
485{
486 /* Sanity check: */
487 AssertPtrReturnVoid(m_pComboProviderName);
488
489 /* Remember current item data to be able to restore it: */
490 QString strOldData;
491 if (m_pComboProviderName->currentIndex() != -1)
492 strOldData = m_pComboProviderName->currentData().toString();
493
494 /* Block signals while updating: */
495 m_pComboProviderName->blockSignals(true);
496
497 /* Clear combo initially: */
498 m_pComboProviderName->clear();
499
500 /* Add empty item: */
501 m_pComboProviderName->addItem("--");
502
503 /* Iterate through existing providers: */
504 foreach (const CCloudProvider &comProvider, listCloudProviders())
505 {
506 /* Skip if we have nothing to populate (file missing?): */
507 if (comProvider.isNull())
508 continue;
509 /* Acquire provider name: */
510 QString strProviderName;
511 if (!cloudProviderName(comProvider, strProviderName))
512 continue;
513 /* Acquire provider short name: */
514 QString strProviderShortName;
515 if (!cloudProviderShortName(comProvider, strProviderShortName))
516 continue;
517
518 /* Compose empty item, fill the data: */
519 m_pComboProviderName->addItem(strProviderName);
520 m_pComboProviderName->setItemData(m_pComboProviderName->count() - 1, strProviderShortName);
521 }
522
523 /* Set previous/default item if possible: */
524 int iNewIndex = -1;
525 if ( iNewIndex == -1
526 && !strOldData.isNull())
527 iNewIndex = m_pComboProviderName->findData(strOldData);
528 if ( iNewIndex == -1
529 && m_pComboProviderName->count() > 0)
530 iNewIndex = 0;
531 if (iNewIndex != -1)
532 m_pComboProviderName->setCurrentIndex(iNewIndex);
533
534 /* Unblock signals after update: */
535 m_pComboProviderName->blockSignals(false);
536}
537
538void UIDetailsWidgetCloudNetwork::prepareProfiles()
539{
540 /* Sanity check: */
541 AssertPtrReturnVoid(m_pComboProfileName);
542
543 /* Remember current item data to be able to restore it: */
544 QString strOldData;
545 if (m_pComboProfileName->currentIndex() != -1)
546 strOldData = m_pComboProfileName->currentData().toString();
547
548 /* Block signals while updating: */
549 m_pComboProfileName->blockSignals(true);
550
551 /* Clear combo initially: */
552 m_pComboProfileName->clear();
553
554 /* Add empty item: */
555 m_pComboProfileName->addItem("--");
556
557 /* Acquire provider short name: */
558 const QString strProviderShortName = m_pComboProviderName->currentData().toString();
559 if (!strProviderShortName.isEmpty())
560 {
561 /* Acquire provider: */
562 CCloudProvider comProvider = cloudProviderByShortName(strProviderShortName);
563 if (comProvider.isNotNull())
564 {
565 /* Iterate through existing profiles: */
566 foreach (const CCloudProfile &comProfile, listCloudProfiles(comProvider))
567 {
568 /* Skip if we have nothing to populate (wtf happened?): */
569 if (comProfile.isNull())
570 continue;
571 /* Acquire current profile name: */
572 QString strProfileName;
573 if (!cloudProfileName(comProfile, strProfileName))
574 continue;
575
576 /* Compose item, fill the data: */
577 m_pComboProfileName->addItem(strProfileName);
578 m_pComboProfileName->setItemData(m_pComboProfileName->count() - 1, strProfileName);
579 }
580
581 /* Set previous/default item if possible: */
582 int iNewIndex = -1;
583 if ( iNewIndex == -1
584 && !strOldData.isNull())
585 iNewIndex = m_pComboProfileName->findData(strOldData);
586 if ( iNewIndex == -1
587 && m_pComboProfileName->count() > 0)
588 iNewIndex = 0;
589 if (iNewIndex != -1)
590 m_pComboProfileName->setCurrentIndex(iNewIndex);
591 }
592 }
593
594 /* Unblock signals after update: */
595 m_pComboProfileName->blockSignals(false);
596}
597
598void UIDetailsWidgetCloudNetwork::loadData()
599{
600 /* Check whether network exists and enabled: */
601 const bool fIsNetworkExists = m_newData.m_fExists;
602
603 /* Update field availability: */
604 m_pLabelNetworkName->setEnabled(fIsNetworkExists);
605 m_pEditorNetworkName->setEnabled(fIsNetworkExists);
606 m_pLabelProviderName->setEnabled(fIsNetworkExists);
607 m_pComboProviderName->setEnabled(fIsNetworkExists);
608 m_pLabelProfileName->setEnabled(fIsNetworkExists);
609 m_pComboProfileName->setEnabled(fIsNetworkExists);
610 m_pLabelNetworkId->setEnabled(fIsNetworkExists);
611 m_pEditorNetworkId->setEnabled(fIsNetworkExists);
612 m_pButtonNetworkId->setEnabled(fIsNetworkExists);
613
614 /* Load fields: */
615 m_pEditorNetworkName->setText(m_newData.m_strName);
616 const int iProviderIndex = m_pComboProviderName->findData(m_newData.m_strProvider);
617 m_pComboProviderName->setCurrentIndex(iProviderIndex == -1 ? 0 : iProviderIndex);
618 const int iProfileIndex = m_pComboProfileName->findData(m_newData.m_strProfile);
619 m_pComboProfileName->setCurrentIndex(iProfileIndex == -1 ? 0 : iProfileIndex);
620 m_pEditorNetworkId->setText(m_newData.m_strId);
621}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use