Пример #1
0
AddressEditWidget::AddressEditWidget( QWidget *parent )
  : QWidget( parent ), mReadOnly( false )
{
  QGridLayout *layout = new QGridLayout( this );
  layout->setSpacing( KDialog::spacingHint() );
  layout->setMargin( 0 );

  mAddressSelectionWidget = new AddressSelectionWidget( this );
  connect( mAddressSelectionWidget, SIGNAL(selectionChanged(KABC::Address)),
           SLOT(updateAddressView()) );
  layout->addWidget( mAddressSelectionWidget, 0, 0, 1, 3 );

  mAddressView = new QLabel( this );
  mAddressView->setFrameStyle( QFrame::Panel | QFrame::Sunken );
  mAddressView->setMinimumHeight( 20 );
  mAddressView->setAlignment( Qt::AlignTop );
  mAddressView->setTextFormat( Qt::PlainText );
  mAddressView->setTextInteractionFlags( Qt::TextSelectableByKeyboard | Qt::TextSelectableByMouse );
  layout->addWidget( mAddressView, 1, 0, 1, 3 );

  mCreateButton = new QPushButton( i18nc( "street/postal", "New..." ), this );
  connect( mCreateButton, SIGNAL(clicked()), this, SLOT(createAddress()) );
  mEditButton = new QPushButton( i18nc( "street/postal", "Edit..." ), this );
  connect( mEditButton, SIGNAL(clicked()), this, SLOT(editAddress()) );
  mDeleteButton = new QPushButton( i18nc( "street/postal", "Delete" ), this );
  connect( mDeleteButton, SIGNAL(clicked()), this, SLOT(deleteAddress()) );

  layout->addWidget( mCreateButton, 2, 0 );
  layout->addWidget( mEditButton, 2, 1 );
  layout->addWidget( mDeleteButton, 2, 2 );

  updateButtons();
}
Пример #2
0
void PersonView::slotLinkClicked( const QUrl &url )
{
  qDebug() << "CLICKED" << url;

  if ( url.scheme() == "polka" ) {
    QStringList path = url.path().split("/");
    QString action = path.first();
    qDebug() << "ACTION" << action;

    if ( action == "editName" ) editName();

    else if ( action == "addEmail" ) addEmail();
    else if ( action == "editEmail" ) editEmail( path.value( 1 ) );
    else if ( action == "removeEmail" ) removeEmail( path.value( 1 ) );
    else if ( action == "commentEmail" ) commentEmail( path.value( 1 ) );

    else if ( action == "addPhone" ) addPhone();
    else if ( action == "editPhone" ) editPhone( path.value( 1 ) );
    else if ( action == "removePhone" ) removePhone( path.value( 1 ) );
    else if ( action == "commentPhone" ) commentPhone( path.value( 1 ) );

    else if ( action == "addLink" ) addLink();
    else if ( action == "editLink" ) editLink( path.value( 1 ) );
    else if ( action == "removeLink" ) removeLink( path.value( 1 ) );
    else if ( action == "commentLink" ) commentLink( path.value( 1 ) );

    else if ( action == "addAddress" ) addAddress();
    else if ( action == "editAddress" ) editAddress( path.value( 1 ) );
    else if ( action == "removeAddress" ) removeAddress( path.value( 1 ) );
    else if ( action == "commentAddress" ) commentAddress( path.value( 1 ) );

    else if ( action == "addComment" ) addComment();
    else if ( action == "editComment" ) editComment( path.value( 1 ) );
    else if ( action == "removeComment" ) removeComment( path.value( 1 ) );

    else if ( action == "close" ) requestClose();
    else if ( action == "magic" ) debugHtml();

    else qDebug() << "unknown action" << action;
  } else {
    new KRun( QUrl( url ), this );
  }
}
Пример #3
0
void BookmarksDialog::customContextMenuRequested(const QPoint &pos)
{
    QMenu menu;
    QModelIndex index = tree->indexAt(pos);
    index = index.sibling(index.row(), 0);
    QModelIndex sourceIndex = m_proxyModel->mapToSource(index);
    const BookmarkNode *node = m_bookmarksModel->node(sourceIndex);
    if (index.isValid() && node->type() != BookmarkNode::Folder) {
        menu.addAction(tr("Open"), this, SLOT(openInCurrentTab()));
        menu.addAction(tr("Open in New Tab"), this, SLOT(openInNewTab()));
        menu.addSeparator();
    }
    menu.addSeparator();
    QAction *renameAction = menu.addAction(tr("Edit Name"), this, SLOT(editName()));
    renameAction->setEnabled(index.flags() & Qt::ItemIsEditable);
    if (index.isValid() && node->type() != BookmarkNode::Folder) {
        menu.addAction(tr("Edit Address"), this, SLOT(editAddress()));
    }
    menu.addSeparator();
    QAction *deleteAction = menu.addAction(tr("Delete"), tree, SLOT(removeSelected()));
    deleteAction->setEnabled(index.flags() & Qt::ItemIsDragEnabled);
    menu.exec(QCursor::pos());
}