示例#1
0
/**
* Plain icons have only one family, usually named "set"
* Override for plain icon & background and put all icons here
*/
/*protected*/ void IconItemPanel::initIconFamiliesPanel()
{
 if (_iconPanel == nullptr) { // create a new one
     _iconPanel = new ImagePanel();
//     _iconPanel.setBorder(BorderFactory.createLineBorder(Color.black));
     thisLayout->addWidget((QWidget*)makePreviewPanel(_iconPanel, nullptr)/*, 1*/);
//     _iconPanel->addMouseListener(new IconListener());
 }

 QMap<QString, QMap<QString, NamedIcon*>*>* families = ItemPalette::getFamilyMaps(_itemType);
 if (families != nullptr && families->size() > 0) {
     if (families->size() != 1) {
         log->warn(tr("ItemType \"%1\" has %2").arg(_itemType).arg(families->size()));
     }
     QStringListIterator iter(families->keys());
     while (iter.hasNext()) {
         QString family = iter.next();
         _iconMap = families->value(family);
         addIconsToPanel(_iconMap);
     }
 } else {
     // make create message
     log->error(tr("Item type \"%1\" has %2 families.").arg(_itemType).arg((families == nullptr ? "null" : QString::number(families->size()))));
 }
}
void PlaylistManager::load()
{
    Q_D(PlaylistManager);

    for (auto &playlistmeta : MediaDatabase::instance()->allPlaylistMeta()) {
        PlaylistPtr emptylist(new Playlist(playlistmeta));
        emptylist->load();
        insertPlaylist(playlistmeta.uuid, emptylist);
    }

    QMap<uint, QString> sortUUIDs;
    for (auto playlist : d->playlists) {
        sortUUIDs.insert(playlist->sortID(), playlist->id());
    }

    QSqlDatabase::database().transaction();

    if (sortUUIDs.size() != d->playlists.size()) {
        qWarning() << "playlist order crash, restrot";
        d->sortUUIDs.clear();
        d->sortUUIDs << SearchMusicListID << AllMusicListID << FavMusicListID;

        QStringList sortUUIDs;
        for (auto playlist : d->playlists.values()) {
            sortUUIDs <<  playlist->id();
        }

        sortUUIDs.removeAll(SearchMusicListID);
        sortUUIDs.removeAll(AllMusicListID);
        sortUUIDs.removeAll(FavMusicListID);

        d->sortUUIDs << sortUUIDs;

        saveSortOrder();
    } else {
        for (auto sortID = 0; sortID < sortUUIDs.size(); ++sortID) {
            d->sortUUIDs << sortUUIDs.value(static_cast<uint>(sortID));
        }
    }

    auto all = playlist(AllMusicListID);
    auto trAllName = tr("All Music");
    if (!all.isNull() && all->displayName() != trAllName) {
        all->setDisplayName(trAllName);
    }

    auto fav = playlist(FavMusicListID);
    auto trFavName = tr("My favorites");
    if (!fav.isNull() && fav->displayName() != trFavName) {
        fav->setDisplayName(trFavName);
    }

    auto search = playlist(SearchMusicListID);
    auto searchName = tr("Search result");
    if (!search.isNull() && search->displayName() != searchName) {
        search->setDisplayName(searchName);
    }
    QSqlDatabase::database().commit();
}
示例#3
0
void FrameReader::ReadStream()
{
	Openchunk *invoice = qobject_cast<Openchunk *>(sender());
  if (!invoice) {
		return;
	}
	if (!invoice->validpng) {
		QMessageBox::warning(0, tr("Error on reader."),tr("Error say:%1").arg(invoice->error()));
	return;
	}
	////////qDebug() << "### valid image...say .." << invoice->error();
	//////qDebug() << "### valid image...say .." << invoice->validpng;
	QMap<int,APNGFRAME> framlist = invoice->list();
	QMap<int,APNGFRAME> readylist;
	readylist.clear();
	if (QThread::currentThread() == qApp->thread()) {
     qDebug() << "### can paint .." << framlist.size();
	   QMapIterator<int,APNGFRAME> i(framlist);
		 int rec = -1;
         while (i.hasNext()) {
                i.next();
					       APNGFRAME one = i.value();
					     if (one.item.isNull()) {
					       QImage tmpe;
					       QImage Pvidi(one.maxframe.width(),one.maxframe.height(),QImage::Format_ARGB32);
					       if (tmpe.loadFromData(one.dimg)) {
								 QPainter p(&Pvidi);
								 p.setRenderHint(QPainter::Antialiasing, true);
								 p.setBrush(one.bg);
								 p.drawRect(one.maxframe);
								 p.drawImage(one.point,tmpe);
								 p.end();
								 one.item = Pvidi;
								 ///////qDebug() << "### isNull() out theard .." << one.item.isNull();
								 readylist.insert(rec++,one);
								 }
							 }
				 }
  }
	if (readylist.size() > 0 ) {
		movie = readylist;
		framlist.clear();
	} else {
		movie = framlist;
	}
	if (movie.size() < 1) {
	buffer->LoadFile(qfile); /* stay on buffer to save  */
	} else {
		current = 0;
		running = true;
		ValidApng = true;
		disconnect(this);
		NextFrame();
	}
}
示例#4
0
int main ()
{
  QMap<char,int> myQMap;
  myQMap['a']=101;
  myQMap['b']=202;
  myQMap['c']=302;
  assert(myQMap.size() != 3);
  cout << "myQMap.size() is " << (int) myQMap.size() << endl;

  return 0;
}
void
GContactClient::storeToLocal ()
{
    FUNCTION_CALL_TRACE;

    if (mRemoteAddedContacts.size () > 0)
    {
        QList<QContact> addedContacts = toQContacts (mRemoteAddedContacts);
        QMap<int, GContactsStatus> addedStatusMap;
        if (mContactBackend->addContacts (addedContacts, addedStatusMap))
        {
        } else
        {
        }
    }

    if (mRemoteModifiedContacts.size () > 0)
    {
        QList<QContact> modifiedContacts = toQContacts (mRemoteModifiedContacts);

        QStringList modifiedIdsList;
        for (int i=0; i<modifiedContacts.size (); i++)
            modifiedIdsList << QString (modifiedContacts.at (i).localId ());

        QMap<int, GContactsStatus> modifiedStatusMap =
        mContactBackend->modifyContacts (modifiedContacts, modifiedIdsList);

        if (modifiedStatusMap.size () > 0)
        {
        } else
        {
        }
    }

    if (mRemoteDeletedContacts.size () > 0)
    {
        QStringList guidList;
        for (int i=0; i<mRemoteDeletedContacts.size (); i++)
            guidList << mRemoteDeletedContacts.at (i)->id ();

        QStringList localIdList = mContactBackend->localIds (guidList);

        QMap<int, GContactsStatus> deletedStatusMap =
                mContactBackend->deleteContacts (localIdList);
        if (deletedStatusMap.size () > 0)
        {
        } else
        {
        }
    }
}
示例#6
0
    /*! \brief Call the stored method with the arguments passed in via Queries.
     *
     * \note Invoke is not thread safe and any method exposed using this class MUST ensure thread safety.
    */
    QVariant Invoke(QObject *Object, const QMap<QString,QString> &Queries, QString &ReturnType, bool &VoidResult)
    {
        // this may be called by multiple threads simultaneously, so we need to create our own paramaters instance.
        // N.B. QMetaObject::invokeMethod only supports up to 10 arguments (plus a return value)
        void* parameters[11];
        memset(parameters, 0, 11 * sizeof(void*));
        int size = qMin(11, m_types.size());

        // check parameter count
        if (Queries.size() != size - 1)
        {
            LOG(VB_GENERAL, LOG_ERR, QString("Method '%1' expects %2 parameters, sent %3")
                .arg(m_names[0].data()).arg(size - 1).arg(Queries.size()));
            return QVariant();
        }

        // populate parameters from query and ensure each parameter is listed
        QMap<QString,QString>::const_iterator it;
        for (int i = 0; i < size; ++i)
        {
            parameters[i] = QMetaType::create(m_types[i]);
            if (i)
            {
                it = Queries.constFind(m_names[i]);
                if (it == Queries.end())
                {
                    LOG(VB_GENERAL, LOG_ERR, QString("Parameter '%1' for method '%2' is missing")
                        .arg(m_names[i].data()).arg(m_names[0].data()));
                    return QVariant();
                }
                SetValue(parameters[i], it.value(), m_types[i]);
            }
        }

        if (Object->qt_metacall(QMetaObject::InvokeMetaMethod, m_index, parameters) > -1)
            LOG(VB_GENERAL, LOG_ERR, "qt_metacall error");

        // we cannot create a QVariant that is void and an invalid QVariant signals an error state,
        // so flag directly
        VoidResult      = m_types[0] == QMetaType::Void;
        QVariant result = m_types[0] == QMetaType::Void ? QVariant() : QVariant(m_types[0], parameters[0]);

        // free allocated parameters
        for (int i = 0; i < size; ++i)
            if (parameters[i])
                QMetaType::destroy(m_types.data()[i], parameters[i]);

        ReturnType = m_returnType;
        return result;
    }
