Skip to content

Commit

Permalink
Better connect
Browse files Browse the repository at this point in the history
  • Loading branch information
kraxarn committed Jul 19, 2020
1 parent 9840203 commit 9948ebe
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 39 deletions.
24 changes: 5 additions & 19 deletions src/librarylist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,14 @@ LibraryList::LibraryList(spt::Spotify &spotify, QWidget *parent)
setCurrentItem(nullptr);

QTreeWidget::connect(
this, &QTreeWidget::itemClicked, this,
[this](QTreeWidgetItem *item, int column)
{
clicked(item);
});

this, &QTreeWidget::itemClicked, this, &LibraryList::clicked);
QTreeWidget::connect(
this, &QTreeWidget::itemDoubleClicked, this,
[this](QTreeWidgetItem *item, int column)
{
doubleClicked(item);
});

this, &QTreeWidget::itemDoubleClicked, this, &LibraryList::doubleClicked);
QTreeWidget::connect(
this, &QTreeWidget::itemExpanded, this,
[this](QTreeWidgetItem *item)
{
expanded(item);
});
this, &QTreeWidget::itemExpanded, this, &LibraryList::expanded);
}

void LibraryList::clicked(QTreeWidgetItem *item)
void LibraryList::clicked(QTreeWidgetItem *item, int)
{
auto mainWindow = dynamic_cast<MainWindow *>(parent);
if (mainWindow == nullptr)
Expand Down Expand Up @@ -118,7 +104,7 @@ void LibraryList::clicked(QTreeWidgetItem *item)
}
}

void LibraryList::doubleClicked(QTreeWidgetItem *item)
void LibraryList::doubleClicked(QTreeWidgetItem *item, int)
{
auto mainWindow = dynamic_cast<MainWindow*>(parent);
if (mainWindow == nullptr)
Expand Down
4 changes: 2 additions & 2 deletions src/librarylist.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class LibraryList: public QTreeWidget
spt::Spotify &spotify;
QWidget *parent = nullptr;

void clicked(QTreeWidgetItem *item);
void doubleClicked(QTreeWidgetItem *item);
void clicked(QTreeWidgetItem *item, int column);
void doubleClicked(QTreeWidgetItem *item, int column);
void expanded(QTreeWidgetItem *item);
};

Expand Down
21 changes: 4 additions & 17 deletions src/playlistlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,13 @@ PlaylistList::PlaylistList(spt::Spotify &spotify, QWidget *parent)
setCurrentRow(0);

QListWidget::connect(
this, &QListWidget::itemClicked, this,
[this](QListWidgetItem *item)
{
clicked(item);
});

this, &QListWidget::itemClicked, this, &PlaylistList::clicked);
QListWidget::connect(
this, &QListWidget::itemDoubleClicked, this,
[this](QListWidgetItem *item)
{
doubleClicked();
});
this, &QListWidget::itemDoubleClicked, this, &PlaylistList::doubleClicked);

setContextMenuPolicy(Qt::ContextMenuPolicy::CustomContextMenu);
QWidget::connect(
this, &QWidget::customContextMenuRequested, this,
[this](const QPoint &pos)
{
menu(pos);
});
this, &QWidget::customContextMenuRequested, this, &PlaylistList::menu);
}

void PlaylistList::clicked(QListWidgetItem *item)
Expand All @@ -43,7 +30,7 @@ void PlaylistList::clicked(QListWidgetItem *item)
mainWindow->loadPlaylist(currentPlaylist);
}

void PlaylistList::doubleClicked()
void PlaylistList::doubleClicked(QListWidgetItem *)
{
auto mainWindow = (MainWindow *) parent;
auto currentPlaylist = mainWindow->getSptPlaylists().at(currentRow());
Expand Down
2 changes: 1 addition & 1 deletion src/playlistlist.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ class PlaylistList: public QListWidget
QWidget *parent;

void clicked(QListWidgetItem *item);
void doubleClicked();
void doubleClicked(QListWidgetItem *item);
void menu(const QPoint &pos);
};

0 comments on commit 9948ebe

Please sign in to comment.