Skip to content

Commit

Permalink
Merge pull request #13 from ge022/auto-sort-songs-by-number
Browse files Browse the repository at this point in the history
Auto sort by song number
  • Loading branch information
vladozar authored Oct 14, 2017
2 parents 0134c3b + 330750d commit 6b9ec77
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion songwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ void SongWidget::on_songbook_menu_currentIndexChanged(int index)

updateButtonStates();

// Sort by song number at initial load, and with songbook change
ui->songs_view->sortByColumn(1,Qt::AscendingOrder);

songs_model->emitLayoutChanged(); // forces the view to redraw
}

Expand All @@ -229,7 +232,9 @@ void SongWidget::on_song_num_spinbox_valueChanged(int value)
isSpinboxEditing = true;
ui->lineEditSearch->clear();
on_lineEditSearch_textEdited("");
ui->songs_view->sortByColumn(0,Qt::AscendingOrder);

// Sort by song number
ui->songs_view->sortByColumn(1,Qt::AscendingOrder);
}

//int max_num = 0;
Expand Down Expand Up @@ -288,6 +293,19 @@ void SongWidget::on_lineEditSearch_textEdited(QString text)
// If no full-text search is in progress, then filter
if(!ui->pushButtonClearResults->isVisible())
{

// If search test is numeric, sort by the number, else sort by title
bool ok;
text.toInt(&ok);
if(ok)
{
ui->songs_view->sortByColumn(1,Qt::AscendingOrder);
}
else
{
ui->songs_view->sortByColumn(2,Qt::AscendingOrder);
}

// These two options are mutually exclusive:
bool match_beginning = (ui->comboBoxFilterType->currentIndex() == 1);
bool exact_match = (ui->comboBoxFilterType->currentIndex() == 2);
Expand Down

0 comments on commit 6b9ec77

Please sign in to comment.