Commit 8256c440 authored by Scott Wheeler's avatar Scott Wheeler

Slightly modified patch from Michael Pyne to fix #66485 where item text was

not being shown in the default view mode after hiding in the system tray and
restoring.

CCMAIL:66485-done@bugs.kde.org

svn path=/trunk/kdemultimedia/juk/; revision=271075
parent 613ecdbf
...@@ -60,6 +60,7 @@ PlaylistBox::PlaylistBox(PlaylistSplitter *parent, const QString &name) : ...@@ -60,6 +60,7 @@ PlaylistBox::PlaylistBox(PlaylistSplitter *parent, const QString &name) :
// Find the main window and then get the associated KActionCollection. // Find the main window and then get the associated KActionCollection.
QObject *w = parent; QObject *w = parent;
while(w && !dynamic_cast<KMainWindow *>(w)) while(w && !dynamic_cast<KMainWindow *>(w))
w = w->parent(); w = w->parent();
...@@ -121,6 +122,7 @@ void PlaylistBox::createItem(Playlist *playlist, const char *icon, bool raise, b ...@@ -121,6 +122,7 @@ void PlaylistBox::createItem(Playlist *playlist, const char *icon, bool raise, b
Item *i = new Item(this, icon, playlist->name(), playlist); Item *i = new Item(this, icon, playlist->name(), playlist);
setupItem(i, playlist); setupItem(i, playlist);
viewMode()->queueRefresh();
if(raise) { if(raise) {
setSingleItem(i); setSingleItem(i);
...@@ -248,8 +250,10 @@ void PlaylistBox::rename(Item *item) ...@@ -248,8 +250,10 @@ void PlaylistBox::rename(Item *item)
// Telling the playlist to change it's name will emit a signal that // Telling the playlist to change it's name will emit a signal that
// is connected to Item::slotSetName(). // is connected to Item::slotSetName().
if(item->playlist()) if(item->playlist()) {
item->playlist()->setName(name); item->playlist()->setName(name);
viewMode()->queueRefresh();
}
sort(); sort();
setSelected(item, true); setSelected(item, true);
......
...@@ -32,7 +32,8 @@ ...@@ -32,7 +32,8 @@
ViewMode::ViewMode(PlaylistBox *b) : QObject(b), ViewMode::ViewMode(PlaylistBox *b) : QObject(b),
m_playlistBox(b), m_playlistBox(b),
m_visible(false) m_visible(false),
m_needsRefresh(false)
{ {
connect(this, SIGNAL(signalCreateSearchList(const PlaylistSearch &, const QString &, const QString &)), connect(this, SIGNAL(signalCreateSearchList(const PlaylistSearch &, const QString &, const QString &)),
b, SIGNAL(signalCreateSearchList(const PlaylistSearch &, const QString &, const QString &))); b, SIGNAL(signalCreateSearchList(const PlaylistSearch &, const QString &, const QString &)));
...@@ -53,6 +54,9 @@ void ViewMode::paintCell(PlaylistBox::Item *i, ...@@ -53,6 +54,9 @@ void ViewMode::paintCell(PlaylistBox::Item *i,
if(width < i->pixmap(column)->width()) if(width < i->pixmap(column)->width())
return; return;
if(m_needsRefresh)
updateHeights();
PlaylistBox::Item *item = static_cast<PlaylistBox::Item *>(i); PlaylistBox::Item *item = static_cast<PlaylistBox::Item *>(i);
QFontMetrics fm = painter->fontMetrics(); QFontMetrics fm = painter->fontMetrics();
...@@ -89,15 +93,15 @@ PlaylistBox::Item *ViewMode::createSearchItem(PlaylistBox *box, SearchPlaylist * ...@@ -89,15 +93,15 @@ PlaylistBox::Item *ViewMode::createSearchItem(PlaylistBox *box, SearchPlaylist *
bool ViewMode::eventFilter(QObject *watched, QEvent *e) bool ViewMode::eventFilter(QObject *watched, QEvent *e)
{ {
if(m_visible && if(m_visible && watched == m_playlistBox->viewport() && e->type() == QEvent::Resize) {
watched == m_playlistBox->viewport() &&
e->type() == QEvent::Resize)
{
QResizeEvent *re = static_cast<QResizeEvent *>(e); QResizeEvent *re = static_cast<QResizeEvent *>(e);
if(re->size().width() != re->oldSize().width()) if(re->size().width() != re->oldSize().width())
updateHeights(); m_needsRefresh = true;
} }
if(e->type() == QEvent::Hide)
m_needsRefresh = true;
return QObject::eventFilter(watched, e); return QObject::eventFilter(watched, e);
} }
...@@ -106,7 +110,7 @@ void ViewMode::setShown(bool shown) ...@@ -106,7 +110,7 @@ void ViewMode::setShown(bool shown)
m_visible = shown; m_visible = shown;
if(shown) { if(shown) {
updateIcons(32); updateIcons(32);
updateHeights(); m_needsRefresh = true;
} }
} }
...@@ -132,6 +136,8 @@ void ViewMode::updateHeights() ...@@ -132,6 +136,8 @@ void ViewMode::updateHeights()
i->setHeight(height); i->setHeight(height);
i->invalidateHeight(); i->invalidateHeight();
} }
m_needsRefresh = false;
} }
QStringList ViewMode::lines(const PlaylistBox::Item *item, QStringList ViewMode::lines(const PlaylistBox::Item *item,
......
...@@ -53,6 +53,9 @@ public: ...@@ -53,6 +53,9 @@ public:
virtual bool eventFilter(QObject *watched, QEvent *e); virtual bool eventFilter(QObject *watched, QEvent *e);
void queueRefresh() { m_needsRefresh = true; }
protected: protected:
PlaylistBox *playlistBox() const { return m_playlistBox; } PlaylistBox *playlistBox() const { return m_playlistBox; }
bool visible() const { return m_visible; } bool visible() const { return m_visible; }
...@@ -72,6 +75,7 @@ private: ...@@ -72,6 +75,7 @@ private:
PlaylistBox *m_playlistBox; PlaylistBox *m_playlistBox;
bool m_visible; bool m_visible;
bool m_needsRefresh;
QMap<PlaylistBox::Item *, QStringList> m_lines; QMap<PlaylistBox::Item *, QStringList> m_lines;
}; };
......
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