connect(ui.listView, SIGNAL( contextMenuRequested( Q3ListViewItem *, const QPoint& , int ) ),
this,
SLOT( PlaylistMenu
( Q3ListViewItem
*,
const QPoint &,
int ) ) );
contextMenu = new Q3PopupMenu( this);
contextMenu2 = new Q3PopupMenu( this);
connect(contextMenu2,
SIGNAL(triggered
(QAction *)),
this,
SLOT(actionTriggered
(QAction *a
)));
void MainWindow
::PlaylistMenu( Q3ListViewItem
* Item,
const QPoint & point,
int ) {
if( Item )
contextMenu->popup( point );
Q_CHECK_PTR( contextMenu );
contextMenu2->clear();
contextMenu->clear();
if((ui.playlistname_cb->currentText() == "") && (ui.listView->childCount() > 0))
{
contextMenu2->setTitle("add to Playlist");
QSqlQuery select_playlistname
("select playlistname from playlistname_tbl");
while(select_playlistname.next())
{
QString playlistname
= select_playlistname.
value(0).
toString();
contextMenu2->addAction(playlistname, this, SLOT(addToPlaylist()));
contextMenu->addMenu(contextMenu2);
}
contextMenu
->exec
( QCursor::pos() );
//delete contextMenu;
//delete contextMenu2;
return;
}
}
void MainWindow::addToPlaylist()
{
}
void MainWindow
::actionTriggered(QAction *a
) {
}
connect(ui.listView, SIGNAL( contextMenuRequested( Q3ListViewItem *, const QPoint& , int ) ),
this, SLOT( PlaylistMenu( Q3ListViewItem *, const QPoint &, int ) ) );
contextMenu = new Q3PopupMenu( this);
contextMenu2 = new Q3PopupMenu( this);
connect(contextMenu2,SIGNAL(triggered(QAction *)),this,SLOT(actionTriggered(QAction *a)));
void MainWindow::PlaylistMenu( Q3ListViewItem* Item, const QPoint & point, int )
{
if( Item )
contextMenu->popup( point );
Q_CHECK_PTR( contextMenu );
contextMenu2->clear();
contextMenu->clear();
if((ui.playlistname_cb->currentText() == "") && (ui.listView->childCount() > 0))
{
contextMenu2->setTitle("add to Playlist");
QSqlQuery select_playlistname("select playlistname from playlistname_tbl");
while(select_playlistname.next())
{
QString playlistname = select_playlistname.value(0).toString();
contextMenu2->addAction(playlistname, this, SLOT(addToPlaylist()));
contextMenu->addMenu(contextMenu2);
}
contextMenu->exec( QCursor::pos() );
//delete contextMenu;
//delete contextMenu2;
return;
}
}
void MainWindow::addToPlaylist()
{
QMessageBox::information(this, "", "addToPlaylist");
}
void MainWindow::actionTriggered(QAction *a)
{
QString str = a->text();
QMessageBox::information(this, "", str);
}
To copy to clipboard, switch view to plain text mode
Bookmarks