Example #1
0
bool Doc::addFixture(Fixture* fixture, quint32 id)
{
    Q_ASSERT(fixture != NULL);

    // No ID given, this method can assign one
    if (id == Fixture::invalidId())
        id = createFixtureId();

    if (m_fixtures.contains(id) == true || id == Fixture::invalidId())
    {
        qWarning() << Q_FUNC_INFO << "a fixture with ID" << id << "already exists!";
        return false;
    }
    else
    {
        fixture->setID(id);
        m_fixtures.insert(id, fixture);

        /* Patch fixture change signals thru Doc */
        connect(fixture, SIGNAL(changed(quint32)),
                this, SLOT(slotFixtureChanged(quint32)));

        /* Keep track of fixture addresses */
        for (uint i = fixture->universeAddress();
             i < fixture->universeAddress() + fixture->channels(); i++)
        {
            m_addresses[i] = id;
        }

        // Add the fixture channels capabilities to the universe they belong
        QList<Universe *> universes = inputOutputMap()->claimUniverses();
        int uni = fixture->universe();

        // TODO !!! if a universe for this fixture doesn't exist, add it !!!
        QList<int> forcedHTP = fixture->forcedHTPChannels();
        QList<int> forcedLTP = fixture->forcedLTPChannels();

        for (quint32 i = 0 ; i < fixture->channels(); i++)
        {
            const QLCChannel* channel(fixture->channel(i));
            if (forcedHTP.contains(i))
                universes.at(uni)->setChannelCapability(fixture->address() + i,
                                                        channel->group(), Universe::HTP);
            else if (forcedLTP.contains(i))
                universes.at(uni)->setChannelCapability(fixture->address() + i,
                                                        channel->group(), Universe::LTP);
            else
                universes.at(uni)->setChannelCapability(fixture->address() + i,
                                                        channel->group());
            ChannelModifier *mod = fixture->channelModifier(i);
            universes.at(uni)->setChannelModifier(fixture->address() + i, mod);
        }
        inputOutputMap()->releaseUniverses(true);

        emit fixtureAdded(id);
        setModified();

        return true;
    }
}
IConnectionProxy ConnectionManager::proxyById(const QUuid &AProxyId) const
{
	static const IConnectionProxy noProxy = {" "+tr("<No Proxy>"), QNetworkProxy(QNetworkProxy::NoProxy) };

	if (!AProxyId.isNull())
	{
		OptionsNode pnode;
		QList<QUuid> plist = proxyList();
		if (plist.contains(AProxyId))
			pnode = Options::node(OPV_PROXY_ITEM,AProxyId.toString());
		else if (plist.contains(defaultProxy()))
			pnode = Options::node(OPV_PROXY_ITEM,defaultProxy().toString());

		if (!pnode.isNull())
		{
			IConnectionProxy proxy;
			proxy.name = pnode.value("name").toString();
			proxy.proxy.setType((QNetworkProxy::ProxyType)pnode.value("type").toInt());
			proxy.proxy.setHostName(pnode.value("host").toString());
			proxy.proxy.setPort(pnode.value("port").toInt());
			proxy.proxy.setUser(pnode.value("user").toString());
			proxy.proxy.setPassword(Options::decrypt(pnode.value("pass").toByteArray()).toString());
			return proxy;
		}
	}

	return noProxy;
}
Example #3
0
void QgsMapCanvasTracer::configure()
{
  setDestinationCrs( mCanvas->mapSettings().destinationCrs() );
  setExtent( mCanvas->extent() );

  QList<QgsVectorLayer *> layers;
  QList<QgsMapLayer *> visibleLayers = mCanvas->mapSettings().layers();

  switch ( mCanvas->snappingUtils()->config().mode() )
  {
    default:
    case QgsSnappingConfig::ActiveLayer:
    {
      QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( mCanvas->currentLayer() );
      if ( vl && visibleLayers.contains( vl ) )
        layers << vl;
    }
    break;
    case QgsSnappingConfig::AllLayers:
      Q_FOREACH ( QgsMapLayer *layer, visibleLayers )
      {
        QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( layer );
        if ( vl )
          layers << vl;
      }
      break;
    case QgsSnappingConfig::AdvancedConfiguration:
      Q_FOREACH ( const QgsSnappingUtils::LayerConfig &cfg, mCanvas->snappingUtils()->layers() )
      {
        if ( visibleLayers.contains( cfg.layer ) )
          layers << cfg.layer;
      }
      break;
  }
Example #4
0
void GetSupportedFileFormats(QList<QByteArray> &g_supportedFormats)
{

    // Assemble list of supported Image Formats from our plugin
    int numPlugins = g_pluginManager.getNumPlugins();
    for (int i = 0; i< numPlugins; i++)
    {
        if (strcmp(g_pluginManager.getPluginType(i), "IMAGE") == 0)
        {
            QByteArray bArray = g_pluginManager.getPluginName(i);
            QByteArray fformat = bArray.toUpper();
            if (!g_supportedFormats.contains(fformat))
                g_supportedFormats.append(fformat);
        }
    }

    // Get a list of all Supported file formats from Qt Plugins
    QList<QByteArray> QtFormats = QImageReader::supportedImageFormats();

    // Upppercase List
    QList<QByteArray>::Iterator i;
    for (i = QtFormats.begin(); i != QtFormats.end(); ++i)
    {
        QByteArray fformat = (*i);
        fformat = fformat.toUpper();
        if (!g_supportedFormats.contains(fformat))
            g_supportedFormats.append(fformat);
    }
    
    // Sort the list to alphabetical order
    std::sort(g_supportedFormats.begin(), g_supportedFormats.end());

}
Example #5
0
QByteArray dispositionNotificationBodyContent( const QString &r,
                                               const QByteArray &o,
                                               const QByteArray &omid,
                                               DispositionType d,
                                               ActionMode a,
                                               SendingMode s,
                                               const QList<DispositionModifier> &m,
                                               const QString &special )
{
  // in Perl: chomp(special)
  QString spec;
  if ( special.endsWith( QLatin1Char( '\n' ) ) ) {
    spec = special.left( special.length() - 1 );
  } else {
    spec = special;
  }

  // std headers:
  QByteArray result = reportingUAField();
  result += orginalRecipient( o );
  result += finalRecipient( r );
  result += originalMessageID( omid );
  result += dispositionField( d, a, s, m );

  // headers that are only present for certain disposition {types,modifiers}:
  if ( d == Failed ) {
    result += "Failure: " + encodeRFC2047String( spec, "utf-8" ) + '\n';
  } else if ( m.contains( Error ) ) {
    result += "Error: " + encodeRFC2047String( spec, "utf-8" ) + '\n';
  } else if ( m.contains( Warning ) ) {
    result += "Warning: " + encodeRFC2047String( spec, "utf-8" ) + '\n';
  }

  return result;
}
Example #6
0
/**
 * A helper method that returns the possible target layers of a given \a stamp.
 */
QList<Layer *> AbstractTileTool::targetLayersForStamp(const TileStamp &stamp) const
{
    QList<Layer*> layers;

    if (!mapDocument())
        return layers;

    const Map &map = *mapDocument()->map();

    for (const TileStampVariation &variation : stamp.variations()) {
        LayerIterator it(variation.map, Layer::TileLayerType);
        const Layer *firstLayer = it.next();
        const bool isMultiLayer = firstLayer && it.next();

        if (isMultiLayer && !firstLayer->name().isEmpty()) {
            for (Layer *layer : variation.map->tileLayers()) {
                TileLayer *target = static_cast<TileLayer*>(map.findLayer(layer->name(), Layer::TileLayerType));
                if (!layers.contains(target))
                    layers.append(target);
            }
        } else {
            if (TileLayer *tileLayer = currentTileLayer())
                if (!layers.contains(tileLayer))
                    layers.append(tileLayer);
        }
    }

    return layers;
}
Dialect Dialect::mergeLanguages(const Dialect &l1, const Dialect &l2)
{
    if (l1 == Dialect::NoLanguage)
        return l2;
    if (l2 == Dialect::NoLanguage)
        return l1;
    QList<Dialect> ll1 = l1.companionLanguages();
    QList<Dialect> ll2 = l2.companionLanguages();
    bool i1 = ll1.contains(l2);
    bool i2 = ll2.contains(l1);
    if (i1 && i2) {
        if (ll1.size() > ll2.size())
            return l1;
        if (ll2.size() > ll1.size())
            return l2;
        if (l1 < l2)
            return l1;
        return l2;
    }
    if (i1 && !i2)
        return l1;
    if (i2 && !i1)
        return l2;
    QList<Dialect> qmlLangs = Dialect(Qml).companionLanguages();
    if (qmlLangs.contains(l1) && qmlLangs.contains(l2))
        return Dialect::Qml;
    return Dialect::AnyLanguage;
}
bool Dialect::restrictLanguage(const Dialect &l2)
{
    if (*this == l2)
        return true;
    QList<Dialect> ll1 = companionLanguages();
    QList<Dialect> ll2 = l2.companionLanguages();
    bool i1 = ll1.contains(l2);
    bool i2 = ll2.contains(*this);
    if (i1 && i2) {
        if (ll1.size() < ll2.size())
            return true;
        if (ll2.size() < ll1.size()) {
            *this = l2;
            return true;
        }
        if (m_dialect < l2.m_dialect)
            return true;
        *this = l2;
        return true;
    }
    if (i1 && !i2) {
        *this = l2;
        return true;
    }
    if (i2 && !i1)
        return true;
    qDebug() << toString() << "restrictTo" << l2.toString() << "failed";
    qDebug() << ll1 << ll2;
    qDebug() << i1 << i2;
    QList<Dialect> qmlLangs = Dialect(Qml).companionLanguages();
    if (qmlLangs.contains(*this) && qmlLangs.contains(l2))
        *this = Dialect::Qml;
    *this = Dialect::AnyLanguage;
    return false;
}
void ProfileManager::setProfiles(const QList<Profile*>& profiles)
{
	QList<Profile*> currentProfiles = this->profiles;

	QList<Profile*>::const_iterator it;

	for (it = currentProfiles.begin() ; it != currentProfiles.end() ; it++) {
		Profile* profile = *it;

		if (!profiles.contains(profile)) {
			if (getCurrentProfile() == profile) {
				setCurrentProfile(NULL);
			}

			removeProfile(profile);
			delete profile;
		}
	}

	for (it = profiles.begin() ; it != profiles.end() ; it++) {
		Profile* profile = *it;

		if (!currentProfiles.contains(profile)) {
			addProfile(profile);
		}
	}
}
 void shouldExposeRoleNames()
 {
     QList<QByteArray> roleNames = model->roleNames().values();
     QVERIFY(roleNames.contains("url"));
     QVERIFY(roleNames.contains("title"));
     QVERIFY(roleNames.contains("icon"));
     QVERIFY(roleNames.contains("tab"));
 }
QGeoMappingManagerEngineOsm::QGeoMappingManagerEngineOsm(const QMap<QString, QVariant> &parameters, QGeoServiceProvider::Error *error, QString *errorString)
        : QGeoTiledMappingManagerEngine(parameters),
        m_parameters(parameters)
{
    Q_UNUSED(error)
    Q_UNUSED(errorString)

    setTileSize(QSize(256,256));
    setMinimumZoomLevel(0.0);
    setMaximumZoomLevel(18.0);
    m_tyleStyleId = "1";

    QList<QGraphicsGeoMap::MapType> types;
    types << QGraphicsGeoMap::StreetMap;
    types << QGraphicsGeoMap::TerrainMap;  // used for cyclemap
    types << TRANSITMAP;

    setSupportedMapTypes(types);

    m_nam = new QNetworkAccessManager(this);

#ifdef USE_NETWORK_CACHE
    m_cache = new QNetworkDiskCache(this);

    QDir dir = QDir::temp();
    dir.mkdir("maptiles-osm");
    dir.cd("maptiles-osm");

    m_cache->setCacheDirectory(dir.path());
#endif

    QList<QString> keys = m_parameters.keys();

    if (keys.contains("mapping.proxy")) {
        QString proxy = m_parameters.value("mapping.proxy").toString();
        if (!proxy.isEmpty())
            m_nam->setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, proxy, 8080));
    }

