2017-02-07 09:08:11 +01:00
|
|
|
# Copyright (C) 2017 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2017-02-07 09:08:11 +01:00
|
|
|
|
2017-10-17 08:54:55 +02:00
|
|
|
def __childrenOfType__(parentObject, typeName):
|
|
|
|
|
return [child for child in object.children(parentObject) if className(child) == typeName]
|
|
|
|
|
|
2024-02-29 14:24:40 +01:00
|
|
|
|
|
|
|
|
def getWelcomeScreenSideBarButton(buttonLabel):
|
2024-03-07 09:43:41 +01:00
|
|
|
return ("{text='%s' type='QAbstractButton' unnamed='1' visible='1' "
|
2024-02-29 14:24:40 +01:00
|
|
|
"window=':Qt Creator_Core::Internal::MainWindow'}" % buttonLabel)
|
|
|
|
|
|
2017-02-07 09:08:11 +01:00
|
|
|
|
|
|
|
|
def getWelcomeTreeView(treeViewLabel):
|
|
|
|
|
try:
|
2019-10-31 17:40:16 +01:00
|
|
|
return waitForObjectExists("{container=':Qt Creator.WelcomeScreenStackedWidget' "
|
|
|
|
|
"name='%s' type='QTreeView' visible='1'}" % treeViewLabel)
|
2017-02-07 09:08:11 +01:00
|
|
|
except:
|
|
|
|
|
return None
|
2017-02-08 09:34:40 +01:00
|
|
|
|
2018-07-10 13:57:16 +02:00
|
|
|
def switchToSubMode(subModeLabel):
|
2024-02-29 14:24:40 +01:00
|
|
|
wsButton = getWelcomeScreenSideBarButton(subModeLabel)
|
|
|
|
|
buttonFound = object.exists(wsButton)
|
|
|
|
|
if buttonFound:
|
|
|
|
|
mouseClick(wsButton)
|
|
|
|
|
return buttonFound
|
2018-07-10 13:57:16 +02:00
|
|
|
|
2017-02-08 09:34:40 +01:00
|
|
|
def findExampleOrTutorial(tableView, regex, verbose=False):
|
2023-10-11 13:11:39 +02:00
|
|
|
filterModel = __childrenOfType__(tableView, 'QSortFilterProxyModel')
|
|
|
|
|
if len(filterModel) != 1:
|
|
|
|
|
test.fatal("Something's wrong - could not find filter proxy model.")
|
|
|
|
|
return None
|
|
|
|
|
filterModel = filterModel[0]
|
|
|
|
|
if filterModel.rowCount() == 0:
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
children = dumpIndices(filterModel)
|
2017-02-08 09:34:40 +01:00
|
|
|
for child in children:
|
|
|
|
|
if re.match(regex, str(child.text)):
|
|
|
|
|
if verbose:
|
|
|
|
|
test.log("Returning matching example/tutorial '%s'." % str(child.text), regex)
|
|
|
|
|
return child
|
|
|
|
|
return None
|