Esempio n. 1
0
    bool DirectoryModel::hasChildren(const QModelIndex & idx) const {
        if (canFetchMore(idx)) {
            const_cast<DirectoryModel*>(this)->fetchMore(idx);
        }

        return rowCount(idx) > 0;
    }
Esempio n. 2
0
void ProjectModel::finishMetadataUpdate(ThreadWeaver::Job * _job)
{
    UpdateStatsJob* job = static_cast<UpdateStatsJob *>(_job);

    if (job->m_status == -2)
    {
        delete job;
        return;
    }

    if ((m_dirsWaitingForMetadata.contains(m_activeNode)) && (job->m_status == 0))
    {
        m_dirsWaitingForMetadata.remove(m_activeNode);
        //store the results

        setMetadataForDir(m_activeNode, m_activeJob->m_info);

        QModelIndex item = indexForNode(m_activeNode);

        //scan dubdirs - initiate data loading into the model.
        for (int row=0; row < m_activeNode->rows.count(); row++)
        {
            QModelIndex child = index(row, 0, item);

            if (canFetchMore(child))
                fetchMore(child);
            //QCoreApplication::processEvents();
        }
    }

    delete m_activeJob;

    startNewMetadataJob();
}
Esempio n. 3
0
void ResourcesModel::fetchMore(const QModelIndex &) {
    if (canFetchMore()) {
        Q_D(ResourcesModel);
        
        d->request->get(d->next);
        emit statusChanged(d->request->status());
    }
}
void CollectionAssetsModel::fetchMore(const QModelIndex &parent)
{
    if (!parent.isValid() || !d->session || !canFetchMore(parent) ||
        !d->session->isAuthenticated()) {
        return;
    }

    collectionListAssetsJob *job = d->session->collectionListAssets(d->collectionId, d->assets.count(), DEFAULT_PAGE_SIZE);

    connect(job, SIGNAL(jobFinished(Bodega::NetworkJob *)),
            this, SLOT(assetsJobFinished(Bodega::NetworkJob *)));
}
Esempio n. 5
0
void RemoteModel::fetchMore(const QModelIndex& parent)
{
    // Can we even fetch more data?
    if(!canFetchMore(parent))
       return;

    // Get parent item
    RemoteModelItem* item = static_cast<RemoteModelItem*>(parent.internalPointer());

    // Fetch item URL
    item->setFetchedDirectoryList(true);
    remoteDatabase.fetch(item->value(RemoteModelColumnUrl).toString(), RemoteDatabase::RequestTypeDirectory, currentClientCert, parent);
}
Esempio n. 6
0
bool InventoryItemModel::Open(const QModelIndex &index)
{
    AbstractInventoryItem *item = GetItem(index);

    if (item->GetItemType() == AbstractInventoryItem::Type_Folder)
    {
        fetchMore(index);
        return canFetchMore(index);
    }

    if (item->GetItemType() == AbstractInventoryItem::Type_Asset)
        return dataModel_->OpenItem(item);

    return false;
}
Esempio n. 7
0
bool
DatabaseModel::setData(const QModelIndex& index, const QVariant& value, int /*role*/)
{
	// Only notes can be updated manually
	if (headerData(index.column(), Qt::Horizontal) != "notes")
		return false;

	// TODO: Grab indices in a more robust manner
	QModelIndex repoIndex = this->index(index.row(), 1);
	QModelIndex fileIndex = this->index(index.row(), 2);
	QModelIndex msgIndex = this->index(index.row(), 4);

	// Update error notes. Errors are considered identical if the same message
	// originates from the same file
	QString updateQuery =
			"UPDATE Errors SET notes=? "
			"WHERE file="
			"    (SELECT id FROM Files WHERE file=? AND repo="
			"        (SELECT id FROM Repos WHERE repo=?)"
			"    ) "
			"AND message="
			"    (SELECT id FROM Messages WHERE message=?)";

	QSqlQuery q;
	q.prepare(updateQuery);
	q.addBindValue(value);
	q.addBindValue(data(fileIndex));
	q.addBindValue(data(repoIndex));
	q.addBindValue(data(msgIndex));
	bool ok = q.exec();

	// Refresh. Block modelAboutToBeReset()/modelReset() signals
	// to maintain the views' sort order and scroll position
	if (ok)
	{
		q = this->query();
		q.exec();

		this->blockSignals(true);
		this->setQuery(q);
		while (canFetchMore())
			fetchMore();
		this->blockSignals(false);
	}

	return ok;
}
Esempio n. 8
0
void checkpivotmodel::buildQuery()
{

    QString query,from,where;
    query="select df.runid,df.value";
    from=" from detectorFlag as df";
    where=" where df.tagid=128";
    int colid=2;

    for (unsigned int i=0; i<infocolumns.size(); i++)
    {
        query+=QString(",rd%1.value").arg(i);
        from+=QString(" join rundata as rd%1 on df.runid=rd%1.runid ").arg(i);
        where+=infocolumns[i].clause(QString("rd%1").arg(i));
    }



    for (unsigned int i=0; i<detectorcolumns.size(); i++)
    {
        query+=QString(",df%1.value").arg(i);
        from+=QString(" join detectorFlag as df%1 on df.runid=df%1.runid ").arg(i);
        where+=detectorcolumns[i].clause(QString("df%1").arg(i));
    }


    QString q=query+from+where+addFilter+" group by df.runid order by df.runid";
    setQuery(q);
    while (canFetchMore()) fetchMore();
    setHeaderData(0, Qt::Horizontal, tr("Run ID"));
    setHeaderData(1, Qt::Horizontal, tr("Type"));
    for (unsigned int i=0; i<infocolumns.size(); i++)
    {

        setHeaderData(colid,Qt::Horizontal,infocolumns[i].name );
        colid++;
    }
    firstdetectorcolumn=colid;

    for (unsigned int i=0; i<detectorcolumns.size(); i++)
    {
        setHeaderData(colid,Qt::Horizontal,detectorcolumns[i].name);
        colid++;
    }

}
Esempio n. 9
0
QVariant SqliteTableModel::data(const QModelIndex &index, int role) const
{
    if (!index.isValid())
        return QVariant();

    if (index.row() >= m_rowCount)
        return QVariant();

    if(role == Qt::DisplayRole || role == Qt::EditRole)
    {
        // If this row is not in the cache yet get it first
        while(index.row() >= m_data.size() && canFetchMore())
            const_cast<SqliteTableModel*>(this)->fetchMore();   // Nothing evil to see here, move along

        if(role == Qt::DisplayRole && isBinary(index))
            return "(BLOB)";
        else
            return m_data.at(index.row()).at(index.column());
    } else {
        return QVariant();
    }
}
Esempio n. 10
0
void ImageListModel::preloadAllImages()
{
    QModelIndex parentDummy;
    while (canFetchMore(parentDummy))
        fetchMore(parentDummy);
}
Esempio n. 11
0
void InventoryItemModel::fetchMore(const QModelIndex &parent) const
{
    if (canFetchMore(parent))
        dataModel_->FetchInventoryDescendents(GetItem(parent));
}
Esempio n. 12
0
bool NotificationsModel::hasMore() const
{
    return canFetchMore(QModelIndex());
}
Esempio n. 13
0
void DicomHierarchyModel::fetchMore ( const QModelIndex & parent ) {

    //eventually: check for Volume type first to instead use C-MOVE ;)
    if (!canFetchMore(parent))
        return;

    AbstractDicomHierarchyNode *node = nodeFromIndex(parent);

    //if node already has children: return without contacting the server
    //as data has already been fetched
    if (node->children_.size() > 0)
        return;
    /*
    //remove old studies
    if (node->children_.size() > 0) {
        LERROR("Already found children ;)");
        beginRemoveRows(parent,0,node->children_.size()-1);
        node->children_.clear();
        endRemoveRows();
    }*/
#ifdef VRN_GDCM_VERSION_22 // network support
    switch (node->type_) {
    case AbstractDicomHierarchyNode::PATIENT: {
        std::vector<StudyInfo> studies;
        try {
            //find all studies
            studies = gdcmReader_->findNetworkStudies(url_,scpAet_,scpPort_,node->getDicomHierarchyID());
        }
        catch (tgt::FileException e) {
            LERROR(e.what());
            QMessageBox::warning(0,"Could not find studies", e.what());
            return;
        }

        //insert all studies
        beginInsertRows(parent, 0, static_cast<int>(studies.size()-1));

        for (std::vector<StudyInfo>::iterator it = studies.begin(); it != studies.end(); ++it) {
            StudyHierarchyNode* child = new StudyHierarchyNode(AbstractDicomHierarchyNode::STUDY,*it);
            child->parent_ = node;
            node->children_.append(child);
        }
        endInsertRows();
        break;
    }
    case AbstractDicomHierarchyNode::STUDY: {
        std::vector<SeriesInfo> series;
        try {
            //find all series
            series = gdcmReader_->findNetworkSeries(url_,scpAet_,scpPort_,node->parent_->getDicomHierarchyID(),node->getDicomHierarchyID());
        }
        catch (tgt::FileException e) {
            LERROR(e.what());
            QMessageBox::warning(0,"Could not find series", e.what());
            return;
        }

        //insert all studies
        beginInsertRows(parent,0, static_cast<int>(series.size()-1));

        for (std::vector<SeriesInfo>::iterator it = series.begin(); it != series.end(); ++it) {
            SeriesHierarchyNode* child = new SeriesHierarchyNode(AbstractDicomHierarchyNode::SERIES,*it);
            child->parent_ = node;
            node->children_.append(child);
        }
        endInsertRows();
        break;
    }
    default:
        //Do nothing ;)
        break;
    }
#endif
}
Esempio n. 14
0
bool DhQDirModel::DvhcanFetchMore(const QModelIndex& x1) const {
  return canFetchMore(x1);
}
Esempio n. 15
0
bool DhQAbstractTableModel::DvhcanFetchMore(const QModelIndex& x1) const {
  return canFetchMore(x1);
}