#ifdef USE_NETWORK_CACHE
    if (keys.contains("mapping.cache.directory")) {
        QString cacheDir = m_parameters.value("mapping.cache.directory").toString();
        if (!cacheDir.isEmpty())
            m_cache->setCacheDirectory(cacheDir);
    }

    if (keys.contains("mapping.cache.size")) {
        bool ok = false;
        qint64 cacheSize = m_parameters.value("mapping.cache.size").toString().toLongLong(&ok);
        if (ok)
            m_cache->setMaximumCacheSize(cacheSize);
    }

    m_nam->setCache(m_cache);
#endif
}
Example #12
0
/**
 * @brief Parses HTML data and assigns it to the given movie object
 * @param html HTML data
 * @param movie Movie object
 * @param infos List of infos to load
 */
void Cinefacts::parseAndAssignInfos(QString html, Movie *movie, QList<int> infos)
{
    QRegExp rx;
    rx.setMinimal(true);
    QTextDocument doc;

    // Title
    rx.setPattern("<span itemprop=\"name\">(.*)</span>");
    if (infos.contains(MovieScraperInfos::Title) && rx.indexIn(html) != -1)
        movie->setName(rx.cap(1).trimmed());

    // Original Title
    rx.setPattern("<span itemprop=\"alternativeHeadline\" >(.*)</span>");
    if (infos.contains(MovieScraperInfos::Title) && rx.indexIn(html) != -1)
        movie->setOriginalName(rx.cap(1).trimmed());

    // Genre
    if (infos.contains(MovieScraperInfos::Genres)) {
        rx.setPattern("<span itemprop=\"genre\" >(.*)</span>");
        int offset = 0;
        while ((offset = rx.indexIn(html, offset)) != -1) {
            offset += rx.matchedLength();
            movie->addGenre(rx.cap(1));
        }
    }

    // Year
    rx.setPattern("<time datetime=\"[^\"]*\" itemprop=\"dateCreated\" >([0-9]{4})</time>");
    if (infos.contains(MovieScraperInfos::Released) && rx.indexIn(html) != -1)
        movie->setReleased(QDate::fromString(rx.cap(1).trimmed(), "yyyy"));

    // Country
    rx.setPattern("<span itemprop=\"genre\" >[^>]*</span> \\| (.*) \\(<time datetime=");
    if (infos.contains(MovieScraperInfos::Countries) && rx.indexIn(html) != -1)
        movie->addCountry(Helper::instance()->mapCountry(rx.cap(1).trimmed()));

    // Studio
    rx.setPattern("<span itemscope itemprop=\"provider\" itemtype=\"http://www.schema.org/Organization\" ><span itemprop=\"name\" >([^<]*)</span>");
    if (infos.contains(MovieScraperInfos::Studios) && rx.indexIn(html) != -1)
        movie->addStudio(Helper::instance()->mapStudio(rx.cap(1).trimmed()));

    // MPAA
    rx.setPattern("Freigegeben ab ([0-9]*) Jahren");
    if (infos.contains(MovieScraperInfos::Certification) && rx.indexIn(html) != -1)
        movie->setCertification(Helper::instance()->mapCertification("FSK " + rx.cap(1)));

    // Runtime
    rx.setPattern("<time itemprop=\"duration\" datetime=\"PT[^\"]*\" >([0-9]*)</time>");
    if (infos.contains(MovieScraperInfos::Runtime) && rx.indexIn(html) != -1)
        movie->setRuntime(rx.cap(1).trimmed().toInt());

    // Overview
    rx.setPattern("<span class=\"thisSummary\" itemprop=\"description\">.*<strong>Inhalt: </strong>(.*)</span>");
    if (infos.contains(MovieScraperInfos::Overview) && rx.indexIn(html) != -1) {
        doc.setHtml(rx.cap(1).trimmed());
        movie->setOverview(doc.toPlainText());
        if (Settings::instance()->usePlotForOutline())
            movie->setOutline(doc.toPlainText());
    }
}
Example #13
0
bool QgsProcessingUtils::canUseLayer( const QgsVectorLayer *layer, const QList<int> &sourceTypes )
{
  return layer && layer->isValid() &&
         ( sourceTypes.isEmpty()
           || ( sourceTypes.contains( QgsProcessing::TypeVectorPoint ) && layer->geometryType() == QgsWkbTypes::PointGeometry )
           || ( sourceTypes.contains( QgsProcessing::TypeVectorLine ) && layer->geometryType() == QgsWkbTypes::LineGeometry )
           || ( sourceTypes.contains( QgsProcessing::TypeVectorPolygon ) && layer->geometryType() == QgsWkbTypes::PolygonGeometry )
           || ( sourceTypes.contains( QgsProcessing::TypeVectorAnyGeometry ) && layer->isSpatial() )
           || sourceTypes.contains( QgsProcessing::TypeVector )
         );
}
Example #14
0
void ClipboardServer::onCommandsSaved(const QVector<Command> &commands)
{
#ifndef NO_GLOBAL_SHORTCUTS
    removeGlobalShortcuts();

    QList<QKeySequence> usedShortcuts;

    for (const auto &command : commands) {
        if (command.type() & CommandType::GlobalShortcut) {
            for (const auto &shortcutText : command.globalShortcuts) {
                QKeySequence shortcut(shortcutText, QKeySequence::PortableText);
                if ( !shortcut.isEmpty() && !usedShortcuts.contains(shortcut) ) {
                    usedShortcuts.append(shortcut);
                    createGlobalShortcut(shortcut, command);
                }
            }
        }
    }
#endif

    const auto hash = monitorCommandStateHash(commands);
    if ( m_monitor && hash != m_monitorCommandsStateHash ) {
        m_monitorCommandsStateHash = hash;
        stopMonitoring();
        startMonitoring();
    }
}
Example #15
0
void
Win32MakefileGenerator::processPrlFiles()
{
    QHash<QString, bool> processed;
    QList<QMakeLocalFileName> libdirs;
    {
        QStringList &libpaths = project->values("QMAKE_LIBDIR");
        for(QStringList::Iterator libpathit = libpaths.begin(); libpathit != libpaths.end(); ++libpathit)
            libdirs.append(QMakeLocalFileName((*libpathit)));
    }
    for(bool ret = false; true; ret = false) {
        //read in any prl files included..
        QStringList l_out;
        QString where = "QMAKE_LIBS";
        if(!project->isEmpty("QMAKE_INTERNAL_PRL_LIBS"))
            where = project->first("QMAKE_INTERNAL_PRL_LIBS");
        QStringList l = project->values(where);
        for(QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
            QString opt = (*it).trimmed();
            if((opt[0] == '\'' || opt[0] == '"') && opt[(int)opt.length()-1] == opt[0])
                opt = opt.mid(1, opt.length()-2);
            if(opt.startsWith("/")) {
                if(opt.startsWith("/LIBPATH:")) {
                    QMakeLocalFileName l(opt.mid(9));
                    if(!libdirs.contains(l))
                        libdirs.append(l);
                }
            } else if(!processed.contains(opt)) {
                if(processPrlFile(opt)) {
                    processed.insert(opt, true);
                    ret = true;
                } else if(QDir::isRelativePath(opt) || opt.startsWith("-l")) {
                    QString tmp;
                    if (opt.startsWith("-l"))
                        tmp = opt.mid(2);
                    else
                        tmp = opt;
                    for(QList<QMakeLocalFileName>::Iterator it = libdirs.begin(); it != libdirs.end(); ++it) {
                        QString prl = (*it).local() + Option::dir_sep + tmp;
                        // the original is used as the key
                        QString orgprl = prl;
                        if(processed.contains(prl)) {
                            break;
                        } else if(processPrlFile(prl)) {
                            processed.insert(orgprl, true);
                            ret = true;
                            break;
                        }
                    }
                }
            }
            if(!opt.isEmpty())
                l_out.append(opt);
        }
        if(ret)
            l = l_out;
        else
            break;
    }
}
Example #16
0
Action::Action( QWidget *pParent, const char *pName, const QString &pDisplayName,
                QObject *pTarget, const char *pActivateSlot,
                QWidget *pAddTo, bool pEnabled,
                const QPixmap &pIcon, QWidget *pToolBar,
                const QString &pToolTip ) :
 QAction(pDisplayName, pParent)
{
  setObjectName(pName);
  _name = pName;
  _displayName = pDisplayName;
  _toolTip = pToolTip;

  QString hotkey = _preferences->parent(pName);
  if (!hotkey.isNull() && !_hotkeyList.contains(hotkey))
  {
    _hotkeyList << hotkey;
    setShortcutContext(Qt::ApplicationShortcut);
    if (hotkey.left(1) == "C")
      setShortcut(QString("Ctrl+%1").arg(hotkey.right(1)));

    else if (hotkey.left(1) == "F")
      setShortcut(hotkey);
  }

  connect(this, SIGNAL(activated()), pTarget, pActivateSlot);
  setEnabled(pEnabled);
  pAddTo->addAction(this);
  setIconSet(QIcon(pIcon));
  addTo(pToolBar);
  setToolTip(_toolTip);
}
Example #17
0
void QgsSnapper::cleanResultList( QMultiMap<double, QgsSnappingResult>& list, const QList<QgsPoint>& excludeList ) const
{
  QgsPoint currentResultPoint;
  QgsSnappingResult currentSnappingResult;
  QList<double> keysToRemove;

  QMultiMap<double, QgsSnappingResult>::iterator result_it = list.begin();
  for ( ; result_it != list.end(); ++result_it )
  {
    currentSnappingResult = result_it.value();
    if ( currentSnappingResult.snappedVertexNr != -1 )
    {
      currentResultPoint = currentSnappingResult.snappedVertex;
      if ( excludeList.contains( currentResultPoint ) )
      {
        keysToRemove.push_back( result_it.key() );
      }
    }
  }

  QList<double>::const_iterator remove_it = keysToRemove.constBegin();
  for ( ; remove_it != keysToRemove.constEnd(); ++remove_it )
  {
    list.remove( *remove_it );
  }
}
QList<QByteArray> QFontEngineQPF::cleanUpAfterClientCrash(const QList<int> &crashedClientIds)
{
    QList<QByteArray> removedFonts;
    QDir dir(qws_fontCacheDir(), QLatin1String("*.qsf"));
    for (int i = 0; i < int(dir.count()); ++i) {
        const QByteArray fileName = QFile::encodeName(dir.absoluteFilePath(dir[i]));

        int fd = ::open(fileName.constData(), O_RDONLY);
        if (fd >= 0) {
            void *header = ::mmap(0, sizeof(QFontEngineQPF::Header), PROT_READ, MAP_SHARED, fd, 0);
            if (header && header != MAP_FAILED) {
                quint32 lockValue = reinterpret_cast<QFontEngineQPF::Header *>(header)->lock;

                if (lockValue && crashedClientIds.contains(lockValue)) {
                    removedFonts.append(fileName);
                    QFile::remove(QFile::decodeName(fileName));
                }

                ::munmap(header, sizeof(QFontEngineQPF::Header));
            }
            ::close(fd);
        }
    }
    if (!removedFonts.isEmpty())
        qDebug() << "list of corrupted and removed fonts:" << removedFonts;
    return removedFonts;
}
Example #19
0
void PropertyEditor::showNodes(const QList < relarank::NodeHandle > &selection)
{
    Q_ASSERT(m_mainCtrl);
    // collect all collapsibles to remove
    QVector < relarank::NodeHandle > removed;
    for (QHash < relarank::NodeHandle, Collapsible * >::iterator i =
             m_nodes.begin(); i != m_nodes.end(); ++i) {
        if (!selection.contains(i.key())) {
            m_layout->removeWidget(i.value());
            removed.append(i.key());
        }
    }
    // ... and remove them after the iteration has finished
    for (relarank::NodeHandle node : removed) {
        m_nodes.take(node)->deleteLater();
    }
    // then create the new collapsibles
    for (relarank::NodeHandle node : selection) {
        if (!m_nodes.contains(node)) {
            Collapsible *collapsible = new Collapsible(this);
            collapsible->
            setWidget(new
                      NodeProperties(m_mainCtrl->getCtrlForHandle(node),
                                     collapsible));
            m_layout->insertWidget(0, collapsible);	// insert the new Collapsible at the top
            m_nodes.insert(node, collapsible);
        }
    }
}
Example #20
0
void CMainWindow::_delete_triggered()
{
    QList<QTableWidgetItem*> list = _listMail->selectedItems();
    QList<int> realList;

    for (int i = 0; i < list.size(); ++i)
    {
        if (!realList.contains(list[i]->row()))
            realList.append(list[i]->row());
    }
    qSort(realList.begin(), realList.end());
    for (int i = 0; i < realList.size(); ++i)
    {
        QTableWidgetItem *item = _listMail->item(realList[i], 0);
        try
        {
            _socket->removeMail(qPrintable(item->text()));
            _listMail->removeRow(realList[i]);
            for (int j = i; j < realList.size(); ++j)
                realList.replace(j, realList[j] - 1);
        }
        catch (const std::exception &e)
        {
        QMessageBox::critical(this, "Delete", "Can't delete row " + QString::number(realList[i] + 1));
        }
    }
}
	void LayerManager::zoomOut()
	{
		QCoreApplication::processEvents();
		ImageManager::instance()->abortLoading();
		zoomImageScroll = QPoint(0,0);
		zoomImage.fill(Qt::white);
		QPixmap tmpImg = composedOffscreenImage.copy(screenmiddle.x()+scroll.x(),screenmiddle.y()+scroll.y(), size.width(), size.height());
		QPainter painter(&zoomImage);
		painter.translate(screenmiddle);
		painter.scale(0.5,0.5);
		painter.translate(-screenmiddle);
		painter.drawPixmap(0,0,tmpImg);
	
		painter.translate(screenmiddle);
		painter.scale(2,2);
		painter.translate(-screenmiddle);
	
		QListIterator<Layer*> it(mylayers);
	//TODO: remove hack, that mapadapters wont get set zoom multiple times
		QList<const MapAdapter*> doneadapters;
		while (it.hasNext())
		{
			Layer* l = it.next();
			if (!doneadapters.contains(l->mapadapter()))
			{
				l->zoomOut();
				doneadapters.append(l->mapadapter());
			}
		}
		mapmiddle_px = layer()->mapadapter()->coordinateToDisplay(mapmiddle);
		whilenewscroll = mapmiddle_px;
		newOffscreenImage();
	}
