Esempio n. 1
0
void ParameterWidget::applyDefaultFilterSet()
{
  XSqlQuery qry;
  QString filter_name;
  int filter_id;
	QString pname;

 

  //hides parameterwidget when it's embedded within another widget with a parent
  if (this->parent() && this->parent()->parent())
  {
    clearFilters();
    this->hide();

    return;
  }

	if(window())
    pname = window()->objectName() + "/";
	_settingsName2 = pname + this->objectName();

	if(_x_preferences)
  {
		_settingsName2 += "/filter_default";
		filter_id = _x_preferences->value(_settingsName2).toInt();
	}

  QString query = "SELECT filter_name "
                  "FROM filter "
                  "WHERE filter_id=:id ";
                  

  if (this->parent())
  {
    QString classname(parent()->objectName());
    if (classname.isEmpty())
      classname = parent()->metaObject()->className();

    qry.prepare(query);
		qry.bindValue(":id", filter_id);
    qry.exec();

    if (qry.first())
    {
      filter_name = qry.value("filter_name").toString();
      setSavedFiltersIndex(filter_name);
      applySaved(0, filter_id);
    }
    else
    {
      addParam();
			applySaved(0, 0);
    }

  }

}
Esempio n. 2
0
void ParameterWidget::applyDefaultFilterSet()
{
  XSqlQuery qry;
  const QMetaObject *metaobject;
  QString classname;
  QString filter_name;
  int filter_id;

  //hides parameterwidget when it's embedded within another widget with a parent
  if (this->parent() && this->parent()->parent())
  {
    clearFilters();
    this->hide();

    return;
  }

  QString query = "SELECT filter_id, filter_name "
                  "FROM filter "
                  "WHERE filter_screen=:screen "
                  " AND filter_username=current_user "
                  " AND filter_selected=TRUE";

  if (this->parent())
  {
    metaobject = this->parent()->metaObject();
    classname = metaobject->className();
    qry.prepare(query);
    qry.bindValue(":screen", classname);

    qry.exec();

    if (qry.first())
    {
      filter_id = qry.value("filter_id").toInt();
      filter_name = qry.value("filter_name").toString();
      setSavedFiltersIndex(filter_name);
      applySaved(0, filter_id);
    }
    else
    {
      addParam();
    }

  }

}