bool Scene::load(const QString& fn) {
    QFile file(fn);
     if (!file.open(QIODevice::ReadOnly)) {
         return false;
     }

     QByteArray data = file.readAll();
     QDomDocument doc;
     if (!doc.setContent(data)) {
         return false;
     }

     clearSelection();
     beginResetModel();
     m_history->clear();
     if (m_static_body)
         delete m_static_body;
     m_static_body = 0;
     foreach( Body* b, m_bodys ) {
         delete b;
     }
     m_bodys.clear();

    QDomElement root = doc.documentElement();
    m_worldSize.setWidth(root.attribute("width").toInt());
    m_worldSize.setHeight(root.attribute("height").toInt());
    QDomElement node = root.firstChildElement("body");
    while (node.isElement()) {
        QString type = node.attribute("type");
        Body* b = 0;
        if (type=="StaticBody") {
            b = new StaticBody(this,"body",this);
            ReadAttributes(b,node);
            if (!m_static_body)
                m_static_body = b;
            else {
                m_bodys.push_back( b );
            }
        } else if (type=="DynamicBody") {
            b = new DynamicBody(this,"body",this);
            ReadAttributes(b,node);
            m_bodys.push_back( b );
        }
        if (b) {
            QDomElement primNode = node.firstChildElement("primitive");
            while (primNode.isElement()) {
                Primitive* p = 0;
                QString type = primNode.attribute("type");
                p = Primitive::create(type,b,this);
                if (p) {
                    ReadAttributes(p,primNode);
                    b->addPrimitive(p);
                }
                primNode = primNode.nextSiblingElement("primitive");
            }
            connect( b,SIGNAL(changed()),this,SLOT(bodyChanged()));
        }
        node = node.nextSiblingElement("body");
    }
    endResetModel();
    m_filename = fn;
    emit changed();
    return true;
}
void DatasetItemModel::loadDatasets(const QList<Dataset> &datasetList)
{
    beginResetModel();
    m_datasets_reference = datasetList;
    endResetModel();
}
/* Brief: Force the model to update
 */
void CDailyWeatherModel::update()
{
    beginResetModel();
    endResetModel();
}
Exemple #4
0
void TablePrintModel::callReset()
{
	beginResetModel();
	endResetModel();
}
void HistoryQueryResultsModel::setResults(const QVector<HistoryQueryResult> &results)
{
	beginResetModel();
	Results = results;
	endResetModel();
}
Exemple #6
0
    void ScreenModel::initScreens(bool first) {
        // Clear
        beginResetModel();
        d->geometry = QRect();
        d->primary = 0;
        d->screens.clear();

#ifndef USE_QT5
        // set role names
        QHash<int, QByteArray> roleNames;
        roleNames[NameRole] = "name";
        roleNames[GeometryRole] = "geometry";
        // set role names
        setRoleNames(roleNames);
#endif

#if 0
        // fake model for testing
        d->geometry = QRect(0, 0, 1920, 1080);
        d->primary = 1;
        d->screens << ScreenPtr { new Screen { "First", QRect(0, 0, 300, 300) } }
                   << ScreenPtr { new Screen { "Second", QRect(300, 0, 1320, 742) } }
                   << ScreenPtr { new Screen { "Third", QRect(1620, 0, 300, 300) } };
        return;
#endif

#ifdef USE_QT5
        QList<QScreen *> screens = QGuiApplication::screens();
        for (int i = 0; i < screens.size(); ++i) {
            QScreen *screen = screens.at(i);
            // add to the screens list
            d->screens << ScreenPtr { new Screen { QString("Screen %1").arg(i + 1), screen->geometry() } };
            // extend available geometry
            d->geometry = d->geometry.united(screen->geometry());
            // check if primary
            if (screen == QGuiApplication::primaryScreen())
                d->primary = i;

            if (first) {
                // Recive screen updates
                connect(screen, SIGNAL(geometryChanged(const QRect &)), this, SLOT(onScreenChanged()));
            }
        }
#else
        // set primary screen
        d->primary = QApplication::desktop()->primaryScreen();
        // get screen count
        int screenCount = QApplication::desktop()->screenCount();

        for (int i = 0; i < screenCount; ++i) {
            QRect geometry = QApplication::desktop()->screenGeometry(i);
            // add to the screens list
            d->screens << ScreenPtr { new Screen { QString("Screen %1").arg(i + 1), geometry } };
            // extend available geometry
            d->geometry = d->geometry.united(geometry);
        }
#endif
        endResetModel();

        emit primaryChanged();
    }
void TaskModelAdapter::resetTasks()
{
    beginResetModel();
    endResetModel();
}
int AbstractListModel::setItems(const QVector<Item>& items)
{
  emit beginResetModel();
  this->Items = items;
  emit endResetModel();
}
void ItemLibrarySectionModel::resetModel()
{
    beginResetModel();
    endResetModel();
}
void RouteModel::refresh()
{
  beginResetModel();
  endResetModel();
}
void QgsAttributeTableFilterModel::setAttributeTableConfig( const QgsAttributeTableConfig& config )
{
  mConfig = config;
  mConfig.update( layer()->fields() );

  QVector<int> newColumnMapping;

  Q_FOREACH ( const QgsAttributeTableConfig::ColumnConfig& columnConfig, mConfig.columns() )
  {
    // Hidden? Forget about this column
    if ( columnConfig.hidden )
      continue;

    // The new value for the mapping (field index or -1 for action column)
    int newValue = ( columnConfig.type == QgsAttributeTableConfig::Action ) ? -1 : layer()->fields().lookupField( columnConfig.name );
    newColumnMapping << newValue;
  }

  if ( newColumnMapping != mColumnMapping )
  {
    bool requiresReset = false;
    int firstRemovedColumn = -1;
    int removedColumnCount = 0;

    // Check if there have a contiguous set of columns have been removed or if we require a full reset
    for ( int i = 0; i < qMin( newColumnMapping.size(), mColumnMapping.size() - removedColumnCount ); ++i )
    {
      if ( newColumnMapping.at( i ) == mColumnMapping.at( i + removedColumnCount ) )
        continue;

      if ( firstRemovedColumn == -1 )
      {
        firstRemovedColumn = i;

        while ( i < mColumnMapping.size() - removedColumnCount && mColumnMapping.at( i + removedColumnCount ) != newColumnMapping.at( i ) )
        {
          ++removedColumnCount;
        }
      }
      else
      {
        requiresReset = true;
        break;
      }
    }

    // No difference found so far
    if ( firstRemovedColumn == -1 )
    {
      if ( newColumnMapping.size() > mColumnMapping.size() )
      {
        // More columns: appended to the end
        beginInsertColumns( QModelIndex(), mColumnMapping.size(), newColumnMapping.size() - 1 );
        mColumnMapping = newColumnMapping;
        endInsertColumns();
      }
      else
      {
        // Less columns: removed from the end
        beginRemoveColumns( QModelIndex(), newColumnMapping.size(), mColumnMapping.size() - 1 );
        mColumnMapping = newColumnMapping;
        endRemoveColumns();
      }
    }
    else
    {
      if ( newColumnMapping.size() == mColumnMapping.size() - removedColumnCount )
      {
        beginRemoveColumns( QModelIndex(), firstRemovedColumn, firstRemovedColumn );
        mColumnMapping = newColumnMapping;
        endRemoveColumns();
      }
      else
      {
        requiresReset = true;
      }
    }

    if ( requiresReset )
    {
      beginResetModel();
      mColumnMapping = newColumnMapping;
      endResetModel();
    }
  }

  sort( config.sortExpression(), config.sortOrder() );
}
//------------------------------------------------------------------------------
// Name: update
// Desc:
//------------------------------------------------------------------------------
void ResultViewModel::update() {
	if(updates_enabled_) {
		beginResetModel();
		endResetModel();
	}
}
void QgsWelcomePageItemsModel::setRecentProjects( const QList<RecentProjectData>& recentProjects )
{
  beginResetModel();
  mRecentProjects = recentProjects;
  endResetModel();
}
Exemple #14
0
void View::Management::CategoryModel::setCategories(QList<Model::Domain::Category *> *categories)
{
    beginResetModel();
    _categories = categories;
    endResetModel();
}
 void setColorSchemes(const QList<ColorSchemeEntry> &colorSchemes)
 {
     beginResetModel();
     m_colorSchemes = colorSchemes;
     endResetModel();
 }
void ItemLibrarySectionModel::clearItems()
{
    beginResetModel();
    endResetModel();
}
/*!
    \reimp
 */
