Ejemplo n.º 1
0
QList<QPair<QString, QString> > Transfers::findByStates(TransferListView* l, QList<uint> states) {
	QList<QPair<QString, QString> > items;
	QTreeWidgetItemIterator it(mPoppedUpload ? mUploads : mDownloads, QTreeWidgetItemIterator::Selectable);
	for(; *it; ++it) {
		TransferListItem* item = dynamic_cast<TransferListItem*>(*it);
		if(item && states.contains(item->state()))
			items += QPair<QString, QString>(item->user(), item->path());
	}
	return items;
}
Ejemplo n.º 2
0
TransferListItem* TransferListView::findTransfer(const QString& _u, const QString& _p) {
    QTreeWidgetItemIterator it(this);
    while (*it) {
        TransferListItem * item = dynamic_cast<TransferListItem *>(*it);
        if (item && (item->user().compare(_u) == 0) && (item->path().compare(_p) == 0))
            return item;
        it++;
    }

    return NULL;
}
Ejemplo n.º 3
0
QList<QPair<QString, QString> > Transfers::findSelected(TransferListView* l) {
	QList<QPair<QString, QString> > items;
	QTreeWidgetItemIterator it(mPoppedUpload ? mUploads : mDownloads, QTreeWidgetItemIterator::Selected | QTreeWidgetItemIterator::NotHidden);
	for(; *it; ++it) {
		TransferListItem* item = dynamic_cast<TransferListItem*>(*it);
		if (!item)
            continue;

		if (!item->path().isEmpty())
            items += QPair<QString, QString>(item->user(), item->path());
        else {
            // We would like to delete a group of transfers
            int numChildren = item->childCount();
            for(int childId = 0; childId < numChildren; childId++) {
                TransferListItem* child = dynamic_cast<TransferListItem*>(item->child(childId));
                if (child)
                    items += QPair<QString, QString>(child->user(), child->path());
            }
        }
	}
	return items;
}
Ejemplo n.º 4
0
TransferListItem* TransferListView::findParent(const QString& user) {
    if (mGroupMode == None)
        return static_cast<TransferListItem *>(invisibleRootItem());

    TransferListItem * parent = 0;
    QList<QTreeWidgetItem *> Groups = TransferListView::findItems(user, Qt::MatchExactly, 0);
    QList<QTreeWidgetItem *>::iterator transfers_it = Groups.begin();
    for(; transfers_it != Groups.end();  ++transfers_it) {
        TransferListItem * trans = dynamic_cast<TransferListItem *>(*transfers_it);
        if (trans && trans->path().isNull()) {
            parent = trans;
        }
    }

    if (! parent)
        parent = new TransferListItem(this, user, QString::null);

    addTopLevelItem(parent);
    return parent;

}
Ejemplo n.º 5
0
void TransferListView::remove(const QString& _u, const QString& _p) {
    TransferListItem* item = findTransfer(_u, _p);
    if (! item )
        return;

    if(item->user() == _u && (mGroupMode != None || item->path() == _p)) {
        if(mGroupMode == None) {
            museeq->output("delete item");
            delete item;
        } else {
            delete item;
            TransferListItem* parent = findParent(_u);
            if(parent->childCount() == 0)
                delete parent;
            else
                parent->updateStats();
        }
        return;
    }

}
Ejemplo n.º 6
0
void Transfers::retrySelected() {
	QList<QPair<QString, QPair<QString, qint64> > > items;
	QTreeWidgetItemIterator it(mPoppedUpload ? mUploads : mDownloads, QTreeWidgetItemIterator::Selected | QTreeWidgetItemIterator::NotHidden);
	for(; *it; ++it) {
		TransferListItem* item = dynamic_cast<TransferListItem*>(*it);
		if (item)
            items += QPair<QString, QPair<QString, qint64> >(item->user(), QPair<QString, qint64>(item->path(), item->size()));
	}

	QList<QPair<QString, QPair<QString, qint64> > >::iterator sit = items.begin();
	for(; sit != items.end(); ++sit) {
		if(mPoppedUpload)
			museeq->uploadFile((*sit).first, (*sit).second.first);
		else
			museeq->downloadFile((*sit).first, (*sit).second.first, (*sit).second.second);
	}
}