Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto sort by song number #13

Merged
merged 2 commits into from
Oct 14, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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