ActionWidget::ActionWidget( const ActionList *list, ConfigDialog* configWidget, QWidget *parent, const char *name ) : KVBox( parent ), advancedWidget( 0L ) { setObjectName(name); Q_ASSERT( list != 0L ); QLabel *lblAction = new QLabel( i18n("Action &list (right click to add/remove commands):"), this ); listView = new ListView( configWidget, this ); lblAction->setBuddy( listView ); listView->addColumn( i18n("Regular Expression (see http://doc.trolltech.com/qregexp.html#details)") ); listView->addColumn( i18n("Description") ); listView->setRenameable(0); listView->setRenameable(1); listView->setItemsRenameable( true ); listView->setItemsMovable( false ); // listView->setAcceptDrops( true ); // listView->setDropVisualizer( true ); // listView->setDragEnabled( true ); listView->setRootIsDecorated( true ); listView->setMultiSelection( false ); listView->setAllColumnsShowFocus( true ); listView->setSelectionMode( Q3ListView::Single ); connect( listView, SIGNAL(executed( Q3ListViewItem*, const QPoint&, int )), SLOT( slotItemChanged( Q3ListViewItem*, const QPoint& , int ) )); connect( listView, SIGNAL( selectionChanged ( Q3ListViewItem * )), SLOT(selectionChanged ( Q3ListViewItem * ))); connect(listView, SIGNAL(contextMenu(K3ListView *, Q3ListViewItem *, const QPoint&)), SLOT( slotContextMenu(K3ListView*, Q3ListViewItem*, const QPoint&))); ClipAction *action = 0L; ClipCommand *command = 0L; Q3ListViewItem *item = 0L; Q3ListViewItem *child = 0L; Q3ListViewItem *after = 0L; // QListView's default inserting really sucks ActionListIterator it( *list ); const QPixmap& doc = SmallIcon( "misc" ); const QPixmap& exec = SmallIcon( "exec" ); for ( action = it.current(); action; action = ++it ) { item = new Q3ListViewItem( listView, after, action->regExp(), action->description() ); item->setPixmap( 0, doc ); Q3PtrListIterator<ClipCommand> it2( action->commands() ); for ( command = it2.current(); command; command = ++it2 ) { child = new Q3ListViewItem( item, after, command->command, command->description); if ( command->pixmap.isEmpty() ) child->setPixmap( 0, exec ); else child->setPixmap( 0, SmallIcon( command->pixmap ) ); after = child; } after = item; } listView->setSorting( -1 ); // newly inserted items just append unsorted cbUseGUIRegExpEditor = new QCheckBox( i18n("&Use graphical editor for editing regular expressions" ), this ); if ( KServiceTypeTrader::self()->query("KRegExpEditor/KRegExpEditor").isEmpty() ) { cbUseGUIRegExpEditor->hide(); cbUseGUIRegExpEditor->setChecked( false ); } KHBox *box = new KHBox( this ); box->setSpacing( KDialog::spacingHint() ); QPushButton *button = new QPushButton( i18n("&Add Action"), box ); connect( button, SIGNAL( clicked() ), SLOT( slotAddAction() )); delActionButton = new QPushButton( i18n("&Delete Action"), box ); connect( delActionButton, SIGNAL( clicked() ), SLOT( slotDeleteAction() )); QLabel *label = new QLabel(i18n("Click on a highlighted item's column to change it. \"%s\" in a command will be replaced with the clipboard contents."), box); label->setAlignment( Qt::AlignLeft | Qt::AlignVCenter ); label->setWordWrap( true ); box->setStretchFactor( label, 5 ); box = new KHBox( this ); QPushButton *advanced = new QPushButton( i18n("Advanced..."), box ); advanced->setFixedSize( advanced->sizeHint() ); connect( advanced, SIGNAL( clicked() ), SLOT( slotAdvanced() )); (void) new QWidget( box ); // spacer delActionButton->setEnabled(listView->currentItem () !=0); }