Commit Graph

11 Commits

Author SHA1 Message Date
Alexey Edelev 0925534e6c Add vcpkg.json for the QtProtobuf sensors example
Use the vcpkg manifest to configure and build QtProtobuf sensors
example. This allows automating the dependency installation using
vcpkg.

Pick-to: 6.9
Task-number: QTBUG-132738
Change-Id: Icae7acf46d97d834a064d7663623757a7ec35742
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-03-07 11:10:50 +01:00
Alexey Edelev 97a99986c0 Scope QAbstractProtobufSerializer::Error enum
All new enums should be scoped.

Drive-by change: Remove the redundant suffixes of the enum elements.
It's obvious from the scope that those are errors.

Pick-to: 6.8
Task-number: QTBUG-123626
Change-Id: Ided4ab4a1ddb2d14713f876ffe4fe339af39ae6b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2024-09-05 10:41:03 +02:00
Alexey Edelev e04f23a76a Generate protobuf enum as enum class
This will unlock the use of enum fields duplicates in the same scope
if the respective feature will be supported by the reference protobuf.

Pick-to: 6.8
Task-number: QTBUG-126992
Change-Id: Ib38e313b62885042e2f75376836d1cb0ad2574db
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2024-08-28 14:47:48 +02:00
Alexey Edelev 119add5fde Make error handling in QAbstractProtobufSerializer generic
Rename the deserializationError(String) interfaces to
lastError(String). The new interface encourages to write the errors
not only during deserialization but also serialization.

TODO: Add serialization error handling to the existing
QAbstractProtobufSerializer implementations. See QTBUG-128331.

[ChangeLog][Protobuf] QAbstractProtobufSerializer::DeserializationError
is renamed to QAbstractProtobufSerializer::Error and now contains list
of both possible serialization and deserialization errors.

[ChangeLog][Protobuf][QAbstractProtobufSerializer] deserializationError
and deserializationErrorString renamed to lastError and lastErrorString
respecively. Interfaces return the error from the last operation,
either serialization or deserialization.

Pick-to: 6.8
Task-number: QTBUG-123626
Change-Id: I705eb69e07393aa6601cc79712845200873235a0
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2024-08-28 14:47:48 +02:00
Lucie Gérard 4b21c9ef0d Correct license for example files
According to QUIP-18 [1], all example files should be
LicenseRef-Qt-Commercial OR BSD-3-Clause

[1]: https://contribute.qt-project.org/quips/18

Pick-to: 6.7
Task-number: QTBUG-121787
Change-Id: If6b8c8eb88c8880e6e277f472dfdd5b380a5c83d
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2024-03-15 14:28:25 +01:00
Alexey Edelev 36a64710a9 Format the .proto files according to the clang-format rules
Pick-to: 6.6 6.5
Change-Id: Iedc563ab8689779960dc6a2cc0b5817a874374e0
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
2023-08-23 10:02:50 +02:00
Alexey Edelev b089a773e9 Move enums to the nested namespace out of class
Protobuf allows the following construction:
  message A {
      enum AEnum {
        AVal0 = 0;
      }
      B.BEnum val = 1;
  }
  message B {
      enum BEnum {
          BVal0 = 0;
      }
      A.AEnum val = 1;
  }

This requires forward declaration of nested enums, that is not possible
in C++. To solve this problem we may do the same trick that we do
for nested messages already.
This patch moves the nested enum type out of class to the
_QtProtobufNested namespace. The solution require the enum name
specification when using enums from this moment, since the owning
messages only contain type aliases now. So from example above to access
the AVal0 you need to use the full qualifier:
  A::AEnum::AVal0

The new generated code structure registrates Qml types using the built-in
macros, that unlocks direct linking of backing library without the need
of Qml plugin usage.

[ChangeLog][Protobuf] Nested enums moved out of message classes to the
nested namespace, same as the nested messages.

[ChangeLog][Protobuf][Qml] The geneated protobuf Qml modules do not
require the use of Qml plugins.

Fixes: QTBUG-115800
Change-Id: Ia67fcbecf492c3fd41350eada4d62fc9e5ea4dab
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-08-18 19:01:25 +02:00
Alexey Edelev 653180829e Fix the client 'bind' call eaten by Q_ASSERT_X
Q_ASSERT_X is empty in release-like configs, so the actual functionality
is eaten by macro. Fix issue in sensor example.

Pick-to: 6.5 6.6
Change-Id: Ib162a09a6552b9f1a522daadc998b8e597780e8a
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
2023-08-16 10:57:19 +02:00
Topi Reinio b519fe95fd Doc: Use the \examplecategory macro to tag examples
The '\meta category' command was used for tagging examples with a
specific category, used in Qt Creators Welcome mode.

As we want to also generate lists of examples belonging to a category
elsewhere in the documentation, replace the command with a macro that
expands to the original \meta command and also adds the example to
a group using the \ingroup command. This way, the category names can
be used as arguments to the \generatelist or \annotatedlist commands.

Pick-to: 6.5
Task-number: QTBUG-112731
Change-Id: I38b38c524b35ad4c0049f2978f5fc65d03c6a1cd
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2023-04-11 13:34:44 +00:00
Alexey Edelev 3b10bf74b2 Add the missing copyright and license headers to the .proto files
Pick-to: 6.5 6.5.0
Change-Id: Id3d75385f251e77aebe0b56a82549e19fd0fbf84
Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io>
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2023-03-06 11:20:05 +01:00
Alexey Edelev 76d94d29ea Add example of communication using protobuf messages
Add the protobuf example that emulates the work of dummy sensors that
send data to the sensor client. The example uses UDP sockets to send
datagrams that contain protobuf messages. Messages consist of two
layers:
 - The Type-Length-Value wrapping message that specifies the the
   message type and allows to verify the message size.
 - Sensor message that contains a sensor data.

The example intends to show how to generate the code from the protobuf
schema and use it in simple UDP signalling protocol on both sender and
receiver sides.

Both client and emulator have simple UI implemented using QtWidgets.

Task-number: QTBUG-109598
Pick-to: 6.5
Change-Id: I13e2c5bcd995b8aa6d873c495a7bd83f6651a061
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-02-13 15:10:52 +01:00