📄 qmplayfirst.cpp
字号:
/* qmplayfirst.cpp * * $Id: qmplayfirst.cpp,v 1.10 2002/03/30 11:49:06 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 "qmplayfirst.h"#include "qmsongitem.h"/*! \file qmplayfirst.cpp \brief Widget for selecting songs from the playlist on the fly *//*! \class QmPlayFirst qmplayfirst.h QmPlayFirst is a play-once playlist. You add songs to the PlayFirst list by mid-clicking (button2) them in the playlist. Songs in the PlayFirst list are played before (shocker) the regular playlist, and dissappear as they are played. Why? At parties people want to choose songs, but they don't want to drag them below the currently playing one, or wait until the current is over, or just skip directly - they want to schedule songs to be played. I also use it alone, just as runtime programmable cd player, it's useful to rapidly select some songs in the order you want to hear them instead of manually rearranging the playlist or creating a new one. This is particularly nice in combination with the playlist/directory browser where you can find and schedule a nice selection of tunes with ease. */QmPlayFirst::QmPlayFirst( QWidget *parent, const char *name) : QmPlayList(parent, name), poped(0){ connect(this, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint &, int)), this, SLOT(mouseClick(int, QListViewItem*, const QPoint &, int))); // Disconnect the selection connection made in the parent class constructor // as the handler in the parent will start a timer for displaying a message // in the statusbar. Without disabling this signal, the statusbar will // switch back and forth from the message from the playlist to the message // from this (playfirst). Since there is no need for the message from the // object of this class, we disconnect the selection signal. disconnect(this, SIGNAL(selectionChanged()), 0, 0);}QmPlayFirst::~QmPlayFirst(){ if (poped!=0) delete poped;}/*! Sets up the menu.*/voidQmPlayFirst::initMenu(){ m_RemoveSelectedSongsId = getMenu()->insertItem( tr("Remove selected"), this, SLOT(removeSelectedSongs()));}/*! Pops (returns and deletes) the next song, returns 0 on failure.*/QListViewItem *QmPlayFirst::pop() { // delete the most recently poped song, primitive attempt to avoid leeks if (poped) delete poped; poped = dynamic_cast<QmSongItem *>(firstChild()); if (poped) takeItem(poped); QmMainWindow::mainwin->showOrHidePlayFirst(); return poped;}/*! Appends a copy of song to the list.*/voidQmPlayFirst::append( QmSongItem *song){ QmSongItem *addMe; addMe = new QmSongItem(this, isEmpty() ? 0 : static_cast<QmPlayListItem *>(lastChild()), song->filePath().latin1(), song->length(), song->bitrate(), song->variableBitrate(), song->title(), song->artist(), song->album(), song->cdPosition()); addMe->setDisplayString(song->displayString()); update(); QmMainWindow::mainwin->showOrHidePlayFirst(); }/*! Appends the song songFilename to the list.*/voidQmPlayFirst::append( const QString &songFilename){ (void) new QmSongItem(this, isEmpty() ? 0 : static_cast<QmPlayListItem *>(lastChild()), songFilename); update(); QmMainWindow::mainwin->showOrHidePlayFirst(); }/*! \returns Always returns 0.*/intQmPlayFirst::position(){ return 0;}/*! \return Song item at index `pos', or 0.*/QmSongItem*QmPlayFirst::song(int pos){ if (pos == -1 || pos == 0) return poped ? poped : 0; if (poped) pos--; for (QListViewItemIterator it(this); it.current(); ++it) { if (pos-- == 0) return dynamic_cast<QmSongItem*>(it.current()); } return 0;}/*! overrides QmPlayList::mouseClick*/voidQmPlayFirst::mouseClick( int button, QListViewItem * item, const QPoint & pos, int c ){ if (button & Qt::RightButton) showPopup(item, pos, c); }/*! Removes the selected songs. If all songs are removed, the list will be hidden.*/voidQmPlayFirst::removeSelectedSongs(){ bool b; removeSelected(&b); QmMainWindow::mainwin->showOrHidePlayFirst();}/*! \return The current song, or 0 if there is no non-bad songs.*/QmSongItem*QmPlayFirst::currentSong(){ return poped && dynamic_cast<QmSongItem*>(poped) ? poped : 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -