Ejemplo n.º 1
0
CategoriesPage::CategoriesPage(Nepomuk::WebExtractorConfig* cfg, QWidget * parent):
    QWidget(parent),
    m_config(cfg),
    m_categoryEdited(false)
{
    this->setupUi(this);
    this->query_edit_widget->hide();
    this->query_prefix_edit->hide();
    this->plugins_selector = new PluginSelector(this);
    this->verticalLayout->insertWidget(0, this->plugins_selector);
    m_oldDelegate = this->plugins_selector->selectedView()->itemDelegate();
    m_newDelegate = new CategoryPluginItemDelegate(this->plugins_selector->selectedView(), this);
    this->plugins_selector->selectedView()->setItemDelegate(m_newDelegate);
    //this->plugins_selector->selectedListWidget()->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    connect(this->query_edit, SIGNAL(textChanged()), this, SLOT(setCategoryChanged()));
    connect(this->query_prefix_edit, SIGNAL(textChanged()), this, SLOT(setCategoryChanged()));
    connect(this->interval_spinbox, SIGNAL(valueChanged(int)), this, SLOT(setCategoryChanged()));
    connect(this->plugins_selector, SIGNAL(added()), this, SLOT(setCategoryChanged()));
    connect(this->plugins_selector, SIGNAL(removed()), this, SLOT(setCategoryChanged()));
    connect(this->plugins_selector, SIGNAL(movedUp()), this, SLOT(setCategoryChanged()));
    connect(this->plugins_selector, SIGNAL(movedDown()), this, SLOT(setCategoryChanged()));
    connect(enabled_categories_listwidget, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)),
            SLOT(switchCategory(QListWidgetItem*, QListWidgetItem*)));

    connect(Nepomuk::CategoriesPool::self(), SIGNAL(categoriesChanged()),
            this, SLOT(reloadAvailableCategoriesList()));

    // Initialize machine
    m_machine = new QStateMachine();
    s1 = new QState();
    s2 = new QState();
    s3 = new QState();

    s1->addTransition(manageButton, SIGNAL(clicked()), s2);
    s2->addTransition(returnButton, SIGNAL(clicked()), s1);

    m_machine->addState(s1);
    m_machine->addState(s2);
    m_machine->setInitialState(s1);

    connect(s1, SIGNAL(entered()), this, SLOT(reloadEnabledCategoriesList()));
    connect(s2, SIGNAL(exited()), this, SLOT(syncEnabledCategoriesList()));
    s1->assignProperty(stackedWidget, "currentIndex", 0);
    s2->assignProperty(stackedWidget, "currentIndex", 1);

    // Initialize validator
    m_catvalidator = new CategoryNameValidator(this);

    // Inilialize buttons
    this->add_button->setGuiItem(KStandardGuiItem::add());
    this->add_button->setText(QString());
    this->remove_button->setGuiItem(KStandardGuiItem::remove());
    this->remove_button->setText(QString());
    connect(this->add_button, SIGNAL(clicked()), this, SLOT(addButton()));

    // no need to query endless numbers of results when we only want to create a query
    Nepomuk::Query::Query baseQuery;
    baseQuery.setLimit(10);
    queryBuilder->setBaseQuery(baseQuery);
}
Ejemplo n.º 2
0
void Dialog::search(const QString queryString)
{
    m_query = queryString;
    m_queryClient->close();
    m_fileQueryClient->close();
    m_lineEdit->setText(queryString);
    m_resultsView->clear();
    // searches emailAddress
    //QString name = "Marco Martin";
    kDebug() << queryString;
    //bool found = false;
    QUrl graphUri = QUrl();
    Nepomuk::Query::Query query;

    //Nepomuk::Query::OrTerm orTerm;
    //Nepomuk::Query::ResourceTypeTerm personTypeTerm(Vocabulary::NCO::PersonContact());
    //orTerm.addSubTerm(personTypeTerm);
/*
    Nepomuk::Query::AndTerm andTerm;
    Nepomuk::Query::ResourceTypeTerm personTypeTerm( Vocabulary::NCO::PersonContact() );
    andTerm.addSubTerm( personTypeTerm );

    const Nepomuk::Query::ComparisonTerm addrTerm( Vocabulary::NCO::emailAddress(),
            Nepomuk::Query::LiteralTerm( queryString ), Nepomuk::Query::ComparisonTerm::Contains );
    const Nepomuk::Query::ComparisonTerm mailTerm( Vocabulary::NCO::hasEmailAddress(), addrTerm );

    andTerm.addSubTerm( mailTerm );
    */
    kDebug() << "tagsearch?" << queryString << queryString.startsWith("hastag:", Qt::CaseInsensitive);
    Nepomuk::Query::FileQuery fileQuery;
    if (queryString.startsWith("hastag:", Qt::CaseInsensitive)) {
        QString tagName = queryString;
        tagName.remove("hastag:", Qt::CaseSensitive);
        kDebug() << "Searching tag" << tagName;
        //Nepomuk::Tag myTag = Nepomuk::Tag(tagName);
        QList<Nepomuk::Tag> allTags = Nepomuk::Tag::allTags();
        if (!allTags.count()) {
            return;
        }
        foreach (const Nepomuk::Tag &t, allTags) {

            if (QString::compare(tagName, t.genericLabel(), Qt::CaseInsensitive) == 0) {
                // term matching the tag
                kDebug() << "Found tag:" << t.genericLabel() << t.uri();
                Nepomuk::Query::ResourceTerm tagTerm( t );

                // term matching tagged resource
                Nepomuk::Query::ComparisonTerm term( Soprano::Vocabulary::NAO::hasTag(),
                                                    tagTerm,
                                                    Nepomuk::Query::ComparisonTerm::Equal );
                fileQuery.setTerm(term);
                query.setTerm(term);
                continue;
            }
        }

    } else {
Ejemplo n.º 3
0
void moviemanager::fetchAllMovieList(KListWidget* mainMovieList)
{
    qDebug() << "fetch All Movie List";
    Nepomuk::Query::Term term =  Nepomuk::Query::ResourceTypeTerm( Nepomuk::Vocabulary::NFO::Video());
    Nepomuk::Query::Query currentQuery;
    currentQuery.setTerm(term);
    QList<Nepomuk::Query::Result> results = Nepomuk::Query::QueryServiceClient::syncQuery( currentQuery );

    Q_FOREACH( const Nepomuk::Query::Result& result,results)
    {
        //An if condition should be added here...
        //If the synopsis propoery is not set, then create a qdownloader object
        //and send the data to fetch from imdb
        //and then let that function add the movie to the list
        if(result.resource().property(Nepomuk::Vocabulary::NFO::fileName()).toString().contains(".avi") == true)   //allowing only .avi files
        {
            qDebug() << "yes, .avi file!";
            if(result.resource().property(Nepomuk::Vocabulary::NMM::synopsis()).toString().contains("tt") == true)     //checking for synopsis
            {
                //only .avi and
                //data already present, so adding to the list
                qDebug() << "yes, contains synopsis";

                //very rarely if title does not exists
                if(result.resource().property(Nepomuk::Vocabulary::NIE::title()).toString().isEmpty() == true)
                {
                    //Title does not exists
                    qDebug() << "title does not exist, so showing file names";
                    mainMovieList->addItem(new QListWidgetItem(result.resource().property(Nepomuk::Vocabulary::NFO::fileName()).toString().remove(".avi")));
                }
                else
                {
                    //Title exists, so displaying the title
                    qDebug() << "Title exists, showing title of the movie: " << result.resource().property(Nepomuk::Vocabulary::NIE::title()).toString();
                    mainMovieList->addItem(new QListWidgetItem(result.resource().property(Nepomuk::Vocabulary::NIE::title()).toString()));
                }
            }
            else
            {
                //.avi but no data and tt synopsis
                qDebug() << "synopsis: " << result.resource().property(Nepomuk::Vocabulary::NMM::synopsis()).toString();
                //no data, so data needs to be fetched
                //item will be added to the list later
                IMDB* imdbFetcher = new IMDB(result.resource(), mainMovieList);
                imdbFetcher->getData();
            }
        }
    }
}