10#include "webwidgetlister.h"
13#include <KContacts/Addressee>
16WebWidgetLister::WebWidgetLister(
QWidget *parent)
17 : KWidgetLister(1, 8, parent)
19 setNumberOfShownWidgetsTo(widgetsMinimum());
20 updateAddRemoveButton();
23WebWidgetLister::~WebWidgetLister() =
default;
27 KContacts::ResourceLocatorUrl::List resourceLocatorList = contact.extraUrlList();
28 if (resourceLocatorList.isEmpty()) {
29 setNumberOfShownWidgetsTo(1);
31 setNumberOfShownWidgetsTo(resourceLocatorList.count());
35 for (
int i = 0; wIt != wEnd; ++wIt, ++i) {
36 auto w = qobject_cast<WebWidget *>(*wIt);
37 w->loadWebSite(resourceLocatorList.at(i));
45 KContacts::ResourceLocatorUrl::List resourceLocatorList;
46 for (
QWidget *widget : widgetList) {
47 auto w = qobject_cast<WebWidget *>(widget);
49 if (newUrl.isValid()) {
50 resourceLocatorList << newUrl;
53 contact.setExtraUrlList(resourceLocatorList);
56void WebWidgetLister::setReadOnly(
bool readOnly)
59 for (
QWidget *widget : widgetList) {
60 auto w = qobject_cast<WebWidget *>(widget);
61 w->setReadOnly(readOnly);
67 auto w =
new WebWidget(parent);
72void WebWidgetLister::reconnectWidget(WebWidget *w)
79void WebWidgetLister::slotAddWidget(WebWidget *w)
81 addWidgetAfterThisWidget(w);
82 updateAddRemoveButton();
85void WebWidgetLister::slotRemoveWidget(WebWidget *w)
87 if (widgets().count() == 1) {
91 updateAddRemoveButton();
95void WebWidgetLister::updateAddRemoveButton()
98 const int numberOfWidget(widgetList.
count());
99 bool addButtonEnabled =
false;
100 if (numberOfWidget <= widgetsMinimum()) {
101 addButtonEnabled =
true;
102 }
else if (numberOfWidget >= widgetsMaximum()) {
103 addButtonEnabled =
false;
105 addButtonEnabled =
true;
109 for (; wIt != wEnd; ++wIt) {
110 auto w = qobject_cast<WebWidget *>(*wIt);
111 w->updateAddRemoveButton(addButtonEnabled);
115void WebWidgetLister::slotPreferredChanged(WebWidget *w)
118 for (
QWidget *widget : widgetList) {
120 (
static_cast<WebWidget *
>(widget))->setPreferred(
false);
125#include "moc_webwidgetlister.cpp"
A widget for editing the display name of a contact.
const_iterator constBegin() const const
const_iterator constEnd() const const
qsizetype count() const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)