Commit Graph

66 Commits

Author SHA1 Message Date
Markus Reitböck
6ef07bb358 Gui: use CMake to generate precompiled headers on all platforms
"Professional CMake" book suggest the following:

"Targets should build successfully with or without compiler support for precompiled headers. It
should be considered an optimization, not a requirement. In particular, do not explicitly include a
precompile header (e.g. stdafx.h) in the source code, let CMake force-include an automatically
generated precompile header on the compiler command line instead. This is more portable across
the major compilers and is likely to be easier to maintain. It will also avoid warnings being
generated from certain code checking tools like iwyu (include what you use)."

Therefore, removed the "#include <PreCompiled.h>" from sources, also
there is no need for the "#ifdef _PreComp_" anymore
2025-09-14 09:47:03 +02:00
B0cho
21c58687d3 Core: Fix 'Expression editor' handling with keyboard 2025-09-05 21:59:08 +02:00
B0cho
8450fbae97 Core: Show 'Expression' completer under cursor position 2025-09-02 01:09:12 +02:00
B0cho
8b93ec2eb2 Core: Switch widget from 'ExpressionLineEdit' to 'ExpressionTextEdit'
+ minor dialog layout adjustments
2025-09-01 23:47:16 +02:00
Max Wilfinger
ecf02b7878 Gui: Update UI strings for consistency
Closes: #22135
2025-08-04 20:14:45 +02:00
Benjamin Nauck
4fcb871b5b Spreadsheet: Only use validator when when prefix is not '=' 2025-06-23 16:14:35 +02:00
wmayer
83f4029277 Gui: Implement validator for ExpressionLineEdit
As requested in issue 21426 a leading '=' shouldn't be allowed in the edit field. The validator now explicitly disallows a leading
'=' in the text. In the future the validator can be extended.

