Пример #1
0
void KPageWidgetModel::addSubPage(KPageWidgetItem *parent, KPageWidgetItem *item)
{
    PageItem *parentPageItem = d_func()->rootItem->findChild(parent);
    if (!parentPageItem) {
        qDebug("Invalid KPageWidgetItem passed!");
        return;
    }

    emit layoutAboutToBeChanged();

    connect(item, SIGNAL(changed()), this, SLOT(_k_itemChanged()));
    connect(item, SIGNAL(toggled(bool)), this, SLOT(_k_itemToggled(bool)));

    // The row to be inserted
    int row = parentPageItem->childCount();

    QModelIndex index;
    if (parentPageItem != d_func()->rootItem) {
        index = createIndex(parentPageItem->row(), 0, parentPageItem);
    }

    beginInsertRows(index, row, row);

    PageItem *newPageItem = new PageItem(item, parentPageItem);
    parentPageItem->appendChild(newPageItem);

    endInsertRows();

    emit layoutChanged();
}
Пример #2
0
void DConfigDlgWdgModel::removePage(DConfigDlgWdgItem* item)
{
    if (!item)
    {
        return;
    }

    Q_D(DConfigDlgWdgModel);

    PageItem* const pageItem = d->rootItem->findChild(item);

    if (!pageItem)
    {
        qCDebug(DIGIKAM_GENERAL_LOG) << "Invalid DConfigDlgWdgItem passed!";
        return;
    }

    emit layoutAboutToBeChanged();

    disconnect(item, SIGNAL(changed()),
               this, SLOT(_k_itemChanged()));

    disconnect(item, SIGNAL(toggled(bool)),
               this, SLOT(_k_itemToggled(bool)));

    PageItem* const parentPageItem = pageItem->parent();
    int row                        = parentPageItem->row();

    QModelIndex index;

    if (parentPageItem != d->rootItem)
    {
        index = createIndex(row, 0, parentPageItem);
    }

    beginRemoveRows(index, pageItem->row(), pageItem->row());

    parentPageItem->removeChild(pageItem->row());
    delete pageItem;

    endRemoveRows();

    emit layoutChanged();
}
Пример #3
0
void KPageWidgetModel::addPage(KPageWidgetItem *item)
{
    emit layoutAboutToBeChanged();

    Q_D(KPageWidgetModel);
    connect(item, SIGNAL(changed()), this, SLOT(_k_itemChanged()));
    connect(item, SIGNAL(toggled(bool)), this, SLOT(_k_itemToggled(bool)));

    // The row to be inserted
    int row = d->rootItem->childCount();

    beginInsertRows(QModelIndex(), row, row);

    PageItem *pageItem = new PageItem(item, d->rootItem);
    d->rootItem->appendChild(pageItem);

    endInsertRows();

    emit layoutChanged();
}
Пример #4
0
void DConfigDlgWdgModel::insertPage(DConfigDlgWdgItem* before, DConfigDlgWdgItem* item)
{
    PageItem* const beforePageItem = d_func()->rootItem->findChild(before);

    if (!beforePageItem)
    {
        qCDebug(DIGIKAM_GENERAL_LOG) << "Invalid DConfigDlgWdgItem passed!";
        return;
    }

    emit layoutAboutToBeChanged();

    connect(item, SIGNAL(changed()),
            this, SLOT(_k_itemChanged()));

    connect(item, SIGNAL(toggled(bool)),
            this, SLOT(_k_itemToggled(bool)));

    PageItem* const parent = beforePageItem->parent();
    // The row to be inserted
    int row                = beforePageItem->row();

    QModelIndex index;

    if (parent != d_func()->rootItem)
    {
        index = createIndex(parent->row(), 0, parent);
    }

    beginInsertRows(index, row, row);

    PageItem* const newPageItem = new PageItem(item, parent);
    parent->insertChild(row, newPageItem);

    endInsertRows();

    emit layoutChanged();
}
Пример #5
0
void KPageWidgetModel::removePage(KPageWidgetItem *item)
{
    if (!item) {
        return;
    }

    Q_D(KPageWidgetModel);

    PageItem *pageItem = d->rootItem->findChild(item);
    if (!pageItem) {
        qDebug("Invalid KPageWidgetItem passed!");
        return;
    }

    emit layoutAboutToBeChanged();

    disconnect(item, SIGNAL(changed()), this, SLOT(_k_itemChanged()));
    disconnect(item, SIGNAL(toggled(bool)), this, SLOT(_k_itemToggled(bool)));

    PageItem *parentPageItem = pageItem->parent();
    int row = parentPageItem->row();

    QModelIndex index;
    if (parentPageItem != d->rootItem) {
        index = createIndex(row, 0, parentPageItem);
    }

    beginRemoveRows(index, pageItem->row(), pageItem->row());

    parentPageItem->removeChild(pageItem->row());
    delete pageItem;

    endRemoveRows();

    emit layoutChanged();
}