Пример #1
0
/** Saves the changes on this page */
bool SoundPage::save(QString &/*errmsg*/)
{
	QTreeWidgetItemIterator itemIterator(ui.eventTreeWidget);
	QTreeWidgetItem *item = NULL;
	while ((item = *itemIterator) != NULL) {
		itemIterator++;

		if (item->type() == TYPE_ITEM) {
			const QString event = item->data(COLUMN_DATA, ROLE_EVENT).toString();
			soundManager->setEventEnabled(event, item->checkState(COLUMN_NAME) == Qt::Checked);
			soundManager->setEventFilename(event, item->text(COLUMN_FILENAME));
		}
	}

	return true;
}
Пример #2
0
/**
 * @brief RsCollectionDialog::download: Start downloading checked items
 */
void RsCollectionDialog::download()
{
	std::cerr << "Downloading!" << std::endl;

	QString dldir = QString::fromUtf8(rsFiles->getDownloadDirectory().c_str()) ;

	std::cerr << "downloading all these files:" << std::endl;

	QTreeWidgetItemIterator itemIterator(ui._fileEntriesTW);
	QTreeWidgetItem *item;
	while ((item = *itemIterator) != NULL) {
		++itemIterator;

		if (item->checkState(COLUMN_FILE) == Qt::Checked) {
			std::cerr << item->data(COLUMN_HASH,ROLE_NAME).toString().toStdString()
			          << " " << item->text(COLUMN_HASH).toStdString()
			          << " " << item->text(COLUMN_SIZE).toStdString()
			          << " " << item->data(COLUMN_HASH,ROLE_PATH).toString().toStdString() << std::endl;
			ColFileInfo colFileInfo;
			colFileInfo.hash = item->text(COLUMN_HASH);
			colFileInfo.name = item->data(COLUMN_HASH,ROLE_NAME).toString();
			colFileInfo.path = item->data(COLUMN_HASH,ROLE_PATH).toString();
			colFileInfo.type = item->data(COLUMN_HASH,ROLE_TYPE).toUInt();
			colFileInfo.size = item->data(COLUMN_SIZE,ROLE_SELSIZE).toULongLong();

			QString cleanPath = dldir + colFileInfo.path ;
			std::cerr << "making directory " << cleanPath.toStdString() << std::endl;

			if(!QDir(QApplication::applicationDirPath()).mkpath(cleanPath))
				QMessageBox::warning(NULL,QObject::tr("Unable to make path"),QObject::tr("Unable to make path:")+"<br>  "+cleanPath) ;

			if (colFileInfo.type==DIR_TYPE_FILE)
				rsFiles->FileRequest(colFileInfo.name.toUtf8().constData(),
				                     RsFileHash(colFileInfo.hash.toStdString()),
				                     colFileInfo.size,
				                     cleanPath.toUtf8().constData(),
				                     RS_FILE_REQ_ANONYMOUS_ROUTING,
				                     std::list<RsPeerId>());
		} else {//if (item->checkState(COLUMN_FILE) == Qt::Checked)
			std::cerr<<"Skipping file : " << item->data(COLUMN_HASH,ROLE_NAME).toString().toStdString() << std::endl;
		}//if (item->checkState(COLUMN_FILE) == Qt::Checked)
	}//while ((item = *itemIterator) != NULL)

	close();
}
Пример #3
0
void CardItem::drawArrow(const QColor &arrowColor)
{
    if (static_cast<TabGame *>(owner->parent())->getSpectator())
        return;
    
    Player *arrowOwner = static_cast<TabGame *>(owner->parent())->getActiveLocalPlayer();
    ArrowDragItem *arrow = new ArrowDragItem(arrowOwner, this, arrowColor);
    scene()->addItem(arrow);
    arrow->grabMouse();
    
    QListIterator<QGraphicsItem *> itemIterator(scene()->selectedItems());
    while (itemIterator.hasNext()) {
        CardItem *c = qgraphicsitem_cast<CardItem *>(itemIterator.next());
        if (!c || (c == this))
            continue;
        if (c->getZone() != zone)
            continue;
        
        ArrowDragItem *childArrow = new ArrowDragItem(arrowOwner, c, arrowColor);
        scene()->addItem(childArrow);
        arrow->addChildArrow(childArrow);
    }
}
HRESULT GetIDListName(IShellItem *psi, PWSTR *ppsz)
{
    *ppsz = NULL;
    HRESULT hr = E_FAIL;

    WCHAR szFullName[2048];
    szFullName[0] = 0;
    PWSTR pszOutput = szFullName;
    size_t cchOutput = ARRAYSIZE(szFullName);

    CItemIterator itemIterator(psi);
    while (itemIterator.MoveNext())
    {
        IShellItem2 *psi;
        hr = itemIterator.GetCurrent(IID_PPV_ARGS(&psi));
        if (SUCCEEDED(hr))
        {
            PWSTR pszName;
            hr = psi->GetDisplayName(SIGDN_PARENTRELATIVE, &pszName);
            if (SUCCEEDED(hr))
            {
                // Ignore errors, this is for debugging only
                StringCchCatEx(pszOutput, cchOutput, L"[", &pszOutput, &cchOutput, 0);
                StringCchCatEx(pszOutput, cchOutput, pszName, &pszOutput, &cchOutput, 0);
                StringCchCatEx(pszOutput, cchOutput, L"]", &pszOutput, &cchOutput, 0);
                CoTaskMemFree(pszName);
            }
            psi->Release();
        }
    }

    if (SUCCEEDED(hr))
    {
        hr = SHStrDup(szFullName, ppsz);
    }
    return hr;
}
Пример #5
0
void IdDialog::insertIdList(uint32_t token)
{
	mStateHelper->setLoading(IDDIALOG_IDLIST, false);

	int accept = ui->filterComboBox->itemData(ui->filterComboBox->currentIndex()).toInt();

	RsGxsIdGroup data;
	std::vector<RsGxsIdGroup> datavector;
	std::vector<RsGxsIdGroup>::iterator vit;
	if (!rsIdentity->getGroupData(token, datavector))
	{
#ifdef ID_DEBUG
		std::cerr << "IdDialog::insertIdList() Error getting GroupData";
		std::cerr << std::endl;
#endif

		mStateHelper->setActive(IDDIALOG_IDLIST, false);
		mStateHelper->clear(IDDIALOG_IDLIST);

		return;
	}

	mStateHelper->setActive(IDDIALOG_IDLIST, true);

	RsPgpId ownPgpId  = rsPeers->getGPGOwnId();

	/* Update existing and remove not existing items */
	QTreeWidgetItemIterator itemIterator(ui->idTreeWidget);
	QTreeWidgetItem *item = NULL;
	while ((item = *itemIterator) != NULL) {
		++itemIterator;

		for (vit = datavector.begin(); vit != datavector.end(); ++vit)
		{
			if (vit->mMeta.mGroupId == RsGxsGroupId(item->text(RSID_COL_KEYID).toStdString()))
			{
				break;
			}
		}
		if (vit == datavector.end())
		{
			delete(item);
		} else {
			if (!fillIdListItem(*vit, item, ownPgpId, accept))
			{
				delete(item);
			}
			datavector.erase(vit);
		}
	}

	/* Insert new items */
	for (vit = datavector.begin(); vit != datavector.end(); ++vit)
	{
		data = (*vit);

		item = NULL;
		if (fillIdListItem(*vit, item, ownPgpId, accept))
		{
			ui->idTreeWidget->addTopLevelItem(item);
		}
	}

	filterIds();

	updateSelection();
}
void CFavoriteLocationsEditor::contextMenu(const QPoint & pos)
{
	auto item = dynamic_cast<CFavoriteLocationsListItem*>(ui->_list->itemAt(pos));
	QMenu menu;
	QAction * addItemAction = nullptr;
	if (!item || item->isCategory())
		addItemAction = menu.addAction(tr("Add item..."));
	else
	{
		addItemAction = menu.addAction(tr("You can only add nested items to categories, not to end items"));
		addItemAction->setEnabled(false);
	}

	connect(addItemAction, &QAction::triggered, [this, item](){
		CNewFavoriteLocationDialog dialog(this, false);
		if (dialog.exec() == QDialog::Accepted)
		{
			std::list<CLocationsCollection>& list = item ? item->itemIterator()->subLocations : _locations.locations();
			if (std::find_if(list.cbegin(), list.cend(), [&dialog](const CLocationsCollection& entry){return entry.absolutePath == dialog.location();}) != list.cend())
			{
				QMessageBox::information(dynamic_cast<QWidget*>(parent()), tr("Similar item already exists"), tr("This item already exists here (possibly under a different name)."), QMessageBox::Cancel);
				return;
			}
			else if (std::find_if(list.cbegin(), list.cend(), [&dialog](const CLocationsCollection& entry){return entry.displayName == dialog.name();}) != list.cend())
			{
				QMessageBox::information(dynamic_cast<QWidget*>(parent()), tr("Similar item already exists"), tr("And item with the same name already exists here (possibly pointing to a different location)."), QMessageBox::Cancel);
				return;
			}

			_locations.addItem(list, dialog.name(), dialog.location());

			if (item)
			{
				new CFavoriteLocationsListItem(item, list, --list.end(), false);
				item->setExpanded(true);
			}
			else
				new CFavoriteLocationsListItem(ui->_list, list, --list.end(), false);
		}
	});

	connect(menu.addAction(tr("Add category...")), &QAction::triggered, [this, item](){
		CNewFavoriteLocationDialog dialog(this, true);
		if (dialog.exec() == QDialog::Accepted)
		{
			std::list<CLocationsCollection>& list = item ? item->itemIterator()->subLocations : _locations.locations();
			if (std::find_if(list.cbegin(), list.cend(), [&dialog](const CLocationsCollection& entry){return entry.displayName == dialog.name();}) != list.cend())
			{
				QMessageBox::information(dynamic_cast<QWidget*>(parent()), tr("Similar item already exists"), tr("And item with the same name already exists here (possibly pointing to a different location)."), QMessageBox::Cancel);
				return;
			}

			_locations.addItem(list, dialog.name());
			if (item)
			{
				new CFavoriteLocationsListItem(item, list, --list.end(), true);
				item->setExpanded(true);
			}
			else
				new CFavoriteLocationsListItem(ui->_list, list, --list.end(), true);
		}
	});

	if (item)
	{
		connect(menu.addAction(tr("Remove item")), &QAction::triggered, [this, item]() {
			if (item->isCategory())
			{
				if (QMessageBox::question(this, tr("Delete the item?"), tr("Are you sure you want to delete this category and all its sub-items?")) == QMessageBox::Yes)
				{
					item->list().erase(item->itemIterator());
					delete item;
				}
			}
			else
			{
				item->list().erase(item->itemIterator());
				delete item;
			}

			_locations.save();
		});
	}

	menu.exec(ui->_list->mapToGlobal(pos));
}