Skip to content

Commit

Permalink
#6156: Open the selected conversation on double click
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Nov 10, 2022
1 parent fd000f8 commit 344fadb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
29 changes: 18 additions & 11 deletions plugins/dm.conversation/ConversationDialog.cpp
Expand Up @@ -86,8 +86,8 @@ void ConversationDialog::populateWindow()
_convView->AppendTextColumn(_("Name"), _convColumns.name.getColumnIndex(),
wxDATAVIEW_CELL_INERT, wxCOL_WIDTH_AUTOSIZE, wxALIGN_NOT, wxDATAVIEW_COL_SORTABLE);

_convView->Connect(wxEVT_DATAVIEW_SELECTION_CHANGED,
wxDataViewEventHandler(ConversationDialog::onConversationSelectionChanged), NULL, this);
_convView->Bind(wxEVT_DATAVIEW_SELECTION_CHANGED, &ConversationDialog::onConversationSelectionChanged, this);
_convView->Bind(wxEVT_DATAVIEW_ITEM_ACTIVATED, [this](auto&) { editSelectedConversation(); });

convPanel->GetSizer()->Add(_convView, 1, wxEXPAND);

Expand Down Expand Up @@ -384,20 +384,27 @@ void ConversationDialog::selectConvByIndex(int index)
handleConversationSelectionChange();
}

void ConversationDialog::onEditConversation(wxCommandEvent& ev)
void ConversationDialog::editSelectedConversation()
{
int index = getSelectedConvIndex();
int index = getSelectedConvIndex();

conversation::Conversation& conv = _curEntity->second->getConversation(index);
if (index == -1) return;

// Display the edit dialog, blocks on construction
ConversationEditor* editor = new ConversationEditor(this, conv);
auto& conv = _curEntity->second->getConversation(index);

editor->ShowModal();
editor->Destroy();
// Display the edit dialog, blocks on construction
auto editor = new ConversationEditor(this, conv);

// Repopulate the conversation list
refreshConversationList();
editor->ShowModal();
editor->Destroy();

// Repopulate the conversation list
refreshConversationList();
}

void ConversationDialog::onEditConversation(wxCommandEvent& ev)
{
editSelectedConversation();
}

void ConversationDialog::onDeleteConversation(wxCommandEvent& ev)
Expand Down
1 change: 1 addition & 0 deletions plugins/dm.conversation/ConversationDialog.h
Expand Up @@ -94,6 +94,7 @@ class ConversationDialog :
void onMoveConversationUpOrDown(wxCommandEvent& ev);
void onClearConversations(wxCommandEvent& ev);

void editSelectedConversation();
int getSelectedConvIndex();
void selectConvByIndex(int index);
};
Expand Down

0 comments on commit 344fadb

Please sign in to comment.