diff --git a/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/blogentry.o b/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/blogentry.o index 30ed380a..72096447 100644 Binary files a/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/blogentry.o and b/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/blogentry.o differ diff --git a/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/blogs.json b/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/blogs.json new file mode 100644 index 00000000..6bbf123b --- /dev/null +++ b/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/blogs.json @@ -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" + } +} diff --git a/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/blogsview.o b/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/blogsview.o index 397662b2..16a7100c 100644 Binary files a/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/blogsview.o and b/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/blogsview.o differ diff --git a/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/lab1 b/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/lab1 index f8926c38..a31a2ed5 100755 Binary files a/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/lab1 and b/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/lab1 differ diff --git a/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/login.o b/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/login.o index ec2dc25b..f216552b 100644 Binary files a/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/login.o and b/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/login.o differ diff --git a/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/mainwindow.o b/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/mainwindow.o index 883aa4b3..d8b27342 100644 Binary files a/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/mainwindow.o and b/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/mainwindow.o differ diff --git a/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/moc_blogentry.cpp b/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/moc_blogentry.cpp index 9c190782..bca111c5 100644 --- a/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/moc_blogentry.cpp +++ b/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/moc_blogentry.cpp @@ -22,17 +22,28 @@ QT_BEGIN_MOC_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED struct qt_meta_stringdata_blogEntry_t { - const uint offsetsAndSize[2]; - char stringdata0[10]; + const uint offsetsAndSize[20]; + char stringdata0[98]; }; #define QT_MOC_LITERAL(ofs, len) \ uint(offsetof(qt_meta_stringdata_blogEntry_t, stringdata0) + ofs), len 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 @@ -42,22 +53,42 @@ static const uint qt_meta_data_blogEntry[] = { 10, // revision 0, // classname 0, 0, // classinfo - 0, 0, // methods + 4, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors 0, // flags 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 }; void blogEntry::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { - (void)_o; - (void)_id; - (void)_c; - (void)_a; + if (_c == QMetaObject::InvokeMetaMethod) { + auto *_t = static_cast(_o); + (void)_t; + 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>(_a[1]))); + if (_a[0]) *reinterpret_cast< QJsonObject*>(_a[0]) = std::move(_r); } break; + case 3: _t->saveJsonFile((*reinterpret_cast< std::add_pointer_t>(_a[1])),(*reinterpret_cast< std::add_pointer_t>(_a[2]))); break; + default: ; + } + } } const QMetaObject blogEntry::staticMetaObject = { { @@ -68,7 +99,7 @@ const QMetaObject blogEntry::staticMetaObject = { { nullptr, qt_incomplete_metaTypeArray - +, QtPrivate::TypeAndForceComplete, QtPrivate::TypeAndForceComplete, QtPrivate::TypeAndForceComplete, QtPrivate::TypeAndForceComplete, QtPrivate::TypeAndForceComplete, QtPrivate::TypeAndForceComplete, QtPrivate::TypeAndForceComplete >, @@ -92,6 +123,17 @@ void *blogEntry::qt_metacast(const char *_clname) int blogEntry::qt_metacall(QMetaObject::Call _c, int _id, void **_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(_a[0]) = QMetaType(); + _id -= 4; + } return _id; } QT_WARNING_POP diff --git a/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/moc_blogentry.o b/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/moc_blogentry.o index 90123b4a..847d9e3b 100644 Binary files a/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/moc_blogentry.o and b/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/moc_blogentry.o differ diff --git a/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/moc_blogsview.o b/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/moc_blogsview.o index e10de3ad..b2780f2d 100644 Binary files a/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/moc_blogsview.o and b/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/moc_blogsview.o differ diff --git a/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/moc_login.o b/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/moc_login.o index 7dad351a..7e5f9d27 100644 Binary files a/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/moc_login.o and b/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/moc_login.o differ diff --git a/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/moc_mainwindow.cpp b/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/moc_mainwindow.cpp index 9afc93d5..60596d46 100644 --- a/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/moc_mainwindow.cpp +++ b/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/moc_mainwindow.cpp @@ -22,8 +22,8 @@ QT_BEGIN_MOC_NAMESPACE QT_WARNING_PUSH QT_WARNING_DISABLE_DEPRECATED struct qt_meta_stringdata_MainWindow_t { - const uint offsetsAndSize[24]; - char stringdata0[163]; + const uint offsetsAndSize[32]; + char stringdata0[194]; }; #define QT_MOC_LITERAL(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(31, 12), // "QJsonObject&" QT_MOC_LITERAL(44, 5), // "users" -QT_MOC_LITERAL(50, 21), // "on_pushButton_clicked" -QT_MOC_LITERAL(72, 12), // "saveJsonFile" -QT_MOC_LITERAL(85, 16), // "readUserJsonFile" -QT_MOC_LITERAL(102, 13), // "thisIdIsTaken" -QT_MOC_LITERAL(116, 13), // "thisIdIsEmpty" -QT_MOC_LITERAL(130, 22), // "on_loginButton_clicked" -QT_MOC_LITERAL(153, 9) // "goToLogin" +QT_MOC_LITERAL(50, 5), // "blogs" +QT_MOC_LITERAL(56, 21), // "on_pushButton_clicked" +QT_MOC_LITERAL(78, 12), // "saveJsonFile" +QT_MOC_LITERAL(91, 4), // "name" +QT_MOC_LITERAL(96, 12), // "readJsonFile" +QT_MOC_LITERAL(109, 5), // "title" +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" - "QJsonObject&\0users\0on_pushButton_clicked\0" - "saveJsonFile\0readUserJsonFile\0" + "QJsonObject&\0users\0blogs\0on_pushButton_clicked\0" + "saveJsonFile\0name\0readJsonFile\0title\0" "thisIdIsTaken\0thisIdIsEmpty\0" - "on_loginButton_clicked\0goToLogin" + "thisBlogIdIsTaken\0on_loginButton_clicked\0" + "goToLogin" }; #undef QT_MOC_LITERAL @@ -57,7 +62,7 @@ static const uint qt_meta_data_MainWindow[] = { 10, // revision 0, // classname 0, 0, // classinfo - 8, 14, // methods + 9, 14, // methods 0, 0, // properties 0, 0, // enums/sets 0, 0, // constructors @@ -65,20 +70,22 @@ static const uint qt_meta_data_MainWindow[] = { 0, // signalCount // slots: name, argc, parameters, tag, flags, initial metatype offsets - 1, 1, 62, 2, 0x108, 1 /* Private | MethodIsConst */, - 5, 0, 65, 2, 0x08, 3 /* Private */, - 6, 1, 66, 2, 0x108, 4 /* Private | MethodIsConst */, - 7, 0, 69, 2, 0x08, 6 /* Private */, - 8, 0, 70, 2, 0x108, 7 /* Private | MethodIsConst */, - 9, 0, 71, 2, 0x108, 8 /* Private | MethodIsConst */, - 10, 0, 72, 2, 0x08, 9 /* Private */, - 11, 0, 73, 2, 0x08, 10 /* Private */, + 1, 2, 68, 2, 0x108, 1 /* Private | MethodIsConst */, + 6, 0, 73, 2, 0x08, 4 /* Private */, + 7, 2, 74, 2, 0x108, 5 /* Private | MethodIsConst */, + 9, 1, 79, 2, 0x08, 8 /* Private */, + 11, 0, 82, 2, 0x108, 10 /* Private | MethodIsConst */, + 12, 0, 83, 2, 0x108, 11 /* Private | MethodIsConst */, + 13, 0, 84, 2, 0x108, 12 /* Private | MethodIsConst */, + 14, 0, 85, 2, 0x08, 13 /* Private */, + 15, 0, 86, 2, 0x08, 14 /* Private */, // 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, 0x80000000 | 3, 4, - QMetaType::QJsonObject, 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(_o); (void)_t; switch (_id) { - case 0: _t->saveRegisteredUser((*reinterpret_cast< std::add_pointer_t>(_a[1]))); break; + case 0: _t->saveRegisteredUser((*reinterpret_cast< std::add_pointer_t>(_a[1])),(*reinterpret_cast< std::add_pointer_t>(_a[2]))); break; case 1: _t->on_pushButton_clicked(); break; - case 2: _t->saveJsonFile((*reinterpret_cast< std::add_pointer_t>(_a[1]))); break; - case 3: { QJsonObject _r = _t->readUserJsonFile(); + case 2: _t->saveJsonFile((*reinterpret_cast< std::add_pointer_t>(_a[1])),(*reinterpret_cast< std::add_pointer_t>(_a[2]))); break; + case 3: { QJsonObject _r = _t->readJsonFile((*reinterpret_cast< std::add_pointer_t>(_a[1]))); if (_a[0]) *reinterpret_cast< QJsonObject*>(_a[0]) = std::move(_r); } break; case 4: _t->thisIdIsTaken(); break; case 5: _t->thisIdIsEmpty(); break; - case 6: _t->on_loginButton_clicked(); break; - case 7: _t->goToLogin(); break; + case 6: _t->thisBlogIdIsTaken(); break; + case 7: _t->on_loginButton_clicked(); break; + case 8: _t->goToLogin(); break; default: ; } } @@ -115,7 +123,7 @@ const QMetaObject MainWindow::staticMetaObject = { { nullptr, qt_incomplete_metaTypeArray -, QtPrivate::TypeAndForceComplete, QtPrivate::TypeAndForceComplete, QtPrivate::TypeAndForceComplete, QtPrivate::TypeAndForceComplete, QtPrivate::TypeAndForceComplete, QtPrivate::TypeAndForceComplete, QtPrivate::TypeAndForceComplete, QtPrivate::TypeAndForceComplete, QtPrivate::TypeAndForceComplete, QtPrivate::TypeAndForceComplete +, QtPrivate::TypeAndForceComplete, QtPrivate::TypeAndForceComplete, QtPrivate::TypeAndForceComplete, QtPrivate::TypeAndForceComplete, QtPrivate::TypeAndForceComplete, QtPrivate::TypeAndForceComplete, QtPrivate::TypeAndForceComplete, QtPrivate::TypeAndForceComplete, QtPrivate::TypeAndForceComplete, QtPrivate::TypeAndForceComplete, QtPrivate::TypeAndForceComplete, QtPrivate::TypeAndForceComplete, QtPrivate::TypeAndForceComplete, QtPrivate::TypeAndForceComplete >, @@ -142,13 +150,13 @@ int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a) if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { - if (_id < 8) + if (_id < 9) qt_static_metacall(this, _c, _id, _a); - _id -= 8; + _id -= 9; } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) { - if (_id < 8) + if (_id < 9) *reinterpret_cast(_a[0]) = QMetaType(); - _id -= 8; + _id -= 9; } return _id; } diff --git a/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/moc_mainwindow.o b/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/moc_mainwindow.o index c1951b1e..4bd442cb 100644 Binary files a/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/moc_mainwindow.o and b/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/moc_mainwindow.o differ diff --git a/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/ui_blogentry.h b/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/ui_blogentry.h index 6cb75db3..092921f9 100644 --- a/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/ui_blogentry.h +++ b/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/ui_blogentry.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -29,6 +30,7 @@ public: QLabel *ownerID; QLabel *dateTime; QTextEdit *textEdit; + QPushButton *saveEntry; void setupUi(QWidget *blogEntry) { @@ -59,9 +61,15 @@ public: textEdit = new QTextEdit(blogEntry); textEdit->setObjectName(QString::fromUtf8("textEdit")); + textEdit->setReadOnly(false); formLayout->setWidget(4, QFormLayout::FieldRole, textEdit); + saveEntry = new QPushButton(blogEntry); + saveEntry->setObjectName(QString::fromUtf8("saveEntry")); + + formLayout->setWidget(5, QFormLayout::FieldRole, saveEntry); + retranslateUi(blogEntry); @@ -75,6 +83,7 @@ public: lineEdit->setText(QCoreApplication::translate("blogEntry", "Title", nullptr)); ownerID->setText(QCoreApplication::translate("blogEntry", "ownerID", nullptr)); dateTime->setText(QCoreApplication::translate("blogEntry", "Date Time", nullptr)); + saveEntry->setText(QCoreApplication::translate("blogEntry", "Save Entry", nullptr)); } // retranslateUi }; diff --git a/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/ui_mainwindow.h b/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/ui_mainwindow.h index a4c5bb90..405b5f40 100644 --- a/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/ui_mainwindow.h +++ b/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/ui_mainwindow.h @@ -35,6 +35,10 @@ public: QLabel *label_2; QLabel *label_4; QPushButton *loginButton; + QLabel *label_5; + QLineEdit *inputBlogTitle; + QLineEdit *inputBlogID; + QLabel *label_6; QMenuBar *menubar; void setupUi(QMainWindow *MainWindow) @@ -54,43 +58,63 @@ public: inputId = new QLineEdit(centralwidget); inputId->setObjectName(QString::fromUtf8("inputId")); - formLayout->setWidget(3, QFormLayout::SpanningRole, inputId); + formLayout->setWidget(6, QFormLayout::SpanningRole, inputId); inputMail = new QLineEdit(centralwidget); inputMail->setObjectName(QString::fromUtf8("inputMail")); - formLayout->setWidget(5, QFormLayout::SpanningRole, inputMail); + formLayout->setWidget(8, QFormLayout::SpanningRole, inputMail); label_3 = new QLabel(centralwidget); 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->setObjectName(QString::fromUtf8("inputPassword")); inputPassword->setEchoMode(QLineEdit::Password); - formLayout->setWidget(7, QFormLayout::SpanningRole, inputPassword); + formLayout->setWidget(10, QFormLayout::SpanningRole, inputPassword); pushButton = new QPushButton(centralwidget); pushButton->setObjectName(QString::fromUtf8("pushButton")); - formLayout->setWidget(8, QFormLayout::SpanningRole, pushButton); + formLayout->setWidget(11, QFormLayout::SpanningRole, pushButton); label_2 = new QLabel(centralwidget); 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->setObjectName(QString::fromUtf8("label_4")); - formLayout->setWidget(2, QFormLayout::SpanningRole, label_4); + formLayout->setWidget(5, QFormLayout::SpanningRole, label_4); loginButton = new QPushButton(centralwidget); 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); menubar = new QMenuBar(MainWindow); @@ -106,14 +130,14 @@ public: void retranslateUi(QMainWindow *MainWindow) { MainWindow->setWindowTitle(QCoreApplication::translate("MainWindow", "MainWindow", nullptr)); - label->setText(QCoreApplication::translate("MainWindow", "

