Movatterモバイル変換


[0]ホーム

URL:


CN115904353B - Method and system for generating target source file of user interface - Google Patents

Method and system for generating target source file of user interface
Download PDF

Info

Publication number
CN115904353B
CN115904353BCN202310190828.7ACN202310190828ACN115904353BCN 115904353 BCN115904353 BCN 115904353BCN 202310190828 ACN202310190828 ACN 202310190828ACN 115904353 BCN115904353 BCN 115904353B
Authority
CN
China
Prior art keywords
sentence
target
statement
source file
class
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202310190828.7A
Other languages
Chinese (zh)
Other versions
CN115904353A (en
Inventor
钱志峰
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Hejian Industrial Software Group Co Ltd
Original Assignee
Shanghai Hejian Industrial Software Group Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Hejian Industrial Software Group Co LtdfiledCriticalShanghai Hejian Industrial Software Group Co Ltd
Priority to CN202310190828.7ApriorityCriticalpatent/CN115904353B/en
Publication of CN115904353ApublicationCriticalpatent/CN115904353A/en
Application grantedgrantedCritical
Publication of CN115904353BpublicationCriticalpatent/CN115904353B/en
Activelegal-statusCriticalCurrent
Anticipated expirationlegal-statusCritical

Links

Images

Classifications

Landscapes

Abstract

The invention relates to the technical field of generating a target source file of a user interface, in particular to a method and a system for generating the target source file of the user interface, which are realized by acquiring a generated header file h0 Identifying h from regular expressions0 The three sentences are respectively stored in different containers; traversing corresponding sentences in each container, and respectively replacing first type elements of the first type sentences with first type target elements to obtain updated first type sentences; replacing class names in the second sentence and the third sentence with target class names and replacing object pointer names with target object pointer names respectively to obtain updated second and third sentences; recombining the updated first, second and third sentences into a target source file to achieve the goal of recombining the header file h0 The purpose of automatically generating the target source file can not only accelerate development progress, but also reduce errors of manual writing, and secondary development can be reused.

Description

Method and system for generating target source file of user interface
Technical Field
The present invention relates to the field of generating a target source file of a user interface, and in particular, to a method and a system for generating a target source file of a user interface.
Background
When editing a user interface, an interface designer in QT is generally used for quickly designing the interface, such as adding a button, and the interface designer generates a ui file in a catalog of an engineering, and when the c++ code related to the interface needs to be edited, a developer needs to use a uic tool to generate an h-head file by using the ui file as input.
Because different projects or users have different development specifications or customized control classes, the generated h-header files need to be modified to conform to the specifications of engineering projects, and the h-header files regenerated by using uic need to be modified each time of the change of ui files, so that the manual modification speed is low and the error probability is high.
Disclosure of Invention
Aiming at the technical problems, the invention adopts the following technical scheme: a method of generating a target source file for a user interface, the method comprising:
s100, acquiring a header file h which is generated according to a user interface created by a user and accords with QT specification0 Said h is0 A first sentence comprising a preprocessing area, a second sentence comprising a class common control member definition area, and a third sentence comprising a function body area, wherein each first sentence is a sentence comprising h0 Each second statement defines a statement for class members including class names and object pointer names, and the third statement includes class names and object pointer names.
S200, identifying h according to regular expression0 The first sentence, the second sentence and the third sentence, the first sentence is stored in the first container, the second sentence is stored in the second container, and the third sentence is stored in the second container according to h0 Is stored in a third container.
S300, traversing a first sentence stored in a first container, and respectively replacing first elements with first target elements according to an element dictionary to obtain an updated first sentence; the element dictionary includes h0 A mapping relationship between the first element of the target source file and the first target element of the target source file.
S400, traversing the second container and the third container respectively, and respectively converting h according to the class name dictionary and the object pointer name dictionary0 Class names of (a) are replaced by target class names, h respectively0 The object pointer name of the (2) is replaced by the target object pointer name, so that updated second sentences and third sentences are obtained; the class name dictionary includes h0 Mapping relationship between class name of object pointer and object class name of object source file, said object pointer name dictionary includes h0 A mapping relationship between the object pointer name of the target source file and the target object pointer name of the target source file.
S500, assembling the updated first statement, second statement and third statement into a target source file h0 The target source file h0 For generating a user interface.
The invention further provides a system for generating the target source file of the user interface, which comprises a processor and a non-transitory computer readable storage medium, wherein at least one instruction or at least one section of program is stored in the non-transitory computer readable storage medium, and the at least one instruction or the at least one section of program is loaded and executed by the processor to realize the method.
Compared with the prior art, the method and the system for generating the target source file of the user interface have obvious beneficial effects, can achieve quite technical progress and practicality, have wide industrial utilization value, and have at least the following beneficial effects:
the invention provides a method and a system for generating a target source file of a user interface, which are realized by acquiring a generated header file h0 Identifying h from regular expressions0 The three sentences are respectively stored in different containers; traversing corresponding sentences in each container, and respectively replacing first type elements of the first type sentences with first type target elements to obtain updated first type sentences; replacing class names in the second sentence and the third sentence with target class names and replacing object pointer names with target object pointer names respectively to obtain updated second and third sentences; recombining the updated first, second and third sentences into a target source file to achieve the goal of recombining the header file h0 The purpose of automatically generating the target source file can not only accelerate development progress, but also reduce errors of manual writing, and the generation method provided by the invention is adopted to directly generate the target source file when the ui file is modified again; solves the problem of manually modifying the header file h in the prior art0 The technical problems of high error rate and slow development speed are caused.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a flowchart of a method for generating a target source file of a user interface according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to fall within the scope of the invention.
Referring to fig. 1, a flowchart of a method for generating a target source file of a user interface is shown, where the method includes:
s100, acquiring a header file h which is generated according to a user interface created by a user and accords with QT specification0 Said h is0 A first sentence comprising a preprocessing area, a second sentence comprising a class common control member definition area, and a third sentence comprising a function body area, wherein each first sentence is a sentence comprising h0 Each second statement defines a statement for class members including class names and object pointer names, and the third statement includes class names and object pointer names.
Note that, header file h0 Is generated from UIC tool, but header file h0 Does not meet the target system specification of the user, and therefore requires the header file h0 An analysis is performed and automatically converted to a target source file that meets target system specifications.
Specifically, the first statement of the preprocessing region is a preprocessing command in a plurality of different formats. Wherein the first key comprises a pre-processing command, wherein the pre-processing command comprises: ifndef, define, include, etc.
Specifically, the second statement in the class common control member definition area is defined for the control class common members of the class. As an example, a class member in the key public format is, for example: "NameA. NameB". The NameA is a class name and the NameB is an object pointer name.
Specifically, the third statement is a statement in the function main body area, and one or more of the statements include a class name and an object pointer name in the class common control member definition area. As an example, in a certain sentence, "pushbutton=new name a (parameter c)", where name is a class name defined in a class public control member definition area.
S200, identifying h according to regular expression0 The first sentence, the second sentence and the third sentence, the first sentence is stored in the first container, the second sentence is stored in the second container, and the third sentence is stored in the second container according to h0 Is stored in a third container.
Wherein the regular expression is h0 A constraint corresponding to the format of the different category sentences. Those skilled in the art will appreciate that all methods of identifying statement classes using the generation of regular expressions in the prior art fall within the scope of the present invention.
As a preferred embodiment, keywords in the corresponding category of sentences are included in the regular expression.
It will be appreciated that h0 Each sentence in the list comprises a plurality of sub-sentences, the plurality of sub-sentences comprise at least one grammar format, namely, the same sentence is identified by a regular expression or synonymous regular expression, and different sentence categories are distinguished by setting different regular matching character strings comprising keywords, sentence characteristics and the like, so that the aim of classifying sentences with different formats is fulfilled.
It can be understood that sentences in different types are stored through different storage containers, so that subsequent processing of sentences in different containers is facilitated. Alternatively, the container is an array or map, etc.
As a preferred embodiment, before storing the first sentence in the first container, the method further comprises: s220, identifying a first keyword in the first sentence, and according to the first keywordObtaining N first seed sentences with the same first key words, wherein the N first seed sentences are in h0 The order of execution of which is the same as or different from the order of storage in the first container. Optionally, the first type of keyword is include.
As a preferred embodiment, before storing the second sentence in the second container, the method further comprises: s240, identifying a second keyword in the second sentence, and acquiring M class members sharing the same second keyword according to the second keyword, wherein the M class members are in h0 The defined order of (a) is the same as or different from the order of storage in the second container. Optionally, the access modifier of the second type of key is public.
It will be appreciated that the third container is an ordered container or may be implemented as a container accessed in a specified order, ensuring that the original logic is not destroyed when the target source code is reorganized.
S300, traversing a first sentence stored in a first container, and respectively replacing first elements with first target elements according to an element dictionary to obtain an updated first sentence; the element dictionary includes h0 A mapping relationship between the first element of the target source file and the first target element of the target source file.
It should be noted that, the target element is a target header file name corresponding to the original header file name, and the naming specification of the target header file name accords with the naming specification of the target system. Header file h0 The first type elements conforming to the QT naming specification are replaced by target elements, so that the replaced first statement conforms to the target system specification. The order of the first element in the element dictionary is a preset order and may be different from the order stored in the first container.
S400, traversing the second container and the third container respectively, and respectively converting h according to the class name dictionary and the object pointer name dictionary0 Class names of (a) are replaced by target class names, h respectively0 The object pointer name of the (2) is replaced by the target object pointer name, so that updated second sentences and third sentences are obtained; the class name dictionary includes h0 Mapping relationship between class name of object pointer and object class name of object source file, said object pointer name dictionary includes h0 A mapping relationship between the object pointer name of the target source file and the target object pointer name of the target source file.
It should be noted that the target class member is a class member conforming to the naming specification of the target source file. Will h0 The class members meeting the QT naming standards are replaced by target class members meeting the target system naming standards of the user, so that the replaced second statement and third statement meet the target system naming standards. The steps S300 and S400 are only for convenience of description, and the steps may be executed first in the step S300 and then in the step S400, without any order between the steps. S400 may be executed first, and S300 may be executed later; in step S400, the traversing order of the second container and the third container is not limited, and similarly, the second container may be traversed first, then the third container may be traversed, or the third container may be traversed first, then the second container may be traversed.
As one example, replacing a class name with a target class name refers to replacing a class name nameA with a target class name nameSA.
As a preferred embodiment, S400 further includes:
s420, traversing the updated third statement according to a statement mapping dictionary, wherein the statement mapping dictionary comprises a mapping relation between a third seed statement and a target sub statement which do not accord with the target source file specification, and identifying the third seed statement and replacing the third seed statement with the target sub statement. Optionally, the sentence mapping dictionary includes a mapping relation that the target sub-sentence is empty. When the target sentence is empty, the essence operation is to delete h0 A third class of sub-statements in (a).
S500, assembling the updated first statement, second statement and third statement into a target source file h0 The target source file h0 For generating a user interface.
It can be appreciated that the reorganization is performed according to the structure of the target source file. Generally, the reorganization is performed in the order of the first sentence, the second sentence, and the third sentence.
As a preferred embodiment, when the naming specification of the target source file is modified, the target class name in the class name dictionary, the target object pointer name in the object pointer name dictionary and/or the first target element in the element dictionary are adaptively modified, so that the adaptive updating of the target source file can be realized.
In summary, the embodiment of the invention provides a method for generating a target source file of a user interface by acquiring a generated header file h0 Identifying h from regular expressions0 The first sentence of the pre-processing area, the second sentence of the class public control member definition area and the third sentence of the function main body area are respectively stored in different containers; traversing corresponding sentences in each container, and respectively replacing first-type elements of the first-type sentences with first-type target elements to obtain updated first-type sentences; respectively replacing class members in the second sentence and the third sentence with target class members to obtain an updated second sentence and third sentence; recombining the updated first, second and third sentences into a target source file to achieve the goal of recombining the header file h0 The aim of automatically generating the target source file can not only accelerate development progress, but also reduce errors of manual writing, and the target source file is directly generated by using the method provided by the embodiment of the invention when the ui file is modified again; solves the problem of manually modifying the header file h in the prior art0 The technical problems of high error rate, low debugging speed and high manual modification cost are caused.
Based on the same inventive concept as the above method embodiment, the present invention further provides a system for generating a target source file of a user interface, where the system includes a processor and a non-transitory computer readable storage medium, where at least one instruction or at least one program is stored in the non-transitory computer readable storage medium, where the at least one instruction or the at least one program is loaded and executed by the processor to implement the method for generating a target source file of a user interface provided in the above embodiment, and the method for generating a target source file of a user interface is described in detail in the above embodiment and is not repeated.
While certain specific embodiments of the invention have been described in detail by way of example, it will be appreciated by those skilled in the art that the above examples are for illustration only and are not intended to limit the scope of the invention. Those skilled in the art will also appreciate that many modifications may be made to the embodiments without departing from the scope and spirit of the invention. The scope of the invention is defined by the appended claims.

Claims (8)

CN202310190828.7A2023-03-022023-03-02Method and system for generating target source file of user interfaceActiveCN115904353B (en)

Priority Applications (1)

Application NumberPriority DateFiling DateTitle
CN202310190828.7ACN115904353B (en)2023-03-022023-03-02Method and system for generating target source file of user interface

Applications Claiming Priority (1)

Application NumberPriority DateFiling DateTitle
CN202310190828.7ACN115904353B (en)2023-03-022023-03-02Method and system for generating target source file of user interface

Publications (2)

Publication NumberPublication Date
CN115904353A CN115904353A (en)2023-04-04
CN115904353Btrue CN115904353B (en)2023-06-23

Family

ID=86496468

Family Applications (1)

Application NumberTitlePriority DateFiling Date
CN202310190828.7AActiveCN115904353B (en)2023-03-022023-03-02Method and system for generating target source file of user interface

Country Status (1)

CountryLink
CN (1)CN115904353B (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
EP0564790A2 (en)*1992-04-071993-10-13International Business Machines CorporationGraphical user interface including integration of what you see is what you get (WYSIWYG) editor and compiler
US6025836A (en)*1997-07-232000-02-15Novell, Inc.Method and apparatus for generating object oriented user interfaces
CN105739957A (en)*2014-12-092016-07-06阿里巴巴集团控股有限公司User interface data processing method and system
CN108549535A (en)*2018-03-162018-09-18北京大学A kind of efficient procedure parsing method and system based on file dependence
CN111857708A (en)*2020-05-302020-10-30南京理工大学 A realization method and system of multi-image stitching software based on Qt interface
CN112286512A (en)*2020-10-302021-01-29西南电子技术研究所(中国电子科技集团公司第十研究所) Avionics Simulation Test Platform UI Management Subsystem
CN114879882A (en)*2022-05-242022-08-09上海合见工业软件集团有限公司Software menu system based on JSON configuration
CN115495079A (en)*2022-09-302022-12-20南京芯传汇电子科技有限公司 A method and system for dynamically generating Qt interface based on PSD file format

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
JP2001306308A (en)*2000-04-112001-11-02Sap Ag How to define a class for data-centric applications
EP3120226A4 (en)*2014-03-212017-12-13Nokia Technologies OYMethod and apparatus for controlling smart objects with a collage user interface using normalized user interface descriptors
US10552122B2 (en)*2017-05-022020-02-04Mastercard International IncorporatedSystems and methods for customizable regular expression generation
US10656920B2 (en)*2018-06-032020-05-19Apple Inc.Dynamically adaptable tool for graphical development of user interfaces
US11418622B2 (en)*2020-08-182022-08-16Baton SimulationsSystem and methods for web-based software application translation

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication numberPriority datePublication dateAssigneeTitle
EP0564790A2 (en)*1992-04-071993-10-13International Business Machines CorporationGraphical user interface including integration of what you see is what you get (WYSIWYG) editor and compiler
US6025836A (en)*1997-07-232000-02-15Novell, Inc.Method and apparatus for generating object oriented user interfaces
CN105739957A (en)*2014-12-092016-07-06阿里巴巴集团控股有限公司User interface data processing method and system
CN108549535A (en)*2018-03-162018-09-18北京大学A kind of efficient procedure parsing method and system based on file dependence
CN111857708A (en)*2020-05-302020-10-30南京理工大学 A realization method and system of multi-image stitching software based on Qt interface
CN112286512A (en)*2020-10-302021-01-29西南电子技术研究所(中国电子科技集团公司第十研究所) Avionics Simulation Test Platform UI Management Subsystem
CN114879882A (en)*2022-05-242022-08-09上海合见工业软件集团有限公司Software menu system based on JSON configuration
CN115495079A (en)*2022-09-302022-12-20南京芯传汇电子科技有限公司 A method and system for dynamically generating Qt interface based on PSD file format

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
基于Qt/Embedded的嵌入式监测系统人机界面;刘胜玉;张志新;;工业控制计算机(第09期);全文*
基于嵌入式Linux系统的Qt/Embedded图像处理界面开发;刘福才;赵佳伟;汤丽娜;;计算机应用与软件(第11期);全文*

Also Published As

Publication numberPublication date
CN115904353A (en)2023-04-04

Similar Documents

PublicationPublication DateTitle
US8082144B1 (en)Tax calculation explanation generator
JP3009215B2 (en) Natural language processing method and natural language processing system
US5555169A (en)Computer system and method for converting a conversational statement to computer command language
US20140156282A1 (en)Method and system for controlling target applications based upon a natural language command string
CN110554875B (en)Code conversion method and device, electronic equipment and storage medium
JPH09502039A (en) Method and apparatus for modeling and querying a database using a structure similar to natural language
US7610292B2 (en)Systems and methods for storing a dataset having a hierarchical data structure in a database
CN113779062A (en)SQL statement generation method and device, storage medium and electronic equipment
RU2544739C1 (en)Method to transform structured data array
CN118012901A (en) A structured query language generation method, device, equipment and readable storage medium
JP3186117B2 (en) Automatic program generation system using data-centric software components
CN119829022A (en)Method for generating front-end prototype based on artificial intelligence technology
CN115904353B (en)Method and system for generating target source file of user interface
CN119127834A (en) Database migration method, device, system and storage medium based on MyBatis
CN116451795B (en) Quantum circuit diagram processing method, device, electronic equipment and storage medium
CN111752549A (en)SQL function generation method and device
CN118170386A (en)Term compiling method, term compiling system, storage medium and electronic device
US20240143928A1 (en)Generation of interactive utterances of code tasks
CN114611714A (en) Model processing method, device, system, electronic device and storage medium
JP2778025B2 (en) Learning Co-occurrence Dictionary
CN116627390B (en)ICD file substitution method and device in aviation software development
JP3050467B2 (en) Data item dictionary generation method
JPH07146785A (en) Program automatic generation method and device
Mishchenko et al.New functionalities of the system for processing natural language specifications and its operating environment
US20250321959A1 (en)Hybrid natural language query (nlq) system based on rule-based and generative artificial intelligence translation

Legal Events

DateCodeTitleDescription
PB01Publication
PB01Publication
SE01Entry into force of request for substantive examination
SE01Entry into force of request for substantive examination
GR01Patent grant
GR01Patent grant

[8]ページ先頭

©2009-2025 Movatter.jp