void GPSSyncDialog::setImages(const KUrl::List& images)
{
    for ( KUrl::List::ConstIterator it = images.begin(); it != images.end(); ++it )
    {
        KipiImageItem* const newItem = new KipiImageItem(d->interface, *it);
        newItem->loadImageData(true, false);
        d->imageModel->addItem(newItem);
    }

    QList<QPersistentModelIndex> imagesToLoad;
    for (int i=0; i<d->imageModel->rowCount(); ++i)
    {
        imagesToLoad << d->imageModel->index(i, 0);
    }

    slotSetUIEnabled(false);
    slotProgressSetup(imagesToLoad.count(), i18n("Loading metadata - %p%"));

    // initiate the saving
    d->fileIOCountDone     = 0;
    d->fileIOCountTotal    = imagesToLoad.count();
    d->fileIOFutureWatcher = new QFutureWatcher<QPair<KUrl, QString> >(this);

    connect(d->fileIOFutureWatcher, SIGNAL(resultsReadyAt(int,int)),
            this, SLOT(slotFileMetadataLoaded(int,int)));

    d->fileIOFuture = QtConcurrent::mapped(imagesToLoad, LoadFileMetadataHelper(d->imageModel));
    d->fileIOFutureWatcher->setFuture(d->fileIOFuture);
}
void CSearchDialog::openDialog(const QList<CSwordModuleInfo*> modules, const QString& searchText, QWidget* parentDialog) {
    if (!m_staticDialog) {
        m_staticDialog = new CSearchDialog(parentDialog);
    };
    m_staticDialog->reset();

    if (modules.count()) {
        m_staticDialog->setModules(modules);
    }
    else {
        m_staticDialog->showModulesSelector();
    }

    m_staticDialog->setSearchText(searchText);
    if (m_staticDialog->isHidden()) {
        m_staticDialog->show();
    }

    if (modules.count() && !searchText.isEmpty()) {
        m_staticDialog->startSearch();
    }
    // moved these to after the startSearch() because
    // the progress dialog caused them to loose focus.
    m_staticDialog->raise();
    m_staticDialog->activateWindow();
}
Example #3
0
/*!
  \reimp
*/
void QStringListModel::sort(int, Qt::SortOrder order)
{
    emit layoutAboutToBeChanged();

    QList<QPair<QString, int> > list;
    for (int i = 0; i < lst.count(); ++i)
        list.append(QPair<QString, int>(lst.at(i), i));

    if (order == Qt::AscendingOrder)
        qSort(list.begin(), list.end(), ascendingLessThan);
    else
        qSort(list.begin(), list.end(), decendingLessThan);

    lst.clear();
    QVector<int> forwarding(list.count());
    for (int i = 0; i < list.count(); ++i) {
        lst.append(list.at(i).first);
        forwarding[list.at(i).second] = i;
    }

    QModelIndexList oldList = persistentIndexList();
    QModelIndexList newList;
    for (int i = 0; i < oldList.count(); ++i)
        newList.append(index(forwarding.at(oldList.at(i).row()), 0));
    changePersistentIndexList(oldList, newList);

    emit layoutChanged();
}
QByteArray QDeclarativeListModelParser::compile(const QList<QDeclarativeCustomParserProperty> &customProps)
{
    QList<ListInstruction> instr;
    QByteArray data;
    listElementTypeName = QByteArray(); // unknown

    for(int ii = 0; ii < customProps.count(); ++ii) {
        const QDeclarativeCustomParserProperty &prop = customProps.at(ii);
        if(!prop.name().isEmpty()) { // isn't default property
            error(prop, QDeclarativeListModel::tr("ListModel: undefined property '%1'").arg(QString::fromUtf8(prop.name())));
            return QByteArray();
        }

        if(!compileProperty(prop, instr, data)) {
            return QByteArray();
        }
    }

    int size = sizeof(ListModelData) +
               instr.count() * sizeof(ListInstruction) +
               data.count();

    QByteArray rv;
    rv.resize(size);

    ListModelData *lmd = (ListModelData *)rv.data();
    lmd->dataOffset = sizeof(ListModelData) +
                     instr.count() * sizeof(ListInstruction);
    lmd->instrCount = instr.count();
    for (int ii = 0; ii < instr.count(); ++ii)
        lmd->instructions()[ii] = instr.at(ii);
    ::memcpy(rv.data() + lmd->dataOffset, data.constData(), data.count());

    return rv;
}
QMap<QString,QString> databaseFile:: insertItemWithKeyId(QString table, QList<QString> infoInsert) // id is key ( increase each time)
{
    QList<QString> dbGet = getDbStructure(table);
    QMap<QString,QString> item;
    int numDb			 = dbGet.count();
    int numFieldInsert	 = infoInsert.count();
    if(numFieldInsert == numDb - 1) // number insert equal ( except id)
    {
        QMap<QString,QString> maxItem = searchMax(table,"id");
        int maxId = maxItem["id"].toInt() +1;
        item["id"] = QString::number(maxId); // id must be the first order
        for(int j=1; j<numDb; j++)
            item[dbGet.at(j)] = infoInsert.at(j-1);
        // append
        if(table =="class")
            classList.append(item);
        else if(table =="class_member")
            classMemberList.append(item);
        else if(table =="course")
            courseList.append(item);
        else if(table =="course_skill")
            courseSkillList.append(item);
        else if(table =="material")
            materialList.append(item);
        else if(table =="materialuse")
            materialUseList.append(item);
        else if(table =="member")
            memberList.append(item);
        else if(table =="skill")
            skillList.append(item);
        else if(table =="skill_material")
            skillMaterialList.append(item);
    }
    return item;
}
const CLanguageMgr::LangMap& CLanguageMgr::availableLanguages() {
	QList<CSwordModuleInfo*> mods = CPointers::backend()->moduleList();

	if ( m_availableModulesCache.moduleCount != (unsigned int)mods.count() ) { //we have to refill the cached map
		m_availableModulesCache.availableLanguages.clear();
		m_availableModulesCache.moduleCount = mods.count();

		//collect the languages abbrevs of all modules
		QStringList abbrevs;

		foreach (const CSwordModuleInfo* mod,  mods) {
			if (!abbrevs.contains(mod->module()->Lang())){
				abbrevs.append(mod->module()->Lang());
			}
		}

		//now create a map of available langs
		foreach ( QString abbrev, abbrevs ) {
			const Language* const lang = languageForAbbrev(abbrev);

			if (lang->isValid()) {
				m_availableModulesCache.availableLanguages.insert( abbrev, lang );
			}
			else { //invalid lang used by a module, create a new language using the abbrev
				Language* newLang = new Language(abbrev, abbrev, abbrev);
				m_cleanupLangPtrs.append(newLang);
				m_availableModulesCache.availableLanguages.insert( abbrev, newLang );
			}
		}
	}
Example #7
0
void QQuickViewTestUtil::QaimModel::addItems(const QList<QPair<QString, QString> > &items)
{
    emit beginInsertRows(QModelIndex(), list.count(), list.count()+items.count()-1);
    for (int i=0; i<items.count(); i++)
        list.append(QPair<QString,QString>(items[i].first, items[i].second));
    emit endInsertRows();
}
Package* AbstractRepository::findOnePackage(
        const QString& package, QString* err)
{
    AbstractRepository* rep = AbstractRepository::getDefault_();
    Package* p = rep->findPackage_(package);

    if (!p) {
        QList<Package*> packages = rep->findPackagesByShortName(package);

        if (packages.count() == 0) {
            *err = QObject::tr("Unknown package: %1").arg(package);
        } else if (packages.count() > 1) {
            QString names;
            for (int i = 0; i < packages.count(); ++i) {
                if (i != 0)
                    names.append(", ");
                Package* pi = packages.at(i);
                names.append(pi->title).append(" (").append(pi->name).
                        append(")");
            }
            *err = QObject::tr("More than one package was found: %1").
                    arg(names);
            qDeleteAll(packages);
        } else {
            p = packages.at(0);
        }
    }

    return p;
}
HbInputButtonPrivate::HbInputButtonPrivate(HbInputButton::HbInputButtonType type, HbInputButton::HbInputButtonState state,
        const QPoint &position, const QSize &size, int keyCode, bool autoRepeat,
        const QList<QString> &texts, const QString &mappedCharacters, const QList<HbIcon> &icons)
    : mType(type), mState(state), mPosition(position), mSize(size), mKeyCode(keyCode), mAutoRepeat(autoRepeat),
      mMappedCharacters(mappedCharacters)
{
    for (int i = 0; i < HbInputButton::ButtonTextIndexCount; ++i) {
        if (i < texts.count()) {
            mTexts.append(texts.at(i));
        } else {
            mTexts.append(QString());
        }
    }

    for (int i = 0; i < HbInputButton::ButtonIconIndexCount; ++i) {
        if (i < icons.count()) {
            mIcons.append(icons.at(i));
        } else {
            mIcons.append(HbIcon());
        }
    }

    if (mSize.width() < 1) {
        mSize.setWidth(1);
    }
    if (mSize.height() < 1) {
        mSize.setHeight(1);
    }
}
Example #10
0
void
CurveGroup::newCurve(int key, bool closed)
{
  //-------------------
  // cull zero curves
  QList<Curve*> curves = m_cg.values(key);
  QList<Curve*> nc;
  for(int j=0; j<curves.count(); j++)
    {
      if (curves[j]->pts.count() > 0)
	nc << curves[j];
      else
	delete curves[j];
    }
  if (nc.count() < curves.count())
    {
      m_cg.remove(key);
      for(int j=0; j<nc.count(); j++)
	m_cg.insert(key, nc[j]);
    }
  //-------------------

  Curve *c = new Curve();
  c->tag = Global::tag();
  c->thickness = Global::thickness();
  c->closed = closed;
  m_cg.insert(key, c);

  m_pointsDirtyBit = true;
}
Example #11
0
void OutputRangeNode::inputsUpdated( qint64 pTimeStamp )
{
	if( !pTimeStamp )
	{
		return;
	}

	QList< QSharedPointer<fugio::PinInterface> >	PinLst = mNode->enumOutputPins();

	int						 PinIdx = -1;
	int						 PinCnt = PinLst.count();

	if( PinCnt != mPinCnt )
	{
		mPidIdx = -1;

		mPinCnt = PinCnt;
	}

	if( !mPinCnt || !mPinInput->isConnectedToActiveNode() )
	{
		return;
	}

	fugio::VariantInterface		*V;

	if( mPinNumber->isConnectedToActiveNode() && ( V = input<fugio::VariantInterface *>( mPinNumber ) ) != nullptr )
	{
		PinIdx = qBound( 0.0, V->variant().toDouble(), 1.0 ) * double( PinCnt - 1 );
	}
	else
	{
		PinIdx = qBound( 0.0, mPinNumber->value().toDouble(), 1.0 ) * double( PinCnt - 1 );
	}

	if( PinIdx == mPidIdx && !mPinInput->isUpdated( pTimeStamp ) )
	{
		return;
	}

	for( int i = 0 ; i < PinLst.count() ; i++ )
	{
		QSharedPointer<fugio::PinInterface>	P = PinLst[ i ];

		if( P->order() == PinIdx )
		{
			P->setControl( mPinInput->connectedPin()->control() );

			pinUpdated( P );
		}
		else
		{
			//P->setControl( QSharedPointer<fugio::PinControlInterface>() );

//			pinUpdated( P );
		}
	}

	mPidIdx = PinIdx;
}
Example #12
0
void
CurveGroup::generateXYpoints()
{
  m_xpoints.clear();
  m_ypoints.clear();

  QList<int> keys = m_cg.keys();
  for(int k=0; k<keys.count(); k++)
    {
      int z = keys[k];
      QList<Curve*> c = m_cg.values(z);
      for(int ic=0; ic<c.count(); ic++)
	{
	  int xcount = c[ic]->pts.count(); 
	  for (int i=0; i<xcount; i++)
	    {
	      int x = c[ic]->pts[i].x();
	      int y = c[ic]->pts[i].y();
	      // Z, X, Y
	      // d, h, w
	      // w, h, d
	      // h, w, d
	      m_xpoints.insert(x, QPoint(z, y));
	      m_ypoints.insert(y, QPoint(z, x));
	    }
	}
    }

  m_pointsDirtyBit = false;
}
Example #13
0
/**
 * @brief cwRegionLoadTask::loadSurveyChunk
 * @param protoChunk
 * @param chunk
 */
void cwRegionLoadTask::loadSurveyChunk(const CavewhereProto::SurveyChunk& protoChunk, cwSurveyChunk *chunk)
{
    QList<cwStation> stations;
    stations.reserve(protoChunk.stations_size());
    for(int i = 0 ; i < protoChunk.stations_size(); i++) {
        cwStation station = loadStation(protoChunk.stations(i));
        stations.append(station);
    }

    QList<cwShot> shots;
    shots.reserve(protoChunk.shots_size());
    for(int i = 0; i < protoChunk.shots_size(); i++) {
        cwShot shot = loadShot(protoChunk.shots(i));
        shots.append(shot);
    }

    if(stations.count() - 1 != shots.count()) {
        qDebug() << "Shot, station count mismatch, survey chunk invalid:" << stations.count() << shots.count();
        return;
    }

    for(int i = 0; i < stations.count() - 1; i++) {
        cwStation fromStation = stations[i];
        cwStation toStation = stations[i + 1];
        cwShot shot = shots[i];

        chunk->appendShot(fromStation, toStation, shot);
    }
}
Example #14
0
void LauncherWindow::set_arg(QString action, QString arg, QString val) {
    qDebug() << "set_arg" << action << " " << arg << " " << val;
    QList<QTreeWidgetItem *> items = tree->findItems(arg, Qt::MatchExactly, 0);

    if(action == "remove") {
        if(items.count() == 0) { //* item not there
            return;
        }
        QTreeWidgetItem *removeItem = items.first();
        tree->invisibleRootItem()->removeChild(removeItem);
        return;
    }

    if(action == "set") {
        if(items.count() == 0) {
            QTreeWidgetItem *newItem = new QTreeWidgetItem(); //* add Item if not exist
            newItem->setText(C_ARG, arg);
            newItem->setTextAlignment(C_ARG, Qt::AlignRight);
            newItem->setText(C_VAL, val);
            tree->addTopLevelItem(newItem);
            return;
        } else {
            QTreeWidgetItem *item =  items.first();  //* update existing
            item->setText(C_VAL, val);
            return;
        }

    }
    qDebug() << "UNHANDLED";

}
void CModuleIndexDialog::indexAllModules( const QList<CSwordModuleInfo*>& modules ) {
    static bool indexing = false;
    if (!indexing) {
        indexing = true;
        if (modules.count() < 1) return;

        m_currentModuleIndex = 0;
        m_progress = new QProgressDialog(QString(""), tr("Cancel"), 0, modules.count()*100);
        m_progress->setWindowModality(Qt::WindowModal); // not useful actually, should have parent for this
        m_progress->setWindowTitle(tr("Creating indices"));
        m_progress->show();
        m_progress->raise();

        foreach (CSwordModuleInfo* info, modules) {
            //TODO: how to cancel
            //QObject::connect(CPointers::backend(), SIGNAL(sigSwordSetupChanged()), this, SLOT(swordSetupChanged()));
            connect(this, SIGNAL(sigCancel()), info, SLOT(cancelIndexing()) );
            connect(m_progress, SIGNAL(canceled()), info, SLOT(cancelIndexing()));
            connect(info, SIGNAL(indexingFinished()), this, SLOT(slotFinished()));
            connect(info, SIGNAL(indexingProgress(int)), this, SLOT(slotModuleProgress(int)) );
            QString modname(info->name());
            const QString labelText = tr("Creating index for work: %1").arg(modname);
            m_progress->setLabelText(labelText);
            //todo: if we want to cancel indexing from
            info->buildIndex(); //waits until this module is finished

            m_currentModuleIndex++;
            disconnect(m_progress, SIGNAL(canceled()), info, SLOT(cancelIndexing()));
            disconnect(info, SIGNAL(indexingFinished()), this, SLOT(slotFinished()));
            disconnect(info, SIGNAL(indexingProgress(int)), this, SLOT(slotModuleProgress(int)) );
            if (m_progress->wasCanceled()) break;
        }
    void elements()
    {
        QFETCH(QString, version);
        QFETCH(QString, element);
        QFETCH(bool, exists);

        QQmlEngine engine;
        QString qml = QString("import QtQuick 2.0\nimport QtSensors %1\n%2 {}").arg(version).arg(element);
        QQmlComponent c(&engine);
        c.setData(qml.toLocal8Bit(), QUrl::fromLocalFile(QDir::currentPath()));
        if (!exists)
            QTest::ignoreMessage(QtWarningMsg, "QQmlComponent: Component is not ready");
        QObject *obj = c.create();
        QCOMPARE(exists, (obj != 0));
        delete obj;
        QList<QQmlError> errors = c.errors();
        if (exists) {
            QCOMPARE(errors.count(), 0);
        } else {
            QCOMPARE(errors.count(), 1);
            QString expected = QString("Cannot create %1").arg(element);
            QString actual = errors.first().description();
            QCOMPARE(expected, actual);
        }
    }
 void MotionPlanningFrame::loadWaypointsToDisplay(QList<QListWidgetItem*> items)
 {
     std::vector<apc_msgs::PrimitiveAction> actions(items.count());
     for (int i = 0; i < items.count(); i++)
         loadActionFromData(actions[i], items[i]->data(Qt::UserRole));
     loadWaypointsToDisplay(actions);
 }
Example #18
0
bool
VolumeInformation::checkForDoubleVolume(QList<QString> files1,
					QList<QString> files2)
{
  if (files1.count() > 0 &&
      files2.count() > 0)
    {
      // check if the all volumes have same dimensions
      VolumeInformation pvlInfo1;
      VolumeInformation pvlInfo2;
      volInfo(files1[0], pvlInfo1);
      volInfo(files2[0], pvlInfo2);
      if ((pvlInfo1.dimensions-pvlInfo2.dimensions).squaredNorm() < 1)
	{
	  int ok = QMessageBox::question(0, "Double Volume ?",
		   QString("We already have volume loaded with %1 time steps.\nLoad this volume (with %2 time steps) as double volume ?"). \
					 arg(files1.count()).\
					 arg(files2.count()),
					 QMessageBox::Yes | QMessageBox::No);
	  if (ok == QMessageBox::Yes)
	    return true;
	}
    }
  return false;
}
QStandardItem* getColumnItem(QStandardItem* parent, QString name, T& proxy)
{
    QStandardItem* item = NULL;
    QList<QStandardItem*> items = findChildItems(parent, name);
    if (items.count() == 0)
    {
        // Create a new item because we did not find this item already
        item = new QStandardItem(proxy.name);
        item->setCheckState( (proxy.flag == 2 ? Qt::Checked : Qt::Unchecked) );
        item->setCheckable(true);
        parent->appendRow(item);
    }
    else if (items.count() > 1)
    {
        item = NULL;
    }
    else
    {
        item = items.at(0);
        item->setCheckState( (proxy.flag == 2 ? Qt::Checked : Qt::Unchecked) );
        item->setCheckable(true);
    }

    return item;
}
void QgsTessellatedPolygonGeometry::setPolygons( const QList<QgsPolygon *> &polygons, const QList<QgsFeatureId> &featureIds, const QgsPointXY &origin, float extrusionHeight, const QList<float> &extrusionHeightPerPolygon )
{
  Q_ASSERT( polygons.count() == featureIds.count() );
  mTriangleIndexStartingIndices.reserve( polygons.count() );
  mTriangleIndexFids.reserve( polygons.count() );

  QgsTessellator tessellator( origin.x(), origin.y(), mWithNormals, mInvertNormals, mAddBackFaces );
  for ( int i = 0; i < polygons.count(); ++i )
  {
    Q_ASSERT( tessellator.dataVerticesCount() % 3 == 0 );
    uint startingTriangleIndex = static_cast<uint>( tessellator.dataVerticesCount() / 3 );
    mTriangleIndexStartingIndices.append( startingTriangleIndex );
    mTriangleIndexFids.append( featureIds[i] );

    QgsPolygon *polygon = polygons.at( i );
    float extr = extrusionHeightPerPolygon.isEmpty() ? extrusionHeight : extrusionHeightPerPolygon.at( i );
    tessellator.addPolygon( *polygon, extr );
  }

  qDeleteAll( polygons );

  QByteArray data( ( const char * )tessellator.data().constData(), tessellator.data().count() * sizeof( float ) );
  int nVerts = data.count() / tessellator.stride();

  mVertexBuffer->setData( data );
  mPositionAttribute->setCount( nVerts );
  if ( mNormalAttribute )
    mNormalAttribute->setCount( nVerts );
}
Example #21
0
void QQuickViewTestUtil::QaimModel::insertItems(int index, const QList<QPair<QString, QString> > &items)
{
    emit beginInsertRows(QModelIndex(), index, index+items.count()-1);
    for (int i=0; i<items.count(); i++)
        list.insert(index + i, QPair<QString,QString>(items[i].first, items[i].second));
    emit endInsertRows();
}
Example #22
0
QStringList SessionManagerPrivate::dependenciesOrder() const
{
    QList<QPair<QString, QStringList> > unordered;
    QStringList ordered;

    // copy the map to a temporary list
    foreach (Project *pro, m_projects) {
        const QString &proName = pro->projectFilePath();
        unordered << QPair<QString, QStringList>(proName, m_depMap.value(proName));
    }

    while (!unordered.isEmpty()) {
        for (int i=(unordered.count()-1); i>=0; --i) {
            if (unordered.at(i).second.isEmpty()) {
                ordered << unordered.at(i).first;
                unordered.removeAt(i);
            }
        }

        // remove the handled projects from the dependency lists
        // of the remaining unordered projects
        for (int i = 0; i < unordered.count(); ++i) {
            foreach (const QString &pro, ordered) {
                QStringList depList = unordered.at(i).second;
                depList.removeAll(pro);
                unordered[i].second = depList;
            }
        }
    }
EditBookmarksDialog::EditBookmarksDialog(IBookmarks *ABookmarks, const Jid &AStreamJid, const QList<IBookmark> &AList, QWidget *AParent) : QDialog(AParent)
{
	REPORT_VIEW;
	ui.setupUi(this);
	setAttribute(Qt::WA_DeleteOnClose,true);
	setWindowTitle(tr("Edit bookmarks - %1").arg(AStreamJid.uBare()));
	IconStorage::staticStorage(RSR_STORAGE_MENUICONS)->insertAutoIcon(this,MNI_BOOKMARKS_EDIT,0,0,"windowIcon");

	FBookmarks = ABookmarks;
	FStreamJid = AStreamJid;

	ui.tbwBookmarks->setRowCount(AList.count());
	for (int row=0; row<AList.count(); ++row)
	{
		IBookmark bookmark = AList.at(row);
		setBookmarkToRow(row,bookmark);
	}

	QHeaderView *header = ui.tbwBookmarks->horizontalHeader();
	header->setSectionsClickable(true);
	header->setSectionResizeMode(COL_NAME,QHeaderView::ResizeToContents);
	header->setSectionResizeMode(COL_VALUE,QHeaderView::Stretch);
	header->setSectionResizeMode(COL_NICK,QHeaderView::ResizeToContents);
	header->hideSection(COL_SORT);
	connect(header,SIGNAL(sectionClicked(int)),SLOT(onSortingStateChange(int)));

	connect(ui.pbtAdd,SIGNAL(clicked()),SLOT(onEditButtonClicked()));
	connect(ui.pbtEdit,SIGNAL(clicked()),SLOT(onEditButtonClicked()));
	connect(ui.pbtDelete,SIGNAL(clicked()),SLOT(onEditButtonClicked()));
	connect(ui.pbtMoveUp,SIGNAL(clicked()),SLOT(onEditButtonClicked()));
	connect(ui.pbtMoveDown,SIGNAL(clicked()),SLOT(onEditButtonClicked()));
	connect(ui.bbxButtons,SIGNAL(accepted()),SLOT(onDialogAccepted()));

	connect(ui.tbwBookmarks,SIGNAL(itemDoubleClicked(QTableWidgetItem *)),SLOT(onTableItemDoubleClicked(QTableWidgetItem *)));
}
Example #24
0
void MainWindow::trainingDataChanged()
{
    QList<QImage> maleTrainingImages = ui->lblMaleTraining->getImages();
    QVector<int> maleLabels;
    maleLabels.fill(MALEINDEX,maleTrainingImages.count());

    QList<QImage> femaleTrainingImages = ui->lblFemaleTraining->getImages();
    QVector<int> femaleLabels;
    femaleLabels.fill(FEMALEINDEX,femaleTrainingImages.count());

    if (maleTrainingImages.isEmpty()) {
        ui->listWidget->addItem(QString("%1: %2").arg(QTime::currentTime().toString("hh:mm"), "Need male images..."));
    }
    if (femaleTrainingImages.isEmpty()) {
        ui->listWidget->addItem(QString("%1: %2").arg(QTime::currentTime().toString("hh:mm"), "Need female images..."));
    }
    if (maleTrainingImages.isEmpty()||femaleTrainingImages.isEmpty())
        return;
    //
    QList<QImage> trainingImages;
    QVector<int> labels;
    trainingImages << maleTrainingImages << femaleTrainingImages;
    labels << maleLabels << femaleLabels;
    //
    ui->listWidget->addItem(QString("%1: %2").arg(QTime::currentTime().toString("hh:mm"), "Training..."));
    recognizer->trainFaces(trainingImages, labels);
    ui->listWidget->addItem(QString("%1: %2").arg(QTime::currentTime().toString("hh:mm"), "Training complete."));
    reevaluateMale();
    reevaluateFemale();
}
Example #25
0
//! [11]
void DiagramScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
{
    if (line != 0 && myMode == InsertLine) {
        QList<QGraphicsItem *> startItems = items(line->line().p1());
        if (startItems.count() && startItems.first() == line)
            startItems.removeFirst();
        QList<QGraphicsItem *> endItems = items(line->line().p2());
        if (endItems.count() && endItems.first() == line)
            endItems.removeFirst();

        removeItem(line);
        delete line;
//! [11] //! [12]

        if (startItems.count() > 0 && endItems.count() > 0 &&
            startItems.first()->type() == DiagramItem::Type &&
            endItems.first()->type() == DiagramItem::Type &&
            startItems.first() != endItems.first()) {
            DiagramItem *startItem =
                qgraphicsitem_cast<DiagramItem *>(startItems.first());
            DiagramItem *endItem =
                qgraphicsitem_cast<DiagramItem *>(endItems.first());
            Arrow *arrow = new Arrow(startItem, endItem);
            arrow->setColor(myLineColor);
            startItem->addArrow(arrow);
            endItem->addArrow(arrow);
            arrow->setZValue(-1000.0);
            addItem(arrow);
            arrow->updatePosition();
        }
    }
//! [12] //! [13]
    line = 0;
    QGraphicsScene::mouseReleaseEvent(mouseEvent);
}
Example #26
0
void
LastFmUserSettings::addRecentStation( const Station& station )
{
    MyQSettings s( this );

    QList<Station> stations = recentStations();

    // remove duplicates
    for ( int i = 0; i < stations.count(); ++i )
        if ( stations[i].url() == station.url() )
            stations.removeAt( i-- );

    stations.prepend( station );

    s.remove( "RecentStations" );

    s.beginGroup( "RecentStations" );
    int j = stations.count();
    while (j--)
        s.setValue( QString::number( j ), stations[j].url() );
    s.endGroup();

    s.setValue( "StationNames/" + station.url(), station.name() );
    s.sync();

    emit userChanged( username() );
    emit historyChanged();
}
Example #27
0
static void initWritingSystems(QtFontFamily *family, ATSFontRef atsFont)
{
    ByteCount length = 0;
    if (ATSFontGetTable(atsFont, MAKE_TAG('O', 'S', '/', '2'), 0, 0, 0, &length) != noErr)
        return;
    QVarLengthArray<uchar> os2Table(length);
    if (length < 86
        || ATSFontGetTable(atsFont, MAKE_TAG('O', 'S', '/', '2'), 0, length, os2Table.data(), &length) != noErr)
        return;

    quint32 unicodeRange[4] = {
        qFromBigEndian<quint32>(os2Table.data() + 42),
        qFromBigEndian<quint32>(os2Table.data() + 46),
        qFromBigEndian<quint32>(os2Table.data() + 50),
        qFromBigEndian<quint32>(os2Table.data() + 54)
    };
    quint32 codePageRange[2] = { qFromBigEndian<quint32>(os2Table.data() + 78), qFromBigEndian<quint32>(os2Table.data() + 82) };
    QList<QFontDatabase::WritingSystem> systems = determineWritingSystemsFromTrueTypeBits(unicodeRange, codePageRange);
#if 0
    QCFString name;
    ATSFontGetName(atsFont, kATSOptionFlagsDefault, &name);
    qDebug() << systems.count() << "writing systems for" << QString(name);
qDebug() << "first char" << hex << unicodeRange[0];
    for (int i = 0; i < systems.count(); ++i)
        qDebug() << QFontDatabase::writingSystemName(systems.at(i));
#endif
    for (int i = 0; i < systems.count(); ++i)
        family->writingSystems[systems.at(i)] = QtFontFamily::Supported;
}
Example #28
0
void Datapicker::addNewPoint(const QPointF& pos, AbstractAspect* parentAspect) {
	QList<DatapickerPoint*> childPoints = parentAspect->children<DatapickerPoint>(AbstractAspect::IncludeHidden);
	if (childPoints.isEmpty())
		beginMacro(i18n("%1: add new point", parentAspect->name()));
	else
		beginMacro(i18n("%1: add new point %2", parentAspect->name(), childPoints.count()));

	DatapickerPoint* newPoint = new DatapickerPoint(i18n("%1 Point", parentAspect->name()));
	newPoint->setPosition(pos);
	newPoint->setHidden(true);
	parentAspect->addChild(newPoint);
	newPoint->retransform();

	DatapickerCurve* datapickerCurve = dynamic_cast<DatapickerCurve*>(parentAspect);
	if (m_image == parentAspect) {
		DatapickerImage::ReferencePoints points = m_image->axisPoints();
		points.scenePos[childPoints.count()].setX(pos.x());
		points.scenePos[childPoints.count()].setY(pos.y());
		m_image->setAxisPoints(points);
	} else if (datapickerCurve) {
		newPoint->initErrorBar(datapickerCurve->curveErrorTypes());
		datapickerCurve->updateData(newPoint);
	}

	endMacro();
	emit requestUpdateActions();
}
Example #29
0
void GradientModel::addStop(qreal position, const QColor &color)
{
    if (m_lock)
        return;

    if (!m_itemNode.isValid() || gradientPropertyName().isEmpty())
        return;

    if (m_itemNode.modelNode().hasNodeProperty(gradientPropertyName().toUtf8())) {
        //QmlDesigner::RewriterTransaction transaction = m_itemNode.modelNode().view()->beginRewriterTransaction();
        //### TODO does not work

        QmlDesigner::ModelNode gradientNode =  m_itemNode.modelNode().nodeProperty(gradientPropertyName().toUtf8()).modelNode();

        QmlDesigner::ModelNode gradientStopNode =
                m_itemNode.modelNode().view()->createModelNode("QtQuick.GradientStop",
                                                               m_itemNode.modelNode().view()->majorQtQuickVersion(), 0);
        gradientStopNode.variantProperty("position").setValue(position);
        gradientStopNode.variantProperty("color").setValue(color);
        gradientNode.nodeListProperty("stops").reparentHere(gradientStopNode);

        const QList<QmlDesigner::ModelNode> stopNodes = gradientNode.nodeListProperty("stops").toModelNodeList();

        int properPos = 0;
        for (int i = 0; i < stopNodes.count(); i++) {
            if (QmlDesigner::QmlObjectNode(stopNodes.at(i)).modelValue("position").toReal() < position)
                properPos = i + 1;
        }
        gradientNode.nodeListProperty("stops").slide(stopNodes.count() - 1, properPos);

        setupModel();
    }
}
Example #30
0
void MScenePrivate::onDisplayChangeEvent(MOnDisplayChangeEvent *event)
{
    Q_Q(MScene);

    if (event->state() == MOnDisplayChangeEvent::FullyOnDisplay ||
            event->state() == MOnDisplayChangeEvent::FullyOffDisplay) {
        // Simple cases. Just forward the event as it is.
        sendEventToMWidgets(filterMWidgets(q->items()), event);
        return;
    }

    QList<MWidget *> fullyOnWidgets;
    QList<MWidget *> partiallyOnWidgets;
    QList<MWidget *> fullyOffWidgets;

    QList<MWidget *> intersectingWidgets = filterMWidgets(q->items(event->viewRect(),
            Qt::IntersectsItemBoundingRect));

    QList<MWidget *> allWidgets = filterMWidgets(q->items());

    // Find who is fully on, partially on and fully off

    QSet<MWidget *> fullyOffWidgetsSet = allWidgets.toSet().subtract(intersectingWidgets.toSet());
    fullyOffWidgets = fullyOffWidgetsSet.toList();

    int intersectingWidgetsCount = intersectingWidgets.count();
    MWidget *widget;
    for (int i = 0; i < intersectingWidgetsCount; i++) {
        widget = intersectingWidgets.at(i);
        if (event->viewRect().contains(widget->sceneBoundingRect())) {
            fullyOnWidgets << widget;
        } else {
            partiallyOnWidgets << widget;
        }
    }

    // Send the events to the corresponding MWidgets

    if (fullyOnWidgets.count() > 0) {
        MOnDisplayChangeEvent fullyOnEvent(MOnDisplayChangeEvent::FullyOnDisplay,
                                             event->viewRect());

        sendEventToMWidgets(fullyOnWidgets, &fullyOnEvent);
    }

    if (fullyOffWidgets.count() > 0) {
        MOnDisplayChangeEvent fullyOffEvent(MOnDisplayChangeEvent::FullyOffDisplay,
                                              event->viewRect());

        sendEventToMWidgets(fullyOffWidgets, &fullyOffEvent);
    }

    if (partiallyOnWidgets.count() > 0) {
        MOnDisplayChangeEvent partiallyOnEvent(MOnDisplayChangeEvent::PartiallyOnDisplay,
                event->viewRect());

        sendEventToMWidgets(partiallyOnWidgets, &partiallyOnEvent);
    }

}