Source Code (Use browser search to find items of interest.)
Class Index
klipper'ActionWidget (./kdeutils/klipper/configdialog.h:44)
class ActionWidget : public QVGroupBox
{
Q_OBJECT
friend class ConfigDialog;
public:
ActionWidget( const ActionList *list, QWidget *parent, const char *name );
~ActionWidget();
/**
* Creates a list of actions from the listView and returns a pointer to the
* list.
* Make sure to free that pointer when you don't need it anymore.
*/
ActionList * actionList();
private slots:
void slotAddAction();
void slotDeleteAction();
void slotRightPressed( QListViewItem *, const QPoint&, int col );
private:
KEditableListView *listView;
};
klipper'ActionWidget::ActionWidget() (./kdeutils/klipper/configdialog.cpp:90)
ActionWidget::ActionWidget( const ActionList *list, QWidget *parent,
const char *name )
: QVGroupBox( parent, name )
{
ASSERT( list != 0L );
setTitle( i18n("Action settings (right-click to add/remove commands)") );
QVBoxLayout *layout = new QVBoxLayout( parent, 0,
KDialogBase::spacingHint() );
layout->addWidget( this );
listView = new KEditableListView( this, "list view" );
listView->addColumn( i18n("Regular expression") );
listView->addColumn( i18n("Description") );
listView->setRootIsDecorated( true );
listView->setMultiSelection( false );
listView->setAllColumnsShowFocus( true );
listView->setSelectionMode( QListView::Single );
connect( listView, SIGNAL( rightButtonPressed( QListViewItem *,
const QPoint&, int) ),
SLOT( slotRightPressed( QListViewItem *, const QPoint&, int )));
ClipAction *action = 0L;
ClipCommand *command = 0L;
QListViewItem *item = 0L;
QListViewItem *child = 0L;
QListViewItem *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 QListViewItem( listView, after,
action->regExp(), action->description() );
item->setPixmap( 0, doc );
QListIterator<ClipCommand> it2( action->commands() );
for ( command = it2.current(); command; command = ++it2 ) {
child = new QListViewItem( item, after,
command->command, command->description);
child->setPixmap( 0, exec );
after = child;
}
after = item;
}
listView->setSorting( -1 ); // newly inserted items just append unsorted
QHBox *box = new QHBox( this );
box->setSpacing( KDialog::spacingHint() );
QPushButton *button = new QPushButton( i18n("&Add Action"), box );
connect( button, SIGNAL( clicked() ), SLOT( slotAddAction() ));
button = new QPushButton( i18n("&Delete Action"), box );
connect( button, 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( WordBreak | AlignLeft | AlignVCenter );
box->setStretchFactor( label, 5 );
}
klipper'ActionWidget::~ActionWidget() (./kdeutils/klipper/configdialog.cpp:155)
ActionWidget::~ActionWidget()
{
}
klipper'ActionWidget::slotRightPressed() (./kdeutils/klipper/configdialog.cpp:160)
void ActionWidget::slotRightPressed( QListViewItem *item, const QPoint&, int )
{
if ( !item )
return;
int addCmd = 0, rmCmd = 0;
KPopupMenu *menu = new KPopupMenu;
addCmd = menu->insertItem( i18n("Add Command") );
rmCmd = menu->insertItem( i18n("Remove Command") );
if ( !item->parent() ) {// no "command" item
menu->setItemEnabled( rmCmd, false );
item->setOpen( true );
}
int id = menu->exec( QCursor::pos() );
if ( id == addCmd ) {
QListViewItem *p = item->parent() ? item->parent() : item;
QListViewItem *cmdItem = new QListViewItem( p, item,
i18n("Click here to set the command to be executed"),
i18n("Description") );
cmdItem->setPixmap( 0, SmallIcon( "exec" ) );
}
else if ( id == rmCmd )
delete item;
delete menu;
}
klipper'ActionWidget::slotAddAction() (./kdeutils/klipper/configdialog.cpp:188)
void ActionWidget::slotAddAction()
{
QListViewItem *item = new QListViewItem( listView );
item->setPixmap( 0, SmallIcon( "misc" ));
}
klipper'ActionWidget::slotDeleteAction() (./kdeutils/klipper/configdialog.cpp:195)
void ActionWidget::slotDeleteAction()
{
QListViewItem *item = listView->currentItem();
if ( item && item->parent() )
item = item->parent();
delete item;
}
klipper'ActionWidget::actionList() (./kdeutils/klipper/configdialog.cpp:204)
ActionList * ActionWidget::actionList()
{
QListViewItem *item = listView->firstChild();
QListViewItem *child = 0L;
ClipAction *action = 0L;
ActionList *list = new ActionList;
list->setAutoDelete( true );
while ( item ) {
action = new ClipAction( item->text( 0 ), item->text( 1 ) );
child = item->firstChild();
// add the commands
while ( child ) {
action->addCommand( child->text( 0 ), child->text( 1 ), true );
child = child->nextSibling();
}
list->append( action );
item = item->nextSibling();
}
return list;
}
///////////////////////////////////////////////////////
//////////