Exemplo n.º 1
0
void SectionDataModel::setModel(QAbstractItemModel *model)
{
    if (model == m_model)
        return;

    if (m_model) {
        disconnect(m_model, SIGNAL(modelReset()), this, SLOT(buildSectionMap()));
        disconnect(m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(handleRowsInserted(QModelIndex,int,int)));
        disconnect(m_model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), this, SLOT(handleRowsMoved(QModelIndex,int,int,QModelIndex,int)));
        disconnect(m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(handleRowsRemoved(QModelIndex,int,int)));
        disconnect(m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(handleDataChanged(QModelIndex,QModelIndex)));
    }

    m_model = model;

    if (m_model) {
        connect(m_model, SIGNAL(modelReset()), SLOT(buildSectionMap()));
        connect(m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), SLOT(handleRowsInserted(QModelIndex,int,int)));
        connect(m_model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)), SLOT(handleRowsMoved(QModelIndex,int,int,QModelIndex,int)));
        connect(m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), SLOT(handleRowsRemoved(QModelIndex,int,int)));
        connect(m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), SLOT(handleDataChanged(QModelIndex,QModelIndex)));

        setRoleNames(m_model->roleNames());
    } else {
        setRoleNames(QHash<int, QByteArray>());
    }

    if (!m_sectionKey.isEmpty()) {
        m_sectionRole = roleNames().key(m_sectionKey.toLatin1());
    }

    emit modelChanged();

    buildSectionMap();
}
	UpdatesNotificationManager::UpdatesNotificationManager (PackagesModel *model,
			ICoreProxy_ptr proxy, QObject *parent)
	: QObject (parent)
	, PM_ (model)
	, Proxy_ (proxy)
	, NotifyScheduled_ (false)
	{
		connect (model,
				SIGNAL (dataChanged (QModelIndex, QModelIndex)),
				this,
				SLOT (handleDataChanged (QModelIndex, QModelIndex)));
		if (const auto rc = model->rowCount ())
			handleDataChanged (model->index (0, 0), model->index (rc - 1, 0));
	}
Exemplo n.º 3
0
void MessageView::setEmpty()
{
    markAsReadTimer->stop();
    m_envelope->setMessage(QModelIndex());
    headerSection->hide();
    message = QModelIndex();
    disconnect(this, SLOT(handleDataChanged(QModelIndex,QModelIndex)));
    tags->hide();
    if (viewer != emptyView) {
        layout->removeWidget(viewer);
        viewer->deleteLater();
        viewer = emptyView;
        viewer->show();
        layout->addWidget(viewer);
        emit messageChanged();
        m_loadingItems.clear();
        m_loadingSpinner->stop();
    }
}
Exemplo n.º 4
0
QDeclarativeFolderListModel::QDeclarativeFolderListModel(QObject *parent)
    : QAbstractListModel(parent)
{
    QHash<int, QByteArray> roles;
    roles[FileNameRole] = "fileName";
    roles[FilePathRole] = "filePath";
    setRoleNames(roles);

    d = new QDeclarativeFolderListModelPrivate;
    d->model.setFilter(QDir::AllDirs | QDir::Files | QDir::Drives | QDir::NoDotAndDotDot);
    connect(&d->model, SIGNAL(rowsInserted(QModelIndex,int,int))
            , this, SLOT(inserted(QModelIndex,int,int)));
    connect(&d->model, SIGNAL(rowsRemoved(QModelIndex,int,int))
            , this, SLOT(removed(QModelIndex,int,int)));
    connect(&d->model, SIGNAL(dataChanged(QModelIndex,QModelIndex))
            , this, SLOT(handleDataChanged(QModelIndex,QModelIndex)));
    connect(&d->model, SIGNAL(modelReset()), this, SLOT(refresh()));
    connect(&d->model, SIGNAL(layoutChanged()), this, SLOT(refresh()));
}
Exemplo n.º 5
0
void MessageView::setMessage(const QModelIndex &index)
{
    // first, let's get a real model
    QModelIndex messageIndex;
    const Imap::Mailbox::Model *constModel = 0;
    Imap::Mailbox::TreeItem *item = Imap::Mailbox::Model::realTreeItem(index, &constModel, &messageIndex);
    Q_ASSERT(item); // Make sure it's a message
    Q_ASSERT(messageIndex.isValid());
    Imap::Mailbox::Model *realModel = const_cast<Imap::Mailbox::Model *>(constModel);
    Q_ASSERT(realModel);

    // The data might be available from the local cache, so let's try to save a possible roundtrip here
    item->fetch(realModel);

    if (!messageIndex.data(Imap::Mailbox::RoleIsFetched).toBool()) {
        // This happens when the message placeholder is already available in the GUI, but the actual message data haven't been
        // loaded yet. This is especially common with the threading model.
        // Note that the data might be already available in the cache, it's just that it isn't in the mailbox tree yet.
        setEmpty();
        connect(realModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(handleDataChanged(QModelIndex,QModelIndex)));
        message = messageIndex;
        return;
    }

    QModelIndex rootPartIndex = messageIndex.child(0, 0);

    headerSection->show();
    if (message != messageIndex) {
        emptyView->hide();
        layout->removeWidget(viewer);
        if (viewer != emptyView) {
            viewer->setParent(0);
            viewer->deleteLater();
        }
        message = messageIndex;
        netAccess->setExternalsEnabled(false);
        externalElements->hide();

        netAccess->setModelMessage(message);

        m_loadingItems.clear();
        m_loadingSpinner->stop();

        PartWidgetFactory::PartLoadingOptions loadingMode;
        if (m_settings->value(Common::SettingsNames::guiPreferPlaintextRendering, QVariant(true)).toBool())
            loadingMode |= PartWidgetFactory::PART_PREFER_PLAINTEXT_OVER_HTML;
        viewer = factory->create(rootPartIndex, 0, loadingMode);
        viewer->setParent(this);
        layout->addWidget(viewer);
        viewer->show();
        m_envelope->setMessage(message);

        tags->show();
        tags->setTagList(messageIndex.data(Imap::Mailbox::RoleMessageFlags).toStringList());
        disconnect(this, SLOT(handleDataChanged(QModelIndex,QModelIndex)));
        connect(realModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(handleDataChanged(QModelIndex,QModelIndex)));

        emit messageChanged();

        // We want to propagate the QWheelEvent to upper layers
        viewer->installEventFilter(this);
    }

    if (realModel->isNetworkAvailable())
        markAsReadTimer->start(200); // FIXME: make this configurable
}
Exemplo n.º 6
0
WorkflowEditor::WorkflowEditor(WorkflowView *p)
    : QWidget(p),
      owner(p),
      custom(NULL),
      customWidget(NULL),
      subject(NULL),
      actor(NULL),
      onFirstTableShow(true)
{
    GCOUNTER( cvar, tvar, "WorkflowEditor" );
    setupUi(this);

    specialParameters = new SpecialParametersPanel(this);
    tableSplitter->insertWidget(0, specialParameters);
    specialParameters->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
    table->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
    specialParameters->hide();

#ifdef Q_OS_MAC
    QString style("QGroupBox::title {margin-top: 1px; margin-left: 15px;}");
    editorBox->setStyleSheet(style);
#endif

    QVBoxLayout *inputScrollAreaContainerLayout = new QVBoxLayout();
    inputScrollAreaContainerLayout->setContentsMargins(0, 0, 0, 0);
    inputScrollAreaContainerLayout->setSpacing(0);
    inputScrollAreaContainerLayout->setSizeConstraint(QLayout::SetMinAndMaxSize);
    inputScrollAreaContainer->setLayout(inputScrollAreaContainerLayout);

    inputPortBox->setEnabled(false);
    inputPortBox->setVisible(true);
    connect(inputPortBox, SIGNAL(toggled(bool)), SLOT(sl_changeVisibleInput(bool)));

    QVBoxLayout *outputScrollAreaContainerLayout = new QVBoxLayout();
    outputScrollAreaContainerLayout->setContentsMargins(0, 0, 0, 0);
    outputScrollAreaContainerLayout->setSpacing(0);
    outputScrollAreaContainerLayout->setSizeConstraint(QLayout::SetMinAndMaxSize);
    outputScrollAreaContainer->setLayout(outputScrollAreaContainerLayout);

    outputPortBox->setEnabled(false);
    outputPortBox->setVisible(true);
    connect(outputPortBox, SIGNAL(toggled(bool)), SLOT(sl_changeVisibleOutput(bool)));

    caption->setMinimumHeight(nameEdit->sizeHint().height());

    actorModel = new ActorCfgModel(this, owner);
    proxyModel = new ActorCfgFilterProxyModel(this);
    proxyModel->setSourceModel(actorModel);
    table->setModel(proxyModel);

    table->horizontalHeader()->setSectionsClickable(false);
    table->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);

    table->verticalHeader()->hide();
    table->verticalHeader()->setDefaultSectionSize(QFontMetrics(QFont()).height() + 6);
    table->setItemDelegate(new SuperDelegate(this));
    table->installEventFilter(this);

    reset();

    doc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    propDoc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    doc->installEventFilter(this);

    connect(nameEdit, SIGNAL(editingFinished()), SLOT(editingLabelFinished()));

    connect(table->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), SLOT(sl_showPropDoc()));
    connect(table->model(), SIGNAL(dataChanged(QModelIndex, QModelIndex)), SLOT(handleDataChanged(QModelIndex, QModelIndex)));
    // FIXME
    //connect(doc, SIGNAL(customContextMenuRequested(const QPoint &)), SLOT(sl_contextMenuForDoc(const QPoint &)));
    table->setTabKeyNavigation(true);
}
Exemplo n.º 7
0
int QDeclarativeFolderListModel::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QAbstractListModel::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: folderChanged(); break;
        case 1: countChanged(); break;
        case 2: refresh(); break;
        case 3: inserted((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 4: removed((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 5: handleDataChanged((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< const QModelIndex(*)>(_a[2]))); break;
        case 6: { bool _r = isFolder((*reinterpret_cast< int(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        default: ;
        }
        _id -= 7;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QUrl*>(_v) = folder(); break;
        case 1: *reinterpret_cast< QUrl*>(_v) = parentFolder(); break;
        case 2: *reinterpret_cast< QStringList*>(_v) = nameFilters(); break;
        case 3: *reinterpret_cast< SortField*>(_v) = sortField(); break;
        case 4: *reinterpret_cast< bool*>(_v) = sortReversed(); break;
        case 5: *reinterpret_cast< bool*>(_v) = showDirs(); break;
        case 6: *reinterpret_cast< bool*>(_v) = showDotAndDotDot(); break;
        case 7: *reinterpret_cast< bool*>(_v) = showOnlyReadable(); break;
        case 8: *reinterpret_cast< int*>(_v) = count(); break;
        }
        _id -= 9;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setFolder(*reinterpret_cast< QUrl*>(_v)); break;
        case 2: setNameFilters(*reinterpret_cast< QStringList*>(_v)); break;
        case 3: setSortField(*reinterpret_cast< SortField*>(_v)); break;
        case 4: setSortReversed(*reinterpret_cast< bool*>(_v)); break;
        case 5: setShowDirs(*reinterpret_cast< bool*>(_v)); break;
        case 6: setShowDotAndDotDot(*reinterpret_cast< bool*>(_v)); break;
        case 7: setShowOnlyReadable(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 9;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 9;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 9;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 9;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 9;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 9;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 9;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}