void QIdentityProxyModel::setSourceModel(QAbstractItemModel* newSourceModel)
{
    beginResetModel();

    if (sourceModel()) {
        disconnect(sourceModel(), SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)),
                   this, SLOT(_q_sourceRowsAboutToBeInserted(QModelIndex,int,int)));
        disconnect(sourceModel(), SIGNAL(rowsInserted(QModelIndex,int,int)),
                   this, SLOT(_q_sourceRowsInserted(QModelIndex,int,int)));
        disconnect(sourceModel(), SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
                   this, SLOT(_q_sourceRowsAboutToBeRemoved(QModelIndex,int,int)));
        disconnect(sourceModel(), SIGNAL(rowsRemoved(QModelIndex,int,int)),
                   this, SLOT(_q_sourceRowsRemoved(QModelIndex,int,int)));
        disconnect(sourceModel(), SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)),
                   this, SLOT(_q_sourceRowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)));
        disconnect(sourceModel(), SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
                   this, SLOT(_q_sourceRowsMoved(QModelIndex,int,int,QModelIndex,int)));
        disconnect(sourceModel(), SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)),
                   this, SLOT(_q_sourceColumnsAboutToBeInserted(QModelIndex,int,int)));
        disconnect(sourceModel(), SIGNAL(columnsInserted(QModelIndex,int,int)),
                   this, SLOT(_q_sourceColumnsInserted(QModelIndex,int,int)));
        disconnect(sourceModel(), SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)),
                   this, SLOT(_q_sourceColumnsAboutToBeRemoved(QModelIndex,int,int)));
        disconnect(sourceModel(), SIGNAL(columnsRemoved(QModelIndex,int,int)),
                   this, SLOT(_q_sourceColumnsRemoved(QModelIndex,int,int)));
        disconnect(sourceModel(), SIGNAL(columnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)),
                   this, SLOT(_q_sourceColumnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)));
        disconnect(sourceModel(), SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
                   this, SLOT(_q_sourceColumnsMoved(QModelIndex,int,int,QModelIndex,int)));
        disconnect(sourceModel(), SIGNAL(modelAboutToBeReset()),
                   this, SLOT(_q_sourceModelAboutToBeReset()));
        disconnect(sourceModel(), SIGNAL(modelReset()),
                   this, SLOT(_q_sourceModelReset()));
        disconnect(sourceModel(), SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
                   this, SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex,QVector<int>)));
        disconnect(sourceModel(), SIGNAL(headerDataChanged(Qt::Orientation,int,int)),
                   this, SLOT(_q_sourceHeaderDataChanged(Qt::Orientation,int,int)));
        disconnect(sourceModel(), SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)),
                   this, SLOT(_q_sourceLayoutAboutToBeChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)));
        disconnect(sourceModel(), SIGNAL(layoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)),
                   this, SLOT(_q_sourceLayoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)));
    }

    QAbstractProxyModel::setSourceModel(newSourceModel);

    if (sourceModel()) {
        connect(sourceModel(), SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)),
                SLOT(_q_sourceRowsAboutToBeInserted(QModelIndex,int,int)));
        connect(sourceModel(), SIGNAL(rowsInserted(QModelIndex,int,int)),
                SLOT(_q_sourceRowsInserted(QModelIndex,int,int)));
        connect(sourceModel(), SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),
                SLOT(_q_sourceRowsAboutToBeRemoved(QModelIndex,int,int)));
        connect(sourceModel(), SIGNAL(rowsRemoved(QModelIndex,int,int)),
                SLOT(_q_sourceRowsRemoved(QModelIndex,int,int)));
        connect(sourceModel(), SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)),
                SLOT(_q_sourceRowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)));
        connect(sourceModel(), SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)),
                SLOT(_q_sourceRowsMoved(QModelIndex,int,int,QModelIndex,int)));
        connect(sourceModel(), SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)),
                SLOT(_q_sourceColumnsAboutToBeInserted(QModelIndex,int,int)));
        connect(sourceModel(), SIGNAL(columnsInserted(QModelIndex,int,int)),
                SLOT(_q_sourceColumnsInserted(QModelIndex,int,int)));
        connect(sourceModel(), SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)),
                SLOT(_q_sourceColumnsAboutToBeRemoved(QModelIndex,int,int)));
        connect(sourceModel(), SIGNAL(columnsRemoved(QModelIndex,int,int)),
                SLOT(_q_sourceColumnsRemoved(QModelIndex,int,int)));
        connect(sourceModel(), SIGNAL(columnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)),
                SLOT(_q_sourceColumnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int)));
        connect(sourceModel(), SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int)),
                SLOT(_q_sourceColumnsMoved(QModelIndex,int,int,QModelIndex,int)));
        connect(sourceModel(), SIGNAL(modelAboutToBeReset()),
                SLOT(_q_sourceModelAboutToBeReset()));
        connect(sourceModel(), SIGNAL(modelReset()),
                SLOT(_q_sourceModelReset()));
        connect(sourceModel(), SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)),
                SLOT(_q_sourceDataChanged(QModelIndex,QModelIndex,QVector<int>)));
        connect(sourceModel(), SIGNAL(headerDataChanged(Qt::Orientation,int,int)),
                SLOT(_q_sourceHeaderDataChanged(Qt::Orientation,int,int)));
        connect(sourceModel(), SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)),
                SLOT(_q_sourceLayoutAboutToBeChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)));
        connect(sourceModel(), SIGNAL(layoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)),
                SLOT(_q_sourceLayoutChanged(QList<QPersistentModelIndex>,QAbstractItemModel::LayoutChangeHint)));
    }

    endResetModel();
}
void
QvisPluginManagerAttributesDataModel::Update(Subject *)
{
    beginResetModel();
    endResetModel();
}
void MusicLibraryModel::clear()
{
    beginResetModel();
    rootItem->clear();
    endResetModel();
}
InstanceList::InstListError InstanceList::loadList()
{
	// load the instance groups
	QMap<QString, QString> groupMap;
	loadGroupList(groupMap);
	
	beginResetModel();
	
	m_instances.clear();
	QDir dir(m_instDir);
	QDirIterator iter(dir);
	while (iter.hasNext())
	{
		QString subDir = iter.next();
		if (!QFileInfo(PathCombine(subDir, "instance.cfg")).exists())
			continue;
		
		BaseInstance *instPtr = NULL;
		auto &loader = InstanceFactory::get();
		auto error = loader.loadInstance(instPtr, subDir);
		
		switch(error)
		{
			case InstanceFactory::NoLoadError:
				break;
			case InstanceFactory::NotAnInstance:
				break;
		}
		
		if (error != InstanceFactory::NoLoadError &&
			error != InstanceFactory::NotAnInstance)
		{
			QString errorMsg = QString("Failed to load instance %1: ").
					arg(QFileInfo(subDir).baseName()).toUtf8();
			
			switch (error)
			{
			default:
				errorMsg += QString("Unknown instance loader error %1").
						arg(error);
				break;
			}
			qDebug(errorMsg.toUtf8());
		}
		else if (!instPtr)
		{
			qDebug(QString("Error loading instance %1. Instance loader returned null.").
					arg(QFileInfo(subDir).baseName()).toUtf8());
		}
		else
		{
			QSharedPointer<BaseInstance> inst(instPtr);
			auto iter = groupMap.find(inst->id());
			if(iter != groupMap.end())
			{
				inst->setGroupInitial((*iter));
			}
			qDebug(QString("Loaded instance %1").arg(inst->name()).toUtf8());
			inst->setParent(this);
			m_instances.append(inst);
			connect(instPtr, SIGNAL(propertiesChanged(BaseInstance*)),this, SLOT(propertiesChanged(BaseInstance*)));
			connect(instPtr, SIGNAL(groupChanged()),this, SLOT(groupChanged()));
			connect(instPtr, SIGNAL(nuked(BaseInstance*)), this, SLOT(instanceNuked(BaseInstance*)));
		}
	}
	endResetModel();
	emit dataIsInvalid();
	return NoError;
}
void QxrdMaskStackModel::onMaskChanged()
{
  emit beginResetModel();

  emit endResetModel();
}
Exemple #22
0
/**
 * @brief Shift the time-window of the model backward. Recalculate the current
 *	  state of the model.
 *
 * @param n: Number of bins to shift.
 */