Register

", nullptr)); + label->setText(QCoreApplication::translate("MainWindow", "

Register

", nullptr)); #if QT_CONFIG(tooltip) inputId->setToolTip(QCoreApplication::translate("MainWindow", "

Input ID

", nullptr)); #endif // QT_CONFIG(tooltip) #if QT_CONFIG(tooltip) inputMail->setToolTip(QCoreApplication::translate("MainWindow", "

Input Mail

", nullptr)); #endif // QT_CONFIG(tooltip) - label_3->setText(QCoreApplication::translate("MainWindow", "

Password

", nullptr)); + label_3->setText(QCoreApplication::translate("MainWindow", "

Password

", nullptr)); #if QT_CONFIG(tooltip) inputPassword->setToolTip(QCoreApplication::translate("MainWindow", "

Input Password

", nullptr)); #endif // QT_CONFIG(tooltip) @@ -125,9 +149,11 @@ public: pushButton->setToolTip(QCoreApplication::translate("MainWindow", "

Register


", nullptr)); #endif // QT_CONFIG(tooltip) pushButton->setText(QCoreApplication::translate("MainWindow", "Register", nullptr)); - label_2->setText(QCoreApplication::translate("MainWindow", "

Mail

", nullptr)); - label_4->setText(QCoreApplication::translate("MainWindow", "

