diff --git a/ChangeLog b/ChangeLog index dbb4f2740..5eca7d963 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2015-09-01 Moritz Bunkus + * MKVToolNix GUI: chapter editor enhancement: added a column in + the tree with the edition's/chapter's flags. + * MKVToolNix GUI: new feature: the state of all columns in all list/tree views can be reset (both the shown/hidden state as well as their order) from the column's context menu. See #1268. diff --git a/src/mkvtoolnix-gui/chapter_editor/chapter_model.cpp b/src/mkvtoolnix-gui/chapter_editor/chapter_model.cpp index 0228169be..2ec9945c5 100644 --- a/src/mkvtoolnix-gui/chapter_editor/chapter_model.cpp +++ b/src/mkvtoolnix-gui/chapter_editor/chapter_model.cpp @@ -13,8 +13,12 @@ namespace mtx { namespace gui { namespace ChapterEditor { using namespace mtx::gui; +static auto const s_numColumns = 4; + ChapterModel::ChapterModel(QObject *parent) : QStandardItemModel{parent} + , m_yesIcon(":/icons/16x16/dialog-ok-apply.png") + , m_noIcon(":/icons/16x16/dialog-cancel.png") { } @@ -23,24 +27,30 @@ ChapterModel::~ChapterModel() { void ChapterModel::retranslateUi() { - auto labels = QStringList{} << QY("Edition/Chapter") << QY("Start") << QY("End"); + auto labels = QStringList{} << QY("Edition/Chapter") << QY("Start") << QY("End") << QY("Flags"); setHorizontalHeaderLabels(labels); for (auto row = 0, numRows = rowCount(); row < numRows; ++row) - setEditionRowText(itemsForRow(index(row, 0))); + walkTree(index(row, 0), [=](QModelIndex const ¤tIdx) { + updateRow(currentIdx); + }); } QList ChapterModel::newRowItems() { - auto items = QList{} << new QStandardItem{} << new QStandardItem{} << new QStandardItem{}; - return items; + auto rowItems = QList{}; + + for (auto column = 0; column < s_numColumns; ++column) + rowItems << new QStandardItem{}; + + return rowItems; } QList ChapterModel::itemsForRow(QModelIndex const &idx) { auto rowItems = QList{}; - for (auto column = 0; 3 > column; ++column) + for (auto column = 0; column < s_numColumns; ++column) rowItems << itemFromIndex(idx.sibling(idx.row(), column)); return rowItems; @@ -48,7 +58,24 @@ ChapterModel::itemsForRow(QModelIndex const &idx) { void ChapterModel::setEditionRowText(QList const &rowItems) { + auto edition = editionFromItem(rowItems[0]); + if (!edition) + return; + + auto flags = QStringList{}; + auto isDefault = edition && FindChildValue(*edition); + auto isHidden = edition && FindChildValue(*edition); + auto isOrdered = edition && FindChildValue(*edition); + + if (isOrdered) + flags << QY("ordered"); + if (isHidden) + flags << QY("hidden"); + if (isDefault) + flags << QY("default"); + rowItems[0]->setText(QY("Edition entry")); + rowItems[3]->setText(flags.join(Q(", "))); } ChapterPtr @@ -67,14 +94,25 @@ ChapterModel::setChapterRowText(QList const &rowItems) { if (!chapter) return; - auto kStart = FindChild(*chapter); - auto kEnd = FindChild(*chapter); + auto flags = QStringList{}; + + auto isEnabled = FindChildValue(*chapter, 1); + auto isHidden = FindChildValue(*chapter); + + auto kStart = FindChild(*chapter); + auto kEnd = FindChild(*chapter); + + if (!isEnabled) + flags << QY("disabled"); + if (isHidden) + flags << QY("hidden"); rowItems[1]->setData(static_cast(kStart ? kStart->GetValue() : 0), QStandardItemModel::sortRole()); rowItems[0]->setText(chapterDisplayName(*chapter)); rowItems[1]->setText(kStart ? Q(format_timecode(kStart->GetValue(), 0)) : Q("")); rowItems[2]->setText(kEnd ? Q(format_timecode(kEnd->GetValue(), 0)) : Q("")); + rowItems[3]->setText(flags.join(Q(", "))); } void diff --git a/src/mkvtoolnix-gui/chapter_editor/chapter_model.h b/src/mkvtoolnix-gui/chapter_editor/chapter_model.h index e67a385b9..2c1e64369 100644 --- a/src/mkvtoolnix-gui/chapter_editor/chapter_model.h +++ b/src/mkvtoolnix-gui/chapter_editor/chapter_model.h @@ -3,6 +3,7 @@ #include "common/common_pch.h" +#include #include #include @@ -29,6 +30,7 @@ protected: qulonglong m_nextElementRegistryIdx{}; QModelIndex m_selectedIdx; + QIcon m_yesIcon, m_noIcon; public: ChapterModel(QObject *parent);