added playlist clear button functionality

git-svn-id: https://projectm.svn.sourceforge.net/svnroot/projectm/trunk@635 6778bc44-b910-0410-a7a0-be141de4315d
This commit is contained in:
w1z7ard
2007-11-02 01:55:11 +00:00
parent 790e6e066e
commit 5e5898fae9
6 changed files with 32 additions and 5 deletions

View File

@ -43,6 +43,9 @@ class PresetLoader {
/// \param url an url referencing the preset
/// \returns The unique index assigned to the preset in the collection. Used with loadPreset
unsigned int addPresetURL ( const std::string & url, const std::string & presetName);
/// Clears all presets from the collection
void clear() { m_entries.clear(); m_presetNames.clear(); }
void removePreset(unsigned int index);

View File

@ -884,7 +884,12 @@ std::string projectM::getPresetName ( unsigned int index ) const
return m_presetLoader->getPresetName(index);
}
unsigned int projectM::getPlayListSize() const
void projectM::clearPlaylist ( )
{
m_presetLoader->clear();
}
unsigned int projectM::getPlaylistSize() const
{
return m_presetLoader->getNumPresets();
}

View File

@ -135,6 +135,10 @@ public:
/// If the preset is locked the queued item will be not switched to until the lock is released
void queuePreset(unsigned int index);
/// Removes entire playlist, The currently loaded preset will end up sticking until new presets are added
void clearPlaylist();
/// Turn on or off a lock that prevents projectM from switching to another preset
void setPresetLock(bool isLocked);
@ -151,7 +155,7 @@ public:
std::string getPresetName ( unsigned int index ) const;
/// Returns the size of the play list
unsigned int getPlayListSize() const;
unsigned int getPlaylistSize() const;
/// Occurs when active preset has switched. Switched to index is returned
virtual void presetSwitchedEvent(bool isHardCut, unsigned int index) const {};

View File

@ -41,6 +41,9 @@ QProjectM_MainWindow::QProjectM_MainWindow(const std::string & config_file)
connect(ui.lockPresetCheckBox, SIGNAL(stateChanged(int)),
m_QProjectMWidget, SLOT(setPresetLock(int)));
connect(ui.clearPresetList_PushButton, SIGNAL(pressed()),
this, SLOT(clearPlaylist()));
connect(m_QProjectMWidget, SIGNAL(projectM_Initialized()), this, SLOT(postProjectM_Initialize()));
@ -65,6 +68,12 @@ QProjectM_MainWindow::QProjectM_MainWindow(const std::string & config_file)
}
void QProjectM_MainWindow::clearPlaylist() {
getQProjectM()->clearPlaylist();
playlistModel.clear();
}
QProjectM * QProjectM_MainWindow::getQProjectM() {
return m_QProjectMWidget->getQProjectM();
}
@ -170,7 +179,8 @@ void QProjectM_MainWindow::open()
loadFile(*pos);
}
}
playlistModel.setHeaderData(0, Qt::Horizontal, tr("Preset"));//, Qt::DisplayRole);
}
@ -178,7 +188,7 @@ void QProjectM_MainWindow::refreshPlaylist() {
playlistModel.clear();
for (unsigned int i = 0; i < getQProjectM()->getPlayListSize(); i++) {
for (unsigned int i = 0; i < getQProjectM()->getPlaylistSize(); i++) {
const std::string & presetURL = getQProjectM()->getPresetURL(i);
const std::string & presetName = getQProjectM()->getPresetName(i);

View File

@ -68,6 +68,7 @@ class QProjectMWidget : public QGLWidget
QProjectM * getQProjectM() { return m_projectM; }
public slots:
void setPresetLock(int state) {
m_projectM->setPresetLock((bool)state);
}
@ -77,8 +78,11 @@ class QProjectMWidget : public QGLWidget
private:
std::string config_file;
QProjectM * m_projectM;
protected:
void keyReleaseEvent ( QKeyEvent * e ) {
projectMKeycode pkey;
@ -212,6 +216,7 @@ protected:
void closeEvent(QCloseEvent *event);
private slots:
void clearPlaylist();
void open();
void about();
void postProjectM_Initialize();

View File

@ -164,7 +164,7 @@ p, li { white-space: pre-wrap; }
<string>&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
p, li { white-space: pre-wrap; }
&lt;/style>&lt;/head>&lt;body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Clears &lt;span style=" font-style:italic;">all&lt;/span> items if &lt;span style=" font-style:italic;">none are selected&lt;/span> and the currently selected items otherwise.&lt;/p>&lt;/body>&lt;/html></string>
&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Clears&lt;span style=" font-style:italic;"> all &lt;/span>presets&lt;span style=" font-style:italic;"> &lt;/span>in the playlist.&lt;/p>&lt;/body>&lt;/html></string>
</property>
<property name="text" >
<string/>