/************************************************************************** Mouse button press handler for the message window treeview. We only care about right clicks on a row; this action centers on the tile associated with the event at that row (if applicable). **************************************************************************/ static gboolean meswin_button_press_callback(GtkWidget *widget, GdkEventButton *ev, gpointer data) { GtkTreePath *path = NULL; GtkTreeModel *model; GtkTreeIter iter; gint row; g_return_val_if_fail(GTK_IS_TREE_VIEW(widget), FALSE); if (ev->type != GDK_BUTTON_PRESS || ev->button != 3) { return FALSE; } if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), (gint) ev->x, (gint) ev->y, &path, NULL, NULL, NULL)) { return TRUE; } model = gtk_tree_view_get_model(GTK_TREE_VIEW(widget)); if (gtk_tree_model_get_iter(model, &iter, path)) { gtk_tree_model_get(model, &iter, 2, &row, -1); meswin_goto(row); } gtk_tree_path_free(path); return TRUE; }
/************************************************************************** ... **************************************************************************/ static void meswin_response_callback(struct gui_dialog *dlg, int response, gpointer data) { GtkTreeSelection *sel; GtkTreeModel *model; GtkTreeIter iter; gint row; if (response != CMD_GOTO && response != CMD_POPCITY) { gui_dialog_destroy(dlg); return; } sel = meswin_selection; g_return_if_fail(sel != NULL); if (!gtk_tree_selection_get_selected(sel, &model, &iter)) { return; } gtk_tree_model_get(model, &iter, 2, &row, -1); if (response == CMD_GOTO) { meswin_goto(row); } else { meswin_popup_city(row); } meswin_set_visited(&iter, TRUE); }
/*************************************************************************** Slot executed when selection on meg_table has changed ***************************************************************************/ void messagewdg::item_selected(const QItemSelection &sl, const QItemSelection &ds) { const struct message *pmsg; int i; QFont f; QModelIndex index; QModelIndexList indexes = sl.indexes(); QTableWidgetItem *item; if (indexes.isEmpty()) { return; } index = indexes.at(0); i = index.row(); pmsg = meswin_get_message(i); if (i > -1 && pmsg != NULL) { if (QApplication::mouseButtons() == Qt::LeftButton || QApplication::mouseButtons() == Qt::RightButton) { meswin_set_visited_state(i, true); item = mesg_table->item(i, 0); f = item->font(); f.setItalic(true); item->setFont(f); } if (QApplication::mouseButtons() == Qt::LeftButton && pmsg->location_ok) { meswin_goto(i); } if (QApplication::mouseButtons() == Qt::RightButton && pmsg->city_ok) { meswin_popup_city(i); } } mesg_table->clearSelection(); }