void BookmarkGui::fillFavoriteInfo( const QString& id , const QString& Id_f ) { this->fillFavoriteInfo( id ) ; this->current_favorite_id = Id_f ; Bookmark bk ; QueryResult res ; bk.getComment( res , Id_f ) ; if ( res.empty() ) ui->Comments->setHtml( "" ) ; else ui->Comments->setHtml( res.getField(0,0) ) ; ui->SaveComment->setDisabled( true ); res.clear() ; bk.getState( res , Id_f ) ; if ( !res.empty() ) { int index = ui->State->findText( res.getField(0,0) ) ; ui->State->setCurrentIndex( index ); } else ui->State->setCurrentIndex( 0 ); res.clear() ; bk.getEvaluation( res , Id_f ) ; if ( !res.empty() ) { int index = ui->Evaluation->findData( res.getField(0,0) ) ; ui->Evaluation->setCurrentIndex( index ); } else ui->Evaluation->setCurrentIndex( 0 ); }
QString Bookmark::getStateId( QString name ) { QString query = "select Id from UserStates where StateName like \'" ; query += name ; query += "\' " ; QueryResult qr ; this->execQuery( query , qr ); if ( qr.size() == 0 ) return QString() ; else return qr.getField(0,0) ; }
void BookmarkGui::setArticleItemDecorations( QTreeWidgetItem* item , const QString& id_articolo , const QString& id ) { QueryResult article ; Bookmark bk ; bk.getFavoriteFullData( article , id_articolo ) ; QIcon doc_icon(":/icons/crystal/doc-icon.png") ; item->setIcon( 0 , doc_icon ); if ( article.size() == 0 ) return ; item->setText( 0 , article.getField( "Titolo" , article.begin() ) ); item->setText( 1 , id_articolo ) ; item->setText( 2 , id ) ; }
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 ; }
bool BookmarkGui::removeEvaluation() { Bookmark bk ; QueryResult favorite ; QTreeWidgetItem *item ; bk.getFavoriteFullData( favorite , this->current_favorite ); QList<QTreeWidgetItem *> list = ui->treeEvaluations->findItems ( favorite.getField( "Id" , favorite.begin() ) , Qt::MatchExactly|Qt::MatchRecursive , 1 ) ; if ( list.size() > 1 || list.isEmpty() ) return false ; item = list.first() ; if ( item->type() != BookmarkGui::item_article ) return false ; QTreeWidgetItem *parent = item->parent() ; parent->removeChild( item ); ; return true ; }
bool BookmarkGui::changeState( QString new_state ) { Bookmark bk ; QueryResult favorite ; QTreeWidgetItem *item ; bk.getFavoriteFullData( favorite , this->current_favorite ); QList<QTreeWidgetItem *> list = ui->treeStates->findItems ( favorite.getField( "Titolo" , favorite.begin() ) , Qt::MatchExactly|Qt::MatchRecursive ) ; if ( list.size() > 1 ) return false ; QList<QTreeWidgetItem *> list_state = ui->treeStates->findItems ( new_state , Qt::MatchExactly ) ; if ( list_state.isEmpty() || list_state.size() > 1 ) return false ; QTreeWidgetItem *state = list_state.first() ; if ( state->type() != BookmarkGui::item_state ) return false ; item = list.first() ; if ( item->type() != BookmarkGui::item_article ) return false ; int index = item->parent()->indexOfChild( item ) ; item = item->parent()->takeChild( index ) ; state->addChild( item ); state->setExpanded( true ); ui->treeStates->setCurrentItem( item ); return true ; }
bool BookmarkGui::changeEvaluation( QString stars ) { Bookmark bk ; QueryResult favorite ; QTreeWidgetItem *item ; bk.getFavoriteFullData( favorite , this->current_favorite ); QList<QTreeWidgetItem *> list = ui->treeEvaluations->findItems ( favorite.getField( "Titolo" , favorite.begin() ) , Qt::MatchExactly|Qt::MatchRecursive ) ; if ( list.size() > 1 ) return false ; QList<QTreeWidgetItem *> list_evaluations = ui->treeEvaluations->findItems ( stars , Qt::MatchExactly , 1 ) ; if ( list_evaluations.isEmpty() || list_evaluations.size() > 1 ) return false ; QTreeWidgetItem *evaluation = list_evaluations.first() ; if ( evaluation->type() != BookmarkGui::item_evaluation ) return false ; item = list.first() ; if ( item->type() != BookmarkGui::item_article ) return false ; int index = item->parent()->indexOfChild( item ) ; item = item->parent()->takeChild( index ) ; evaluation->addChild( item ); evaluation->setExpanded( true ); ui->treeEvaluations->setCurrentItem( item ); return true ; }