32 #include <QMessageBox>
51 else if (index.row() > 1)
52 tagFilter = model->
tag(index);
62 proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
65 setFrameShape(QFrame::NoFrame);
66 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
67 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
68 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
69 setUniformRowHeights(
true);
70 setHeaderHidden(
true);
72 #if defined(Q_OS_MACOS)
73 setAttribute(Qt::WA_MacShowFocusRect,
false);
76 setContextMenuPolicy(Qt::CustomContextMenu);
77 sortByColumn(0, Qt::AscendingOrder);
78 setCurrentIndex(model()->index(0, 0));
83 connect(selectionModel(), &QItemSelectionModel::currentRowChanged,
this
91 const auto selectedRows = selectionModel()->selectedRows();
92 if (!selectedRows.isEmpty())
93 current = selectedRows.first();
107 QMenu *menu =
new QMenu(
this);
108 menu->setAttribute(Qt::WA_DeleteOnClose);
113 const auto selectedRows = selectionModel()->selectedRows();
122 menu->addSeparator();
130 menu->popup(QCursor::pos());
143 sizeHintForColumn(0),
145 static_cast<int>(sizeHintForRow(0) * (model()->rowCount() + 0.5)),
158 QTreeView::rowsInserted(parent, start, end);
171 this, tr(
"New Tag"), tr(
"Tag:"), QLineEdit::Normal, tag, &ok).trimmed();
172 if (ok && !tag.isEmpty())
176 QMessageBox::warning(
177 this, tr(
"Invalid tag name")
178 , tr(
"Tag name '%1' is invalid").arg(tag));
184 return ok ? tag : QString();
190 if (tag.isEmpty())
return;
193 QMessageBox::warning(
this, tr(
"Tag exists"), tr(
"Tag name already exists."));
200 const auto selectedRows = selectionModel()->selectedRows();
212 for (
const QString &tag :
asConst(session->tags()))
213 if (model()->data(
static_cast<TagFilterProxyModel *
>(model())->index(tag), Qt::UserRole) == 0)
214 session->removeTag(tag);
static QString getText(QWidget *parent, const QString &title, const QString &label, QLineEdit::EchoMode mode=QLineEdit::Normal, const QString &text={}, bool *ok=nullptr, bool excludeExtension=false, Qt::InputMethodHints inputMethodHints=Qt::ImhNone)
bool removeTag(const QString &tag)
static Session * instance()
bool addTag(const QString &tag)
static bool isValidTag(const QString &tag)
static bool isSpecialItem(const QModelIndex &index)
QString tag(const QModelIndex &index) const
static UIThemeManager * instance()
constexpr std::add_const_t< T > & asConst(T &t) noexcept
QSize smallIconSize(const QWidget *widget=nullptr)