void KMultiFormListBoxWindowed::slotEditSelected() { WindowListboxItem *item = selected(); if (item) { slotEditSelected(item); } }
KMultiFormListBoxWindowed::KMultiFormListBoxWindowed(KMultiFormListBoxFactory *factory, TQWidget *parent, bool showUpDownButtons, bool showHelpButton, TQString addButtonText,const char *name) : TQWidget( parent, name ) { _layout = new TQVBoxLayout(this); TQHBoxLayout *innerLayout = new TQHBoxLayout(); _layout->addLayout(innerLayout); _listbox = new TDEListBox(this,"listbox"); _listbox->setSelectionMode(TQListBox::Single); innerLayout->addWidget(_listbox); TQVBoxLayout *buttons = new TQVBoxLayout(); innerLayout->addLayout(buttons); TQPushButton *but = new TQPushButton(addButtonText, this,"Add Button"); buttons->addWidget(but,0); connect(but, TQT_SIGNAL(clicked()), this, TQT_SLOT(addNewElement())); but = new TQPushButton(i18n("Edit"), this,"Edit Button"); buttons->addWidget(but,0); connect(but,TQT_SIGNAL(clicked()), this, TQT_SLOT(slotEditSelected())); connect(_listbox, TQT_SIGNAL(doubleClicked(TQListBoxItem *)), this, TQT_SLOT(slotEditSelected(TQListBoxItem *))); _buttonList.append(but); but = new TQPushButton(i18n("Delete"), this, "Delete Button"); buttons->addWidget(but,0); connect(but, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotDeleteEntry())); _buttonList.append(but); but = new TQPushButton(i18n("Copy"), this, "Copy Button"); buttons->addWidget(but,0); connect(but, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotCopySelected())); _buttonList.append(but); if (showUpDownButtons) { but = new TQPushButton(i18n("Up"), this, "Up Button"); buttons->addWidget(but, 0); connect(but, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotMoveItemUp())); _buttonList.append(but); but = new TQPushButton(i18n("Down"), this, "Down Button"); buttons->addWidget(but, 0); connect(but, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotMoveItemDown())); _buttonList.append(but); } if (showHelpButton) { but = new KPushButton(KStdGuiItem::help(), this, "Help Button"); buttons->addWidget(but, 0); connect(but, TQT_SIGNAL(clicked()), this, TQT_SIGNAL(showHelp())); } buttons->addStretch(1); _factory = factory; slotUpdateButtonState(); }
void AlbumsView::contextMenuEvent( QGraphicsSceneContextMenuEvent *event ) { KAction *appendAction = new KAction( KIcon( "media-track-add-amarok" ), i18n( "&Append to Playlist" ), this ); KAction *loadAction = new KAction( KIcon( "folder-open" ), i18nc( "Replace the currently loaded tracks with these", "&Load" ), this ); KAction *queueAction = new KAction( KIcon( "media-track-queue-amarok" ), i18n( "&Queue" ), this ); KAction *editAction = new KAction( KIcon( "media-track-edit-amarok" ), i18n( "Edit Track Details" ), this ); connect( appendAction, SIGNAL( triggered() ), this, SLOT( slotAppendSelected() ) ); connect( loadAction , SIGNAL( triggered() ), this, SLOT( slotPlaySelected() ) ); connect( queueAction , SIGNAL( triggered() ), this, SLOT( slotQueueSelected() ) ); connect( editAction , SIGNAL( triggered() ), this, SLOT( slotEditSelected() ) ); KMenu menu; menu.addAction( appendAction ); menu.addAction( loadAction ); menu.addAction( queueAction ); menu.addSeparator(); menu.addAction( editAction ); QModelIndex index = nativeWidget()->indexAt( event->pos().toPoint() ); if( index.isValid() ) { QStandardItem *item = static_cast<QStandardItemModel*>( model() )->itemFromIndex( index ); AlbumItem *album = dynamic_cast<AlbumItem*>(item); if( album ) { Meta::AlbumPtr albumPtr = album->album(); Meta::CustomActionsCapability *cac = albumPtr->create<Meta::CustomActionsCapability>(); if( cac ) { QList<PopupDropperAction *> actions = cac->customActions(); menu.addSeparator(); foreach( PopupDropperAction *action, actions ) menu.addAction( action ); } } } menu.exec( event->screenPos() ); }
KMultiFormListBoxWindowed::KMultiFormListBoxWindowed(KMultiFormListBoxFactory *factory, QWidget *parent, bool showUpDownButtons, bool showHelpButton, QString addButtonText) : QWidget( parent ) { _layout = new QVBoxLayout(this); QHBoxLayout *innerLayout = new QHBoxLayout(); _layout->addLayout(innerLayout); _listbox = new KListWidget(this/*,"listbox"*/); _listbox->setSelectionMode(QAbstractItemView::SingleSelection); innerLayout->addWidget(_listbox); QVBoxLayout *buttons = new QVBoxLayout(); innerLayout->addLayout(buttons); KPushButton *but = new KPushButton(addButtonText, this); but->setObjectName("Add Button"); buttons->addWidget(but,0); connect(but, SIGNAL(clicked()), this, SLOT(addNewElement())); but = new KPushButton(i18n("Edit"), this); but->setObjectName("Edit Button"); buttons->addWidget(but,0); connect(but,SIGNAL(clicked()), this, SLOT(slotEditSelected())); connect(_listbox, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(slotEditSelected(QListWidgetItem *))); _buttonList.append(but); but = new KPushButton(i18n("Delete"), this); but->setObjectName("Delete Button"); buttons->addWidget(but,0); connect(but, SIGNAL(clicked()), this, SLOT(slotDeleteEntry())); _buttonList.append(but); but = new KPushButton(i18n("Copy"), this); but->setObjectName("Copy Button"); buttons->addWidget(but,0); connect(but, SIGNAL(clicked()), this, SLOT(slotCopySelected())); _buttonList.append(but); if (showUpDownButtons) { but = new KPushButton(i18n("Up"), this); but->setObjectName("Up Button"); buttons->addWidget(but, 0); connect(but, SIGNAL(clicked()), this, SLOT(slotMoveItemUp())); _buttonList.append(but); but = new KPushButton(i18n("Down"), this); but->setObjectName( "Down Button"); buttons->addWidget(but, 0); connect(but, SIGNAL(clicked()), this, SLOT(slotMoveItemDown())); _buttonList.append(but); } if (showHelpButton) { but = new KPushButton(KStandardGuiItem::help(), this); but->setObjectName( "Help Button"); buttons->addWidget(but, 0); connect(but, SIGNAL(clicked()), this, SIGNAL(showHelp())); } buttons->addStretch(1); _factory = factory; slotUpdateButtonState(); }