Skip to content

Commit

Permalink
bookmarks: support tag renaming in a tag selection dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
vladisslav2011 committed Nov 10, 2024
1 parent 20a7568 commit 38bfeb6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/qtgui/dockbookmarks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ DockBookmarks::DockBookmarks(QWidget *parent) :
| QDialogButtonBox::Cancel);
connect(buttonBox, SIGNAL(accepted()), tagsDialog, SLOT(accept()));
connect(buttonBox, SIGNAL(rejected()), tagsDialog, SLOT(reject()));
connect(dialogTaglist, SIGNAL(itemChanged(QTableWidgetItem *)), this, SLOT(dialog_tableWidgetTagList_itemChanged(QTableWidgetItem *)));

QVBoxLayout *mainLayout = new QVBoxLayout(tagsDialog);
mainLayout->addWidget(dialogTaglist);
Expand Down Expand Up @@ -217,6 +218,30 @@ void DockBookmarks::on_tableWidgetTagList_itemChanged(QTableWidgetItem *item)
Bookmarks::Get().setTagChecked(strText, isChecked);
}

void DockBookmarks::dialog_tableWidgetTagList_itemChanged(QTableWidgetItem *item)
{
// we only want to react on changed by the user, not changes by the program itself.
if(ui->tableWidgetTagList->m_bUpdating) return;

int col = item->column();
if (col != 1)
return;

QString strText = item->text();
QString strOld = item->data(Qt::UserRole).toString();
if(strText != strOld)
{
if(Bookmarks::Get().getTagIndex(strText) == -1)
{
Bookmarks::Get().findOrAddTag(strOld)->name = strText;
item->setData(Qt::UserRole, strText);
Bookmarks::Get().save();
}else
item->setText(strOld);
updateTags();
}
}

bool DockBookmarks::eventFilter(QObject* object, QEvent* event)
{
if (event->type() == QEvent::KeyPress)
Expand Down
1 change: 1 addition & 0 deletions src/qtgui/dockbookmarks.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ private slots:
//void on_addButton_clicked();
//void on_delButton_clicked();
void on_tableWidgetTagList_itemChanged(QTableWidgetItem* item);
void dialog_tableWidgetTagList_itemChanged(QTableWidgetItem *item);
void ShowContextMenu(const QPoint&pos);
bool DeleteSelectedBookmark();
bool tuneHere();
Expand Down

0 comments on commit 38bfeb6

Please sign in to comment.