Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
abstractrandomstring.h
Go to the documentation of this file.
1/*
2 * Copyright 2020 Twilight
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15*/
16#pragma once
17#include <QObject>
18#include <QString>
19
20#include "../db_autoport.h"
21
22class QQmlEngine;
23
35class DB_AUTOPORT AbstractRandomString : public QObject
36{
37 Q_OBJECT
38 Q_PROPERTY(int getStoreSize READ getStoreSize STORED false NOTIFY listChanged)
39
40signals:
41 // Sort of an exception, the DB is almost entirely read-only but this is an
42 // exception of some moving parts in the DB
43 void listChanged();
44
45public:
46 const QVector<QString> getStore() const;
47 int getStoreSize() const;
48 Q_INVOKABLE const QString getStoreAt(const int ind) const;
49
50 Q_INVOKABLE QString randomExample();
51
52public slots:
53 // QML accessible methods
54 void load();
55 void qmlProtect(const QQmlEngine* const engine) const;
56
57protected slots:
58 virtual void qmlRegister() const = 0;
59
60protected:
62 AbstractRandomString(const QString fileName);
63 QVector<QString> store;
64 const QString fileName;
65};
void qmlProtect(const QQmlEngine *const engine) const
Pin to C++ ownership.
const QVector< QString > getStore() const
All strings.
QString randomExample()
A random string from the list.
AbstractRandomString(const QString fileName)
int getStoreSize() const
String count.
const QString getStoreAt(const int ind) const
String at ind (for QML).
const QString fileName
Asset path (set by the subclass).
void load()
Load the strings from fileName.
QVector< QString > store
The loaded strings.
virtual void qmlRegister() const =0
Subclass registers its concrete type with QML.
Import/export macro for the db library, plus the central list of DB entry pointer types declared opaq...
#define DB_AUTOPORT
Expands to the correct dllexport/dllimport decoration for this library.
Definition db_autoport.h:37