Exemplo 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;
    }
}
KLProjectConfigWidget::KLProjectConfigWidget(KLProject* project, QWidget *parent, const char *name)
    :QDialog(parent, name), m_validator(QRegExp("0x[0-9a-fA-F]{1,4}"), this, "reValidator"),
      ui(new Ui_KLProjectConfigWidgetBase)
{
    ui->setupUi(this);
    m_project = project;
    m_projectManagerInConfigWidget =
            new KLProjectManagerWidget( project, ui->tab_common, "managerInConfig" );
    m_projectManagerInConfigWidget->setConfigButtonVisible( false );
    ui->layProjectManager->addWidget( m_projectManagerInConfigWidget );
    ui->cbCPU->clear();
    // Add all the CPUs:
    ui->cbCPU->insertStringList( project->cpus() );
    // Update the project files list:
    project->update();
    // Add linker flags columns
    ui->lvLinkerFlags->addColumn(i18n("Purpose"));
    ui->lvLinkerFlags->addColumn(i18n("Flags"));
    // Fill the linker flags list:
    m_possibleLinkerFlags["-Wl,-lm"] = i18n("Link with math library");
    m_possibleLinkerFlags["-Wl,-lprintf"] = i18n("Link with printf library");
    m_possibleLinkerFlags["-Wl,-lprintf_min"] = i18n("Link with printf_min library");
    m_possibleLinkerFlags["-Wl,-u,vfprintf -Wl,-lprintf_flt"] = i18n("Link with floating point printf library");
    QStringList keys = m_possibleLinkerFlags.keys();
    keys.sort();

    for ( QStringList::iterator it = keys.begin(); it != keys.end(); ++it )
    {
        Q3CheckListItem* cur = new Q3CheckListItem( ui->lvLinkerFlags, m_possibleLinkerFlags[*it], Q3CheckListItem::CheckBox );
        cur->setText( 1, *it );
        m_linkerFlagsCBs.append( cur );
    }
    updateGUIFromSettings();
    updateCPUInfo( ui->cbCPU->currentText() );

    connect(ui->cbCPU,SIGNAL(currentIndexChanged(QString)),this,SLOT(slotCPUChanged(QString)));
    connect(ui->pbOK,SIGNAL(clicked()),this,SLOT(slotOK()));
    connect(ui->pbCancel,SIGNAL(clicked()),this,SLOT(slotCancel()));
    connect(ui->pbSetDefault,SIGNAL(clicked()),this,SLOT(slotSetDefault()));

    //Setup spinboxes with hex-in and output
    ui->kisbStartOfText->setValidator(&m_validator);
    ui->kisbStartOfText->setBase(16);

    ui->kisbStartOfData->setValidator(&m_validator);
    ui->kisbStartOfData->setBase(16);

    ui->kisbStartOfBSS->setValidator(&m_validator);
    ui->kisbStartOfBSS->setBase(16);

    ui->kisbStartOfHeap->setValidator(&m_validator);
    ui->kisbStartOfHeap->setBase(16);

    ui->kisbEndOfHeap->setValidator(&m_validator);
    ui->kisbEndOfHeap->setBase(16);
}
void DisplayFlagWidget::findChildren(Q3CheckListItem *item, std::vector<Q3CheckListItem* > &children)
{
    Q3CheckListItem * child = (Q3CheckListItem * )item->firstChild();
    while(child)
    {
        children.push_back(child);
        findChildren(child,children);
        child = (Q3CheckListItem * )child->nextSibling();
    }
}
Exemplo n.º 4
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);
		}
	}
}
Exemplo n.º 5
0
void KDMUsersWidget::updateOptList( Q3ListViewItem *item, QStringList &list )
{
	if (!item)
		return;
	Q3CheckListItem *itm = (Q3CheckListItem *)item;
	int ind = list.indexOf( itm->text() );
	if (itm->isOn()) {
		if (ind < 0)
			list.append( itm->text() );
	} else {
		if (ind >= 0)
			list.removeAt( ind );
	}
}
Exemplo n.º 6
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;
}
DisplayFlagWidget::DisplayFlagWidget(QWidget* parent, const char* name,  Qt::WFlags f ):
    Q3ListView(parent,name,f)
{
    addColumn(QString::null);
    setRootIsDecorated( TRUE );
    setTreeStepSize( 12 );
    header()->hide();
    clear();

    setMouseTracking(false);

#ifdef SOFA_QT4
    setFocusPolicy(Qt::NoFocus);
#else
    setFocusPolicy(QWidget::NoFocus);
#endif

    setFrameShadow(QFrame::Plain);
    setFrameShape(QFrame::NoFrame );

    setSortColumn(-1);
    Q3CheckListItem* itemShowAll = new Q3CheckListItem(this, "All", Q3CheckListItem::CheckBoxController);
    itemShowAll->setOpen(true);
    Q3CheckListItem* itemShowVisual    = new Q3CheckListItem(itemShowAll, "Visual", Q3CheckListItem::CheckBoxController);
    itemShowVisual->setOpen(true);
    itemShowFlag[VISUALMODELS]   = new Q3CheckListItem(itemShowVisual, "Visual Models", Q3CheckListItem::CheckBox);
    Q3CheckListItem* itemShowBehavior  = new Q3CheckListItem(itemShowAll, itemShowVisual, "Behavior", Q3CheckListItem::CheckBoxController);
    itemShowBehavior->setOpen(true);
    itemShowFlag[BEHAVIORMODELS]   = new Q3CheckListItem(itemShowBehavior,  "Behavior Models", Q3CheckListItem::CheckBox);
    itemShowFlag[FORCEFIELDS]   = new Q3CheckListItem(itemShowBehavior, itemShowFlag[BEHAVIORMODELS], "Force Fields", Q3CheckListItem::CheckBox);
    itemShowFlag[INTERACTIONFORCEFIELDS]   = new Q3CheckListItem(itemShowBehavior, itemShowFlag[FORCEFIELDS],  "Interactions", Q3CheckListItem::CheckBox);
    Q3CheckListItem* itemShowCollision = new Q3CheckListItem(itemShowAll, itemShowBehavior, "Collision", Q3CheckListItem::CheckBoxController);
    itemShowCollision->setOpen(true);
    itemShowFlag[COLLISIONMODELS]   = new Q3CheckListItem(itemShowCollision,  "Collision Models", Q3CheckListItem::CheckBox);
    itemShowFlag[BOUNDINGCOLLISIONMODELS]   = new Q3CheckListItem(itemShowCollision, itemShowFlag[COLLISIONMODELS], "Bounding Trees", Q3CheckListItem::CheckBox);
    Q3CheckListItem* itemShowMapping   = new Q3CheckListItem(itemShowAll, itemShowCollision, "Mapping", Q3CheckListItem::CheckBoxController);
    itemShowMapping->setOpen(true);
    itemShowFlag[MAPPINGS]   = new Q3CheckListItem(itemShowMapping,  "Visual Mappings", Q3CheckListItem::CheckBox);
    itemShowFlag[MECHANICALMAPPINGS]   = new Q3CheckListItem(itemShowMapping, itemShowFlag[MAPPINGS],  "Mechanical Mappings", Q3CheckListItem::CheckBox);
    Q3ListViewItem*  itemShowOptions   = new Q3ListViewItem(this, itemShowAll, "Options");
    itemShowOptions->setOpen(true);
    itemShowFlag[RENDERING]   = new Q3CheckListItem(itemShowOptions, "Advanced Rendering", Q3CheckListItem::CheckBox);
    itemShowFlag[WIREFRAME]   = new Q3CheckListItem(itemShowOptions, "Wire Frame", Q3CheckListItem::CheckBox);
    itemShowFlag[NORMALS]   = new Q3CheckListItem(itemShowOptions, itemShowFlag[WIREFRAME], "Normals", Q3CheckListItem::CheckBox);

#ifdef SOFA_SMP
    itemShowFlag[PROCESSORCOLOR]   = new Q3CheckListItem(itemShowOptions, itemShowFlag[NORMALS], "Processor Color", Q3CheckListItem::CheckBox);
#endif
    insertItem(itemShowAll);
    itemShowAll->insertItem(itemShowVisual); itemShowAll->setOpen(true);
    itemShowVisual->insertItem(itemShowFlag[VISUALMODELS]);
    itemShowAll->insertItem(itemShowBehavior);
    itemShowBehavior->insertItem(itemShowFlag[BEHAVIORMODELS]);
    itemShowBehavior->insertItem(itemShowFlag[FORCEFIELDS]);
    itemShowBehavior->insertItem(itemShowFlag[INTERACTIONFORCEFIELDS]);
    itemShowAll->insertItem(itemShowCollision);
    itemShowCollision->insertItem(itemShowFlag[COLLISIONMODELS]);
    itemShowCollision->insertItem(itemShowFlag[BOUNDINGCOLLISIONMODELS]);
    itemShowAll->insertItem(itemShowMapping);
    itemShowMapping->insertItem(itemShowFlag[MAPPINGS]);
    itemShowMapping->insertItem(itemShowFlag[MECHANICALMAPPINGS]);

    insertItem(itemShowOptions); itemShowOptions->setOpen(true);
    itemShowOptions->insertItem(itemShowFlag[RENDERING]);
    itemShowOptions->insertItem(itemShowFlag[WIREFRAME]);
    itemShowOptions->insertItem(itemShowFlag[NORMALS]);
#ifdef SOFA_SMP
    itemShowOptions->insertItem(itemShowFlag[PROCESSORCOLOR]);
#endif
    for (int i=0; i<ALLFLAGS; ++i)  mapFlag.insert(std::make_pair(itemShowFlag[i],i));
}
Exemplo n.º 8
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;
}
Exemplo n.º 9
0
void RecipeImportDialog::loadListView()
{
    CustomCheckListItem * head_item = new CustomCheckListItem( kListView, i18nc( "@item:inlistbox All items", "All (%1)", list_copy.count() ), Q3CheckListItem::CheckBox );
    head_item->setOpen( true );

    //get all categories
    QStringList categoryList;

    RecipeList::const_iterator recipe_it;
    for ( recipe_it = list_copy.begin(); recipe_it != list_copy.end(); ++recipe_it ) {
        for ( ElementList::const_iterator cat_it = ( *recipe_it ).categoryList.begin(); cat_it != ( *recipe_it ).categoryList.end(); ++cat_it ) {
            if ( categoryList.contains( ( *cat_it ).name ) == false )
                categoryList << ( *cat_it ).name;
        }
    }

    //create all category check list items
    Q3Dict<CustomCheckListItem> all_categories;

    QStringList::iterator it;
    for ( it = categoryList.begin(); it != categoryList.end(); ++it ) {
        CustomCheckListItem *category_item = new CustomCheckListItem( head_item, *it, Q3CheckListItem::CheckBox );
        //category_item->setOpen(true);

        all_categories.insert( *it, category_item );
    }

    //add recipes to category check list items
    recipe_items = new QMap<CustomCheckListItem*, RecipeList::const_iterator>; //we won't be able to identify a recipe later if we  just put a value in here. The iterator will be unique so we'll use it.  This is safe since the list is constant (iterators won't become invlalid).

    CustomCheckListItem *item = 0;
    CustomCheckListItem *category_item = 0;

    for ( recipe_it = list_copy.begin(); recipe_it != list_copy.end(); ++recipe_it ) {
        if ( ( *recipe_it ).categoryList.count() == 0 ) {
            if ( !category_item )  //don't create this until there are recipes to put in it
            {
                category_item = new CustomCheckListItem( head_item, i18nc( "@item", "Uncategorized" ), Q3CheckListItem::CheckBox );
                all_categories.insert( i18nc( "@item", "Uncategorized" ), category_item );
            }
            CustomCheckListItem *item = new CustomCheckListItem( category_item, ( *recipe_it ).title, Q3CheckListItem::CheckBox );
            recipe_items->insert( item, recipe_it );
        }
        else {
            for ( ElementList::const_iterator cat_it = ( *recipe_it ).categoryList.begin(); cat_it != ( *recipe_it ).categoryList.end(); ++cat_it ) {

                CustomCheckListItem *category_item = all_categories[ ( *cat_it ).name ];

                item = new CustomCheckListItem( category_item, item, ( *recipe_it ).title, Q3CheckListItem::CheckBox );
                recipe_items->insert( item, recipe_it );
            }
        }
    }

    //append the number of recipes in each category to the check list item text
    Q3DictIterator<CustomCheckListItem> categories_it( all_categories );
    for ( ; categories_it.current(); ++categories_it ) {
        int count = 0;
        for ( Q3CheckListItem * it = static_cast<Q3CheckListItem*>( categories_it.current() ->firstChild() ); it; it = static_cast<Q3CheckListItem*>( it->nextSibling() ) ) {
            count++;
        }
        categories_it.current() ->setText( 0, categories_it.current() ->text( 0 ) + QString( " (%1)" ).arg( count ) );
    }

    head_item->setOn( true ); //this will check all recipes
}