Ejemplo n.º 1
0
QSet<RPropertyTypeId> RBlockReferenceEntity::getPropertyTypeIds() const {
    QSet<RPropertyTypeId> ret;

    // TODO: move to RObject?
    // add attribute tag / values as properties of the block reference:
    const RDocument* doc = getDocument();
    if (doc!=NULL) {
        QSet<REntity::Id> childIds = doc->queryChildEntities(getId(), RS::EntityAttribute);
        QSet<REntity::Id>::iterator it;
        for (it=childIds.begin(); it!=childIds.end(); it++) {
            REntity::Id childId = *it;
            QSharedPointer<REntity> child = doc->queryEntityDirect(childId);
            if (child.isNull()) {
                continue;
            }

            QSet<RPropertyTypeId> childProperties = child->getPropertyTypeIds();
            QSet<RPropertyTypeId>::iterator it2;
            for (it2=childProperties.begin(); it2!=childProperties.end(); it2++) {
                RPropertyTypeId pid = *it2;
                QPair<QVariant, RPropertyAttributes> p = child->getProperty(pid);
                if (p.second.isVisibleToParent()) {
                    pid.setId(RPropertyTypeId::INVALID_ID);
                    ret.insert(pid);
                    //qDebug() << pid.getCustomPropertyTitle() << " / " << pid.getCustomPropertyName();
                    //qDebug() << p.first.toString();
                }
            }
        }
    }

    ret.unite(REntity::getPropertyTypeIds());
    return ret;
}
Ejemplo n.º 2
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
QString PMFileGenerator::createReplacementString(FileType type, QSet<QString> names)
{
  QString pluginName = getPluginName();
  QString replaceStr = "";
  if (type == CMAKELISTS)
  {
    // Build up the huge string full of namespaces using names
    QSet<QString>::iterator iter = names.begin();
    while (iter != names.end())
    {
      QString name = *iter;

      if (name == "@PluginName@Filter")
      {
        name.replace("@PluginName@", pluginName);
      }

      replaceStr.append("AddDREAM3DUnitTest(TESTNAME " + name + "Test SOURCES ${${PROJECT_NAME}_SOURCE_DIR}/" + name + "Test.cpp LINK_LIBRARIES ${${PROJECT_NAME}_Link_Libs})");

      if (++iter != names.end())
      {
        replaceStr.append("\n");
      }
    }
  }
  else if (type == TESTFILELOCATIONS)
  {
    // Build up the huge string full of namespaces using names
    QSet<QString>::iterator iter = names.begin();
    while (iter != names.end())
    {
      QString name = *iter;

      if (name == "@PluginName@Filter")
      {
        name.replace("@PluginName@", pluginName);
      }

      replaceStr.append("namespace " + name + "Test\n");
      replaceStr.append("  {\n");
      replaceStr.append("    const QString TestFile1(\"@TEST_TEMP_DIR@/TestFile1.txt\");\n");
      replaceStr.append("    const QString TestFile2(\"@TEST_TEMP_DIR@/TestFile2.txt\");\n");
      replaceStr.append("  }");

      if (++iter != names.end())
      {
        replaceStr.append("\n\n");
      }
    }
  }

  return replaceStr;
}
Ejemplo n.º 3
0
/**
 * Overwrites a potentially existing block with the given block.
 */
