Ejemplo n.º 1
0
void CustomCheckListItem::stateChange( bool on )
{
    if ( !m_locked ) {
        for ( Q3CheckListItem * it = static_cast<Q3CheckListItem*>( firstChild() ); it; it = static_cast<Q3CheckListItem*>( it->nextSibling() ) ) {
            it->setOn( on );
        }
    }

    if ( !on ) {
        Q3ListViewItem * parent = this->parent();
        if ( parent && ( parent->rtti() == 1 ) ) {
            CustomCheckListItem * item = static_cast<CustomCheckListItem*>( parent );
            item->setLocked( true );
            item->setOn( on );
            item->setLocked( false );
        }
    }

    QString thisText = text(0);
    Q3ListViewItemIterator it( listView() );
    while ( it.current() ) {
        if ( it.current()->rtti() == 1 && it.current()->text(0) == thisText ) {
            CustomCheckListItem * item = static_cast<CustomCheckListItem*>( it.current() );
            item->setOn( on );
        }
        ++it;
    }
}
Ejemplo n.º 2
0
void IngredientCheckListView::load( int limit, int offset )
{
	IngredientListView::load(limit,offset);

	for ( QList<Element>::const_iterator ing_it = m_selections.constBegin(); ing_it != m_selections.constEnd(); ++ing_it ) {
		Q3CheckListItem * item = ( Q3CheckListItem* ) findItem( QString::number( (*ing_it).id ), 1 );
		if ( item ) {
			item->setOn(true);
		}
	}
}
Ejemplo n.º 3
0
bool DatabaseDialog::tablesDoNext()
{
  m_databaseStatus->setText( i18n("Retrieving meta data of tables...") );
  QStringList tables;

  {
    Q3ListViewItem * item = (Q3CheckListItem *) m_tableView->firstChild();
    for (; item; item = item->nextSibling())
    {
      if (((Q3CheckListItem * ) item)->isOn())
      {
        tables.append(((Q3CheckListItem * ) item)->text());
      }
    }
  }

  if (tables.empty())
  {
    KMessageBox::error( this, i18n("You have to select at least one table.") );
    return false;
  }

  m_columnView->clear();
  QSqlRecord info;
  for (int i = 0; i < (int) tables.size(); ++i)
  {
    info = m_dbConnection.record( tables[i] );
    for (int j = 0; j < (int) info.count(); ++j)
    {
      QString name = info.fieldName(j);
      Q3CheckListItem * checkItem = new Q3CheckListItem( m_columnView, name,
                                 Q3CheckListItem::CheckBox );
      checkItem->setOn(false);
      m_columnView->insertItem( checkItem );
      checkItem->setText( 1, tables[i] );
      QSqlField field = info.field(name);
      checkItem->setText( 2, QVariant::typeToName(field.type()) );
    }
  }
  m_columnView->setSorting(1, true);
  m_columnView->sort();
  m_columnView->setSorting( -1 );

  setValid(m_columns, true);

  return true;
}
Ejemplo n.º 4
0
bool DatabaseDialog::databaseDoNext()
{
  m_dbConnection = QSqlDatabase::addDatabase( m_driver->currentText() );

  if ( m_dbConnection.isValid() )
  {
    m_dbConnection.setDatabaseName( m_databaseName->text() );
    m_dbConnection.setHostName( m_host->text() );

    if ( !m_username->text().isEmpty() )
      m_dbConnection.setUserName( m_username->text() );

    if ( !m_password->text().isEmpty() )
      m_dbConnection.setPassword( m_password->text() );

    if ( !m_port->text().isEmpty() )
    {
      bool ok = false;
      int port = m_port->text().toInt( &ok );
      if (!ok)
      {
        KMessageBox::error( this, i18n("The port must be a number") );
        return false;
      }
      m_dbConnection.setPort( port );
    }

    m_databaseStatus->setText( i18n("Connecting to database...") );
    if ( m_dbConnection.open() )
    {
      m_databaseStatus->setText( i18n("Connected. Retrieving table information...") );
      QStringList tableList( m_dbConnection.tables() );

      if ( tableList.isEmpty() )
      {
        KMessageBox::error( this, i18n("This database contains no tables") );
        m_databaseStatus->setText( " " );
        return false;
      }

      m_tableView->clear();

      for ( int i = 0; i < tableList.size(); ++i )
      {
        Q3CheckListItem * item = new Q3CheckListItem( m_tableView, tableList[i],
                                                    Q3CheckListItem::CheckBox );
        item->setOn(false);
        m_tableView->insertItem( item );
      }

      m_tableView->setEnabled( true );
      m_databaseStatus->setText( " " );
    }
    else
    {
      QSqlError error = m_dbConnection.lastError();
      QString errorMsg;
      QString err1 = error.driverText();
      QString err2 = error.databaseText();
      if ( !err1.isEmpty() )
      {
        errorMsg.append( error.driverText() );
        errorMsg.append( '\n' );
      }
      if ( !err2.isEmpty() && err1 != err2)
      {
        errorMsg.append( error.databaseText() );
        errorMsg.append( '\n' );
      }

      KMessageBox::error( this, errorMsg );
      m_databaseStatus->setText( " " );
      return false;
    }
  }
  else
  {
    KMessageBox::error( this, i18n("Driver could not be loaded") );
    m_databaseStatus->setText( " " );
    return false;
  }
  setValid(m_table, true);

  return true;
}