implement tooltip in playlist view

parent 4fa7321f
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <KLocalizedString> #include <KLocalizedString>
#include "k3bexporter.h" #include "k3bexporter.h"
#include <QFileInfo> #include <QFileInfo>
#include <QToolTip>
#include "coverinfo.h" #include "coverinfo.h"
using namespace ActionCollection; using namespace ActionCollection;
...@@ -110,54 +111,22 @@ void PlaylistView::contextMenuEvent(QContextMenuEvent *event) ...@@ -110,54 +111,22 @@ void PlaylistView::contextMenuEvent(QContextMenuEvent *event)
m_contextMenu->exec(event->globalPos()); m_contextMenu->exec(event->globalPos());
} }
bool PlaylistView::event(QEvent *e)
{
if (e->type() == QEvent::ToolTip) {
QHelpEvent *event = static_cast<QHelpEvent*>(e);
int column = columnAt(event->x());
/** // A tooltip specialized to show full filenames over the file name column.
* A tooltip specialized to show full filenames over the file name column. if (column == Playlist::FileNameColumn) {
*/ QString text = playlist()->items()[indexAt(event->pos()).row()]->file().absFilePath();
// class PlaylistToolTip : public QToolTip QToolTip::showText(event->globalPos(), text);
// { return true;
// public: }// else if (column == Playlist::CoverColumn) { TODO
// PlaylistToolTip(QWidget *parent, Playlist *playlist) : }
// QToolTip(parent), m_playlist(playlist) {}
//
// virtual void maybeTip(const QPoint &p)
// {
// PlaylistItem *item = static_cast<PlaylistItem *>(m_playlist->itemAt(p));
//
// if(!item)
// return;
//
// QPoint contentsPosition = m_playlist->viewportToContents(p);
//
// int column = m_playlist->header()->sectionAt(contentsPosition.x());
//
// if(column == m_playlist->columnOffset() + PlaylistItem::FileNameColumn ||
// item->cachedWidths()[column] > m_playlist->columnWidth(column) ||
// (column == m_playlist->columnOffset() + PlaylistItem::CoverColumn &&
// item->file().coverInfo()->hasCover()))
// {
// QRect r = m_playlist->itemRect(item);
// int headerPosition = m_playlist->header()->sectionPos(column);
// r.setLeft(headerPosition);
// r.setRight(headerPosition + m_playlist->header()->sectionSize(column));
//
// if(column == m_playlist->columnOffset() + PlaylistItem::FileNameColumn)
// tip(r, item->file().absFilePath());
// else if(column == m_playlist->columnOffset() + PlaylistItem::CoverColumn) {
// Q3MimeSourceFactory *f = Q3MimeSourceFactory::defaultFactory();
// f->setImage("coverThumb",
// QImage(item->file().coverInfo()->pixmap(CoverInfo::Thumbnail).convertToImage()));
// tip(r, "<center><img source=\"coverThumb\"/></center>");
// }
// else
// tip(r, item->text(column));
// }
// }
//
// private:
// Playlist *m_playlist;
// };
return QAbstractItemView::event(e);
}
//### TODO: VIEW //### TODO: VIEW
/** /**
......
...@@ -13,6 +13,7 @@ public: ...@@ -13,6 +13,7 @@ public:
protected slots: protected slots:
virtual void contextMenuEvent(QContextMenuEvent*); virtual void contextMenuEvent(QContextMenuEvent*);
virtual bool event(QEvent*);
private: private:
Playlist *playlist() { return qobject_cast<Playlist*>(model()); } Playlist *playlist() { return qobject_cast<Playlist*>(model()); }
......
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