Commit Graph

55 Commits

Author SHA1 Message Date
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
wmayer
b50b21576e core system
force strict ISO C++ (-Wpedantic)
TODO: still a lot of variadic macros are not valid ISO C++
2019-09-18 01:01:14 +02:00
luz.paz
a1984aeece Fix typos, grammar, and some whitespace issues
Found via `codespell -q 2 -L aci,ake,aline,alle,alledges,alocation,als,ang,anid,ba,beginn,behaviour,bloaded,byteorder,calculater,cancelled,cancelling,cas,cascade,centimetre,childs,colour,colours,commen,currenty,dof,doubleclick,dum,eiter,elemente,feld,freez,hist,iff,indicies,initialisation,initialise,initialised,initialises,initialisiert,ist,kilometre,lod,mantatory,methode,metres,millimetre,modell,nd,noe,normale,normaly,nto,numer,oder,orgin,orginx,orginy,ot,pard,pres,programm,que,recurrance,rougly,seperator,serie,sinc,strack,substraction,te,thist,thru,tread,uint,unter,vertexes,wallthickness,whitespaces -S ./.git,*.po,*.ts,./ChangeLog.txt,./src/3rdParty,./src/Mod/Assembly/App/opendcm,./src/CXX,./src/zipios++,./src/Base/swig*,./src/Mod/Robot/App/kdl_cp,./src/Mod/Import/App/SCL,./src/WindowsInstaller,./src/Doc/FreeCAD.uml`
2019-09-07 11:58:38 -04:00
Zheng, Lei
3e0cfb4ba5 Gui: fix ExpressionCompleter for property 2019-08-30 14:51:33 +02:00
Zheng, Lei
c2c6053e71 Gui: improve expression completer
Proper support of completing an edit in the middel of an expression.

Also support 'noProperty' mode in the completer, where no completion is
offered for property names. This will be used by tree view object
search.
2019-08-30 14:49:14 +02:00
wmayer
5172c3bc08 Fix clang compiler warnings:
+ fix -Winconsistent-missing-override
+ fix -Wunused-variable
+ fix -Wbraced-scalar-init
+ fix -Wparentheses (View3DInventorViewer::checkGroupOnTop: operator '?:' has lower precedence than '+'; '+' will be evaluated first)
+ fix -Wundefined-bool-conversion (MainWindow::updateActions)
+ suppress -Woverloaded-virtual but fix later
2019-08-17 19:52:12 +02:00
Zheng, Lei
26dad093f6 ExpressionCompleter: fix missing init() call 2019-08-17 15:32:48 +02:00
Zheng, Lei
2bd4795e80 Gui: property view related changes
* Display property from linked object, colored green,

* Change DlgPropertyLink to support external linking and sub-object
  selection

* Improve large selection performance by using a timer

* Improve TAB key behavior in property editor

* Add context menu to show hidden properties, change property status,
  set expression on any and property, and add/remove dynamic properties

* Optimize expression completer model construction, as the original
  implementation gets prohibitively slow for moderate number of objects.
2019-08-17 15:08:33 +02:00
Unknown
d949210aed Typos, grammar & uniformiity
3rd party KDL typos have been submitted upstream https://github.com/orocos/orocos_kinematics_dynamics/pull/121
2017-12-13 00:10:46 -05:00
wmayer
150bd625b8 fix crash in ExpressionCompleter::slotUpdate 2017-12-06 23:02:00 +01:00
Eivind Kvedalen
75d006a97d Expression completer: Fixed issue #3197. 2017-12-05 16:37:12 +01:00
wmayer
0824c5fd3c fix Coverity issues 2016-08-21 14:03:02 +02:00