diff options
author | Arno <arno@disconnect.de> | 2017-03-24 18:18:49 +0100 |
---|---|---|
committer | Arno <arno@disconnect.de> | 2017-03-24 18:18:49 +0100 |
commit | a55b7eb7a765f09f0e83e9d3ce5696f540b6bd9b (patch) | |
tree | 2f331faf9fb16130494482c212df76bb5180e8d7 | |
parent | c4388dcc1830d5df4f04ec2df42d1359b68cbda3 (diff) | |
download | BeetPlayer-a55b7eb7a765f09f0e83e9d3ce5696f540b6bd9b.tar.gz BeetPlayer-a55b7eb7a765f09f0e83e9d3ce5696f540b6bd9b.tar.bz2 BeetPlayer-a55b7eb7a765f09f0e83e9d3ce5696f540b6bd9b.zip |
Change to new style connect syntax
Quite some code churn, but I like the idea that wrong connections are
compile time errors.
Since I had to get rid of default arguments in Slots, this simplified
things in doPopulateByFolder...
-rw-r--r-- | beetplayer.cpp | 16 | ||||
-rw-r--r-- | configurationdialog.cpp | 10 | ||||
-rw-r--r-- | indexerdialog.cpp | 4 | ||||
-rw-r--r-- | indexerwidget.cpp | 6 | ||||
-rw-r--r-- | playerwidget.cpp | 92 | ||||
-rw-r--r-- | playerwidget.h | 2 |
6 files changed, 63 insertions, 67 deletions
diff --git a/beetplayer.cpp b/beetplayer.cpp index ef3f84f..3ccf9d5 100644 --- a/beetplayer.cpp +++ b/beetplayer.cpp @@ -34,12 +34,12 @@ BeetPlayer::BeetPlayer(QWidget *parent, Qt::WindowFlags f) : QMainWindow(parent, splash.showMessage(tr("Constructing Player..."), Qt::AlignHCenter, Qt::yellow); qApp->processEvents(); mPlayerWidget = new PlayerWidget; - connect(mPlayerWidget, SIGNAL(viewModeChanged(QString)), this, SLOT(setViewMode(QString))); - connect(mPlayerWidget, SIGNAL(playModeChanged(QString)), this, SLOT(setPlayMode(QString))); - connect(mPlayerWidget, SIGNAL(numFilesChanged(int)), this, SLOT(setNumFiles(int))); - connect(mPlayerWidget, SIGNAL(playListLengthChanged(quint64)), this, SLOT(setPlayListLength(quint64))); - connect(mPlayerWidget, SIGNAL(message(QString)), this, SLOT(setMessage(QString))); - connect(mPlayerWidget, SIGNAL(setWinTitle(QString)), this, SLOT(setWindowTitle(QString))); + connect(mPlayerWidget, &PlayerWidget::viewModeChanged, this, &BeetPlayer::setViewMode); + connect(mPlayerWidget, &PlayerWidget::playModeChanged, this, &BeetPlayer::setPlayMode); + connect(mPlayerWidget, &PlayerWidget::numFilesChanged, this, &BeetPlayer::setNumFiles); + connect(mPlayerWidget, &PlayerWidget::playListLengthChanged, this, &BeetPlayer::setPlayListLength); + connect(mPlayerWidget, &PlayerWidget::message, this, &BeetPlayer::setMessage); + connect(mPlayerWidget, &PlayerWidget::setWinTitle, this, &BeetPlayer::setWindowTitle); createStatusbar(); setCentralWidget(mPlayerWidget); splash.showMessage(tr("Populating..."), Qt::AlignHCenter, Qt::yellow); @@ -93,11 +93,11 @@ void BeetPlayer::readSettings(){ void BeetPlayer::createGlobalActions(){ QAction *quitA = new QAction(tr("Quit"), this); quitA->setShortcut(tr("CTRL+Q")); - connect(quitA, SIGNAL(triggered()), qApp, SLOT(closeAllWindows())); + connect(quitA, &QAction::triggered, qApp, &QApplication::closeAllWindows); quitA->setData(Globals::QuitAction); Globals::instance()->addAction(quitA); QAction *configA = new QAction(QIcon(":/chastity_belt.png"), tr("Configure..."), this); - connect(configA, SIGNAL(triggered()), this, SLOT(configure())); + connect(configA, &QAction::triggered, this, &BeetPlayer::configure); configA->setData(Globals::ConfigAction); Globals::instance()->addAction(configA); } diff --git a/configurationdialog.cpp b/configurationdialog.cpp index 1d3b605..58e33e8 100644 --- a/configurationdialog.cpp +++ b/configurationdialog.cpp @@ -33,9 +33,9 @@ ConfigurationDialog::ConfigurationDialog(QWidget *parent, Qt::WindowFlags f) : Q //buttons QPushButton *acceptB = new QPushButton(tr("Save")); - connect(acceptB, SIGNAL(clicked()), this, SLOT(accept())); + connect(acceptB, &QPushButton::clicked, this, &ConfigurationDialog::accept); QPushButton *cancelB = new QPushButton(tr("Cancel")); - connect(cancelB, SIGNAL(clicked()), this, SLOT(reject())); + connect(cancelB, &QPushButton::clicked, this, &ConfigurationDialog::reject); QHBoxLayout *bLayout = new QHBoxLayout; bLayout->addStretch(); bLayout->addWidget(acceptB); @@ -71,9 +71,9 @@ ConfigurationDialog::ConfigurationDialog(QWidget *parent, Qt::WindowFlags f) : Q QSignalMapper *colorMapper = new QSignalMapper(this); colorMapper->setMapping(baseColorB, mBaseColorL); colorMapper->setMapping(altColorB, mAltColorL); - connect(baseColorB, SIGNAL(clicked()), colorMapper, SLOT(map())); - connect(altColorB, SIGNAL(clicked()), colorMapper, SLOT(map())); - connect(colorMapper, SIGNAL(mapped(QWidget*)), this, SLOT(chooseColor(QWidget*))); + connect(baseColorB, &QPushButton::clicked, colorMapper, static_cast<void(QSignalMapper::*)()>(&QSignalMapper::map)); + connect(altColorB, &QPushButton::clicked, colorMapper, static_cast<void(QSignalMapper::*)()>(&QSignalMapper::map)); + connect(colorMapper, static_cast<void(QSignalMapper::*)(QWidget*)>(&QSignalMapper::mapped), this, &ConfigurationDialog::chooseColor); //dialog layout QVBoxLayout *mainLayout = new QVBoxLayout; diff --git a/indexerdialog.cpp b/indexerdialog.cpp index 0722bad..c9e6ca3 100644 --- a/indexerdialog.cpp +++ b/indexerdialog.cpp @@ -12,9 +12,9 @@ IndexerDialog::IndexerDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(paren //buttons QPushButton *startB = new QPushButton(tr("Start")); - connect(startB, SIGNAL(clicked()), mIndexer, SLOT(startIndexing())); + connect(startB, &QPushButton::clicked, mIndexer, &IndexerWidget::startIndexing); QPushButton *stopB = new QPushButton(tr("Stop")); - connect(stopB, SIGNAL(clicked()), mIndexer, SLOT(stopIndexing())); + connect(stopB, &QPushButton::clicked, mIndexer, &IndexerWidget::stopIndexing); QHBoxLayout *buttonLayout = new QHBoxLayout; buttonLayout->addStretch(); buttonLayout->addWidget(startB); diff --git a/indexerwidget.cpp b/indexerwidget.cpp index 49b221a..cd91c36 100644 --- a/indexerwidget.cpp +++ b/indexerwidget.cpp @@ -40,9 +40,9 @@ IndexerWidget::IndexerWidget(QWidget *parent) : QWidget(parent), mMax(0) { //reader mReader = new BeetReader; - connect(mReader, SIGNAL(errorMsg(QString)), this, SLOT(addToError(QString))); - connect(mReader, SIGNAL(totalCount(int)), this, SLOT(setupProgress(int))); - connect(mReader, SIGNAL(progress(int)), this, SLOT(progress(int))); + connect(mReader, &BeetReader::errorMsg, this, &IndexerWidget::addToError); + connect(mReader, &BeetReader::totalCount, this, &IndexerWidget::setupProgress); + connect(mReader, &BeetReader::progress, this, &IndexerWidget::progress); //main layout QVBoxLayout *mainLayout = new QVBoxLayout; diff --git a/playerwidget.cpp b/playerwidget.cpp index a37aea6..f026bfe 100644 --- a/playerwidget.cpp +++ b/playerwidget.cpp @@ -46,8 +46,8 @@ PlayerWidget::~PlayerWidget(){ void PlayerWidget::setupGui(){ //the Player mPlayer = new QMediaPlayer(this); - connect(mPlayer, SIGNAL(positionChanged(qint64)), this, SLOT(setPosition(qint64))); - connect(mPlayer, SIGNAL(mediaStatusChanged(QMediaPlayer::MediaStatus)), this, SLOT(continuePlaying(QMediaPlayer::MediaStatus))); + connect(mPlayer, &QMediaPlayer::positionChanged, this, &PlayerWidget::setPosition); + connect(mPlayer, &QMediaPlayer::mediaStatusChanged, this, &PlayerWidget::continuePlaying); //tray icon mTrayIcon = new QSystemTrayIcon(this); @@ -61,7 +61,7 @@ void PlayerWidget::setupGui(){ mView->setModel(mViewModel); mSearchModel = new QStandardItemModel; mView->setSelectionMode(QAbstractItemView::ExtendedSelection); - connect(mView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(viewDoubleClicked(QModelIndex))); + connect(mView, &BeetView::doubleClicked, this, &PlayerWidget::viewDoubleClicked); mFolderModel = new QStandardItemModel; mCurrentModel = mViewModel; QToolBar *viewTB = new QToolBar; @@ -70,50 +70,50 @@ void PlayerWidget::setupGui(){ mViewByArtistA = new QAction(QIcon(":/artist.png"), tr("View by artist"), this); mViewByArtistA->setCheckable(true); viewAG->addAction(mViewByArtistA); - connect(mViewByArtistA, SIGNAL(triggered()), this, SLOT(doPopulateByArtist())); + connect(mViewByArtistA, &QAction::triggered, this, &PlayerWidget::doPopulateByArtist); QAction *viewByAlbumA = new QAction(QIcon(":/album.png"), tr("View by album"), this); viewByAlbumA->setCheckable(true); viewAG->addAction(viewByAlbumA); - connect(viewByAlbumA, SIGNAL(triggered()), this, SLOT(doPopulateByAlbum())); + connect(viewByAlbumA, &QAction::triggered, this, &PlayerWidget::doPopulateByAlbum); QAction *viewBySongA = new QAction(QIcon(":/song.png"), tr("View by song"), this); viewBySongA->setCheckable(true); viewAG->addAction(viewBySongA); - connect(viewBySongA, SIGNAL(triggered()), this, SLOT(doPopulateBySong())); + connect(viewBySongA, &QAction::triggered, this, &PlayerWidget::doPopulateBySong); QAction *viewByGenreA = new QAction(QIcon(":/genre.png"), tr("View by genre"), this); viewByGenreA->setCheckable(true); viewAG->addAction(viewByGenreA); - connect(viewByGenreA, SIGNAL(triggered()), this, SLOT(doPopulateByGenre())); + connect(viewByGenreA, &QAction::triggered, this, &PlayerWidget::doPopulateByGenre); viewAG->addAction(Helper::createSeparator(this)); QAction *viewByFolderA = new QAction(QIcon(":/folder.png"), tr("View by folder"), this); viewByFolderA->setCheckable(true); viewAG->addAction(viewByFolderA); - connect(viewByFolderA, SIGNAL(triggered()), this, SLOT(doPopulateByFolder())); + connect(viewByFolderA, &QAction::triggered, this, &PlayerWidget::doPopulateByFolder); viewAG->addAction(Helper::createSeparator(this)); mSearchA = new QAction(QIcon(":/gaping_ass.png"), tr("View search"), this); mSearchA->setCheckable(true); viewAG->addAction(mSearchA); - connect(mSearchA, SIGNAL(triggered()), this, SLOT(doFilter())); + connect(mSearchA, &QAction::triggered, this, &PlayerWidget::doFilter); viewTB->addActions(viewAG->actions()); mSelectFilesA = new QAction(QIcon(":/bizarre_amputee.png"), tr("Select files..."), this); mSelectFilesA->setShortcut(tr("CTRL++")); - connect(mSelectFilesA, SIGNAL(triggered()), this, SLOT(doSelectFiles())); + connect(mSelectFilesA, &QAction::triggered, this, &PlayerWidget::doSelectFiles); mDeselectAllA = new QAction(QIcon(":/gaping_ass.png"), tr("Clear Selection"), this); mDeselectAllA->setShortcut(tr("CTRL+-")); - connect(mDeselectAllA, SIGNAL(triggered()), this, SLOT(doDeselect())); + connect(mDeselectAllA, &QAction::triggered, this, &PlayerWidget::doDeleteFiles); mDeleteFilesA = new QAction(QIcon(":/delete.png"), tr("Delete files..."), this); mDeleteFilesA->setShortcut(QKeySequence::Delete); - connect(mDeleteFilesA, SIGNAL(triggered()), this, SLOT(doDeleteFiles())); + connect(mDeleteFilesA, &QAction::triggered, this, &PlayerWidget::doDeleteFiles); //filter QGroupBox *filterGB = new QGroupBox(tr("Search")); mSearch = new QLineEdit; - connect(mSearch, SIGNAL(returnPressed()), this, SLOT(doFilter())); + connect(mSearch, &QLineEdit::returnPressed, this, &PlayerWidget::doFilter); QToolBar *searchTB = new QToolBar; QAction *clearSearchA = new QAction(QIcon(":/clean_tampon.png"), tr("Clear search"), this); - connect(clearSearchA, SIGNAL(triggered()), this, SLOT(clearFilter())); + connect(clearSearchA, &QAction::triggered, this, &PlayerWidget::clearFilter); searchTB->addAction(clearSearchA); QAction *doSearchA = new QAction(QIcon(":/stomp.png"), tr("Go searching!"), this); - connect(doSearchA, SIGNAL(triggered()), this, SLOT(doFilter())); + connect(doSearchA, &QAction::triggered, this, &PlayerWidget::doFilter); searchTB->addAction(doSearchA); QHBoxLayout *filterLayout = new QHBoxLayout; filterLayout->addWidget(mSearch); @@ -132,7 +132,7 @@ void PlayerWidget::setupGui(){ selViewL->addStretch(); leftWidgetL->addLayout(selViewL); leftWidget->setLayout(leftWidgetL); - connect(this, SIGNAL(modelChanged()), this, SLOT(doModelChanged())); + connect(this, &PlayerWidget::modelChanged, this, &PlayerWidget::doModelChanged); //now playing label mNowPlayingL = new QLabel; @@ -144,7 +144,7 @@ void PlayerWidget::setupGui(){ QLabel *l1 = new QLabel(tr("Song")); mSongSlider = new QSlider; mSongSlider->setOrientation(Qt::Horizontal); - connect(mSongSlider, SIGNAL(sliderMoved(int)), this, SLOT(slide(int))); + connect(mSongSlider, &QSlider::sliderMoved, this, &PlayerWidget::slide); mPos = new QLabel(tr("00:00")); mPos->setFont(QFont("courier")); QHBoxLayout *songSliderL = new QHBoxLayout; @@ -169,8 +169,8 @@ void PlayerWidget::setupGui(){ mVolumeSlider->setMaximum(100); mVolumePos = new QLabel(tr("000 %")); mVolumePos->setFont(QFont("courier")); - connect(mVolumeSlider, SIGNAL(valueChanged(int)), mPlayer, SLOT(setVolume(int))); - connect(mVolumeSlider, SIGNAL(valueChanged(int)), this, SLOT(volumeChanged(int))); + connect(mVolumeSlider, &QSlider::valueChanged, mPlayer, &QMediaPlayer::setVolume); + connect(mVolumeSlider, &QSlider::valueChanged, this, &PlayerWidget::volumeChanged); mVolumeSlider->setValue(33); QHBoxLayout *volumeL = new QHBoxLayout; volumeL->addWidget(l2); @@ -196,7 +196,7 @@ void PlayerWidget::setupGui(){ mPlayListView->setModel(mPlayListModel); mPlayListView->setRootIsDecorated(false); mPlayListView->setSelectionMode(QAbstractItemView::ExtendedSelection); - connect(mPlayListView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(playCurrent(QModelIndex))); + connect(mPlayListView, &BeetView::doubleClicked, this, &PlayerWidget::playCurrent); QGroupBox *playListGB = new QGroupBox(tr("Playlist")); QVBoxLayout *playListL = new QVBoxLayout; playListL->addWidget(mPlayListView); @@ -224,67 +224,67 @@ void PlayerWidget::createActions(){ mPlayA = new QAction(QIcon(":/play.png"), tr("Play"), this); mPlayA->setCheckable(true); playAG->addAction(mPlayA); - connect(mPlayA, SIGNAL(triggered()), this, SLOT(doPlay())); + connect(mPlayA, &QAction::triggered, this, &PlayerWidget::doPlay); mPauseA = new QAction(QIcon(":/pause.png"), tr("Pause"), this); mPauseA->setCheckable(true); playAG->addAction(mPauseA); - connect(mPauseA, SIGNAL(triggered()), this, SLOT(doPause())); + connect(mPauseA, &QAction::triggered, this, &PlayerWidget::doPause); mStopA = new QAction(QIcon(":/stop.png"), tr("Stop"), this); mStopA->setCheckable(true); playAG->addAction(mStopA); mStopA->setChecked(true); - connect(mStopA, SIGNAL(triggered()), this, SLOT(doStop())); + connect(mStopA, &QAction::triggered, this, &PlayerWidget::doStop); QAction *playOrPauseA = new QAction(tr("Play or Pause"), this); playOrPauseA->setObjectName("beetPlayerDoPlayOrPause"); - connect(playOrPauseA, SIGNAL(triggered()), this, SLOT(doPlayOrPause())); + connect(playOrPauseA, &QAction::triggered, this, &PlayerWidget::doPlayOrPause); KGlobalAccel::self()->setShortcut(playOrPauseA, QList<QKeySequence>() << QKeySequence(Qt::Key_MediaPlay), KGlobalAccel::Autoloading); QAction *previousA = new QAction(QIcon(":/previous.png"), tr("Previous"), this); previousA->setObjectName("beetPlayerPrevious"); - connect(previousA, SIGNAL(triggered()), this, SLOT(previous())); + connect(previousA, &QAction::triggered, this, &PlayerWidget::previous); KGlobalAccel::self()->setShortcut(previousA, QList<QKeySequence>() << QKeySequence(Qt::Key_Launch2), KGlobalAccel::Autoloading); QAction *nextA = new QAction(QIcon(":/next.png"), tr("Next"), this); nextA->setObjectName("beetPlayerNext"); - connect(nextA, SIGNAL(triggered()), this, SLOT(next())); + connect(nextA, &QAction::triggered, this, &PlayerWidget::next); KGlobalAccel::self()->setShortcut(nextA, QList<QKeySequence>() << QKeySequence(Qt::Key_Launch3), KGlobalAccel::Autoloading); QAction *addToPlayListA = new QAction(QIcon(":/belly_right.png"), tr("Add to playlist"), this); - connect(addToPlayListA, SIGNAL(triggered()), this, SLOT(addToPlayList())); + connect(addToPlayListA, &QAction::triggered, this, &PlayerWidget::addToPlayList); QAction *addToPlayListAndClearA = new QAction(QIcon(":/belly_right_and_clear.png"), tr("Clear and add"), this); - connect(addToPlayListAndClearA, SIGNAL(triggered()), this, SLOT(addToPlayListAndClear())); + connect(addToPlayListAndClearA, &QAction::triggered, this, &PlayerWidget::addToPlayListAndClear); QAction *expandA = new QAction(Helper::iconFromQChar(QChar(0x2640), 90), tr("Expand"), this); - connect(expandA, SIGNAL(triggered()), this, SLOT(expand())); + connect(expandA, &QAction::triggered, this, &PlayerWidget::expand); QAction *collapseAllA = new QAction(Helper::iconFromQChar(QChar(0x2642), 120), tr("Collapse all"), this); - connect(collapseAllA, SIGNAL(triggered()), mView, SLOT(collapseAll())); + connect(collapseAllA, &QAction::triggered, mView, &BeetView::collapseAll); QAction *removeFromPlayListA = new QAction(QIcon(":/belly_left.png"), tr("Remove from playlist"), this); - connect(removeFromPlayListA, SIGNAL(triggered()), this, SLOT(removeFromPlayList())); + connect(removeFromPlayListA, &QAction::triggered, this, &PlayerWidget::removeFromPlayList); QAction *clearPlayListA = new QAction(QIcon(":/delete.png"), tr("Clear Playlist"), this); - connect(clearPlayListA, SIGNAL(triggered()), this, SLOT(clearPlayList())); + connect(clearPlayListA, &QAction::triggered, this, &PlayerWidget::clearPlayList); QAction *refreshA = new QAction(QIcon(":/refresh.png"), tr("Refresh..."), this); - connect(refreshA, SIGNAL(triggered()), this, SLOT(reindex())); + connect(refreshA, &QAction::triggered, this, &PlayerWidget::reindex); QAction *shufflePlayistA = new QAction(QIcon(":/shuffle.png"), tr("Shuffle playlist"), this); - connect(shufflePlayistA, SIGNAL(triggered()), this, SLOT(shufflePlayList())); + connect(shufflePlayistA, &QAction::triggered, this, &PlayerWidget::shufflePlayList); QAction *randomPlayA = new QAction(QIcon(":/dice.png"), tr("Play random"), this); - connect(randomPlayA, SIGNAL(triggered()), this, SLOT(randomPlay())); + connect(randomPlayA, &QAction::triggered, this, &PlayerWidget::randomPlay); QAction *muteA = new QAction(QIcon(":/mute.png"), tr("Mute"), this); muteA->setObjectName("beetPlayerMute"); muteA->setCheckable(true); - connect(muteA, SIGNAL(triggered(bool)), this, SLOT(mute(bool))); + connect(muteA, &QAction::triggered, this, &PlayerWidget::mute); KGlobalAccel::self()->setShortcut(muteA, QList<QKeySequence>() << QKeySequence(Qt::Key_VolumeMute), KGlobalAccel::Autoloading); QAction *volumeUpA = new QAction(tr("Increase volume"), this); volumeUpA->setObjectName("beetPlayerIncVolume"); - connect(volumeUpA, SIGNAL(triggered()), this, SLOT(volumeUp())); + connect(volumeUpA, &QAction::triggered, this, &PlayerWidget::volumeUp); KGlobalAccel::self()->setShortcut(volumeUpA, QList<QKeySequence>() << QKeySequence(Qt::Key_VolumeUp), KGlobalAccel::Autoloading); QAction *volumeDownA = new QAction(tr("Decrease volume"), this); volumeDownA->setObjectName("beetPlayerDecVolume"); - connect(volumeDownA, SIGNAL(triggered()), this, SLOT(volumeDown())); + connect(volumeDownA, &QAction::triggered, this, &PlayerWidget::volumeDown); KGlobalAccel::self()->setShortcut(volumeDownA, QList<QKeySequence>() << QKeySequence(Qt::Key_VolumeDown), KGlobalAccel::Autoloading); QAction *configA = Globals::instance()->action(Globals::ConfigAction); QAction *helpA = new QAction(Helper::iconFromQChar(QChar(0x00BF), 50), tr("Help"), this); QMenu *helpM = new QMenu; QAction *aboutThisA = new QAction(tr("About..."), this); - connect(aboutThisA, SIGNAL(triggered()), this, SLOT(aboutDlg())); + connect(aboutThisA, &QAction::triggered, this, &PlayerWidget::aboutDlg);; helpM->addAction(aboutThisA); QAction *aboutQtA = new QAction(tr("About Qt..."), this); - connect(aboutQtA, SIGNAL(triggered()), qApp, SLOT(aboutQt())); + connect(aboutQtA, &QAction::triggered, qApp, &QApplication::aboutQt); helpM->addAction(aboutQtA); helpA->setMenu(helpM); mView->addAction(addToPlayListA); @@ -337,7 +337,7 @@ void PlayerWidget::createActions(){ trayMenu->addAction(previousA); trayMenu->addSeparator(); QAction *quitA = new QAction(tr("Quit"), this); - connect(quitA, SIGNAL(triggered()), qApp, SLOT(quit())); + connect(quitA, &QAction::triggered, qApp, &QApplication::quit); trayMenu->addAction(quitA); mTrayIcon->setContextMenu(trayMenu); } @@ -546,15 +546,11 @@ void PlayerWidget::populateByGenre(QStandardItem *parent, const QString &filter) } } -void PlayerWidget::doPopulateByFolder(QString dir){ +void PlayerWidget::doPopulateByFolder(){ mCurrentModel = mFolderModel; mFolderModel->clear(); mFolderModel->setHorizontalHeaderLabels(QStringList() << tr("Name")); - if(dir.isEmpty()){ - dir = mCurDir; - } - mCurDir = dir; - QDir d(dir); + QDir d(mCurDir); if(!d.exists()){ d = QDir(QDir::homePath()); mCurDir = d.absolutePath(); @@ -617,8 +613,8 @@ void PlayerWidget::viewDoubleClicked(const QModelIndex &idx){ QString fp(idx.data(FullPathRole).toString()); QFileInfo fi(fp); if(fi.isDir()){ - doPopulateByFolder(fp); mCurDir = fp; + doPopulateByFolder(); }else{ addToPlayList(); } diff --git a/playerwidget.h b/playerwidget.h index 0a1a9c2..04e023a 100644 --- a/playerwidget.h +++ b/playerwidget.h @@ -32,7 +32,7 @@ class PlayerWidget : public QWidget { void doPopulateByAlbum(); void doPopulateByGenre(); void doPopulateBySong(); - void doPopulateByFolder(QString dir = QString()); + void doPopulateByFolder(); void doModelChanged(); void viewDoubleClicked(const QModelIndex &idx); void doPlay(); |