Commit Graph

90 Commits

Author SHA1 Message Date
Eike Ziller
07a0ced947 TreeModel: Remove unused function overload
9124833a63 introduced an optional
parameter to removeChildren to suppress signal emitting, and
a61f9162f1 reimplemented that in a ABI
compatible way with a new removeChildrenSilently method instead.

The code now uses removeChildrenSilently, so the parameter to
removeChildren is no longer needed.

Change-Id: I8411d80f90e83b8746c2553dddb41c3f40a2bfc7
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: David Schulz <david.schulz@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
2024-01-09 11:14:26 +00:00
Eike Ziller
cf63b1884e Merge remote-tracking branch 'origin/12.0'
Conflicts:
	src/libs/utils/treemodel.cpp
	src/libs/utils/treemodel.h

Change-Id: I9c5e8ef77905745c201cfc647218c9e747d268d6
2024-01-08 14:56:54 +01:00
David Faure
a61f9162f1 Fix TreeModel emitting nested QAbstractItemModel signals
This led to an assert in QSFPM because it got confused by the
nested reset signals.

Detected by adding
new QAbstractItemModelTester(this,
QAbstractItemModelTester::FailureReportingMode::Fatal);
to the OutlineModel constructor, and just opening QtCreator on a small
qmake-based project.

Fixes: QTCREATORBUG-30035
Change-Id: I41dbc81b5a2275521ece6b865115e1428e07ecf7
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
(cherry picked from commit 9124833a63)
Reviewed-by: David Faure <david.faure@kdab.com>
2024-01-08 12:50:17 +00:00
David Faure
9124833a63 Fix TreeModel emitting nested QAbstractItemModel signals
This led to an assert in QSFPM because it got confused by the
nested reset signals.

Detected by adding
new QAbstractItemModelTester(this, QAbstractItemModelTester::FailureReportingMode::Fatal);
to the OutlineModel constructor, and just opening QtCreator on a small
qmake-based project.

Change-Id: I41dbc81b5a2275521ece6b865115e1428e07ecf7
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: hjk <hjk@qt.io>
2023-12-13 17:42:10 +00:00
Christian Kandeler
3c3a9f6786 Improve sorting in Kit-related settings tabs
- Use a proper sort model in the Kits settings widgets, so kits will
  not just initially be sorted.
- Handle the top-level nodes in a special way, as not to rely on
  "Auto-detected" coming before "Manual" in all languages.

Change-Id: I1eb8e1bee6836b47164d76b49435f8ff5120bb14
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-09-08 07:32:55 +00:00
Christian Kandeler
7adeaafd93 QtSupport: Use natural sorting for Qt versions in settings widget
Change-Id: I4ef14a575c536e9f789fedf24937bd0f9e118f91
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-09-05 08:27:55 +00:00
Jarek Kobus
6cc471f38d Utils: Replace QVector with QList
Make usages of QList consistent. In some cases the
declaration contained QVector arg, while the definition
had QList arg.

Remove some unneeded includes of QList.

Change-Id: I7c15b39f261cefdeec6aaaf506ff4cc981432855
Reviewed-by: hjk <hjk@qt.io>
2023-07-20 09:57:07 +00:00
Kai Köhne
56baf8c058 Remove GPL-3.0+ from license identifiers
Since we also license under GPL-3.0 WITH Qt-GPL-exception-1.0,
this applies only to a hypothetical newer version of GPL, that doesn't
exist yet. If such a version emerges, we can still decide to relicense...

While at it, replace (deprecated) GPL-3.0 with more explicit GPL-3.0-only

Change was done by running

  find . -type f -exec perl -pi -e "s/LicenseRef-Qt-Commercial OR GPL-3.0\+ OR GPL-3.0 WITH Qt-GPL-exception-1.0/LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0/g" {} \;

Change-Id: I5097e6ce8d10233993ee30d7e25120e2659eb10b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2023-01-06 11:15:13 +00:00
Lucie Gérard
a7956df3ca Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.

Task-number: QTBUG-67283
Change-Id: I708fd1f9f2b73d60f57cc3568646929117825813
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2022-08-26 12:27:18 +00:00
Jarek Kobus
f3957d383f Utils: More forward declarations / drop unused headers [T-Z]
Round 1 - focus on headers.
For classes with initial in range [T-Z].

Replace QT_FORWARD_DECLARE_CLASS with QT_BEGIN_NAMESPACE and
QT_END_NAMESPACE and forward declare inside.

