Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 1daa7c6b authored by Laurent Montel's avatar Laurent Montel 😁

Use readOnly

parent 663cbb16
......@@ -60,5 +60,5 @@ void MessagingListWidget::storeContact(KContacts::Addressee &contact) const
void MessagingListWidget::setReadOnly(bool readOnly)
{
mMessagingWidgetLister->setEnabled(!readOnly);
mMessagingWidgetLister->setReadOnly(readOnly);
}
......@@ -118,3 +118,12 @@ void MessagingWidget::clearWidget()
mProtocolCombo->setCurrentIndex(0);
mMessagingEdit->clear();
}
void MessagingWidget::setReadOnly(bool readOnly)
{
mMessagingEdit->setReadOnly(readOnly);
mAddButton->setEnabled(!readOnly);
mRemoveButton->setEnabled(!readOnly);
mProtocolCombo->setEnabled(!readOnly);
}
......@@ -43,6 +43,7 @@ public:
void setIMAddress(const IMAddress &address);
void setPreferred(bool b);
void clearWidget();
void setReadOnly(bool readOnly);
Q_SIGNALS:
void addWidget(MessagingWidget *);
void removeWidget(MessagingWidget *);
......
......@@ -110,6 +110,15 @@ void MessagingWidgetLister::storeContact(KContacts::Addressee &contact) const
}
}
void MessagingWidgetLister::setReadOnly(bool readOnly)
{
const QList<QWidget *> widgetList = widgets();
for (QWidget *widget : widgetList) {
MessagingWidget *w = qobject_cast<MessagingWidget *>(widget);
w->setReadOnly(readOnly);
}
}
QWidget *MessagingWidgetLister::createWidget(QWidget *parent)
{
MessagingWidget *w = new MessagingWidget(parent);
......
......@@ -39,6 +39,8 @@ public:
void loadContact(const KContacts::Addressee &contact);
void storeContact(KContacts::Addressee &contact) const;
void setReadOnly(bool readOnly);
protected:
QWidget *createWidget(QWidget *) override;
......
......@@ -121,4 +121,7 @@ void PhoneWidget::setPreferred(bool b)
void PhoneWidget::setReadOnly(bool readOnly)
{
mPhoneNumberEdit->setReadOnly(readOnly);
mAddButton->setEnabled(!readOnly);
mRemoveButton->setEnabled(!readOnly);
mPhoneType->setEnabled(!readOnly);
}
......@@ -61,5 +61,5 @@ void WebListWidget::storeContact(KContacts::Addressee &contact) const
void WebListWidget::setReadOnly(bool readOnly)
{
mWebWidgetLister->setEnabled(!readOnly);
mWebWidgetLister->setReadOnly(readOnly);
}
......@@ -154,6 +154,14 @@ void WebWidget::loadWebSite(const KContacts::ResourceLocatorUrl &url)
mWebSiteEdit->setText(mUrl.url().toDisplayString());
}
void WebWidget::setReadOnly(bool readOnly)
{
mWebSiteEdit->setReadOnly(readOnly);
mAddButton->setEnabled(!readOnly);
mRemoveButton->setEnabled(!readOnly);
mWebType->setEnabled(!readOnly);
}
void WebWidget::slotPreferredChanged()
{
Q_EMIT preferredChanged(this);
......
......@@ -44,6 +44,8 @@ public:
KContacts::ResourceLocatorUrl url();
void loadWebSite(const KContacts::ResourceLocatorUrl &url);
void setReadOnly(bool readOnly);
Q_SIGNALS:
void addWidget(WebWidget *);
void removeWidget(WebWidget *);
......
......@@ -68,6 +68,15 @@ void WebWidgetLister::storeContact(KContacts::Addressee &contact) const
contact.setExtraUrlList(resourceLocatorList);
}
void WebWidgetLister::setReadOnly(bool readOnly)
{
const QList<QWidget *> widgetList = widgets();
for (QWidget *widget : widgetList) {
WebWidget *w = qobject_cast<WebWidget *>(widget);
w->setReadOnly(readOnly);
}
}
QWidget *WebWidgetLister::createWidget(QWidget *parent)
{
WebWidget *w = new WebWidget(parent);
......
......@@ -38,6 +38,7 @@ public:
void loadContact(const KContacts::Addressee &contact);
void storeContact(KContacts::Addressee &contact) const;
void setReadOnly(bool readOnly);
protected:
QWidget *createWidget(QWidget *) override;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment