示例#1
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
bool UiTreeModelPdm::setData(const QModelIndex &index, const QVariant &value, int role /*= Qt::EditRole*/)
{
    if (!index.isValid())
    {
        return false;
    }
    
    PdmUiTreeItem* treeItem = UiTreeModelPdm::getTreeItemFromIndex(index);
    assert(treeItem);
    
    PdmObject* obj = treeItem->dataObject();
    assert(obj);
            
    if (role == Qt::EditRole && obj->userDescriptionField())
    {
        obj->userDescriptionField()->setValueFromUi(value);

        emitDataChanged(index);
        
        return true;
    }
    else if (role == Qt::CheckStateRole && obj->objectToggleField())
    {
        bool toggleOn = (value == Qt::Checked);
        
        obj->objectToggleField()->setValueFromUi(toggleOn);

        emitDataChanged(index);

        return true;
    }

    return false;
}
示例#2
0
bool AMInMemoryDataStore::setValue(const AMnDIndex &scanIndex, int measurementId, const AMnDIndex &measurementIndex, const AMNumber &newValue) {

	if(scanIndex.rank() != axes_.count())
		return false; // scan axis index doesn't provide enough / too many dimensions

	if((unsigned)measurementId >= (unsigned)measurements_.count())
		return false;	// invalid measurement specified;

	if(measurementIndex.rank() != measurements_.at(measurementId).rank())
		return false;

	int flatMeasurementIndex = flatIndexForMeasurement(measurementId, measurementIndex);

	if(axes_.count() == 0) {
#ifdef AM_ENABLE_BOUNDS_CHECKING
		if(flatMeasurementIndex >= scalarScanPoint_.at(measurementId).size())
			return false;
#endif
		scalarScanPoint_[measurementId][flatMeasurementIndex] = newValue;
	}
	else { // higher dimensions:
		int flatScanIndex = scanIndex.flatIndexInArrayOfSize(scanSize_);
#ifdef AM_ENABLE_BOUNDS_CHECKING
		if(flatScanIndex >= scanPoints_.count())
			return false;
		if(flatMeasurementIndex >= scanPoints_.at(flatScanIndex).at(measurementId).size())
			return false;
#endif
		scanPoints_[flatScanIndex][measurementId][flatMeasurementIndex] = newValue;
	}

	emitDataChanged(scanIndex, scanIndex, measurementId);
	return true;
}
示例#3
0
void DivePlannerPointsModel::loadFromDive(dive *d)
{
	bool oldRec = recalc;
	recalc = false;
	CylindersModel::instance()->updateDive();
	duration_t lasttime = {};
	struct gasmix gas;
	free_dps(&diveplan);
	diveplan.when = d->when;
	// is this a "new" dive where we marked manually entered samples?
	// if yes then the first sample should be marked
	// if it is we only add the manually entered samples as waypoints to the diveplan
	// otherwise we have to add all of them
	bool hasMarkedSamples = d->dc.sample[0].manually_entered;
	for (int i = 0; i < d->dc.samples - 1; i++) {
		const sample &s = d->dc.sample[i];
		if (s.time.seconds == 0 || (hasMarkedSamples && !s.manually_entered))
			continue;
		get_gas_at_time(d, &d->dc, lasttime, &gas);
		plannerModel->addStop(s.depth.mm, s.time.seconds, &gas, 0, true);
		lasttime = s.time;
	}
	recalc = oldRec;
	emitDataChanged();
}
示例#4
0
void DivePlannerPointsModel::triggerGFHigh()
{
	if (diveplan.gfhigh != tempGFHigh) {
		diveplan.gfhigh = tempGFHigh;
		emitDataChanged();
	}
}
示例#5
0
void DivePlannerPointsModel::setVpmbConservatism(int level)
{
	if (diveplan.vpmb_conservatism != level) {
		diveplan.vpmb_conservatism = level;
		emitDataChanged();
	}
}
示例#6
0
void DivePlannerPointsModel::setStartTime(const QTime &t)
{
	startTime.setTime(t);
		diveplan.when = startTime.toTime_t();
	displayed_dive.when = diveplan.when;
	emitDataChanged();
}
示例#7
0
void ServerItem::init() {
	// Without this, columncount is wrong.
	setData(0, Qt::DisplayRole, QVariant());
	setData(1, Qt::DisplayRole, QVariant());
	setData(2, Qt::DisplayRole, QVariant());
	emitDataChanged();
}
示例#8
0
void DivePlannerPointsModel::setDecoSac(double sac)
{
	diveplan.decosac = units_to_sac(sac);
	auto planner = SettingsObjectWrapper::instance()->planner_settings;
	planner->setDecoSac(diveplan.decosac);
	emitDataChanged();
}
示例#9
0
void Buffers::cleanChanged(bool clean) {
    Q_UNUSED(clean);
    const qce::Document *d = qobject_cast<const qce::Document*>(sender());
    int idx = lowerBound(m_buffers, d->fileName());
    Q_ASSERT(idx < m_buffers.count() && m_buffers.at(idx)->document == d);
    emitDataChanged(idx);
}
示例#10
0
void DivePlannerPointsModel::gaschange(const QModelIndex &index, int newcylinderid)
{
	int i = index.row(), oldcylinderid = divepoints[i].cylinderid;
	while (i < rowCount() && oldcylinderid == divepoints[i].cylinderid)
		divepoints[i++].cylinderid = newcylinderid;
	emitDataChanged();
}
示例#11
0
 void setBaseFont(const QFont &font)
 {
     emit layoutAboutToBeChanged(); // So the view adjust to new item height
     m_baseFont = font;
     emit layoutChanged();
     emitDataChanged(index(0));
 }
