示例#1
0
void TableWidget::showAlbumInfo( const Album &a ){

    int n = std::max( a.songs().size(), this->rowCount() );
    setRowCount(n);
    bool enabled = isSortingEnabled();
    setSortingEnabled(false);

    //delete old results
    for(int i=0;i<rowCount();i++){
        delete takeItem(i,TITLE);
        delete takeItem(i,TRACK);
    }

    int k=0;
    QList<Song> leftOverSongs;
    QList<Song> songs = a.songs();
    while( songs.size()>0 ){
        int row;
        //qDebug()<<a.songs[0].title;
        if(matchByTrackAction->isChecked()){
            row = matchResult( songs[0].track(), CURRENT_TRACK );
        }else if(matchByTitleAction->isChecked()){
            row = matchResult( songs[0].title(), CURRENT_TITLE );
        }else if(matchByTitleTrackAction->isChecked()){
            row = matchResult( songs[0].title(), CURRENT_TITLE );
            if(row==-1){
                row = matchResult( songs[0].track(), CURRENT_TRACK );
            }
            if(row==-1){
                row = matchResult( songs[0].title(), FILE_NAME );
            }
        }else if(matchByTrackTitleAction->isChecked()){
            row = matchResult( songs[0].track(), CURRENT_TRACK );
            if(row==-1){
                row = matchResult( songs[0].title(), CURRENT_TITLE );
            }
            if(row==-1){
                row = matchResult( songs[0].title(), FILE_NAME );
            }
        }else if(matchByFileNameAction->isChecked()){
            row = matchResult( songs[0].title(), FILE_NAME );
        }else if(dontMatchAction->isChecked()){;
            row = k;
            k++;
        }else{
            row = k;
            k++;
        }
        if(row==-1){
            leftOverSongs.append(songs[0]);
            songs.removeAt(0);
            continue;
        }

        TableWidgetItem *newItem = new TableWidgetItem;
        newItem->setText(songs[0].title());
        QFont f = newItem->font();f.setPointSize(10);
        newItem->setFont(f);
        setItem(row, TITLE, newItem);

        TableWidgetItem *newItem1 = new TableWidgetItem;
        newItem1->setText(songs[0].track());
        newItem1->setFont(f);
        setItem(row, TRACK, newItem1);

        songs.removeAt(0);
    }
    for(int i=0;i<leftOverSongs.size();i++){
        int n = rowCount();
        int row=n+1;
        for(int j=0;j<n;j++){
            if(!item(j,TITLE)){
                row=j;
                break;
            }
        }
        qDebug()<<leftOverSongs[i].title()<<" leftover, put in row "<<row;
        TableWidgetItem *newItem = new TableWidgetItem;
        newItem->setText(leftOverSongs[i].title());
        QFont f = newItem->font();f.setPointSize(10);
        newItem->setFont(f);
        setItem(row, TITLE, newItem);

        TableWidgetItem *newItem1 = new TableWidgetItem;
        newItem1->setText(leftOverSongs[i].track());
        newItem1->setFont(f);
        setItem(row, TRACK, newItem1);
    }
    setSortingEnabled(enabled);
    setNonEditable( 0, n );
}
示例#2
0
文件: locktests.c 项目: cephpp/test
void compteur(int r,int n){
    TOTAL_RESULTAT_OK[n]+=matchResult(r, n);
}