void checkFilterKeyBookkeeping() { // GIVEN QScopedPointer<Qt3DRender::QRenderPassFilter> passFilter(new Qt3DRender::QRenderPassFilter); { // WHEN Qt3DRender::QFilterKey filterKey; passFilter->addMatch(&filterKey); // THEN QCOMPARE(filterKey.parent(), passFilter.data()); QCOMPARE(passFilter->matchAny().size(), 1); } // THEN (Should not crash and parameter be unset) QVERIFY(passFilter->matchAny().empty()); { // WHEN Qt3DRender::QRenderPassFilter someOtherPassFilter; QScopedPointer<Qt3DRender::QFilterKey> filterKey(new Qt3DRender::QFilterKey(&someOtherPassFilter)); passFilter->addMatch(filterKey.data()); // THEN QCOMPARE(filterKey->parent(), &someOtherPassFilter); QCOMPARE(passFilter->matchAny().size(), 1); // WHEN passFilter.reset(); filterKey.reset(); // THEN Should not crash when the parameter is destroyed (tests for failed removal of destruction helper) } }
/*! \internal */ void PropertyBrowser::populateData(bool force) { if(dataInitialised == true && force == false) return; m_values.clear(); QString key = filterKey( m_property ); QStringList args = m_filter.argumentMatches( QContentFilter::Synthetic, key ); int keylen = key.length(); foreach( QString arg, args ) { m_values.append( arg.mid( keylen ) ); }
QString Key8Manager::getKey(QList<QPoint> const & path) { QString key = ""; int last = -1; for (int k = 1; k < path.size(); k++) { for (int i = 0; i < 8; i++) { double det1 = cos(pi / 8 - i * pi / 4) * (path[k].y() - path[k - 1].y()) - sin(pi / 8 - i * pi / 4) * (path[k].x() - path[k - 1].x()); double det2 = cos(pi / 8 - (i + 1) * pi / 4) * (path[k].y() - path[k - 1].y()) - sin(pi / 8 - (i + 1) * pi / 4) * (path[k].x() - path[k - 1].x()); if (det2 >= 0 && det1 < 0 && last != i) { last = i; key += str8[i]; } } } return filterKey(key); }
/*! \fn QString PropertyBrowser::filterString( const QModelIndex& index ) const \internal */ QString PropertyBrowser::filterString( const QModelIndex& index ) const { const_cast<PropertyBrowser *>(this)->populateData(); return filterKey( m_property ) + m_values[index.row()]; }