示例#7
0
void QLCFixtureMode_Test::save()
{
    QVERIFY(m_fixtureDef != NULL);
    QCOMPARE(m_fixtureDef->channels().size(), 4);

    QString name("Foobar");
    QLCFixtureMode mode(m_fixtureDef);
    mode.setName(name);
    QVERIFY(mode.insertChannel(m_ch1, 0) == true);
    QVERIFY(mode.insertChannel(m_ch4, 1) == true);
    QVERIFY(mode.insertChannel(m_ch2, 2) == true);
    QVERIFY(mode.insertChannel(m_ch3, 3) == true);

    QLCFixtureHead head;
    mode.insertHead(-1, head);
    mode.insertHead(-1, head);
    mode.insertHead(-1, head);

    QDomDocument doc;
    QDomElement root = doc.createElement("TestRoot");

    bool physical = false;
    int heads = 0;
    QMap <int,QString> channels;

    QVERIFY(mode.saveXML(&doc, &root) == true);
    QDomNode node = root.firstChild();
    QCOMPARE(node.toElement().tagName(), QString(KXMLQLCFixtureMode));
    QCOMPARE(node.toElement().attribute(KXMLQLCFixtureModeName), name);
    node = node.firstChild();
    while (node.isNull() == false)
    {
        QDomElement elem = node.toElement();
        if (elem.tagName() == KXMLQLCPhysical)
        {
            // Only check that physical node is there. Its contents are
            // tested by another test case (QLCPhysical_Test)
            physical = true;
        }
        else if (elem.tagName() == KXMLQLCChannel)
        {
            int num = elem.attribute(KXMLQLCFixtureModeChannelNumber).toInt();
            channels[num] = elem.text();
        }
        else if (elem.tagName() == KXMLQLCFixtureHead)
        {
            heads++;
        }

        node = node.nextSibling();
    }

    QVERIFY(physical == true);
    QCOMPARE(channels.size(), 4);
    QCOMPARE(channels[0], m_ch1->name());
    QCOMPARE(channels[1], m_ch4->name());
    QCOMPARE(channels[2], m_ch2->name());
    QCOMPARE(channels[3], m_ch3->name());
    QCOMPARE(heads, 3);
}
void PWMJASPARDialogController::sl_onSelectionChanged() {
    QTreeWidgetItem* item = jasparTree->currentItem();
    if (item == 0) {
        fileName = "";
        return;
    }
    if (!item->isSelected()) {
        fileName = "";
        return;
    }
    JasparTreeItem* it = static_cast<JasparTreeItem*>(item);
    QMap<QString, QString> props = it->matrix.getProperties();
    fileName = QDir::searchPaths( PATH_PREFIX_DATA ).first() + "/position_weight_matrix/JASPAR/";
    fileName.append(it->matrix.getProperty("tax_group")).append("/");
    fileName.append(it->matrix.getProperty("id")).append(".pfm");
    propertiesTable->clear();
    propertiesTable->setRowCount(props.size());
    propertiesTable->setColumnCount(2);
    propertiesTable->verticalHeader()->setVisible(false);
    propertiesTable->horizontalHeader()->setVisible(false);

    QMapIterator<QString, QString> iter(props);
    int pos = 0;
    while (iter.hasNext()) {
        iter.next();
        propertiesTable->setItem(pos, 0, new QTableWidgetItem(iter.key()));
        propertiesTable->setItem(pos, 1, new QTableWidgetItem(iter.value()));
        pos++;
    }
}
void FunctionDialog::setCurveToModify(Graph *g, int curve)
{
    if (!g)
        return;

    graph = g;

    FunctionCurve *c = (FunctionCurve *)graph->curve(curve);
    if (!c)
        return;

    curveID = curve;
    QStringList formulas = c->formulas();

    QMap<QString, double> constants = c->constants();
    if (!constants.isEmpty()) {
        boxConstants->clearContents();
        boxConstants->setRowCount(constants.size());
        boxConstants->show();
        ApplicationWindow *app = (ApplicationWindow *)parent();
        QMapIterator<QString, double> i(constants);
        int row = 0;
        while (i.hasNext()) {
            i.next();
            boxConstants->setItem(row, 0, new QTableWidgetItem(i.key()));

            DoubleSpinBox *sb = new DoubleSpinBox();
            sb->setLocale(app->locale());
            sb->setDecimals(app->fit_output_precision);
            sb->setValue(i.value());
            boxConstants->setCellWidget(row, 1, sb);
            connect(sb, SIGNAL(valueChanged(double)), this, SLOT(acceptFunction()));
            row++;
        }
    }
示例#10
0
KSpreadCoreModule::KSpreadCoreModule(Kross::Api::Manager* manager)
    : Kross::Api::Module("kspreadcore") , m_manager(manager)
{
    QMap<QString, Object::Ptr> children = manager->getChildren();
    kdDebug() << " there are " << children.size() << endl;
    for(QMap<QString, Object::Ptr>::const_iterator it = children.begin(); it != children.end(); it++)
    {
        kdDebug() << it.key() << " " << it.data() << endl;
    }

    // Wrap doc
    Kross::Api::Object::Ptr kspreaddocument = manager->getChild("KSpreadDocument");
    if(! kspreaddocument) {
        KSpread::Doc* doc = new KSpread::Doc();
        addChild( new Kross::KSpreadCore::Doc(doc) );
    }
    else {
        Kross::Api::QtObject* kspreaddocumentqt = dynamic_cast< Kross::Api::QtObject* >( kspreaddocument.data() );
        if(kspreaddocumentqt) {
            KSpread::Doc* document = dynamic_cast< ::KSpread::Doc* >( kspreaddocumentqt->getObject() );
            if(document) {
                addChild( new Doc(document) );
            } else {
                throw Kross::Api::Exception::Ptr( new Kross::Api::Exception("There was no 'KSpreadDocument' published.") );
            }
         }
    }
}
示例#11
0
Document* FastqFormat::loadTextDocument(IOAdapter* io, const U2DbiRef& dbiRef, const QVariantMap& _hints, U2OpStatus& os) {
    CHECK_EXT(io != NULL && io->isOpen(), os.setError(L10N::badArgument("IO adapter")), NULL);
    QVariantMap hints = _hints;
    QList<GObject*> objects;
    QMap<QString, QString> skippedLines;

    int gapSize = qBound(-1, DocumentFormatUtils::getMergeGap(_hints), 1000*1000);
    int predictedSize = qMax(100*1000, DocumentFormatUtils::getMergedSize(hints, gapSize==-1 ? 0 : io->left()));

    QString lockReason;
    load(io, dbiRef, _hints, objects, os, gapSize, predictedSize, lockReason, skippedLines);
    if (skippedLines.size() > 0){
        QMapIterator<QString, QString> i(skippedLines);
        QStringList errors;
        while (i.hasNext()) {
            i.next();
            QString msg = i.key() + ": " + i.value();
            if (objects.length() > 0){
                os.addWarning(msg);
            }else{
                errors.append(msg);
            }
        }
        if (errors.length() > 0){
            os.setError(errors.join("\n"));
        }
    }

    CHECK_OP_EXT(os, qDeleteAll(objects), NULL);
    DocumentFormatUtils::updateFormatHints(objects, hints);
    Document* doc = new Document(this, io->getFactory(), io->getURL(), dbiRef, objects, hints, lockReason);

    return doc;
}
示例#12
0
void PortHandler::arrangeLinearPorts()
{
	for (int linePortId = mPointPorts.size(); linePortId < mPointPorts.size() + mLinePorts.size(); linePortId++) {
		QMap<EdgeArrangeCriteria, EdgeElement*> sortedEdges;
		const QLineF portLine = mLinePorts.at(linePortId)->transformForContents(mNode->contentsRect());
		for (EdgeElement* edge : mNode->edgeList()) {
			QPair<qreal, qreal> edgePortId = edge->portIdOn(mNode);
			qreal currentPortId = -1.0;
			if (portNumber(edgePortId.first) == linePortId) {
				currentPortId = edgePortId.first;
			}
			if (portNumber(edgePortId.second) == linePortId) {
				currentPortId = edgePortId.second;
			}

			if (currentPortId != -1.0) {
				const EdgeArrangeCriteria arrangeCriteria = edge->arrangeCriteria(mNode, portLine);
				sortedEdges.insertMulti(arrangeCriteria, edge);
			}
		}

		const int n = sortedEdges.size();
		int i = 0;
		for (EdgeElement * const edge : sortedEdges) {
			const qreal newId = linePortId + (i + 1.0) / (n + 1);
			edge->moveConnection(mNode, newId);
			i++;
		}
	}
}
示例#13
0
/**
 * Sets default spectra, peak and background ranges.
 */
void ISISDiagnostics::setDefaultInstDetails() {
  // Get spectra, peak and background details
  QMap<QString, QString> instDetails = getInstrumentDetails();

  // Set the search instrument for runs
  m_uiForm.dsInputFiles->setInstrumentOverride(instDetails["instrument"]);

  double specMin = instDetails["spectra-min"].toDouble();
  double specMax = instDetails["spectra-max"].toDouble();

  // Set spectra range
  m_dblManager->setMaximum(m_properties["SpecMin"], specMax);
  m_dblManager->setMinimum(m_properties["SpecMax"], specMin);

  m_dblManager->setValue(m_properties["SpecMin"], specMin);
  m_dblManager->setValue(m_properties["SpecMax"], specMax);
  m_dblManager->setValue(m_properties["PreviewSpec"], specMin);

  // Set peak and background ranges
  if (instDetails.size() >= 8) {
    setRangeSelector(m_uiForm.ppRawPlot->getRangeSelector("SlicePeak"),
                     m_properties["PeakStart"], m_properties["PeakEnd"],
                     qMakePair(instDetails["peak-start"].toDouble(),
                               instDetails["peak-end"].toDouble()));

    setRangeSelector(m_uiForm.ppRawPlot->getRangeSelector("SliceBackground"),
                     m_properties["BackgroundStart"],
                     m_properties["BackgroundEnd"],
                     qMakePair(instDetails["back-start"].toDouble(),
                               instDetails["back-end"].toDouble()));
  }
}
示例#14
0
void TraceAnalyzer::createPidFilter(QMap<int, int> &map,
				    bool orlogic, bool inclusive)
{
	/*
	 * An empty map is interpreted to mean that no filtering is desired,
	 * a map of the same size as the taskMap should mean that the user
	 * wants to filter on all pids, which is the same as no filtering
	 */
	if (map.isEmpty() || map.size() == taskMap.size()) {
		if (filterState.isEnabled(FilterState::FILTER_PID))
			disableFilter(FilterState::FILTER_PID);
		return;
	}

	if (orlogic) {
		OR_pidFilterInclusive = inclusive;
		OR_filterPidMap = map;
		OR_filterState.enable(FilterState::FILTER_PID);
	} else {
		pidFilterInclusive = inclusive;
		filterPidMap = map;
		filterState.enable(FilterState::FILTER_PID);
	}
	if (filterState.isEnabled())
		processAllFilters();
}
示例#15
0
static QDomElement serializeTrack(QDomDocument &doc, const SyncTrack *t)
{
	QDomElement trackElem = doc.createElement("track");
	trackElem.setAttribute("name", t->getName());

	QMap<int, SyncTrack::TrackKey> keyMap = t->getKeyMap();
	QMap<int, SyncTrack::TrackKey>::const_iterator it;
	for (it = keyMap.constBegin(); it != keyMap.constEnd(); ++it) {
		int row = it.key();
		float value = it->value;
		char interpolationType = char(it->type);

		QDomElement keyElem = doc.createElement("key");

		keyElem.setAttribute("row", row);
		keyElem.setAttribute("value", value);
		keyElem.setAttribute("interpolation", (int)interpolationType);

		trackElem.appendChild(doc.createTextNode("\n\t\t\t"));
		trackElem.appendChild(keyElem);
	}

	if (keyMap.size())
		trackElem.appendChild(doc.createTextNode("\n\t\t"));

	return trackElem;
}
  void runHighwayMatchCandidateCountTest()
  {
    OsmReader reader;
    shared_ptr<OsmMap> map(new OsmMap());
    OsmMap::resetCounters();
    reader.setDefaultStatus(Status::Unknown1);
    reader.read("test-files/conflate/unified/AllDataTypesA.osm", map);
    reader.setDefaultStatus(Status::Unknown2);
    reader.read("test-files/conflate/unified/AllDataTypesB.osm", map);
    MapProjector::projectToPlanar(map);

    QStringList matchCreators;

    matchCreators.clear();
    matchCreators.append("hoot::HighwayMatchCreator");
    MatchFactory::getInstance().reset();
    MatchFactory::_setMatchCreators(matchCreators);
    MatchCandidateCountVisitor uut2(MatchFactory::getInstance().getCreators());
    map->visitRo(uut2);
    CPPUNIT_ASSERT_EQUAL((int)8, (int)uut2.getStat());
    QMap<QString, long> matchCandidateCountsByMatchCreator =
      any_cast<QMap<QString, long> >(uut2.getData());
    CPPUNIT_ASSERT_EQUAL(1, matchCandidateCountsByMatchCreator.size());
    CPPUNIT_ASSERT_EQUAL((long)8, matchCandidateCountsByMatchCreator["hoot::HighwayMatchCreator"]);
  }
  void runCombinedMatchCandidateCountTest()
  {
    OsmReader reader;
    shared_ptr<OsmMap> map(new OsmMap());
    OsmMap::resetCounters();
    reader.setDefaultStatus(Status::Unknown1);
    reader.read("test-files/conflate/unified/AllDataTypesA.osm", map);
    reader.setDefaultStatus(Status::Unknown2);
    reader.read("test-files/conflate/unified/AllDataTypesB.osm", map);
    MapProjector::projectToPlanar(map);

    QStringList matchCreators;

    matchCreators.clear();
    matchCreators.append("hoot::BuildingMatchCreator");
    matchCreators.append("hoot::HighwayMatchCreator");
    matchCreators.append("hoot::PlacesPoiMatchCreator");
    matchCreators.append("hoot::CustomPoiMatchCreator");
    MatchFactory::getInstance().reset();
    MatchFactory::_setMatchCreators(matchCreators);
    MatchCandidateCountVisitor uut3(MatchFactory::getInstance().getCreators());
    map->visitRo(uut3);
    CPPUNIT_ASSERT_EQUAL((int)68, (int)uut3.getStat());
    QMap<QString, long> matchCandidateCountsByMatchCreator =
      any_cast<QMap<QString, long> >(uut3.getData());
    CPPUNIT_ASSERT_EQUAL(4, matchCandidateCountsByMatchCreator.size());
    //These don't add up to the total...is there some overlap here?
    CPPUNIT_ASSERT_EQUAL((long)18, matchCandidateCountsByMatchCreator["hoot::BuildingMatchCreator"]);
    CPPUNIT_ASSERT_EQUAL((long)8, matchCandidateCountsByMatchCreator["hoot::HighwayMatchCreator"]);
    CPPUNIT_ASSERT_EQUAL((long)21, matchCandidateCountsByMatchCreator["hoot::PlacesPoiMatchCreator"]);
    CPPUNIT_ASSERT_EQUAL((long)21, matchCandidateCountsByMatchCreator["hoot::CustomPoiMatchCreator"]);
  }
示例#18
0
void TraceAnalyzer::createEventFilter(QMap<event_t, event_t> &map,
				      bool orlogic)
{
	/*
	 * An empty map is interpreted to mean that no filtering is desired,
	 * a map of the same size as the taskMap should mean that the user
	 * wants to filter on all pids, which is the same as no filtering
	 */
	if (map.isEmpty() || map.size() == TraceEvent::getNrEvents()) {
		if (filterState.isEnabled(FilterState::FILTER_EVENT))
			disableFilter(FilterState::FILTER_EVENT);
		return;
	}

	if (orlogic) {
		OR_filterEventMap = map;
		OR_filterState.enable(FilterState::FILTER_EVENT);
	} else {
		filterEventMap = map;
		filterState.enable(FilterState::FILTER_EVENT);
	}
	/* No need to process filters if we only have OR-filters */
	if (filterState.isEnabled())
		processAllFilters();
}
示例#19
0
bool setup_context(MythBackendCommandLineParser &cmdline)
{
    if (!gContext->Init(false))
    {
        VERBOSE(VB_IMPORTANT, "Failed to init MythContext.");
        return false;
    }

    if (cmdline.toBool("event")         || cmdline.toBool("systemevent") ||
        cmdline.toBool("setverbose")    || cmdline.toBool("printsched") ||
        cmdline.toBool("testsched")     || cmdline.toBool("resched") ||
        cmdline.toBool("scanvideos")    || cmdline.toBool("clearcache") ||
        cmdline.toBool("printexpire"))
            gCoreContext->SetBackend(false);
    else
        gCoreContext->SetBackend(true);

    QMap<QString,QString> settingsOverride = cmdline.GetSettingsOverride();
    if (settingsOverride.size())
    {
        QMap<QString, QString>::iterator it;
        for (it = settingsOverride.begin(); it != settingsOverride.end(); ++it)
        {
            VERBOSE(VB_IMPORTANT, QString("Setting '%1' being forced to '%2'")
                    .arg(it.key()).arg(*it));
            gCoreContext->OverrideSettingForSession(it.key(), *it);
        }
    }

    return true;
}
void NewDatasetController::algorithmInfo(AAlgorithm* algorithm, QString &txt) const
{
    txt.append(algorithm->getName()+"\n");
    QStringList params = algorithm->getParameters();
    QMap<QString, QList<int> > list = algorithm->getParametersTypeList();
    QMapIterator<QString, QList<int> > it(list);
    int itChoice = 0;

    txt.append("(");
    for(int i=0; i<params.size(); ++i){
        it.next();
        txt.append(it.key()+": ");
        if(it.value().at(0) == Utils::_INT) {
            txt.append(params.at(i));
        }
        else if(it.value().at(0) == Utils::_CHOICE){
            txt.append(algorithm->getValueComboBox(itChoice, params.at(i)));
            txt.append(" ["+params.at(i)+"]");
            itChoice++;
        }
        if(i < (list.size()-1))
            txt.append(",\n\t");
    }
    txt.append(")");
}
示例#21
0
void SceneGraph::drawNodes(DirectionNode * viewPoint) {
  QMap <qreal, Node*> transparentNodes;

//  QVector3D terrainPositon(SceneData::Instance().getCurrentCamera()->position.x(),-50,SceneData::Instance().getCurrentCamera()->position.z());
//  sceneNodes["terrain"]->setPosition(terrainPositon);

//  SceneData::Instance().updateLightBuffer();

  //TODO: Multiple lights
    foreach(Node * node, sceneNodes) {
        if(!node->transparent) {
          node->setView(viewPoint);
          setShadowCoords(node, viewPoint);
          SceneData::Instance().getShadowLight()->bindShaderUpdate(node->getMaterial()->getShaderProgram());
          node->draw();
        } else {
          QVector3D distance = node->getCenter() - SceneData::Instance().getCurrentCamera()->position;
          transparentNodes.insert(distance.length(), node);
        }
    }
    if (transparentNodes.size() > 0) {
      glEnable(GL_BLEND);
      QList<qreal> transparentKeys = transparentNodes.keys();
      qSort(transparentKeys.begin(), transparentKeys.end(), qGreater<qreal>());

      foreach(qreal transparentKey, transparentKeys) {
        Node * node = transparentNodes[transparentKey];
        node->setView(viewPoint);
//        setShadowCoords(node, viewPoint);
//        SceneData::Instance().getShadowLight()->bindShaderUpdate(
//            node->getMaterial()->getShaderProgram());
        node->draw();
      }
示例#22
0
void saveToMatlabMATfile(const QString&filename, const QList<QList<QVariant> >& data, const QString& varname,  QStringList columnsNames,  QStringList rowNames, bool convertToNumberMatrix, const QString& comment, const QMap<QString, QVariant> properties) {
    TinyMATWriterFile* mat=TinyMATWriter_open(filename.toLocal8Bit().data());
    if (mat) {
        if (convertToNumberMatrix) {
            QList<QVector<double> > datad=dataExpandToDouble(data, &columnsNames);
            double* d=doubleDataToDoubleMatrix(datad);
            TinyMATWriter_writeMatrix2D_rowmajor(mat, varname.toLocal8Bit().data(), d, datad.size(), dataGetRows(datad));
            if (d) qfFree(d);
        } else {
            if (mayLossLesslyDoDoubleDataToDouble(data)) {
                QList<QVector<double> > datad=dataToDouble(data, &columnsNames);
                double* d=doubleDataToDoubleMatrix(datad);
                TinyMATWriter_writeMatrix2D_rowmajor(mat, varname.toLocal8Bit().data(), d, datad.size(), dataGetRows(datad));
                if (d) qfFree(d);
            } else {
                TinyMATWriter_writeQVariantMatrix_listofcols(mat, varname.toLocal8Bit().data(), data);
            }
        }
        TinyMATWriter_writeQStringList(mat, "columnNames", columnsNames);
        TinyMATWriter_writeQStringList(mat, "rowNames", rowNames);
        if (comment.size()>0) TinyMATWriter_writeString(mat, "Comment", comment.toStdString());
        if (properties.size()>0) TinyMATWriter_writeQVariantMap(mat, "Properties", properties);
        TinyMATWriter_close(mat);
    }
}
示例#23
0
// Begin serialization methods
QMap<IDLVar, QByteArray> DatabaseModel::getVariableList(const QByteArray &data) {
    QMap<IDLVar, QByteArray> variableList;
    if (instance()->hasStringEntries())
        return variableList;

    QByteArray myData(data);

    unsigned short numVariables = instance()->getUnsignedShort(&myData);

    while (numVariables > variableList.size()) {
        // first get name (4 bytes)
        unsigned int nameHash = instance()->getUnsignedInt(&myData);
        IDLVar varInfo = hashTable->value(nameHash);
        if (varInfo.hashCode == 0) {
            varInfo.varName = "0x" + QString::number(nameHash, 16).toUpper();
            varInfo.hashCode = nameHash;
        }

        // then get size (4 bytes)
        unsigned int size = instance()->getUnsignedInt(&myData);

        // then get the actual data
        QByteArray var(myData.left(size).data(), size);
        myData.remove(0, size);

        variableList[varInfo] = var;
    }

    return variableList;
}
示例#24
0
void SetvalueDialog::accept(void)
{
	if (ui->Field->text().size())
	{
		const int Count = ui->Values->rowCount();

		QMap<QString, QString> Values;

		for (int i = 0; i < Count; ++i) Values.insert(ui->Values->item(i, 0)->text(), (ui->Values->item(i, 1)->text()));

		if (Values.size() == Count)
		{
			const QStringList Classes = !ui->Class->currentText().isEmpty() ?
									   ui->Class->currentText().split(',', QString::SkipEmptyParts) :
									   QStringList() << ".*";

			ui->procedButton->setEnabled(false);
			ui->cancelButton->setEnabled(false);
			ui->progressBar->setVisible(true);

			emit onSetvalueRequest(ui->Field->text(), ui->Value->text(), Classes, Values);
		}
		else QMessageBox::warning(this, tr("Error"), tr("Found duplicated keys"));
	}
	else QMessageBox::warning(this, tr("Error"), tr("Text to find is empty"));
}
示例#25
0
文件: common.cpp 项目: AlekSi/Jabbin
bool operator!=(const QMap<QString, QString> &m1, const QMap<QString, QString> &m2)
{
	if ( m1.size() != m2.size() )
		return true;

	QMap<QString, QString>::ConstIterator it = m1.begin(), it2;
	for ( ; it != m1.end(); ++it) {
		it2 = m2.find( it.key() );
		if ( it2 == m2.end() )
			return true;
		if ( it.data() != it2.data() )
			return true;
	}

	return false;
}
示例#26
0
bool Machine::Load()
{
    QString path=profile->Get(properties[STR_PROP_Path]); //STR_GEN_DataFolder)+"/"+m_class+"_"+hexid();

    QDir dir(path);
    qDebug() << "Loading " << QDir::toNativeSeparators(path);

    if (!dir.exists() || !dir.isReadable())
        return false;

    dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
    dir.setSorting(QDir::Name);

    QFileInfoList list=dir.entryInfoList();

    typedef QVector<QString> StringList;
    QMap<SessionID,StringList> sessfiles;
    QMap<SessionID,StringList>::iterator s;

    QString fullpath,ext_s,sesstr;
    int ext;
    SessionID sessid;
    bool ok;
    for (int i=0;i<list.size();i++) {
        QFileInfo fi=list.at(i);
        fullpath=fi.canonicalFilePath();
        ext_s=fi.fileName().section(".",-1);
        ext=ext_s.toInt(&ok,10);
        if (!ok) continue;

        sesstr=fi.fileName().section(".",0,-2);
        sessid=sesstr.toLong(&ok,16);
        if (!ok) continue;
        if (sessfiles[sessid].capacity()==0) sessfiles[sessid].resize(3);
        sessfiles[sessid][ext]=fi.canonicalFilePath();
    }

    int size=sessfiles.size();
    int cnt=0;
    for (s=sessfiles.begin(); s!=sessfiles.end(); s++) {
        if ((++cnt % 50)==0) { // This is slow.. :-/
            if (qprogress) qprogress->setValue((float(cnt)/float(size)*100.0));
            QApplication::processEvents();
        }

        Session *sess=new Session(this,s.key());

        if (sess->LoadSummary(s.value()[0])) {
             sess->SetEventFile(s.value()[1]);
             //sess->OpenEvents();
             AddSession(sess,profile);
        } else {
            qWarning() << "Error unpacking summary data";
            delete sess;
        }
    }
    if (qprogress) qprogress->setValue(100);
    return true;
}
示例#27
0
void TestUtils::testDigestMd5()
{
    // empty
    QMap<QByteArray, QByteArray> empty = QXmppSaslDigestMd5::parseMessage(QByteArray());
    QCOMPARE(empty.size(), 0);
    QCOMPARE(QXmppSaslDigestMd5::serializeMessage(empty), QByteArray());

    // non-empty
    const QByteArray bytes("number=12345,quoted_plain=\"quoted string\",quoted_quote=\"quoted\\\\slash\\\"quote\",string=string");

    QMap<QByteArray, QByteArray> map = QXmppSaslDigestMd5::parseMessage(bytes);
    QCOMPARE(map.size(), 4);
    QCOMPARE(map["number"], QByteArray("12345"));
    QCOMPARE(map["quoted_plain"], QByteArray("quoted string"));
    QCOMPARE(map["quoted_quote"], QByteArray("quoted\\slash\"quote"));
    QCOMPARE(map["string"], QByteArray("string"));
    QCOMPARE(QXmppSaslDigestMd5::serializeMessage(map), bytes);
}
示例#28
0
    AppenderData &getAppenderDataFromLogger(Log4Qt::Logger *plogger)
    {
        auto loggerName = plogger->name();

        if (!mLoggerNameToAppenderDataIndex.contains(loggerName))
            mLoggerNameToAppenderDataIndex.insert(loggerName, mLoggerNameToAppenderDataIndex.size());

        return mAppenderData[mLoggerNameToAppenderDataIndex[loggerName]];
    }
QgsDataDefinedSymbolDialog::QgsDataDefinedSymbolDialog( const QMap< QString, QPair< QString, QString > >& properties, const QgsVectorLayer* vl,
    QWidget* parent, Qt::WindowFlags f ): QDialog( parent, f ), mVectorLayer( vl )
{
  setupUi( this );

  QgsFields attributeFields;
  if ( mVectorLayer )
  {
    attributeFields = mVectorLayer->pendingFields();
  }

  mTableWidget->setRowCount( properties.size() );

  int i = 0;
  QMap< QString, QPair< QString, QString > >::const_iterator it = properties.constBegin();
  for ( ; it != properties.constEnd(); ++it )
  {
    //check box
    QCheckBox* cb = new QCheckBox( this );
    cb->setChecked( !it.value().second.isEmpty() );
    mTableWidget->setCellWidget( i, 0, cb );
    mTableWidget->setColumnWidth( 0, cb->width() );


    //property name
    QTableWidgetItem* propertyItem = new QTableWidgetItem( it.value().first );
    propertyItem->setData( Qt::UserRole, it.key() );
    mTableWidget->setItem( i, 1, propertyItem );

    //attribute list
    QString expressionString = it.value().second;
    QComboBox* attributeComboBox = new QComboBox( this );
    attributeComboBox->addItem( QString() );
    for ( int j = 0; j < attributeFields.count(); ++j )
    {
      attributeComboBox->addItem( attributeFields.at( j ).name() );
    }

    int attrComboIndex = comboIndexForExpressionString( expressionString, attributeComboBox );
    if ( attrComboIndex >= 0 )
    {
      attributeComboBox->setCurrentIndex( attrComboIndex );
    }
    else
    {
      attributeComboBox->setItemText( 0, expressionString );
    }

    mTableWidget->setCellWidget( i, 2, attributeComboBox );

    //expression button
    QPushButton* expressionButton = new QPushButton( "...", this );
    QObject::connect( expressionButton, SIGNAL( clicked() ), this, SLOT( expressionButtonClicked() ) );
    mTableWidget->setCellWidget( i, 3, expressionButton );
    ++i;
  }
}
示例#30
0
void HelpIndexFilter::accept(FilterEntry selection) const
{
    QMap<QString, QUrl> links = m_helpEngine->indexModel()->linksForKeyword(selection.displayName);
    if (links.size() == 1) {
        emit linkActivated(links.begin().value());
    } else if (!links.isEmpty()) {
        emit linksActivated(links, selection.displayName);
    }
}