bool RTransaction::overwriteBlock(QSharedPointer<RBlock> block) {
    QString blockName = block->getName();
    if (blockName==RBlock::modelSpaceName) {
        //qWarning() << "RTransaction::overwriteBlock: "
        //              "trying to overwrite the model space block";
        return false;
    }

    bool hasBlock = storage->hasBlock(blockName);

    QSet<REntity::Id> refs;

    // block exists and must be overwritten:
    if (hasBlock) {
        // temporarily 'ground' all existing references to the existing block:
        refs = storage->queryBlockReferences(storage->getBlockId(blockName));
        QSet<REntity::Id>::iterator it;
        for (it = refs.begin(); it != refs.end(); ++it) {
            QSharedPointer<RBlockReferenceEntity> e =
                    storage->queryEntity(*it).dynamicCast<RBlockReferenceEntity> ();
            if (!e.isNull() && !e->isUndone()) {
                e->setReferencedBlockId(REntity::INVALID_ID);
                addObject(e, false);
            }
        }

        // delete existing block in dest:
        // block references are not deleted,
        // because they no longer reference this block
        // block contents is deleted
        deleteObject(storage->getBlockId(blockName));
    }

    // add new block to dest or overwrite block:
    addObject(block);

    // block exists and must be overwritten:
    if (hasBlock) {
        // point previously grounded block references to new block:
        QSet<REntity::Id>::iterator it;
        for (it = refs.begin(); it != refs.end(); ++it) {
            QSharedPointer<RBlockReferenceEntity> e =
                    storage->queryEntity(*it).dynamicCast<RBlockReferenceEntity> ();
            if (!e.isNull() && !e->isUndone()) {
                e->setReferencedBlockId(block->getId());
                addObject(e, false);
                affectedBlockReferenceIds.insert(*it);
            }
        }
    }
    return true;
}
Ejemplo n.º 4
0
 bool checkseeniff(QSet const& qs) {
   for (QSet::const_iterator i = qs.begin(), e = qs.end(); i != e; ++i)
     if (test(seenq, *i))
       reset(seenq, *i);
     else {
       for (QSet::const_iterator j = qs.begin(); j != i; ++j)  // undo resets
         setValue(seenq, *j);
       return false;
     }
   bool ret = true;
   if (seenq.count()) ret = false;
   for (QSet::const_iterator i = qs.begin(), e = qs.end(); i != e; ++i)  // undo resets
     setValue(seenq, *i);
   return ret;
 }
