Commit abb256f2 authored by Michael Pyne's avatar Michael Pyne

Remove needless event filter, add alt. row colors, sane column weights.

parent a15af145
......@@ -862,18 +862,14 @@ bool Playlist::eventFilter(QObject *watched, QEvent *e)
void Playlist::keyPressEvent(QKeyEvent *event)
{
if(event->key() == Qt::Key_Up) {
using ::operator|;
QTreeWidgetItemIterator selected(this, QTreeWidgetItemIterator::Selected |
QTreeWidgetItemIterator::NotHidden);
if(*selected) {
const auto topItem = topLevelItem(0);
if(topItem && topItem == currentItem()) {
QTreeWidgetItemIterator visible(this, QTreeWidgetItemIterator::NotHidden);
if(*selected == *visible)
QApplication::postEvent(parent(), new FocusUpEvent);
if(topItem == *visible) {
emit signalMoveFocusAway();
event->accept();
}
}
}
else if(event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter) {
slotPlayCurrent();
}
QTreeWidget::keyPressEvent(event);
......@@ -1408,6 +1404,7 @@ void Playlist::slotPlayFromBackMenu(QAction *backAction) const
void Playlist::setup()
{
setAlternatingRowColors(true);
setRootIsDecorated(false);
setContextMenuPolicy(Qt::CustomContextMenu);
setUniformRowHeights(true);
......@@ -1423,6 +1420,9 @@ void Playlist::setup()
sortByColumn(1, Qt::AscendingOrder);
// Should this be itemActivated? It is quite annoying when I try it...
connect(this, &QTreeWidget::itemDoubleClicked, this, &Playlist::slotPlayCurrent);
// This apparently must be created very early in initialization for other
// Playlist code requiring m_headerMenu.
m_columnVisibleAction = new KActionMenu(i18n("&Show Columns"), this);
......@@ -1651,7 +1651,18 @@ void Playlist::cleanupAfterAllFileLoadsCompleted()
m_blockDataChanged = false;
setEnabled(true);
slotWeightDirty();
// Even if doing a manual column weights we'll generally start off with
// incorrect column sizes so at least figure out a reasonable column size
// and let user adjust from there.
if(manualResize()) {
auto manualResizeAction = action<KToggleAction>("resizeColumnsManually");
manualResizeAction->toggle();
calculateColumnWeights();
slotUpdateColumnWidths();
manualResizeAction->toggle();
}
playlistItemsChanged();
}
......
......@@ -349,7 +349,6 @@ public slots:
* @see clearItems()
*/
virtual void clear();
virtual void selectAll() { QTreeView::selectAll(); }
/**
* Refreshes the tags of the selection from disk, or all of the files in the
......@@ -493,6 +492,8 @@ signals:
void signalPlaylistItemsDropped(Playlist *p);
void signalMoveFocusAway();
private:
void setup();
......@@ -715,15 +716,6 @@ typedef QVector<Playlist *> PlaylistList;
bool processEvents();
class FocusUpEvent : public QEvent
{
public:
FocusUpEvent() : QEvent(id) {}
Type type() const { return id; }
static const Type id = static_cast<Type>(QEvent::User + 1);
};
QDataStream &operator<<(QDataStream &s, const Playlist &p);
QDataStream &operator>>(QDataStream &s, Playlist &p);
......
......@@ -260,13 +260,15 @@ void PlaylistBox::slotSetHistoryPlaylistEnabled(bool enable)
void PlaylistBox::setupPlaylist(Playlist *playlist, const QString &iconName)
{
setupPlaylist(playlist, iconName, 0);
setupPlaylist(playlist, iconName, nullptr);
}
void PlaylistBox::setupPlaylist(Playlist *playlist, const QString &iconName, Item *parentItem)
{
connect(playlist, SIGNAL(signalPlaylistItemsDropped(Playlist*)),
SLOT(slotPlaylistItemsDropped(Playlist*)));
connect(playlist, &Playlist::signalPlaylistItemsDropped,
this, &PlaylistBox::slotPlaylistItemsDropped);
connect(playlist, &Playlist::signalMoveFocusAway,
this, &PlaylistBox::signalMoveFocusAway);
PlaylistCollection::setupPlaylist(playlist, iconName);
......
......@@ -67,7 +67,7 @@ public:
Item *dropItem() const { return m_dropItem; }
void setupPlaylist(Playlist *playlist, const QString &iconName, Item *parentItem = 0);
void setupPlaylist(Playlist *playlist, const QString &iconName, Item *parentItem = nullptr);
public slots:
void paste();
......@@ -84,6 +84,7 @@ protected:
signals:
void signalPlaylistDestroyed(Playlist *);
void signalMoveFocusAway(); // Handles keyboard scrolling up out of playlist
void startupComplete(); ///< Emitted after playlists are loaded.
void startFilePlayback(const FileHandle &file);
......
......@@ -103,15 +103,6 @@ PlaylistInterface *PlaylistSplitter::playlist() const
return m_playlistBox;
}
bool PlaylistSplitter::eventFilter(QObject *, QEvent *event)
{
if(event->type() == FocusUpEvent::id) {
m_searchWidget->setFocus();
return true;
}
return false;
}
////////////////////////////////////////////////////////////////////////////////
// public slots
////////////////////////////////////////////////////////////////////////////////
......@@ -197,7 +188,6 @@ void PlaylistSplitter::setupLayout()
m_playlistStack = new QStackedWidget(top);
m_playlistStack->setObjectName(QLatin1String("playlistStack"));
m_playlistStack->installEventFilter(this);
m_playlistStack->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_playlistStack->hide(); // Will be shown after CollectionList filled.
......@@ -252,6 +242,8 @@ void PlaylistSplitter::setupLayout()
m_playlistBox->object(), SLOT(slotPlayFirst()));
connect(ActionCollection::action<KToggleAction>("showSearch"), SIGNAL(toggled(bool)),
m_searchWidget, SLOT(setEnabled(bool)));
connect(m_playlistBox, &PlaylistBox::signalMoveFocusAway,
m_searchWidget, &SearchWidget::setFocus);
topLayout->addWidget(m_nowPlaying);
topLayout->addWidget(m_searchWidget);
......
......@@ -51,8 +51,6 @@ public:
PlaylistInterface *playlist() const;
virtual bool eventFilter(QObject *watched, QEvent *event);
signals:
/**
* Emitted when GUI is created and the cache is loaded. Is kind of a hack
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment