예제 #1
0
void SubsonicService::onGetMusicDirectoryFinished()
{
  QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());
  Q_ASSERT(reply);
  reply->deleteLater();
  QXmlStreamReader reader(reply);

  reader.readNextStartElement();
  Q_ASSERT(reader.name() == "subsonic-response");
  if (reader.attributes().value("status") != "ok")
  {
    // TODO: error handling
    return;
  }

  reader.readNextStartElement();
  Q_ASSERT(reader.name() == "directory");
  QStandardItem *parent = item_lookup_.value(reader.attributes().value("id").toString());
  parent->setRowCount(0);
  while (reader.readNextStartElement())
  {
    if (reader.attributes().value("isDir") == "true")
    {
      ReadAlbum(&reader, parent);
    }
    else if (reader.attributes().value("isVideo") == "false")
    {
      ReadTrack(&reader, parent);
    }
    else
    {
      reader.skipCurrentElement();
    }
  }
}
예제 #2
0
void tst_QStandardItem::getSetRowAndColumnCount()
{
    QStandardItem item;

    item.setRowCount(-1);
    QCOMPARE(item.rowCount(), 0);

    item.setColumnCount(-1);
    QCOMPARE(item.columnCount(), 0);

    item.setRowCount(1);
    QCOMPARE(item.rowCount(), 1);
    QCOMPARE(item.columnCount(), 0);

    item.setColumnCount(1);
    QCOMPARE(item.columnCount(), 1);
    QCOMPARE(item.rowCount(), 1);

    item.setColumnCount(10);
    QCOMPARE(item.columnCount(), 10);
    QCOMPARE(item.rowCount(), 1);

    item.setRowCount(20);
    QCOMPARE(item.rowCount(), 20);
    QCOMPARE(item.columnCount(), 10);

    item.setRowCount(-1);
    QCOMPARE(item.rowCount(), 20);

    item.setColumnCount(-1);
    QCOMPARE(item.columnCount(), 10);

    item.setColumnCount(0);
    QCOMPARE(item.columnCount(), 0);
    QCOMPARE(item.rowCount(), 20);

    item.setRowCount(0);
    QCOMPARE(item.rowCount(), 0);
}
예제 #3
0
void
MSPeakSummary::setResult( int row, const std::vector<double>& coeffs, double sd )
{
	QStandardItemModel& model = *model_;
    QStandardItem * parent = model.itemFromIndex( model.index( r_result, 0 ) );

    if ( row >= parent->rowCount() )
        parent->setRowCount( row + 1 );

    model.setData( model.index( row, c_mspeaksummary_mode, parent->index() ), row );
    model.setData( model.index( row, c_mspeaksummary_coeffs + 0, parent->index() ), coeffs[0] );
    model.setData( model.index( row, c_mspeaksummary_coeffs + 1, parent->index() ), coeffs[1] );
    model.setData( model.index( row, c_mspeaksummary_sd, parent->index() ), sd );
    // model.setData( model.index( row, c_mspeaksummary_t0, parent->index() ), t0 );
}
예제 #4
0
void
MSPeakSummary::setPolynomials( const std::string& formula, const std::vector<double>& coeffs, double sd, double v )
{
	QStandardItemModel& model = *model_;
    QStandardItem * parent = model.itemFromIndex( model.index( r_length_vs_time, 0 ) );
    int row = parent->rowCount();
	for ( int r = 0; r < row; ++r ) {
		if ( model.data( model.index( r, c_mspeaksummary_mode, parent->index() ) ).toString() == QString::fromStdString(formula) ) {
            row = r;
            break;
        }
	}
    if ( row >= parent->rowCount() )
        parent->setRowCount( row + 1 );

    model.setData( model.index( row, c_mspeaksummary_mode, parent->index() ), QString::fromStdString( formula ) );
    model.setData( model.index( row, c_mspeaksummary_coeffs + 0, parent->index() ), coeffs[0] );
    model.setData( model.index( row, c_mspeaksummary_coeffs + 1, parent->index() ), coeffs[1] );
    model.setData( model.index( row, c_mspeaksummary_sd, parent->index() ), sd );
    double t0 = coeffs[0];
    model.setData( model.index( row, c_mspeaksummary_t0, parent->index() ), t0 );
    model.setData( model.index( row, c_mspeaksummary_velocity, parent->index() ), v );
}