void KBookmarkMenuImporter::connectToImporter(const QObject &importer) { connect(&importer, SIGNAL(newBookmark(QString,QString,QString)), SLOT(newBookmark(QString,QString,QString))); connect(&importer, SIGNAL(newFolder(QString,bool,QString)), SLOT(newFolder(QString,bool,QString))); connect(&importer, SIGNAL(newSeparator()), SLOT(newSeparator())); connect(&importer, SIGNAL(endFolder()), SLOT(endFolder())); }
void BookmarksToolBar::contextMenuRequested(const QPoint &position) { QAction *action = actionAt(position); QMenu menu; if (action) { QVariant variant = action->data(); Q_ASSERT(variant.canConvert<QModelIndex>()); QAction *menuAction = 0; if (!action->menu()) { menuAction = menu.addAction(tr("Open"), this, SLOT(openBookmarkInCurrentTab())); menuAction->setData(variant); menuAction = menu.addAction(tr("Open in New &Tab"), this, SLOT(openBookmarkInNewTab())); menuAction->setData(variant); menu.addSeparator(); } menuAction = menu.addAction(tr("Remove"), this, SLOT(removeBookmark())); menuAction->setData(variant); menu.addSeparator(); } menu.addAction(tr("Add Bookmark..."), this, SLOT(newBookmark())); menu.addAction(tr("Add Folder..."), this, SLOT(newFolder())); menu.exec(QCursor::pos()); }
bool BookmarkXXPort::exportContacts( const KABC::AddresseeList &list, const QString& ) { QString fileName = locateLocal( "data", "kabc/bookmarks.xml" ); KBookmarkManager *mgr = KBookmarkManager::managerForFile( fileName ); KBookmarkDomBuilder *builder = new KBookmarkDomBuilder( mgr->root(), mgr ); builder->connectImporter( this ); KABC::AddresseeList::ConstIterator it; emit newFolder( i18n( "AddressBook" ), false, "" ); for ( it = list.begin(); it != list.end(); ++it ) { if ( !(*it).url().isEmpty() ) { QString name = (*it).givenName() + " " + (*it).familyName(); emit newBookmark( name, (*it).url().url().latin1(), QString( "" ) ); } } emit endFolder(); delete builder; mgr->save(); KBookmarkMenu::DynMenuInfo menu; menu.name = i18n( "Addressbook Bookmarks" ); menu.location = fileName; menu.type = "xbel"; menu.show = true; KBookmarkMenu::setDynamicBookmarks( "kabc", menu ); return true; }
void BookmarksToolBar::contextMenuRequested(const QPoint &position) { QToolButton *button = qobject_cast<QToolButton *>(childAt(position)); QMenu menu; QAction *action; if (button) { QModelIndex index; QVariant variant; BookmarkToolButton *bookmarkButton = qobject_cast<BookmarkToolButton *>(button); ModelMenu *modelMenu = qobject_cast<ModelMenu *>(button->menu()); if (modelMenu) { index = modelMenu->rootIndex(); variant.setValue(index); } else if (bookmarkButton) { index = bookmarkButton->index(); variant.setValue(index); action = menu.addAction(tr("Open"), this, SLOT(openBookmark())); action->setData(variant); action = menu.addAction(tr("Open in New &Tab"), this, SLOT(openBookmarkInNewTab())); action->setData(variant); menu.addSeparator(); } if (variant.isValid()) { action = menu.addAction(tr("Remove"), this, SLOT(removeBookmark())); action->setData(variant); } menu.addSeparator(); } action = menu.addAction(tr("Add Bookmark..."), this, SLOT(newBookmark())); action = menu.addAction(tr("Add Folder..."), this, SLOT(newFolder())); menu.exec(QCursor::pos()); }
DialogBookmarks::DialogBookmarks(QWidget *parent) : QDialog(parent), ui(new Ui::DialogBookmarks) { ui->setupUi(this); //setWindowFlags(Qt::WindowTitleHint); connect(ui->listWidget, SIGNAL(clicked(QModelIndex)), this, SLOT(selectedBookmark())); connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(newBookmark())); connect(ui->pushButton_2, SIGNAL(clicked()), SLOT(deleteBookmark())); connect(ui->lineEdit, SIGNAL(textEdited(QString)), this, SLOT(saveBookmark())); connect(ui->lineEdit_2, SIGNAL(textEdited(QString)), this, SLOT(saveBookmark())); connect(ui->lineEdit_3, SIGNAL(textEdited(QString)), this, SLOT(saveBookmark())); connect(ui->lineEdit_4, SIGNAL(textEdited(QString)), this, SLOT(saveBookmark())); connect(this, SIGNAL(finished(int)), this, SLOT(saveBookmark())); loadBookmarks(); }