Compare commits

...

4 Commits

Author SHA1 Message Date
Laurent Trinques 2785e25569 Merge pull request #863 from ispyisail/fix/bugtracker-97-recent-files-menu
Fix bugtracker #97: "Recently opened" never updates during a session
2026-09-14 09:09:45 +02:00
Laurent Trinques c8e4396b2a Merge pull request #864 from ispyisail/fix/bugtracker-238-summary-order
Fix bugtracker #238: summary table ordered by its columns, not by folio
2026-09-14 09:04:25 +02:00
ispyisail 0147453494 Fix bugtracker #238: summary table ordered by its columns, not by folio
SummaryQueryWidget::queryStr() built its ORDER BY from the columns the user
chose to display, in the order they chose them:

    column   += key;
    order_by += key;

So a summary whose first column is Title came out sorted alphabetically by
title, and one starting with Author sorted by author. A table of contents
lists the folios of a project; its order is the project's order, not
whatever the first column happens to be.

It now orders by "pos", the folio position that project_summary_view already
exposes from diagram.pos. That column is an INTEGER, so the sort is numeric
and folio 10 does not land between folio 1 and folio 2. One row per folio
means pos fully determines the order, so no secondary key is needed.

Demonstrated against a stand-in view holding four folios:

    ORDER BY title, pos   Apple(2) Banana(3) Mango(10) Zebra(1)
    ORDER BY pos          Zebra(1) Apple(2) Banana(3) Mango(10)

The hand-written query path (m_edit_sql_query_cb) returns before this and is
untouched, so anyone wanting a different order still has one.

ctest 4/4, Qt 5.15.18.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-14 15:30:44 +12:00
ispyisail 181bbb7f21 Fix bugtracker #97: "Recently opened" never updates during a session
The File > Recently-opened submenu was filled once, at editor construction,
by copying the QActions that RecentFiles' menu happened to hold at that
moment:

    recentfile->addActions(QETApp::projectsRecentFiles()->menu()->actions());

RecentFiles::buildMenu() runs on every fileWasOpened(), clears its menu and
creates fresh QActions. The editor's copy therefore never gained an entry,
and the list only ever looked correct after a restart.

The submenu is now the RecentFiles menu itself. QMenu::addMenu() adds the
submenu's menuAction() rather than reparenting it, so several editor windows
can share the one live menu, which is what an application-wide recent-files
list should do anyway.

Measured with a temporary probe comparing the live menu against what the
File menu actually shows, after one file had been opened in the same
session:

    without the fix   live=1  shownInFileMenu=0
    with the fix      live=1  shownInFileMenu=1

ctest 4/4, GUI starts clean with the menu bar intact. Qt 5.15.18.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-14 15:25:51 +12:00
2 changed files with 31 additions and 5 deletions
+17 -3
View File
@@ -63,7 +63,6 @@ QString SummaryQueryWidget::queryStr() const
QStringList keys = selectedKeys();
QString select ="SELECT ";
QString order_by = " ORDER BY ";
QString column;
bool first = true;
@@ -72,14 +71,29 @@ QString SummaryQueryWidget::queryStr() const
first = false;
} else {
column += ", ";
order_by +=", ";
}
column += key;
order_by += key;
}
QString from = " FROM project_summary_view";
//Always ordered by the folio's own position, never by the columns
//the user happened to choose to display. This is a table of
//contents: it lists the folios of the project and its order is the
//project's order. Ordering by the displayed columns instead meant
//that choosing, say, Title as the first column silently sorted the
//summary alphabetically (bugtracker #238).
//
//project_summary_view exposes the position as "pos", from
//diagram.pos, which is an INTEGER -- so this sorts numerically and
//folio 10 does not land between folio 1 and folio 2. One row per
//folio means pos fully determines the order and no secondary key is
//needed.
//
//A user who wants a different order can still write the query by
//hand; that path returns above, untouched.
QString order_by = " ORDER BY pos";
QString q(select + column + from + order_by);
return q;
}
+14 -2
View File
@@ -903,8 +903,20 @@ void QETDiagramEditor::setUpMenu()
insertMenu(help_menu_, windows_menu);
// File menu
QMenu *recentfile = menu_fichier -> addMenu(QET::Icons::DocumentOpenRecent, tr("&Récemment ouverts"));
recentfile->addActions(QETApp::projectsRecentFiles()->menu()->actions());
// Add the RecentFiles menu itself, not a copy of the actions it
// happened to hold at construction time. RecentFiles::buildMenu()
// clears that menu and creates fresh QActions every time a file is
// opened, so a snapshot taken here never gained an entry again and
// the list only looked right after a restart (bugtracker #97).
//
// The menu is an application-wide singleton and several editor
// windows may exist. QMenu::addMenu() adds the submenu's menuAction()
// rather than reparenting it, so every window shows the same live
// menu, which is the intent.
QMenu *recentfile = QETApp::projectsRecentFiles()->menu();
recentfile->setTitle(tr("&Récemment ouverts"));
recentfile->setIcon(QET::Icons::DocumentOpenRecent);
menu_fichier->addMenu(recentfile);
connect(QETApp::projectsRecentFiles(), &RecentFiles::fileOpeningRequested, this, &QETDiagramEditor::openRecentFile);
menu_fichier -> addActions(m_file_actions_group.actions());
menu_fichier -> addSeparator();