Skip to content

Commit

Permalink
Support tag renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
yuzawa-san committed Nov 9, 2024
1 parent 7a6444a commit d61debe
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 20 deletions.
2 changes: 2 additions & 0 deletions src/qtgui/bookmarks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ bool Bookmarks::load()
std::stable_sort(m_BookmarkList.begin(),m_BookmarkList.end());

emit BookmarksChanged();
emit TagListChanged();
return true;
}
return false;
Expand Down Expand Up @@ -201,6 +202,7 @@ bool Bookmarks::save()
}

emit BookmarksChanged();
emit TagListChanged();
file.close();
return true;
}
Expand Down
38 changes: 19 additions & 19 deletions src/qtgui/bookmarkstaglist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,26 +182,20 @@ void BookmarksTagList::ShowContextMenu(const QPoint& pos)
{
QMenu* menu=new QMenu(this);

// Rename currently does not work.
// The problem is that after the tag name is changed in GUI
// you can not find the right TagInfo because you dont know
// the old tag name.
#if 0
// MenuItem "Rename"
{
QAction* actionRename = new QAction("Rename", this);
menu->addAction(actionRename);
connect(actionRename, SIGNAL(triggered()), this, SLOT(RenameSelectedTag()));
}
#endif

// MenuItem "Create new Tag"
{
QAction* actionNewTag = new QAction("Create new Tag", this);
menu->addAction(actionNewTag);
connect(actionNewTag, SIGNAL(triggered()), this, SLOT(AddNewTag()));
}

// MenuItem "Rename Tag"
{
QAction* actionRename = new QAction("Rename Tag", this);
menu->addAction(actionRename);
connect(actionRename, SIGNAL(triggered()), this, SLOT(RenameSelectedTag()));
}

// Menu "Delete Tag"
{
QAction* actionDeleteTag = new QAction("Delete Tag", this);
Expand All @@ -226,7 +220,6 @@ void BookmarksTagList::ShowContextMenu(const QPoint& pos)
menu->popup(viewport()->mapToGlobal(pos));
}

#if 0
bool BookmarksTagList::RenameSelectedTag()
{
QModelIndexList selected = selectionModel()->selectedRows();
Expand All @@ -236,14 +229,21 @@ bool BookmarksTagList::RenameSelectedTag()
return true;
}

int iRow = selected.first().row();
QTableWidgetItem* pItem = item(iRow,1);bUpdating
editItem(pItem);
//Bookmarks::Get().save();
int row = selected.first().row();
QString oldName = item(row, 1)->text();
TagInfo::sptr info = Bookmarks::Get().findOrAddTag(oldName);

bool ok;
QString newName = QInputDialog::getText(this, "Rename Tag", "Tag Name:",
QLineEdit::Normal, oldName, &ok);
if (ok && newName != oldName)
{
info->name = newName;
updateTags();
Bookmarks::Get().save();
}
return true;
}
#endif

void BookmarksTagList::AddNewTag()
{
Expand Down
2 changes: 1 addition & 1 deletion src/qtgui/bookmarkstaglist.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public slots:
void changeColor(int row, int column);
void toggleCheckedState(int row, int column);
void ShowContextMenu(const QPoint& pos);
//bool RenameSelectedTag();
bool RenameSelectedTag();
void AddNewTag();
void AddTag(QString name, Qt::CheckState checkstate = Qt::Checked, QColor color = TagInfo::DefaultColor);
void DeleteSelectedTag();
Expand Down

0 comments on commit d61debe

Please sign in to comment.