int CBookmarkManager::createBookmark (const std::string & url, const std::string & time) { char bookmarkname[26]=""; CStringInputSMS bookmarkname_input(LOCALE_MOVIEPLAYER_BOOKMARKNAME, bookmarkname, 25, LOCALE_MOVIEPLAYER_BOOKMARKNAME_HINT1, LOCALE_MOVIEPLAYER_BOOKMARKNAME_HINT2, "abcdefghijklmnopqrstuvwxyz\xE4\xF6\xFC\xDF""0123456789-_"); bookmarkname_input.exec(NULL, ""); // TODO: return -1 if no name was entered return createBookmark(ZapitTools::Latin1_to_UTF8(bookmarkname), url, time); }
int CBookmarkManager::createBookmark (const std::string & url, const std::string & time) { char bookmarkname[26]=""; CStringInputSMS bookmarkname_input(LOCALE_MOVIEPLAYER_BOOKMARKNAME, bookmarkname, 25, LOCALE_MOVIEPLAYER_BOOKMARKNAME_HINT1, LOCALE_MOVIEPLAYER_BOOKMARKNAME_HINT2, "abcdefghijklmnopqrstuvwxyz0123456789-_"); bookmarkname_input.exec(NULL, ""); // TODO: return -1 if no name was entered if(!strlen(bookmarkname)) return -1; return createBookmark(std::string(bookmarkname), url, time); }
int CBookmarkManager::createBookmark (const std::string & url, const std::string & time) { std::string bookmarkname; CStringInputSMS bookmarkname_input(LOCALE_MOVIEPLAYER_BOOKMARKNAME, &bookmarkname, 25, LOCALE_MOVIEPLAYER_BOOKMARKNAME_HINT1, LOCALE_MOVIEPLAYER_BOOKMARKNAME_HINT2, "abcdefghijklmnopqrstuvwxyz0123456789-_", this); bookmarkname_input.exec(NULL, ""); if (bookmarkname_entered) { bookmarkname_entered = false; return createBookmark(bookmarkname, url, time); } return -1; }
BookmarkWidget::BookmarkWidget(QWidget *parent) : QWidget(parent) { hbox1 = new QHBoxLayout(); bTreeWidget = new BookmarkTreeWidget(); // DT: allow for right-click popup context menu. bTreeWidget->setContextMenuPolicy(Qt::CustomContextMenu); hbox1->addWidget(bTreeWidget); hbox2 = new QHBoxLayout(); //newFolderButton = new QPushButton("New Folder"); addButton = new QPushButton("Add"); editButton = new QPushButton("Edit"); deleteButton = new QPushButton("Delete"); //newFolderButton->setEnabled(false); addButton->setEnabled(false); editButton->setEnabled(false); deleteButton->setEnabled(false); //hbox2->addWidget(newFolderButton); hbox2->addWidget(addButton); hbox2->addWidget(editButton); hbox2->addWidget(deleteButton); connect(bTreeWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(handleDoubleClick(QTreeWidgetItem*,int))); connect(bTreeWidget, SIGNAL(itemExpanded(QTreeWidgetItem*)), this, SLOT(saveFolderState(QTreeWidgetItem*))); connect(bTreeWidget, SIGNAL(itemCollapsed(QTreeWidgetItem*)), this, SLOT(saveFolderState(QTreeWidgetItem*))); connect(bTreeWidget, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(showContextMenu(const QPoint&))); //connect(newFolderButton, SIGNAL(clicked()), this, SLOT(createFolder())); connect(addButton, SIGNAL(clicked()), this, SLOT(createBookmark())); connect(editButton, SIGNAL(clicked()), this, SLOT(editItem())); connect(deleteButton, SIGNAL(clicked()), this, SLOT(deleteItem())); vbox = new QVBoxLayout(); vbox->addLayout(hbox1); vbox->addLayout(hbox2); setLayout(vbox); show(); renderingMode = NULL; }
VBookmark FilePlacesItem::createSystemBookmark(VBookmarkManager *manager, const QString &untranslatedLabel, const QString &translatedLabel, const QUrl &url, const QString &iconName) { // System boomarks created with this method are special locations // such as Desktop, Home, Documents, Music, ... // We always create these bookmarks with the untranslated label, the // translatedLabel parameter is needed to force the caller providing a // translation which will be picked when the item is shown while we store // the untranslated label on disk Q_UNUSED(translatedLabel); VBookmark bookmark = createBookmark(manager, untranslatedLabel, url, iconName); if (!bookmark.isNull()) bookmark.setMetaDataItem("IsSystemItem", "true"); return bookmark; }
void Word_setupBookmarkLinks(WordPutData *put) { DFHashTable *referencesById = findReferences(put->conv->html); const char **sortedIds = DFHashTableCopyKeys(referencesById); DFSortStringsCaseSensitive(sortedIds); for (int idIndex = 0; sortedIds[idIndex]; idIndex++) { const char *targetId = sortedIds[idIndex]; DFArray *references = DFHashTableLookup(referencesById,targetId); DFNode *targetElem = DFElementForIdAttr(put->conv->html,targetId); if (targetElem == NULL) continue; // The following is only relevant for figures and tables int refText = 0; int refLabelNum = 0; int refCaptionText = 0; for (int refIndex = 0; refIndex < DFArrayCount(references); refIndex++) { DFNode *a = DFArrayItemAt(references,refIndex); const char *className = DFGetAttribute(a,HTML_CLASS); if (DFStringEquals(className,DFRefTextClass)) refText = 1; else if (DFStringEquals(className,DFRefLabelNumClass)) refLabelNum = 1; else if (DFStringEquals(className,DFRefCaptionTextClass)) refCaptionText = 1; } DFNode *concrete = WordConverterGetConcrete(put,targetElem); switch (targetElem->tag) { case HTML_H1: case HTML_H2: case HTML_H3: case HTML_H4: case HTML_H5: case HTML_H6: { const char *bookmarkId = NULL; const char *bookmarkName = NULL; DFNode *bookmarkElem = NULL; if ((concrete != NULL) && (concrete->tag == WORD_P)) { // FIXME: We only want to consider the bookmark to be the headings "correct" // bookmark in the case where it contains all of the heading's content, though // excluding other bookmarks that might come before or after it. // If you have the cursor inside a heading bookmark when you save the document, // word puts a bookmark called _GoBack there, and we of course don't want to // confuse that with the actual heading's bookmark (if any). // For now as a temporary hack we just explicitly filter out _GoBack; but there // needs to be a more general fix, as there may be other bookmarks that end up // in the heading. for (DFNode *child = concrete->first; child != NULL; child = child->next) { if ((child->tag == WORD_BOOKMARK) && !DFStringEquals(DFGetAttribute(child,WORD_NAME),"_GoBack")) { bookmarkElem = child; bookmarkId = DFGetAttribute(bookmarkElem,WORD_ID); bookmarkName = DFGetAttribute(bookmarkElem,WORD_NAME); break; } } } if ((bookmarkElem == NULL) || (bookmarkId == NULL) || (bookmarkName == NULL)) { // New bookmark WordBookmark *bookmark = WordObjectsAddBookmark(put->conv->objects); bookmarkId =bookmark->bookmarkId; bookmarkName = bookmark->bookmarkName; } DFNode *bookmarkSpan = DFCreateElement(put->conv->package->document,HTML_SPAN); DFSetAttribute(bookmarkSpan,HTML_CLASS,DFBookmarkClass); if (bookmarkElem != NULL) { // FIXME: Not covered by tests DFFormatAttribute(bookmarkSpan,HTML_ID,"%s%u",put->conv->idPrefix,bookmarkElem->seqNo); } DFSetAttribute(bookmarkSpan,WORD_NAME,bookmarkName); DFSetAttribute(bookmarkSpan,WORD_ID,bookmarkId); while (targetElem->first != NULL) DFAppendChild(bookmarkSpan,targetElem->first); DFAppendChild(targetElem,bookmarkSpan); break; } case HTML_TABLE: case HTML_FIGURE: { WordCaption *caption = WordObjectsCaptionForTarget(put->conv->objects,targetElem); if (caption == NULL) break; assert(caption->element != NULL); assert((caption->number == NULL) || (caption->number->parent == caption->element)); assert((caption->contentStart == NULL) || (caption->contentStart->parent == caption->element)); // Note: caption.number may be null (i.e. if the caption is unnumbered) // caption.contentStart may be null (if there is no text in the caption) WordBookmark *captionTextBookmark = NULL; WordBookmark *labelNumBookmark = NULL; WordBookmark *textBookmark = NULL; if (!refCaptionText && !refLabelNum && !refText) refText = 1; if (refCaptionText) { captionTextBookmark = createBookmark(put->conv); DFNode *nnext; for (DFNode *n = caption->contentStart; n != NULL; n = nnext) { nnext = n->next; DFAppendChild(captionTextBookmark->element,n); } DFAppendChild(caption->element,captionTextBookmark->element); } if (refLabelNum && (caption->number != NULL)) { labelNumBookmark = createBookmark(put->conv); DFNode *numberNext = caption->number->next; DFNode *nnext; for (DFNode *n = caption->element->first; (n != NULL) && (n != numberNext); n = nnext) { nnext = n->next; DFAppendChild(labelNumBookmark->element,n); } DFInsertBefore(caption->element,labelNumBookmark->element,caption->element->first); } if (refText) { textBookmark = createBookmark(put->conv); DFNode *nnext; for (DFNode *n = caption->element->first; n != NULL; n = nnext) { nnext = n->next; DFAppendChild(textBookmark->element,n); } DFAppendChild(caption->element,textBookmark->element); } caption->captionTextBookmark = captionTextBookmark; caption->labelNumBookmark = labelNumBookmark; caption->textBookmark = textBookmark; break; } } } free(sortedIds); DFHashTableRelease(referencesById); }
/* * Implements the right-click context menu. * User can right-click to add a folder/bookmark if no item is selected, or edit/delete * the currently selected item. */ void BookmarkWidget::showContextMenu(const QPoint &pos) { QString text, s_edit, s_delete; QMenu menu; // DT: only show menu if there is an item being visualized. if(!mw()->VTKA()) return; QPoint globalPos = bTreeWidget->mapToGlobal(pos); QTreeWidgetItem* item = bTreeWidget->itemAt(pos); if(!item) { //QAction* addFolderAct = menu.addAction(tr("Add Folder...")); //addFolderAct->setData(QVariant(ADD_FOLDER)); QAction* addBookmarkAct = menu.addAction(tr("Add Bookmark...")); addBookmarkAct->setData(QVariant(ADD_BOOKMARK)); } else { text = item->text(TITLE_COLUMN); if(text.length() > STRING_MAX) { text.truncate(STRING_MAX); s_edit = "Edit \"" + text + "...\""; s_delete = "Delete \"" + text + "...\""; } else { s_edit = "Edit \"" + text + "\""; s_delete = "Delete \"" + text + "\""; } QAction* editItemAct = menu.addAction(s_edit); editItemAct->setData(QVariant(EDIT_ITEM)); QAction* deleteItemAct = menu.addAction(s_delete); deleteItemAct->setData(QVariant(DELETE_ITEM)); menu.addSeparator(); QAction* getInfoAct = menu.addAction(tr("Get Info...")); getInfoAct->setData(QVariant(GET_INFO)); } QAction* act = menu.exec(globalPos); if (act) { int a = act->data().toInt(); switch(a) { //case ADD_FOLDER: { createFolder(); break; } case ADD_BOOKMARK: { createBookmark(); break; } case EDIT_ITEM: { editItem(item); break; } case DELETE_ITEM: { deleteItem(item); break; } case GET_INFO: { displayItemInfo(item); break; } default: break; } } }