From a4b69fc12a0360fd2afe65ef1a7988b567032068 Mon Sep 17 00:00:00 2001 From: birkeh Date: Tue, 21 Feb 2017 15:28:06 +0100 Subject: [PATCH] Changed colors for first column --- cmainwindow.cpp | 36 +++++++++++++++++++++++++++++++ cseasondelegate.cpp | 52 --------------------------------------------- 2 files changed, 36 insertions(+), 52 deletions(-) diff --git a/cmainwindow.cpp b/cmainwindow.cpp index bb1ae8d..c41f725 100644 --- a/cmainwindow.cpp +++ b/cmainwindow.cpp @@ -262,12 +262,17 @@ void cMainWindow::displaySeries() lp0->setText(2, lpSerie->firstAired().toString("yyyy")); lp0->setTextAlignment(2, Qt::AlignRight); + bool bHasInit = false; + bool bHasProg = false; + bool bHasDone = false; + QList seasonList = lpSerie->seasonList(); for(int z = 0;z < seasonList.count();z++) { QString szInit = ""; QString szProg = ""; QString szDone = ""; + cSeason* lpSeason = seasonList.at(z); lp0->setData(lpSeason->number()+3-iMin, Qt::UserRole, QVariant::fromValue(lpSeason)); @@ -279,6 +284,9 @@ void cMainWindow::displaySeries() szInit.append(QString("%1").arg(lpSeason->episodeList().at(y)->episodeNumber())); else szInit.append(QString(", %1").arg(lpSeason->episodeList().at(y)->episodeNumber())); + + if(lpSeason->number()) + bHasInit = true; } else if(lpSeason->episodeList().at(y)->state() == cEpisode::StateProgress) { @@ -286,6 +294,9 @@ void cMainWindow::displaySeries() szProg.append(QString("%1").arg(lpSeason->episodeList().at(y)->episodeNumber())); else szProg.append(QString(", %1").arg(lpSeason->episodeList().at(y)->episodeNumber())); + + if(lpSeason->number()) + bHasProg = true; } else if(lpSeason->episodeList().at(y)->state() == cEpisode::StateDone) { @@ -293,6 +304,9 @@ void cMainWindow::displaySeries() szDone.append(QString("%1").arg(lpSeason->episodeList().at(y)->episodeNumber())); else szDone.append(QString(", %1").arg(lpSeason->episodeList().at(y)->episodeNumber())); + + if(lpSeason->number()) + bHasDone = true; } } @@ -336,6 +350,28 @@ void cMainWindow::displaySeries() lp0->setForeground(2, QBrush(Qt::red)); } + if(bHasProg) + { + lp0->setForeground(0, QBrush(Qt::white)); + lp0->setForeground(1, QBrush(Qt::white)); + lp0->setForeground(2, QBrush(Qt::white)); + lp0->setBackground(0, QBrush(Qt::blue)); + lp0->setBackground(1, QBrush(Qt::blue)); + lp0->setBackground(2, QBrush(Qt::blue)); + } + else if(bHasInit) + { + lp0->setBackground(0, QBrush(Qt::lightGray)); + lp0->setBackground(1, QBrush(Qt::lightGray)); + lp0->setBackground(2, QBrush(Qt::lightGray)); + } + else + { + lp0->setBackground(0, QBrush(Qt::green)); + lp0->setBackground(1, QBrush(Qt::green)); + lp0->setBackground(2, QBrush(Qt::green)); + } + if(lpSerie->download().length()) lp0->setIcon(0, icon); ui->m_lpSeriesList->insertTopLevelItem(0, lp0); diff --git a/cseasondelegate.cpp b/cseasondelegate.cpp index fc42806..a6345e9 100644 --- a/cseasondelegate.cpp +++ b/cseasondelegate.cpp @@ -107,55 +107,3 @@ QSize cSeasonDelegate::sizeHint(const QStyleOptionViewItem &option, const QModel } return QStyledItemDelegate::sizeHint(option, index); } - -/* -QWidget *cSeasonDelegate::createEditor(QWidget *parent, - const QStyleOptionViewItem &option, - const QModelIndex &index) const - -{ - if (index.data().canConvert()) { - StarEditor *editor = new StarEditor(parent); - connect(editor, SIGNAL(editingFinished()), - this, SLOT(commitAndCloseEditor())); - return editor; - } else { - return QStyledItemDelegate::createEditor(parent, option, index); - } -} -*/ -/* -void cSeasonDelegate::setEditorData(QWidget *editor, - const QModelIndex &index) const -{ - if (index.data().canConvert()) { - StarRating starRating = qvariant_cast(index.data()); - StarEditor *starEditor = qobject_cast(editor); - starEditor->setStarRating(starRating); - } else { - QStyledItemDelegate::setEditorData(editor, index); - } -} -*/ -/* -void cSeasonDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const -{ - if (index.data().canConvert()) - { - StarEditor *starEditor = qobject_cast(editor); - model->setData(index, QVariant::fromValue(starEditor->starRating())); - } - else - { - QStyledItemDelegate::setModelData(editor, model, index); - } -} -*/ -/* -void cSeasonDelegate::commitAndCloseEditor() -{ - StarEditor *editor = qobject_cast(sender()); - emit commitData(editor); - emit closeEditor(editor); -} -*/