MCPcopy Create free account
hub / github.com/KDE/kwin / setSource

Method setSource

src/debug_console.cpp:1729–1757  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1727}
1728
1729void DataSourceModel::setSource(AbstractDataSource *source)
1730{
1731 beginResetModel();
1732 m_source = source;
1733 m_data.clear();
1734 if (source) {
1735 const QStringList mimeTypes = m_source->mimeTypes();
1736 m_data.resize(mimeTypes.size());
1737 for (auto type = mimeTypes.begin(); type != mimeTypes.end(); ++type) {
1738 std::optional<Pipe> pipe = Pipe::create(O_CLOEXEC);
1739 if (!pipe) {
1740 continue;
1741 }
1742 source->requestData(*type, std::move(pipe->writeEndpoint));
1743 QFuture<QByteArray> data = QtConcurrent::run(readData, pipe->readEndpoint.take());
1744 auto watcher = new QFutureWatcher<QByteArray>(this);
1745 watcher->setFuture(data);
1746 const int index = type - mimeTypes.begin();
1747 connect(watcher, &QFutureWatcher<QByteArray>::finished, this, [this, watcher, index, source = QPointer(source)] {
1748 watcher->deleteLater();
1749 if (source && source == m_source) {
1750 m_data[index] = watcher->result();
1751 Q_EMIT dataChanged(this->index(index, 1), this->index(index, 1), {Qt::DecorationRole | Qt::DisplayRole});
1752 }
1753 });
1754 }
1755 }
1756 endResetModel();
1757}
1758
1759DebugConsoleEffectItem::DebugConsoleEffectItem(const QString &name, bool loaded, QWidget *parent)
1760 : QWidget(parent)

Callers 1

DebugConsoleMethod · 0.45

Calls 11

createFunction · 0.70
clearMethod · 0.45
mimeTypesMethod · 0.45
resizeMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
requestDataMethod · 0.45
takeMethod · 0.45
resultMethod · 0.45
indexMethod · 0.45

Tested by

no test coverage detected