Beispiel #1
0
void KEndingBalanceDlg::createCategory(const QString& txt, QString& id, const MyMoneyAccount& parent)
{
  MyMoneyAccount acc;
  acc.setName(txt);

  emit createCategory(acc, parent);

  id = acc.id();
}
Beispiel #2
0
/*
The function checks if the name of an aliment contains the given string. If the name contains it, we go in the list of categories
check if the category of the aliment that contains the string is already in the category list. Yes-We increase the quantity of that
category .No-we add it to the list.
Input:The list of aliments,the list of categories, the given string
Output:The categories list,modified
*/
void checkString(FoodRepoDynamic* v,solRepoDynamic* s,char solution[]){
    int i=0,k=0,ok;
    for (i=0;i<v->length;i++){
        k=0,ok=0;
        if (strstr(v->foodstuff[i].category,solution)>0){
            addSol(s,createCategory(v->foodstuff[i].category,v->foodstuff[i].quantity));
            //printf("%49s",s->solstuff[k].categorySol);
           // printf("%lf",s->solstuff[k].quantitySol);
            k++;
        }
    }
    sortAsc(s);
}
Beispiel #3
0
void KSplitTransactionDlg::slotCreateCategory(const QString& name, QString& id)
{
    MyMoneyAccount acc, parent;
    acc.setName(name);

    if (m_isDeposit)
        parent = MyMoneyFile::instance()->income();
    else
        parent = MyMoneyFile::instance()->expense();

    // TODO extract possible first part of a hierarchy and check if it is one
    // of our top categories. If so, remove it and select the parent
    // according to this information.

    emit createCategory(acc, parent);

    // return id
    id = acc.id();
}
Beispiel #4
0
//-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~
void
PropertiesView::onAddProperty(I_PropertiesPublisher& _publisher, I_Property& _property)
{
    // Get the handle associated with this publisher.
    PropertiesHandle* const pHandle = m_propertiesMap[&_publisher];

    // TODO Fix:  pHandle is sometimes NULL.  Why?

    // The name is a concatenation of the property set name and the property name.
    std::stringstream name;
    name << pHandle->getPublisher().getPropertiesName();

    // Get the parent category
    // Use pParent now.
    //wxPropertyCategory* const pCategory = pHandle->getCategory();

    if (_property.getParent() != NULL)
    {
        // Append the parent name.  This gives us the fully qualified
        // parent name.
        name << "\\" << _property.getParent()->getFullName();
    }

    // Get the parent by name.
    wxPGProperty* pParent = m_pPropertyGrid->GetPropertyByName(std2wx(name.str()));

    // Make sure the parent is not NULL.  It should at least return the
    // top category.
    assert(pParent != NULL);

    // Now create the child name.
    name << "\\" << _property.getName();

    wxPGProperty* pChild = NULL;

    switch(_property.getType())
    {
    case I_Property::STRING_TYPE:
        // The first parameter is the label which is shown on the screen.
        // The second parameter is the label, which is the unqiue identifier of the property.
        pChild = new wxStringProperty(std2wx(_property.getName()), std2wx(name.str()), std2wx(_property.getValue()));
        break;
    case I_Property::ENUM_TYPE:
        pChild = createEnum(_property, name.str());
        break;
    case I_Property::CATEGORY_TYPE:
        pChild = createCategory(_property, name.str());
        break;
    default:
        throw Zen::Utility::runtime_exception("Error, invalid property type.");
    }

    pChild->SetClientData(&_property);
    pParent->AppendChild(pChild);

    // Assume a string value type for now.

    // TEST See how to get the property (name or label)
    wxPGProperty* pByName = m_pPropertyGrid->GetPropertyByName(std2wx(name.str()));
#if 0
    m_pPropertyGrid->Insert(pCategory,
        new wxStringProperty(_property.getName(), name.str(), _property.getValue()));
#endif
}
Beispiel #5
0
void SofaLibrary::build( const std::vector< std::string >& examples)
{
    exampleFiles=examples;
    //-----------------------------------------------------------------------
    //Read the content of the Object Factory
    //-----------------------------------------------------------------------
    std::vector< ClassEntry* > entries;
    sofa::core::ObjectFactory::getInstance()->getAllEntries(entries);
    //Set of categories found in the Object Factory
    std::set< std::string > mainCategories;
    //Data containing all the entries for a given category
    std::multimap< std::string, ClassEntry* > inventory;

    for (std::size_t i=0; i<entries.size(); ++i)
    {
#ifdef      TEST_CREATION_COMPONENT
        {
            sofa::core::objectmodel::BaseObject::SPtr object;
            std::cerr << "Creating " << entries[i]->className << std::endl;
            if (entries[i]->creatorMap.find(entries[i]->defaultTemplate) != entries[i]->creatorMap.end())
            {
                object = entries[i]->creatorMap.find(entries[i]->defaultTemplate)->second->createInstance(NULL, NULL);
            }
            else
            {
                object = entries[i]->creatorList.begin()->second->createInstance(NULL, NULL);
            }
            std::cerr << "Deleting " << entries[i]->className << std::endl;
            object.reset();
            std::cerr << "Ok for " << entries[i]->className << std::endl;
        }
#endif

        //Insert Template specification
        std::set< std::string >::iterator it;
        for (it = entries[i]->baseClasses.begin(); it != entries[i]->baseClasses.end(); ++it)
        {
            mainCategories.insert((*it));
            inventory.insert(std::make_pair((*it), entries[i]));
        }
        //If no inheritance was found for the given component, we store it in a default category
        if (entries[i]->baseClasses.empty())
        {
            mainCategories.insert("_Miscellaneous");
            inventory.insert(std::make_pair("_Miscellaneous", entries[i]));
        }
    }

    //-----------------------------------------------------------------------
    //Using the inventory, Add each component to the Sofa Library
    //-----------------------------------------------------------------------
    std::set< std::string >::iterator itCategory;
    typedef std::multimap< std::string, ClassEntry* >::iterator IteratorInventory;


    //We add the components category by category
    for (itCategory = mainCategories.begin(); itCategory != mainCategories.end(); ++itCategory)
    {
        const std::string& categoryName = *itCategory;
        IteratorInventory itComponent;

        std::pair< IteratorInventory,IteratorInventory > rangeCategory;
        rangeCategory = inventory.equal_range(categoryName);



        const unsigned int numComponentInCategory = (unsigned int)inventory.count(categoryName);
        CategoryLibrary *category = createCategory(categoryName,numComponentInCategory);

        //Process all the component of the current category, and add them to the group
        for (itComponent=rangeCategory.first; itComponent != rangeCategory.second; ++itComponent)
        {
            ClassEntry *entry = itComponent->second;
            const std::string &componentName=entry->className;

            //Special Case of Mass Component: they are also considered as forcefield. We remove their occurence of the force field category group
            if (categoryName == "ForceField")
            {
                std::set< std::string >::iterator inheritanceClass;
                bool needToRemove=false;
                for (inheritanceClass = entry->baseClasses.begin(); inheritanceClass != entry->baseClasses.end(); ++inheritanceClass)
                {
                    if (*inheritanceClass == "Mass") { needToRemove=true; break;};
                }
                if (needToRemove) continue;
            }
            //Special Case of TopologyObject: they are also considered as Topology. We remove their occurence of the topology category group
            else if (categoryName == "Topology")
            {
                std::set< std::string >::iterator inheritanceClass;
                bool needToRemove=false;
                for (inheritanceClass = entry->baseClasses.begin(); inheritanceClass != entry->baseClasses.end(); ++inheritanceClass)
                {
                    if (*inheritanceClass == "TopologyObject") { needToRemove=true; break;};
                }
                if (needToRemove) continue;
            }

            //Add the component to the category
            category->addComponent(componentName, entry, exampleFiles);
        }
        category->endConstruction();
        addCategory(category);
    }
    computeNumComponents();
}
Beispiel #6
0
 virtual void run(Arg)
 {
     createCategory();
     containmentQuery();
     ordering();
 }
Beispiel #7
0
sol getCategoryOnPos(solRepoDynamic* s,int pos){
    if (pos<0 || pos>=s->lengthSol)
        return createCategory("",-1);
    return s->solstuff[pos];
}
Beispiel #8
0
void KEndingBalanceDlg::slotCreateChargesCategory(const QString& txt, QString& id)
{
  createCategory(txt, id, MyMoneyFile::instance()->expense());
}
Beispiel #9
0
void KEndingBalanceDlg::slotCreateInterestCategory(const QString& txt, QString& id)
{
  createCategory(txt, id, MyMoneyFile::instance()->income());
}