ID

", nullptr)); + label_2->setText(QCoreApplication::translate("MainWindow", "

Mail

", nullptr)); + label_4->setText(QCoreApplication::translate("MainWindow", "

ID

", nullptr)); loginButton->setText(QCoreApplication::translate("MainWindow", "Already Registered? Click here to Login!", nullptr)); + label_5->setText(QCoreApplication::translate("MainWindow", "

Blog Title

", nullptr)); + label_6->setText(QCoreApplication::translate("MainWindow", "

Blog ID

", nullptr)); } // retranslateUi }; diff --git a/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/user.json b/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/user.json index 4b781024..60e8b06c 100644 --- a/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/user.json +++ b/EGUI/build-lab1-Desktop_Qt_6_2_4_GCC_64bit-Debug/user.json @@ -13,5 +13,20 @@ "id": "2", "mail": "", "password": "" + }, + "5": { + "email": "5", + "password": "", + "userId": "5" + }, + "6": { + "email": "5", + "password": "", + "userId": "6" + }, + "7": { + "email": "5", + "password": "5", + "userId": "7" } } diff --git a/EGUI/lab1/blogentry.cpp b/EGUI/lab1/blogentry.cpp index 5f733903..62f649da 100644 --- a/EGUI/lab1/blogentry.cpp +++ b/EGUI/lab1/blogentry.cpp @@ -1,6 +1,9 @@ #include "blogentry.h" #include "ui_blogentry.h" #include +#include +#include +#include blogEntry::blogEntry(QWidget *parent) : QWidget(parent), @@ -10,6 +13,8 @@ blogEntry::blogEntry(QWidget *parent) : QString Time = QTime::currentTime().toString(); QString Date = QDate::currentDate().toString(); ui -> dateTime -> setText(Date + " " + Time); + + qDebug() << "blogEntry id: " << userId; qDebug() << Time; } @@ -17,3 +22,61 @@ blogEntry::~blogEntry() { 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(); +} + diff --git a/EGUI/lab1/blogentry.h b/EGUI/lab1/blogentry.h index bfb694b4..87339767 100644 --- a/EGUI/lab1/blogentry.h +++ b/EGUI/lab1/blogentry.h @@ -2,6 +2,9 @@ #define BLOGENTRY_H #include +#include +#include +#include namespace Ui { class blogEntry; @@ -14,9 +17,16 @@ class blogEntry : public QWidget public: explicit blogEntry(QWidget *parent = nullptr); ~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: Ui::blogEntry *ui; + QString userId; }; #endif // BLOGENTRY_H diff --git a/EGUI/lab1/blogentry.ui b/EGUI/lab1/blogentry.ui index 7f70aa24..9e6cd561 100644 --- a/EGUI/lab1/blogentry.ui +++ b/EGUI/lab1/blogentry.ui @@ -43,7 +43,18 @@ - + + + false + + + + + + + Save Entry + + diff --git a/EGUI/lab1/blogsview.cpp b/EGUI/lab1/blogsview.cpp index c6ae2950..09214777 100644 --- a/EGUI/lab1/blogsview.cpp +++ b/EGUI/lab1/blogsview.cpp @@ -2,6 +2,9 @@ #include "ui_blogsview.h" #include "blogentry.h" #include "ui_blogentry.h" +#include +#include +#include blogsView::blogsView(QWidget *parent) : QMainWindow(parent), @@ -15,9 +18,31 @@ blogsView::~blogsView() 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() { + QJsonObject blogsFile = readJsonFile("blogs.json"); + QJsonObject blogEntryJson; + blogEntryJson["title"]; + blogEntryJson["datetime"]; + blogEntryJson["content"]; + qDebug() << "blogsView id: " << userId; blogEntry *e = new blogEntry(); + e -> setUserId(userId); ui -> blogsLayout -> addWidget(e); } diff --git a/EGUI/lab1/blogsview.h b/EGUI/lab1/blogsview.h index a5963e00..7c4d516e 100644 --- a/EGUI/lab1/blogsview.h +++ b/EGUI/lab1/blogsview.h @@ -15,12 +15,16 @@ public: explicit blogsView(QWidget *parent = nullptr); ~blogsView(); void createNewBlogEntry(); + void setUserId(const QString &userId); + QJsonObject readJsonFile(const QString title); private slots: void on_actionCreate_new_Blog_entry_triggered(); + private: Ui::blogsView *ui; + QString userId; }; #endif // BLOGSVIEW_H diff --git a/EGUI/lab1/login.cpp b/EGUI/lab1/login.cpp index 06a3247b..b5d85ac8 100644 --- a/EGUI/lab1/login.cpp +++ b/EGUI/lab1/login.cpp @@ -34,9 +34,11 @@ void login::wrongPassword() wrongPassword.exec(); } -void login::loginSuccessful() +void login::loginSuccessful(const QString &id) { + qDebug() << "login id: " << id; blogsView *b = new blogsView(); + b -> setUserId(id); b -> show(); hide(); } @@ -51,7 +53,7 @@ void login::loginUser(QJsonObject &users) QString enteredPassword = ui->inputPassword->text(); if (user["password"] == enteredPassword) { - loginSuccessful(); + loginSuccessful(id); }else wrongPassword(); } } diff --git a/EGUI/lab1/login.h b/EGUI/lab1/login.h index ab4ddcf3..40a5c955 100644 --- a/EGUI/lab1/login.h +++ b/EGUI/lab1/login.h @@ -18,7 +18,7 @@ public: void loginUser(QJsonObject &users); QJsonObject readUserJsonFile(); void wrongPassword(); - void loginSuccessful(); + void loginSuccessful(const QString &id); private slots: diff --git a/EGUI/lab1/mainwindow.cpp b/EGUI/lab1/mainwindow.cpp index 4259ab5d..8318c081 100644 --- a/EGUI/lab1/mainwindow.cpp +++ b/EGUI/lab1/mainwindow.cpp @@ -22,9 +22,9 @@ MainWindow::~MainWindow() 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); QByteArray bytes = file.readAll(); file.close(); @@ -32,12 +32,9 @@ QJsonObject MainWindow::readUserJsonFile() return document.object(); } -void MainWindow::saveJsonFile(QJsonObject &users) const +void MainWindow::saveJsonFile(QJsonObject &users, const QString name) const { - qDebug() << QFile::exists(QStringLiteral(":/user.json")); - qDebug() << QFile::exists(QStringLiteral("./user.json")); - qDebug() << QFile::exists(QStringLiteral("user.json")); - QFile jsonFile(QStringLiteral("user.json")); + QFile jsonFile(name); QJsonDocument document; document.setObject( users ); QByteArray bytes = document.toJson( QJsonDocument::Indented ); @@ -64,7 +61,14 @@ void MainWindow::thisIdIsTaken() const 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(); if(id == "") @@ -81,21 +85,33 @@ void MainWindow::saveRegisteredUser(QJsonObject &users) const user["userId"] = id; user["email"] = mail; user["password"]=password; + users.insert(id, user); /* userId - unique user id - text obtained from the user during user registration email - e-mail address of the user password - password provided by the user */ - users.insert(id, user); - saveJsonFile(users); + QJsonObject blog; + 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(); } void MainWindow::on_pushButton_clicked() { - QJsonObject users = readUserJsonFile(); - saveRegisteredUser(users); + QJsonObject blogs = readJsonFile("blogs.json"); + QJsonObject users = readJsonFile("user.json"); + saveRegisteredUser(users, blogs); } diff --git a/EGUI/lab1/mainwindow.h b/EGUI/lab1/mainwindow.h index e57c98b6..522d98bf 100644 --- a/EGUI/lab1/mainwindow.h +++ b/EGUI/lab1/mainwindow.h @@ -29,13 +29,14 @@ public: private slots: - void saveRegisteredUser(QJsonObject &users) const; + void saveRegisteredUser(QJsonObject &users, QJsonObject &blogs) const; void on_pushButton_clicked(); - void saveJsonFile(QJsonObject &users) const; - QJsonObject readUserJsonFile(); + void saveJsonFile(QJsonObject &users, const QString name) const; + QJsonObject readJsonFile(const QString title); void thisIdIsTaken() const; void thisIdIsEmpty() const; + void thisBlogIdIsTaken() const; void on_loginButton_clicked(); void goToLogin(); diff --git a/EGUI/lab1/mainwindow.ui b/EGUI/lab1/mainwindow.ui index e17490b6..b243ac60 100644 --- a/EGUI/lab1/mainwindow.ui +++ b/EGUI/lab1/mainwindow.ui @@ -18,32 +18,32 @@ - <html><head/><body><p align="center"><span style=" font-size:72pt;">Register</span></p></body></html> + <html><head/><body><p align="center"><span style=" font-size:48pt;">Register</span></p></body></html> - + <html><head/><body><p align="center"><span style=" font-size:48pt;">Input ID</span></p></body></html> - + <html><head/><body><p align="center"><span style=" font-size:48pt;">Input Mail</span></p></body></html> - + - <html><head/><body><p align="center"><span style=" font-size:36pt;">Password</span></p></body></html> + <html><head/><body><p align="center"><span style=" font-size:28pt;">Password</span></p></body></html> - + <html><head/><body><p align="center"><span style=" font-size:48pt;">Input Password</span></p></body></html> @@ -59,7 +59,7 @@ - + <html><head/><body><p><span style=" font-size:72pt;">Register</span></p><p><br/></p></body></html> @@ -69,27 +69,47 @@ - + - <html><head/><body><p align="center"><span style=" font-size:36pt;">Mail</span></p></body></html> + <html><head/><body><p align="center"><span style=" font-size:28pt;">Mail</span></p></body></html> - + - <html><head/><body><p align="center"><span style=" font-size:36pt;">ID</span></p></body></html> + <html><head/><body><p align="center"><span style=" font-size:28pt;">ID</span></p></body></html> - + Already Registered? Click here to Login! + + + + <html><head/><body><p align="center"><span style=" font-size:28pt;">Blog Title</span></p></body></html> + + + + + + + + + + + + + <html><head/><body><p align="center"><span style=" font-size:28pt;">Blog ID</span></p></body></html> + + +