void SelectionDialog:: addResourceType( QString type ) { // Add the new constraint to the list; value is "any", and no // relatives are included by default. First, look up all the // resource ids for this type. QString resources; ConstraintListItem * item = new ConstraintListItem( constraintListView, "N", type, "ANY", "---", type, resources ); // Don't let user set the value in RelCol (types of relatives to get) // The purpose of a resource-type-only entry is to limit the search to // include entries at a specific level, and searching for all // relatives of all resources of a given type (as we do for other // constraints) would be expensive. item->setRenameEnabled( RelCol, false ); // Put all resources of this type in the database's temporary table // The blank value string means "find all values" dataSource->beginAdd(); int results = dataSource->addResourcesByName( type, QString() ); if( results < 0 ) { dataSource->cancelAdd(); delete item; } else { setCounts( item, results ); dataSource->endAdd(); } }
HistogramBinDistribution::HistogramBinDistribution(std::vector<double> abscissas, std::vector<double> counts) : UncertaintyDescription(boost::shared_ptr<detail::UncertaintyDescription_Impl>( new detail::UncertaintyDescription_Impl(HistogramBinDistribution::type()))) { setAbscissas(abscissas); setCounts(counts); }
void DesuraJSBinding::updateCounts(int32 msg, int32 updates, int32 threads, int32 cart) { auto userCore = GetUserCore(); if (userCore) userCore->setCounts(msg, updates, threads, cart); }
void SelectionDialog:: addConstraint( QString type, QString value, QString resources, QString resourceType ) { // Before we add an item, make sure it's not a duplicate // of an exisiting item, since that's not useful and hard // to recover from later. Q3ListViewItemIterator it( constraintListView ); while( it.current() ) { ConstraintListItem * item = (ConstraintListItem *)it.current(); if( item->text( ValueCol ) == value && item->resourceType() == resourceType ) { // Show the duplicate by selecting it constraintListView->setSelected( item, true ); return; } ++it; } // Add the new constraint to the list ConstraintListItem * item = new ConstraintListItem( constraintListView, "D", type, value, "---", resourceType, resources ); // Allow user to set the value in RelCol (types of relatives to get) item->setRenameEnabled( RelCol, true ); // Put resources in the db list according to the specifications in // this item. dataSource->beginAdd(); int results = addItemRelatives( item, Self | FromItem ); // Check for success; rollback and remove item if there was an error if( results < 0 ) { dataSource->cancelAdd(); delete item; } else { dataSource->endAdd(); setCounts( item, results ); } }
void SelectionDialog:: setRelatives( Q3ListViewItem * item, int col ) { // Sanity check; the only column that should have been changed // is the Relatives List if( col != RelCol ) return; // Cast to the right type ConstraintListItem * it = (ConstraintListItem*) item; // Make the following changes atomically dataSource->beginAdd(); // We don't know the what relatives were included previously, // so we'll delete any ancestors and descendants and then // add whatever was requested. deleteItemRelatives( it, Both ); // Get the count for the remaining resources (no relatives) in this item int results = dataSource->getResultCount( 1, QString(),labelList() ); if( results < 0 ) { dataSource->cancelAdd(); return; } // Now add back the items as specfied in the RelCol int count = addItemRelatives( it, FromItem ); // Be sure the changes succeeded if( count < 0 ) { dataSource->cancelAdd(); return; } // Update OK; commit it and count the results dataSource->endAdd(); results += count; // Update the item count for this item and the whole set setCounts( it, results ); }