mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-11-11 14:07:39 +01:00
feat: save blog information
This commit is contained in:
parent
5289bb6fb2
commit
460f633d08
Binary file not shown.
27
EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/blogs.json
Normal file
27
EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/blogs.json
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"5": {
|
||||||
|
"blogId": "5",
|
||||||
|
"ownerId": "6",
|
||||||
|
"title": "6"
|
||||||
|
},
|
||||||
|
"6": {
|
||||||
|
"blogId": "6",
|
||||||
|
"ownerId": "7",
|
||||||
|
"title": "5"
|
||||||
|
},
|
||||||
|
"Title": {
|
||||||
|
"content": "asdas",
|
||||||
|
"datetime": "00:25:30 Tue Apr 5 2022",
|
||||||
|
"title": "Title"
|
||||||
|
},
|
||||||
|
"blogtitle3": {
|
||||||
|
"content": "blogtitle3",
|
||||||
|
"datetime": "00:25:37 Tue Apr 5 2022",
|
||||||
|
"title": "blogtitle3"
|
||||||
|
},
|
||||||
|
"title": {
|
||||||
|
"content": "blogentry2",
|
||||||
|
"datetime": "00:24:53 Tue Apr 5 2022",
|
||||||
|
"title": "blogtitle2"
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -22,17 +22,28 @@ QT_BEGIN_MOC_NAMESPACE
|
|||||||
QT_WARNING_PUSH
|
QT_WARNING_PUSH
|
||||||
QT_WARNING_DISABLE_DEPRECATED
|
QT_WARNING_DISABLE_DEPRECATED
|
||||||
struct qt_meta_stringdata_blogEntry_t {
|
struct qt_meta_stringdata_blogEntry_t {
|
||||||
const uint offsetsAndSize[2];
|
const uint offsetsAndSize[20];
|
||||||
char stringdata0[10];
|
char stringdata0[98];
|
||||||
};
|
};
|
||||||
#define QT_MOC_LITERAL(ofs, len) \
|
#define QT_MOC_LITERAL(ofs, len) \
|
||||||
uint(offsetof(qt_meta_stringdata_blogEntry_t, stringdata0) + ofs), len
|
uint(offsetof(qt_meta_stringdata_blogEntry_t, stringdata0) + ofs), len
|
||||||
static const qt_meta_stringdata_blogEntry_t qt_meta_stringdata_blogEntry = {
|
static const qt_meta_stringdata_blogEntry_t qt_meta_stringdata_blogEntry = {
|
||||||
{
|
{
|
||||||
QT_MOC_LITERAL(0, 9) // "blogEntry"
|
QT_MOC_LITERAL(0, 9), // "blogEntry"
|
||||||
|
QT_MOC_LITERAL(10, 20), // "on_saveEntry_clicked"
|
||||||
|
QT_MOC_LITERAL(31, 0), // ""
|
||||||
|
QT_MOC_LITERAL(32, 9), // "saveEntry"
|
||||||
|
QT_MOC_LITERAL(42, 12), // "readJsonFile"
|
||||||
|
QT_MOC_LITERAL(55, 5), // "title"
|
||||||
|
QT_MOC_LITERAL(61, 12), // "saveJsonFile"
|
||||||
|
QT_MOC_LITERAL(74, 12), // "QJsonObject&"
|
||||||
|
QT_MOC_LITERAL(87, 5), // "users"
|
||||||
|
QT_MOC_LITERAL(93, 4) // "name"
|
||||||
|
|
||||||
},
|
},
|
||||||
"blogEntry"
|
"blogEntry\0on_saveEntry_clicked\0\0"
|
||||||
|
"saveEntry\0readJsonFile\0title\0saveJsonFile\0"
|
||||||
|
"QJsonObject&\0users\0name"
|
||||||
};
|
};
|
||||||
#undef QT_MOC_LITERAL
|
#undef QT_MOC_LITERAL
|
||||||
|
|
||||||
@ -42,22 +53,42 @@ static const uint qt_meta_data_blogEntry[] = {
|
|||||||
10, // revision
|
10, // revision
|
||||||
0, // classname
|
0, // classname
|
||||||
0, 0, // classinfo
|
0, 0, // classinfo
|
||||||
0, 0, // methods
|
4, 14, // methods
|
||||||
0, 0, // properties
|
0, 0, // properties
|
||||||
0, 0, // enums/sets
|
0, 0, // enums/sets
|
||||||
0, 0, // constructors
|
0, 0, // constructors
|
||||||
0, // flags
|
0, // flags
|
||||||
0, // signalCount
|
0, // signalCount
|
||||||
|
|
||||||
|
// slots: name, argc, parameters, tag, flags, initial metatype offsets
|
||||||
|
1, 0, 38, 2, 0x08, 1 /* Private */,
|
||||||
|
3, 0, 39, 2, 0x08, 2 /* Private */,
|
||||||
|
4, 1, 40, 2, 0x08, 3 /* Private */,
|
||||||
|
6, 2, 43, 2, 0x108, 5 /* Private | MethodIsConst */,
|
||||||
|
|
||||||
|
// slots: parameters
|
||||||
|
QMetaType::Void,
|
||||||
|
QMetaType::Void,
|
||||||
|
QMetaType::QJsonObject, QMetaType::QString, 5,
|
||||||
|
QMetaType::Void, 0x80000000 | 7, QMetaType::QString, 8, 9,
|
||||||
|
|
||||||
0 // eod
|
0 // eod
|
||||||
};
|
};
|
||||||
|
|
||||||
void blogEntry::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
|
void blogEntry::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
|
||||||
{
|
{
|
||||||
(void)_o;
|
if (_c == QMetaObject::InvokeMetaMethod) {
|
||||||
(void)_id;
|
auto *_t = static_cast<blogEntry *>(_o);
|
||||||
(void)_c;
|
(void)_t;
|
||||||
(void)_a;
|
switch (_id) {
|
||||||
|
case 0: _t->on_saveEntry_clicked(); break;
|
||||||
|
case 1: _t->saveEntry(); break;
|
||||||
|
case 2: { QJsonObject _r = _t->readJsonFile((*reinterpret_cast< std::add_pointer_t<QString>>(_a[1])));
|
||||||
|
if (_a[0]) *reinterpret_cast< QJsonObject*>(_a[0]) = std::move(_r); } break;
|
||||||
|
case 3: _t->saveJsonFile((*reinterpret_cast< std::add_pointer_t<QJsonObject&>>(_a[1])),(*reinterpret_cast< std::add_pointer_t<QString>>(_a[2]))); break;
|
||||||
|
default: ;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const QMetaObject blogEntry::staticMetaObject = { {
|
const QMetaObject blogEntry::staticMetaObject = { {
|
||||||
@ -68,7 +99,7 @@ const QMetaObject blogEntry::staticMetaObject = { {
|
|||||||
nullptr,
|
nullptr,
|
||||||
qt_incomplete_metaTypeArray<qt_meta_stringdata_blogEntry_t
|
qt_incomplete_metaTypeArray<qt_meta_stringdata_blogEntry_t
|
||||||
, QtPrivate::TypeAndForceComplete<blogEntry, std::true_type>
|
, QtPrivate::TypeAndForceComplete<blogEntry, std::true_type>
|
||||||
|
, QtPrivate::TypeAndForceComplete<void, std::false_type>, QtPrivate::TypeAndForceComplete<void, std::false_type>, QtPrivate::TypeAndForceComplete<QJsonObject, std::false_type>, QtPrivate::TypeAndForceComplete<const QString, std::false_type>, QtPrivate::TypeAndForceComplete<void, std::false_type>, QtPrivate::TypeAndForceComplete<QJsonObject &, std::false_type>, QtPrivate::TypeAndForceComplete<const QString, std::false_type>
|
||||||
|
|
||||||
|
|
||||||
>,
|
>,
|
||||||
@ -92,6 +123,17 @@ void *blogEntry::qt_metacast(const char *_clname)
|
|||||||
int blogEntry::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
int blogEntry::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
||||||
{
|
{
|
||||||
_id = QWidget::qt_metacall(_c, _id, _a);
|
_id = QWidget::qt_metacall(_c, _id, _a);
|
||||||
|
if (_id < 0)
|
||||||
|
return _id;
|
||||||
|
if (_c == QMetaObject::InvokeMetaMethod) {
|
||||||
|
if (_id < 4)
|
||||||
|
qt_static_metacall(this, _c, _id, _a);
|
||||||
|
_id -= 4;
|
||||||
|
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
|
||||||
|
if (_id < 4)
|
||||||
|
*reinterpret_cast<QMetaType *>(_a[0]) = QMetaType();
|
||||||
|
_id -= 4;
|
||||||
|
}
|
||||||
return _id;
|
return _id;
|
||||||
}
|
}
|
||||||
QT_WARNING_POP
|
QT_WARNING_POP
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -22,8 +22,8 @@ QT_BEGIN_MOC_NAMESPACE
|
|||||||
QT_WARNING_PUSH
|
QT_WARNING_PUSH
|
||||||
QT_WARNING_DISABLE_DEPRECATED
|
QT_WARNING_DISABLE_DEPRECATED
|
||||||
struct qt_meta_stringdata_MainWindow_t {
|
struct qt_meta_stringdata_MainWindow_t {
|
||||||
const uint offsetsAndSize[24];
|
const uint offsetsAndSize[32];
|
||||||
char stringdata0[163];
|
char stringdata0[194];
|
||||||
};
|
};
|
||||||
#define QT_MOC_LITERAL(ofs, len) \
|
#define QT_MOC_LITERAL(ofs, len) \
|
||||||
uint(offsetof(qt_meta_stringdata_MainWindow_t, stringdata0) + ofs), len
|
uint(offsetof(qt_meta_stringdata_MainWindow_t, stringdata0) + ofs), len
|
||||||
@ -34,20 +34,25 @@ QT_MOC_LITERAL(11, 18), // "saveRegisteredUser"
|
|||||||
QT_MOC_LITERAL(30, 0), // ""
|
QT_MOC_LITERAL(30, 0), // ""
|
||||||
QT_MOC_LITERAL(31, 12), // "QJsonObject&"
|
QT_MOC_LITERAL(31, 12), // "QJsonObject&"
|
||||||
QT_MOC_LITERAL(44, 5), // "users"
|
QT_MOC_LITERAL(44, 5), // "users"
|
||||||
QT_MOC_LITERAL(50, 21), // "on_pushButton_clicked"
|
QT_MOC_LITERAL(50, 5), // "blogs"
|
||||||
QT_MOC_LITERAL(72, 12), // "saveJsonFile"
|
QT_MOC_LITERAL(56, 21), // "on_pushButton_clicked"
|
||||||
QT_MOC_LITERAL(85, 16), // "readUserJsonFile"
|
QT_MOC_LITERAL(78, 12), // "saveJsonFile"
|
||||||
QT_MOC_LITERAL(102, 13), // "thisIdIsTaken"
|
QT_MOC_LITERAL(91, 4), // "name"
|
||||||
QT_MOC_LITERAL(116, 13), // "thisIdIsEmpty"
|
QT_MOC_LITERAL(96, 12), // "readJsonFile"
|
||||||
QT_MOC_LITERAL(130, 22), // "on_loginButton_clicked"
|
QT_MOC_LITERAL(109, 5), // "title"
|
||||||
QT_MOC_LITERAL(153, 9) // "goToLogin"
|
QT_MOC_LITERAL(115, 13), // "thisIdIsTaken"
|
||||||
|
QT_MOC_LITERAL(129, 13), // "thisIdIsEmpty"
|
||||||
|
QT_MOC_LITERAL(143, 17), // "thisBlogIdIsTaken"
|
||||||
|
QT_MOC_LITERAL(161, 22), // "on_loginButton_clicked"
|
||||||
|
QT_MOC_LITERAL(184, 9) // "goToLogin"
|
||||||
|
|
||||||
},
|
},
|
||||||
"MainWindow\0saveRegisteredUser\0\0"
|
"MainWindow\0saveRegisteredUser\0\0"
|
||||||
"QJsonObject&\0users\0on_pushButton_clicked\0"
|
"QJsonObject&\0users\0blogs\0on_pushButton_clicked\0"
|
||||||
"saveJsonFile\0readUserJsonFile\0"
|
"saveJsonFile\0name\0readJsonFile\0title\0"
|
||||||
"thisIdIsTaken\0thisIdIsEmpty\0"
|
"thisIdIsTaken\0thisIdIsEmpty\0"
|
||||||
"on_loginButton_clicked\0goToLogin"
|
"thisBlogIdIsTaken\0on_loginButton_clicked\0"
|
||||||
|
"goToLogin"
|
||||||
};
|
};
|
||||||
#undef QT_MOC_LITERAL
|
#undef QT_MOC_LITERAL
|
||||||
|
|
||||||
@ -57,7 +62,7 @@ static const uint qt_meta_data_MainWindow[] = {
|
|||||||
10, // revision
|
10, // revision
|
||||||
0, // classname
|
0, // classname
|
||||||
0, 0, // classinfo
|
0, 0, // classinfo
|
||||||
8, 14, // methods
|
9, 14, // methods
|
||||||
0, 0, // properties
|
0, 0, // properties
|
||||||
0, 0, // enums/sets
|
0, 0, // enums/sets
|
||||||
0, 0, // constructors
|
0, 0, // constructors
|
||||||
@ -65,20 +70,22 @@ static const uint qt_meta_data_MainWindow[] = {
|
|||||||
0, // signalCount
|
0, // signalCount
|
||||||
|
|
||||||
// slots: name, argc, parameters, tag, flags, initial metatype offsets
|
// slots: name, argc, parameters, tag, flags, initial metatype offsets
|
||||||
1, 1, 62, 2, 0x108, 1 /* Private | MethodIsConst */,
|
1, 2, 68, 2, 0x108, 1 /* Private | MethodIsConst */,
|
||||||
5, 0, 65, 2, 0x08, 3 /* Private */,
|
6, 0, 73, 2, 0x08, 4 /* Private */,
|
||||||
6, 1, 66, 2, 0x108, 4 /* Private | MethodIsConst */,
|
7, 2, 74, 2, 0x108, 5 /* Private | MethodIsConst */,
|
||||||
7, 0, 69, 2, 0x08, 6 /* Private */,
|
9, 1, 79, 2, 0x08, 8 /* Private */,
|
||||||
8, 0, 70, 2, 0x108, 7 /* Private | MethodIsConst */,
|
11, 0, 82, 2, 0x108, 10 /* Private | MethodIsConst */,
|
||||||
9, 0, 71, 2, 0x108, 8 /* Private | MethodIsConst */,
|
12, 0, 83, 2, 0x108, 11 /* Private | MethodIsConst */,
|
||||||
10, 0, 72, 2, 0x08, 9 /* Private */,
|
13, 0, 84, 2, 0x108, 12 /* Private | MethodIsConst */,
|
||||||
11, 0, 73, 2, 0x08, 10 /* Private */,
|
14, 0, 85, 2, 0x08, 13 /* Private */,
|
||||||
|
15, 0, 86, 2, 0x08, 14 /* Private */,
|
||||||
|
|
||||||
// slots: parameters
|
// slots: parameters
|
||||||
QMetaType::Void, 0x80000000 | 3, 4,
|
QMetaType::Void, 0x80000000 | 3, 0x80000000 | 3, 4, 5,
|
||||||
|
QMetaType::Void,
|
||||||
|
QMetaType::Void, 0x80000000 | 3, QMetaType::QString, 4, 8,
|
||||||
|
QMetaType::QJsonObject, QMetaType::QString, 10,
|
||||||
QMetaType::Void,
|
QMetaType::Void,
|
||||||
QMetaType::Void, 0x80000000 | 3, 4,
|
|
||||||
QMetaType::QJsonObject,
|
|
||||||
QMetaType::Void,
|
QMetaType::Void,
|
||||||
QMetaType::Void,
|
QMetaType::Void,
|
||||||
QMetaType::Void,
|
QMetaType::Void,
|
||||||
@ -93,15 +100,16 @@ void MainWindow::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id,
|
|||||||
auto *_t = static_cast<MainWindow *>(_o);
|
auto *_t = static_cast<MainWindow *>(_o);
|
||||||
(void)_t;
|
(void)_t;
|
||||||
switch (_id) {
|
switch (_id) {
|
||||||
case 0: _t->saveRegisteredUser((*reinterpret_cast< std::add_pointer_t<QJsonObject&>>(_a[1]))); break;
|
case 0: _t->saveRegisteredUser((*reinterpret_cast< std::add_pointer_t<QJsonObject&>>(_a[1])),(*reinterpret_cast< std::add_pointer_t<QJsonObject&>>(_a[2]))); break;
|
||||||
case 1: _t->on_pushButton_clicked(); break;
|
case 1: _t->on_pushButton_clicked(); break;
|
||||||
case 2: _t->saveJsonFile((*reinterpret_cast< std::add_pointer_t<QJsonObject&>>(_a[1]))); break;
|
case 2: _t->saveJsonFile((*reinterpret_cast< std::add_pointer_t<QJsonObject&>>(_a[1])),(*reinterpret_cast< std::add_pointer_t<QString>>(_a[2]))); break;
|
||||||
case 3: { QJsonObject _r = _t->readUserJsonFile();
|
case 3: { QJsonObject _r = _t->readJsonFile((*reinterpret_cast< std::add_pointer_t<QString>>(_a[1])));
|
||||||
if (_a[0]) *reinterpret_cast< QJsonObject*>(_a[0]) = std::move(_r); } break;
|
if (_a[0]) *reinterpret_cast< QJsonObject*>(_a[0]) = std::move(_r); } break;
|
||||||
case 4: _t->thisIdIsTaken(); break;
|
case 4: _t->thisIdIsTaken(); break;
|
||||||
case 5: _t->thisIdIsEmpty(); break;
|
case 5: _t->thisIdIsEmpty(); break;
|
||||||
case 6: _t->on_loginButton_clicked(); break;
|
case 6: _t->thisBlogIdIsTaken(); break;
|
||||||
case 7: _t->goToLogin(); break;
|
case 7: _t->on_loginButton_clicked(); break;
|
||||||
|
case 8: _t->goToLogin(); break;
|
||||||
default: ;
|
default: ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,7 +123,7 @@ const QMetaObject MainWindow::staticMetaObject = { {
|
|||||||
nullptr,
|
nullptr,
|
||||||
qt_incomplete_metaTypeArray<qt_meta_stringdata_MainWindow_t
|
qt_incomplete_metaTypeArray<qt_meta_stringdata_MainWindow_t
|
||||||
, QtPrivate::TypeAndForceComplete<MainWindow, std::true_type>
|
, QtPrivate::TypeAndForceComplete<MainWindow, std::true_type>
|
||||||
, QtPrivate::TypeAndForceComplete<void, std::false_type>, QtPrivate::TypeAndForceComplete<QJsonObject &, std::false_type>, QtPrivate::TypeAndForceComplete<void, std::false_type>, QtPrivate::TypeAndForceComplete<void, std::false_type>, QtPrivate::TypeAndForceComplete<QJsonObject &, std::false_type>, QtPrivate::TypeAndForceComplete<QJsonObject, std::false_type>, QtPrivate::TypeAndForceComplete<void, std::false_type>, QtPrivate::TypeAndForceComplete<void, std::false_type>, QtPrivate::TypeAndForceComplete<void, std::false_type>, QtPrivate::TypeAndForceComplete<void, std::false_type>
|
, QtPrivate::TypeAndForceComplete<void, std::false_type>, QtPrivate::TypeAndForceComplete<QJsonObject &, std::false_type>, QtPrivate::TypeAndForceComplete<QJsonObject &, std::false_type>, QtPrivate::TypeAndForceComplete<void, std::false_type>, QtPrivate::TypeAndForceComplete<void, std::false_type>, QtPrivate::TypeAndForceComplete<QJsonObject &, std::false_type>, QtPrivate::TypeAndForceComplete<const QString, std::false_type>, QtPrivate::TypeAndForceComplete<QJsonObject, std::false_type>, QtPrivate::TypeAndForceComplete<const QString, std::false_type>, QtPrivate::TypeAndForceComplete<void, std::false_type>, QtPrivate::TypeAndForceComplete<void, std::false_type>, QtPrivate::TypeAndForceComplete<void, std::false_type>, QtPrivate::TypeAndForceComplete<void, std::false_type>, QtPrivate::TypeAndForceComplete<void, std::false_type>
|
||||||
|
|
||||||
|
|
||||||
>,
|
>,
|
||||||
@ -142,13 +150,13 @@ int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
|||||||
if (_id < 0)
|
if (_id < 0)
|
||||||
return _id;
|
return _id;
|
||||||
if (_c == QMetaObject::InvokeMetaMethod) {
|
if (_c == QMetaObject::InvokeMetaMethod) {
|
||||||
if (_id < 8)
|
if (_id < 9)
|
||||||
qt_static_metacall(this, _c, _id, _a);
|
qt_static_metacall(this, _c, _id, _a);
|
||||||
_id -= 8;
|
_id -= 9;
|
||||||
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
|
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
|
||||||
if (_id < 8)
|
if (_id < 9)
|
||||||
*reinterpret_cast<QMetaType *>(_a[0]) = QMetaType();
|
*reinterpret_cast<QMetaType *>(_a[0]) = QMetaType();
|
||||||
_id -= 8;
|
_id -= 9;
|
||||||
}
|
}
|
||||||
return _id;
|
return _id;
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@ -15,6 +15,7 @@
|
|||||||
#include <QtWidgets/QFormLayout>
|
#include <QtWidgets/QFormLayout>
|
||||||
#include <QtWidgets/QLabel>
|
#include <QtWidgets/QLabel>
|
||||||
#include <QtWidgets/QLineEdit>
|
#include <QtWidgets/QLineEdit>
|
||||||
|
#include <QtWidgets/QPushButton>
|
||||||
#include <QtWidgets/QTextEdit>
|
#include <QtWidgets/QTextEdit>
|
||||||
#include <QtWidgets/QWidget>
|
#include <QtWidgets/QWidget>
|
||||||
|
|
||||||
@ -29,6 +30,7 @@ public:
|
|||||||
QLabel *ownerID;
|
QLabel *ownerID;
|
||||||
QLabel *dateTime;
|
QLabel *dateTime;
|
||||||
QTextEdit *textEdit;
|
QTextEdit *textEdit;
|
||||||
|
QPushButton *saveEntry;
|
||||||
|
|
||||||
void setupUi(QWidget *blogEntry)
|
void setupUi(QWidget *blogEntry)
|
||||||
{
|
{
|
||||||
@ -59,9 +61,15 @@ public:
|
|||||||
|
|
||||||
textEdit = new QTextEdit(blogEntry);
|
textEdit = new QTextEdit(blogEntry);
|
||||||
textEdit->setObjectName(QString::fromUtf8("textEdit"));
|
textEdit->setObjectName(QString::fromUtf8("textEdit"));
|
||||||
|
textEdit->setReadOnly(false);
|
||||||
|
|
||||||
formLayout->setWidget(4, QFormLayout::FieldRole, textEdit);
|
formLayout->setWidget(4, QFormLayout::FieldRole, textEdit);
|
||||||
|
|
||||||
|
saveEntry = new QPushButton(blogEntry);
|
||||||
|
saveEntry->setObjectName(QString::fromUtf8("saveEntry"));
|
||||||
|
|
||||||
|
formLayout->setWidget(5, QFormLayout::FieldRole, saveEntry);
|
||||||
|
|
||||||
|
|
||||||
retranslateUi(blogEntry);
|
retranslateUi(blogEntry);
|
||||||
|
|
||||||
@ -75,6 +83,7 @@ public:
|
|||||||
lineEdit->setText(QCoreApplication::translate("blogEntry", "Title", nullptr));
|
lineEdit->setText(QCoreApplication::translate("blogEntry", "Title", nullptr));
|
||||||
ownerID->setText(QCoreApplication::translate("blogEntry", "ownerID", nullptr));
|
ownerID->setText(QCoreApplication::translate("blogEntry", "ownerID", nullptr));
|
||||||
dateTime->setText(QCoreApplication::translate("blogEntry", "Date Time", nullptr));
|
dateTime->setText(QCoreApplication::translate("blogEntry", "Date Time", nullptr));
|
||||||
|
saveEntry->setText(QCoreApplication::translate("blogEntry", "Save Entry", nullptr));
|
||||||
} // retranslateUi
|
} // retranslateUi
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -35,6 +35,10 @@ public:
|
|||||||
QLabel *label_2;
|
QLabel *label_2;
|
||||||
QLabel *label_4;
|
QLabel *label_4;
|
||||||
QPushButton *loginButton;
|
QPushButton *loginButton;
|
||||||
|
QLabel *label_5;
|
||||||
|
QLineEdit *inputBlogTitle;
|
||||||
|
QLineEdit *inputBlogID;
|
||||||
|
QLabel *label_6;
|
||||||
QMenuBar *menubar;
|
QMenuBar *menubar;
|
||||||
|
|
||||||
void setupUi(QMainWindow *MainWindow)
|
void setupUi(QMainWindow *MainWindow)
|
||||||
@ -54,43 +58,63 @@ public:
|
|||||||
inputId = new QLineEdit(centralwidget);
|
inputId = new QLineEdit(centralwidget);
|
||||||
inputId->setObjectName(QString::fromUtf8("inputId"));
|
inputId->setObjectName(QString::fromUtf8("inputId"));
|
||||||
|
|
||||||
formLayout->setWidget(3, QFormLayout::SpanningRole, inputId);
|
formLayout->setWidget(6, QFormLayout::SpanningRole, inputId);
|
||||||
|
|
||||||
inputMail = new QLineEdit(centralwidget);
|
inputMail = new QLineEdit(centralwidget);
|
||||||
inputMail->setObjectName(QString::fromUtf8("inputMail"));
|
inputMail->setObjectName(QString::fromUtf8("inputMail"));
|
||||||
|
|
||||||
formLayout->setWidget(5, QFormLayout::SpanningRole, inputMail);
|
formLayout->setWidget(8, QFormLayout::SpanningRole, inputMail);
|
||||||
|
|
||||||
label_3 = new QLabel(centralwidget);
|
label_3 = new QLabel(centralwidget);
|
||||||
label_3->setObjectName(QString::fromUtf8("label_3"));
|
label_3->setObjectName(QString::fromUtf8("label_3"));
|
||||||
|
|
||||||
formLayout->setWidget(6, QFormLayout::SpanningRole, label_3);
|
formLayout->setWidget(9, QFormLayout::SpanningRole, label_3);
|
||||||
|
|
||||||
inputPassword = new QLineEdit(centralwidget);
|
inputPassword = new QLineEdit(centralwidget);
|
||||||
inputPassword->setObjectName(QString::fromUtf8("inputPassword"));
|
inputPassword->setObjectName(QString::fromUtf8("inputPassword"));
|
||||||
inputPassword->setEchoMode(QLineEdit::Password);
|
inputPassword->setEchoMode(QLineEdit::Password);
|
||||||
|
|
||||||
formLayout->setWidget(7, QFormLayout::SpanningRole, inputPassword);
|
formLayout->setWidget(10, QFormLayout::SpanningRole, inputPassword);
|
||||||
|
|
||||||
pushButton = new QPushButton(centralwidget);
|
pushButton = new QPushButton(centralwidget);
|
||||||
pushButton->setObjectName(QString::fromUtf8("pushButton"));
|
pushButton->setObjectName(QString::fromUtf8("pushButton"));
|
||||||
|
|
||||||
formLayout->setWidget(8, QFormLayout::SpanningRole, pushButton);
|
formLayout->setWidget(11, QFormLayout::SpanningRole, pushButton);
|
||||||
|
|
||||||
label_2 = new QLabel(centralwidget);
|
label_2 = new QLabel(centralwidget);
|
||||||
label_2->setObjectName(QString::fromUtf8("label_2"));
|
label_2->setObjectName(QString::fromUtf8("label_2"));
|
||||||
|
|
||||||
formLayout->setWidget(4, QFormLayout::SpanningRole, label_2);
|
formLayout->setWidget(7, QFormLayout::SpanningRole, label_2);
|
||||||
|
|
||||||
label_4 = new QLabel(centralwidget);
|
label_4 = new QLabel(centralwidget);
|
||||||
label_4->setObjectName(QString::fromUtf8("label_4"));
|
label_4->setObjectName(QString::fromUtf8("label_4"));
|
||||||
|
|
||||||
formLayout->setWidget(2, QFormLayout::SpanningRole, label_4);
|
formLayout->setWidget(5, QFormLayout::SpanningRole, label_4);
|
||||||
|
|
||||||
loginButton = new QPushButton(centralwidget);
|
loginButton = new QPushButton(centralwidget);
|
||||||
loginButton->setObjectName(QString::fromUtf8("loginButton"));
|
loginButton->setObjectName(QString::fromUtf8("loginButton"));
|
||||||
|
|
||||||
formLayout->setWidget(9, QFormLayout::SpanningRole, loginButton);
|
formLayout->setWidget(12, QFormLayout::SpanningRole, loginButton);
|
||||||
|
|
||||||
|
label_5 = new QLabel(centralwidget);
|
||||||
|
label_5->setObjectName(QString::fromUtf8("label_5"));
|
||||||
|
|
||||||
|
formLayout->setWidget(3, QFormLayout::FieldRole, label_5);
|
||||||
|
|
||||||
|
inputBlogTitle = new QLineEdit(centralwidget);
|
||||||
|
inputBlogTitle->setObjectName(QString::fromUtf8("inputBlogTitle"));
|
||||||
|
|
||||||
|
formLayout->setWidget(4, QFormLayout::SpanningRole, inputBlogTitle);
|
||||||
|
|
||||||
|
inputBlogID = new QLineEdit(centralwidget);
|
||||||
|
inputBlogID->setObjectName(QString::fromUtf8("inputBlogID"));
|
||||||
|
|
||||||
|
formLayout->setWidget(2, QFormLayout::FieldRole, inputBlogID);
|
||||||
|
|
||||||
|
label_6 = new QLabel(centralwidget);
|
||||||
|
label_6->setObjectName(QString::fromUtf8("label_6"));
|
||||||
|
|
||||||
|
formLayout->setWidget(1, QFormLayout::FieldRole, label_6);
|
||||||
|
|
||||||
MainWindow->setCentralWidget(centralwidget);
|
MainWindow->setCentralWidget(centralwidget);
|
||||||
menubar = new QMenuBar(MainWindow);
|
menubar = new QMenuBar(MainWindow);
|
||||||
@ -106,14 +130,14 @@ public:
|
|||||||
void retranslateUi(QMainWindow *MainWindow)
|
void retranslateUi(QMainWindow *MainWindow)
|
||||||
{
|
{
|
||||||
MainWindow->setWindowTitle(QCoreApplication::translate("MainWindow", "MainWindow", nullptr));
|
MainWindow->setWindowTitle(QCoreApplication::translate("MainWindow", "MainWindow", nullptr));
|
||||||
label->setText(QCoreApplication::translate("MainWindow", "<html><head/><body><p align=\"center\"><span style=\" font-size:72pt;\">Register</span></p></body></html>", nullptr));
|
label->setText(QCoreApplication::translate("MainWindow", "<html><head/><body><p align=\"center\"><span style=\" font-size:48pt;\">Register</span></p></body></html>", nullptr));
|
||||||
#if QT_CONFIG(tooltip)
|
#if QT_CONFIG(tooltip)
|
||||||
inputId->setToolTip(QCoreApplication::translate("MainWindow", "<html><head/><body><p align=\"center\"><span style=\" font-size:48pt;\">Input ID</span></p></body></html>", nullptr));
|
inputId->setToolTip(QCoreApplication::translate("MainWindow", "<html><head/><body><p align=\"center\"><span style=\" font-size:48pt;\">Input ID</span></p></body></html>", nullptr));
|
||||||
#endif // QT_CONFIG(tooltip)
|
#endif // QT_CONFIG(tooltip)
|
||||||
#if QT_CONFIG(tooltip)
|
#if QT_CONFIG(tooltip)
|
||||||
inputMail->setToolTip(QCoreApplication::translate("MainWindow", "<html><head/><body><p align=\"center\"><span style=\" font-size:48pt;\">Input Mail</span></p></body></html>", nullptr));
|
inputMail->setToolTip(QCoreApplication::translate("MainWindow", "<html><head/><body><p align=\"center\"><span style=\" font-size:48pt;\">Input Mail</span></p></body></html>", nullptr));
|
||||||
#endif // QT_CONFIG(tooltip)
|
#endif // QT_CONFIG(tooltip)
|
||||||
label_3->setText(QCoreApplication::translate("MainWindow", "<html><head/><body><p align=\"center\"><span style=\" font-size:36pt;\">Password</span></p></body></html>", nullptr));
|
label_3->setText(QCoreApplication::translate("MainWindow", "<html><head/><body><p align=\"center\"><span style=\" font-size:28pt;\">Password</span></p></body></html>", nullptr));
|
||||||
#if QT_CONFIG(tooltip)
|
#if QT_CONFIG(tooltip)
|
||||||
inputPassword->setToolTip(QCoreApplication::translate("MainWindow", "<html><head/><body><p align=\"center\"><span style=\" font-size:48pt;\">Input Password</span></p></body></html>", nullptr));
|
inputPassword->setToolTip(QCoreApplication::translate("MainWindow", "<html><head/><body><p align=\"center\"><span style=\" font-size:48pt;\">Input Password</span></p></body></html>", nullptr));
|
||||||
#endif // QT_CONFIG(tooltip)
|
#endif // QT_CONFIG(tooltip)
|
||||||
@ -125,9 +149,11 @@ public:
|
|||||||
pushButton->setToolTip(QCoreApplication::translate("MainWindow", "<html><head/><body><p><span style=\" font-size:72pt;\">Register</span></p><p><br/></p></body></html>", nullptr));
|
pushButton->setToolTip(QCoreApplication::translate("MainWindow", "<html><head/><body><p><span style=\" font-size:72pt;\">Register</span></p><p><br/></p></body></html>", nullptr));
|
||||||
#endif // QT_CONFIG(tooltip)
|
#endif // QT_CONFIG(tooltip)
|
||||||
pushButton->setText(QCoreApplication::translate("MainWindow", "Register", nullptr));
|
pushButton->setText(QCoreApplication::translate("MainWindow", "Register", nullptr));
|
||||||
label_2->setText(QCoreApplication::translate("MainWindow", "<html><head/><body><p align=\"center\"><span style=\" font-size:36pt;\">Mail</span></p></body></html>", nullptr));
|
label_2->setText(QCoreApplication::translate("MainWindow", "<html><head/><body><p align=\"center\"><span style=\" font-size:28pt;\">Mail</span></p></body></html>", nullptr));
|
||||||
label_4->setText(QCoreApplication::translate("MainWindow", "<html><head/><body><p align=\"center\"><span style=\" font-size:36pt;\">ID</span></p></body></html>", nullptr));
|
label_4->setText(QCoreApplication::translate("MainWindow", "<html><head/><body><p align=\"center\"><span style=\" font-size:28pt;\">ID</span></p></body></html>", nullptr));
|
||||||
loginButton->setText(QCoreApplication::translate("MainWindow", "Already Registered? Click here to Login!", nullptr));
|
loginButton->setText(QCoreApplication::translate("MainWindow", "Already Registered? Click here to Login!", nullptr));
|
||||||
|
label_5->setText(QCoreApplication::translate("MainWindow", "<html><head/><body><p align=\"center\"><span style=\" font-size:28pt;\">Blog Title</span></p></body></html>", nullptr));
|
||||||
|
label_6->setText(QCoreApplication::translate("MainWindow", "<html><head/><body><p align=\"center\"><span style=\" font-size:28pt;\">Blog ID</span></p></body></html>", nullptr));
|
||||||
} // retranslateUi
|
} // retranslateUi
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -13,5 +13,20 @@
|
|||||||
"id": "2",
|
"id": "2",
|
||||||
"mail": "",
|
"mail": "",
|
||||||
"password": ""
|
"password": ""
|
||||||
|
},
|
||||||
|
"5": {
|
||||||
|
"email": "5",
|
||||||
|
"password": "",
|
||||||
|
"userId": "5"
|
||||||
|
},
|
||||||
|
"6": {
|
||||||
|
"email": "5",
|
||||||
|
"password": "",
|
||||||
|
"userId": "6"
|
||||||
|
},
|
||||||
|
"7": {
|
||||||
|
"email": "5",
|
||||||
|
"password": "5",
|
||||||
|
"userId": "7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
#include "blogentry.h"
|
#include "blogentry.h"
|
||||||
#include "ui_blogentry.h"
|
#include "ui_blogentry.h"
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
|
||||||
blogEntry::blogEntry(QWidget *parent) :
|
blogEntry::blogEntry(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
@ -10,6 +13,8 @@ blogEntry::blogEntry(QWidget *parent) :
|
|||||||
QString Time = QTime::currentTime().toString();
|
QString Time = QTime::currentTime().toString();
|
||||||
QString Date = QDate::currentDate().toString();
|
QString Date = QDate::currentDate().toString();
|
||||||
ui -> dateTime -> setText(Date + " " + Time);
|
ui -> dateTime -> setText(Date + " " + Time);
|
||||||
|
|
||||||
|
qDebug() << "blogEntry id: " << userId;
|
||||||
qDebug() << Time;
|
qDebug() << Time;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,3 +22,61 @@ blogEntry::~blogEntry()
|
|||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void blogEntry::setUserId(const QString &userId)
|
||||||
|
{
|
||||||
|
qDebug() << "blogEntry id: " << userId;
|
||||||
|
this->userId = userId;
|
||||||
|
ui -> ownerID -> setText("Owner ID: " + userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject blogEntry::readJsonFile(const QString title)
|
||||||
|
{
|
||||||
|
QFile file(title);
|
||||||
|
file.open( QIODevice::ReadOnly);
|
||||||
|
QByteArray bytes = file.readAll();
|
||||||
|
file.close();
|
||||||
|
QJsonDocument document = QJsonDocument::fromJson( bytes );
|
||||||
|
return document.object();
|
||||||
|
}
|
||||||
|
|
||||||
|
void blogEntry::saveJsonFile(QJsonObject &users, const QString name) const
|
||||||
|
{
|
||||||
|
QFile jsonFile(name);
|
||||||
|
QJsonDocument document;
|
||||||
|
document.setObject( users );
|
||||||
|
QByteArray bytes = document.toJson( QJsonDocument::Indented );
|
||||||
|
jsonFile.open( QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate );
|
||||||
|
QTextStream iStream( &jsonFile );
|
||||||
|
// iStream.setCodec( "utf-8" );
|
||||||
|
iStream << bytes;
|
||||||
|
jsonFile.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void blogEntry::saveEntry()
|
||||||
|
{
|
||||||
|
|
||||||
|
ui -> textEdit -> setReadOnly(true);
|
||||||
|
ui -> lineEdit -> setReadOnly(true);
|
||||||
|
QJsonObject blogEntry;
|
||||||
|
blogEntry["content"] = ui -> textEdit -> toPlainText();
|
||||||
|
QString Time = QTime::currentTime().toString();
|
||||||
|
QString Date = QDate::currentDate().toString();
|
||||||
|
blogEntry["datetime"] = Time + " " + Date;
|
||||||
|
blogEntry["title"] = ui -> lineEdit -> text();
|
||||||
|
QJsonObject blogsFile = readJsonFile("blogs.json");
|
||||||
|
QJsonObject blogEntryJson;
|
||||||
|
blogEntryJson["title"] = ui -> lineEdit -> text();
|
||||||
|
blogEntryJson["datetime"] = Time + " " + Date;
|
||||||
|
blogEntryJson["content"] = ui -> textEdit -> toPlainText();
|
||||||
|
blogsFile.insert(ui -> lineEdit -> text(), blogEntryJson);
|
||||||
|
saveJsonFile(blogsFile, "blogs.json");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void blogEntry::on_saveEntry_clicked()
|
||||||
|
{
|
||||||
|
saveEntry();
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,9 @@
|
|||||||
#define BLOGENTRY_H
|
#define BLOGENTRY_H
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class blogEntry;
|
class blogEntry;
|
||||||
@ -14,9 +17,16 @@ class blogEntry : public QWidget
|
|||||||
public:
|
public:
|
||||||
explicit blogEntry(QWidget *parent = nullptr);
|
explicit blogEntry(QWidget *parent = nullptr);
|
||||||
~blogEntry();
|
~blogEntry();
|
||||||
|
void setUserId(const QString &userId);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_saveEntry_clicked();
|
||||||
|
void saveEntry();
|
||||||
|
QJsonObject readJsonFile(const QString title);
|
||||||
|
void saveJsonFile(QJsonObject &users, const QString name) const;
|
||||||
private:
|
private:
|
||||||
Ui::blogEntry *ui;
|
Ui::blogEntry *ui;
|
||||||
|
QString userId;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BLOGENTRY_H
|
#endif // BLOGENTRY_H
|
||||||
|
|||||||
@ -43,7 +43,18 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1">
|
<item row="4" column="1">
|
||||||
<widget class="QTextEdit" name="textEdit"/>
|
<widget class="QTextEdit" name="textEdit">
|
||||||
|
<property name="readOnly">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="1">
|
||||||
|
<widget class="QPushButton" name="saveEntry">
|
||||||
|
<property name="text">
|
||||||
|
<string>Save Entry</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
@ -2,6 +2,9 @@
|
|||||||
#include "ui_blogsview.h"
|
#include "ui_blogsview.h"
|
||||||
#include "blogentry.h"
|
#include "blogentry.h"
|
||||||
#include "ui_blogentry.h"
|
#include "ui_blogentry.h"
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QFile>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
|
||||||
blogsView::blogsView(QWidget *parent) :
|
blogsView::blogsView(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
@ -15,9 +18,31 @@ blogsView::~blogsView()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void blogsView::setUserId(const QString &userId)
|
||||||
|
{
|
||||||
|
this->userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonObject blogsView::readJsonFile(const QString title)
|
||||||
|
{
|
||||||
|
QFile file(title);
|
||||||
|
file.open( QIODevice::ReadOnly);
|
||||||
|
QByteArray bytes = file.readAll();
|
||||||
|
file.close();
|
||||||
|
QJsonDocument document = QJsonDocument::fromJson( bytes );
|
||||||
|
return document.object();
|
||||||
|
}
|
||||||
|
|
||||||
void blogsView::createNewBlogEntry()
|
void blogsView::createNewBlogEntry()
|
||||||
{
|
{
|
||||||
|
QJsonObject blogsFile = readJsonFile("blogs.json");
|
||||||
|
QJsonObject blogEntryJson;
|
||||||
|
blogEntryJson["title"];
|
||||||
|
blogEntryJson["datetime"];
|
||||||
|
blogEntryJson["content"];
|
||||||
|
qDebug() << "blogsView id: " << userId;
|
||||||
blogEntry *e = new blogEntry();
|
blogEntry *e = new blogEntry();
|
||||||
|
e -> setUserId(userId);
|
||||||
ui -> blogsLayout -> addWidget(e);
|
ui -> blogsLayout -> addWidget(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -15,12 +15,16 @@ public:
|
|||||||
explicit blogsView(QWidget *parent = nullptr);
|
explicit blogsView(QWidget *parent = nullptr);
|
||||||
~blogsView();
|
~blogsView();
|
||||||
void createNewBlogEntry();
|
void createNewBlogEntry();
|
||||||
|
void setUserId(const QString &userId);
|
||||||
|
QJsonObject readJsonFile(const QString title);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_actionCreate_new_Blog_entry_triggered();
|
void on_actionCreate_new_Blog_entry_triggered();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::blogsView *ui;
|
Ui::blogsView *ui;
|
||||||
|
QString userId;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BLOGSVIEW_H
|
#endif // BLOGSVIEW_H
|
||||||
|
|||||||
@ -34,9 +34,11 @@ void login::wrongPassword()
|
|||||||
wrongPassword.exec();
|
wrongPassword.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void login::loginSuccessful()
|
void login::loginSuccessful(const QString &id)
|
||||||
{
|
{
|
||||||
|
qDebug() << "login id: " << id;
|
||||||
blogsView *b = new blogsView();
|
blogsView *b = new blogsView();
|
||||||
|
b -> setUserId(id);
|
||||||
b -> show();
|
b -> show();
|
||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
@ -51,7 +53,7 @@ void login::loginUser(QJsonObject &users)
|
|||||||
QString enteredPassword = ui->inputPassword->text();
|
QString enteredPassword = ui->inputPassword->text();
|
||||||
if (user["password"] == enteredPassword)
|
if (user["password"] == enteredPassword)
|
||||||
{
|
{
|
||||||
loginSuccessful();
|
loginSuccessful(id);
|
||||||
}else wrongPassword();
|
}else wrongPassword();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,7 @@ public:
|
|||||||
void loginUser(QJsonObject &users);
|
void loginUser(QJsonObject &users);
|
||||||
QJsonObject readUserJsonFile();
|
QJsonObject readUserJsonFile();
|
||||||
void wrongPassword();
|
void wrongPassword();
|
||||||
void loginSuccessful();
|
void loginSuccessful(const QString &id);
|
||||||
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|||||||
@ -22,9 +22,9 @@ MainWindow::~MainWindow()
|
|||||||
delete ui; // in the destructor, we delete the ui
|
delete ui; // in the destructor, we delete the ui
|
||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject MainWindow::readUserJsonFile()
|
QJsonObject MainWindow::readJsonFile(const QString title)
|
||||||
{
|
{
|
||||||
QFile file("user.json");
|
QFile file(title);
|
||||||
file.open( QIODevice::ReadOnly);
|
file.open( QIODevice::ReadOnly);
|
||||||
QByteArray bytes = file.readAll();
|
QByteArray bytes = file.readAll();
|
||||||
file.close();
|
file.close();
|
||||||
@ -32,12 +32,9 @@ QJsonObject MainWindow::readUserJsonFile()
|
|||||||
return document.object();
|
return document.object();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::saveJsonFile(QJsonObject &users) const
|
void MainWindow::saveJsonFile(QJsonObject &users, const QString name) const
|
||||||
{
|
{
|
||||||
qDebug() << QFile::exists(QStringLiteral(":/user.json"));
|
QFile jsonFile(name);
|
||||||
qDebug() << QFile::exists(QStringLiteral("./user.json"));
|
|
||||||
qDebug() << QFile::exists(QStringLiteral("user.json"));
|
|
||||||
QFile jsonFile(QStringLiteral("user.json"));
|
|
||||||
QJsonDocument document;
|
QJsonDocument document;
|
||||||
document.setObject( users );
|
document.setObject( users );
|
||||||
QByteArray bytes = document.toJson( QJsonDocument::Indented );
|
QByteArray bytes = document.toJson( QJsonDocument::Indented );
|
||||||
@ -64,7 +61,14 @@ void MainWindow::thisIdIsTaken() const
|
|||||||
idTaken.exec();
|
idTaken.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::saveRegisteredUser(QJsonObject &users) const
|
void MainWindow::thisBlogIdIsTaken() const
|
||||||
|
{
|
||||||
|
QMessageBox idTaken;
|
||||||
|
idTaken.setText("THIS BLOG ID IS ALREADY TAKEN!");
|
||||||
|
idTaken.exec();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::saveRegisteredUser(QJsonObject &users, QJsonObject &blogs) const
|
||||||
{
|
{
|
||||||
QString id = ui->inputId->text();
|
QString id = ui->inputId->text();
|
||||||
if(id == "")
|
if(id == "")
|
||||||
@ -81,21 +85,33 @@ void MainWindow::saveRegisteredUser(QJsonObject &users) const
|
|||||||
user["userId"] = id;
|
user["userId"] = id;
|
||||||
user["email"] = mail;
|
user["email"] = mail;
|
||||||
user["password"]=password;
|
user["password"]=password;
|
||||||
|
users.insert(id, user);
|
||||||
/*
|
/*
|
||||||
userId - unique user id - text obtained from the user during user registration
|
userId - unique user id - text obtained from the user during user registration
|
||||||
email - e-mail address of the user
|
email - e-mail address of the user
|
||||||
password - password provided by the user
|
password - password provided by the user
|
||||||
*/
|
*/
|
||||||
users.insert(id, user);
|
QJsonObject blog;
|
||||||
saveJsonFile(users);
|
QString blogTitle = ui -> inputBlogTitle->text();
|
||||||
|
QString blogId = ui -> inputBlogID->text();
|
||||||
|
if(blogs.find(blogId) == blogs.end())
|
||||||
|
{
|
||||||
|
blog["ownerId"] = id;
|
||||||
|
blog["title"] = blogTitle;
|
||||||
|
blog["blogId"] = blogId;
|
||||||
|
blogs.insert(blogId, blog);
|
||||||
|
saveJsonFile(blogs, "blogs.json");
|
||||||
|
saveJsonFile(users, "user.json");
|
||||||
|
}else thisBlogIdIsTaken();
|
||||||
}else thisIdIsTaken();
|
}else thisIdIsTaken();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainWindow::on_pushButton_clicked()
|
void MainWindow::on_pushButton_clicked()
|
||||||
{
|
{
|
||||||
QJsonObject users = readUserJsonFile();
|
QJsonObject blogs = readJsonFile("blogs.json");
|
||||||
saveRegisteredUser(users);
|
QJsonObject users = readJsonFile("user.json");
|
||||||
|
saveRegisteredUser(users, blogs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -29,13 +29,14 @@ public:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void saveRegisteredUser(QJsonObject &users) const;
|
void saveRegisteredUser(QJsonObject &users, QJsonObject &blogs) const;
|
||||||
|
|
||||||
void on_pushButton_clicked();
|
void on_pushButton_clicked();
|
||||||
void saveJsonFile(QJsonObject &users) const;
|
void saveJsonFile(QJsonObject &users, const QString name) const;
|
||||||
QJsonObject readUserJsonFile();
|
QJsonObject readJsonFile(const QString title);
|
||||||
void thisIdIsTaken() const;
|
void thisIdIsTaken() const;
|
||||||
void thisIdIsEmpty() const;
|
void thisIdIsEmpty() const;
|
||||||
|
void thisBlogIdIsTaken() const;
|
||||||
|
|
||||||
void on_loginButton_clicked();
|
void on_loginButton_clicked();
|
||||||
void goToLogin();
|
void goToLogin();
|
||||||
|
|||||||
@ -18,32 +18,32 @@
|
|||||||
<item row="0" column="0" colspan="2">
|
<item row="0" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><html><head/><body><p align="center"><span style=" font-size:72pt;">Register</span></p></body></html></string>
|
<string><html><head/><body><p align="center"><span style=" font-size:48pt;">Register</span></p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0" colspan="2">
|
<item row="6" column="0" colspan="2">
|
||||||
<widget class="QLineEdit" name="inputId">
|
<widget class="QLineEdit" name="inputId">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string><html><head/><body><p align="center"><span style=" font-size:48pt;">Input ID</span></p></body></html></string>
|
<string><html><head/><body><p align="center"><span style=" font-size:48pt;">Input ID</span></p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0" colspan="2">
|
<item row="8" column="0" colspan="2">
|
||||||
<widget class="QLineEdit" name="inputMail">
|
<widget class="QLineEdit" name="inputMail">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string><html><head/><body><p align="center"><span style=" font-size:48pt;">Input Mail</span></p></body></html></string>
|
<string><html><head/><body><p align="center"><span style=" font-size:48pt;">Input Mail</span></p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="0" colspan="2">
|
<item row="9" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="label_3">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><html><head/><body><p align="center"><span style=" font-size:36pt;">Password</span></p></body></html></string>
|
<string><html><head/><body><p align="center"><span style=" font-size:28pt;">Password</span></p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="0" colspan="2">
|
<item row="10" column="0" colspan="2">
|
||||||
<widget class="QLineEdit" name="inputPassword">
|
<widget class="QLineEdit" name="inputPassword">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string><html><head/><body><p align="center"><span style=" font-size:48pt;">Input Password</span></p></body></html></string>
|
<string><html><head/><body><p align="center"><span style=" font-size:48pt;">Input Password</span></p></body></html></string>
|
||||||
@ -59,7 +59,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="8" column="0" colspan="2">
|
<item row="11" column="0" colspan="2">
|
||||||
<widget class="QPushButton" name="pushButton">
|
<widget class="QPushButton" name="pushButton">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string><html><head/><body><p><span style=" font-size:72pt;">Register</span></p><p><br/></p></body></html></string>
|
<string><html><head/><body><p><span style=" font-size:72pt;">Register</span></p><p><br/></p></body></html></string>
|
||||||
@ -69,27 +69,47 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0" colspan="2">
|
<item row="7" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><html><head/><body><p align="center"><span style=" font-size:36pt;">Mail</span></p></body></html></string>
|
<string><html><head/><body><p align="center"><span style=" font-size:28pt;">Mail</span></p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" colspan="2">
|
<item row="5" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="QLabel" name="label_4">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string><html><head/><body><p align="center"><span style=" font-size:36pt;">ID</span></p></body></html></string>
|
<string><html><head/><body><p align="center"><span style=" font-size:28pt;">ID</span></p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="9" column="0" colspan="2">
|
<item row="12" column="0" colspan="2">
|
||||||
<widget class="QPushButton" name="loginButton">
|
<widget class="QPushButton" name="loginButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Already Registered? Click here to Login!</string>
|
<string>Already Registered? Click here to Login!</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="text">
|
||||||
|
<string><html><head/><body><p align="center"><span style=" font-size:28pt;">Blog Title</span></p></body></html></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0" colspan="2">
|
||||||
|
<widget class="QLineEdit" name="inputBlogTitle"/>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QLineEdit" name="inputBlogID"/>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QLabel" name="label_6">
|
||||||
|
<property name="text">
|
||||||
|
<string><html><head/><body><p align="center"><span style=" font-size:28pt;">Blog ID</span></p></body></html></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenuBar" name="menubar">
|
<widget class="QMenuBar" name="menubar">
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user