QAudioFormat QAudioDeviceInfo::nearestFormat(const QAudioFormat &settings) const
{
    if (isFormatSupported(settings))
        return settings;

    QAudioFormat nearest = settings;

    nearest.setCodec(QLatin1String("audio/pcm"));

    if (nearest.sampleType() == QAudioFormat::Unknown) {
        QAudioFormat preferred = preferredFormat();
        nearest.setSampleType(preferred.sampleType());
    }

    QMap<int,int> testFrequencies;
    QList<int> frequenciesAvailable = supportedFrequencies();
    QMap<int,int> testSampleSizes;
    QList<int> sampleSizesAvailable = supportedSampleSizes();

    // Get sorted sampleSizes (equal to and ascending values only)
    if (sampleSizesAvailable.contains(settings.sampleSize()))
        testSampleSizes.insert(0,settings.sampleSize());
    sampleSizesAvailable.removeAll(settings.sampleSize());
    foreach (int size, sampleSizesAvailable) {
        int larger  = (size > settings.sampleSize()) ? size : settings.sampleSize();
        int smaller = (size > settings.sampleSize()) ? settings.sampleSize() : size;
        if (size >= settings.sampleSize()) {
            int diff = larger - smaller;
            testSampleSizes.insert(diff, size);
        }
    }
Example #23
0
QMimeData* BrowseTableModel::mimeData(const QModelIndexList &indexes) const {
    QMimeData *mimeData = new QMimeData();
    QList<QUrl> urls;

    // Ok, so the list of indexes we're given contains separates indexes for
    // each column, so even if only one row is selected, we'll have like 7
    // indexes.  We need to only count each row once:
    QList<int> rows;

    foreach (QModelIndex index, indexes) {
        if (index.isValid()) {
            if (!rows.contains(index.row())) {
                rows.push_back(index.row());
                QUrl url = QUrl::fromLocalFile(getTrackLocation(index));
                if (!url.isValid()) {
                    qDebug() << "ERROR invalid url\n";
                } else {
                    urls.append(url);
                    qDebug() << "Appending URL:" << url;
                }
            }
        }
    }
    mimeData->setUrls(urls);
    return mimeData;
}
Example #24
0
void Player::updateCurrent(qint64 msecsElapsed)
{
    // Sanity check
    if(m_script == 0)
        return;
    // Find subtitles that match elapsed time
    QList<Subtitle *> currentSubtitles = m_script->currentSubtitles(msecsElapsed);

    // Compare subtitles that match elapsed time with subtitles that matched elapsed time last
    // time the timer was fired to find the differences
    bool change = false;
    foreach(Subtitle *e, m_lastSubtitles) {
        // Subtitles that where presents and that are no more presents : suppress
        if(!currentSubtitles.contains(e)) {
            emit off(e);
            change = true;
        }
    }
    foreach(Subtitle *e, currentSubtitles) {
        // Subtitles that are presents and that were not presents : add
        if(!m_lastSubtitles.contains(e)) {
            emit on(e);
            change = true;
        }
    }
    m_lastSubtitles = currentSubtitles;
    if (change)
        emit changed(m_lastSubtitles);
}
Example #25
0
  /** 
   * This method is called when the user selects a row or rows
   * uses the delete button or selects the delete row menu item
   * from the file menu.
   * 
   */
  void TableMainWindow::deleteRows () {
    QList<QTableWidgetItem*> list = p_table->selectedItems();
    QList<int> selectedRows;

    for(int i = 0; i < list.size(); i++) {
      if(selectedRows.size() == 0) {
        selectedRows.push_back(p_table->row(list[i]));
      } else if(!selectedRows.contains(p_table->row(list[i]))){
        selectedRows.push_back(p_table->row(list[i]));
      }
    }
    
    qSort(selectedRows.begin(), selectedRows.end());
    for(int d = selectedRows.size(); d > 0; d--) {
      p_table->removeRow(selectedRows[d-1]);
    }
  
    // get the number of rows that are filled in
    int filledRows = 0;
    for(int r = 0; r <  p_table->rowCount(); r++ ) {
      for(int c =0; c < p_table->columnCount(); c++) {
        if(!p_table->item(r,c) || p_table->item(r,c)->text() != "") {
          filledRows++;
          break;
        }
      }
    }
 
    p_currentRow = filledRows;    
  }
bool Slash::IsAvailable(const Player *player, const Card *slash, bool considerSpecificAssignee)
{
    Slash *newslash = new Slash(Card::NoSuit, 0);
    newslash->deleteLater();
#define THIS_SLASH (slash == NULL ? newslash : slash)
    if (player->isCardLimited(THIS_SLASH, Card::MethodUse))
        return false;

    if (Sanguosha->getCurrentCardUseReason() == CardUseStruct::CARD_USE_REASON_PLAY) {
        QList<int> ids;
        if (slash) {
            if (slash->isVirtualCard()) {
                if (slash->subcardsLength() > 0)
                    ids = slash->getSubcards();
            } else {
                ids << slash->getEffectiveId();
            }
        }
        bool has_weapon = player->hasWeapon("Crossbow") && ids.contains(player->getWeapon()->getEffectiveId());
        if ((!has_weapon && player->hasWeapon("Crossbow")) || player->canSlashWithoutCrossbow(THIS_SLASH))
            return true;

        if (considerSpecificAssignee) {
            QStringList assignee_list = player->property("extra_slash_specific_assignee").toString().split("+");
            if (!assignee_list.isEmpty()) {
                foreach (const Player *p, player->getAliveSiblings()) {
                    if (assignee_list.contains(p->objectName()) && player->canSlash(p, THIS_SLASH))
                        return true;
                }
            }
        }
Example #27
0
QList<int> TArea::getCollisionNodes()
{
    QList<int> problems;
    QMap<int, QMap<int, QMultiMap<int, int>>> kS = koordinatenSystem();
    QMapIterator<int, QMap<int, QMultiMap<int, int>>> it(kS);
    while (it.hasNext()) {
        it.next();
        QMap<int, QMultiMap<int, int>> x_val = it.value();
        QMapIterator<int, QMultiMap<int, int>> it2(x_val);
        while (it2.hasNext()) {
            it2.next();
            QMultiMap<int, int> y_val = it2.value();
            QMapIterator<int, int> it3(y_val);
            QList<int> z_coordinates;
            while (it3.hasNext()) {
                it3.next();
                int z = it3.key();
                int node = it3.value();

                if (!z_coordinates.contains(node)) {
                    z_coordinates.append(node);
                } else {
                    if (!problems.contains(node)) {
                        auto it4 = y_val.find(z);
                        problems.append(it4.value());
                        //qDebug()<<"problem node="<<node;
                    }
                }
            }
        }
    }
    return problems;
}
void TableEditorDialog::deleteSelectedRowsOrColumns(Qt::Orientation orientation)
{
    // Note: In the following, both rows and columns will be referred to
    // as "row", for ease of reading this code.
    Q_ASSERT(m_tableView->model());

    const QModelIndexList selectedIndexes = m_tableView->selectionModel()->selectedIndexes();
    if (selectedIndexes.isEmpty())
        return;

    QList<int> rowsToBeRemoved;
    // Make sure we don't delete a row twice, as indexes can exist
    // multiple times for one row
    foreach(const QModelIndex &index, selectedIndexes) {
        const int row = orientation == Qt::Horizontal ? index.row() : index.column();
        if (!rowsToBeRemoved.contains(row))
            rowsToBeRemoved.append(row);
    }

    // Use qGreater<int>() as comparator to remove rows in reversed order
    // to not change the indexes of the selected rows
    qSort(rowsToBeRemoved.begin(), rowsToBeRemoved.end(), qGreater<int>());

    foreach(int row, rowsToBeRemoved) {
        Q_ASSERT(row >= 0);
        if (orientation == Qt::Horizontal)
            m_tableView->model()->removeRow(row);
        else
            m_tableView->model()->removeColumn(row);
    }
Example #29
0
void QTactileFeedback::touchFeedback(QEvent *event, const QWidget *widget)
{
    //Lets share the global instance for touch feedback (you are NOT allowed to try and delete it!).
    MTouchFeedback* feedback = MTouchFeedback::Instance();

    //If the widget itself is not handling focus, try to use focusProxy widget.
    const QWidget *w = ((widget->focusPolicy() == Qt::NoFocus) && (widget->focusProxy())) ? widget->focusProxy() : widget;

    //Only give tactile feedback for enabled widgets that take focus.
    if (feedback && w && w->isEnabled() && w->isWidgetType() && w->isVisible()) {
        //Scrollbars are 'special' that they don't take focus (nor they have focusProxy), yet we'd like to have tactile feedback for them
        if (w->focusPolicy() == Qt::NoFocus)
            if (!qobject_cast<const QScrollBar *>(w))
                return;

        //Don't give tactile feedback for widgets that are outside topmost dialog.
        QWidget *dialog = QApplication::activeModalWidget();
        if (dialog) {
            QList<const QWidget *> allChildren = dialog->findChildren<const QWidget *>();
            if (!allChildren.contains(w))
                return;
        }

        //Widget specific tactile feedback.
        if (qobject_cast<const QSlider *>(w) || qobject_cast<const QScrollBar *>(w))
            feedback->InstantFeedback(ETouchFeedbackSensitive);
        else
            feedback->InstantFeedback(ETouchFeedbackBasic);
    }
}
int DJGameUserContext::createFunctionMenu( DJGameUser* clickedUser, DJGameUser *selfUser )
{
	m_menuFunction->clear();
	int	count	= 0;
	
	if ( ( selfUser->isDown() || selfUser->isReady() )
		 && !clickedUser->isPlaying()
		 && DJGAME_USER_STATUS_NORMAL == clickedUser->generalStatus() 
		 && clickedUser->tableId() != selfUser->tableId() ) {
        m_menuFunction->addAction( m_actInvite );
        count++;
	}
	if ( 0 != selfUser->tableId()
		&& selfUser->tableId() == clickedUser->tableId()
		&& !selfUser->isPlaying() ) {
        DJTableController*	tc	= m_gameController->tableController( selfUser->tableId() );
        if ( tc && tc->isPreceding( selfUser, clickedUser ) ) {
        	m_menuFunction->addAction( m_actForceStandUp );
        	count++;
        }
	}
	QList<quint8> tableIds	=  m_gameController->allPanelTableIds();
	if ( clickedUser->isPlaying()
		&& !tableIds.contains( clickedUser->tableId()) ) {
        m_menuFunction->addAction( m_actLookOn );
        count++;
    }
    if ( DJ_CONTACT_USER_TYPE_FRIEND == m_gameController->contactUserType(clickedUser->userId()) ) {
        m_menuFunction->addAction( m_actChat );
        count++;
    }
    return count;
}