Beispiel #1
0
static void addEnableActions(CJobRunner::ItemList &urls)
{
    CJobRunner::ItemList                modified;
    CJobRunner::ItemList::ConstIterator it(urls.constBegin()),
                                        end(urls.constEnd());
                            
    for(; it!=end; ++it)
    {
        if((*it).isDisabled)
        {
            CJobRunner::Item item(*it);
            item.fileName=QLatin1String("--");
            modified.append(item);
        }
        modified.append(*it);
    }
    
    urls=modified;
}
CJobRunner::ItemList CFontFileListView::getMarkedItems()
{
    QTreeWidgetItem      *root=invisibleRootItem();
    CJobRunner::ItemList items;
    QString              home(Misc::dirSyntax(QDir::homePath()));

    for(int t=0; t<root->childCount(); ++t)
    {
        QList<QTreeWidgetItem *> removeFiles;
        StyleItem                *style=(StyleItem *)root->child(t);

        for(int c=0; c<style->childCount(); ++c)
        {
            QTreeWidgetItem *file=style->child(c);

            if(isMarked(file))
                items.append(CJobRunner::Item(file->text(0), style->family(), style->value(), 0!=file->text(0).indexOf(home)));
        }
    }

    return items;
}
Beispiel #3
0
int CInstaller::install(const QSet<KUrl> &urls)
{
    QSet<KUrl>::ConstIterator it(urls.begin()),
                              end(urls.end());
    bool                      sysInstall(false);
    CJobRunner *jobRunner=new CJobRunner(itsParent);

    CJobRunner::startDbusService();

    if(!Misc::root())
    {
        switch(KMessageBox::questionYesNoCancel(itsParent,
                                       i18n("Do you wish to install the font(s) for personal use "
                                            "(only available to you), or "
                                            "system-wide (available to all users)?"),
                                       i18n("Where to Install"), KGuiItem(i18n(KFI_KIO_FONTS_USER)),
                                       KGuiItem(i18n(KFI_KIO_FONTS_SYS))))
        {
            case KMessageBox::No:
                sysInstall=true;
                break;
            case KMessageBox::Cancel:
                return -1;
            default:
                break;
        }
    }

    QSet<KUrl> instUrls;

    for(; it!=end; ++it)
    {
        KUrl local(KIO::NetAccess::mostLocalUrl(*it, NULL));
        bool package(false);

        if(local.isLocalFile())
        {
            QString localFile(local.toLocalFile());

            if(Misc::isPackage(localFile))
            {
                instUrls+=FontsPackage::extract(localFile, &itsTempDir);
                package=true;
            }
        }
        if(!package)
        {
            KUrl::List associatedUrls;

            CJobRunner::getAssociatedUrls(*it, associatedUrls, false, itsParent);
            instUrls.insert(*it);

            KUrl::List::Iterator aIt(associatedUrls.begin()),
                                 aEnd(associatedUrls.end());

            for(; aIt!=aEnd; ++aIt)
                instUrls.insert(*aIt);
        }
    }

    if(instUrls.count())
    {
        CJobRunner::ItemList      list;
        QSet<KUrl>::ConstIterator it(instUrls.begin()),
                                  end(instUrls.end());

        for(; it!=end; ++it)
            list.append(*it);

        return jobRunner->exec(CJobRunner::CMD_INSTALL, list, Misc::root() || sysInstall);
    }
    else
        return -1;
}