/* copyModel - Copy all the contents from one model to another */
void copyModel(Model *dst_m, Model *src_m) {
  int u, i;
  assert(src_m&&dst_m);
  //assert(src_m->uu<=dst_m->uu); /* Take into account the elimination of unreachable states */
  assert(src_m->ffm[0]->ii==dst_m->ffm[0]->ii);

  if(src_m->uu != dst_m->uu){
    freeModel(dst_m);
    dst_m = allocModel(src_m->ffm[0]->ii, src_m->uu);
    for(i = 0; i < src_m->ffm[0]->ii; i ++){
      switch((src_m->ffm[0])->ft[i]){
      case FT_CONTINUOUS:
	defineContFeat(dst_m, i, ((struct ContFI*)((src_m->ffm[0])->fi[i]))->initialSigma);
	break;
      case FT_RADIAL:
	defineRadialFeat(dst_m, i);
	break;
      case FT_DISCRETE:
	defineDiscreteFeat(dst_m, i);
	break;
      default:break;
      }
    }
  }
  
  copyHMM(dst_m->hmm, src_m->hmm);
  for (u = 0; u<src_m->uu; u++) copyFFM(dst_m->ffm[u], src_m->ffm[u]);
}
Beispiel #2
0
void toResultTableView::querySub(QSharedPointer<toConnectionSubLoan> &con, const QString &sql, toQueryParams const& param)
{
    setSqlAndParams(sql, param);

    TLOG(7, toDecorator, __HERE__) << "Query from toResultTableView::querySub :" << sql << std::endl;
    try
    {
        if (Model && running())
            Model->stop();
        freeModel();

        readAllAct->setEnabled(true);
        Ready = false;
        Finished = false;
        Working->setText(tr("Please wait..."));
        Working->hide();

        // sets visible true but won't show if parent is hidden
        QTimer t(this);
        t.singleShot(300, Working, SLOT(forceShow()));

        toEventQuery *query = new toEventQuery(this
                                               , con
                                               , sql
                                               , param
                                               , toEventQuery::READ_FIRST
                                               //, Statistics
                                              );

        toResultModel *model = allocModel(query);
        setModel(model);

        connect(Model, SIGNAL(done()), this, SLOT(slotHandleDone()));
        connect(Model, SIGNAL(modelReset()), this, SLOT(slotHandleReset()));
        connect(Model,
                SIGNAL(firstResult(const toConnection::exception &, bool)),
                this,
                SLOT(slotHandleFirst(const toConnection::exception &, bool)));
        setSortingEnabled(true);
        query->start();
    }
    catch (const toConnection::exception &str)
    {
        emit firstResult(toResult::sql(), str, true);
        emit done();
        slotHandleDone();
        Utils::toStatusMessage(str);
    }
    catch (const QString &str)
    {
        emit firstResult(toResult::sql(), str, true);
        emit done();
        slotHandleDone();
        Utils::toStatusMessage(str);
    }

    verticalHeader()->setVisible(false);
    verticalHeader()->setDefaultSectionSize(QFontMetrics(QFont()).height() + 4);

    horizontalHeader()->setHighlightSections(false);

    // when a new model is created the column sizes are lost
    ColumnsResized = false;
}