Ejemplo n.º 5
0
void MusicScanner::scanFolder(MusicLibraryItemRoot *library, const QString &topLevel, const QString &f,
                              QSet<FileOnlySong> &existing, int level)
{
    if (stopRequested) {
        return;
    }
    if (level<4) {
        QDir d(f);
        QFileInfoList entries=d.entryInfoList(QDir::Files|QDir::NoSymLinks|QDir::Dirs|QDir::NoDotAndDotDot);
        MusicLibraryItemArtist *artistItem = 0;
        MusicLibraryItemAlbum *albumItem = 0;
        foreach (const QFileInfo &info, entries) {
            if (stopRequested) {
                return;
            }
            if (info.isDir()) {
                scanFolder(library, topLevel, info.absoluteFilePath(), existing, level+1);
            } else if(info.isReadable()) {
                Song song;
                QString fname=info.absoluteFilePath().mid(topLevel.length());

                if (fname.endsWith(".jpg", Qt::CaseInsensitive) || fname.endsWith(".png", Qt::CaseInsensitive) ||
                    fname.endsWith(".lyrics", Qt::CaseInsensitive) || fname.endsWith(".pamp", Qt::CaseInsensitive)) {
                    continue;
                }
                song.file=fname;
                QSet<FileOnlySong>::iterator it=existing.find(song);
                if (existing.end()==it) {
                    song=Tags::read(info.absoluteFilePath());
                    song.file=fname;
                } else {
                    song=*it;
                    existing.erase(it);
                }
                if (song.isEmpty()) {
                    continue;
                }
                count++;
                int t=time(NULL);
                if ((t-lastUpdate)>=2 || 0==(count%5)) {
                    lastUpdate=t;
                    emit songCount(count);
                }

                song.fillEmptyFields();
                song.size=info.size();
                if (!artistItem || song.artistOrComposer()!=artistItem->data()) {
                    artistItem = library->artist(song);
                }
                if (!albumItem || albumItem->parentItem()!=artistItem || song.albumName()!=albumItem->data()) {
                    albumItem = artistItem->album(song);
                }
                MusicLibraryItemSong *songItem = new MusicLibraryItemSong(song, albumItem);
                albumItem->append(songItem);
                albumItem->addGenre(song.genre);
                artistItem->addGenre(song.genre);
                library->addGenre(song.genre);
            }
        }
    }
Ejemplo n.º 6
0
void CFontFileListView::openViewer()
{
    // Number of fonts user has selected, before we ask if they really want to view them all...
    static const int constMaxBeforePrompt=10;

    QList<QTreeWidgetItem *> items(selectedItems());
    QTreeWidgetItem          *item;
    QSet<QString>            files;

    foreach(item, items)
        if(item->parent()) // Then it is a file, not font name :-)
            files.insert(item->text(0));

    if(files.count() &&
       (files.count()<constMaxBeforePrompt ||
        KMessageBox::Yes==KMessageBox::questionYesNo(this, i18np("Open font in font viewer?",
                                                                 "Open all %1 fonts in font viewer?",
                                                                 files.count()))))
    {
         QSet<QString>::ConstIterator it(files.begin()),
                                      end(files.end());

        for(; it!=end; ++it)
        {
            QStringList args;

            args << (*it);

            QProcess::startDetached(Misc::app(KFI_VIEWER), args);
        }
    }
}
Ejemplo n.º 7
0
/**
 * Checks recursively, if the given block is allowed to contain
 * references to the potential child block.
 *
 * \return true if a recusrion has been found.
 */
bool RMemoryStorage::checkRecursion(
    RBlock::Id blockId, RBlock::Id potentialChildBlockId) {

    if (blockId==potentialChildBlockId) {
        return true;
    }

    // iterate through all entities inside potential child block and check
    // if anything refers back to the given block:
    QSet<REntity::Id> ids = queryBlockEntities(potentialChildBlockId);
    QSet<REntity::Id>::iterator it;
    for (it = ids.begin(); it != ids.end(); ++it) {
        QSharedPointer<REntity> e = queryEntityDirect(*it);
        QSharedPointer<RBlockReferenceEntity> blockRef = e.dynamicCast<
                RBlockReferenceEntity> ();
        if (blockRef.isNull()) {
            continue;
        }

        if (blockRef->getReferencedBlockId() == blockId) {
            return true;
        }
        if (checkRecursion(blockId, blockRef->getReferencedBlockId())) {
            return true;
        }
    }
    return false;
}
Ejemplo n.º 8
0
    bool mergeArraysOfStrings(const QJsonArray &arrayFrom, QJsonArray &arrayTo) {
        QJsonArray arrayMerged;

        QSet<QString> commonValues;
        commonValues.reserve(arrayTo.size() + arrayFrom.size());

        int i = 0;
        int sizeTo = arrayTo.size();
        for (i = 0; i < sizeTo; ++i) {
            Q_ASSERT(arrayTo[i].type() == QJsonValue::String);
            commonValues.insert(arrayTo[i].toString());
        }

        int sizeFrom = arrayFrom.size();
        for (i = 0; i < sizeFrom; ++i) {
            Q_ASSERT(arrayFrom[i].type() == QJsonValue::String);
            commonValues.insert(arrayFrom[i].toString());
        }

        QSet<QString>::iterator begin = commonValues.begin();
        QSet<QString>::iterator end = commonValues.end();

        for (QSet<QString>::iterator it = begin; it != end; ++it) {
            arrayMerged.append(*it);
        }

        arrayTo = arrayMerged;
        return true;
    }
Ejemplo n.º 9
0
QString nearestName( const QString& actual, const QSet<QString>& candidates )
{
    int deltaBest = 10000;
    int numBest = 0;
    QString best;

    QSet<QString>::ConstIterator c = candidates.begin();
    while ( c != candidates.end() ) {
	if ( (*c)[0] == actual[0] ) {
	    int delta = editDistance( actual, *c );
	    if ( delta < deltaBest ) {
		deltaBest = delta;
		numBest = 1;
		best = *c;
	    } else if ( delta == deltaBest ) {
		numBest++;
	    }
	}
	++c;
    }

    if ( numBest == 1 && deltaBest <= 2 &&
	 actual.length() + best.length() >= 5 ) {
	return best;
    } else {
	return "";
    }
}
Ejemplo n.º 10
0
void RMemoryStorage::deleteTransactionsFrom(int transactionId) {
    QSet<int> keysToRemove;

    {
        QHash<int, RTransaction>::iterator it;
        for (it = transactionMap.begin(); it!=transactionMap.end(); ++it) {
            if (it.key()>=transactionId) {
                // delete orphaned objects:
                QList<RObject::Id> affectedObjects =
                    it.value().getAffectedObjects();

                QList<RObject::Id>::iterator it2;
                for (it2=affectedObjects.begin(); it2!=affectedObjects.end(); ++it2) {
                    QSharedPointer<RObject> obj = queryObjectDirect(*it2);
                    if (!obj.isNull() && obj->isUndone()) {
                        deleteObject(*it2);
                    }
                }

                // delete transaction:
                keysToRemove.insert(it.key());
            }
        }
    }

    {
        QSet<int>::iterator it;
        for (it=keysToRemove.begin(); it!=keysToRemove.end(); ++it) {
            transactionMap.remove(*it);
        }
    }
}
Ejemplo n.º 11
0
/**
 * Selects first the top most parent in the entity hierarchy and then
 * all children of it. This is necessary for attributes which are
 * children of block references.
 */
void RMemoryStorage::setEntitySelected(QSharedPointer<REntity> entity, bool on,
    QSet<REntity::Id>* affectedEntities, bool onlyDescend) {

//    disabled:
//    attributes can be selected individually to edit their attributes
//    if (!onlyDescend) {
//        // entity has a parent: select parent instead
//        // (select block ref for attribute):
//        REntity::Id parentId = entity->getParentId();
//        QSharedPointer<REntity> parent = queryEntityDirect(parentId);
//        if (!parent.isNull()) {
//            setEntitySelected(parent, on, affectedEntities);
//            return;
//        }
//    }

    entity->setSelected(on);
    if (affectedEntities!=NULL) {
        affectedEntities->insert(entity->getId());
    }

    // if this is a parent, select all child entities (attributes for block ref):
    if (hasChildEntities(entity->getId())) {
        QSet<REntity::Id> childIds = queryChildEntities(entity->getId());
        QSet<REntity::Id>::iterator it;
        for (it=childIds.begin(); it!=childIds.end(); it++) {
            REntity::Id childId = *it;
            QSharedPointer<REntity> child = queryEntityDirect(childId);
            if (child.isNull()) {
                continue;
            }
            setEntitySelected(child, on, affectedEntities, true);
        }
    }
}
Ejemplo n.º 12
0
void PointSetAnnotationTool::mouseMoveEvent(QMouseEvent *event) {
  if (_viewer) {
    if (_generating) {
      QPointF scenePos = _viewer->mapToScene(event->pos());
      if (event->buttons() == Qt::LeftButton) {
        if (QLineF(_viewer->mapFromScene(scenePos), _viewer->mapFromScene(QPointF(_last.getX(), _last.getY()))).length() > 40) {
          addCoordinate(scenePos);
        }
      }
    }
    else if (_startSelectionMove && event->modifiers() == Qt::AltModifier) {
      QPointF scenePos = _viewer->mapToScene(event->pos());
      QSet<QtAnnotation*> selected = _annotationPlugin->getSelectedAnnotations();
      for (QSet<QtAnnotation*>::iterator it = selected.begin(); it != selected.end(); ++it) {
        QPointF delta = (scenePos - _moveStart);
        (*it)->moveCoordinatesBy(Point(delta.x(), delta.y()));
      }
      _moveStart = scenePos;
    }
    else if (_startSelectionMove) {
      QPointF scenePos = _viewer->mapToScene(event->pos());
      PointSetQtAnnotation* active = dynamic_cast<PointSetQtAnnotation*>(_annotationPlugin->getActiveAnnotation());
      if (active && active->getEditable()) {
        int activeSeedPoint = active->getActiveSeedPoint();
        if (activeSeedPoint >= 0) {
          QPointF delta = (scenePos - _moveStart);
          active->moveCoordinateBy(activeSeedPoint, Point(delta.x(), delta.y()));
          _moveStart = scenePos;
        }
      }
    }
    event->accept();
  }
}
Ejemplo n.º 13
0
int CFrmUserList::UpdateGroup(CRoster* pRoster, QSet<QString> groups)
{
    if(groups.isEmpty())
    {
        QString szDefaulGroup(tr("My friends"));
        groups.insert(szDefaulGroup);
    }

    for(QSet<QString>::iterator itGroup = groups.begin(); itGroup != groups.end(); itGroup++)
    {
        QString szGroup = *itGroup;
        QStandardItem* lstGroup = NULL;
        QMap<QString, QStandardItem*>::iterator it;
        it = m_Groups.find(szGroup);
        if(m_Groups.end() == it)
        {
            //新建立组条目 
            /*lstGroup = new QStandardItem(szGroup);
            lstGroup->setEditable(false);  //禁止双击编辑 
            m_pModel->appendRow(lstGroup);
            m_Groups.insert(szGroup, lstGroup);//*/
            lstGroup = InsertGroup(szGroup);
        }
        else
            lstGroup = it.value();

        lstGroup->appendRow(pRoster->GetItem());
        LOG_MODEL_DEBUG("Roster", "CFrmUserList::UpdateGroup:%s,(%s)",
                qPrintable(pRoster->BareJid()),
                qPrintable(szGroup));
    }

    return 0;
}
Ejemplo n.º 14
0
void MThread::GetAllThreadNames(QStringList &list)
{
    QMutexLocker locker(&s_all_threads_lock);
    QSet<MThread*>::const_iterator it;
    for (it = s_all_threads.begin(); it != s_all_threads.end(); ++it)
        list.push_back((*it)->objectName());
}
Ejemplo n.º 15
0
//FIXME: Commas in names
bool Bookmarks::save()
{
    QFile file(m_bookmarksFile);
    if(file.open(QFile::WriteOnly | QFile::Truncate | QIODevice::Text))
    {
        QTextStream stream(&file);

        stream << QString("# Tag name").leftJustified(20) + "; " +
                  QString(" color") << endl;

        QSet<TagInfo*> usedTags;
        for (int iBookmark = 0; iBookmark < m_BookmarkList.size(); iBookmark++)
        {
            BookmarkInfo& info = m_BookmarkList[iBookmark];
            for(int iTag = 0; iTag < info.tags.size(); ++iTag)
            {
              TagInfo& tag = *info.tags[iTag];
              usedTags.insert(&tag);
            }
        }

        for (QSet<TagInfo*>::iterator i = usedTags.begin(); i != usedTags.end(); i++)
        {
            TagInfo& info = **i;
            stream << info.name.leftJustified(20) + "; " + info.color.name() << endl;
        }

        stream << endl;

        stream << QString("# Frequency").leftJustified(12) + "; " +
                  QString("Name").leftJustified(25)+ "; " +
                  QString("Modulation").leftJustified(20) + "; " +
                  QString("Bandwidth").rightJustified(10) + "; " +
                  QString("Tags") << endl;

        for (int i = 0; i < m_BookmarkList.size(); i++)
        {
            BookmarkInfo& info = m_BookmarkList[i];
            QString line = QString::number(info.frequency).rightJustified(12) +
                    "; " + info.name.leftJustified(25) + "; " +
                    info.modulation.leftJustified(20)+ "; " +
                    QString::number(info.bandwidth).rightJustified(10) + "; ";
            for(int iTag = 0; iTag<info.tags.size(); ++iTag)
            {
                TagInfo& tag = *info.tags[iTag];
                if(iTag!=0)
                {
                    line.append(",");
                }
                line.append(tag.name);
            }

            stream << line << endl;
        }

        file.close();
        return true;
    }
    return false;
}
Ejemplo n.º 16
0
/**
 * Exports the visual representation of all entities that are completely
 * or partly inside the given area.
 */
void RExporter::exportEntities(const RBox& box) {
    QSet<REntity::Id> ids = document->queryIntersectedEntitiesXY(box);
    QSet<REntity::Id>::iterator it;
    for (it = ids.begin(); it != ids.end(); it++) {
        exportEntity(*it);
    }
}
Ejemplo n.º 17
0
RTransaction RMoveReferencePointOperation::apply(RDocument& document, bool preview) const {
    Q_UNUSED(preview)

    RTransaction transaction(document.getStorage(), text);
    transaction.setGroup(transactionGroup);

    QSet<REntity::Id> selectedEntities = document.querySelectedEntities();
    QSet<REntity::Id>::iterator it;
    for (it=selectedEntities.begin(); it!=selectedEntities.end(); it++) {
        QSharedPointer<REntity> entity = document.queryEntity(*it);
        if (entity.isNull()) {
            continue;
        }
        
        // apply operation to cloned entity:
        bool modified = entity->moveReferencePoint(referencePoint, targetPoint);
        
        if (modified) {
            transaction.addObject(entity, false);
        }
    }
        
    transaction.end();

    return transaction;
}
Ejemplo n.º 18
0
int CFrmUserList::ItemUpdateGroup(QSharedPointer<CUserInfo> info)
{
    QSet<QString> groups = info->GetGroups();
    if(groups.isEmpty())
    {
        QString szDefaulGroup(tr("My friends"));
        groups.insert(szDefaulGroup);
    }

    for(QSet<QString>::iterator itGroup = groups.begin(); itGroup != groups.end(); itGroup++)
    {
        QString szGroup = *itGroup;
        QStandardItem* lstGroup = NULL;
        QMap<QString, QStandardItem*>::iterator it;
        it = m_Groups.find(szGroup);
        if(m_Groups.end() == it)
        {
            //新建立组条目 
            lstGroup = ItemInsertGroup(szGroup);
        }
        else
            lstGroup = it.value();

        QList<QStandardItem *> lstItems = NewItemRoster(info);
        if(lstItems.isEmpty())
            continue;
        lstGroup->appendRow(lstItems);
    }

    return 0;
}
Ejemplo n.º 19
0
void CGroupList::addToGroup(const QModelIndex &group, const QSet<QString> &families)
{
    if(group.isValid())
    {
        CGroupListItem *grp=static_cast<CGroupListItem *>(group.internalPointer());

        if(grp && grp->isCustom())
        {
            QSet<QString>::ConstIterator it(families.begin()),
                                         end(families.end());
            bool                         update(false);

            for(; it!=end; ++it)
                if(!grp->hasFamily(*it))
                {
                    grp->addFamily(*it);
                    update=true;
                    itsModified=true;
                }

            if(update)
                emit refresh();
        }
    }
}
Ejemplo n.º 20
0
        bool Backend::endConnectionChange(QSet<QObject *> objects)
        {
            //end of a transaction
            for(QSet<QObject *>::const_iterator it = objects.begin(); it != objects.end(); ++it) {
                if (BackendNode *node = qobject_cast<BackendNode*>(*it)) {
                    MediaObject *mo = node->mediaObject();
                    if (mo) {
                        switch(mo->transactionState)
                        {
                        case Phonon::ErrorState:
                        case Phonon::StoppedState:
                        case Phonon::LoadingState:
                            //nothing to do
                            break;
                        case Phonon::PausedState:
                            mo->transactionState = Phonon::StoppedState;
                            mo->pause();
                            break;
                        default:
                            mo->transactionState = Phonon::StoppedState;
                            mo->play();
                            break;
                        }

                        if (mo->state() == Phonon::ErrorState)
                            return false;
                    }
                }
            }

            return true;
        }
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
int H5FilterParametersWriter::writeArraySelections(const QString name, QSet<QString> v)
{
  size_t size = v.size();
  herr_t err = 0;
  if (size > 0)
  {
    QString setStr = "";
    QSet<QString>::iterator iter = v.begin();
    for (; iter != v.end(); iter++)
    {
      setStr.append(*iter).append("\n");
    }

    err = QH5Lite::writeStringDataset(m_CurrentGroupId, name, setStr);
    if (err < 0)
    {
      return err;
    }
  }
  if(size > 0)
  {
    err = QH5Lite::writeScalarAttribute(m_CurrentGroupId, name, "NumArrays", size);
    if (err < 0)
    {
      return err;
    }
  }
  return err;
}
Ejemplo n.º 22
0
void ProcessMonitor::reconnectServers()
{
   ProcessList list(s_processMap.keys());
   QSet<Server*> servers;

   ProcessList::iterator iter;
   for (iter = list.begin(); iter != list.end(); ++iter) {
	   // We set the status to Unknown when we load the proceses from file if
	   // the process hasn't finished.
       if ((*iter)->status() == Process::Unknown ||
           (*iter)->status() == Process::Queued) {

          Server* server = ServerRegistry::instance().get((*iter)->serverName());
          if (server) servers.insert(server);
       }
   }

   QSet<Server*>::iterator server;   
   for (server = servers.begin(); server != servers.end(); ++server) {
       try {
          QLOG_INFO() << "Reconnecting to server" << (*server)->name();
          if (!(*server)->connectServer()) throw Server::Exception("Connection failed");
          QLOG_INFO() << "Updating Processes on server" << (*server)->name();
          (*server)->updateProcesses();
       } catch (std::exception& err) {
          QString msg("Failed to reconnect to server: ");
          msg += (*server)->name() +":\n";
          QLOG_WARN() << msg;
          QMsgBox::warning(this, "IQmol", msg);
       }
   }
}
Ejemplo n.º 23
0
toConnectionSub *toQPSqlConnectionImpl::createConnection(void)
{
    // TODO shouldn't be this method reenteant?
    static QAtomicInt ID_COUNTER(0);
    int ID = ID_COUNTER.fetchAndAddAcquire(1);

    QString dbName = QString::number(ID);
    QSqlDatabase db = QSqlDatabase::addDatabase(parentConnection().provider(), dbName);
    db.setDatabaseName(parentConnection().database());
    QString host = parentConnection().host();
    int pos = host.indexOf(QString(":"));
    if (pos < 0)
        db.setHostName(host);
    else
    {
        db.setHostName(host.mid(0, pos));
        db.setPort(host.mid(pos + 1).toInt());
    }

    QString opt;

    QSet<QString> options = parentConnection().options();
    if (options.find("Compress") != options.end())
        opt += ";CLIENT_COMPRESS";
    if (options.find("Ignore Space") != options.end())
        opt += ";CLIENT_IGNORE_SPACE";
    if (options.find("No Schema") != options.end())
        opt += ";CLIENT_NO_SCHEMA";
    if (options.find("SSL") != options.end())
        opt += ";CLIENT_SSL";

    if (!opt.isEmpty())
        db.setConnectOptions(opt.mid(1)); // Strip first ; character

    db.open(parentConnection().user(), parentConnection().password());
    if (!db.isOpen())
    {
        QString t = toQPSqlConnectionSub::ErrorString(db.lastError());
        QSqlDatabase::removeDatabase(dbName);
        throw t;
    }

    toQPSqlConnectionSub *ret = new toQPSqlConnectionSub(parentConnection(), db, dbName);
    return ret;
}
Ejemplo n.º 24
0
RTransaction RChangePropertyOperation::apply(RDocument& document, bool preview) const {
    Q_UNUSED(preview)
    RTransaction transaction(document.getStorage(), text);

    // always allow property changes (e.g. move entity to hidden layer)
    transaction.setAllowInvisible(true);
    transaction.setGroup(transactionGroup);

    QVariant val = value;

    // optimization: change layer ID instead of changing layer name:
    if (propertyTypeId==REntity::PropertyLayer && value.type() == QVariant::String) {
        val = QVariant(document.getLayerId(value.toString()));
    }

    //RDebug::startTimer();

    //qDebug() << "filter: " << entityTypeFilter;

    QSet<RObject::Id> selectedObjects = document.queryPropertyEditorObjects();
    QSet<RObject::Id>::iterator it;
    for (it = selectedObjects.begin(); it != selectedObjects.end(); it++) {

        QSharedPointer<RObject> obj = document.queryObject(*it);
        if (obj.isNull()) {
            continue;
        }
        if (entityTypeFilter!=RS::EntityAll) {
            // special filter for block references and attributes:
            if (entityTypeFilter==RS::EntityBlockRefAttr) {
                if (obj->getType()!=RS::EntityBlockRef &&
                    obj->getType()!=RS::EntityAttribute) {
                    continue;
                }
            }
            else {
                if (entityTypeFilter!=obj->getType()) {
                    continue;
                }
            }
        }

        // apply operation to object:
        bool modified = obj->setProperty(propertyTypeId, val, &transaction);

        if (modified) {
            transaction.addObject(obj, false, false,
                QSet<RPropertyTypeId>() << propertyTypeId);
        }
    }

    transaction.end();

    //RDebug::stopTimer("RChangePropertyOperation::apply");

    return transaction;
}
Ejemplo n.º 25
0
static QSet<QByteArray> activeConditions()
{
    QSet<QByteArray> result = keywords();

    QByteArray distributionName = QSysInfo::productType().toLower().toUtf8();
    QByteArray distributionRelease = QSysInfo::productVersion().toLower().toUtf8();
    if (!distributionName.isEmpty()) {
        if (result.find(distributionName) == result.end())
            result.insert(distributionName);
        if (!distributionRelease.isEmpty()) {
            QByteArray versioned = distributionName + "-" + distributionRelease;
            if (result.find(versioned) == result.end())
                result.insert(versioned);
        }
    }

    return result;
}
void ClassSpaceChecker::onPackageReportItemSelectionChanged()
{
	QList<QTableWidgetItem *> items = ui.tableWidgetPackageReport->selectedItems();
	if(items.size() <= 0)
	{
		ui.lineEdit_Result->setText(prevTotalResultStr_);
		return;
	}

	QSet<int> set;
	int classCount = 0;
	int uniqueClassCount = 0;
	int diffClassCount = 0;
	int totalSize = 0;
	for(int i = 0; i < items.size(); i++) 
	{
		QTableWidgetItem *item = items.at(i);
		int row = item->row();
		if(set.find(row) != set.end())
			continue;

		QTableWidgetItem *itemClassCount = ui.tableWidgetPackageReport->item(item->row(), 1);
		if(itemClassCount == NULL)
			continue;
		classCount += itemClassCount->data(Qt::DisplayRole).toInt();

		QTableWidgetItem *itemUniqueClassCount = ui.tableWidgetPackageReport->item(item->row(), 2);
		if(itemUniqueClassCount == NULL)
			continue;
		uniqueClassCount += itemUniqueClassCount->data(Qt::DisplayRole).toInt();

		QTableWidgetItem *itemDiffClassCount = ui.tableWidgetPackageReport->item(item->row(), 3);
		if(itemDiffClassCount == NULL)
			continue;
		diffClassCount += itemDiffClassCount->data(Qt::DisplayRole).toInt();

		QTableWidgetItem *itemFileSize = ui.tableWidgetPackageReport->item(item->row(), 5);
		if(itemFileSize == NULL)
			continue;
		totalSize += itemFileSize->data(Qt::DisplayRole).toInt();
		set.insert(row);
	}


	QString resultStr;
	resultStr += "All Class Count : ";
	resultStr += QString::number(classCount);
	resultStr += ", Unique Class Count : ";
	resultStr += QString::number(uniqueClassCount);
	resultStr += ", Diff Class Count : ";
	resultStr += QString::number(diffClassCount);
	resultStr += ", File Size : ";
	resultStr += numberDot(QString::number(totalSize));
	resultStr += " bytes";

	ui.lineEdit_Result->setText(resultStr);
}
Ejemplo n.º 27
0
void RExporter::exportLinetypes() {
    QSet<RLinetype::Id> ids = document->queryAllLinetypes();
    QSet<RLinetype::Id>::iterator it;
    for (it = ids.begin(); it != ids.end(); it++) {
        QSharedPointer<RLinetype> e = document->queryLinetype(*it);
        if (!e.isNull()) {
            exportLinetype(*e);
        }
    }
}
Ejemplo n.º 28
0
void RExporter::exportViews() {
    QSet<RView::Id> ids = document->queryAllViews();
    QSet<RView::Id>::iterator it;
    for (it = ids.begin(); it != ids.end(); it++) {
        QSharedPointer<RView> e = document->queryView(*it);
        if (!e.isNull()) {
            exportView(*e);
        }
    }
}
Ejemplo n.º 29
0
void RExporter::exportBlocks() {
    QSet<RBlock::Id> ids = document->queryAllBlocks();
    QSet<RBlock::Id>::iterator it;
    for (it = ids.begin(); it != ids.end(); it++) {
        QSharedPointer<RBlock> e = document->queryBlock(*it);
        if (!e.isNull()) {
            exportBlock(*e);
        }
    }
}
Ejemplo n.º 30
0
/**
 * Adds the given objects to the list of objects that are
 * affected by this transaction.
 */
void RTransaction::addAffectedObjects(const QSet<RObject::Id>& objectIds) {
    if (storage == NULL) {
        return;
    }

    QSet<RObject::Id>::const_iterator it;
    for (it=objectIds.begin(); it!=objectIds.end(); it++) {
        addAffectedObject(*it);
    }
}