示例#1
0
// Received from AMSamplePlate. Used to implement beginInsertRows.
void AMSamplePlateItemModel::onSamplePositionAboutToBeAdded(int index) {
	beginInsertRows(QModelIndex(), index, index);
	cachedSamples_.insert(index, AMSample());
}
示例#2
0
// Received from AMSamplePlate. Used to implement beginRemoveRows.
void AMSamplePlateItemModel::onSamplePositionAboutToBeRemoved(int index) {

	beginRemoveRows(QModelIndex(), index, index);
}
示例#3
0
QModelIndex DailyScheduleModel::parent(const QModelIndex & /* index */) const {
	return QModelIndex();
}
示例#4
0
void KateFileTree::slotDocumentNext()
{
  // kDebug(debugArea()) << "BEGIN";

  KateFileTreeProxyModel *ftpm = static_cast<KateFileTreeProxyModel*>(model());

  QModelIndex current_index = currentIndex();
  int parent_row_count = ftpm->rowCount( ftpm->parent(current_index) );
  QModelIndex next;

  // scan down the tree skipping any dir nodes
  while(current_index.isValid()) {
    if(current_index.row() < parent_row_count-1) {
      current_index = ftpm->sibling(current_index.row()+1, current_index.column(), current_index);
      if(!current_index.isValid()) {
        break;
      }

      if(ftpm->isDir(current_index)) {
        // we have a dir node
        while(ftpm->isDir(current_index)) {
          current_index = ftpm->index(0, 0, current_index);
        }

        parent_row_count = ftpm->rowCount( ftpm->parent(current_index) );

        if(!ftpm->isDir(current_index)) {
          next = current_index;
          break;
        }
      } else { // found document item
        next = current_index;
        break;
      }
    }
    else {
      // select the parent's next sibling
      QModelIndex parent_index = ftpm->parent(current_index);
      int grandparent_row_count = ftpm->rowCount( ftpm->parent(parent_index) );

      current_index = parent_index;
      parent_row_count = grandparent_row_count;

      // at least if we're not past the last node
      if(!current_index.isValid()) {
        // paste the root node here, try and wrap around
        QModelIndex last_index = ftpm->index(0, 0, QModelIndex());
        if(!last_index.isValid()) {
          break;
        }

        if(ftpm->isDir(last_index)) {
          // last node is a dir, select first child row
          while(ftpm->isDir(last_index)) {
            if(ftpm->rowCount(last_index)) {
              // has children, select first
              last_index = ftpm->index(0, 0, last_index);
            }
          }

          next = last_index;
          break;
        }
        else {
          // got first file node
          next = last_index;
          break;
        }
      }
    }
  }

  if(next.isValid()) {
    //kDebug(debugArea()) << "got next node:" << next;
    //kDebug(debugArea()) << "doc:" << ftpm->data(next, Qt::DisplayRole).value<QString>();

    KTextEditor::Document *doc = model()->data(next, KateFileTreeModel::DocumentRole).value<KTextEditor::Document *>();
    emit activateDocument(doc);
  }
  else {
//     kDebug(debugArea()) << "didn't get next node :(";
  }

//   kDebug(debugArea()) << "END";
}
void QgsCategorizedSymbolRendererV2Model::removeAllRows()
{
  beginRemoveRows( QModelIndex(), 0, mRenderer->categories().size() - 1 );
  mRenderer->deleteAllCategories();
  endRemoveRows();
}
示例#6
0
void GriloDataSource::addMedia(GriloMedia *media) {
  int size = m_media.size();

  foreach (GriloModel *model, m_models) {
    model->beginInsertRows(QModelIndex(), size, size);
  }
void tst_QAbstractProxyModel::flags_data()
{
    QTest::addColumn<QModelIndex>("index");
    QTest::addColumn<Qt::ItemFlags>("flags");
    QTest::newRow("null") << QModelIndex() << (Qt::ItemFlags)0;
}
QModelIndex IndicesTableModel::parent(const QModelIndex&) const
{
    return QModelIndex();
}
示例#9
0
void ContTblPlugin::tblResult(DataBox *data, QString nameGene)
{
    Q_UNUSED(nameGene)

    QVector<QString> names;
    QVector<int> numH;
    QVector<int> numI;

    QModelIndex index1, index2;
    int max = 0;
    for (int i = 0; i < data->rowCount(QModelIndex()); ++i)
    {
        index1 = data->index(i, 1);
        if (data->data(index1, Qt::DisplayRole).toInt() > max)
            max = data->data(index1, Qt::DisplayRole).toInt();
    }

    names.resize(max);
    numH.resize(max);
    numI.resize(max);

    for (int i = 0; i < data->rowCount(QModelIndex()); ++i)
    {
        index1 = data->index(i, 1); //группа
        int group = data->data(index1, Qt::DisplayRole).toInt();
        index2 = data->index(i, 0); //имя аллели
        names[group - 1] += data->data(index2, Qt::DisplayRole).toString() + "; ";
        index2 = data->index(i, 2); //здор кол
        numH[group - 1] += data->data(index2, Qt::DisplayRole).toInt();
        index2 = data->index(i, 3); //боль кол
        numI[group - 1] += data->data(index2, Qt::DisplayRole).toInt();
    }
    qDebug() << "stage1 : " << names.size() << numH.size() << numI.size();
    /*******************************/
    /*      rewrite data           */
    /*******************************/

    data->dataClear();

    data->setColumnCount(8);
    data->setRowCount(names.size());

    int allH = 0, allI = 0;
    for (int i = 0; i < names.size(); ++i)
    {
        allH += numH[i];
        allI += numI[i];
    }

    for (int i = 0; i < data->getRowCount(); ++i)
    {
        DataForAlleles var;
        for (int j = 0; j < data->getColumnCount(); ++j)
        {
            switch (j)
            {
            case 0: // наименование
                var.name = names[i];
                break;
            case 1: // группа
                var.group = i + 1;
                break;
            case 2: // здоровые кол-во
                var.numHealthy = numH[i];
                break;
            case 3: // больные кол-во
                var.numIll = numI[i];
                break;
            case 4: // здоровые частота
                var.freakHealthy = (double)numH[i] / allH;
                break;
            case 5: // больные частота
                var.freakIll = (double)numI[i] / allI;
                break;
            case 6: // относ риск
                processRR(names[i], names, numH, numI);
                var.RR = RR;
                break;
            case 7: // 95% интервал
                var.RRInt = confInt;
                break;
            default:
                qDebug() << "no columns to show";
            }
            var.geneName = nameGene;
        }
        data->setDataToModel(var);
    }
    data->resetModel();
}
 QModelIndex parent(const QModelIndex&) const
 {
     return QModelIndex();
 }
示例#11
0
QModelIndex PackageModel::parent(const QModelIndex&) const
{
  return QModelIndex();
}
示例#12
0
void tst_QDataWidgetMapper::navigate()
{
    QDataWidgetMapper mapper;
    QAbstractItemModel *model = testModel(&mapper);
    mapper.setModel(model);

    QLineEdit edit1;
    QLineEdit edit2;
    QLineEdit edit3;

    mapper.addMapping(&edit1, 0);
    mapper.toFirst();
    mapper.addMapping(&edit2, 1);
    mapper.addMapping(&edit3, 2);

    QCOMPARE(edit1.text(), QString("item 0 0"));
    QVERIFY(edit2.text().isEmpty());
    QVERIFY(edit3.text().isEmpty());
    QVERIFY(mapper.submit());
    edit2.setText(QString("item 0 1"));
    edit3.setText(QString("item 0 2"));
    QVERIFY(mapper.submit());

    mapper.toFirst(); //this will repopulate
    QCOMPARE(edit1.text(), QString("item 0 0"));
    QCOMPARE(edit2.text(), QString("item 0 1"));
    QCOMPARE(edit3.text(), QString("item 0 2"));


    mapper.toFirst();
    QCOMPARE(edit1.text(), QString("item 0 0"));
    QCOMPARE(edit2.text(), QString("item 0 1"));
    QCOMPARE(edit3.text(), QString("item 0 2"));

    mapper.toPrevious(); // should do nothing
    QCOMPARE(edit1.text(), QString("item 0 0"));
    QCOMPARE(edit2.text(), QString("item 0 1"));
    QCOMPARE(edit3.text(), QString("item 0 2"));

    mapper.toNext();
    QCOMPARE(edit1.text(), QString("item 1 0"));
    QCOMPARE(edit2.text(), QString("item 1 1"));
    QCOMPARE(edit3.text(), QString("item 1 2"));

    mapper.toLast();
    QCOMPARE(edit1.text(), QString("item 9 0"));
    QCOMPARE(edit2.text(), QString("item 9 1"));
    QCOMPARE(edit3.text(), QString("item 9 2"));

    mapper.toNext(); // should do nothing
    QCOMPARE(edit1.text(), QString("item 9 0"));
    QCOMPARE(edit2.text(), QString("item 9 1"));
    QCOMPARE(edit3.text(), QString("item 9 2"));

    mapper.setCurrentIndex(4);
    QCOMPARE(edit1.text(), QString("item 4 0"));
    QCOMPARE(edit2.text(), QString("item 4 1"));
    QCOMPARE(edit3.text(), QString("item 4 2"));

    mapper.setCurrentIndex(-1); // should do nothing
    QCOMPARE(edit1.text(), QString("item 4 0"));
    QCOMPARE(edit2.text(), QString("item 4 1"));
    QCOMPARE(edit3.text(), QString("item 4 2"));

    mapper.setCurrentIndex(10); // should do nothing
    QCOMPARE(edit1.text(), QString("item 4 0"));
    QCOMPARE(edit2.text(), QString("item 4 1"));
    QCOMPARE(edit3.text(), QString("item 4 2"));

    mapper.setCurrentModelIndex(QModelIndex()); // should do nothing
    QCOMPARE(edit1.text(), QString("item 4 0"));
    QCOMPARE(edit2.text(), QString("item 4 1"));
    QCOMPARE(edit3.text(), QString("item 4 2"));

    mapper.setCurrentModelIndex(model->index(6, 0));
    QCOMPARE(edit1.text(), QString("item 6 0"));
    QCOMPARE(edit2.text(), QString("item 6 1"));
    QCOMPARE(edit3.text(), QString("item 6 2"));

    /* now try vertical navigation */

    mapper.setOrientation(Qt::Vertical);

    mapper.addMapping(&edit1, 0);
    mapper.addMapping(&edit2, 1);
    mapper.addMapping(&edit3, 2);

    mapper.toFirst();
    QCOMPARE(edit1.text(), QString("item 0 0"));
    QCOMPARE(edit2.text(), QString("item 1 0"));
    QCOMPARE(edit3.text(), QString("item 2 0"));

    mapper.toPrevious(); // should do nothing
    QCOMPARE(edit1.text(), QString("item 0 0"));
    QCOMPARE(edit2.text(), QString("item 1 0"));
    QCOMPARE(edit3.text(), QString("item 2 0"));

    mapper.toNext();
    QCOMPARE(edit1.text(), QString("item 0 1"));
    QCOMPARE(edit2.text(), QString("item 1 1"));
    QCOMPARE(edit3.text(), QString("item 2 1"));

    mapper.toLast();
    QCOMPARE(edit1.text(), QString("item 0 9"));
    QCOMPARE(edit2.text(), QString("item 1 9"));
    QCOMPARE(edit3.text(), QString("item 2 9"));

    mapper.toNext(); // should do nothing
    QCOMPARE(edit1.text(), QString("item 0 9"));
    QCOMPARE(edit2.text(), QString("item 1 9"));
    QCOMPARE(edit3.text(), QString("item 2 9"));

    mapper.setCurrentIndex(4);
    QCOMPARE(edit1.text(), QString("item 0 4"));
    QCOMPARE(edit2.text(), QString("item 1 4"));
    QCOMPARE(edit3.text(), QString("item 2 4"));

    mapper.setCurrentIndex(-1); // should do nothing
    QCOMPARE(edit1.text(), QString("item 0 4"));
    QCOMPARE(edit2.text(), QString("item 1 4"));
    QCOMPARE(edit3.text(), QString("item 2 4"));

    mapper.setCurrentIndex(10); // should do nothing
    QCOMPARE(edit1.text(), QString("item 0 4"));
    QCOMPARE(edit2.text(), QString("item 1 4"));
    QCOMPARE(edit3.text(), QString("item 2 4"));

    mapper.setCurrentModelIndex(QModelIndex()); // should do nothing
    QCOMPARE(edit1.text(), QString("item 0 4"));
    QCOMPARE(edit2.text(), QString("item 1 4"));
    QCOMPARE(edit3.text(), QString("item 2 4"));

    mapper.setCurrentModelIndex(model->index(0, 6));
    QCOMPARE(edit1.text(), QString("item 0 6"));
    QCOMPARE(edit2.text(), QString("item 1 6"));
    QCOMPARE(edit3.text(), QString("item 2 6"));
}
示例#13
0
	int CalendarModel::rowCount(const QModelIndex &index) const {
		if (index == QModelIndex())
			return WEEKS;
		return 0;
	}
示例#14
0
void Browse_Organization::SlotEdit()
{
    if (Table->model()->rowCount() == 0) {
        GuiWarning("Редактирование невозможно: таблица пуста!");
        return;
    }
    int Num = Table->model()->data(Table->model()->index(Table->selectionModel()->currentIndex().row(),0,QModelIndex())).toInt();
    Global.StartTransaction();                             GuiCheckFatal()
    LockForcer * Lock = new LockForcer(this,"Загрузка","Organization",Num);
    AllowUpdate = false;
    if (Lock->exec()) {
        Dialog_Organization *Dialog = new Dialog_Organization(this,tr("Редактировать Организацию"), Num);
        if (Dialog->exec()) {
            Global.CommitTransaction();                    GuiCheckFatal();
            Global.SetOperation("Organization",Num,2,"");  GuiCheckFatal();
            Global.Notify("Organization","*");             GuiCheckFatal();
            emit SigParent("Browse_Organization","MainWindow","OrganizationChanged",0);
            NeedUpdate = true;
        } else {
            Global.RollbackTransaction();                  GuiCheckFatal();
        }
        delete Dialog;
        Global.DelLocker("Organization",Num);              GuiCheckFatal();
    }
    delete Lock;
    AllowUpdate = true;
}
void tst_QAbstractProxyModel::mapToSource_data()
{
    QTest::addColumn<QModelIndex>("proxyIndex");
    QTest::addColumn<QModelIndex>("mapToSource");
    QTest::newRow("null") << QModelIndex() << QModelIndex();
}
示例#16
0
void Browse_Organization::SlotCurChanged(QModelIndex, QModelIndex)
{
    int Row = Table->selectionModel()->currentIndex().row();
    Cur = Table->model()->data(Table->model()->index(Row,0,QModelIndex())).toInt();
}
 // QAbstractProxyModel::mapFromSource is a pure virtual function.
 QModelIndex mapFromSource(QModelIndex const& sourceIndex) const
     { Q_UNUSED(sourceIndex); return QModelIndex(); }
QModelIndex QgsCategorizedSymbolRendererV2Model::parent( const QModelIndex &index ) const
{
  Q_UNUSED( index );
  return QModelIndex();
}
 // QAbstractProxyModel::mapToSource is a pure virtual function.
 QModelIndex mapToSource(QModelIndex const& proxyIndex) const
     { Q_UNUSED(proxyIndex); return QModelIndex(); }
示例#20
0
bool CQSpecieDM::removeRows(QModelIndexList rows, const QModelIndex&)
{
  mpUndoStack->push(new RemoveSpecieRowsCommand(rows, this, QModelIndex()));

  return true;
}
 QModelIndex index(int, int, const QModelIndex&) const
 {
     return QModelIndex();
 }
示例#22
0
void NoteModel::addNote(const QDomElement& note)
{
	beginInsertRows(QModelIndex(), notesList.size(), notesList.size());
	notesList.append(note);
	endInsertRows();
}
示例#23
0
    /* Update our model of the wallet incrementally, to synchronize our model of the wallet
       with that of the core.

       Call with transaction that was added, removed or changed.
     */
    void updateWallet(const uint256 &hash, int status)
    {
        OutputDebugStringF("updateWallet %s %i\n", hash.ToString().c_str(), status);
        {
            LOCK(wallet->cs_wallet);

            // Find transaction in wallet
            std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(hash);
            bool inWallet = mi != wallet->mapWallet.end();

            // Find bounds of this transaction in model
            QList<TransactionRecord>::iterator lower = qLowerBound(
                cachedWallet.begin(), cachedWallet.end(), hash, TxLessThan());
            QList<TransactionRecord>::iterator upper = qUpperBound(
                cachedWallet.begin(), cachedWallet.end(), hash, TxLessThan());
            int lowerIndex = (lower - cachedWallet.begin());
            int upperIndex = (upper - cachedWallet.begin());
            bool inModel = (lower != upper);

            // Determine whether to show transaction or not
            bool showTransaction = (inWallet && TransactionRecord::showTransaction(mi->second));

            if(status == CT_UPDATED)
            {
                if(showTransaction && !inModel)
                    status = CT_NEW; /* Not in model, but want to show, treat as new */
                if(!showTransaction && inModel)
                    status = CT_DELETED; /* In model, but want to hide, treat as deleted */
            }

            OutputDebugStringF("   inWallet=%i inModel=%i Index=%i-%i showTransaction=%i derivedStatus=%i\n",
                     inWallet, inModel, lowerIndex, upperIndex, showTransaction, status);

            switch(status)
            {
            case CT_NEW:
                if(inModel)
                {
                    OutputDebugStringF("Warning: updateWallet: Got CT_NEW, but transaction is already in model\n");
                    break;
                }
                if(!inWallet)
                {
                    OutputDebugStringF("Warning: updateWallet: Got CT_NEW, but transaction is not in wallet\n");
                    break;
                }
                if(showTransaction)
                {
                    // Added -- insert at the right position
                    QList<TransactionRecord> toInsert =
                            TransactionRecord::decomposeTransaction(wallet, mi->second);
                    if(!toInsert.isEmpty()) /* only if something to insert */
                    {
                        parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex+toInsert.size()-1);
                        int insert_idx = lowerIndex;
                        foreach(const TransactionRecord &rec, toInsert)
                        {
                            cachedWallet.insert(insert_idx, rec);
                            insert_idx += 1;
                        }
                        parent->endInsertRows();
                    }
                }
                break;
            case CT_DELETED:
                if(!inModel)
                {
                    OutputDebugStringF("Warning: updateWallet: Got CT_DELETED, but transaction is not in model\n");
                    break;
                }
                // Removed -- remove entire transaction from table
                parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
                cachedWallet.erase(lower, upper);
                parent->endRemoveRows();
                break;
            case CT_UPDATED:
                // Miscellaneous updates -- nothing to do, status update will take care of this, and is only computed for
                // visible transactions.
                break;
            }
示例#24
0
int DivePlannerPointsModel::addStop(int milimeters, int seconds, gasmix *gas_in, int ccpoint, bool entered)
{
	struct gasmix air = {};
	struct gasmix gas = {};
	bool usePrevious = false;
	if (gas_in)
		gas = *gas_in;
	else
		usePrevious = true;
	if (recalcQ())
		removeDeco();

	int row = divepoints.count();
	if (seconds == 0 && milimeters == 0 && row != 0) {
		/* this is only possible if the user clicked on the 'plus' sign on the DivePoints Table */
		const divedatapoint t = divepoints.at(lastEnteredPoint());
		milimeters = t.depth;
		seconds = t.time + 600; // 10 minutes.
		gas = t.gasmix;
		ccpoint = t.setpoint;
	} else if (seconds == 0 && milimeters == 0 && row == 0) {
		milimeters = M_OR_FT(5, 15); // 5m / 15ft
		seconds = 600;		     // 10 min
		//Default to the first defined gas, if we got one.
		cylinder_t *cyl = &displayed_dive.cylinder[0];
		if (cyl)
			gas = cyl->gasmix;
	}
	if (!usePrevious)
		if (!addGas(gas))
			qDebug("addGas failed"); // FIXME add error propagation

	// check if there's already a new stop before this one:
	for (int i = 0; i < row; i++) {
		const divedatapoint &dp = divepoints.at(i);
		if (dp.time == seconds) {
			row = i;
			beginRemoveRows(QModelIndex(), row, row);
			divepoints.remove(row);
			endRemoveRows();
			break;
		}
		if (dp.time > seconds) {
			row = i;
			break;
		}
	}
	// Previous, actually means next as we are typically subdiving a segment and the gas for
	// the segment is determined by the waypoint at the end.
	if (usePrevious) {
		if (row  < divepoints.count()) {
			gas = divepoints.at(row).gasmix;
		} else if (row > 0) {
			gas = divepoints.at(row - 1).gasmix;
		} else {
			if (!addGas(air))
				qDebug("addGas failed"); // FIXME add error propagation

		}
	}

	// add the new stop
	beginInsertRows(QModelIndex(), row, row);
	divedatapoint point;
	point.depth = milimeters;
	point.time = seconds;
	point.gasmix = gas;
	point.setpoint = ccpoint;
	point.entered = entered;
	point.next = NULL;
	divepoints.append(point);
	std::sort(divepoints.begin(), divepoints.end(), divePointsLessThan);
	endInsertRows();
	return row;
}
示例#25
0
// Everything is under the root.
QModelIndex PacketListModel::parent(const QModelIndex &index) const
{
    Q_UNUSED(index);
    return QModelIndex();
}