This fixes issue 21426
2025-06-03 16:11:48 -05:00
Benjamin Nauck
a882289995 Gui: use contains() and isEmpty() instead of count() where possible 2025-05-03 22:19:51 +02:00
xtemp09
b3008feaa1 [Spreadsheet] Fix input in expression editor (#19934)
* [Spreadsheet] Fix input in expression editor

Closes #19804

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-03-22 11:25:17 -05:00
Ladislav Michl
0ee3c9f8e6 Base: Drop QString-std::string conversion functions from Tools
Convenience helpers function Tools::toStdString and Tools::fromStdString
were implemented for Qt4 or older to perform utf8 aware conversion as
QString::toStdString/QString::fromStdString were using toAscii/fromAscii
internally (see https://dreamswork.github.io/qt4/classQString.html).

Since Qt5 QString uses toUtf8/fromUTf8, which makes the helper functions
obsolete (see https://doc.qt.io/qt-5/qstring.html#fromStdString).
2024-12-02 23:30:53 -05:00
wwmayer
977e13795a Gui: Prepare for clang-format (#16051)
* Gui: Prepare for clang-format

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-09-02 17:48:55 +02:00
xtemp09
a3036d16f1 Fix the crash described in #12785
Closes #12785. The cause of the segmentation fault is access to the
already deleted _QMenu_. Simple setting attribute `Qt::WA_DeleteOnClose`
and removal of `delete menu` prevented it. To reproduce the crash, one
needs to mess up the `user.cfg` file in the way described in the issue.

Here is the fragment from the issue to mess up the `user.cfg` file:

```xml
<FCParamGroup Name="Expression">
<FCText Name="EditorTrigger">=</FCText>
<FCBool Name="AntoHideEditorIcon" Value="1"/>
<FCBool Name="NoSystemBackground" Value="1"/>
<FCInt Name="EditDialogBGAlpha" Value="1"/>
<FCInt Name="EditDialogWidth" Value="300"/>
<FCInt Name="EditDialogHeight" Value="214"/>
<FCInt Name="EditDialogTextHeight" Value="35"/>
</FCParamGroup>
```

---

This commit changes also unconnected things:

- usage of `QObject::connect` instead of if statements
- relocation of a separator and an action inside the if statement (I saw
no reason to have a separator and an action for _ExpressionCompleter_ if
there is no expression completer)
- usage of asynchronous `QMenu::popup()` instead of synchronous
`QMenu::exec()`. This way is used within [the source code of Qt]
(https://github.com/qt/qtbase/blob/5.15/src/widgets/widgets/
qlineedit.cpp#L2191-L2197).
2024-03-09 16:12:47 +01:00
André Caldas
560898907b Avoids using getNameInDocument() to test if DocumentObject is attached to a Document.
This patch substitutes by isAttachedToDocument() (almost) everywhere where
getNameInDocument() is used for this purpose.

The very few places not touched by this patch demand a (just a little) less trivial change.
When we change the returning type of getNameInDocument() to std::string,
those places will be easily found, because they shall generate a compiler error
(converting std::string to bool).

Rationale:
The fact that getNameInDocument() return nullptr to indicate
that the object is not attached to a document is responsible for lots of bugs
where the developer does not check for "nullptr".

The idea is to eliminate all those uses of getNameInDocument() and, in the near future,
make getNameInDocument() return always a valid std::string.
2023-12-11 17:37:58 +01:00
wmayer
54bb9c9c62 Gui: modernize C++: return braced init list 2023-08-18 00:36:24 +02:00
wmayer
2a88c7c7df modernize C++: use bool literals 2023-08-06 01:35:39 +02:00
wmayer
b7b8113824 Gui: fixes #8501: FreeCAD crashes when constraining a sketch with an expression containing . (dot) 2023-03-09 12:45:16 +01:00
wmayer
972329be99 App: split tokenizer handling of ExpressionCompleter to its own class 2023-02-26 09:00:27 +01:00
0penBrain
5bf522ebcf [Bugfix] Gui: fix bug in expression completer tokenizing, fixes #8590 2023-02-23 13:49:03 +01:00
Uwe
e07af014e6 [Gui] ExpressionCompleter: fix some GitHub Action reports (#8264)
* [Gui] ExpressionCompleter: fix some GitHub Action reports

- too long lines
- too short variable names
- use .empty()

- also some reformatting according to our current clang file
2023-01-27 00:37:54 +01:00
Adrian Popescu
f727945f1e Fix8228 warnings (#8262)
* Cleaned up Expression Completer
2023-01-26 00:19:05 +01:00
wmayer
0f694c3ae7 Gui: fix several compiler warnings 2023-01-25 23:05:29 +01:00
wmayer
9374155cfe Gui: improve formatation and use of curly braces 2023-01-25 23:05:29 +01:00
luzpaz
8d861e6abd Gui: fix trailing whitespace 2023-01-25 15:23:47 +01:00
Adrian Popescu
b853278296 Expressions: path auto-completion fixes (#8228)
PR #8228 consisted of the following:
* Added Documentation for the expression completer
* Working PATH completion
* Allow completes on trailing separator
* Fixed paths appearing with a . at first
* Chaining completions on enter
* Fixed Missing Separator and Document Completions
- fixed missing separator for contextual Properties (ConstraintsHeight instead of Constraints.Height)
- fixed retries on filename#objectname so that they work better
2023-01-24 14:57:59 -06:00
wmayer
ac94fb4a33 Gui: move to new style connect() 2023-01-12 17:40:20 +01:00
wmayer
103de43a4e Gui: fix possible problems with new style connect
* In UIntSpinBox rename the signal to not overwrite the signal of the base class
* In UIntSpinBox use the (ambiguous) signal 'valueChanged' of the base class QSpinBox
* To avoid that connect() fails use the function pointer of the Qt class where the signal is defined
2023-01-12 17:02:59 +01:00
Uwe
ed995b5a15 [Gui] modernize some connect() settings
- addresses #6166
2023-01-12 15:13:16 +01:00
Uwe
4091db4739 [skip ci] [Gui] ExpressionCompleter: fix a typo
- found by the CI
2023-01-12 04:20:40 +01:00
luz paz
c16e88845b Gui: fix trailing whitespace 2022-12-02 19:18:54 -06:00
berniev
75acacd1b7 Gui: Use auto and range-based for (#7481)
* 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
2022-09-14 13:25:13 -05:00
berniev
0c70d45c83 Gui: Use override etc 2 2022-08-09 12:43:23 +02:00
berniev
d88729d2c4 Gui: use empty 2022-08-06 16:35:45 +02:00
Uwe
316a869b26 [Gui] remove superfluous nullptr checks 2022-07-18 03:17:42 +02:00
wmayer
2dd9d69112 Gui: fix crash in ExpressionCompleter::slotUpdate
Forum thread: https://forum.freecadweb.org/viewtopic.php?f=3&t=69931
2022-07-16 18:23:42 +02:00
wmayer
d0f98bf45c Conda: ssize_t is a POSIX type and thus not necessarily defined on Windows. Currently this causes build failures with Conda + Py3.10.
The solution is to get rid off all occurrences of ssize_t in FreeCAD code
2022-05-17 11:43:40 +02:00
wmayer
96adb98f46 Gui: modernize C++11
* use nullptr
2022-03-23 18:41:21 +01:00
Uwe
c4f5628899 [Gui] So headers: remove unused includes
- also sort out some headers to be used in precompiled headers
- also move a boost header to precompiled headers
2022-03-16 02:01:32 +01:00
Uwe
c7aed638ed [Gui] compilation fix for ExpressionCompleter
MSVC complained that ssize_t was undefined
2022-03-05 01:12:30 +01:00
Uwe
b9777464c3 [Gui] Expression: remove unused includes 2022-03-02 05:00:21 +01:00
Zheng, Lei
2a3951ca32 Spreadsheet: change alias handling
No longer add dynamic property for alias, simply rely on
get(Dynamic)PropertyByName() to check for aliases.

Add new API PropertyContainer::getPropertyNamedList() so that
ExpressionCompleter can discover properties with aliases.
2021-12-21 21:41:02 -07:00
Zheng, Lei
68fca40983 Spreadsheet: support cell binding
Cell binding allows one to bind a range of cells of one sheet to another
range of cells of an arbitary sheet, including any empty cells in the
range.

The binding is implemented with PropertyExpressionEngine and
PropertySheet::setPathValue(), which binds a special path of
PropertySheet, such as

    .cells.Bind.A1.D1

to an expression, such as

     tuple(.cells, <<A2>>, <<A5>>)

The A1 and D1 in the example above specifies the binding start and end
cell address. And <<A2>> and <<A5>> are the range of cells to bind to.
Note that you can use any expression that evalutes to string for the
binding destination, e.g. <<A%d>> % B1, which uses the value inside B1
to construct the binding destination. The '.cells' in the tuple shown
above is an example to bind cells of the same PropertySheet. It can be
change to to reference to any other spreadsheet, even those outside the
current document, e.g. Document#Spreadsheet001.cells
2021-12-21 21:41:02 -07:00
Chris Hennes
50c7ee36bf [GUI] Remove code for Qt < 5.9 2021-04-02 10:10:37 +02:00
Benjamin Nauck
64e2811192 [Gui] Switch from boost::tuple to std::tuple
It's better to use the standard lib when possible
2021-03-06 19:31:06 +01:00
Benjamin Nauck
db3b35cb5d Gui: Minor cleanup
Cleans up code which was touched in previous commit.

* Don't call popup() twice when not needed
* use nullptr instead of 0 for pointers
2021-02-19 16:22:41 +01:00
Benjamin Nauck
f5b7f645d8 Spreadsheet: Don't autocomplete when writing strings
After pull request https://github.com/FreeCAD/FreeCAD/pull/4215 it
doesn't make much sense helping the user to write expressions without
leading '=', as that content will be parsed as a string.

This change adjusts the behaviour in SpreadsheetGui's LineEdit to avoid
popping up the ExpressionCompleter when no leading equal sign is used.
2021-02-19 16:22:41 +01:00
luz paz
298c677873 Gui: Fix header uniformity, whitespace, and doxygen fixes 2020-11-26 10:14:56 +01:00
wmayer
2c744264d6 Gui: several fixes for expression search box:
+ rename method setMatchExact() to setExactMatch()
+ move handling of user-defined parameters to class ExpressionParameter
+ Qt::MatchExactly is not supported by QCompleter, use Qt::MatchStartsWith instead
+ add possibility to change match behaviour via context-menu
2020-09-13 18:35:46 +02:00
Zheng, Lei
4f5a2e923c Gui: allow change ExpressionCompleter filter mode
Fixes #4428

Filter mode set to Qt::MatchContains for tree view search and link
property editor object search.

Other usage of the completer (e.g. property editor, speadsheet) defaults
to Qt::MatchContains, but can be changed using parameter,

    BaseApp/Preferences/Expression/CompleterMatchExact
2020-09-13 18:35:02 +02:00
Zheng, Lei
0633abb70d Gui: refactor link property editor
PropertyLinkItem now support all major types of link property.
PropertyLinkListItem is no longer necessary, but kept for backward
compatible, which is now identical to PropertyLinkItem.

DlgPropertyLink, the link selection dialog, is now made modeless, so
that that user can select geometry sub-element directory from 3D view.
2020-02-11 15:40:27 -05:00
Zheng, Lei
ea7eee8061 Expression: split Expression.h to ExpressionParser.h
Split Expression details into a separate header to reduce recompilation
time on changes.
2019-09-28 15:30:41 +02:00