/*!
    \qmlmethod bool Detail::removeValue(field)

    Removes the value stored in this detail for the given \a field. Returns true if a value was stored for
    the given field and the operation succeeded, and false otherwise.
*/
bool QDeclarativeContactDetail::removeValue(int field)
{
    bool ok = m_detail.removeValue(field);
    if (ok)
        emit detailChanged();
    return ok;
}
QTCONTACTS_USE_NAMESPACE

QT_BEGIN_NAMESPACE

/* ==================== QDeclarativeContactDetail ======================= */

/*!
   \qmltype ContactDetail
    \instantiates QDeclarativeContactDetail
   \brief The ContactDetail element represents a single, complete detail about a contact.
   \ingroup qml-contacts-main
   \inqmlmodule QtContacts 5.0

   \sa QContactDetail

    The ContactDetail element is part of the \b{QtContacts} module.
*/

QDeclarativeContactDetail::QDeclarativeContactDetail(QObject* parent)
    :QObject(parent)
{
    QDeclarativeContact* c = qobject_cast<QDeclarativeContact*>(parent);
    if (c)
        connect(this, SIGNAL(detailChanged()), c, SIGNAL(contactChanged()));
}
QT_BEGIN_NAMESPACE_CONTACTS

QDeclarativeContactDetail::QDeclarativeContactDetail(QObject* parent)
    :QObject(parent)
{
    QDeclarativeContact* c = qobject_cast<QDeclarativeContact*>(parent);
    if (c)
        connect(this, SIGNAL(detailChanged()), c, SIGNAL(contactChanged()));
}
bool QDeclarativeContactDetail::setValue(int field, const QVariant& v)
{
    bool changed = false;

    if (value(field) != v)
         changed = m_detail.setValue(field, v);

    if (changed)
        emit detailChanged();

    return changed;
}
示例#5
0
void QDeclarativeContact::setContact(const QContact& contact)
{
    m_id = contact.id();
    foreach (QDeclarativeContactDetail *detail, m_details)
        delete detail;
    m_details.clear();
    m_preferredDetails.clear();

    QList<QContactDetail> details(contact.details());
    foreach (const QContactDetail &detail, details) {
        QDeclarativeContactDetail *contactDetail = QDeclarativeContactDetailFactory::createContactDetail(static_cast<QDeclarativeContactDetail::DetailType>(detail.type()));
        contactDetail->setParent(this);
        contactDetail->setDetail(detail);
        connect(contactDetail, SIGNAL(detailChanged()), this, SIGNAL(contactChanged()));
        m_details.append(contactDetail);
    }
示例#6
0
KCMDesktopTheme::KCMDesktopTheme( QWidget* parent, const QVariantList& )
    : KCModule( parent )
    , m_dialog(0)
    , m_installProcess(0)
    , m_defaultTheme(new Plasma::Theme(this))
{
    setQuickHelp( i18n("<h1>Desktop Theme</h1>"
            "This module allows you to modify the visual appearance "
            "of the desktop."));

    setupUi(this);

    m_bDesktopThemeDirty = false;
    m_bDetailsDirty = false;

    KAutostart plasmaNetbookAutoStart("plasma-netbook");
    m_isNetbook = plasmaNetbookAutoStart.autostarts();

    KGlobal::dirs()->addResourceType("themes", "data", "kstyle/themes");

    KAboutData *about =
        new KAboutData( I18N_NOOP("KCMDesktopTheme"), 0,
                        i18n("KDE Desktop Theme Module"),
                        0, QString(), KAboutData::License_GPL,
                        i18n("(c) 2002 Karol Szwed, Daniel Molkentin"));

    about->addAuthor(i18n("Karol Szwed"), QString(), QStringLiteral("*****@*****.**"));
    about->addAuthor(i18n("Daniel Molkentin"), QString(), QStringLiteral("*****@*****.**"));
    about->addAuthor(i18n("Ralf Nolden"), QString(), QStringLiteral("*****@*****.**"));
    setAboutData( about );

    m_newThemeButton->setIcon(QIcon::fromTheme("get-hot-new-stuff"));

    m_themeModel = new ThemeModel(this);
    m_theme->setModel(m_themeModel);
    m_theme->setItemDelegate(new ThemeDelegate(m_theme));
    m_theme->setVerticalScrollMode(QAbstractItemView::ScrollPerItem);

    connect(m_detailsWidget, SIGNAL(changed()), this, SLOT(detailChanged()));

    connect(m_theme->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)),
            this, SLOT(setDesktopThemeDirty()));
    connect(m_newThemeButton, SIGNAL(clicked()), this, SLOT(getNewThemes()));
    connect(m_fileInstallButton, &QPushButton::clicked, this, &KCMDesktopTheme::showFileDialog);
}
示例#7
0
void QMLContact::setContact(const QContact& c)
{
    m_contact = c;

    if (m_contactMap) {
        delete m_contactMap;
        m_detailMaps.clear();
    }

    foreach (QObject* detail, m_details) {
        delete detail;
    }
    m_details.clear();

    m_contactMap = new QDeclarativePropertyMap(this);


    QList<QContactDetail> details = m_contact.details();
    foreach (const QContactDetail& detail, details) {
      QMLContactDetail* qd = new QMLContactDetail(this);

      QDeclarativePropertyMap* dm = new QDeclarativePropertyMap(m_contactMap);

      connect(dm, SIGNAL(valueChanged(QString,QVariant)), qd, SLOT(detailChanged(QString,QVariant)));


      QVariantMap values = detail.variantValues();
      foreach (const QString& key, values.keys()) {
          dm->insert(normalizePropertyName(key), values.value(key));
      }
      qd->setName(normalizePropertyName(detail.definitionName()));
      m_details.append(qd);
      qd->setDetailPropertyMap(dm);
      m_detailMaps.append(dm);;
      m_contactMap->insert(normalizePropertyName(detail.definitionName()), QVariant::fromValue(static_cast<QObject*>(dm)));
    }
void QDeclarativeContactDetail::setDetail(const QContactDetail& detail)
{
    m_detail = detail;
    emit detailChanged();
}