mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-11-11 19:33:55 +01:00
feat: remove entries
This commit is contained in:
parent
362ae8c36f
commit
a165216ec7
Binary file not shown.
@ -2,16 +2,6 @@
|
|||||||
"": {
|
"": {
|
||||||
"blogId": "",
|
"blogId": "",
|
||||||
"items": [
|
"items": [
|
||||||
{
|
|
||||||
"content": "",
|
|
||||||
"datetime": "01:05:33 Wed Apr 6 2022",
|
|
||||||
"title": "Title"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"content": "notempty",
|
|
||||||
"datetime": "01:05:44 Wed Apr 6 2022",
|
|
||||||
"title": "anotherTitle"
|
|
||||||
}
|
|
||||||
],
|
],
|
||||||
"ownerId": "1",
|
"ownerId": "1",
|
||||||
"title": ""
|
"title": ""
|
||||||
|
|||||||
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_blogEntry_t {
|
struct qt_meta_stringdata_blogEntry_t {
|
||||||
const uint offsetsAndSize[20];
|
const uint offsetsAndSize[24];
|
||||||
char stringdata0[98];
|
char stringdata0[132];
|
||||||
};
|
};
|
||||||
#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
|
||||||
@ -38,12 +38,15 @@ QT_MOC_LITERAL(55, 5), // "title"
|
|||||||
QT_MOC_LITERAL(61, 12), // "saveJsonFile"
|
QT_MOC_LITERAL(61, 12), // "saveJsonFile"
|
||||||
QT_MOC_LITERAL(74, 12), // "QJsonObject&"
|
QT_MOC_LITERAL(74, 12), // "QJsonObject&"
|
||||||
QT_MOC_LITERAL(87, 5), // "users"
|
QT_MOC_LITERAL(87, 5), // "users"
|
||||||
QT_MOC_LITERAL(93, 4) // "name"
|
QT_MOC_LITERAL(93, 4), // "name"
|
||||||
|
QT_MOC_LITERAL(98, 11), // "removeEntry"
|
||||||
|
QT_MOC_LITERAL(110, 21) // "on_pushButton_clicked"
|
||||||
|
|
||||||
},
|
},
|
||||||
"blogEntry\0on_saveEntry_clicked\0\0"
|
"blogEntry\0on_saveEntry_clicked\0\0"
|
||||||
"saveEntry\0readJsonFile\0title\0saveJsonFile\0"
|
"saveEntry\0readJsonFile\0title\0saveJsonFile\0"
|
||||||
"QJsonObject&\0users\0name"
|
"QJsonObject&\0users\0name\0removeEntry\0"
|
||||||
|
"on_pushButton_clicked"
|
||||||
};
|
};
|
||||||
#undef QT_MOC_LITERAL
|
#undef QT_MOC_LITERAL
|
||||||
|
|
||||||
@ -53,7 +56,7 @@ static const uint qt_meta_data_blogEntry[] = {
|
|||||||
10, // revision
|
10, // revision
|
||||||
0, // classname
|
0, // classname
|
||||||
0, 0, // classinfo
|
0, 0, // classinfo
|
||||||
4, 14, // methods
|
6, 14, // methods
|
||||||
0, 0, // properties
|
0, 0, // properties
|
||||||
0, 0, // enums/sets
|
0, 0, // enums/sets
|
||||||
0, 0, // constructors
|
0, 0, // constructors
|
||||||
@ -61,16 +64,20 @@ static const uint qt_meta_data_blogEntry[] = {
|
|||||||
0, // signalCount
|
0, // signalCount
|
||||||
|
|
||||||
// slots: name, argc, parameters, tag, flags, initial metatype offsets
|
// slots: name, argc, parameters, tag, flags, initial metatype offsets
|
||||||
1, 0, 38, 2, 0x08, 1 /* Private */,
|
1, 0, 50, 2, 0x08, 1 /* Private */,
|
||||||
3, 0, 39, 2, 0x08, 2 /* Private */,
|
3, 0, 51, 2, 0x08, 2 /* Private */,
|
||||||
4, 1, 40, 2, 0x08, 3 /* Private */,
|
4, 1, 52, 2, 0x08, 3 /* Private */,
|
||||||
6, 2, 43, 2, 0x108, 5 /* Private | MethodIsConst */,
|
6, 2, 55, 2, 0x108, 5 /* Private | MethodIsConst */,
|
||||||
|
10, 0, 60, 2, 0x08, 8 /* Private */,
|
||||||
|
11, 0, 61, 2, 0x08, 9 /* Private */,
|
||||||
|
|
||||||
// slots: parameters
|
// slots: parameters
|
||||||
QMetaType::Void,
|
QMetaType::Void,
|
||||||
QMetaType::Void,
|
QMetaType::Void,
|
||||||
QMetaType::QJsonObject, QMetaType::QString, 5,
|
QMetaType::QJsonObject, QMetaType::QString, 5,
|
||||||
QMetaType::Void, 0x80000000 | 7, QMetaType::QString, 8, 9,
|
QMetaType::Void, 0x80000000 | 7, QMetaType::QString, 8, 9,
|
||||||
|
QMetaType::Void,
|
||||||
|
QMetaType::Void,
|
||||||
|
|
||||||
0 // eod
|
0 // eod
|
||||||
};
|
};
|
||||||
@ -86,6 +93,8 @@ void blogEntry::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, v
|
|||||||
case 2: { QJsonObject _r = _t->readJsonFile((*reinterpret_cast< std::add_pointer_t<QString>>(_a[1])));
|
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;
|
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;
|
case 3: _t->saveJsonFile((*reinterpret_cast< std::add_pointer_t<QJsonObject&>>(_a[1])),(*reinterpret_cast< std::add_pointer_t<QString>>(_a[2]))); break;
|
||||||
|
case 4: _t->removeEntry(); break;
|
||||||
|
case 5: _t->on_pushButton_clicked(); break;
|
||||||
default: ;
|
default: ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -99,7 +108,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>
|
, 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>, QtPrivate::TypeAndForceComplete<void, std::false_type>, QtPrivate::TypeAndForceComplete<void, std::false_type>
|
||||||
|
|
||||||
|
|
||||||
>,
|
>,
|
||||||
@ -126,13 +135,13 @@ int blogEntry::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 < 4)
|
if (_id < 6)
|
||||||
qt_static_metacall(this, _c, _id, _a);
|
qt_static_metacall(this, _c, _id, _a);
|
||||||
_id -= 4;
|
_id -= 6;
|
||||||
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
|
} else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
|
||||||
if (_id < 4)
|
if (_id < 6)
|
||||||
*reinterpret_cast<QMetaType *>(_a[0]) = QMetaType();
|
*reinterpret_cast<QMetaType *>(_a[0]) = QMetaType();
|
||||||
_id -= 4;
|
_id -= 6;
|
||||||
}
|
}
|
||||||
return _id;
|
return _id;
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
#include <QtCore/QVariant>
|
#include <QtCore/QVariant>
|
||||||
#include <QtWidgets/QApplication>
|
#include <QtWidgets/QApplication>
|
||||||
#include <QtWidgets/QCheckBox>
|
|
||||||
#include <QtWidgets/QFormLayout>
|
#include <QtWidgets/QFormLayout>
|
||||||
#include <QtWidgets/QLabel>
|
#include <QtWidgets/QLabel>
|
||||||
#include <QtWidgets/QLineEdit>
|
#include <QtWidgets/QLineEdit>
|
||||||
@ -25,12 +24,12 @@ class Ui_blogEntry
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QFormLayout *formLayout;
|
QFormLayout *formLayout;
|
||||||
QCheckBox *checkBox;
|
|
||||||
QLineEdit *lineEdit;
|
QLineEdit *lineEdit;
|
||||||
QLabel *ownerID;
|
QLabel *ownerID;
|
||||||
QLabel *dateTime;
|
QLabel *dateTime;
|
||||||
QTextEdit *textEdit;
|
QTextEdit *textEdit;
|
||||||
QPushButton *saveEntry;
|
QPushButton *saveEntry;
|
||||||
|
QPushButton *pushButton;
|
||||||
|
|
||||||
void setupUi(QWidget *blogEntry)
|
void setupUi(QWidget *blogEntry)
|
||||||
{
|
{
|
||||||
@ -39,36 +38,36 @@ public:
|
|||||||
blogEntry->resize(400, 300);
|
blogEntry->resize(400, 300);
|
||||||
formLayout = new QFormLayout(blogEntry);
|
formLayout = new QFormLayout(blogEntry);
|
||||||
formLayout->setObjectName(QString::fromUtf8("formLayout"));
|
formLayout->setObjectName(QString::fromUtf8("formLayout"));
|
||||||
checkBox = new QCheckBox(blogEntry);
|
|
||||||
checkBox->setObjectName(QString::fromUtf8("checkBox"));
|
|
||||||
|
|
||||||
formLayout->setWidget(0, QFormLayout::FieldRole, checkBox);
|
|
||||||
|
|
||||||
lineEdit = new QLineEdit(blogEntry);
|
lineEdit = new QLineEdit(blogEntry);
|
||||||
lineEdit->setObjectName(QString::fromUtf8("lineEdit"));
|
lineEdit->setObjectName(QString::fromUtf8("lineEdit"));
|
||||||
|
|
||||||
formLayout->setWidget(1, QFormLayout::FieldRole, lineEdit);
|
formLayout->setWidget(0, QFormLayout::FieldRole, lineEdit);
|
||||||
|
|
||||||
ownerID = new QLabel(blogEntry);
|
ownerID = new QLabel(blogEntry);
|
||||||
ownerID->setObjectName(QString::fromUtf8("ownerID"));
|
ownerID->setObjectName(QString::fromUtf8("ownerID"));
|
||||||
|
|
||||||
formLayout->setWidget(2, QFormLayout::FieldRole, ownerID);
|
formLayout->setWidget(1, QFormLayout::FieldRole, ownerID);
|
||||||
|
|
||||||
dateTime = new QLabel(blogEntry);
|
dateTime = new QLabel(blogEntry);
|
||||||
dateTime->setObjectName(QString::fromUtf8("dateTime"));
|
dateTime->setObjectName(QString::fromUtf8("dateTime"));
|
||||||
|
|
||||||
formLayout->setWidget(3, QFormLayout::FieldRole, dateTime);
|
formLayout->setWidget(2, QFormLayout::FieldRole, dateTime);
|
||||||
|
|
||||||
textEdit = new QTextEdit(blogEntry);
|
textEdit = new QTextEdit(blogEntry);
|
||||||
textEdit->setObjectName(QString::fromUtf8("textEdit"));
|
textEdit->setObjectName(QString::fromUtf8("textEdit"));
|
||||||
textEdit->setReadOnly(false);
|
textEdit->setReadOnly(false);
|
||||||
|
|
||||||
formLayout->setWidget(4, QFormLayout::FieldRole, textEdit);
|
formLayout->setWidget(3, QFormLayout::FieldRole, textEdit);
|
||||||
|
|
||||||
saveEntry = new QPushButton(blogEntry);
|
saveEntry = new QPushButton(blogEntry);
|
||||||
saveEntry->setObjectName(QString::fromUtf8("saveEntry"));
|
saveEntry->setObjectName(QString::fromUtf8("saveEntry"));
|
||||||
|
|
||||||
formLayout->setWidget(5, QFormLayout::FieldRole, saveEntry);
|
formLayout->setWidget(4, QFormLayout::FieldRole, saveEntry);
|
||||||
|
|
||||||
|
pushButton = new QPushButton(blogEntry);
|
||||||
|
pushButton->setObjectName(QString::fromUtf8("pushButton"));
|
||||||
|
|
||||||
|
formLayout->setWidget(5, QFormLayout::FieldRole, pushButton);
|
||||||
|
|
||||||
|
|
||||||
retranslateUi(blogEntry);
|
retranslateUi(blogEntry);
|
||||||
@ -79,11 +78,11 @@ public:
|
|||||||
void retranslateUi(QWidget *blogEntry)
|
void retranslateUi(QWidget *blogEntry)
|
||||||
{
|
{
|
||||||
blogEntry->setWindowTitle(QCoreApplication::translate("blogEntry", "Form", nullptr));
|
blogEntry->setWindowTitle(QCoreApplication::translate("blogEntry", "Form", nullptr));
|
||||||
checkBox->setText(QCoreApplication::translate("blogEntry", "Remove", nullptr));
|
|
||||||
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));
|
saveEntry->setText(QCoreApplication::translate("blogEntry", "Save Entry", nullptr));
|
||||||
|
pushButton->setText(QCoreApplication::translate("blogEntry", "Remove Entry", nullptr));
|
||||||
} // retranslateUi
|
} // retranslateUi
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -11,12 +11,17 @@ blogEntry::blogEntry(QWidget *parent) :
|
|||||||
ui(new Ui::blogEntry)
|
ui(new Ui::blogEntry)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
QString Time = QTime::currentTime().toString();
|
|
||||||
QString Date = QDate::currentDate().toString();
|
|
||||||
ui -> dateTime -> setText(Date + " " + Time);
|
|
||||||
|
|
||||||
qDebug() << "blogEntry id: " << userId;
|
}
|
||||||
qDebug() << Time;
|
|
||||||
|
void blogEntry::setUpBlogEntryFromJson(const QJsonObject entry)
|
||||||
|
{
|
||||||
|
ui -> lineEdit-> setText(entry["title"].toString());
|
||||||
|
ui -> textEdit -> setText(entry["content"].toString());
|
||||||
|
ui -> dateTime -> setText(entry["datetime"].toString());
|
||||||
|
ui -> ownerID -> setText("Owner ID: " + userId);
|
||||||
|
ui -> textEdit -> setReadOnly(true);
|
||||||
|
ui -> lineEdit -> setReadOnly(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
blogEntry::~blogEntry()
|
blogEntry::~blogEntry()
|
||||||
@ -72,7 +77,9 @@ void blogEntry::saveEntry()
|
|||||||
entry["title"] = ui -> lineEdit -> text();
|
entry["title"] = ui -> lineEdit -> text();
|
||||||
QString Time = QTime::currentTime().toString();
|
QString Time = QTime::currentTime().toString();
|
||||||
QString Date = QDate::currentDate().toString();
|
QString Date = QDate::currentDate().toString();
|
||||||
|
|
||||||
entry["datetime"] = Time + " " + Date;
|
entry["datetime"] = Time + " " + Date;
|
||||||
|
ui -> dateTime -> setText( Time + " " + Date);
|
||||||
entry["content"] = ui -> textEdit -> toPlainText();
|
entry["content"] = ui -> textEdit -> toPlainText();
|
||||||
QJsonArray items = blogEntryJson["items"].toArray();
|
QJsonArray items = blogEntryJson["items"].toArray();
|
||||||
items.append(entry);
|
items.append(entry);
|
||||||
@ -82,8 +89,36 @@ void blogEntry::saveEntry()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void blogEntry::removeEntry()
|
||||||
|
{
|
||||||
|
QJsonObject blogsFile = readJsonFile("blogs.json");
|
||||||
|
QJsonObject blogEntryJson = blogsFile[blogId].toObject();
|
||||||
|
QJsonArray items = blogEntryJson["items"].toArray();
|
||||||
|
for(int i = 0; i < items.size(); i++)
|
||||||
|
{
|
||||||
|
QJsonObject currentItem = items[i].toObject();
|
||||||
|
qDebug() << currentItem["datetime"].toString();
|
||||||
|
qDebug() << ui -> dateTime -> text();
|
||||||
|
if(currentItem["datetime"].toString() == ui -> dateTime -> text())
|
||||||
|
{
|
||||||
|
items.removeAt(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
blogEntryJson.insert("items", items);
|
||||||
|
blogsFile.insert(blogId, blogEntryJson);
|
||||||
|
saveJsonFile(blogsFile, "blogs.json");
|
||||||
|
this -> ~blogEntry();
|
||||||
|
}
|
||||||
|
|
||||||
void blogEntry::on_saveEntry_clicked()
|
void blogEntry::on_saveEntry_clicked()
|
||||||
{
|
{
|
||||||
saveEntry();
|
saveEntry();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void blogEntry::on_pushButton_clicked()
|
||||||
|
{
|
||||||
|
removeEntry();
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -19,17 +19,21 @@ public:
|
|||||||
~blogEntry();
|
~blogEntry();
|
||||||
void setUserId(const QString &userId);
|
void setUserId(const QString &userId);
|
||||||
void setBlogId(const QString &blogId);
|
void setBlogId(const QString &blogId);
|
||||||
|
void setUpBlogEntryFromJson(const QJsonObject entry);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_saveEntry_clicked();
|
void on_saveEntry_clicked();
|
||||||
void saveEntry();
|
void saveEntry();
|
||||||
QJsonObject readJsonFile(const QString title);
|
QJsonObject readJsonFile(const QString title);
|
||||||
void saveJsonFile(QJsonObject &users, const QString name) const;
|
void saveJsonFile(QJsonObject &users, const QString name) const;
|
||||||
|
void removeEntry();
|
||||||
|
void on_pushButton_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::blogEntry *ui;
|
Ui::blogEntry *ui;
|
||||||
QString userId;
|
QString userId;
|
||||||
QString blogId;
|
QString blogId;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BLOGENTRY_H
|
#endif // BLOGENTRY_H
|
||||||
|
|||||||
@ -15,47 +15,47 @@
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QFormLayout" name="formLayout">
|
<layout class="QFormLayout" name="formLayout">
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<widget class="QCheckBox" name="checkBox">
|
|
||||||
<property name="text">
|
|
||||||
<string>Remove</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QLineEdit" name="lineEdit">
|
<widget class="QLineEdit" name="lineEdit">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Title</string>
|
<string>Title</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QLabel" name="ownerID">
|
<widget class="QLabel" name="ownerID">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>ownerID</string>
|
<string>ownerID</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QLabel" name="dateTime">
|
<widget class="QLabel" name="dateTime">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Date Time</string>
|
<string>Date Time</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="QTextEdit" name="textEdit">
|
<widget class="QTextEdit" name="textEdit">
|
||||||
<property name="readOnly">
|
<property name="readOnly">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="1">
|
<item row="4" column="1">
|
||||||
<widget class="QPushButton" name="saveEntry">
|
<widget class="QPushButton" name="saveEntry">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Save Entry</string>
|
<string>Save Entry</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="5" column="1">
|
||||||
|
<widget class="QPushButton" name="pushButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Remove Entry</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
|||||||
@ -2,15 +2,18 @@
|
|||||||
#include "ui_blogsview.h"
|
#include "ui_blogsview.h"
|
||||||
#include "blogentry.h"
|
#include "blogentry.h"
|
||||||
#include "ui_blogentry.h"
|
#include "ui_blogentry.h"
|
||||||
|
#include <algorithm>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
#include <QJsonArray>
|
||||||
|
|
||||||
blogsView::blogsView(QWidget *parent) :
|
blogsView::blogsView(QWidget *parent) :
|
||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
ui(new Ui::blogsView)
|
ui(new Ui::blogsView)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
displayBlogEntries();
|
||||||
}
|
}
|
||||||
|
|
||||||
blogsView::~blogsView()
|
blogsView::~blogsView()
|
||||||
@ -65,6 +68,23 @@ void blogsView::createNewBlogEntry()
|
|||||||
ui -> blogsLayout -> addWidget(e);
|
ui -> blogsLayout -> addWidget(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void blogsView::displayBlogEntries()
|
||||||
|
{
|
||||||
|
QJsonObject blogsFile = readJsonFile("blogs.json");
|
||||||
|
QJsonObject userBlog = blogsFile[blogId].toObject();
|
||||||
|
QJsonArray blogEntries = userBlog["items"].toArray();
|
||||||
|
for(int i = 0; i < blogEntries.size(); i++)
|
||||||
|
{
|
||||||
|
QJsonObject entry = (blogEntries.at(i)).toObject();
|
||||||
|
blogEntry *e = new blogEntry();
|
||||||
|
e -> setUserId(userId);
|
||||||
|
e -> setUpBlogEntryFromJson(entry);
|
||||||
|
ui -> blogsLayout -> addWidget(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void blogsView::on_actionCreate_new_Blog_entry_triggered()
|
void blogsView::on_actionCreate_new_Blog_entry_triggered()
|
||||||
{
|
{
|
||||||
createNewBlogEntry();
|
createNewBlogEntry();
|
||||||
|
|||||||
@ -22,6 +22,7 @@ public:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_actionCreate_new_Blog_entry_triggered();
|
void on_actionCreate_new_Blog_entry_triggered();
|
||||||
|
void displayBlogEntries();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user