示例#1
0
void mythfile_open_register_callback(const char *pathname, void* object,
                                     callback_t func)
{
    m_callbackLock.lock();
    QString path(pathname);
    if (m_fileOpenCallbacks.contains(path))
    {
        // if we already have a callback registered for this path with this
        // object then remove the callback and return (i.e. end callback)
        QMutableHashIterator<QString,Callback> it(m_fileOpenCallbacks);
        while (it.hasNext())
        {
            it.next();
            if (object == it.value().m_object)
            {
                it.remove();
                VERBOSE(VB_PLAYBACK, LOC +
                    QString("Removing fileopen callback for %1").arg(path));
                VERBOSE(VB_PLAYBACK, LOC + QString("%1 callbacks remaining")
                    .arg(m_fileOpenCallbacks.size()));
                m_callbackLock.unlock();
                return;
            }
        }
    }

    Callback new_callback(object, func);
    m_fileOpenCallbacks.insert(path, new_callback);
    VERBOSE(VB_PLAYBACK, LOC +
        QString("Added fileopen callback for %1").arg(path));
    VERBOSE(VB_PLAYBACK, LOC + QString("%1 callbacks open")
        .arg(m_fileOpenCallbacks.size()));

    m_callbackLock.unlock();
}
示例#2
0
void tst_QVersitDocument::testRemoveProperty()
{
    // Remove an empty property.
    QCOMPARE(mVersitDocument->properties().count(), 0);
    QVersitProperty property;
    mVersitDocument->addProperty(property);
    mVersitDocument->removeProperty(property);
    QCOMPARE(mVersitDocument->properties().count(), 0);

    // A full property.
    property.setName(QLatin1String("TEL"));
    property.setGroups(QStringList(QLatin1String("HOME")));
    QMultiHash<QString, QString> params;
    params.insert(QLatin1String("TYPE"), QLatin1String("HOME"));
    property.setParameters(params);
    property.setValue(QLatin1String("123"));
    mVersitDocument->addProperty(property);
    QCOMPARE(mVersitDocument->properties().count(), 1);
    QVersitProperty property2;
    property2.setName(QLatin1String("TEL"));
    // Remove with a partial property fails.
    mVersitDocument->removeProperty(property2);
    QCOMPARE(mVersitDocument->properties().count(), 1);
    property2.setGroups(QStringList(QLatin1String("HOME")));
    property2.setParameters(params);
    property2.setValue(QLatin1String("123"));
    // Remove with a fully specified property succeeds.
    mVersitDocument->removeProperty(property2);
    QCOMPARE(mVersitDocument->properties().count(), 0);
}
void CDspVmAutoTaskManagerBase::Init()
{
	WRITE_TRACE( DBG_DEBUG, "Initializing %s manager", getManagerName() );

	QMultiHash<QString , SmartPtr<CVmConfiguration> > hashAllVms
		= CDspService::instance()->getVmDirHelper().getAllVmList();

	QMultiHash<QString , SmartPtr<CVmConfiguration> >::iterator it;
	for(it = hashAllVms.begin(); it != hashAllVms.end(); ++it)
	{
		SmartPtr<CVmConfiguration> pVmConfig = it.value();
		PRL_ASSERT(pVmConfig);

		if (isEnabled(pVmConfig, true))
		{
			PRL_RESULT res = tryToRegisterVm(pVmConfig, it.key());
			if (PRL_FAILED(res))
				WRITE_TRACE(DBG_FATAL,
					"Can't register VM %s in Auto-task Manager during starting dispetcher."
					"Error: 0x%x, (%s).",
					QSTR2UTF8(pVmConfig->getVmIdentification()->getVmUuid()),
					res, PRL_RESULT_TO_STRING(res) );
		}
	}

	m_bInitialized = true;
}
bool ProjectCollection::addProject(const QString& name, const QString& author, const QString& description, const QMultiHash<int, QString> & users)
{
    if (!k->db->exists(name)) {
        if (!k->projects.contains(name)) {
            
            QMultiHash<SProject::UserType, QString> newusers; 
            foreach (int type, users.uniqueKeys()) {
                     foreach (QString login, users.values(type))
                              newusers.insert( SProject::UserType(type), login);
            }

            if (newusers.values(SProject::Owner).empty())
                return false;
            
            SProject *project = new SProject( kAppProp->cacheDir() +"/"+ k->db->nextFileName());
            project->setProjectName(name);
            project->setAuthor(author);
            project->setDescription(description);
            bool okAddProject = false;
            
            project->setUsers(newusers);
            
            bool okSaveProject = project->save();
            if (okSaveProject)
                okAddProject = k->db->addProject(project);

            delete project;

            return okAddProject;
        }
    }
示例#5
0
void CodeAtlas::FuzzyDependBuilder::buildProjDepend( const SymbolNode::Ptr& proj )
{
	QList<SymbolNode::Ptr> globalSymList;
	SymbolTree::getGlobalSymbols(proj, globalSymList);
	ProjectAttr::Ptr projAttr = proj->getOrAddAttr<ProjectAttr>();
	projAttr->setGlobalSymList(globalSymList);


	QMultiHash<QString, ChildPack>      childList;
	bool* isNonVar = new bool[globalSymList.size()];
	for (int ithGloSym = 0; ithGloSym < globalSymList.size(); ++ithGloSym)
	{
		ChildPack p;
		SymbolNode::Ptr pSym = globalSymList[ithGloSym];

		pSym->getOrAddAttr<GlobalSymAttr>();
		p.m_info = pSym->getSymInfo();
		p.m_code = collectFuzzyDepend(pSym);
		p.m_pNode = pSym;
		p.m_index = ithGloSym;
		childList.insertMulti(p.m_info.name(), p);

		isNonVar[ithGloSym] = (p.m_info.elementType() & SymbolInfo::Variable) == 0;
	}

	FuzzyDependAttr::Ptr pAttr = proj->getOrAddAttr<FuzzyDependAttr>();
	buildChildDepend(childList,pAttr->vtxEdgeMatrix(), pAttr->edgeWeightVector(), pAttr->dependPairList());

	buildSubGraphLevel(pAttr->vtxEdgeMatrix(), isNonVar, globalSymList.size(), pAttr->levelVector());
	delete[] isNonVar;
}
/*!
 * \brief The OfflineMessageManager::offlineMessageManagerReply method parse an offline message query an return response
 * \param iqXML
 * \param iqFrom
 * \return QByteArray
 */
QByteArray OfflineMessageManager::offlineMessageManagerReply(QDomDocument document, QString iqFrom)
{
    QString id = document.documentElement().attribute("id", Utils::generateId());
    QString offlineFirstChildTagName = document.documentElement().firstChildElement().firstChildElement().tagName();
    if (offlineFirstChildTagName == "fetch")
    {
        QMultiHash<QString, QByteArray> messageList = getAllOfflineMessage(Utils::getBareJid(iqFrom));
        QList<QString> keyList = messageList.keys();

        QByteArray allMessages;
        foreach (QString key, keyList)
        {
            QDomDocument document;
            document.setContent(messageList.value(key));

            QDomElement offlineElement = document.createElement("offline");
            offlineElement.setAttribute("xmlns", "http://jabber.org/protocol/offline");

            QDomElement item = document.createElement("item");
            item.setAttribute("node", key);

            offlineElement.appendChild(item);
            document.documentElement().appendChild(offlineElement);
            allMessages += document.toByteArray();
        }
void searchInCoordinateIndex(QString const &pathToIndex, QString const &pathToCoordinateIndex)
{
	IndexLoader loader(pathToIndex);
	QMultiHash<QString, QString> hashTable = loader.loadedIndex();

	if (hashTable.isEmpty()) {
		qDebug() << "Index is not loaded";
	}

	CoordinateIndexLoader coordinateLoader(pathToCoordinateIndex);
	QHash<QString, QMultiHash<QString, QString>> coordinateHashTable = coordinateLoader.loadedIndex();

	if (coordinateHashTable.isEmpty()) {
		qDebug() << "Coordinate index is not loaded";
	}

	qDebug() << "Requests: \n";
	QString line = "";

	Searcher search(hashTable);
	CoordinateIndexSearcher coordinateSearch(coordinateHashTable);

	QTextStream in(stdin);
	in.setCodec(QTextCodec::codecForName("IBM 866"));

	do {
		line = in.readLine();
		if (line != ":q") {
			QStringList result = search.processRequest(line);
			coordinateSearch.processRequest(result, line);
		}
	} while (line != ":q");
}
示例#8
0
文件: entryedict.cpp 项目: KDE/kiten
 QStringList createSuffixesList()
 {
   QStringList list;
   list.append( PartOfSpeechCategories.values( suffix ) );
   list.append( PartOfSpeechCategories.values( nounSuffix ) );
   return list;
 }
示例#9
0
文件: entryedict.cpp 项目: KDE/kiten
 QStringList createExpressionsList()
 {
   QStringList list;
   list.append( PartOfSpeechCategories.values( expression ) );
   list.append( PartOfSpeechCategories.values( idiomaticExpression ) );
   return list;
 }
// Return the current class info list.
QList<ClassInfo> qpycore_get_class_info_list()
{
    PyFrameObject *frame = PyEval_GetFrame();
    QList<ClassInfo> class_info_list = class_info_hash.values(frame);

    class_info_hash.remove(frame);

    return class_info_list;
}
示例#11
0
void XKCommon::saveClusters(QDataStream&stream,SuperVoxelClusters&clusters)
{
    QMultiHash<uint32_t,QByteArray> qClusters;
    foreach (SuperVoxelClusters::value_type v, clusters) {
        QByteArray data;
        QDataStream stream(&data,QIODevice::WriteOnly);
        saveSuperVoxel(stream,*v.second);
        qClusters.insert(v.first,data);
    }
示例#12
0
void CodeAtlas::FuzzyDependBuilder::buildChildDepend( QMultiHash<QString, ChildPack>& childList , 
													 Eigen::SparseMatrix<double>& vtxEdgeMat,
													 Eigen::VectorXd&             edgeWeightVec,
													 QList<FuzzyDependAttr::DependPair>& dependPair)
{
	QStringList codeList;
	QVector<ChildPack*> childPackPtr;
	for (QMultiHash<QString, ChildPack>::Iterator pChild = childList.begin();
		pChild != childList.end(); ++pChild)
	{
		codeList.push_back(pChild.value().m_code);
		childPackPtr.push_back(&pChild.value());
	}

	std::vector<Triplet> tripletArray;
	QVector<double>		 edgeWeightArray;

	// add dependency edges between child nodes
	int ithSrc = 0;
	for (QMultiHash<QString, ChildPack>::Iterator pChild = childList.begin();
		pChild != childList.end(); ++pChild, ++ithSrc)
	{
		// for each child, find number of occurrences of this child's name
		ChildPack& srcChild = pChild.value();
		const QString& srcName = pChild.key();
		QVector<int> occurence;
		WordExtractor::findOccurrence(srcName, codeList, occurence);

		for (int ithTar = 0; ithTar < childPackPtr.size(); ++ithTar)
		{
			int nOccur = occurence[ithTar];
			if (nOccur == 0 || ithTar == ithSrc)
				continue;

			ChildPack& tarChild = *childPackPtr[ithTar];

			SymbolEdge::Ptr pEdge = SymbolTree::getOrAddEdge(srcChild.m_pNode, tarChild.m_pNode, SymbolEdge::EDGE_FUZZY_DEPEND);
			pEdge->clear();
			pEdge->strength() = nOccur;

			int nEdge = tripletArray.size()/2;
			tripletArray.push_back(Triplet(srcChild.m_index, nEdge ,1.0));
			tripletArray.push_back(Triplet(tarChild.m_index, nEdge ,-1.0));

			edgeWeightArray.push_back(nOccur);
			dependPair.push_back(FuzzyDependAttr::DependPair(srcChild.m_pNode, tarChild.m_pNode, nOccur));
		}
	}

	if (int nEdges = tripletArray.size()/2)
	{
		vtxEdgeMat.resize(childList.size(),nEdges);
		vtxEdgeMat.setFromTriplets(tripletArray.begin(), tripletArray.end());
		edgeWeightVec.resize(nEdges);
		memcpy(edgeWeightVec.data(), edgeWeightArray.data(), sizeof(double)* nEdges);
	}
}
示例#13
0
Component xapianDocToComponent(Xapian::Document document) {
    Component component;

    // kind
    QString kindString = value (document, XapianValues::TYPE);
    component.setKind(Component::stringToKind(kindString));

    // Identifier
    QString id = value(document, XapianValues::IDENTIFIER);
    component.setId(id);

    // Component name
    QString name = value(document,XapianValues::CPTNAME);
    component.setName(name);

    // Package name
    QStringList packageNames = value(document,XapianValues::PKGNAME).split("\n",QString::SkipEmptyParts);
    component.setPackageNames(packageNames);

    // URLs
    QString concatUrlStrings = value(document, XapianValues::URLS);
    QStringList urlStrings = concatUrlStrings.split('\n',QString::SkipEmptyParts);
    if(urlStrings.size() %2 == 0) {
        QMultiHash<Component::UrlKind, QUrl> urls;
        for(int i = 0; i < urlStrings.size(); i=i+2) {
            Component::UrlKind ukind = Component::stringToUrlKind(urlStrings.at(i));
            QUrl url = QUrl::fromUserInput(urlStrings.at(i+1));
            urls.insertMulti(ukind, url);
        }
        component.setUrls(urls);
    } else {
        qWarning("Bad url strings for component: '%s' (%s)", qPrintable(id), qPrintable(concatUrlStrings));
    }

    // Provided items
    QString concatProvides = value(document, XapianValues::PROVIDED_ITEMS);
    QStringList providesList = concatProvides.split('\n',QString::SkipEmptyParts);
    QList<Provides> provideslist;
    Q_FOREACH(const QString& string, providesList) {
        QStringList providesParts = string.split(';',QString::SkipEmptyParts);
        if(providesParts.size() < 2) {
            qWarning("Bad component parts for component: '%s' (%s)", qPrintable(id), qPrintable(string));
            continue;
        }
        QString kindString = providesParts.takeFirst();
        Provides::Kind kind = Provides::stringToKind(kindString);
        Provides provides;
        provides.setKind(kind);
        QString value = providesParts.takeFirst();
        provides.setValue(value);
        QString extraData = providesParts.join(";");
        provides.setExtraData(extraData);
        provideslist << provides;
    }
示例#14
0
SessionsManagerDialog::SessionsManagerDialog(QWidget *parent) : Dialog(parent),
	m_ui(new Ui::SessionsManagerDialog)
{
	m_ui->setupUi(this);
	m_ui->openInExistingWindowCheckBox->setChecked(SettingsManager::getValue(SettingsManager::Sessions_OpenInExistingWindowOption).toBool());

	const QStringList sessions(SessionsManager::getSessions());
	QMultiHash<QString, SessionInformation> information;

	for (int i = 0; i < sessions.count(); ++i)
	{
		const SessionInformation session(SessionsManager::getSession(sessions.at(i)));

		information.insert((session.title.isEmpty() ? tr("(Untitled)") : session.title), session);
	}

	QStandardItemModel *model(new QStandardItemModel(this));
	model->setHorizontalHeaderLabels(QStringList({tr("Title"), tr("Identifier"), tr("Windows")}));

	const QList<SessionInformation> sorted(information.values());
	const QString currentSession(SessionsManager::getCurrentSession());
	int row(0);

	for (int i = 0; i < sorted.count(); ++i)
	{
		int windows(0);

		for (int j = 0; j < sorted.at(i).windows.count(); ++j)
		{
			windows += sorted.at(i).windows.at(j).windows.count();
		}

		if (sorted.at(i).path == currentSession)
		{
			row = i;
		}

		QList<QStandardItem*> items({new QStandardItem(sorted.at(i).title.isEmpty() ? tr("(Untitled)") : sorted.at(i).title), new QStandardItem(sorted.at(i).path), new QStandardItem(tr("%n window(s) (%1)", "", sorted.at(i).windows.count()).arg(tr("%n tab(s)", "", windows)))});
		items[0]->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
		items[1]->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
		items[2]->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);

		model->appendRow(items);
	}

	m_ui->sessionsViewWidget->setModel(model);

	connect(m_ui->openButton, SIGNAL(clicked()), this, SLOT(openSession()));
	connect(m_ui->deleteButton, SIGNAL(clicked()), this, SLOT(deleteSession()));
	connect(m_ui->sessionsViewWidget, SIGNAL(needsActionsUpdate()), this, SLOT(updateActions()));

	m_ui->sessionsViewWidget->setCurrentIndex(m_ui->sessionsViewWidget->getIndex(row, 0));
}
示例#15
0
void MainWindow::menuSessionsAboutToShow()
{
	if (m_sessionsGroup)
	{
		m_sessionsGroup->deleteLater();

		QAction *saveSessionAction = m_ui->menuSessions->actions().at(0);
		saveSessionAction->setParent(this);

		QAction *manageSessionsAction = m_ui->menuSessions->actions().at(1);
		manageSessionsAction->setParent(this);

		m_ui->menuSessions->clear();
		m_ui->menuSessions->addAction(saveSessionAction);
		m_ui->menuSessions->addAction(manageSessionsAction);
		m_ui->menuSessions->addSeparator();
	}

	m_sessionsGroup = new QActionGroup(this);
	m_sessionsGroup->setExclusive(true);

	const QStringList sessions = SessionsManager::getSessions();
	QMultiHash<QString, SessionInformation> information;

	for (int i = 0; i < sessions.count(); ++i)
	{
		const SessionInformation session = SessionsManager::getSession(sessions.at(i));

		information.insert((session.title.isEmpty() ? tr("(Untitled)") : session.title), session);
	}

	const QList<SessionInformation> sorted = information.values();
	const QString currentSession = SessionsManager::getCurrentSession();

	for (int i = 0; i < sorted.count(); ++i)
	{
		int windows = 0;

		for (int j = 0; j < sorted.at(i).windows.count(); ++j)
		{
			windows += sorted.at(i).windows.at(j).windows.count();
		}

		QAction *action = m_ui->menuSessions->addAction(tr("%1 (%n tab(s))", "", windows).arg(sorted.at(i).title.isEmpty() ? tr("(Untitled)") : QString(sorted.at(i).title).replace(QLatin1Char('&'), QLatin1String("&&"))));
		action->setData(sorted.at(i).path);
		action->setCheckable(true);
		action->setChecked(sorted.at(i).path == currentSession);

		m_sessionsGroup->addAction(action);
	}
}
示例#16
0
int QxtRPCServiceIntrospector::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    // Qt's signal dispatch mechanism invokes qt_metacall for each slot connected to the object.

    // The metacall protocol expects slots to be checked from the bottom up, starting with QObject and proceeding to
    // the more derived classes. qt_metacall returns a negative number to indicate that the request was processed or a
    // positive number to indicate the greatest method ID that was checked. moc-generated qt_metacall implementations
    // subtract the return value from _id so that slots on a given class can be counted starting at 0, allowing the
    // subclasses to add new signals or slots without breaking compatibility. QxtRPCService doesn't need this because
    // it just asks its base class how many methods it has before adding slots.
    if(QObject::qt_metacall(_c, _id, _a) < 0)
        return _id;

    // qt_metacall is also used for other behaviors besides just invoking methods; we don't implement any of these, so
    // we just return here.
    if(_c != QMetaObject::InvokeMetaMethod)
        return _id;

    // Construct an array of QVariants based on the parameters passed through _a.
    QVariant v[8];
    const QList<int>& types = signalParameters.at(idToParams.value(_id));
    int ct = types.count();
    for(int i = 0; i < ct; i++) {
        // The qt_metacall implementation is expected to already know the data types in _a, so that's why we tracked it.
        v[i] = QVariant(types.at(i), _a[i+1]);
    }

    foreach(const QString& rpcName, idToRpc.values(_id)) {
        // Invoke each RPC message connected to the requested dynamic slot ID.
        rpc->call(rpcName, v[0], v[1], v[2], v[3], v[4], v[5], v[6], v[7]);
    }

    // Inform the calling function that we handled the call.
    return -1;
}
SessionsManagerDialog::SessionsManagerDialog(QWidget *parent) : Dialog(parent),
	m_ui(new Ui::SessionsManagerDialog)
{
	m_ui->setupUi(this);
	m_ui->openInExistingWindowCheckBox->setChecked(SettingsManager::getValue(QLatin1String("Sessions/OpenInExistingWindow")).toBool());

	const QStringList sessions = SessionsManager::getSessions();
	QMultiHash<QString, SessionInformation> information;

	for (int i = 0; i < sessions.count(); ++i)
	{
		const SessionInformation session = SessionsManager::getSession(sessions.at(i));

		information.insert((session.title.isEmpty() ? tr("(Untitled)") : session.title), session);
	}

	const QList<SessionInformation> sorted = information.values();
	const QString currentSession = SessionsManager::getCurrentSession();
	int index = 0;

	m_ui->sessionsWidget->setRowCount(sorted.count());

	for (int i = 0; i < sorted.count(); ++i)
	{
		int windows = 0;

		for (int j = 0; j < sorted.at(i).windows.count(); ++j)
		{
			windows += sorted.at(i).windows.at(j).windows.count();
		}

		if (sorted.at(i).path == currentSession)
		{
			index = i;
		}

		m_ui->sessionsWidget->setItem(i, 0, new QTableWidgetItem(sorted.at(i).title.isEmpty() ? tr("(Untitled)") : sorted.at(i).title));
		m_ui->sessionsWidget->setItem(i, 1, new QTableWidgetItem(sorted.at(i).path));
		m_ui->sessionsWidget->setItem(i, 2, new QTableWidgetItem(QStringLiteral("%1 (%2)").arg(sorted.at(i).windows.count()).arg(windows)));
	}

	connect(m_ui->openButton, SIGNAL(clicked()), this, SLOT(openSession()));
	connect(m_ui->deleteButton, SIGNAL(clicked()), this, SLOT(deleteSession()));
	connect(m_ui->sessionsWidget, SIGNAL(currentCellChanged(int,int,int,int)), this, SLOT(currentChanged(int)));

	m_ui->sessionsWidget->setCurrentCell(index, 0);
}
示例#18
0
QList<Action *> Menu::findActions(const QMultiHash<int, QVariant> AData, bool ASearchInSubMenu /*= false*/) const
{
    QList<Action *> actionList;
    QList<int> keys = AData.keys();
    foreach(Action *action,FActions)
    {
        foreach (int key, keys)
        {
            if (AData.values(key).contains(action->data(key)))
            {
                actionList.append(action);
                break;
            }
        }
        if (ASearchInSubMenu && action->menu())
            actionList += action->menu()->findActions(AData,ASearchInSubMenu);
    }
void tst_QVersitProperty::testParameters()
{
    QString typeParameterName(QLatin1String("TYPE"));

    QString name(QLatin1String("type"));
    QString value1(QLatin1String("home"));
    mVersitProperty->insertParameter(name,value1);
    QMultiHash<QString,QString> parameters = mVersitProperty->parameters();
    QCOMPARE(parameters.count(), 1);
    QVERIFY(parameters.contains(typeParameterName,QLatin1String("home")));

    QString value2(QLatin1String("voice"));
    mVersitProperty->insertParameter(name,value2);
    parameters = mVersitProperty->parameters();
    QCOMPARE(parameters.count(), 2);
    QVERIFY(parameters.contains(typeParameterName,QLatin1String("home")));
    QVERIFY(parameters.contains(typeParameterName,QLatin1String("voice")));

    mVersitProperty->removeParameter(name,value1);
    QCOMPARE(mVersitProperty->parameters().count(), 1);
    QVERIFY(parameters.contains(typeParameterName,QLatin1String("home")));

    mVersitProperty->removeParameter(name,value2);
    QCOMPARE(mVersitProperty->parameters().count(), 0);

    mVersitProperty->insertParameter(name, value1);
    mVersitProperty->insertParameter(name, value2);
    QCOMPARE(mVersitProperty->parameters().count(), 2);
    mVersitProperty->removeParameters(name);
    QCOMPARE(mVersitProperty->parameters().count(), 0);
}
示例#20
0
文件: entryedict.cpp 项目: KDE/kiten
 QStringList createVerbsList()
 {
   QStringList list;
   list.append( PartOfSpeechCategories.values( verb ) );
   list.append( IchidanVerbs );
   list.append( GodanVerbs );
   list.append( FukisokuVerbs );
   return list;
 }
示例#21
0
bool QVCardRestoreHandler::propertyProcessed(
        const QVersitProperty& property,
        QList<QContactDetail>* updatedDetails)
{
    bool success = false;
    QString group;
    if (!property.groups().isEmpty())
        group = property.groups().first();
    if (property.name() == PropertyName) {
        if (property.groups().size() != 1)
            return false;
        QMultiHash<QString, QString> parameters = property.parameters();
        QContactDetail::DetailType detailType = QContactDetail::DetailType(parameters.value(DetailTypeParameter).toUInt());
        QString fieldName = parameters.value(FieldParameter);
        // Find a detail previously seen with the same definitionName, which was generated from
        // a property from the same group
        QContactDetail detail(detailType);
        foreach (const QContactDetail& previousDetail, mDetailGroupMap.detailsInGroup(group)) {
            if (previousDetail.type() == detailType) {
                detail = previousDetail;
            }
        }
        // If not found, it's a new empty detail with the definitionName set.

        detail.setValue(fieldName.toInt(), deserializeValue(property));

        // Replace the equivalent detail in updatedDetails with the new one
        QMutableListIterator<QContactDetail> it(*updatedDetails);
        while (it.hasNext()) {
            if (it.next().key() == detail.key()) {
                it.remove();
                break;
            }
        }
        updatedDetails->append(detail);
        success = true;
    }
    if (!group.isEmpty()) {
        // Keep track of which details were generated from which Versit groups
        foreach (const QContactDetail& detail, *updatedDetails) {
            mDetailGroupMap.insert(group, detail);
        }
    }
MergeConfirmationDialog::MergeConfirmationDialog(DatabaseManager* dbm, const QList<long long>& BIDs,
                                                 OutParams* outParams, QWidget* parent) :
    QDialog(parent), ui(new Ui::MergeConfirmationDialog), dbm(dbm),
    canShowTheDialog(false), outParams(outParams)
{
    ui->setupUi(this);

    QStringList bookmarkNames;
    QMultiHash<long long, QString> bookmarkURLs;

    canShowTheDialog = dbm->bms.RetrieveBookmarkNames(BIDs, bookmarkNames);
    if (!canShowTheDialog)
        return;

    canShowTheDialog = dbm->bms.RetrieveBookmarkFullURLs(BIDs, bookmarkURLs);
    if (!canShowTheDialog)
        return;

    radioContext = new RichRadioButtonContext();

    for (int i = 0; i < BIDs.count(); i++)
    {
        long long BID = BIDs[i];

        //Create formatted URLs for display.
        //Reverse the urls to get the original order, as QMultiHash docs say:
        //  "The items that share the same key are available from most recently to least recently inserted."
        QStringList urls = bookmarkURLs.values(BID);
        std::reverse(urls.begin(), urls.end());

        QString urlsSeparated = "";
        const QString sep = "";
        foreach (const QString& url, urls)
            urlsSeparated += "<li style=\"color: blue;\">" + Util::FullyPercentDecodedUrl(url).toHtmlEscaped() + "</li>" + sep;
        urlsSeparated.chop(sep.length());

        QString radioText = QString("<strong>%1</strong>\n<ul>%2</ul>").arg(bookmarkNames[i], urlsSeparated);

        RichRadioButton* bmRadio = new RichRadioButton(radioText, BID, (i == 0), radioContext);
        ui->mainVerticalLayout->insertWidget(ui->mainVerticalLayout->count() -2, bmRadio);
    }
}
示例#23
0
void ContextManager::setFixtureSelection(quint32 fxID, bool enable)
{
    if (m_selectedFixtures.contains(fxID))
    {
        if (enable == false)
            m_selectedFixtures.removeAll(fxID);
        else
            return;
    }
    else
    {
        if (enable)
            m_selectedFixtures.append(fxID);
        else
            return;
    }

    if (m_DMXView->isEnabled())
        m_DMXView->updateFixtureSelection(fxID, enable);
    if (m_2DView->isEnabled())
        m_2DView->updateFixtureSelection(fxID, enable);

    QMultiHash<int, SceneValue> channels = m_fixtureManager->setFixtureCapabilities(fxID, enable);
    if(channels.keys().isEmpty())
        return;

    qDebug() << "[ContextManager] found" << channels.keys().count() << "capabilities";

    QHashIterator<int, SceneValue>it(channels);
    while(it.hasNext())
    {
        it.next();
        quint32 chType = it.key();
        SceneValue sv = it.value();
        if (enable)
            m_channelsMap.insert(chType, sv);
        else
            m_channelsMap.remove(chType, sv);
    }
    emit selectedFixturesChanged();
}
示例#24
0
QDebug operator<<(QDebug dbg, const QVersitProperty& property)
{
    QStringList groups = property.groups();
    QString name = property.name();
    QMultiHash<QString,QString> parameters = property.parameters();
    dbg.nospace() << "QVersitProperty(";
    foreach (const QString& group, groups) {
        dbg.nospace() << group << '.';
    }
    dbg.nospace() << name;
    QHash<QString,QString>::const_iterator it;
    for (it = parameters.constBegin(); it != parameters.constEnd(); ++it) {
        dbg.nospace() << ';' << it.key() << '=' << it.value();
    }
    if (property.valueType() == QVersitProperty::VersitDocumentType)
        dbg.nospace() << ':' << property.value<QVersitDocument>();
    else
        dbg.nospace() << ':' << property.variantValue();
    dbg.nospace() << ')';
    return dbg.maybeSpace();
}
示例#25
0
void PersonsModel::onContactsFetched()
{
    Q_D(PersonsModel);

    KABC::Addressee::Map addresseeMap;

    //fetch all already loaded contacts from plugins
    Q_FOREACH (const AllContactsMonitorPtr &contactWatcher, d->m_sourceMonitors) {
        addresseeMap.unite(contactWatcher->contacts());
    }

    //add metacontacts
    QMultiHash<QString, QString> contactMapping = PersonManager::instance()->allPersons();

    Q_FOREACH (const QString &key, contactMapping.uniqueKeys()) {
        KABC::Addressee::Map contacts;
        Q_FOREACH (const QString &contact, contactMapping.values(key)) {
            d->contactToPersons[contact] = key;
            if (addresseeMap.contains(contact)) {
                contacts[contact] = addresseeMap.take(contact);
            }
        }
        if (!contacts.isEmpty()) {
            addPerson(MetaContact(key, contacts));
        }
    }

    //add remaining contacts
    KABC::Addressee::Map::const_iterator i;
    for (i = addresseeMap.constBegin(); i != addresseeMap.constEnd(); ++i) {
        addPerson(MetaContact(i.key(), i.value()));
    }

    Q_FOREACH(const AllContactsMonitorPtr monitor, d->m_sourceMonitors) {
        connect(monitor.data(), SIGNAL(contactAdded(QString,KABC::Addressee)), SLOT(onContactAdded(QString,KABC::Addressee)));
        connect(monitor.data(), SIGNAL(contactChanged(QString,KABC::Addressee)), SLOT(onContactChanged(QString,KABC::Addressee)));
        connect(monitor.data(), SIGNAL(contactRemoved(QString)), SLOT(onContactRemoved(QString)));
    }
}
示例#26
0
void QxtRPCServiceIntrospector::disconnectObject(QObject* obj)
{
    const QMetaObject* meta = obj->metaObject();

    foreach(const SignalDef& sig, signalToId.keys()) {
        // Iterate through all tracked connections and skip any that don't match the incoming object.
        if(sig.first != obj) continue;

        int methodID = methodIDs[qMakePair(meta, sig.second)];
        foreach(int id, signalToId.values(sig)) {
            // Iterate through all of the different connections for the object and explicitly disconnect them.
            QMetaObject::disconnect(obj, methodID, this, id);

            // Remove the connection from our mappings.
            idToRpc.remove(id);
            idToParams.remove(id);
        }

        // Remove the object/signal from the mapping.
        signalToId.remove(sig);
    }
}
示例#27
0
int main()
{
    QSet<QString *> s;
    qDeleteAll(s);
    qDeleteAll(s.begin(), s.end());
    qDeleteAll(s.values()); // warning

    QHash<int, QString *> h;
    qDeleteAll(h);
    qDeleteAll(h.begin(), h.end());
    qDeleteAll(h.values()); // warning

    QMap<int*, QString *> m;
    qDeleteAll(m);
    qDeleteAll(m.begin(), m.end());
    qDeleteAll(m.values()); // warning

    QMultiHash<int, QString *> mh;
    qDeleteAll(mh);
    qDeleteAll(mh.begin(), mh.end());
    qDeleteAll(mh.values()); // warning

    QMultiMap<int, QString *> mm;
    qDeleteAll(mm);
    qDeleteAll(mm.begin(), mm.end());
    qDeleteAll(mm.values()); // warning

    qDeleteAll(values());  // ok

    Foo foo;
    qDeleteAll(foo.values());  // ok
    qDeleteAll(foo.doSomethingWithValues(h.values()));  // ok

    qDeleteAll(m.keys()); // warning
    qDeleteAll(keys()); // ok

    qDeleteAll(h.values(1)); // warning

}
示例#28
0
QString CodeAtlas::FuzzyDependBuilder::collectFuzzyDepend( SymbolNode::Ptr& node )
{
	// ignore dependency under a function
	SymbolInfo nodeInfo = node->getSymInfo();
	if (nodeInfo.elementType() & SymbolInfo::Variable)
		return nodeInfo.type() + " " + nodeInfo.name();

	QString    nodeCode;
	CodeAttr::Ptr pCode = node->getAttr<CodeAttr>();
	if (pCode)
		nodeCode = pCode->getCode();
	if (nodeInfo.elementType() & SymbolInfo::Function)
		return nodeCode;

	QMultiHash<QString, ChildPack>      childList;
	int ithChild = 0;
	
	bool* isNonVar = new bool[node->childCount()];
	for (SymbolNode::ChildIterator pChild = node->childBegin();
		pChild != node->childEnd(); ++pChild, ++ithChild)
	{
		ChildPack p;
		p.m_info = pChild.key();
		p.m_code = collectFuzzyDepend(pChild.value());
		p.m_pNode = pChild.value();
		p.m_index = ithChild;
		childList.insertMulti(p.m_info.name(), p);

		isNonVar[ithChild] = (p.m_info.elementType() & SymbolInfo::Variable) == 0;
		nodeCode += "\n" + p.m_code;
	}

	FuzzyDependAttr::Ptr pAttr = node->getOrAddAttr<FuzzyDependAttr>();
	buildChildDepend(childList, pAttr->vtxEdgeMatrix(), pAttr->edgeWeightVector(), pAttr->dependPairList());

	buildSubGraphLevel(pAttr->vtxEdgeMatrix(), isNonVar, ithChild, pAttr->levelVector());
	delete[] isNonVar;
	return nodeCode;
}
示例#29
0
void IcecastService::ParseDirectoryFinished(
    QFuture<IcecastBackend::StationList> future) {
  IcecastBackend::StationList all_stations = future.result();
  sort(all_stations.begin(), all_stations.end(),
       StationSorter<IcecastBackend::Station>());
  // Remove duplicates by name. These tend to be multiple URLs for the same
  // station.
  IcecastBackend::StationList::iterator it =
      unique(all_stations.begin(), all_stations.end(),
             StationEquality<IcecastBackend::Station>());
  all_stations.erase(it, all_stations.end());

  // Cluster stations by genre.
  QMultiHash<QString, IcecastBackend::Station*> genres;

  // Add stations.
  for (int i = 0; i < all_stations.count(); ++i) {
    IcecastBackend::Station& s = all_stations[i];
    genres.insert(s.genre, &s);
  }

  QSet<QString> genre_set = genres.keys().toSet();

  // Merge genres with only 1 or 2 stations into "Other".
  for (const QString& genre : genre_set) {
    if (genres.count(genre) < 3) {
      const QList<IcecastBackend::Station*>& small_genre = genres.values(genre);
      for (IcecastBackend::Station* s : small_genre) {
        s->genre = "Other";
      }
    }
  }

  backend_->ClearAndAddStations(all_stations);

  app_->task_manager()->SetTaskFinished(load_directory_task_id_);
  load_directory_task_id_ = 0;
}
bool PtDrugDatatabaseStep::createDatabase()
{
    Q_EMIT progressLabelChanged(tr("Preparing raw source files"));
    Q_EMIT progressRangeChanged(0, 1);
    Q_EMIT progress(0);

    if (!DrugsDB::Tools::createMasterDrugInteractionDatabase())
        return false;

    QMultiHash<QString, QVariant> labels;
    labels.insert("fr","Base de données thérapeutique du portugaise");
    labels.insert("en","Portuguese therapeutic database");
    labels.insert("de","Portugiesische Therapeutische Datenbank");

    if (DrugsDB::Tools::createNewDrugsSource(Core::Constants::MASTER_DATABASE_NAME, PT_DRUGS_DATABASE_NAME, labels) == -1) {
        LOG_ERROR("Unable to create the PT drugs sources");
        return false;
    }

    LOG(QString("Database schema created"));
    Q_EMIT progress(1);
    return true;
}