示例#12
0
void DivePlannerPointsModel::triggerGFLow()
{
	if (diveplan.gflow != tempGFLow) {
		diveplan.gflow = tempGFLow;
		emitDataChanged();
	}
}
示例#13
0
bool AMInMemoryDataStore::setValue(const AMnDIndex &scanIndex, int measurementId, const double *inputData) {
	// scan axis index doesn't provide enough / too many dimensions
	if(scanIndex.rank() != axes_.count())
		return false;

	if((unsigned)measurementId >= (unsigned)measurements_.count())
		return false;	// invalid measurement specified;

	// scalar scan space:
	if(axes_.count() == 0) {
		AMIMDSMeasurement& measurement = scalarScanPoint_[measurementId];
		for(int i=0,cc=measurement.size(); i<cc; ++i)
			measurement[i] = inputData[i];
	}
	// higher dimension scan space:
	else {
		int flatScanIndex = scanIndex.flatIndexInArrayOfSize(scanSize_);
#ifdef AM_ENABLE_BOUNDS_CHECKING
		if(flatScanIndex >= scanPoints_.count())
			return false;
#endif
		AMIMDSMeasurement& measurement = scanPoints_[flatScanIndex][measurementId];
		for(int i=0,cc=measurement.size(); i<cc; ++i)
			measurement[i] = inputData[i];
	}

	emitDataChanged(scanIndex, scanIndex, measurementId);
	return true;
}
示例#14
0
void DivePlannerPointsModel::setRebreatherMode(int mode)
{
	int i;
	displayed_dive.dc.divemode = (dive_comp_type) mode;
	for (i=0; i < rowCount(); i++)
		divepoints[i].setpoint = mode == CCR ? prefs.defaultsetpoint : 0;
	emitDataChanged();
}
示例#15
0
void DivePlannerPointsModel::setReserveGas(int reserve)
{
	auto planner = SettingsObjectWrapper::instance()->planner_settings;
	if (prefs.units.pressure == units::BAR)
		planner->setReserveGas(reserve * 1000);
	else
		planner->setReserveGas(psi_to_mbar(reserve));
	emitDataChanged();
}
/*!
    setItemMetaData. Set function for item related meta data object
 */
