本文整理汇总了C++中Playlist::id方法的典型用法代码示例。如果您正苦于以下问题:C++ Playlist::id方法的具体用法?C++ Playlist::id怎么用?C++ Playlist::id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Playlist
的用法示例。
在下文中一共展示了Playlist::id方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updatePlaylists
/** Update saved playlists when one is adding a new one. */
void PlaylistDialog::updatePlaylists()
{
// Populate saved playlists area
_savedPlaylistModel->clear();
_savedPlaylistModel->blockSignals(true);
QMap<uint, Playlist*> map;
for (int i = 0; i < _playlists.count(); i++) {
Playlist *p = _playlists.at(i);
if (p->id() != 0) {
map.insert(p->id(), p);
}
}
for (PlaylistDAO playlist : SqlDatabase::instance()->selectPlaylists()) {
QStandardItem *item = new QStandardItem(playlist.title());
item->setData(playlist.id(), PlaylistID);
if (playlist.icon().isEmpty()) {
Playlist *p = map.value(playlist.id().toUInt());
if (p && p->isModified()) {
item->setIcon(QIcon(":/icons/playlist_modified"));
item->setData(true, PlaylistModified);
item->setToolTip(tr("This playlist has changed"));
} else {
item->setIcon(QIcon(":/icons/playlist"));
}
} else {
item->setIcon(QIcon(playlist.icon()));
}
_savedPlaylistModel->appendRow(item);
_saved.insert(item, playlist);
}
_savedPlaylistModel->blockSignals(false);
// Reset buttons status
loadPlaylists->setEnabled(false);
savePlaylists->setEnabled(false);
deletePlaylists->setEnabled(false);
exportPlaylists->setEnabled(false);
}
示例2: populatePreviewFromSaved
void PlaylistDialog::populatePreviewFromSaved(const QItemSelection &, const QItemSelection &)
{
static const int MAX_TRACKS_PREVIEW_AREA = 30;
QModelIndexList indexes = savedPlaylists->selectionModel()->selectedIndexes();
bool empty = indexes.isEmpty();
this->clearPreview(!empty);
if (indexes.size() == 1) {
uint playlistId = _savedPlaylistModel->itemFromIndex(indexes.first())->data(PlaylistID).toUInt();
QList<TrackDAO> tracks = SqlDatabase::instance()->selectPlaylistTracks(playlistId);
for (int i = 0; i < tracks.size(); i++) {
TrackDAO track = tracks.at(i);
QTreeWidgetItem *item = new QTreeWidgetItem;
item->setText(0, QString("%1 (%2 - %3)").arg(track.title(), track.artist(), track.album()));
previewPlaylist->addTopLevelItem(item);
if (i + 1 == MAX_TRACKS_PREVIEW_AREA) {
QTreeWidgetItem *item = new QTreeWidgetItem;
item->setText(0, tr("And more tracks..."));
previewPlaylist->addTopLevelItem(item);
break;
}
}
}
loadPlaylists->setDisabled(empty);
deletePlaylists->setDisabled(empty);
exportPlaylists->setEnabled(indexes.size() == 1);
// Some work for the Save button
if (empty) {
savePlaylists->setEnabled(false);
} else {
bool allPlaylistsAreModified = true;
QMap<uint, Playlist*> map;
for (int i = 0; i < _playlists.count(); i++) {
Playlist *p = _playlists.at(i);
map.insert(p->id(), p);
}
for (QModelIndex idx : indexes) {
uint playlistId = idx.data(PlaylistID).toUInt();
if (map.contains(playlistId)) {
Playlist *p = map.value(playlistId);
allPlaylistsAreModified = allPlaylistsAreModified && p->isModified();
}
}
savePlaylists->setEnabled(allPlaylistsAreModified);
}
}
示例3: updatePlaylist
UpdateStatus Database::updatePlaylist(const Playlist &playlist)
{
pqxx::result res;
try
{
res = _work.parameterized("UPDATE playlists "
"SET name=$1, "
"is_public=$2 "
"WHERE id=$3 "
" AND user_id=$4;")
(playlist.name())(playlist.isPublic())
(playlist.id())(playlist.userId()).exec();
}
catch (const pqxx::unique_violation &e)
{
return UpdateStatus::CONFLICT;
}
return res.affected_rows() == 1 ? UpdateStatus::UPDATED : UpdateStatus::NOT_FOUND;
}
示例4: open
/** Redefined: clean preview area, populate once again lists. */
void PlaylistDialog::open()
{
SettingsPrivate *settings = SettingsPrivate::instance();
if (settings->value("PlaylistDialogGeometry").isValid()) {
this->restoreGeometry(settings->value("PlaylistDialogGeometry").toByteArray());
}
this->clearPreview(false);
for (int i = 0; i < _playlists.count(); i++) {
Playlist *p = _playlists.at(i);
if (p && p->id() == 0 && !p->mediaPlaylist()->isEmpty()) {
QStandardItem *item = new QStandardItem(p->title());
_unsavedPlaylistModel->appendRow(item);
_unsaved.insert(item, p);
}
}
this->updatePlaylists();
QDialog::open();
this->activateWindow();
}
示例5: emptyPlaylist
PlaylistDialog::PlaylistDialog(QWidget *parent)
: QDialog(parent)
, _unsavedPlaylistModel(new QStandardItemModel(this))
, _savedPlaylistModel(new QStandardItemModel(this))
{
setupUi(this);
this->setAttribute(Qt::WA_DeleteOnClose);
unsavedPlaylists->setAttribute(Qt::WA_MacShowFocusRect, false);
savedPlaylists->setAttribute(Qt::WA_MacShowFocusRect, false);
previewPlaylist->setAttribute(Qt::WA_MacShowFocusRect, false);
delete groupBoxPreview->layout();
_stackLayout = new QStackedLayout(groupBoxPreview);
groupBoxPreview->setContentsMargins(11, 24, 11, 11);
QLabel *icon = new QLabel();
icon->setAlignment(Qt::AlignCenter);
QPixmap emptyPlaylist(":/icons/emptyPlaylist");
emptyPlaylist.setDevicePixelRatio(2.0);
icon->setPixmap(emptyPlaylist);
_labelEmptyPreview = new QLabel(tr("This preview area is empty.\nSelect a playlist to display the first 30 tracks."));
_labelEmptyPreview->setAlignment(Qt::AlignCenter);
_labelEmptyPreview->setWordWrap(true);
QVBoxLayout *vboxLayout = new QVBoxLayout();
vboxLayout->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Expanding));
vboxLayout->addWidget(icon);
vboxLayout->addWidget(_labelEmptyPreview);
vboxLayout->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Expanding));
QWidget *widget = new QWidget();
widget->setLayout(vboxLayout);
_stackLayout->addWidget(widget);
_stackLayout->addWidget(previewPlaylist);
loadPlaylists->setIcon(this->style()->standardIcon(QStyle::SP_DialogOpenButton));
deletePlaylists->setIcon(this->style()->standardIcon(QStyle::SP_DialogCloseButton));
exportPlaylists->setIcon(this->style()->standardIcon(QStyle::SP_DialogSaveButton));
unsavedPlaylists->installEventFilter(this);
savedPlaylists->installEventFilter(this);
savedPlaylists->setDragDropMode(QListView::DropOnly);
this->installEventFilter(this);
unsavedPlaylists->setModel(_unsavedPlaylistModel);
savedPlaylists->setModel(_savedPlaylistModel);
/// XXX: MiamStyledItemDelegate should be improved!
// savedPlaylists->setItemDelegate(new MiamStyledItemDelegate(savedPlaylists, false));
connect(unsavedPlaylists->selectionModel(), &QItemSelectionModel::selectionChanged, this, &PlaylistDialog::populatePreviewFromUnsaved);
connect(savedPlaylists->selectionModel(), &QItemSelectionModel::selectionChanged, this, &PlaylistDialog::populatePreviewFromSaved);
connect(loadPlaylists, &QPushButton::clicked, this, &PlaylistDialog::loadSelectedPlaylists);
connect(savePlaylists, &QPushButton::clicked, this, [=]() {
for (QModelIndex idx : savedPlaylists->selectionModel()->selectedIndexes()) {
uint playlistId = idx.data(PlaylistID).toUInt();
for (int i = 0; i < _playlists.count(); i++) {
Playlist *p = _playlists.at(i);
if (playlistId == p->id()) {
emit aboutToSavePlaylist(p, true);
break;
}
}
}
this->updatePlaylists();
});
connect(deletePlaylists, &QPushButton::clicked, this, &PlaylistDialog::deleteSavedPlaylists);
connect(unsavedPlaylists->model(), &QStandardItemModel::rowsAboutToBeRemoved, this, &PlaylistDialog::dropAutoSavePlaylists);
connect(unsavedPlaylists->model(), &QStandardItemModel::rowsRemoved, this, [=](const QModelIndex &, int, int) {
this->updatePlaylists();
});
connect(_unsavedPlaylistModel, &QStandardItemModel::itemChanged, this, &PlaylistDialog::renameItem);
connect(_savedPlaylistModel, &QStandardItemModel::itemChanged, this, &PlaylistDialog::renameItem);
connect(exportPlaylists, &QPushButton::clicked, this, &PlaylistDialog::exportSelectedPlaylist);
}