void BookmarkGui::fillCategorieRec( const QString& name , const QString& parent_id , QTreeWidgetItem* parent )
{
     Bookmark bk ;
     QueryResult qr ;

     bk.getFoldersId( qr , parent_id ) ;

     for ( QueryResult::iterator itr = qr.begin() ; itr < qr.end() ; itr++ )
     {
          QString name = qr.getField( "Folder" , itr ) ;
          QString id = qr.getField( "Id" , itr ) ;
          QTreeWidgetItem* item = new QTreeWidgetItem( parent , BookmarkGui::item_folder ) ;
          this->setFolderItemDecorations( item , name , id ) ;
          this->fillCategorieRec( name , id , item ) ;
     }

     bk.getFavoritesByParent( qr , name ) ;
     for ( QueryResult::iterator itr = qr.begin() ; itr < qr.end() ; itr++ )
     {
          QString id_entry = qr.getField( "IdEntry" , itr ) ;
          QString id = qr.getField( "Id" , itr ) ;
          QTreeWidgetItem* item = new QTreeWidgetItem( parent , BookmarkGui::item_article ) ;
          this->setArticleItemDecorations( item , id_entry , id ) ;
     }
}
void BookmarkGui::fillEvaluations()
{
    QueryResult eval ;
    Bookmark bk ;


    QList<QTreeWidgetItem*> items;

    ui->Evaluation->clear();

    int index = 0 ;

    ui->Evaluation->setIconSize( QSize( 100 , 20 ) );
    ui->treeEvaluations->setIconSize( QSize( 100 , 20 ) );

    ui->Evaluation->insertItem( index , tr("Nessuna valutazione") , "-1" );

    bk.getEvaluations( eval );

    for ( QueryResult::iterator itr = eval.begin() ; itr < eval.end() ; itr++ )
    {
        QString Evaluation = eval.getField( "Evaluation" , itr ) ;

        QString stars_file = ":/stars/stars/" ;
        stars_file += Evaluation ;
        stars_file += "s.png" ;
        QIcon stars_icon( stars_file ) ;
        QTreeWidgetItem* item = new QTreeWidgetItem( (QTreeWidget*)0 , BookmarkGui::item_evaluation ) ;
        item->setIcon( 0 , stars_icon ) ;

        item->setText( 1 , Evaluation ) ;
        qDebug() << item->text(1);


        QueryResult entries ;
        bk.getFavoritesByEvaluation( entries , Evaluation ) ;
        for ( QueryResult::iterator itr_b = entries.begin() ; itr_b < entries.end() ; itr_b++ )
        {
            QString id_entry = entries.getField( "IdEntry" , itr_b ) ;
            QString id = entries.getField( "Id" , itr_b ) ;
            QTreeWidgetItem* entry_item = new QTreeWidgetItem( item , BookmarkGui::item_article ) ;
            this->setArticleItemDecorations( entry_item , id_entry , id ) ;
        }


        items.append( item );

        QVariant stars ;
        stars.setValue( Evaluation );
        ui->Evaluation->insertItem( ++index , stars_icon , "" , stars ) ;
    }

    ui->treeEvaluations->clear();
    ui->treeEvaluations->addTopLevelItems( items );
}
void BookmarkGui::fillCategorie()
{
     QList<QTreeWidgetItem *> items;
     Bookmark bk ;
     QueryResult qr ;

     bk.getRootFolders( qr );
     for ( QueryResult::iterator itr = qr.begin() ; itr < qr.end() ; itr++ )
     {
         QString name = qr.getField( "Folder" , itr ) ;
         QString id = qr.getField( "Id" , itr ) ;
         QTreeWidgetItem* item = new QTreeWidgetItem( (QTreeWidget*)0 , BookmarkGui::item_folder ) ;
         setFolderItemDecorations( item , name , id ) ;
         fillCategorieRec( name , id , item ) ;
         items.append( item ) ;
     }

     // ATTENIONE!
     bk.getFavoritesByParentId( qr , "" ) ;
     for ( QueryResult::iterator itr = qr.begin() ; itr < qr.end() ; itr++ )
     {
          QString name = qr.getField( "IdArticolo" , itr ) ;
          QString id = qr.getField( "Id" , itr ) ;
          QTreeWidgetItem* item = new QTreeWidgetItem( (QTreeWidget*)0 , BookmarkGui::item_article ) ;
          this->setArticleItemDecorations( item , name , id ) ;
          items.append( item );
     }

     ui->treeCategorie->clear();

     if ( items.isEmpty() )
     {
         showDataBaseMessage() ;
         return ;
     }

     current_favorites_item = items.first() ;
     ui->treeCategorie->insertTopLevelItems(0, items);
     current_favorites_item->setExpanded( true ) ;
}
Exemple #4
0
QueryResult OrQuery::eval(const TextQuery &text) const
{
    QueryResult right = rhs.eval(text), left= lhs.eval(text);

    //! copy the left-hand operand into the result set
    std::shared_ptr<std::set<line_no>> ret_lines =
            std::make_shared<std::set<line_no>>(left.begin(), left.end());

    //! inert lines from the right-hand operand
    ret_lines->insert(right.begin(), right.end());

    return QueryResult(rep(),ret_lines,left.get_file());
}
void BookmarkGui::fillStates()
{
    QueryResult states ;
    Bookmark bk ;

    bk.getStates( states );
    QList<QTreeWidgetItem*> items;

    ui->State->clear();

    int index = 0 ;
    ui->State->insertItem( index , tr("Non definito") ) ;

    for ( QueryResult::iterator itr = states.begin() ; itr < states.end() ; itr++ )
    {
        QString name = states.getField( "StateName" , itr ) ;
        QString id = states.getField( "Id" , itr ) ;
        QTreeWidgetItem* item = new QTreeWidgetItem( (QTreeWidget*)0 , BookmarkGui::item_state ) ;

        QueryResult entries ;
        bk.getFavoritesByState( entries , name ) ;
        for ( QueryResult::iterator itr_b = entries.begin() ; itr_b < entries.end() ; itr_b++ )
        {
            QString id_entry = entries.getField( "IdEntry" , itr_b ) ;
            QString id = entries.getField( "Id" , itr_b ) ;
            QTreeWidgetItem* entry_item = new QTreeWidgetItem( item , BookmarkGui::item_article ) ;
            this->setArticleItemDecorations( entry_item , id_entry , id ) ;
        }

        this->setFolderItemDecorations( item , name , id ) ;
        items.append( item );

        ui->State->insertItem( ++index , name ) ;
    }

    ui->treeStates->clear();
    ui->treeStates->addTopLevelItems( items ) ;
}
bool LeScienze500::fillQListWidget( QListWidget *w_list , QueryResult &r_list )
{
    if ( r_list.empty() )
        return false ;

    w_list->clear();
    QString col_name = r_list.getFirstColumnName() ;

    QueryResult::iterator it;

    for( it = r_list.begin() ; it < r_list.end() ; it++ )
    {
        w_list->addItem( r_list.getField( col_name , it ) );
    }

    return true ;
}