Logo Search packages:      
Sourcecode: facturalux version File versions  Download package

void FLTableDB::refresh (  )  [slot]

Actualiza el conjunto de registros.

Se le puede pasar una cadena con la que filtran los registros de la tabla, solo aquellos que cumplan el filtrado serán mostrados.

Definition at line 129 of file FLTableDB.cpp.

References FLFieldMetaData::alias(), columnsWidths, cursor_, FLTableMetaData::field(), filter, FLSqlCursor::metadata(), FLTableMetaData::name(), FLSqlCursor::seek(), sortField_, tableName_, tableRecords, and FLFieldMetaData::visible().

Referenced by disconnectSignalSlots(), filterRecords(), initCursor(), putFirstCol(), and show().

{ 
  if (!tableRecords || !lineEditSearch || !comboBoxFieldToSearch || !cursor_)
      return;

  FLTableMetaData *tMD = cursor_->metadata ();

  if (!tMD)
      return;

  if (tableName_.isEmpty ())
       tableName_ = cursor_->metadata()->name();

  int pos = cursor_->at ();

  QString filterOrig = cursor_->filter ();

  if (filter.isEmpty ())
      tableRecords->setFilter (filterOrig);
  else
      {
        if (filterOrig.isEmpty ())
            tableRecords->setFilter (filter);
         else
              tableRecords->setFilter (filterOrig + " AND " + filter);
      }

  if (!columnsWidths.isEmpty())
    {
        int i=0;
        for (QStringList::Iterator it = columnsWidths.begin (); it != columnsWidths.end (); ++it, i++)
            tableRecords->setColumnWidth( i , ( *it ).toInt() );
    }

  tableRecords->refresh (QDataTable::RefreshAll);

  QHeader *horizHeader = tableRecords->horizontalHeader ();
    
  QStringList s = QStringList () << horizHeader->label (0);
  tableRecords->setSort (s);
    
  FLFieldMetaData * field;
  horizHeader->hide();
  for (int i = 0; i < tableRecords->numCols (); i++)
      {
           field = tMD->field(horizHeader->label (i));
           if (!field)
                continue;
           if (i==0)
            sortField_ = field;
          if (!field->visible())
            {
                horizHeader->removeLabel(i);
                tableRecords->removeColumn(i);
                continue;
            }
          if (comboBoxFieldToSearch->count()==i)
            comboBoxFieldToSearch->insertItem (field->alias());
         horizHeader->setLabel (i, field->alias());
      }
  horizHeader->show();    
  tableRecords->refresh ();
  
  if (pos < 0)
    {
       pos = 0;
        tableRecords->setCurrentCell(0,0);
     }
  if (pos > tableRecords->numRows ())
      pos = tableRecords->numRows () - 1;
  cursor_->setFilter (filterOrig);
  cursor_->seek (pos);
  if (cursor_->size()==1)
    tableRecords->setCurrentCell(0,0);
}


Generated by  Doxygen 1.6.0   Back to index