~ubuntu-branches/ubuntu/vivid/kdepim/vivid

« back to all changes in this revision

Viewing changes to kmail/simplestringlisteditor.cpp

  • Committer: Package Import Robot
  • Author(s): Rohan Garg
  • Date: 2013-02-06 11:49:08 UTC
  • mfrom: (0.2.38)
  • Revision ID: package-import@ubuntu.com-20130206114908-eb7adh9xp54jk7gi
Tags: 4:4.10.0a-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
#include <kdebug.h>
38
38
#include <kpushbutton.h>
39
39
#include <kdialog.h>
 
40
#include <KMenu>
40
41
#include <QVBoxLayout>
41
42
#include <QHBoxLayout>
42
43
#include <QListWidget>
62
63
  hlay->setMargin( 0 );
63
64
 
64
65
  mListBox = new QListWidget( this );
 
66
 
 
67
  mListBox->setContextMenuPolicy( Qt::CustomContextMenu );
 
68
  connect( mListBox, SIGNAL(customContextMenuRequested(QPoint)),
 
69
           SLOT(slotContextMenu(QPoint)) );
 
70
 
 
71
 
65
72
  mListBox->setSelectionMode(QAbstractItemView::ExtendedSelection);
66
73
  hlay->addWidget( mListBox, 1 );
67
74
 
347
354
  }
348
355
}
349
356
 
 
357
void SimpleStringListEditor::slotContextMenu(const QPoint&pos)
 
358
{
 
359
    QList<QListWidgetItem *> lstSelectedItems = mListBox->selectedItems();
 
360
    const bool hasItemsSelected = !lstSelectedItems.isEmpty();
 
361
    KMenu *menu = new KMenu( this );
 
362
    if (mAddButton) {
 
363
        menu->addAction( mAddButton->text(), this, SLOT(slotAdd()));
 
364
    }
 
365
    if (mModifyButton && (lstSelectedItems.count() == 1)) {
 
366
        menu->addAction( mModifyButton->text(), this, SLOT(slotModify()));
 
367
    }
 
368
    if (mRemoveButton && hasItemsSelected) {
 
369
        menu->addAction( mRemoveButton->text(), this, SLOT(slotRemove()));
 
370
    }
 
371
    menu->exec( mListBox->mapToGlobal( pos ) );
 
372
    delete menu;
 
373
}
 
374
 
350
375
 
351
376
 
352
377
#include "simplestringlisteditor.moc"