void RecipeWidget::displayTagInput() { tagLayout->removeWidget(addTagButton); addTagButton->deleteLater(); addTagInput = new ExtendedLineEdit(); addTagInput->setObjectName("tagEdit"); tagLayout->addWidget(addTagInput); QTimer::singleShot(0, addTagInput, SLOT(setFocus())); connect(addTagInput, SIGNAL(returnPressed()), this, SLOT(addNewTag())); connect(addTagInput, SIGNAL(escPressed()), this, SLOT(cancelAddTag())); }
NepomukWidget::NepomukWidget(TransferHandler *transfer, QWidget *parent) : QWidget(parent), m_transfer(transfer), m_nepHandler(m_transfer->nepomukHandler()), m_currentTag(QString()) { if (!m_nepHandler) return; Ui::NepomukWidget ui; ui.setupUi(this); ui.ratingWidget->setRating(m_nepHandler->rating()); ui.tags->setAutoUpdate(true); foreach (const QString &string, m_nepHandler->tags()) ui.tags->addTag(string, 4); ui.button->setIcon(KIcon("list-add")); m_lineEdit = ui.lineEdit; connect(ui.ratingWidget, SIGNAL(ratingChanged(int)), m_nepHandler, SLOT(setRating(int))); connect(ui.tags, SIGNAL(tagClicked(const QString&)), SLOT(showTagContextMenu(const QString&))); connect(m_lineEdit, SIGNAL(returnPressed(const QString&)), m_nepHandler, SLOT(addTag(const QString&))); connect(m_lineEdit, SIGNAL(returnPressed(const QString&)), m_lineEdit, SLOT(clear())); connect(ui.button, SIGNAL(pressed()), this, SLOT(addNewTag())); }
ImageTags::ImageTags(QWidget *parent, ThumbView *thumbView, MetadataCache *mdCache) : QWidget(parent) { tagsTree = new QTreeWidget; tagsTree->setColumnCount(2); tagsTree->setDragEnabled(false); tagsTree->setSortingEnabled(true); tagsTree->header()->close(); tagsTree->setSelectionMode(QAbstractItemView::ExtendedSelection); this->thumbView = thumbView; this->mdCache = mdCache; negateFilterEnabled = false; tabs = new QTabBar(this); tabs->addTab(tr("Image Tags")); tabs->addTab(tr("Filter")); tabs->setTabIcon(0, QIcon(":/images/tag_yellow.png")); tabs->setTabIcon(1, QIcon(":/images/tag_filter_off.png")); connect(tabs, SIGNAL(currentChanged(int)), this, SLOT(tabsChanged(int))); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->setContentsMargins(0, 3, 0, 0); mainLayout->setSpacing(0); mainLayout->addWidget(tabs); mainLayout->addWidget(tagsTree); setLayout(mainLayout); currentDisplayMode = SelectionTagsDisplay; folderFilteringActive = false; connect(tagsTree, SIGNAL(itemChanged(QTreeWidgetItem *, int)), this, SLOT(saveLastChangedTag(QTreeWidgetItem *, int))); connect(tagsTree, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(tagClicked(QTreeWidgetItem *, int))); tagsTree->setContextMenuPolicy(Qt::CustomContextMenu); connect(tagsTree, SIGNAL(customContextMenuRequested(QPoint)), SLOT(showMenu(QPoint))); addToSelectionAction = new QAction(tr("Tag"), this); addToSelectionAction->setIcon(QIcon(":/images/tag_yellow.png")); connect(addToSelectionAction, SIGNAL(triggered()), this, SLOT(addTagsToSelection())); removeFromSelectionAction = new QAction(tr("Untag"), this); connect(removeFromSelectionAction, SIGNAL(triggered()), this, SLOT(removeTagsFromSelection())); addTagAction = new QAction(tr("New Tag"), this); addTagAction->setIcon(QIcon(":/images/new_tag.png")); connect(addTagAction, SIGNAL(triggered()), this, SLOT(addNewTag())); removeTagAction = new QAction(tr("Remove Tag"), this); removeTagAction->setIcon(QIcon::fromTheme("edit-delete", QIcon(":/images/delete.png"))); clearTagsFilterAction = new QAction(tr("Clear Filters"), this); clearTagsFilterAction->setIcon(QIcon(":/images/tag_filter_off.png")); connect(clearTagsFilterAction, SIGNAL(triggered()), this, SLOT(clearTagFilters())); negateAction = new QAction(tr("Negate"), this); negateAction->setCheckable(true); connect(negateAction, SIGNAL(triggered()), this, SLOT(negateFilter())); tagsMenu = new QMenu(""); tagsMenu->addAction(addToSelectionAction); tagsMenu->addAction(removeFromSelectionAction); tagsMenu->addSeparator(); tagsMenu->addAction(addTagAction); tagsMenu->addAction(removeTagAction); tagsMenu->addSeparator(); tagsMenu->addAction(clearTagsFilterAction); tagsMenu->addAction(negateAction); }