Change-Id: I4ac3a8391e6167aa2db3973a9f94a45ac3c8ebd1
Reviewed-by: hjk <hjk@qt.io>
2022-05-25 07:40:47 +00:00
Wojciech Smigaj
9d3100ff1e ProjectTree: Merge descendants of hidden Sources and Headers virtual folders
Unchecking the recently added "Show Source and Header Groups" option removes
the Sources and Headers virtual folders from the Projects tree. This patch
additionally merges descendants of these folders with identical priorities,
display names and file paths.

For example, if a project contains a folder including both source and header
files, both the Sources and Headers virtual folders will have child nodes
representing that folder. Previously, unchecking "Show Source and Header
Groups" kept both these identically named nodes in the Projects tree (one
containing sources, the other headers). With this patch, these nodes are
merged into a single node containing both sources and headers.

Change-Id: I4786eee4a528ea141a7fe117e14a050f68411890
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-07-15 19:45:03 +00:00
Eike Ziller
c245a642f2 Share "auto-detected" UI string and add tool tip
No need to have the same translatable string repeated at all these
places.
Also add tooltip to expand a bit on what "auto-detected" actually means.

Task-number: QTCREATORBUG-25291
Change-Id: I25d43486758ba17256cf7e1ea2eea0ec3d567b62
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
2021-01-29 15:04:05 +00:00
Christian Stenger
b4cc084a98 Utils: Add findAnyChild() to TypedTreeItem
Removes some static casts on the user side.

Change-Id: I0a9ae512f294c0e78e0a5890e557c483af86abfe
Reviewed-by: hjk <hjk@qt.io>
2021-01-08 05:58:54 +00:00
Jarek Kobus
900007e781 Reuse the requestExpansion() signal from the base class
In addition correct the signatures of signals in BaseTreeModel.

Change-Id: I8c49105c9fcc1a6115c5e5c0dc8d9e87ff98d707
Reviewed-by: hjk <hjk@qt.io>
2020-11-17 13:52:41 +00:00
Christian Stenger
7ba74c2ba4 AutoTest: Use TypedTreeItem for TestResultItem
Simplifies code and reduces (visible) static_casts on
the auto test plugin's side.

Change-Id: I31ae3e4f1a32d3e74527ccb36080944848f3b1fa
Reviewed-by: David Schulz <david.schulz@qt.io>
2019-02-08 05:39:25 +00:00
Alessandro Portale
f6943a712a Utils: Modernize further
Many issues, mostly in headers, were not addressed in
e38410b76c

modernize-use-auto
modernize-use-nullptr
modernize-use-override
modernize-use-using
modernize-use-default-member-init
modernize-use-equals-default

Change-Id: I320a51726db881e582b898948d53735ebb06887a
Reviewed-by: hjk <hjk@qt.io>
2018-07-24 12:21:42 +00:00
Tobias Hunger
63ef88d015 Utils: Consistently use nullptr
Fixed by clang-tidy modernize-use-nullptr.

Change-Id: I93edae67271a521e3b2a1f97f486e5fa97009836
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
2018-05-13 19:53:14 +00:00
Christian Stenger
c46b6dbb56 Utils: Fix treemodel's hasChildren
Basically this reverts 08e73d1a93, but adds an
additional check for the column as the BaseTreeModel
implementation just allows children at the first column.

Main reason for this revert is that the variable choosers
used across Qt Creator did no more populate their
respective macro lists automatically.

Change-Id: I172506a9dbe18f20b152ec797f35feff717dc3cf
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-05-02 12:58:28 +00:00
hjk
08e73d1a93 Utils: Remove BaseTreeModel::hasChildren re-implementation
Not needed and wrong, as it doesn't handle the case of column != 0.

Change-Id: I0ff62df0547a47ea80e1450b7cca1ecc86da7005
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
2018-02-20 11:19:47 +00:00
hjk
8ce6fffa0f Utils: Let tree items request collapsing
In addition to the already existing expansion request.

Change-Id: I5a60a2ae6d71bdd1fcf44af5554ca45212d9d5bd
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2018-01-31 14:12:37 +00:00
Christian Stenger
17c64e27f8 Utils: Change processing of children in reverseFindAnyChild()
This changes the processing of children to step down into the children
first (and their children recursively) instead of just processing direct
children in reverse.
Fixes an issue with AutoTest plugin where results of data tags got a
new intermediate although there was already one present.

Change-Id: I1fe42942db975c7a1aa3ddb0b6596979c1164dd7
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2018-01-24 12:02:24 +00:00
Christian Stenger
cd51ff7c0f Utils: Fix typo in function name
Change-Id: Ibd973f68d291731dab06ef1b7eee902be19601a5
Reviewed-by: hjk <hjk@qt.io>
2017-09-05 13:49:23 +00:00
hjk
2aab5510ed TreeModel: Add a sibling() implementation
The base implementation uses the parent() index, which
in turn accesses the grand parent level. We can save
a few cycles here.

