=========================================
Console error, warnings, ... allow for a notifiername. This appears separately in the notification area. However, the report view ignores it.
This commit prepends the notifier string separated by a semicolon, if not empty.
It solves the problem that, if the message did not include the notifier, this was not indicated in the Report View.
If the message included the notifier, then it was duplicated in the notification area.
==================================================================================
Limitations of the current framework:
- Codes the translated state only for TranslatedNotification as part of the type.
- Does not code the intended recipient (user, developer, ...)
Problems:
- Some errors are intended for developers, some errors may only be intended for users,
if, for example, there is another developer error which already contains all the information.
The current framework may lead to information duplication or to showing to the user developer
information, which is perceived as annoying.
- Logs shall be in English (report view), while every message to the user (UI) shall be translated.
The current framework can only differentiate where to report based on subscription (legacy logs do not
subscribe to notifications), and for notifications, whether it is translated or not depends on the type.
It is not possible to code errors or warnings that are already translated.
Solution:
- To extend the ILogger interface with additional metainformation, indicating the intended recipient
(User, Developer, All), and the content of the message (translated, untranslated, untranslatable). The latter
is useful for dynamic strings that won't find a match in the translation framework.
Bonus:
- This extended version allows to do away with translatednotification, as now any message can be independently
marked as translated or untranslated or untraslatable.
- It is now possible to provide the right icon of severity (error, warning, info), even when it is only user intended
and already translated.
=======================================
Refactor:
- Substitute the use of variadic templates with parameter packs.
- Use recently incorporated external library "fmt" to handle printf like formating.
- Extensive cleaning of pragmas and unnecessary forward declarations.
- Parameter packs and libfmt provide a much stronger type checking now, so
conversions that are by standard implicit as bool to int need an explicit static_cast
to avoid compilation warnings.
Extension:
- Include a notifier field, so that the originator of the message can be provided. E.g. Document#DocumentObject
- Include a new type of message called CriticalMessage, this message is intended to have
special behaviour in the future. Namely, it will be used to notify forward compatilibity issues.
It will be used to substitute the current signal/slot mechanism.
- Include two new types of messages for user notifications (Notification and TranslatedNotification). This messages
will be use to convey UI notifications intended for the user (such as non-intrusive message about the usage of a tool). There
are two versions to mark whether the string provided as a message is already translated or not. When using the console system for
notifications, these notifications may originate from the App or the Gui. In the former, it is generally the case that the strings
of messages are not (yet) translated (but they can be marked with QT_TRANSLATE_NOOP). In the latter, often the messages to be provided
are already translated.
Python support for CriticalMessage, Notification and TranslatedNofification, including shortcuts:
Crt = FreeCAD.Console.PrintCritical
Ntf = FreeCAD.Console.PrintNotification
Tnf = FreeCAD.Console.PrintTranslatedNotification
* QApplication::setFallbackSessionManagementEnabled has been removed
* QString::medRef() has been removed. Use QString::mid() again.
* QTextStream::setCodec has been removed
* Use operator QVariant of the QFont class to make code Qt5 and Qt6 compatible
* Signature of QTreeWidget::mimeData() has changed in Qt6. Remove TreeWidget::mimeData() because it doesn't change the implementation
* QLayout::setMargin() is deprecated in Qt5 and has been removed in Qt6. Use QLayout::setContentsMargins()
* QDateTime::toTime_t() is deprecated in Qt5 and has been removed in Qt6. Use QDateTime::toSecsSinceEpoch()
* QDesktopWidget is deprecated in Qt5 and has been removed in Qt6. Use QScreen
* On lines where the variable type is obvious from inspection, avoid repeating the type using auto.
* When possible use a ranged for loop instead of begin() and end() iterators
I introduced FreeCAD to several people and see that especially newbies are confused with all the warnings they get but cannot understand.
The solution was to change that the report view panel is not automatically shown on every warning.
This PR does this.
More experienced users can anytime enable the option. Thus this PR has not much impact but obviously makes life easier for beginners.
+ add function to cleanup units and quantities in debug build
+ fix reference leak in PropertyVector::getPyPathValue()
+ fix reference leak in PropertyPlacement::getPyPathValue()
+ in InterpreterSingleton::init() use a static std::vector<wchar_t*> instead of a C array
to free memory at program end
+ in MainWindow::closeEvent() explicitly delete all task watchers
+ in ReportOutputObserver constructor pass parent to QObject
+ in PropertyEditor destructor explicitly delete QItemEditorFactory
Make default values consistent for whether to show report view on log and normal messages. Default values should be warnings: true, errors: true, normals: false, logs: false.
...Renamed to "ILogger", to designate that this is an Interface for a
Logger. This "Interface" is pure virtual, so that it cannot be
instantiated directly. This makes it clear that it is intended to be
derived.
Finally, got rid of all the individual log-style methods and replaced
with SendLog. The idea here is that day-to-day users will only interact
with ILogger through ConsoleSingleton (or, likely, LoggerSingleton in
the future). This singleton will manage an arbirtary collection of
ILogger, and call SendLog with the appropriate parameters based on what
the user requests.
Therefore, the singleton itself will have the individual Log, Message,
Error, etc... methods, while stil allowing us to simplify the code base
of ILogger and its derived classes.
Application:
* signalNewDocument, check the extra argument, isMainDoc, the decide
whether to create view of the new document. This is so that external
linked document can be opened in background without crowding the tab
list.
* slotDeleteDocument, calls Document::beforeDelete()
* slotActiveDocument, creates view if none, because external document
is now opened without view.
* onLastWindowClosed(), switch to next active document, and creates view
if none.
* send(Has)MsgToFocusView(), new API to send message to the active view
in focus. This is to solve the ambiguity of things like pressing
delete key, copy, paste handling when the active new is not in focus.
For example, when spread sheet view is active, delete/copy/paste
handling should be different when the focus on the spread sheet view
or focus on tree view.
* tryClose(), delegate to MainWindow for close confirmation
* reopen(), new API to reload a partial document in full
Document/DocumentP:
* _CoinMap, new internal map for quick access view provider from its
root node.
* slotNewObject, modified to support view provider override from
App::FeaturePython, through new API
DocumentObject::getViewProviderNameOverride().
* slotDeletedObject/slotTransactionRemove, improve handling of geo group
children rebuild
* slotSkipRecompute, add special handling of document with skip
recompute. Some command cannot work when skip recompute is active.
For example, sketcher command will check if recompute is successful
on many commands, and will undo if not. New 'PartialCompute' flag is
added to allow recompute only the editing object and all its
dependencies if 'SkipRecompute' is active.
* slotTouchedObject, new signal handling of manually touched object.
* setModified(), do nothing if already modified. This is a critical
performance improvement, because marking tab window as modified turns
out to be a relatively expensive operation, and will cause massive
slow down if calling it on every property change.
* getViewProviderByPathFromHead/getViewProvidersByPath(), new APIs to
obtain view provider(s) from coin SoPath.
* save/saveAll/saveCopy, modified to support external document saving.
* Save/RestoreDocFile(), save and restore tree item recursive expansion
status.
* slotFinishRestoreObject(), handle new signal
signalFinishRestoreObject(), unifies postprocessing in restore and
import operation.
* createView/setActiveView(), add support of delayed view creations
* canClose(), delegate to MainWindows to ask for confirmation
* undo/redo(), support grouped transaction undo/redo. Transactions may
be grouped by the same transaction ID if they are triggered by a
single operation but involves objects from multiple documents.
* toggleInSceneGraph(), new API to add or remove root node from or to
scenegraph without deleting the view object.
MainWindow:
* Update command status using a single shot timer instead of periodical
one.
* Improve message display is status bar. Give error and warning message
higher priority (using QStatusBar::showMessage()) than normal status
message (using actionLabel), reversed from original implementation.
* confirmSave(), new API to check for modification, and ask user to save
the document before closing. The confirmation dialog allows user to
apply the answer to all document for convenience.
* saveAll(), new API to save all document with correct ordering in case
of external linking.
* createMimeDataFromSelection/insertFromMimeData(), support copy paste
object with external linking. A new dialog DlgObjectSelection is used
to let user select exactly which object to export.
CommandDoc/CommandWindow:
* Related changes to object delete, document import, export, and save.
+ add method to make image view unclosable for user
+ fix possible crash in MeshAlgorithm::GetMeshBorder
+ fix possible crash in MeshAlgorithm::ConnectLines