void KsGraphModel::shiftBackward(size_t n)
{
	beginResetModel();
	ksmodel_shift_backward(&_histo, n);
	endResetModel();
}
Exemple #23
0
void QgsFieldModel::removeExpression()
{
  beginResetModel();
  mExpression = QList<QString>();
  endResetModel();
}
Exemple #24
0
/**
 * @brief Move the time-window of the model to a given location. Recalculate
 *	  the current state of the model.
 *
 * @param ts: position in time to be visualized.
 */
void KsGraphModel::jumpTo(size_t ts)
{
	beginResetModel();
	ksmodel_jump_to(&_histo, ts);
	endResetModel();
}
Exemple #25
0
void DockModel::resetModel()
{
  beginResetModel();
  endResetModel();
}
Exemple #26
0
/**
 * @brief Shrink the time-window of the model. Recalculate the current state
 *	  of the model.
 *
 * @param r: Scale factor of the zoom-in.
 * @param mark: Focus point of the zoom-in.
 */
void KsGraphModel::zoomIn(double r, int mark)
{
	beginResetModel();
	ksmodel_zoom_in(&_histo, r, mark);
	endResetModel();
}
void DatasetItemModel::clear()
{
    beginResetModel();
    m_datasets_reference.clear();
    endResetModel();
}
Exemple #28
0
/** Reset the model. */
void KsGraphModel::reset()
{
	beginResetModel();
	ksmodel_clear(&_histo);
	endResetModel();
}
Exemple #29
0
 void setFormatDescriptions(const FormatDescriptions *descriptions)
 {
     beginResetModel();
     m_descriptions = descriptions;
     endResetModel();
 }
//-----------------------------------------------------------------------------
// Function: ApiFunctionParameterModel::setFunction()
//-----------------------------------------------------------------------------
void ApiFunctionParameterModel::setFunction(QSharedPointer<ApiFunction> func)
{
    beginResetModel();
    func_ = func;
    endResetModel();
}