This commit is contained in:
2017-10-19 19:37:15 +02:00
parent 738c420157
commit 9aa9b29c6b
4 changed files with 76 additions and 38 deletions
+50 -21
View File
@@ -39,6 +39,34 @@
#include <QDesktopWidget>
static bool serieSort(cSerie* s1, cSerie* s2)
{
QString str1 = s1->seriesName();
QString str2 = s2->seriesName();
return(str1 < str2);
}
static bool movieSort(cMovie* s1, cMovie* s2)
{
QString collection1 = s1->belongsToCollection();
QString collection2 = s2->belongsToCollection();
QString title1 = s1->movieTitle();
QString title2 = s2->movieTitle();
if(collection1.isEmpty() && collection2.isEmpty())
return(title1 < title2);
if(!collection1.isEmpty() && !collection2.isEmpty())
{
if(collection1 == collection2)
return(title1 < title2);
return(collection1 < collection2);
}
return(title1 < title2);
}
cMainWindow::cMainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::cMainWindow),
@@ -317,7 +345,7 @@ void cMainWindow::loadMoviesDB()
QSqlQuery query;
qint32 iMovieID;
if(query.exec("SELECT movieID, movieTitle, originalTitle, backdropPath, posterPath, overview, releaseDate, genre, imdbid, originalLanguage, popularity, productionCompanies, productionCountries, voteAverage, voteCount, adult, belongsToCollection, budget, homepage, revenue, runtime, spokenLanguages, status, tagline, video, `cast`, crew, state FROM movie ORDER BY movieTitle, releaseDate;"))
if(query.exec("SELECT movieID, movieTitle, originalTitle, backdropPath, posterPath, overview, releaseDate, genre, imdbid, originalLanguage, popularity, productionCompanies, productionCountries, voteAverage, voteCount, adult, belongsToCollection, budget, homepage, revenue, runtime, spokenLanguages, status, tagline, video, `cast`, crew, state, sortText FROM (SELECT *, IFNULL(belongsToCollection, movieTitle) AS sortText FROM movie) ORDER BY sortText, releaseDate;"))
{
while(query.next())
{
@@ -574,7 +602,6 @@ void cMainWindow::displaySeries()
void cMainWindow::displayMovies()
{
m_lpMoviesListModel->clear();
m_lpMoviesListModel->setColumnCount(1);
QStringList header;
@@ -582,13 +609,32 @@ void cMainWindow::displayMovies()
m_lpMoviesListModel->setHorizontalHeaderLabels(header);
QString szOldCollection("");
QStandardItem* lpRoot = 0;
for(int x = 0;x < m_movieList.count();x++)
{
cMovie* lpMovie = m_movieList.at(x);
if(lpMovie->belongsToCollection() != szOldCollection)
{
szOldCollection = lpMovie->belongsToCollection();
if(szOldCollection.isEmpty())
lpRoot = 0;
else
{
lpRoot = new QStandardItem(szOldCollection);
m_lpMoviesListModel->appendRow(lpRoot);
}
}
QStandardItem* lpItem = new QStandardItem(QString("<font color='white'><b>%1</b> (%2)&nbsp;&nbsp;<br><i>%3</i></font>").arg(lpMovie->movieTitle()).arg(lpMovie->releaseDate().year()).arg(lpMovie->tagline()));
lpItem->setData(QVariant::fromValue(lpMovie), Qt::UserRole);
m_lpMoviesListModel->appendRow(lpItem);
if(lpRoot)
lpRoot->appendRow(lpItem);
else
m_lpMoviesListModel->appendRow(lpItem);
}
}
@@ -658,21 +704,6 @@ void cMainWindow::showMoviesContextMenu(QTreeView* lpTreeView, const QPoint &pos
lpMenu->popup(lpTreeView->viewport()->mapToGlobal(pos));
}
static bool serieSort(cSerie* s1, cSerie* s2)
{
QString str1 = s1->seriesName();
QString str2 = s2->seriesName();
return(str1 < str2);
}
static bool movieSort(cMovie* s1, cMovie* s2)
{
QString str1 = s1->movieTitle();
QString str2 = s2->movieTitle();
return(str1 < str2);
}
bool cMainWindow::runEdit(cSerie* lpSerie, QString& szDownload)
{
cEdit* lpEdit = new cEdit;
@@ -902,9 +933,7 @@ void cMainWindow::onActionMovieAdd()
*/
}
m_movieList.add(lpMovie);
std::sort(m_movieList.begin(), m_movieList.end(), movieSort);
loadMoviesDB();
displayMovies();
delete lpDialog;
+1 -1
View File
@@ -130,7 +130,7 @@
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="allColumnsShowFocus">
<bool>true</bool>
+1 -1
View File
@@ -40,7 +40,7 @@ void cMovieSearch::on_m_lpSearchButton_clicked()
lpDialog->show();
cTheMovieDBV3 theMovieDBV3;
QList<cMovie*> movieList = theMovieDBV3.search(ui->m_lpSearch->text());
QList<cMovie*> movieList = theMovieDBV3.search(ui->m_lpSearch->text(), -1, "de");
ui->m_lpResults->clear();
+24 -15
View File
@@ -36,25 +36,34 @@ void cMovieViewItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem
//doc.drawContents(painter, clip);
painter->setClipRect(clip);
oldBrush = painter->brush();
switch(lpMovie->state())
if(!lpMovie)
{
case cMovie::StateInit:
painter->setBrush(STATE_INIT);
break;
case cMovie::StateProgress:
painter->setBrush(STATE_PROGRESS);
break;
case cMovie::StateDone:
painter->setBrush(STATE_DONE);
break;
default:
break;
QItemModel* lpModel = (QItemModel*)index.model();
aaaaa
}
painter->drawRect(clip);
if(lpMovie)
{
oldBrush = painter->brush();
painter->setBrush(oldBrush);
switch(lpMovie->state())
{
case cMovie::StateInit:
painter->setBrush(STATE_INIT);
break;
case cMovie::StateProgress:
painter->setBrush(STATE_PROGRESS);
break;
case cMovie::StateDone:
painter->setBrush(STATE_DONE);
break;
default:
break;
}
painter->drawRect(clip);
painter->setBrush(oldBrush);
}
QAbstractTextDocumentLayout::PaintContext ctx;
// set text color to red for selected item