void NmMailboxListModelItem::setItemMetaData(NmMailboxMetaData *mailbox)
{
    NM_FUNCTION;
    
    if (mMailbox) {
        delete mMailbox;
    }
    mMailbox = mailbox;
    emitDataChanged();
}
示例#17
0
void
UserListItem::setHostAddreess(const QHostAddress& address)
{
  if (d->host_address_ == address)
    return;

  d->host_address_ = address;
  updateActivity();
  emitDataChanged();
}
示例#18
0
void DiagramsModel::emitDataChanged(UMLView *view)
{
#if QT_VERSION < 0x050000
    emit layoutAboutToBeChanged();
#endif
    int index = m_views.indexOf(view);
    emitDataChanged(index);
#if QT_VERSION < 0x050000
    emit layoutChanged();
#endif
}
示例#19
0
bool UserListItem::updateIcon()
{
  bool new_blinking = false;
  ChatWindow *window = ChatWindow::findWindow(d->uuid_);
  if (0 != window)
    new_blinking = window->hasUnreadMessages();

  if (d->icon_blinking_ != new_blinking)
    {
      d->icon_blinking_ = new_blinking;
      emitDataChanged();
    }
  else
    {
      if (d->icon_blinking_)
        emitDataChanged();
    }

  return d->icon_blinking_;
}
示例#20
0
void Entry::setIcon(int iconNumber)
{
    Q_ASSERT(iconNumber >= 0);

    if (m_data.iconNumber != iconNumber || !m_data.customIcon.isNull()) {
        m_data.iconNumber = iconNumber;
        m_data.customIcon = Uuid();

        Q_EMIT modified();
        emitDataChanged();
    }
}
示例#21
0
void Entry::setIcon(const Uuid& uuid)
{
    Q_ASSERT(!uuid.isNull());

    if (m_data.customIcon != uuid) {
        m_data.customIcon = uuid;
        m_data.iconNumber = 0;

        Q_EMIT modified();
        emitDataChanged();
    }
}
示例#22
0
void DivePlannerPointsModel::editStop(int row, divedatapoint newData)
{
	/*
	 * When moving divepoints rigorously, we might end up with index
	 * out of range, thus returning the last one instead.
	 */
	if (row >= divepoints.count())
		return;
	divepoints[row] = newData;
	std::sort(divepoints.begin(), divepoints.end(), divePointsLessThan);
	if (updateMaxDepth())
		CylindersModel::instance()->updateBestMixes();
	emitDataChanged();
}
示例#23
0
void AMTESTSeriesData::addData(const QVector<qreal> &data)
{
	yAxis_.addValues(data);
	int seriesSize = yAxis_.size();

	if (xAxis_.size() != seriesSize){

		xAxis_ = QVector<qreal>(seriesSize, 0);

		for (int i = 0; i < seriesSize; i++)
			xAxis_[i] = -1*(seriesSize-(i+1))/updateRate_;
	}

	emitDataChanged();
}
示例#24
0
QAbstractListModel* ProvidersModel::createListModel()
{
  ProvidersListModel* pListModel = new ProvidersListModel(m_providers, this);
  connect(this, SIGNAL(modelAboutToBeReset()),        pListModel, SIGNAL(modelAboutToBeReset()));
  connect(this, SIGNAL(modelReset()),                 pListModel, SIGNAL(modelReset()));
  connect(this, SIGNAL(layoutAboutToBeChanged()),     pListModel, SIGNAL(modelReset()));
  connect(this, SIGNAL(layoutChanged()),              pListModel, SIGNAL(modelReset()));
  connect(this, SIGNAL(dataChanged(QModelIndex,QModelIndex)),       pListModel, SLOT(emitDataChanged(QModelIndex,QModelIndex)));
  connect(this, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), pListModel, SLOT(emitRowsAboutToBeInserted(QModelIndex,int,int)));
  connect(this, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)),  pListModel, SLOT(emitRowsAboutToBeRemoved(QModelIndex,int,int)));
  connect(this, SIGNAL(rowsInserted(QModelIndex,int,int)),          pListModel, SLOT(emitRowsInserted(QModelIndex,int,int)));
  connect(this, SIGNAL(rowsRemoved(QModelIndex,int,int)),           pListModel, SLOT(emitRowsRemoved(QModelIndex,int,int)));

  return pListModel;
}
示例#25
0
void DivePlannerPointsModel::loadFromDive(dive *d)
{
	int depthsum = 0;
	int samplecount = 0;
	bool oldRec = recalc;
	recalc = false;
	CylindersModel::instance()->updateDive();
	duration_t lasttime = {};
	duration_t newtime = {};
	struct gasmix gas;
	free_dps(&diveplan);
	diveplan.when = d->when;
	// is this a "new" dive where we marked manually entered samples?
	// if yes then the first sample should be marked
	// if it is we only add the manually entered samples as waypoints to the diveplan
	// otherwise we have to add all of them

	bool hasMarkedSamples = false;

	if (d->dc.samples)
		hasMarkedSamples = d->dc.sample[0].manually_entered;

	// if this dive has more than 100 samples (so it is probably a logged dive),
	// average samples so we end up with a total of 100 samples.
	int plansamples = d->dc.samples <= 100 ? d->dc.samples : 100;
	int j = 0;
	for (int i = 0; i < plansamples - 1; i++) {
		while (j * plansamples <= i * d->dc.samples) {
			const sample &s = d->dc.sample[j];
			if (s.time.seconds != 0 && (!hasMarkedSamples || s.manually_entered)) {
				depthsum += s.depth.mm;
				++samplecount;
				newtime = s.time;
			}
			j++;
		}
		if (samplecount) {
			get_gas_at_time(d, &d->dc, lasttime, &gas);
			addStop(depthsum / samplecount, newtime.seconds, &gas, 0, true);
			lasttime = newtime;
			depthsum = 0;
			samplecount = 0;
		}
	}
	recalc = oldRec;
	emitDataChanged();
}
示例#26
0
void MediaView::search(SearchParams *searchParams) {
    if (!searchParams->keywords().isEmpty()) {
        if (searchParams->keywords().startsWith("http://") ||
                searchParams->keywords().startsWith("https://")) {
            QString videoId = YTSearch::videoIdFromUrl(searchParams->keywords());
            if (!videoId.isEmpty()) {
                YTSingleVideoSource *singleVideoSource = new YTSingleVideoSource(this);
                singleVideoSource->setVideoId(videoId);
                setVideoSource(singleVideoSource);
                return;
            }
        }
    }
    YTSearch *ytSearch = new YTSearch(searchParams, this);
    ytSearch->setAsyncDetails(true);
    connect(ytSearch, SIGNAL(gotDetails()), playlistModel, SLOT(emitDataChanged()));
    setVideoSource(ytSearch);
}
示例#27
0
Entry::Entry()
    : m_attributes(new EntryAttributes(this))
    , m_attachments(new EntryAttachments(this))
    , m_autoTypeAssociations(new AutoTypeAssociations(this))
    , m_tmpHistoryItem(Q_NULLPTR)
    , m_updateTimeinfo(true)
{
    m_data.iconNumber = DefaultIconNumber;
    m_data.autoTypeEnabled = true;
    m_data.autoTypeObfuscation = 0;

    connect(m_attributes, SIGNAL(modified()), this, SIGNAL(modified()));
    connect(m_attributes, SIGNAL(defaultKeyModified()), SLOT(emitDataChanged()));
    connect(m_attachments, SIGNAL(modified()), this, SIGNAL(modified()));
    connect(m_autoTypeAssociations, SIGNAL(modified()), SIGNAL(modified()));

    connect(this, SIGNAL(modified()), SLOT(updateTimeinfo()));
    connect(this, SIGNAL(modified()), SLOT(updateModifiedSinceBegin()));
}
示例#28
0
void DivePlannerPointsModel::setDropStoneMode(bool value)
{
	auto planner = SettingsObjectWrapper::instance()->planner_settings;
	planner->setDropStoneMode(value);
	if (prefs.drop_stone_mode) {
	/* Remove the first entry if we enable drop_stone_mode */
		if (rowCount() >= 2) {
			beginRemoveRows(QModelIndex(), 0, 0);
			divepoints.remove(0);
			endRemoveRows();
		}
	} else {
		/* Add a first entry if we disable drop_stone_mode */
		beginInsertRows(QModelIndex(), 0, 0);
		/* Copy the first current point */
		divedatapoint p = divepoints.at(0);
		p.time = p.depth.mm / prefs.descrate;
		divepoints.push_front(p);
		endInsertRows();
	}
	emitDataChanged();
}
示例#29
0
void QScriptDebuggerLocalsModelPrivate::reallySyncIndex(const QModelIndex &index,
                                                        const QScriptDebuggerObjectSnapshotDelta &delta)
{
    if (!index.isValid())
        return;
    QScriptDebuggerLocalsModelNode *node = nodeFromIndex(index);
    // update or remove existing children
    for (int i = 0; i < node->children.count(); ++i) {
        QScriptDebuggerLocalsModelNode *child = node->children.at(i);
        int j;
        for (j = 0; j < delta.changedProperties.count(); ++j) {
            if (child->property.name() == delta.changedProperties.at(j).name()) {
                child->property = delta.changedProperties.at(j);
                child->changed = true;
                emitDataChanged(index, index.sibling(0, 1));
                repopulate(child);
                break;
            }
        }
        if (j != delta.changedProperties.count())
            continue; // was changed
        for (j = 0; j < delta.removedProperties.count(); ++j) {
            if (child->property.name() == delta.removedProperties.at(j)) {
                removeChild(index, node, i);
                --i;
                break;
            }
        }
        if (j != delta.removedProperties.count())
            continue; // was removed
        // neither changed nor removed, but its children might be
        if (child->populationState == QScriptDebuggerLocalsModelNode::Populated) {
            QScriptDebuggerJob *job = new SyncModelIndexJob(indexFromNode(child), commandScheduler);
            jobScheduler->scheduleJob(job);
        }
    }
    addChildren(index, node, delta.addedProperties);
}
示例#30
0
 void setColorScheme(const ColorScheme *scheme)
 {
     m_scheme = scheme;
     emitDataChanged(index(0));
 }