-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
1,545 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
#include "add_member.h" | ||
#include "ui_add_member.h" | ||
#include<iostream> | ||
#include<QJsonArray> | ||
#include<QJsonDocument> | ||
#include<QJsonObject> | ||
#include<QFile> | ||
#include<QMessageBox> | ||
#include<QPushButton> | ||
#include<QListWidget> | ||
|
||
void Add_Member::on_btn_Clicked() | ||
{ | ||
QPushButton* buttonSender = qobject_cast<QPushButton*>(sender()); // retrieve the button you have clicked | ||
QString buttonText = buttonSender->text(); // retrive the text from the button clicked | ||
QJsonObject All_Channel; | ||
QFile F_R_Channel("All_Channel.json"); | ||
if(F_R_Channel.open(QIODevice::ReadOnly)) | ||
{ | ||
QByteArray a = F_R_Channel.readAll(); | ||
QJsonDocument b = QJsonDocument::fromJson(a); | ||
All_Channel = b.object(); | ||
F_R_Channel.close(); | ||
} | ||
QJsonObject This_Channel = All_Channel[Chat_name].toObject(); | ||
QJsonArray members = This_Channel["Members"].toArray(); | ||
members.append(buttonText); | ||
This_Channel["Members"] = members; | ||
All_Channel[Chat_name] = This_Channel; | ||
QFile F_W_Channel("All_Channel.json"); | ||
if(F_W_Channel.open(QIODevice::WriteOnly)) | ||
{ | ||
QJsonDocument Channel_file(All_Channel); | ||
F_W_Channel.write(Channel_file.toJson()); | ||
F_W_Channel.close(); | ||
} | ||
QJsonObject All_User; | ||
QFile F_R_Users("All_User.json"); | ||
if(F_R_Users.open(QIODevice::ReadOnly)) | ||
{ | ||
QByteArray a = F_R_Users.readAll(); | ||
QJsonDocument b = QJsonDocument::fromJson(a); | ||
All_User = b.object(); | ||
F_R_Users.close(); | ||
} | ||
QJsonObject This_User = All_User[buttonText].toObject(); | ||
QJsonArray User_chats = This_User["Chats"].toArray(); | ||
User_chats.append(this->Chat_name); | ||
This_User["Chats"] = User_chats; | ||
All_User[buttonText] = This_User; | ||
QJsonDocument All_User_File(All_User); | ||
QFile F_W_Users("All_User.json"); | ||
if(F_W_Users.open(QIODevice::WriteOnly)) | ||
{ | ||
F_W_Users.write(All_User_File.toJson()); | ||
F_W_Users.close(); | ||
} | ||
QMessageBox::information(this,"operation Succesful",buttonText+" Added"); | ||
this->destroy(); | ||
} | ||
|
||
Add_Member::Add_Member(QString Current_user,QString Chat_Page,QWidget *parent) : | ||
QDialog(parent), | ||
ui(new Ui::Add_Member) | ||
{ | ||
ui->setupUi(this); | ||
QFile F_R_User("All_User.json"); | ||
this->Chat_name = Chat_Page; | ||
QJsonObject All_User; | ||
if(F_R_User.open(QIODevice::ReadOnly)) | ||
{ | ||
QByteArray a = F_R_User.readAll(); | ||
QJsonDocument b = QJsonDocument::fromJson(a); | ||
All_User = b.object(); | ||
F_R_User.close(); | ||
} | ||
QJsonObject All_Channel; | ||
QFile F_R_Channel("All_Channel.json"); | ||
if(F_R_Channel.open(QIODevice::ReadOnly)) | ||
{ | ||
QByteArray a = F_R_Channel.readAll(); | ||
QJsonDocument b = QJsonDocument::fromJson(a); | ||
All_Channel = b.object(); | ||
F_R_Channel.close(); | ||
} | ||
QJsonObject This_User = All_User[Current_user].toObject(); | ||
QJsonObject This_Channel = All_Channel[Chat_Page].toObject(); | ||
QJsonArray contacts = This_User["Contacts"].toArray(); | ||
QJsonArray Members = This_Channel["Members"].toArray(); | ||
QJsonArray Show; | ||
for(int i = 0 ;i<contacts.size();i++) | ||
{ | ||
int state = 1; | ||
for(int j=0;j<Members.size();j++) | ||
{ | ||
if(contacts[i]==Members[j]) | ||
{ | ||
state = 0; | ||
break; | ||
} | ||
} | ||
if(state) | ||
Show.append(contacts[i]); | ||
} | ||
for(int i = 0; i<Show.size();i++) | ||
{ | ||
QPushButton* btn = new QPushButton(Show[i].toString()); | ||
connect(btn, SIGNAL(clicked()), this, SLOT(on_btn_Clicked())); | ||
QListWidgetItem *item = new QListWidgetItem(ui->listWidget); | ||
ui->listWidget->addItem(item); | ||
ui->listWidget->setItemWidget(item, btn); | ||
} | ||
} | ||
|
||
Add_Member::~Add_Member() | ||
{ | ||
delete ui; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#ifndef ADD_MEMBER_H | ||
#define ADD_MEMBER_H | ||
|
||
#include <QDialog> | ||
|
||
namespace Ui { | ||
class Add_Member; | ||
} | ||
|
||
class Add_Member : public QDialog | ||
{ | ||
Q_OBJECT | ||
|
||
public slots: | ||
void on_btn_Clicked(); | ||
public: | ||
explicit Add_Member(QString Current_user,QString Chat_Page,QWidget *parent = nullptr); | ||
~Add_Member(); | ||
|
||
private: | ||
Ui::Add_Member *ui; | ||
QString Chat_name; | ||
}; | ||
|
||
#endif // ADD_MEMBER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>Add_Member</class> | ||
<widget class="QDialog" name="Add_Member"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>298</width> | ||
<height>588</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Dialog</string> | ||
</property> | ||
<widget class="QListWidget" name="listWidget"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>5</x> | ||
<y>10</y> | ||
<width>291</width> | ||
<height>571</height> | ||
</rect> | ||
</property> | ||
</widget> | ||
</widget> | ||
<resources/> | ||
<connections/> | ||
</ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+24 Bytes
(100%)
...3_1_MinGW_64_bit-Debug/.qtc_clangd/.cache/clangd/index/add_admin.cpp.0FB3CE50423536F3.idx
Binary file not shown.
Binary file added
BIN
+4.48 KB
..._1_MinGW_64_bit-Debug/.qtc_clangd/.cache/clangd/index/add_member.cpp.49095F0EC1BCC11E.idx
Binary file not shown.
Binary file added
BIN
+1.06 KB
..._3_1_MinGW_64_bit-Debug/.qtc_clangd/.cache/clangd/index/add_member.h.9EDAD19D7799814E.idx
Binary file not shown.
Binary file modified
BIN
+586 Bytes
(110%)
...6_3_1_MinGW_64_bit-Debug/.qtc_clangd/.cache/clangd/index/channel.cpp.868822EAA2579F99.idx
Binary file not shown.
Binary file modified
BIN
+164 Bytes
(110%)
...t_6_3_1_MinGW_64_bit-Debug/.qtc_clangd/.cache/clangd/index/channel.h.A7A2F4CA760E02D4.idx
Binary file not shown.
Binary file modified
BIN
+3.45 KB
(240%)
..._MinGW_64_bit-Debug/.qtc_clangd/.cache/clangd/index/deletemember.cpp.6DCF9D9B9AA1E587.idx
Binary file not shown.
Binary file modified
BIN
+142 Bytes
(110%)
..._1_MinGW_64_bit-Debug/.qtc_clangd/.cache/clangd/index/deletemember.h.E6917305EB998C8A.idx
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
..._1_MinGW_64_bit-Debug/.qtc_clangd/.cache/clangd/index/mainwindow.cpp.CD0709C73D07F821.idx
Binary file not shown.
Binary file added
BIN
+3.25 KB
...1_MinGW_64_bit-Debug/.qtc_clangd/.cache/clangd/index/ui_add_member.h.C822B6B0FBC8D03E.idx
Binary file not shown.
Binary file added
BIN
+1.41 KB
...1_MinGW_64_bit-Debug/.qtc_clangd/.cache/clangd/index/ui_add_member.h.EFB302619C4E26D6.idx
Binary file not shown.
Binary file modified
BIN
-24 Bytes
(99%)
..._3_1_MinGW_64_bit-Debug/.qtc_clangd/.cache/clangd/index/ui_channel.h.B18555A3BBF9A956.idx
Binary file not shown.
Binary file modified
BIN
+386 Bytes
(140%)
...MinGW_64_bit-Debug/.qtc_clangd/.cache/clangd/index/ui_deletemember.h.72B0DE8AD0FC88B2.idx
Binary file not shown.
Binary file added
BIN
+3.26 KB
...MinGW_64_bit-Debug/.qtc_clangd/.cache/clangd/index/ui_deletemember.h.D91DF9F1962041AA.idx
Binary file not shown.
Binary file added
BIN
+6.03 KB
...1_MinGW_64_bit-Debug/.qtc_clangd/.cache/clangd/index/ui_mainwindow.h.A7347BA7BCD5E30F.idx
Binary file not shown.
Oops, something went wrong.