Permalink
Browse files

MythMusic: Convert to MythUI and remove the last of the Qt3 stuff

This is far from complete and is subject to change but it's a start.
  • Loading branch information...
1 parent 8e9d2a0 commit 8e29824366e2957a0b9764d0e9abbfb850d80287 Paul Harrison committed Jan 4, 2012
Showing with 5,462 additions and 9,418 deletions.
  1. +141 −168 mythplugins/mythmusic/mythmusic/bumpscope.cpp
  2. +29 −34 mythplugins/mythmusic/mythmusic/bumpscope.h
  3. +0 −1,373 mythplugins/mythmusic/mythmusic/databasebox.cpp
  4. +0 −121 mythplugins/mythmusic/mythmusic/databasebox.h
  5. +17 −7 mythplugins/mythmusic/mythmusic/decoderhandler.cpp
  6. +30 −27 mythplugins/mythmusic/mythmusic/editmetadata.cpp
  7. +0 −4 mythplugins/mythmusic/mythmusic/editmetadata.h
  8. +2 −4 mythplugins/mythmusic/mythmusic/filescanner.cpp
  9. +9 −391 mythplugins/mythmusic/mythmusic/globalsettings.cpp
  10. +0 −44 mythplugins/mythmusic/mythmusic/globalsettings.h
  11. +36 −59 mythplugins/mythmusic/mythmusic/goom/mythgoom.cpp
  12. +4 −11 mythplugins/mythmusic/mythmusic/goom/mythgoom.h
  13. +1 −1 mythplugins/mythmusic/mythmusic/importmusic.cpp
  14. +0 −381 mythplugins/mythmusic/mythmusic/libvisualplugin.cpp
  15. +0 −52 mythplugins/mythmusic/mythmusic/libvisualplugin.h
  16. +45 −20 mythplugins/mythmusic/mythmusic/main.cpp
  17. +101 −809 mythplugins/mythmusic/mythmusic/mainvisual.cpp
  18. +30 −173 mythplugins/mythmusic/mythmusic/mainvisual.h
  19. +108 −403 mythplugins/mythmusic/mythmusic/metadata.cpp
  20. +40 −107 mythplugins/mythmusic/mythmusic/metadata.h
  21. +2 −2 mythplugins/mythmusic/mythmusic/metaio.cpp
  22. +1 −1 mythplugins/mythmusic/mythmusic/metaioavfcomment.cpp
  23. +25 −23 mythplugins/mythmusic/mythmusic/metaioflacvorbis.cpp
  24. +56 −23 mythplugins/mythmusic/mythmusic/metaioid3.cpp
  25. +15 −14 mythplugins/mythmusic/mythmusic/metaiooggvorbis.cpp
  26. +4 −11 mythplugins/mythmusic/mythmusic/metaiotaglib.cpp
  27. +15 −13 mythplugins/mythmusic/mythmusic/metaiowavpack.cpp
  28. +4 −0 mythplugins/mythmusic/mythmusic/miniplayer.cpp
  29. +1 −1 mythplugins/mythmusic/mythmusic/miniplayer.h
  30. +1,176 −175 mythplugins/mythmusic/mythmusic/musiccommon.cpp
  31. +77 −19 mythplugins/mythmusic/mythmusic/musiccommon.h
  32. +456 −216 mythplugins/mythmusic/mythmusic/musicplayer.cpp
  33. +59 −27 mythplugins/mythmusic/mythmusic/musicplayer.h
  34. +133 −0 mythplugins/mythmusic/mythmusic/musicutils.cpp
  35. +16 −0 mythplugins/mythmusic/mythmusic/musicutils.h
  36. +0 −206 mythplugins/mythmusic/mythmusic/mythlistbox-qt3.cpp
  37. +0 −39 mythplugins/mythmusic/mythmusic/mythlistbox-qt3.h
  38. +0 −100 mythplugins/mythmusic/mythmusic/mythlistview-qt3.cpp
  39. +0 −19 mythplugins/mythmusic/mythmusic/mythlistview-qt3.h
  40. +19 −17 mythplugins/mythmusic/mythmusic/mythmusic.pro
  41. +0 −2,589 mythplugins/mythmusic/mythmusic/playbackbox.cpp
  42. +0 −229 mythplugins/mythmusic/mythmusic/playbackbox.h
  43. +620 −817 mythplugins/mythmusic/mythmusic/playlist.cpp
  44. +50 −100 mythplugins/mythmusic/mythmusic/playlist.h
  45. +53 −194 mythplugins/mythmusic/mythmusic/playlistcontainer.cpp
  46. +14 −15 mythplugins/mythmusic/mythmusic/playlistcontainer.h
  47. +1,161 −0 mythplugins/mythmusic/mythmusic/playlisteditorview.cpp
  48. +110 −0 mythplugins/mythmusic/mythmusic/playlisteditorview.h
  49. +101 −0 mythplugins/mythmusic/mythmusic/playlistview.cpp
  50. +34 −0 mythplugins/mythmusic/mythmusic/playlistview.h
  51. +48 −3 mythplugins/mythmusic/mythmusic/pls.cpp
  52. +19 −3 mythplugins/mythmusic/mythmusic/pls.h
  53. +0 −292 mythplugins/mythmusic/mythmusic/search.cpp
  54. +0 −53 mythplugins/mythmusic/mythmusic/search.h
  55. +465 −0 mythplugins/mythmusic/mythmusic/searchview.cpp
  56. +49 −0 mythplugins/mythmusic/mythmusic/searchview.h
  57. +86 −28 mythplugins/mythmusic/mythmusic/shoutcast.cpp
