added a small fileinfo dialog to the playlistwidget

This commit is contained in:
Thomas Frauendorfer 2008-02-14 20:21:13 +01:00
parent 0369b3aa37
commit 8dc34b1759
9 changed files with 406 additions and 6 deletions

View file

@ -1,10 +1,13 @@
HEADERS += playlistchooser.h \
HEADERS += entryinfo.h \
playlistchooser.h \
urlopen.h
SOURCES += playlistchooser.cpp \
SOURCES += entryinfo.cpp \
playlistchooser.cpp \
urlopen.cpp
FORMS += playlistchooser.ui \
FORMS += entryinfo.ui \
playlistchooser.ui \
urlopen.ui
INCLUDEPATH += $$PWD

84
src/dialogs/entryinfo.cpp Normal file
View file

@ -0,0 +1,84 @@
/**
* This file is a part of promoe, an XMMS2 client
*
* Copyright (C) 2008 Thomas Frauendorfer
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "xclientcache.h"
#include "entryinfo.h"
#include <QHash>
#include <QString>
#include <QVariant>
EntryInfo::EntryInfo (QWidget *paren, XClientCache *cache, uint32_t id)
{
setupUi (this);
setAttribute (Qt::WA_DeleteOnClose);
m_cache = cache;
m_id = id;
connect (cache, SIGNAL (entryChanged (uint32_t)),
this, SLOT (mlib_entry_changed (uint32_t)));
connect (cache, SIGNAL (entryRemoved (uint32_t)),
this, SLOT (mlib_entry_removed (uint32_t)));
getInfo ();
}
void
EntryInfo::getInfo ()
{
QHash<QString, QVariant> tmp = m_cache->get_info (m_id);
//FIXME "url" value ist wrong. tight be an error in clientcache
filenameEdit->setText (tmp.value ("url").toString ());
titleEdit->setText (tmp.value ("title").toString ());
artistEdit->setText (tmp.value ("artist").toString ());
albumEdit->setText (tmp.value ("album").toString ());
// commentEdit->setText ();
yearEdit->setText (tmp.value ("date").toString ());
trackEdit->setText (tmp.value ("tracknr").toString ());
genreEdit->setText (tmp.value ("genre").toString ());
}
void
EntryInfo::setId (uint32_t id)
{
m_id = id;
getInfo ();
}
void
EntryInfo::mlib_entry_changed (uint32_t id)
{
if (id == m_id) {
// the metadata for the current entry changed,
// so we update the dialog to display the current values
// TODO: think of a good way to handle changed values as soon as
// we allow editing of metadata
getInfo ();
}
}
void
EntryInfo::mlib_entry_removed (uint32_t id)
{
// if the mlib no longer contains our item, we have to remove it
if (id == m_id) {
close ();
}
}

46
src/dialogs/entryinfo.h Normal file
View file

@ -0,0 +1,46 @@
/**
* This file is a part of Promoe, an XMMS2 client
*
* Copyright (C) 2008 Thomas Frauendorfer
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef __ENTRYINFO_H__
#define __ENTRYINFO_H__
#include "ui_entryinfo.h"
#include <QDialog>
class XClientCache;
class EntryInfo : public QDialog, private Ui::EntryInfo {
Q_OBJECT
public:
EntryInfo (QWidget *parent, XClientCache *cache, uint32_t id = 0);
public slots:
void setId (uint32_t id);
private slots:
void mlib_entry_changed (uint32_t id);
void mlib_entry_removed (uint32_t id);
private:
void getInfo ();
uint32_t m_id;
XClientCache *m_cache;
};
#endif

224
src/dialogs/entryinfo.ui Normal file
View file

@ -0,0 +1,224 @@
<ui version="4.0" >
<class>EntryInfo</class>
<widget class="QDialog" name="EntryInfo" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>426</width>
<height>357</height>
</rect>
</property>
<property name="windowTitle" >
<string>Dialog</string>
</property>
<layout class="QVBoxLayout" >
<item>
<layout class="QHBoxLayout" >
<item>
<widget class="QLabel" name="filenameLabel" >
<property name="text" >
<string>Filename:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="filenameEdit" >
<property name="readOnly" >
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="idBox" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title" >
<string>ID Tag:</string>
</property>
<layout class="QGridLayout" >
<item row="0" column="0" >
<widget class="QLabel" name="titleLabel" >
<property name="text" >
<string>Title:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1" colspan="3" >
<widget class="QLineEdit" name="titleEdit" >
<property name="readOnly" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="artistLabel" >
<property name="text" >
<string>Artist:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1" colspan="3" >
<widget class="QLineEdit" name="artistEdit" >
<property name="readOnly" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="albumLabel" >
<property name="text" >
<string>Album:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="1" colspan="3" >
<widget class="QLineEdit" name="albumEdit" >
<property name="readOnly" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="3" column="0" >
<widget class="QLabel" name="commentLabel" >
<property name="text" >
<string>Comment:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="1" colspan="3" >
<widget class="QLineEdit" name="commentEdit" >
<property name="readOnly" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0" >
<widget class="QLabel" name="yearLabel" >
<property name="text" >
<string>Year:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="1" >
<widget class="QLineEdit" name="yearEdit" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize" >
<size>
<width>80</width>
<height>16777215</height>
</size>
</property>
<property name="readOnly" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="2" >
<widget class="QLabel" name="trackLabel" >
<property name="text" >
<string>Track Number:</string>
</property>
</widget>
</item>
<item row="4" column="3" >
<widget class="QLineEdit" name="trackEdit" >
<property name="readOnly" >
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0" >
<widget class="QLabel" name="genreLabel" >
<property name="text" >
<string>Genre:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="5" column="1" colspan="3" >
<widget class="QLineEdit" name="genreEdit" >
<property name="readOnly" >
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Close</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>EntryInfo</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel" >
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>EntryInfo</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel" >
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View file

@ -256,7 +256,6 @@ MainDisplay::SetupToggleButtons (void)
m_repeat->move(210, 89);
connect (m_repeat, SIGNAL (clicked (bool)),
this, SLOT (setRepeatAllEnabled (bool)));
//m_repeat->setEnabled(false); // FIXME: Disabled button for now, not yet implemented
}

View file

@ -23,6 +23,7 @@
#include "playlistmodel.h"
#include "playlistwidget.h"
#include "Skin.h"
#include "entryinfo.h"
#include <QColor>
#include <QMenu>
@ -142,6 +143,9 @@ PlaylistView::PlaylistView (QWidget *parent) : QListView (parent)
connect (&xmmsh, SIGNAL(playbackStatusChanged(Xmms::Playback::Status)),
this, SLOT(handleStatus(Xmms::Playback::Status)));
connect (this, SIGNAL (clicked (QModelIndex)),
this, SLOT (on_item_clicked (QModelIndex)));
}
void
@ -182,7 +186,7 @@ PlaylistView::contextMenuEvent (QContextMenuEvent *e)
a = new QAction (tr ("Show file info"), this);
a->setShortcut (tr ("Ctrl+Enter"));
a->setEnabled(false); // FIXME: Disabled for now
connect (a, SIGNAL (triggered ()), this, SLOT (showEntryInfo ()));
qm.addAction (a);
qm.addSeparator ();
@ -278,3 +282,33 @@ PlaylistView::mouseDoubleClickEvent (QMouseEvent *event)
xmmsh.xplayback ()->play ();
}
}
void
PlaylistView::showEntryInfo (void)
{
XMMSHandler &client = XMMSHandler::getInstance ();
QModelIndex current = selectionModel ()->currentIndex ();
if (current.isValid ()) {
uint32_t id = model ()->data (current, PlaylistModel::MedialibIdRole)
.toUInt ();
// If no infodialog exists, create one, else set the selected Item as
// displayed item
if (!m_entry_info) {
m_entry_info = new EntryInfo (this, client.cache (), id);
} else {
m_entry_info->raise ();
m_entry_info->setId (id);
}
m_entry_info->show ();
}
}
void
PlaylistView::on_item_clicked (QModelIndex index)
{
if (m_entry_info) {
uint32_t id = model ()->data (index, PlaylistModel::MedialibIdRole)
.toUInt ();
m_entry_info->setId (id);
}
}

View file

@ -19,12 +19,15 @@
//include "Playlist.h"
#include <xmmsclient/xmmsclient++.h>
#include <entryinfo.h>
class Skin;
#include <QObject>
#include <QAbstractItemDelegate>
#include <QListView>
#include <QPointer>
class QWidget;
class QModelIndex;
class PlaylistDelegate : public QAbstractItemDelegate {
Q_OBJECT
@ -57,12 +60,16 @@ class PlaylistView : public QListView {
void invertSelection (void);
void cropSelected (void);
void removeSelected (void);
void showEntryInfo (void);
void settingsSaved (void);
void setPixmaps (Skin *skin);
protected:
void mouseDoubleClickEvent (QMouseEvent *event);
private slots:
void on_item_clicked (QModelIndex index);
private:
Xmms::Playback::Status m_status;
QFont *m_font;
@ -71,6 +78,7 @@ class PlaylistView : public QListView {
QColor m_color_selected;
QColor m_color_normal;
QColor m_color_normal_bg;
QPointer<EntryInfo> m_entry_info;
};

View file

@ -273,6 +273,8 @@ PlaylistWidget::addButtons (void)
Skin::PLS_MSC_SRT_1);
b = new PlaylistMenuButton (m_msc, Skin::PLS_MSC_INF_0,
Skin::PLS_MSC_INF_1);
connect (b, SIGNAL (activated ()),
m_view, SLOT (showEntryInfo ()));
b = new PlaylistMenuButton (m_msc, Skin::PLS_MSC_OPT_0,
Skin::PLS_MSC_OPT_1);
/* playlist menu */