void MyKGanttView::setScheduleManager( ScheduleManager *sm )
{
    clearDependencies();
    m_manager = sm;
    KGantt::DateTimeGrid *g = static_cast<KGantt::DateTimeGrid*>( grid() );
    if ( sm && project() ) {
        QDateTime start = project()->startTime( sm->scheduleId() ).addDays( -1 );
        if ( g->startDateTime() !=  start ) {
            g->setStartDateTime( start );
        }
    }
    if ( ! g->startDateTime().isValid() ) {
        g->setStartDateTime( QDateTime::currentDateTime() );
    }
    model()->setScheduleManager( sm );
    createDependencies();
}
ModulePackage::ModulePackage(DnfSack * moduleSack, LibsolvRepo * repo,
    ModuleMetadata && metadata,  const std::string & repoID)
        : metadata(std::move(metadata))
        , moduleSack(moduleSack)
        , repoID(repoID)
{
    Pool * pool = dnf_sack_get_pool(moduleSack);
    id = repo_add_solvable(repo);
    Solvable *solvable = pool_id2solvable(pool, id);

    setSovable(pool, solvable, getName(), getStream(), getVersion(), getContext(), getArchCStr());
    createDependencies(solvable);
    HyRepo hyRepo = static_cast<HyRepo>(repo->appdata);
    libdnf::repoGetImpl(hyRepo)->needs_internalizing = 1;
    dnf_sack_set_provides_not_ready(moduleSack);
    dnf_sack_set_considered_to_update(moduleSack);
}
DependenciesSolvingResult ComponentInstaller::tryToInstall(const QStringList &componentNames)
{
    deleteComponents();

    // Add existed componens to resolve componens for install
    IComponentDependenciesPtr dependencies(createDependencies());
    for (IComponent *comp : m_existedComponents)
        dependencies->addComponent(comp);

    QList<IComponent *> discoveredComponents = discoverComponents();

    // Select components to install from the all discovered components
    QList<IComponent *> toInstall;
    for (IComponent *comp : discoveredComponents) {
        dependencies->addComponent(comp);
        if (componentNames.contains(comp->name()))
            toInstall.push_back(comp);
    }

    // Find all parents for components to install
    DependenciesSolvingResult result = dependencies->completeListWithChildren(toInstall);
    if (!result.orphans().isEmpty()) {
        qDeleteAll(toInstall);
        return result;
    }

    // Return only components that have to be installed
    for (IComponent *comp : result.ordered()) {
        if (toInstall.contains(comp))
            continue;

        if (discoveredComponents.contains(comp))
            toInstall.push_back(comp);
    }

    // Delete unused components
    for (IComponent *comp : discoveredComponents) {
        if (!toInstall.contains(comp))
            delete comp;
    }

    m_componentsToInstall = toInstall;

    return DependenciesSolvingResult(m_componentsToInstall);
}
void MyKGanttView::setProject( Project *proj )
{
    clearDependencies();
    if ( project() ) {
        disconnect( project(), SIGNAL(relationToBeModified(Relation*)), this, SLOT(removeDependency(Relation*)));
        disconnect( project(), SIGNAL(relationModified(Relation*)), this, SLOT(addDependency(Relation*)));
        disconnect( project(), SIGNAL(relationAdded(Relation*)), this, SLOT(addDependency(Relation*)) );
        disconnect( project(), SIGNAL(relationToBeRemoved(Relation*)), this, SLOT(removeDependency(Relation*)) );
        disconnect( project(), SIGNAL(projectCalculated(ScheduleManager*)), this, SLOT(slotProjectCalculated(ScheduleManager*)) );
    }
    NodeGanttViewBase::setProject( proj );
    if ( proj ) {
        connect( project(), SIGNAL(relationToBeModified(Relation*)), this, SLOT(removeDependency(Relation*)));
        connect( project(), SIGNAL(relationModified(Relation*)), this, SLOT(addDependency(Relation*)));
        connect( proj, SIGNAL(relationAdded(Relation*)), this, SLOT(addDependency(Relation*)) );
        connect( proj, SIGNAL(relationToBeRemoved(Relation*)), this, SLOT(removeDependency(Relation*)) );
        connect( proj, SIGNAL(projectCalculated(ScheduleManager*)), this, SLOT(slotProjectCalculated(ScheduleManager*)) );
    }

    createDependencies();
}