Change-Id: I3c3696118fe7c3d4563ee3cd28981fca62013828
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2017-09-04 12:36:26 +00:00
hjk
06569e5f3a ProjectExplorer: Order projects in session alphabetically again
Task-number: QTCREATORBUG-18337
Change-Id: I716369a1012f93c6c676e89c3b32cd1a406996a5
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2017-08-17 07:57:50 +00:00
Tobias Hunger
ea867cd49a ProjectExplorer: Add option to hide empty directories from project tree
Together with the earlier fix for hiding generated files, this change makes
for a very clean CMake server-mode project tree:-)

Change-Id: Ib70fd66699eddf5d6e602f3f8848b31fd6d85b57
Reviewed-by: André Hartmann <aha_1980@gmx.de>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
2017-08-04 13:34:13 +00:00
Christian Stenger
4edc715b1c AutoTest: Speed up finding parent items
We normally add new results to the last added
item, so processing the search for the parent
from bottom to top makes more sense and avoids
iterating over almost every item.

Change-Id: Iede08b9c0d4c80227d2e8fea9b002354f01d5b35
Reviewed-by: hjk <hjk@qt.io>
2017-06-30 11:36:44 +00:00
hjk
2a6237705c TreeModel/Find: Save a few cycles when searching
Calls parent() only ~two out of three times and remove some
function calls in the TreeModel::parent() implementation,
reducing the overall footprint of this bit from ~5 to ~1.5%
when searching something in the project tree (test case
was Creator-in-Creator, and searching for 'dddddddddd',
resulting in 8 complete scans of the tree.

Task-number: QTCREATORBUG-17956
Change-Id: I4e46ef0467dd2aea58a7c944e1a2ee5c01e6fbba
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-04-05 13:25:12 +00:00
hjk
196dbbe0e7 Utils: Introduce TreeItem::{begin,end}
... and use this to reduce the number of explicit uses of m_children.

Despite of being shorter code by itself it is a step towards having
an explicit LeafItem object that doesn't explicitly store a(n empty)
vector of child nodes.

Change-Id: If8db85e2f1134dd1578a78d31235bf57a28f863a
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2017-02-08 16:08:42 +00:00
hjk
3c743346b0 ProjectExplorer: Make the FlatModel a Utils::TreeModel
The FlatModel is essentially a proxy model keeping expansion and
filter state per ProjectTree(View). Using a Utils::TreeModel makes
it fast enough to allow recreation of the proxy structure on
structural changes simplifying the parent/child logic significantly.

The {Session,Project,Folder,File}Node hierarchy still is still primary
information and shared by all views.

Change-Id: Ic08180a19bda37908280ff30e0737d188ed93e92
Reviewed-by: Robert Loehning <robert.loehning@qt.io>
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
2017-01-25 13:52:51 +00:00
hjk
a6acd3e8d9 TreeModel: Introduce a TreeItem::indexInParent() convenience function
To shorten user code and hide the ugly const_cast.

Change-Id: I798bd105932004ea17cb95b243fc38ccfcda0a2c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2016-08-03 09:24:01 +00:00
hjk
def8ca8ba1 TreeModel: Move some base TreeItem code out-of-line
Avoid code explosion.

Change-Id: I7d239a4560e90b68cc4991341adf940a98776254
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2016-08-03 09:23:46 +00:00
hjk
be2a0b9ecd TreeModel: Remove BaseTreeModel::topLevelItemCount()
Not used, and easily done with rootItem()->childCount() in case it
is needed again.

Change-Id: I7e85ac1bb72b3a799987b1bf6bd54d21b7ab06ee
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2016-08-03 07:54:35 +00:00
hjk
cc873518c0 TreeModel: Make TreeItem::m_children private
Change-Id: Ica8ee995fb265d1108fced1e1c1a4c9234783c2b
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2016-08-01 08:48:12 +00:00
hjk
08366cdf6e TreeModel: Remove uses of Q_DECL_EQ_DELETE
Use ' = delete' instead like everywhere else.

Change-Id: I63d0fd1adbc336f4b390b7c68d3f945e4045052c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2016-08-01 07:31:42 +00:00
hjk
c3d3589c0f TreeModel: Remove now-unused TreeItem::setFlags() and m_flags
Change-Id: I1bae545b96c274a74cd6491b33ba138be489086f
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2016-08-01 07:23:37 +00:00
hjk
53415cece1 Utils: Streamline TreeModel API
The LeveledTreeModel case is general enough to cover
the UniformTreeModel case, so merge them and rename to
TreeModel. The former TreeModel is now BaseTreeModel.

BaseTreeModels should not be instantiated directly,
a tree model with non-uniform basic items is available
as TreeModel<>.

Done-with: Eike Ziller <eike.ziller@qt.io>
Change-Id: I64a65617ab68c0cde39cf65f4bc092ef808ee6fb
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2016-07-27 08:00:40 +00:00
hjk
e6069d8b03 TreeModel: Introduce a recursive TreeItem::updateAll() function
Useful in cases where e.g. siblings are affected (e.g. font
changes to indicate active items).

Change-Id: Ib2f8018688d00bd682bb6aaff08156f0be04f5dc
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2016-07-12 12:02:03 +00:00
hjk
20ec978b56 TreeModel: Initialize root item with proper type in LeveledTreeModel
Current usage is to use setRootItem() manually when needed, but
since the type is known in a LeveledTreeModel this can be automatic.

Change-Id: I511acdf9b9b3f4b67cf87d07b5446baa329a6a77
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2016-07-12 11:57:12 +00:00
Eike Ziller
546df37c98 Merge remote-tracking branch 'origin/4.1'
Conflicts:
	README.md
	src/plugins/modeleditor/actionhandler.cpp

Change-Id: I65c2885593b881eda94872168a3891cab9cafe71
2016-07-11 10:46:05 +02:00
hjk
e48451b0a3 TreeModel: Consolidate child()/childAt() and rowCount()/childCount()
We never used the possibility to overload the virtual child() and
rowCount() functions, it's unlikely to be needed in future.

Change-Id: I7ebdf4dfc70bb0bcadea9ef3fb88f16632a95696
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2016-07-07 13:39:15 +00:00
hjk
7b4c7d49a9 TreeModel: Introduce a destroyItem() convenience function
Shorthand for delete takeItem(...).

Change-Id: Icb7b60e5c19aa0d21650eefff65f7eb55e9f90b0
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2016-07-06 11:41:55 +00:00
hjk
3c431c92c9 TreeModel: Declare Utils::TreeItem * as meta type
Change-Id: I4a72646a7647c898fb2f5ce627d6381f9c7d23ef
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2016-07-06 11:37:47 +00:00
hjk
0cfd569038 TreeModel: Add an optional ParentType parameter for TypedTreeItem
... and use it to add a ParentType *parent() function.

Also, de-virtualize the TreeModel::parent(), this flexibility has not
been needed so far.

Change-Id: I0bcf930a0d6b05d5621753a5a8a1f8c3e5017386
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2016-06-27 08:55:49 +00:00
hjk
2536c2bfc7 TreeModel: Re-order template arguments for tree levels
More natural and easier to extend to use parameter packs later.

Adjust users.

Change-Id: Ic167196cc969d18bb1615084397e884f769d1e85
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2016-06-24 07:34:13 +00:00
hjk
441b81b2b3 Utils: Add a TypeTreeItem::forFirstLevelChildren iterating function
More typesafety.

Change-Id: Ica50e1c38f6c5d7d3545b588c698f0cbb5775672
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2016-06-21 06:00:52 +00:00
hjk
cfc724e709 Utils: Make remaining TreeModel iterating functions 'const'
This follows the rest of similar functions. It is arguably abusing the
C++ misfeature that 'const' only applies to the top level, but
avoids re-typing the same implementations stanzas for otherwise needed
const/non-const overloads.

Change-Id: If90fc879b406fd94714995ff4c42a4ebe3c69faa
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2016-06-20 10:14:59 +00:00
hjk
5ff15e89f2 Utils: Add a typesafe TypedTreeItem::childAt(int) overload
Change-Id: I5285d07576803511b23cdb19c930df286c430f92
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2016-06-20 06:12:44 +00:00
hjk
1ce258d710 Debugger/Utils: Remove TwoLevelTreeModel
It's well covered by the more generic Utils::LeveledTreeModel now.

Change-Id: I3982ad39a64742b0a0a59433024457db3808bfc7
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
2016-06-17 12:40:09 +00:00
hjk
fb482846fc TreeModel: Add a StaticTreeItem(QString) convenience constructor
Covers the common case and hopefully avoids the recurring MSVC
problem with initializer lists in this location.

Change-Id: I1b2bbb083f9fc86af3b51b8f52615fb70c832b95
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
2016-06-17 08:09:48 +00:00
hjk
b281d6dad7 TreeModel: Introduce a StaticTreeItem
This splits out the case of static string displays from the
TreeItem base class, making the base more lightweight.

Change-Id: If1f442011ec60094399a41b65d9b5015f432f82e
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2016-06-15 08:55:16 +00:00