LogManager::LogManager(string name)
{
	this->name = name;
	db = new DBInterface;

	events = db->getAllEvents(name);
	copy_events = db->getAllCopyEvent(name);

	calcStatistic();
}
void QgsMergeAttributesDialog::refreshMergedValue( int col )
{
  QComboBox *comboBox = qobject_cast<QComboBox *>( mTableWidget->cellWidget( 0, col ) );
  if ( !comboBox )
  {
    return;
  }

  int fieldIdx = mTableWidget->horizontalHeaderItem( col )->data( FieldIndex ).toInt();

  //evaluate behavior (feature value or min / max / mean )
  QString mergeBehaviorString = comboBox->currentData().toString();
  QVariant mergeResult; // result to show in the merge result field
  if ( mergeBehaviorString == QLatin1String( "concat" ) )
  {
    mergeResult = concatenationAttribute( col );
  }
  else if ( mergeBehaviorString == QLatin1String( "skip" ) )
  {
    mergeResult = tr( "Skipped" );
  }
  else if ( mergeBehaviorString == QLatin1String( "manual" ) )
  {
    return; //nothing to do
  }
  else if ( mergeBehaviorString.startsWith( 'f' ) )
  {
    //an existing feature value
    QgsFeatureId featureId = STRING_TO_FID( mergeBehaviorString.mid( 1 ) );
    mergeResult = featureAttribute( featureId, fieldIdx );
  }
  else
  {
    //numerical statistic
    QgsStatisticalSummary::Statistic stat = ( QgsStatisticalSummary::Statistic )( comboBox->currentData().toInt() );
    mergeResult = calcStatistic( fieldIdx, stat );
  }

  //insert string into table widget
  mUpdating = true; // prevent combobox changing to "manual" value
  QTableWidgetItem *item = mTableWidget->item( mTableWidget->rowCount() - 1, col );
  item->setData( Qt::DisplayRole, mergeResult );
  mUpdating = false;
}
void LogManager::setEvents(vector<LogEvent>& events)
{
	this->events = events;
	calcStatistic();
	//groupAccAction();
}