Sorry, we could not display the entire diff because it was too big.
View
309 mythplugins/mythmusic/mythmusic/bumpscope.cpp
@@ -8,8 +8,6 @@
// Bump Scope - Visualization Plugin for XMMS
// Copyright (C) 1999-2001 Zinx Verituse
-#ifdef SDL_SUPPORT
-
#include <cmath>
#include <cstdlib>
@@ -18,97 +16,83 @@ using namespace std;
#include <QPainter>
-BumpScope::BumpScope(long int winid) :
- size(0,0),
+BumpScope::BumpScope() :
+ m_image(NULL),
- surface(NULL),
+ m_size(0,0),
- m_color(0x7ACCFF),
+ m_color(0x2050FF),
m_x(0), m_y(0), m_width(800), m_height(600),
m_phongrad(800),
- color_cycle(true),
- moving_light(true),
- diamond(false),
+ m_color_cycle(true),
+ m_moving_light(true),
+ m_diamond(true),
- bpl(0),
+ m_bpl(0),
- rgb_buf(NULL),
+ m_rgb_buf(NULL),
- iangle(0), ixo(0), iyo(0), ixd(0), iyd(0), ilx(0), ily(0),
- was_moving(0), was_color(0),
- ih(0.0), is(0.0), iv(0.0), isd(0.0), ihd(0),
- icolor(0)
+ m_iangle(0), m_ixo(0), m_iyo(0), m_ixd(0), m_iyd(0), m_ilx(0), m_ily(0),
+ m_was_moving(0), m_was_color(0),
+ m_ih(0.0), m_is(0.0), m_iv(0.0), m_isd(0.0), m_ihd(0),
+ m_icolor(0)
{
- fps = 15;
+ m_fps = 15;
for (unsigned int i = 255; i > 0; i--)
{
- intense1[i] = cos(((double)(255 - i) * M_PI) / 512.0);
- intense2[i] = pow(intense1[i], 250) * 150;
- }
- intense1[0] = intense1[1];
- intense2[0] = intense2[1];
-
- static char SDL_windowhack[32];
- sprintf(SDL_windowhack, "SDL_WINDOWID=%ld", winid);
- putenv(SDL_windowhack);
-
- if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0)
- {
- LOG(VB_GENERAL, LOG_ERR, "Unable to init SDL");
- return;
+ m_intense1[i] = cos(((double)(255 - i) * M_PI) / 512.0);
+ m_intense2[i] = pow(m_intense1[i], 250) * 150;
}
-
- SDL_ShowCursor(0);
+ m_intense1[0] = m_intense1[1];
+ m_intense2[0] = m_intense2[1];
}
BumpScope::~BumpScope()
{
- if (rgb_buf)
- delete [] rgb_buf;
+ if (m_rgb_buf)
+ delete [] m_rgb_buf;
- for (unsigned int i = 0; i < phongdat.size(); i++)
- phongdat[i].resize(0);
- phongdat.resize(0);
+ if (m_image)
+ delete m_image;
- SDL_Quit();
+ for (unsigned int i = 0; i < m_phongdat.size(); i++)
+ m_phongdat[i].resize(0);
+ m_phongdat.resize(0);
}
void BumpScope::resize(const QSize &newsize)
{
- size = newsize;
+ m_size = newsize;
- size.setHeight((size.height() / 2) * 2);
- size.setWidth((size.width() / 4) * 4);
+ m_size.setHeight((m_size.height() / 2) * 2);
+ m_size.setWidth((m_size.width() / 4) * 4);
- if (rgb_buf)
- delete [] rgb_buf;
+ if (m_rgb_buf)
+ delete [] m_rgb_buf;
- int bufsize = (size.height() + 2) * (size.width() + 2);
+ int bufsize = (m_size.height() + 2) * (m_size.width() + 2);
- rgb_buf = new unsigned char[bufsize];
+ m_rgb_buf = new unsigned char[bufsize];
- bpl = size.width() + 2;
+ m_bpl = m_size.width() + 2;
- surface = SDL_SetVideoMode(size.width(), size.height(), 8, 0);
+ if (m_image)
+ delete m_image;
- if (!surface)
- {
- LOG(VB_GENERAL, LOG_ERR, "Couldn't get SDL surface");
- return;
- }
+ m_image = new QImage(m_size.width(), m_size.height(), QImage::Format_Indexed8);
- m_width = size.width();
- m_height = size.height();
+ m_width = m_size.width();
+ m_height = m_size.height();
m_phongrad = m_width;
m_x = m_width / 2;
m_y = m_height;
-
- phongdat.resize(m_phongrad * 2);
- for (unsigned int i = 0; i < phongdat.size(); i++)
- phongdat[i].resize(m_phongrad * 2);
+
+ m_phongdat.resize(m_phongrad * 2);
+ for (unsigned int i = 0; i < m_phongdat.size(); i++)
+ m_phongdat[i].resize(m_phongrad * 2);
generate_phongdat();
generate_cmap(m_color);
@@ -123,7 +107,7 @@ void BumpScope::blur_8(unsigned char *ptr, int w, int h, int bpl)
iptr = ptr + bpl + 1;
i = bpl * h;
-
+
while (i--)
{
sum = (iptr[-bpl] + iptr[-1] + iptr[1] + iptr[bpl]) >> 2;
@@ -135,37 +119,30 @@ void BumpScope::blur_8(unsigned char *ptr, int w, int h, int bpl)
void BumpScope::generate_cmap(unsigned int color)
{
- SDL_Color sdlPalette[256];
unsigned int i, red, blue, green, r, g, b;
- if (surface)
+ if (m_image)
{
red = (unsigned int)(color / 0x10000);
green = (unsigned int)((color % 0x10000) / 0x100);
blue = (unsigned int)(color % 0x100);
for (i = 255; i > 0; i--)
{
- r = (unsigned int)(((double)(100 * Qt::red / 255) * intense1[i] + intense2[i]));
+ r = (unsigned int)(((double)(100 * red / 255) * m_intense1[i] + m_intense2[i]));
if (r > 255)
r = 255;
- g = (unsigned int)(((double)(100 * Qt::green / 255) * intense1[i] + intense2[i]));
+ g = (unsigned int)(((double)(100 * green / 255) * m_intense1[i] + m_intense2[i]));
if (g > 255)
g = 255;
- b = (unsigned int)(((double)(100 * Qt::blue / 255) * intense1[i] + intense2[i]));
+ b = (unsigned int)(((double)(100 * blue / 255) * m_intense1[i] + m_intense2[i]));
if (b > 255)
b = 255;
- sdlPalette[i].r = r;
- sdlPalette[i].g = g;
- sdlPalette[i].b = b;
+ m_image->setColor(i, qRgba(r, g, b, 255));
}
- sdlPalette[0].r = sdlPalette[1].r;
- sdlPalette[0].g = sdlPalette[1].g;
- sdlPalette[0].b = sdlPalette[1].b;
-
- SDL_SetColors(surface, sdlPalette, 0, 256);
+ m_image->setColor(0, m_image->color(1));
}
}
@@ -183,14 +160,14 @@ void BumpScope::generate_phongdat(void)
i = (double)x / ((double)m_phongrad) - 1;
i2 = (double)y / ((double)m_phongrad) - 1;
- if (diamond)
+ if (m_diamond)
i = 1 - pow(i*i2,.75) - i*i - i2*i2;
else
i = 1 - i*i - i2*i2;
if (i >= 0)
{
- if (diamond)
+ if (m_diamond)
i = i*i*i * 255.0;
else
i = i*i*i * 255.0;
@@ -199,17 +176,17 @@ void BumpScope::generate_phongdat(void)
i = 255;
unsigned char uci = (unsigned char)i;
- phongdat[y][x] = uci;
- phongdat[(PHONGRES-1)-y][x] = uci;
- phongdat[y][(PHONGRES-1)-x] = uci;
- phongdat[(PHONGRES-1)-y][(PHONGRES-1)-x] = uci;
+ m_phongdat[y][x] = uci;
+ m_phongdat[(PHONGRES-1)-y][x] = uci;
+ m_phongdat[y][(PHONGRES-1)-x] = uci;
+ m_phongdat[(PHONGRES-1)-y][(PHONGRES-1)-x] = uci;
}
else
{
- phongdat[y][x] = 0;
- phongdat[(PHONGRES-1)-y][x] = 0;
- phongdat[y][(PHONGRES-1)-x] = 0;
- phongdat[(PHONGRES-1)-y][(PHONGRES-1)-x] = 0;
+ m_phongdat[y][x] = 0;
+ m_phongdat[(PHONGRES-1)-y][x] = 0;
+ m_phongdat[y][(PHONGRES-1)-x] = 0;
+ m_phongdat[(PHONGRES-1)-y][(PHONGRES-1)-x] = 0;
}
}
}
@@ -273,24 +250,24 @@ inline void BumpScope::draw_vert_line(unsigned char *buffer, int x, int y1,
if (y1 < y2)
{
- p = buffer + ((y1 + 1) * bpl) + x + 1;
+ p = buffer + ((y1 + 1) * m_bpl) + x + 1;
for (y = y1; y <= y2; y++)
{
*p = 0xff;
- p += bpl;
+ p += m_bpl;
}
}
else if (y2 < y1)
{
- p = buffer + ((y2 + 1) * bpl) + x + 1;
+ p = buffer + ((y2 + 1) * m_bpl) + x + 1;
for (y = y2; y <= y1; y++)
{
*p = 0xff;
- p += bpl;
+ p += m_bpl;
}
}
else
- buffer[((y1 + 1) * bpl) + x + 1] = 0xff;
+ buffer[((y1 + 1) * m_bpl) + x + 1] = 0xff;
}
void BumpScope::render_light(int lx, int ly)
@@ -299,18 +276,18 @@ void BumpScope::render_light(int lx, int ly)
unsigned int PHONGRES = m_phongrad * 2;
unsigned int i, j;
- prev_y = bpl + 1;
+ prev_y = m_bpl + 1;
out_y = 0;
- unsigned char *outputbuf = (unsigned char *)(surface->pixels);
+ unsigned char *outputbuf = (unsigned char *)(m_image->bits());
for (dy = (-ly) + (PHONGRES / 2), j = 0; j < m_height; j++, dy++,
- prev_y += bpl - m_width)
+ prev_y += m_bpl - m_width)
{
for (dx = (-lx) + (PHONGRES / 2), i = 0; i < m_width; i++, dx++,
prev_y++, out_y++)
{
- xp = (rgb_buf[prev_y - 1] - rgb_buf[prev_y + 1]) + dx;
- yp = (rgb_buf[prev_y - bpl] - rgb_buf[prev_y + bpl]) + dy;
+ xp = (m_rgb_buf[prev_y - 1] - m_rgb_buf[prev_y + 1]) + dx;
+ yp = (m_rgb_buf[prev_y - m_bpl] - m_rgb_buf[prev_y + m_bpl]) + dy;
if (yp < 0 || yp >= (int)PHONGRES ||
xp < 0 || xp >= (int)PHONGRES)
@@ -319,7 +296,7 @@ void BumpScope::render_light(int lx, int ly)
continue;
}
- outputbuf[out_y] = phongdat[yp][xp];
+ outputbuf[out_y] = m_phongdat[yp][xp];
}
}
}
@@ -399,8 +376,8 @@ void BumpScope::hsv_to_rgb(double h, double s, double v, unsigned int *color)
bool BumpScope::process(VisualNode *node)
{
- if (!node || node->length == 0 || !surface)
- return true;
+ if (!node || node->length == 0 || !m_image)
+ return false;
int numSamps = 512;
if (node->length < 512)
@@ -427,157 +404,155 @@ bool BumpScope::process(VisualNode *node)
if (y >= (int)m_height)
y = m_height - 1;
- draw_vert_line(rgb_buf, i, prev_y, y);
+ draw_vert_line(m_rgb_buf, i, prev_y, y);
prev_y = y;
}
- blur_8(rgb_buf, m_width, m_height, bpl);
+ blur_8(m_rgb_buf, m_width, m_height, m_bpl);
+
return false;
}
bool BumpScope::draw(QPainter *p, const QColor &back)
{
- (void)p;
- (void)back;
-
- if (!surface)
+ if (!m_image || m_image->isNull())
{
- LOG(VB_GENERAL, LOG_ERR, "No sdl surface");
+ LOG(VB_GENERAL, LOG_ERR, "BumpScope::draw: Bad image");
return false;
}
- ilx = m_x;
- ily = m_y;
+ m_ilx = m_x;
+ m_ily = m_y;
- if (moving_light)
+ if (m_moving_light)
{
- if (!was_moving)
+ if (!m_was_moving)
{
- translate(ilx, ily, &ixo, &iyo, &ixd, &iyd, &iangle);
- was_moving = 1;
+ translate(m_ilx, m_ily, &m_ixo, &m_iyo, &m_ixd, &m_iyd, &m_iangle);
+ m_was_moving = 1;
}
+
+ m_ilx = (int)(m_width / 2 + cos(m_iangle * (M_PI / 180.0)) * m_ixo);
+ m_ily = (int)(m_height / 2 + sin(m_iangle * (M_PI / 180.0)) * m_iyo);
- ilx = (int)(m_width / 2 + cos(iangle * (M_PI / 180.0)) * ixo);
- ily = (int)(m_height / 2 + sin(iangle * (M_PI / 180.0)) * iyo);
-
- iangle += 2;
- if (iangle >= 360)
- iangle = 0;
+ m_iangle += 2;
+ if (m_iangle >= 360)
+ m_iangle = 0;
- ixo += ixd;
- if ((int)ixo > ((int)m_width / 2) || (int)ixo < -((int)m_width / 2))
+ m_ixo += m_ixd;
+ if ((int)m_ixo > ((int)m_width / 2) || (int)m_ixo < -((int)m_width / 2))
{
- ixo = (ixo > 0) ? (m_width / 2) : -(m_width / 2);
+ m_ixo = (m_ixo > 0) ? (m_width / 2) : -(m_width / 2);
if (random() & 1)
{
- ixd = (ixd > 0) ? -1 : 1;
- iyd = 0;
+ m_ixd = (m_ixd > 0) ? -1 : 1;
+ m_iyd = 0;
}
else
{
- iyd = (iyd > 0) ? -1 : 1;
- ixd = 0;
+ m_iyd = (m_iyd > 0) ? -1 : 1;
+ m_ixd = 0;
}
}
- iyo += iyd;
- if ((int)iyo > ((int)m_height / 2) || (int)iyo < -((int)m_height / 2))
+ m_iyo += m_iyd;
+ if ((int)m_iyo > ((int)m_height / 2) || (int)m_iyo < -((int)m_height / 2))
{
- iyo = (iyo > 0) ? (m_height / 2) : -(m_height / 2);
+ m_iyo = (m_iyo > 0) ? (m_height / 2) : -(m_height / 2);
if (random() & 1)
{
- ixd = (ixd > 0) ? -1 : 1;
- iyd = 0;
+ m_ixd = (m_ixd > 0) ? -1 : 1;
+ m_iyd = 0;
}
else
{
- iyd = (iyd > 0) ? -1 : 1;
- ixd = 0;
+ m_iyd = (m_iyd > 0) ? -1 : 1;
+ m_ixd = 0;
}
}
}
- if (color_cycle)
+ if (m_color_cycle)
{
- if (!was_color)
+ if (!m_was_color)
{
- rgb_to_hsv(m_color, &ih, &is, &iv);
- was_color = 1;
+ rgb_to_hsv(m_color, &m_ih, &m_is, &m_iv);
+ m_was_color = 1;
if (random() & 1)
{
- ihd = (random() & 1) * 2 - 1;
- isd = 0;
+ m_ihd = (random() & 1) * 2 - 1;
+ m_isd = 0;
}
else
{
- isd = 0.01 * ((random() & 1) * 2 - 1);
- ihd = 0;
+ m_isd = 0.01 * ((random() & 1) * 2 - 1);
+ m_ihd = 0;
}
}
- hsv_to_rgb(ih, is, iv, &icolor);
+ hsv_to_rgb(m_ih, m_is, m_iv, &m_icolor);
- generate_cmap(icolor);
+ generate_cmap(m_icolor);
- if (ihd)
+ if (m_ihd)
{
- ih += ihd;
- if (ih >= 360)
- ih = 0;
- if (ih < 0)
- ih = 359;
+ m_ih += m_ihd;
+ if (m_ih >= 360)
+ m_ih = 0;
+ if (m_ih < 0)
+ m_ih = 359;
if ((random() % 150) == 0)
{
if (random() & 1)
{
- ihd = (random() & 1) * 2 - 1;
- isd = 0;
+ m_ihd = (random() & 1) * 2 - 1;
+ m_isd = 0;
}
else
{
- isd = 0.01 * ((random() & 1) * 2 - 1);
- ihd = 0;
+ m_isd = 0.01 * ((random() & 1) * 2 - 1);
+ m_ihd = 0;
}
}
}
else
{
- is += isd;
+ m_is += m_isd;
- if (is <= 0 || is >= 0.5)
+ if (m_is <= 0 || m_is >= 0.5)
{
- if (is < 0)
- is = 0;
- if (is > 0.52)
- isd = -0.01;
- else if (is == 0)
+ if (m_is < 0)
+ m_is = 0;
+ if (m_is > 0.52)
+ m_isd = -0.01;
+ else if (m_is == 0)
{
- ihd = random() % 360;
- isd = 0.01;
+ m_ihd = random() % 360;
+ m_isd = 0.01;
}
else
{
if (random() & 1)
{
- ihd = (random() & 1) * 2 - 1;
- isd = 0;
+ m_ihd = (random() & 1) * 2 - 1;
+ m_isd = 0;
}
else
{
- isd = 0.01 * ((random() & 1) * 2 - 1);
- ihd = 0;
+ m_isd = 0.01 * ((random() & 1) * 2 - 1);
+ m_ihd = 0;
}
}
}
}
}
- render_light(ilx, ily);
+ render_light(m_ilx, m_ily);
- SDL_UpdateRect(surface, 0, 0, 0, 0);
+ p->drawImage(0, 0, *m_image);
- return false;
+ return true;
}
static class BumpScopeFactory : public VisFactory
@@ -595,12 +570,10 @@ static class BumpScopeFactory : public VisFactory
return 1;
}
- VisualBase *create(MainVisual *parent, long int winid, const QString &pluginName) const
+ VisualBase *create(MainVisual *parent, const QString &pluginName) const
{
(void)parent;
(void)pluginName;
- return new BumpScope(winid);
+ return new BumpScope();
}
}BumpScopeFactory;
-
-#endif
View
63 mythplugins/mythmusic/mythmusic/bumpscope.h
@@ -7,15 +7,12 @@
#include <vector>
using namespace std;
-#ifdef SDL_SUPPORT
-#include <SDL.h>
-
#define MAX_PHONGRES 1024
class BumpScope : public VisualBase
{
public:
- BumpScope(long int winid);
+ BumpScope();
virtual ~BumpScope();
void resize(const QSize &size);
@@ -38,9 +35,9 @@ class BumpScope : public VisualBase
void rgb_to_hsv(unsigned int color, double *h, double *s, double *v);
void hsv_to_rgb(double h, double s, double v, unsigned int *color);
- QSize size;
+ QImage *m_image;
- SDL_Surface *surface;
+ QSize m_size;
unsigned int m_color;
unsigned int m_x;
@@ -49,35 +46,33 @@ class BumpScope : public VisualBase
unsigned int m_height;
unsigned int m_phongrad;
- bool color_cycle;
- bool moving_light;
- bool diamond;
-
- int bpl;
-
- vector<vector<unsigned char> > phongdat;
- unsigned char *rgb_buf;
- double intense1[256];
- double intense2[256];
-
- int iangle;
- int ixo;
- int iyo;
- int ixd;
- int iyd;
- int ilx;
- int ily;
- int was_moving;
- int was_color;
- double ih;
- double is;
- double iv;
- double isd;
- int ihd;
- unsigned int icolor;
+ bool m_color_cycle;
+ bool m_moving_light;
+ bool m_diamond;
+
+ int m_bpl;
+
+ vector<vector<unsigned char> > m_phongdat;
+ unsigned char *m_rgb_buf;
+ double m_intense1[256];
+ double m_intense2[256];
+
+ int m_iangle;
+ int m_ixo;
+ int m_iyo;
+ int m_ixd;
+ int m_iyd;
+ int m_ilx;
+ int m_ily;
+ int m_was_moving;
+ int m_was_color;
+ double m_ih;
+ double m_is;
+ double m_iv;
+ double m_isd;
+ int m_ihd;
+ unsigned int m_icolor;
};
#endif
-
-#endif // __mainvisual_h
View
1,373 mythplugins/mythmusic/mythmusic/databasebox.cpp
@@ -1,1373 +0,0 @@
-// C
-#include <cstdlib>
-
-// C++
-#include <iostream>
-using namespace std;
-
-// qt
-#include <QApplication>
-#include <QKeyEvent>
-#include <QRegExp>
-#include <QLayout>
-#include <QEvent>
-
-// mythtv
-#include <dialogbox.h>
-#include <mythcontext.h>
-#include <lcddevice.h>
-#include <uitypes.h>
-#include <uilistbtntype.h>
-#include <mythmediamonitor.h>
-#include <mythsystem.h>
-#include <exitcodes.h>
-#include "mythlogging.h"
-
-// mythmusic
-#include "metadata.h"
-#include "databasebox.h"
-#include "treecheckitem.h"
-#include "cddecoder.h"
-#include "playlistcontainer.h"
-#include "musicplayer.h"
-#ifndef USING_MINGW
-#include "cddecoder.h"
-#endif
-
-DatabaseBox::DatabaseBox(MythMainWindow *parent,
- const QString dev, const QString &window_name,
- const QString &theme_filename, const char *name)
- : MythThemedDialog(parent, window_name, theme_filename, name)
-{
- m_CDdevice = dev;
- active_playlist = NULL;
-
- if (!gMusicData->all_music)
- {
- LOG(VB_GENERAL, LOG_ERR, "We are not going to get very far with a null "
- "pointer to metadata");
- // TODO: is this OK?
- exit(0);
- }
-
- // Do we check the CD?
- cd_checking_flag = false;
- cd_checking_flag = gCoreContext->GetNumSetting("AutoLookupCD");
-
- QString treelev = gCoreContext->GetSetting("TreeLevels", "artist album title");
- QStringList treelevels = treelev.toLower().split(" ", QString::SkipEmptyParts);
-
- active_popup = NULL;
- active_pl_edit = NULL;
-
- playlist_popup = NULL;
-
- cditem = NULL;
- holding_track = false;
-
- tree = getUIListTreeType("musictree");
- if (!tree)
- {
- DialogBox *dlg = new DialogBox(
- GetMythMainWindow(),
- QObject::tr(
- "The theme you are using does not contain the "
- "%1 element. Please contact the theme creator "
- "and ask if they could please update it.<br><br>"
- "The next screen will be empty. "
- "Escape out of it to return to the menu.")
- .arg("'musictree'"));
-
- dlg->AddButton(tr("OK"));
- dlg->exec();
- dlg->deleteLater();
-
- return;
- }
-
- UITextType *line = NULL;
-
- for (int i = 1; i <= 6; i++)
- {
- QString linename = QString("line%1").arg(i);
- if ((line = getUITextType(linename)))
- m_lines.push_back(line);
- }
-
- if (m_lines.size() < 6)
- {
- DialogBox *dlg = new DialogBox(
- GetMythMainWindow(),
- tr("The theme you are using does not contain enough info "
- "lines in the music element. Please contact the theme "
- "creator and ask if they could please update it."));
-
- dlg->AddButton(tr("OK"));
- dlg->exec();
- dlg->deleteLater();
- }
-
- connect(tree, SIGNAL(itemEntered(UIListTreeType *, UIListGenericTree *)),
- this, SLOT(entered(UIListTreeType *, UIListGenericTree *)));
-
- // Make the first few nodes in the tree that everything else hangs off
- // as children
-
- rootNode = new UIListGenericTree(NULL, "Root Music Node");
-
- allmusic = new TreeCheckItem(rootNode, tr("All My Music"), "genre", 0);
- if (cd_checking_flag)
- cditem = new CDCheckItem(rootNode, tr("Blechy Blech Blah"), "cd", 0);
- alllists = new TreeCheckItem(rootNode, tr("All My Playlists"), "genre", 0);
- allcurrent = new PlaylistTitle(rootNode, tr("Active Play Queue"));
-
- tree->SetTree(rootNode);
-
- cd_reader_thread = NULL;
- if (cd_checking_flag)
- {
- // Start the CD checking thread, and set up a timer to make it check
- // occasionally
-
- cd_reader_thread = new ReadCDThread(m_CDdevice);
-
- // filling initialy before thread running
- fillCD();
-
- cd_reader_thread->start();
-
- cd_watcher = new QTimer(this);
- connect(cd_watcher, SIGNAL(timeout()), this, SLOT(occasionallyCheckCD()));
- cd_watcher->start(1000); // Every second?
- }
-
- // Set a timer to keep redoing the fillList stuff until the metadata and
- // playlist loading threads are done
-
- wait_counter = 0;
- numb_wait_dots = 0;
- fill_list_timer = new QTimer(this);
- connect(fill_list_timer, SIGNAL(timeout()), this, SLOT(keepFilling()));
- fill_list_timer->start(20);
-}
-
-DatabaseBox::~DatabaseBox()
-{
- if (cd_reader_thread)
- {
- cd_watcher->stop();
-
- cd_reader_thread->wait();
- delete cd_reader_thread;
- }
-
- gMusicData->all_music->cleanOutThreads();
- gMusicData->all_playlists->cleanOutThreads();
-
- gMusicData->all_music->resetListings();
-
- gMusicData->all_playlists->getActive()->removeAllWidgets();
- gMusicData->all_playlists->getActive()->fillSonglistFromSongs();
-
- if (LCD *lcd = LCD::Get())
- lcd->switchToTime();
-
- delete rootNode;
-
- gCoreContext->SaveSetting("MusicBookmark", "");
- gCoreContext->SaveSetting("MusicBookmarkPosition", 0);
-}
-
-void DatabaseBox::showWaiting()
-{
- wait_counter++;
- if (wait_counter > 10)
- {
- wait_counter = 0;
- ++numb_wait_dots;
- if (numb_wait_dots > 3)
- numb_wait_dots = 1;
-
- QString a_string = tr("All My Music ~ Loading Music Data ");
-
- if (LCD *lcd = LCD::Get())
- {
- // Set Loading Message on the LCD
- QList<LCDTextItem> textItems;
-
- textItems.append(LCDTextItem(1, ALIGN_CENTERED,
- tr("Loading Music Data"), "Generic", false));
- lcd->switchToGeneric(textItems);
- }
-
- for (int i = 0; i < numb_wait_dots; i++)
- a_string += ".";
-
- allmusic->setText(a_string);
- }
-}
-
-void DatabaseBox::keepFilling()
-{
- if (gMusicData->all_music->doneLoading() &&
- gMusicData->all_playlists->doneLoading())
- {
- // Good, now lets grab some QListItems
- if (gMusicData->all_music->putYourselfOnTheListView(allmusic))
- {
- allmusic->setText(tr("All My Music"));
- fill_list_timer->stop();
- gMusicData->all_playlists->setActiveWidget(allcurrent);
- active_playlist = gMusicData->all_playlists->getActive();
- active_playlist->putYourselfOnTheListView(allcurrent);
- gMusicData->all_playlists->showRelevantPlaylists(alllists);
- // XXX listview->ensureItemVisible(listview->currentItem());
- checkTree();
-
- // make sure we get rid of the 'Loading Music Data' message
- if (LCD *lcd = LCD::Get())
- lcd->switchToTime();
- }
- else
- showWaiting();
- }
- else
- showWaiting();
-}
-
-void DatabaseBox::occasionallyCheckCD()
-{
- if (!cd_reader_thread->getLock()->tryLock())
- return;
- cd_reader_thread->getLock()->unlock();
-
- if (cd_reader_thread->statusChanged())
- {
- if (active_playlist)
- {
- active_playlist->ripOutAllCDTracksNow();
- fillCD();
- }
- }
- if (!cd_reader_thread->isRunning())
- cd_reader_thread->start();
-}
-
-void DatabaseBox::copyNewPlaylist()
-{
- if (!active_popup)
- return;
-
- if (active_pl_edit->text().length() < 1)
- {
- closeActivePopup();
- return;
- }
-
- if (gMusicData->all_playlists->nameIsUnique(active_pl_edit->text(), 0))
- {
- gMusicData->all_playlists->copyNewPlaylist(active_pl_edit->text());
- gMusicData->all_playlists->showRelevantPlaylists(alllists);
- checkTree();
- closeActivePopup();
- }
- else
- {
- // Oh to beep
- }
-}
-
-
-void DatabaseBox::renamePlaylist()
-{
- if (!playlist_popup)
- return;
-
- if (playlist_rename->text().length() < 1)
- {
- closePlaylistPopup();
- return;
- }
-
- UIListGenericTree *item = tree->GetCurrentPosition();
-
- if (TreeCheckItem *rename_item = dynamic_cast<TreeCheckItem*>(item) )
- {
- if (rename_item->getID() < 0)
- {
- if (gMusicData->all_playlists->nameIsUnique(playlist_rename->text(),
- rename_item->getID() * -1))
- {
- gMusicData->all_playlists->renamePlaylist(rename_item->getID() * -1,
- playlist_rename->text());
- rename_item->setText(playlist_rename->text());
- tree->Redraw();
- closePlaylistPopup();
- }
- else
- {
- // I'd really like to beep at the user here
- }
- }
- else
- {
- LOG(VB_GENERAL, LOG_ERR, "Trying to rename something that doesn't "
- "seem to be a playlist");
- }
- }
-}
-
-void DatabaseBox::popBackPlaylist()
-{
- if (!active_popup)
- return;
-
- gMusicData->all_playlists->popBackPlaylist();
- gMusicData->all_playlists->showRelevantPlaylists(alllists);
- checkTree();
-
- closeActivePopup();
-}
-
-void DatabaseBox::clearActive()
-{
- if (!active_popup)
- return;
-
- closeActivePopup();
-
- gMusicData->all_playlists->clearActive();
- gMusicData->all_playlists->showRelevantPlaylists(alllists);
- checkTree();
-}
-
-void DatabaseBox::CreateCDAudio()
-{
- int error;
-
- if (!active_popup)
- return;
-
- closeActivePopup();
-
- // Begin CD Audio Creation
-
- error = active_playlist->CreateCDAudio();
-
- error_popup = NULL;
-
- if (error)
- ErrorPopup(tr("Couldn't create CD"));
- else
- ErrorPopup(tr("CD Created"));
-}
-
-void DatabaseBox::CreateCDMP3()
-{
- int error;
- if (!active_popup)
- return;
-
- closeActivePopup();
-
- // Begin MP3 Creation
-
- error = active_playlist->CreateCDMP3();
-
- error_popup=NULL;
-
- if (error)
- ErrorPopup(tr("Couldn't create CD"));
- else
- ErrorPopup(tr("CD Created"));
-}
-
-void DatabaseBox::ErrorPopup(const QString &msg)
-{
- if (error_popup)
- return;
-
- error_popup = new MythPopupBox(GetMythMainWindow(),
- "playlist_popup");
-
- error_popup->addLabel(msg);
-
- QAbstractButton *mac_b =error_popup->addButton(tr("OK"), this,
- SLOT(closeErrorPopup()));
-
- int x = (int)(100 * wmult);
- int y = (int)(100 * hmult);
-
- error_popup->ShowPopupAtXY(x, y, this, SLOT(closeErrorPopup()));
- mac_b->setFocus();
-}
-
-void DatabaseBox::closeErrorPopup(void)
-{
- if (!error_popup)
- return;
-
- error_popup->hide();
- error_popup->deleteLater();
- error_popup = NULL;
-}
-
-void DatabaseBox::BlankCDRW()
-{
- if (!active_popup)
- return;
-
- closeActivePopup();
-
- // Check & get global settings
- if (!gCoreContext->GetNumSetting("CDWriterEnabled"))
- {
- LOG(VB_GENERAL, LOG_ERR, "Writer is not enabled. We cannot be here!");
- return;
- }
-
- QString scsidev = MediaMonitor::defaultCDWriter();
- if (scsidev.isEmpty())
- {
- LOG(VB_GENERAL, LOG_ERR, "No CD Writer device defined.");
- return;
- }
-
- // Begin Blanking
- MythProgressDialog *record_progress;
- record_progress = new MythProgressDialog(tr("CD-RW Blanking Progress"), 10);
-
- // Run CD Record
- QString blanktype=gCoreContext->GetSetting("CDBlankType");
-
- record_progress->setProgress(1);
-
- QString cmd = QString("cdrecord -v dev=%1 -blank=%2")
- .arg(scsidev).arg(blanktype);
- uint flags = kMSRunShell | kMSDontBlockInputDevs | kMSDontDisableDrawing;
-
- if (myth_system(cmd, flags) != GENERIC_EXIT_OK)
- {
- LOG(VB_GENERAL, LOG_ERR,
- QString("DatabaseBox::BlankCDRW() cmd: '%1' Failed!").arg(cmd));
- }
-
- record_progress->Close();
- record_progress->deleteLater();
-}
-
-void DatabaseBox::deletePlaylist()
-{
- if (!playlist_popup)
- return;
-
- // Delete currently selected
-
- closePlaylistPopup();
-
- UIListGenericTree *item = tree->GetCurrentPosition();
-
- if (TreeCheckItem *check_item = dynamic_cast<TreeCheckItem*>(item) )
- {
- if (check_item->getID() < 0)
- {
- if (check_item->nextSibling(1))
- tree->MoveDown();
- else if (check_item->prevSibling(1))
- tree->MoveUp();
-
- gMusicData->all_playlists->deletePlaylist(check_item->getID() * -1);
- //gMusicData->all_playlists->showRelevantPlaylists(alllists);
- item->RemoveFromParent();
- //delete item; will be deleted by generic tree
- gMusicData->all_playlists->refreshRelevantPlaylists(alllists);
- checkTree();
- return;
- }
- }
-
- LOG(VB_GENERAL, LOG_ERR, "deletePlaylist() - Playlist popup on a "
- "non-playlist item");
-}
-
-
-void DatabaseBox::copyToActive()
-{
- if (!playlist_popup)
- return;
-
- closePlaylistPopup();
-
- UIListGenericTree *item = tree->GetCurrentPosition();
-
- if (TreeCheckItem *check_item = dynamic_cast<TreeCheckItem*>(item) )
- {
- if (check_item->getID() < 0)
- {
- gMusicData->all_playlists->copyToActive(check_item->getID() * -1);
- gMusicData->all_playlists->refreshRelevantPlaylists(alllists);
- tree->RefreshCurrentLevel();
- checkTree();
- // XXX listview->setCurrentItem(allcurrent);
- return;
- }
- }
- LOG(VB_GENERAL, LOG_ERR, "copyToActive() - Playlist popup on a "
- "non-playlist item");
-}
-
-
-void DatabaseBox::fillCD(void)
-{
- QMutexLocker locker(cd_reader_thread->getLock());
-
- if (cditem)
- {
-
- // Close leaf before delete if opened
-
- UIListGenericTree *curItem = tree->GetCurrentPosition();
- if (dynamic_cast<CDCheckItem*>(curItem))
- {
- int depth = curItem->calculateDepth(0);
- while(depth--)
- tree->MoveLeft();
- }
-
- // Delete anything that might be there
-
- while (cditem->childCount())
- {
- CDCheckItem *track_ptr =
- static_cast<CDCheckItem*>(cditem->getChildAt(0));
- track_ptr->RemoveFromParent();
- }
-
- // Put on whatever all_music tells us is there
-
- cditem->setText(gMusicData->all_music->getCDTitle());
- cditem->setCheck(0);
- cditem->setCheckable(false);
-
- gMusicData->all_music->putCDOnTheListView(cditem);
-
- // reflect selections in cd playlist
-
- GenericTree::iterator it;
- for (it = cditem->begin(); it != cditem->end(); ++it)
- {
- UIListGenericTree *uit = (UIListGenericTree*)(*it);
-
- if (CDCheckItem *track_ptr = dynamic_cast<CDCheckItem*>(uit))
- {
- track_ptr->setCheck(0);
- if (gMusicData->all_playlists->checkCDTrack(
- track_ptr->getID() * -1))
- {
- track_ptr->setCheck(2);
- }
- }
- }
-
- // Can't check what ain't there
-
- if (cditem->childCount() > 0)
- {
- cditem->setCheckable(true);
- cditem->setCheck(0);
- checkParent(cditem);
- }
-
- tree->Redraw();
- }
-}
-
-void DatabaseBox::doMenus(UIListGenericTree *item)
-{
- if (dynamic_cast<CDCheckItem*>(item))
- return;
- else if (TreeCheckItem *item_ptr = dynamic_cast<TreeCheckItem*>(item))
- {
- if (item_ptr->getID() < 0)
- doPlaylistPopup(item_ptr);
- }
- else if (PlaylistTitle *item_ptr = dynamic_cast<PlaylistTitle*>(item))
- doActivePopup(item_ptr);
-}
-
-void DatabaseBox::alternateDoMenus(UIListGenericTree *item, int keypad_number)
-{
- if (TreeCheckItem *item_ptr = dynamic_cast<TreeCheckItem*>(item))
- {
- bool is_cd = dynamic_cast<CDCheckItem*>(item) != 0;
- if (item_ptr->getID() < 0 && !is_cd)
- doPlaylistPopup(item_ptr);
- else if (item->getParent())
- {
- int a_number = item->getParent()->childCount();
- a_number = (int)(a_number * ( keypad_number / 10.0));
-
- tree->MoveUp(UIListTreeType::MoveMax);
- tree->MoveDown(a_number);
- }
- }
- else if (PlaylistTitle *item_ptr = dynamic_cast<PlaylistTitle*>(item))
- doActivePopup(item_ptr);
-}
-
-void DatabaseBox::entered(UIListTreeType *treetype, UIListGenericTree *item)
-{
- if (!item || !treetype)
- return;
-
- // Determin if this is a CD entry
- bool cd = false;
- if (dynamic_cast<CDCheckItem*>(item))
- cd = true;
-
- TreeCheckItem *item_ptr = dynamic_cast<TreeCheckItem*>(item);
-
- if (item_ptr
- && item->childCount() == 0
- && item_ptr->getLevel() == "title")
- {
- int id = item_ptr->getID();
-
- Metadata *mdata;
- if (!cd)
- {
- mdata = gMusicData->all_music->getMetadata(id);
- if (!mdata)
- return;
- }
- else
- {
- // Need to allocate storage for CD Metadata
- mdata = new Metadata;
- if (!gMusicData->all_music->getCDMetadata(id, mdata))
- {
- delete mdata;
- return;
- }
- }
-
- unsigned int line = 0;
- QString tmpstr;
-
- if (mdata->Compilation())
- {
- tmpstr = tr("Compilation Artist:\t") + mdata->CompilationArtist();
- if (m_lines.at(line))
- m_lines.at(line++)->SetText(tmpstr);
- }
-
- tmpstr = tr("Artist:\t") + mdata->Artist();
- if (m_lines.at(line))
- m_lines.at(line++)->SetText(tmpstr);
-
- tmpstr = tr("Album:\t") + mdata->Album();
- if (m_lines.at(line))
- m_lines.at(line++)->SetText(tmpstr);
-
- tmpstr = tr("Title:\t") + mdata->Title();
- if (m_lines.at(line))
- m_lines.at(line++)->SetText(tmpstr);
-
- if (m_lines.at(line))
- {
- int maxTime = mdata->Length() / 1000;
-
- int maxh = maxTime / 3600;
- int maxm = (maxTime / 60) % 60;
- int maxs = maxTime % 60;
-
- QString timeStr;
- if (maxh > 0)
- timeStr.sprintf("%02d:%02d:%02d", maxh, maxm, maxs);
- else
- timeStr.sprintf("%02d:%02d", maxm, maxs);
-
- tmpstr = tr("Length:\t") + timeStr;
-
- m_lines.at(line++)->SetText(tmpstr);
- }
-
- tmpstr = tr("Genre: ") + mdata->Genre();
-
- if (m_lines.at(line))
- {
- m_lines.at(line)->SetText(tmpstr);
- }
- else
- {
- QString prevvalue = m_lines.at(line-1)->GetText();
- tmpstr = prevvalue + " " + tmpstr;
- m_lines.at(line-1)->SetText(tmpstr);
- }
-
- // Pre increment as not incremented from previous use.
- while (++line < (unsigned) m_lines.size())
- m_lines.at(line)->SetText("");
-
- // Don't forget to delete the mdata storage if we allocated it.
- if (cd)
- delete mdata;
-
- return;
- }
-
- QStringList pathto = treetype->getRouteToCurrent();
-
- int linelen = 0;
- int dispat = 0;
- QString data;
-
- for (QStringList::Iterator it = pathto.begin();
- it != pathto.end(); ++it)
- {
- if (it == pathto.begin())
- continue;
-
- if (!data.isEmpty())
- data += " / ";
-
- data += *it;
- linelen++;
- if (linelen == 2)
- {
- if (m_lines.at(dispat))
- {
- m_lines.at(dispat)->SetText(data);
- }
-
- data.clear();
- linelen = 0;
- dispat++;
- }
- }
-
- if (linelen != 0)
- {
- if (m_lines.at(dispat))
- {
- m_lines.at(dispat)->SetText(data);
- }
- dispat++;
- }
-
- for (unsigned int i = dispat; i < (unsigned) m_lines.size(); i++)
- m_lines.at(i)->SetText("");
-}
-
-void DatabaseBox::selected(UIListGenericTree *item)
-{
- if (!item)
- return;
-
- UIListGenericTree *parent = (UIListGenericTree *)item->getParent();
-
- if (CDCheckItem *item_ptr = dynamic_cast<CDCheckItem*>(item))
- {
- // Something to do with a CD
- if (active_playlist)
- {
- if (item_ptr->getCheck() > 0)
- item_ptr->setCheck(0);
- else
- item_ptr->setCheck(2);
- doSelected(item_ptr, true);
- if (CDCheckItem *item_ptr = dynamic_cast<CDCheckItem*>(parent))
- checkParent(item_ptr);
- tree->Redraw();
- }
-
- }
- else if (TreeCheckItem *item_ptr = dynamic_cast<TreeCheckItem*>(item))
- {
- if (active_playlist)
- {
- if (item_ptr->getCheck() > 0)
- item_ptr->setCheck(0);
- else
- item_ptr->setCheck(2);
- doSelected(item_ptr, false);
- if (TreeCheckItem *item_ptr = dynamic_cast<TreeCheckItem*>(parent))
- checkParent(item_ptr);
- tree->Redraw();
- }
- }
- else if (PlaylistItem *item_ptr = dynamic_cast<PlaylistTrack*>(item))
- dealWithTracks(item_ptr);
- else if (PlaylistTitle *item_ptr = dynamic_cast<PlaylistTitle*>(item))
- doActivePopup(item_ptr);
- else
- {
- LOG(VB_GENERAL, LOG_ERR, "That's odd ... there's something I don't "
- "recognize on a ListView");
- }
-}
-
-
-void DatabaseBox::doPlaylistPopup(TreeCheckItem *item_ptr)
-{
- if (playlist_popup)
- return;
-
- // Popup for all other playlists (up top)
- playlist_popup = new MythPopupBox(GetMythMainWindow(),
- "playlist_popup");
-
- QAbstractButton *mac_b = playlist_popup->addButton(tr("Move to Active Play Queue"),
- this, SLOT(copyToActive()));
-
- playlist_popup->addButton(tr("Delete This Playlist"), this,
- SLOT(deletePlaylist()));
-
- playlist_rename = new MythRemoteLineEdit(playlist_popup);
- playlist_rename->setText(item_ptr->getString());
- playlist_popup->addWidget(playlist_rename);
-
- playlist_popup->addButton(tr("Rename This Playlist"), this,
- SLOT(renamePlaylist()));
-
- playlist_popup->ShowPopup(this, SLOT(closePlaylistPopup()));
-
- mac_b->setFocus();
-}
-
-void DatabaseBox::closePlaylistPopup(void)
-{
- if (!playlist_popup)
- return;
-
- playlist_popup->hide();
- playlist_popup->deleteLater();
- playlist_popup = NULL;
-}
-
-void DatabaseBox::doActivePopup(PlaylistTitle *item_ptr)
-{
- if (active_popup)
- return;
-
- // Popup for active playlist
- active_popup = new MythPopupBox(GetMythMainWindow(),
- "active_popup");
- active_pl_edit = new MythRemoteLineEdit(active_popup);
- active_popup->addWidget(active_pl_edit);
- active_pl_edit->setFocus();
-
- active_popup->addButton(tr("Copy To New Playlist"), this,
- SLOT(copyNewPlaylist()));
-
- active_popup->addButton(tr("Clear the Active Play Queue"), this,
- SLOT(clearActive()));
-
- QAbstractButton *pb = active_popup->addButton(tr("Save Back to Playlist Tree"),
- this, SLOT(popBackPlaylist()));
-
- // CD writing
-
- bool cdwriter = false;
-
- if (gCoreContext->GetNumSetting("CDWriterEnabled"))
- {
- QString scsidev = MediaMonitor::defaultCDWriter();
- if (!scsidev.isEmpty())
- cdwriter = true;
- }
-
- QAbstractButton *cdaudiob = NULL;
- QAbstractButton *cdmp3b = NULL;
-
- if (cdwriter)
- {
-#if 0
- /*
- Disabled as Playlist::CreateCDAudio() is empty,
- it is called by CreateCDAudio()
- */
- cdaudiob = active_popup->addButton(tr("Create Audio CD from "
- "Playlist"), this,
- SLOT(CreateCDAudio()));
-#endif
-
- cdmp3b = active_popup->addButton(tr("Create MP3 CD from Playlist"),
- this, SLOT(CreateCDMP3()));
-
- active_popup->addButton(tr("Clear CD-RW Disk"), this,
- SLOT(BlankCDRW()));
-
- double size_in_MB = 0.0;
- double size_in_sec = 0.0;
- active_playlist->computeSize(size_in_MB, size_in_sec);
-
- int disksize = gCoreContext->GetNumSetting("CDDiskSize", 2);
-
- double max_size_in_MB;
- double max_size_in_min;
-
- if (disksize == 1)
- {
- max_size_in_MB = 650;
- max_size_in_min = 75;
- }
- else
- {
- max_size_in_MB = 700;
- max_size_in_min = 80;
- }
-
- double ratio_MB = 100.0 * size_in_MB / max_size_in_MB;
- double ratio_sec = 100.0 * size_in_sec / 60.0 / 1000.0 / max_size_in_min;
-
- QString label1;
- QString label2;
-
- label1.sprintf("Size: %dMB (%02d%%)", (int)(size_in_MB),
- (int)(ratio_MB));
- label2.sprintf("Duration: %3dmin (%02d%%)",
- (int)(size_in_sec / 60.0 / 1000.0), (int)(ratio_sec));
-
- active_popup->addLabel(label1);
- active_popup->addLabel(label2);
-
- cdmp3b->setEnabled((ratio_MB <= 100.0));
-
- if (cdaudiob)
- {
- cdaudiob->setEnabled((ratio_sec <= 100.0));
- cdaudiob->setEnabled(false);
- }
- }
-
- (void)item_ptr;
-
- active_pl_edit->setText("");
-
- active_popup->ShowPopup(this, SLOT(closeActivePopup()));
-
- if (gMusicData->all_playlists->pendingWriteback())
- pb->setEnabled(true);
- else
- pb->setEnabled(false);
-}
-
-void DatabaseBox::closeActivePopup(void)
-{
- if (!active_popup)
- return;
-
- active_popup->hide();
- active_popup->deleteLater();
- active_popup = NULL;
-}
-
-void DatabaseBox::dealWithTracks(PlaylistItem *item_ptr)
-{
- // Logic to handle the start of moving/deleting songs from playlist
-
- if (holding_track)
- {
- LOG(VB_GENERAL, LOG_ERR, "dealWithTracks() - Holding track. This is "
- "not supposed to happen");
- holding_track = false;
- track_held->beMoving(false);
- releaseKeyboard();
- tree->RedrawCurrent();
- }
- else
- {
- holding_track = true;
- track_held = dynamic_cast<PlaylistTrack*>(item_ptr);
- track_held->beMoving(true);
- grabKeyboard();
- tree->RedrawCurrent();
- }
-}
-
-void DatabaseBox::doSelected(UIListGenericTree *item, bool cd_flag)
-{
- bool keep_going = false;
-
- TreeCheckItem *tcitem = (TreeCheckItem *)item;
-
- if (tcitem->childCount() > 0)
- {
- keep_going = true;
- UIListGenericTree *test = (UIListGenericTree *)tcitem->getChildAt(0);
- if (PlaylistItem *check_item = dynamic_cast<PlaylistItem*>(test))
- {
- (void)check_item;
- keep_going = false;
- }
- }
-
- if (keep_going)
- {
- GenericTree::iterator it;
- for (it = tcitem->begin(); it != tcitem->end(); ++it)
- {
- TreeCheckItem *child = (TreeCheckItem*)(*it);
- if (child->getCheck() != tcitem->getCheck())
- {
- child->setCheck(tcitem->getCheck());
- doSelected(child, cd_flag);
- }
- }
- }
- else
- {
- if (tcitem->getCheck() == 2)
- active_playlist->addTrack(tcitem->getID(), true, cd_flag);
- else
- active_playlist->removeTrack(tcitem->getID(), cd_flag);
- }
-}
-
-void DatabaseBox::checkParent(UIListGenericTree *item)
-{
- if (!item)
- return;
-
- bool do_check = false;
-
- if (TreeCheckItem *tcitem = dynamic_cast<TreeCheckItem*>(item))
- {
- (void)tcitem;
- do_check = true;
- }
- else if (CDCheckItem *tcitem = dynamic_cast<CDCheckItem*>(item))
- {
- (void)tcitem;
- do_check = true;
- }
-
- if (do_check)
- {
- TreeCheckItem *tcitem = dynamic_cast<TreeCheckItem*>(item);
- TreeCheckItem *child = (TreeCheckItem *)tcitem->getChildAt(0);
- if (!child)
- return;
-
- bool allon = true;
- bool oneon = false;
-
- GenericTree::iterator it;
- for (it = tcitem->begin(); it != tcitem->end(); ++it)
- {
- child = (TreeCheckItem*)(*it);
- if (child->getCheck() > 0)
- oneon = true;
- if (child->getCheck() == 0)
- allon = false;
- }
-
- if (allon)
- tcitem->setCheck(2);
- else if (oneon)
- tcitem->setCheck(1);
- else
- tcitem->setCheck(0);
-
- if (tcitem->getParent())
- checkParent((UIListGenericTree *)tcitem->getParent());
- }
-}
-
-void DatabaseBox::deleteTrack(UIListGenericTree *item)
-{
- if (PlaylistTrack *delete_item = dynamic_cast<PlaylistCD*>(item) )
- {
- if (delete_item->nextSibling(1))
- tree->MoveDown();
- else if (delete_item->prevSibling(1))
- tree->MoveUp();
-
- UIListGenericTree *newItem = (UIListGenericTree *)delete_item->getParent();
- if (TreeCheckItem *item_owner = dynamic_cast<TreeCheckItem*>(newItem))
- {
- Playlist *owner =
- gMusicData->all_playlists->getPlaylist(item_owner->getID() * -1);
-
- if (owner)
- owner->removeTrack(delete_item->getID(), true);
- }
- else if (PlaylistTitle *item_owner = dynamic_cast<PlaylistTitle*>(newItem))
- {
- (void)item_owner;
- active_playlist->removeTrack(delete_item->getID(), true);
- }
- else
- {
- LOG(VB_GENERAL, LOG_ERR, "deleteTrack() - I don't know how to "
- "delete whatever you're trying to get "
- "rid of");
- }
-
- gMusicData->all_playlists->refreshRelevantPlaylists(alllists);
- checkTree();
- }
- else if (PlaylistTrack *delete_item = dynamic_cast<PlaylistTrack*>(item))
- {
- if (delete_item->nextSibling(1))
- tree->MoveDown();
- else if (delete_item->prevSibling(1))
- tree->MoveUp();
-
- UIListGenericTree *newItem = (UIListGenericTree *)delete_item->getParent();
- if (TreeCheckItem *item_owner = dynamic_cast<TreeCheckItem*>(newItem))
- {
- Playlist *owner =
- gMusicData->all_playlists->getPlaylist(item_owner->getID() * -1);
-
- if (owner)
- owner->removeTrack(delete_item->getID(), false);
- }
- else if (PlaylistTitle *item_owner = dynamic_cast<PlaylistTitle*>(newItem))
- {
- (void)item_owner;
- active_playlist->removeTrack(delete_item->getID(), false);
- }
- else
- {
- LOG(VB_GENERAL, LOG_ERR, "deleteTrack() - I don't know how to "
- "delete whatever you're trying to get "
- "rid of");
- }
- gMusicData->all_playlists->refreshRelevantPlaylists(alllists);
- checkTree();
- }
-}
-
-void DatabaseBox::moveHeldUpDown(bool flag)
-{
- track_held->moveUpDown(flag);
- tree->RedrawCurrent();
- //XXX listview->ensureItemVisible(track_held);
- //XXX listview->setCurrentItem(track_held);
-}
-
-void DatabaseBox::keyPressEvent(QKeyEvent *e)
-{
- // This is a bit wonky, but it works (more or less)
-
- if (holding_track)
- {
- bool handled = false;
- QStringList actions;
- handled = GetMythMainWindow()->TranslateKeyPress("Qt", e, actions);
- for (int i = 0; i < actions.size() && !handled; i++)
- {
- QString action = actions[i];
- handled = true;
-
- if (action == "SELECT" || action == "ESCAPE")
- {
- // Done holding this track
- holding_track = false;
- track_held->beMoving(false);
- tree->RedrawCurrent();
- releaseKeyboard();
- }
- else if (action == "UP")
- moveHeldUpDown(true);
- else if (action == "DOWN")
- moveHeldUpDown(false);
- else
- handled = false;
- }
- return;
- }
-
- bool handled = false;
- QStringList actions;
- handled = GetMythMainWindow()->TranslateKeyPress("Music", e, actions);
-
- UIListGenericTree *curItem = tree->GetCurrentPosition();
-
- for (int i = 0; i < actions.size() && !handled; i++)
- {
- QString action = actions[i];
- handled = true;
-
- if (action == "DELETE")
- deleteTrack(curItem);
- else if (action == "MENU" || action == "INFO")
- doMenus(curItem);
- else if (action == "SELECT")
- selected(curItem);
- else if (action == "0" || action == "1" || action == "2" ||
- action == "3" || action == "4" || action == "5" ||
- action == "6" || action == "7" || action == "8" ||
- action == "9")
- {
- alternateDoMenus(curItem, action.toInt());
- }
- else if (action == "UP")
- tree->MoveUp();
- else if (action == "DOWN")
- tree->MoveDown();
- else if (action == "LEFT")
- tree->MoveLeft();
- else if (action == "RIGHT")
- tree->MoveRight();
- else if (action == "PAGEUP")
- tree->MoveUp(UIListTreeType::MovePage);
- else if (action == "PAGEDOWN")
- tree->MoveDown(UIListTreeType::MovePage);
- else if (action == "INCSEARCH")
- tree->incSearchStart();
- else if (action == "INCSEARCHNEXT")
- tree->incSearchNext();
- else
- handled = false;
- }
-
- if (handled)
- return;
-
- MythDialog::keyPressEvent(e);
-}
-
-void DatabaseBox::checkTree(UIListGenericTree *startingpoint)
-{
- bool toplevel = false;
- if (!startingpoint)
- {
- toplevel = true;
- startingpoint = rootNode;
- }
-
- GenericTree::iterator it;
- for (it = startingpoint->begin(); it != startingpoint->end(); ++it)
- {
- UIListGenericTree *uit = (UIListGenericTree*)(*it);
- // Only check things which are TreeCheckItem's
- if (TreeCheckItem *item = dynamic_cast<TreeCheckItem*>(uit))
- {
- bool is_cd = dynamic_cast<CDCheckItem*>(uit) != 0;
- item->setCheck(0);
- if (active_playlist->checkTrack(item->getID(), is_cd))
- {
- // Turn on if it's on the current playlist
- item->setCheck(2);
- checkParent((UIListGenericTree *)item->getParent());
- }
-
- if (item->childCount() > 0)
- checkTree(item);
- }
- }
-
- if (toplevel)
- tree->Redraw();
-}
-
-void DatabaseBox::setCDTitle(const QString& title)
-{
- if (cditem)
- cditem->setText(title);
-}
-
-ReadCDThread::ReadCDThread(const QString &dev) :
- MThread("ReadCD"), m_CDdevice(dev), cd_status_changed(false)
-{
-}
-
-void ReadCDThread::run()
-{
- RunProlog();
-#ifndef USING_MINGW
- // lock all_music and cd_status_changed while running thread
- QMutexLocker locker(getLock());
-
- CdDecoder *decoder = new CdDecoder("cda", NULL, NULL, NULL);
- decoder->setDevice(m_CDdevice);
- int tracknum = decoder->getNumCDAudioTracks();
-
- bool redo = false;
-
- if (tracknum != gMusicData->all_music->getCDTrackCount())
- {
- cd_status_changed = true;
- LOG(VB_GENERAL, LOG_INFO, QString("CD status has changed."));
- }
- else
- cd_status_changed = false;
-
- if (tracknum == 0)
- {
- // No CD, or no recognizable CD
- gMusicData->all_music->clearCDData();
- gMusicData->all_playlists->clearCDList();
- }
- else if (tracknum > 0)
- {
- // Check the last track to see if it's differen than whatever it was
- // before
- Metadata *checker = decoder->getLastMetadata();
- if (checker)
- {
- if (!gMusicData->all_music->checkCDTrack(checker))
- {
- redo = true;
- cd_status_changed = true;
- gMusicData->all_music->clearCDData();
- gMusicData->all_playlists->clearCDList();
- }
- else
- cd_status_changed = false;
- delete checker;
- }
- else
- {
- LOG(VB_GENERAL, LOG_ERR, "The cddecoder said it had audio tracks, "
- "but it won't tell me about them");
- }
- }
-
- int tracks = decoder->getNumTracks();
- bool setTitle = false;
-
- for (int actual_tracknum = 1;
- redo && actual_tracknum <= tracks; actual_tracknum++)
- {
- Metadata *track = decoder->getMetadata(actual_tracknum);
- if (track)
- {
- gMusicData->all_music->addCDTrack(track);
-
- if (!setTitle)
- {
-
- QString parenttitle = " ";
- if (track->FormatArtist().length() > 0)
- {
- parenttitle += track->FormatArtist();
- parenttitle += " ~ ";
- }
-
- if (track->Album().length() > 0)
- parenttitle += track->Album();
- else
- {
- parenttitle = " " + QObject::tr("Unknown");
- LOG(VB_GENERAL, LOG_ERR,
- "Couldn't find your CD. It may not be in the freedb "
- "database.\n"
- " More likely, however, is that you need to delete\n"
- " ~/.cddb and ~/.cdserverrc and restart mythmusic.");
- }
- gMusicData->all_music->setCDTitle(parenttitle);
- setTitle = true;
- }
- delete track;
- }
- }
-
- delete decoder;
-#endif // USING_MINGW
- RunEpilog();
-}
-
View
121 mythplugins/mythmusic/mythmusic/databasebox.h
@@ -1,121 +0,0 @@
-#ifndef DATABASEBOX_H_
-#define DATABASEBOX_H_
-
-#include <vector>
-using namespace std;
-
-#include <QStringList>
-#include <QPixmap>
-
-#include "metadata.h"
-#include "playlist.h"
-
-#include <mythwidgets.h>
-#include <lcddevice.h>
-#include <uilistbtntype.h>
-#include <mthread.h>
-
-class TreeCheckItem;
-class QTimer;
-class QKeyEvent;
-
-class ReadCDThread : public MThread
-{
- public:
-
- ReadCDThread(const QString &dev);
- virtual void run();
- bool statusChanged(){return cd_status_changed;}
- QMutex *getLock(){return &music_lock;}
-
- private:
-
- QString m_CDdevice;
- bool cd_status_changed;
- QMutex music_lock;
-};
-
-class DatabaseBox : public MythThemedDialog
-{
- Q_OBJECT
- public:
- DatabaseBox(MythMainWindow *parent,
- const QString dev, const QString &window_name,
- const QString &theme_filename, const char *name = 0);
- ~DatabaseBox();
-
- void dealWithTracks(PlaylistItem *item_ptr);
- void setCDTitle(const QString& title);
- void fillCD(void);
-
- protected slots:
- void selected(UIListGenericTree *);
- void entered(UIListTreeType *, UIListGenericTree *);
- void doMenus(UIListGenericTree *);
- void alternateDoMenus(UIListGenericTree *, int);
- void keyPressEvent(QKeyEvent *e);
- void moveHeldUpDown(bool flag);
- void deleteTrack(UIListGenericTree *item);
- void copyNewPlaylist();
- void copyToActive();
- void deletePlaylist();
- void renamePlaylist();
- void popBackPlaylist();
- void clearActive();
- void closeActivePopup();
- void closePlaylistPopup();
- void occasionallyCheckCD();
- void keepFilling();
- void showWaiting();
-
- void ErrorPopup(const QString &msg);
- void closeErrorPopup();
-
- void CreateCDAudio();
- void CreateCDMP3();
- void BlankCDRW();
-
- private:
- void doSelected(UIListGenericTree *, bool cd_flag);
- void doPlaylistPopup(TreeCheckItem *item_ptr);
- void doActivePopup(PlaylistTitle *item_ptr);
- void checkParent(UIListGenericTree *);
-
- void checkTree(UIListGenericTree *startingpoint = NULL);
- QPixmap getPixmap(QString &level);
-
- UIListGenericTree *rootNode;
- UIListTreeType *tree;
-
- CDCheckItem *cditem;
-
- QString m_CDdevice;
- bool holding_track;
- PlaylistTrack *track_held;
- TreeCheckItem *allmusic;
- TreeCheckItem *alllists;
- PlaylistTitle *allcurrent;
- Playlist *active_playlist;
-
- MythPopupBox *active_popup;
- MythRemoteLineEdit *active_pl_edit;
-
- MythPopupBox *playlist_popup;
- MythRemoteLineEdit *playlist_rename;
-
- MythPopupBox *error_popup;
-
- ReadCDThread *cd_reader_thread;
- QTimer *cd_watcher;
- bool cd_checking_flag;
-
- QTimer *fill_list_timer;
- int wait_counter;
- int numb_wait_dots;
-
- QStringList treelevels;
-
- vector<UITextType*> m_lines;
-};
-
-#endif
View
24 mythplugins/mythmusic/mythmusic/decoderhandler.cpp
@@ -129,6 +129,8 @@ void DecoderIOFactoryFile::start(void)
doConnectDecoder(getUrl().toLocalFile());
}
+/**********************************************************************/
+
DecoderIOFactoryUrl::DecoderIOFactoryUrl(DecoderHandler *parent) : DecoderIOFactory(parent)
{
m_accessManager = new QNetworkAccessManager(this);
@@ -193,7 +195,7 @@ void DecoderIOFactoryUrl::replyFinished(QNetworkReply *reply)
{
LOG(VB_PLAYBACK, LOG_INFO,
QString("DecoderIOFactory: Got redirected to %1")
- .arg(possibleRedirectUrl));
+ .arg(possibleRedirectUrl.toString()));
m_redirectCount++;
@@ -240,7 +242,7 @@ void DecoderIOFactoryUrl::readyRead(void)
void DecoderIOFactoryUrl::doStart(void)
{
- doConnectDecoder(getUrl());
+ doConnectDecoder(getUrl().toString());
m_started = true;
}
@@ -381,7 +383,7 @@ void DecoderHandler::stop(void)
if (m_decoder)
{
m_decoder->wait();
- delete m_decoder->input();
+ //delete m_decoder->input(); // TODO: need to sort out who is responsible for the input
delete m_decoder;
m_decoder = NULL;
}
@@ -406,7 +408,7 @@ bool DecoderHandler::createPlaylist(const QUrl &url)
QString extension = QFileInfo(url.path()).suffix();
LOG(VB_NETWORK, LOG_INFO,
QString("File %1 has extension %2")
- .arg(url.fileName()).arg(extension));
+ .arg(QFileInfo(url.path()).fileName()).arg(extension));
if (extension == "pls" || extension == "m3u")
{
@@ -439,7 +441,9 @@ bool DecoderHandler::createPlaylistFromFile(const QUrl &url)
f.open(QIODevice::ReadOnly);
QTextStream stream(&f);
- if (PlayListFile::parse(&m_playlist, &stream) < 0)
+ QString extension = QFileInfo(url.path()).suffix().toLower();
+
+ if (PlayListFile::parse(&m_playlist, &stream, extension) <= 0)
return false;
return m_playlist.size() > 0;
@@ -454,14 +458,20 @@ bool DecoderHandler::createPlaylistFromRemoteUrl(const QUrl &url)
QByteArray data;
- if (!GetMythDownloadManager()->download(url, &data))
+ if (!GetMythDownloadManager()->download(url.toString(), &data))
+ {
+ LOG(VB_GENERAL, LOG_ERR, QString("DecoderHandler:: Failed to download playlist from: %1").arg(url.toString()));
+ doOperationStop();
return false;
+ }
doOperationStop();
QTextStream stream(&data, QIODevice::ReadOnly);
- bool result = PlayListFile::parse(&m_playlist, &stream) > 0;
+ QString extension = QFileInfo(url.path()).suffix().toLower();
+
+ bool result = PlayListFile::parse(&m_playlist, &stream, extension) > 0;
return result;
}
View
57 mythplugins/mythmusic/mythmusic/editmetadata.cpp
@@ -23,15 +23,10 @@
#include "genres.h"
#include "metaio.h"
#include "musicplayer.h"
+#include "musicutils.h"
#include "editmetadata.h"
-static inline QString fixFileToken(QString token)
-{
- token.replace(QRegExp("(/|\\\\|:|\'|\"|\\?|\\|)"), QString("_"));
- return token;
-}
-
// these need to be static so both screens can pick them up
bool EditMetadataCommon::metadataOnly = false;
Metadata *EditMetadataCommon::m_metadata = NULL;
@@ -401,24 +396,6 @@ bool EditMetadataDialog::Create(void)
return true;
}
-QString EditMetadataDialog::findIcon(const QString &type, const QString &name)
-{
- QString cleanName = fixFileToken(name);
- QString file = GetConfDir() + QString("/MythMusic/Icons/%1/%2").arg(type).arg(cleanName);
-
- if (QFile::exists(file + ".jpg"))
- return file + ".jpg";
-
- if (QFile::exists(file + ".jpeg"))
- return file + ".jpeg";
-
- if (QFile::exists(file + ".png"))
- return file + ".png";
-
- return QString();
-
-}
-
void EditMetadataDialog::fillWidgets()
{
m_compArtistEdit->SetText(m_metadata->CompilationArtist());
@@ -520,7 +497,7 @@ void EditMetadataDialog::showMenu(void )
menu->AddButton(tr("Search Internet For Artist Image"));
menu->AddButton(tr("Search Internet For Album Image"));
menu->AddButton(tr("Search Internet For Genre Image"));
-
+ menu->AddButton(tr("Check Track Length"));
menu->AddButton(tr("Cancel"));
popupStack->AddScreen(menu);
@@ -750,7 +727,7 @@ void EditMetadataDialog::searchForGenreImages(void)
QUrl url("http://www.flickr.com/search/groups/?w=908425%40N22&m=pool&q=" + genre, QUrl::TolerantMode);
- QString cleanName = fixFileToken(m_metadata->Genre().toLower());
+ QString cleanName = fixFilename(m_metadata->Genre().toLower());
QString file = GetConfDir() + QString("/MythMusic/Icons/%1/%2.jpg").arg("genre").arg(cleanName);
QFileInfo fi(file);
@@ -765,7