Пример #1
0
/*!
 * \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();
        }
Пример #2
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();
}
Пример #3
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);
    }
Пример #4
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);
    }
}
Пример #5
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;
}