⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qmplaylistitem.cpp

📁 可以播放MP3,wma等文件格式的播放器
💻 CPP
字号:
/* qmplaylistitem.cpp * * $Id: qmplaylistitem.cpp,v 1.24.2.2 2002/10/11 06:39:03 kyllingstad Exp $ * * Apollo sound player: http://www.apolloplayer.org * Copyright(C) 2000-2002 Apollo Team.  See CREDITS file. * * 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. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. * * The GNU General Public License is also available online at: * * http://www.gnu.org/copyleft/gpl.html */#include "message.h"#include "qmplaylistitem.h"#include "qmmainwindow.h"#include "qmconfig.h"#include "qmdiritem.h"#include "qmplaylist.h"#include "qmsongitem.h"#include "util.h"#include <time.h>#include <qtextstream.h>#include <qstring.h>#include <iostream>/* Disables false warning in Visual Studio about dynamic_cast */#ifdef _WS_WIN_#pragma warning(disable: 4541)#endifQmPlayListItem *QmPlayListItem::m_pSearchMatch = 0;/*!  \file qmplaylistitem.cpp  Base for directory and song items in the playlist widget *//*!  \class QmPlayListItem qmplaylistitem.h  \brief Represents an item in the play list.  This is the base class for items in the play list.  It provides  a common interface for persistant storage.*//*! \fn virtual QString	QmPlayListItem::save( const QString &rel_path ) const  \return The save string of the item.  Each subclass must implement this and return a proper  string which is used when saving the playlist.*//*! \fn virtual bool QmPlayListItem::isSong() const  \return True of the item is a song.*//*!  Listview constructor*/QmPlayListItem::QmPlayListItem(    QListView *parent,    QListViewItem *after)    : QmListViewItem(parent, after)//  ,//      m_Count( count >= 0 ? count : QmPlayList::count() ){}/*!  Listview item constructor*/QmPlayListItem::QmPlayListItem(    QmPlayListItem *parent,    QListViewItem *after)    : QmListViewItem(parent, after)//  ,//      m_Count( count >= 0 ? count : QmPlayList::count() ){}/*!  Destroys the object*/QmPlayListItem::~QmPlayListItem(){}/*!  Akin to firstChild() but instead returns the last item in the listviewitem.  \sa firstChild()*/QmPlayListItem*QmPlayListItem::lastChild() const{    QmPlayListItem *found = 0;    QmPlayListItem *item = dynamic_cast<QmPlayListItem *>( firstChild() );    while ( item )    {        found = item;        item = dynamic_cast<QmPlayListItem *>( item->nextSibling() );    }    return found;}voidQmPlayListItem::setDisplayFormat(    const char * /*format*/,    const char * /*multiFormat*/){}/*! Sets the length of the song in minutes and seconds, this used instead *  of the file size if non-empty. */voidQmPlayListItem::setLength(    const QString &len){    m_Length = len;}/*! \param length song length in seconds */voidQmPlayListItem::setLengthSeconds(    long length){    if (m_LengthSeconds!=length && length>0)    {        m_LengthSeconds = length;        m_Length.truncate(0);        secondsToTimeString(length, m_Length);    }}//  /*!//    Returns the internal counter for this item.//  *///  int QmPlayListItem::sortCounter() const//  {//      return m_Count;//  }//  /*!//    Returns a string of numbers by using the sortCounter(),//    this string is used for sorting playlist items properly.//  *///  QString QmPlayListItem::sortCounterString() const//  {//      QString tmp;//      tmp.sprintf( "%.10d", sortCounter() );//      return tmp;//  }/*!  Saves the item to \a out.  Unlike QmBrowserItem::save(QTextStream&), this  saves \e all items, regardless of depth.*/voidQmPlayListItem::save(	QTextStream &out) const{	QListViewItemIterator it(listView());	save(out, it);	// Debug: Dump to stdout.//	QTextStream q_cout( stdout, IO_WriteOnly );//	save(q_cout, it);}/*!  Recursive helper function for save(QTextStream &).  \a out is the same as in  the other save function. */voidQmPlayListItem::save(	QTextStream &out,	QListViewItemIterator &it,    long start_time,    int dir_count,    int song_count) const{	QmPlayListItem *item;    if (start_time == 0)        start_time = time(0);    	while(it.current() != 0)	{		item = dynamic_cast<QmPlayListItem*>(it.current());		CHECK_PTR(item);				QString s1(QmConfig::indent(item->depth() + 1));		QString s2(QmConfig::indent(item->depth() + 2));		bool is_dir = false;		if( ! item->isSong())		{			QmDirItem *diritem = dynamic_cast<QmDirItem*>(item);			CHECK_PTR(diritem);			is_dir = true;			out << s1 << "<dir>\n"				<< s2 << "<name>" << "<![CDATA[" << diritem->text(0) << "]]>" << "</name>\n"				<< s2 << "<path>" << "<![CDATA[" << diritem->fullName() << "]]>" << "</path>\n"				<< s2 << "<open>" << diritem->isOpen() << "</open>\n";            if (++dir_count%10==0)            {                QmMainWindow::mainwin->statusUpdate(new Message(Message::Update,                                                                "Saved %d songs in %d folders (%ld seconds)",                                                                song_count,                                                                dir_count,                                                                time(0) - start_time));            }		}		else		{			QmSongItem *songitem = dynamic_cast<QmSongItem*>(item);			CHECK_PTR(songitem);			is_dir = false;			out << s1 << "<song>\n"				<< s2 << "<name><![CDATA[" << songitem->text(0) << "]]></name>\n"				<< s2 << "<path><![CDATA[" << songitem->filePath() << "]]></path>\n";            if (songitem->cdPosition()!="")                out << s2 << "<cd-position>" << songitem->cdPosition() << "</cd-position>\n";            if (songitem->length() != 0)                out << s2 << "<length>" << songitem->length() << "</length>\n";            if (songitem->artist() != "")                out << s2 << "<artist><![CDATA[" << songitem->artist() << "]]></artist>\n";            if (songitem->title() != "")                out << s2 << "<title><![CDATA[" << songitem->title() << "]]></title>\n";            if (songitem->album() != "")                out << s2 << "<album><![CDATA[" << songitem->album() << "]]></album>\n";            if (++song_count%100 == 0)            {                QmMainWindow::mainwin->statusUpdate(new Message(Message::Update,                                                                "Saved %d songs in %d folders (%ld seconds)",                                                                song_count,                                                                dir_count,                                                                time(0) - start_time));            }// 			out << s1 << "<song>\n"// 				<< s2 << "<title>" << "<![CDATA[" << songitem->text(0) << "]]>" << "</title>\n"// 				<< s2 << "<path>" << "<![CDATA[" << songitem->filePath() << "]]>" << "</path>\n"// 				<< s2 << "<length>" << "</length>\n"// 				<< s2 << "<artist>" << "</artist>\n"// 				<< s2 << "<album>" << "</album>\n"// 				<< s2 << "<cd-position>" << "</cd-position>\n";		}		++it;		if(it.current() == 0)		{            out << s1 << (is_dir ? "</dir>\n" : "</song>\n");			break;		}		else		{			if(it.current()->depth() == item->depth())			{                out << s1 << (is_dir ? "</dir>\n" : "</song>\n");			}			else if(it.current()->depth() > item->depth())			{				save(out, it);                out << s1 << (is_dir ? "</dir>\n" : "</song>\n");			}			else			{                out << s1 << (is_dir ? "</dir>\n" : "</song>\n");				return;			}		}	}}boolQmPlayListItem::isBad() const {    return false;}/*!  If \a item is non-null, that item will be painted in a different color to  show that it was the match in a search. If \a item is null, no item will  be painted differently. */voidQmPlayListItem::setMatchItem(    QmPlayListItem *item){    QmPlayListItem *last = m_pSearchMatch;    m_pSearchMatch = item;    if(last)        last->repaint();    if(item)        item->repaint();}/*!  \return The match item, or null if no match.*/QmPlayListItem*QmPlayListItem::matchItem(){    return m_pSearchMatch;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -