diff options
-rw-r--r-- | searchdialog.cpp | 31 | ||||
-rw-r--r-- | searchdialog.h | 2 |
2 files changed, 23 insertions, 10 deletions
diff --git a/searchdialog.cpp b/searchdialog.cpp index 50109b9..4e62f5e 100644 --- a/searchdialog.cpp +++ b/searchdialog.cpp @@ -96,10 +96,7 @@ void SearchDialog::doSearch(){ }else if(type == Actors){ doSearchActor(); } - QModelIndex first = mResV->selectionModel()->model()->index(0, 0); - if(first.isValid()){ - mResV->selectionModel()->setCurrentIndex(first, QItemSelectionModel::ClearAndSelect); - } + clearOrSelectFirst(); qApp->restoreOverrideCursor(); } @@ -135,7 +132,7 @@ void SearchDialog::doSearchTitle(){ QStandardItem *root = mResM->invisibleRootItem(); QSqlDatabase db = QSqlDatabase::database("shemovdb"); QSqlQuery tQ(db); - tQ.prepare("SELECT DISTINCT(iseries_id), tseries_name FROM series WHERE tseries_name ~ :title ORDER BY tseries_name"); + tQ.prepare("SELECT DISTINCT(iseries_id), tseries_name FROM series WHERE tseries_name ~ :title"); tQ.bindValue(":title", mSearch->text()); tQ.exec(); while(tQ.next()){ @@ -146,6 +143,7 @@ void SearchDialog::doSearchTitle(){ root->appendRow(cur); } mResV->setSortingEnabled(true); + mResV->sortByColumn(0, Qt::AscendingOrder); } void SearchDialog::doSearchFilename(){ @@ -202,7 +200,7 @@ void SearchDialog::doSearchActor(){ QStandardItem *root = mResM->invisibleRootItem(); QSqlDatabase db = QSqlDatabase::database("shemovdb"); QSqlQuery aQ(db); - aQ.prepare("SELECT tactorname, iactors_id FROM actors WHERE tactorname ~ :name ORDER BY tactorname"); + aQ.prepare("SELECT tactorname, iactors_id FROM actors WHERE tactorname ~ :name"); aQ.bindValue(":name", mSearch->text()); aQ.exec(); while(aQ.next()){ @@ -214,7 +212,7 @@ void SearchDialog::doSearchActor(){ root->appendRow(cur); } mResV->setSortingEnabled(true); - mResV->sortByColumn(0); + mResV->sortByColumn(0, Qt::AscendingOrder); } void SearchDialog::doResultName(const QModelIndex &sel, int resType){ @@ -256,7 +254,7 @@ void SearchDialog::doResultName(const QModelIndex &sel, int resType){ root->appendRow(cur); } mDataV->setSortingEnabled(true); - mDataV->sortByColumn(0); + mDataV->sortByColumn(0, Qt::AscendingOrder); } void SearchDialog::doResultActor(const QModelIndex &sel){ @@ -309,7 +307,7 @@ void SearchDialog::doResultActor(const QModelIndex &sel){ root->appendRow(cur); } mDataV->setSortingEnabled(true); - mDataV->sortByColumn(0); + mDataV->sortByColumn(0, Qt::AscendingOrder); } } @@ -414,3 +412,18 @@ void SearchDialog::doActorGenres(QStandardItem *item){ } } } + +void SearchDialog::clearOrSelectFirst(){ + QModelIndex first = mResV->selectionModel()->model()->index(0, 0); + if(first.isValid()){ + mResV->selectionModel()->setCurrentIndex(first, QItemSelectionModel::ClearAndSelect); + }else{ + mDataM->clear(); + int type = mTypeSel->currentData().toInt(); + if(type == Title){ + mDataM->setHeaderData(0, Qt::Horizontal, tr("Parts")); + }else if(type == Filename || type == Actors){ + mDataM->setHeaderData(0, Qt::Horizontal, tr("Series")); + } + } +} diff --git a/searchdialog.h b/searchdialog.h index 252f429..dca9431 100644 --- a/searchdialog.h +++ b/searchdialog.h @@ -36,7 +36,7 @@ class SearchDialog : public QDialog { private: void doChild(QStandardItem *item, int childMode); void doActorGenres(QStandardItem *item); - void doActorFiles(QStandardItem *item); + void clearOrSelectFirst(); QLineEdit *mSearch; QComboBox *mTypeSel; SearchView *mResV; |