-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin.cpp
130 lines (116 loc) · 3.59 KB
/
admin.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#include "admin.h"
#include "ui_admin.h"
#include "Global.h"
#include "widget_user.h"
#include "edituser.h"
#include "add_to_cart.h"
#include "login.h"
#include "widget_transactions.h"
QVector<int> Admin::vec_id_kala;
Admin::Admin(int cons,QWidget *parent) :
QDialog(parent),
ui(new Ui::Admin)
{
ui->setupUi(this);
this->setFixedSize(1241,688);
setWindowFlags(Qt::Window | Qt::FramelessWindowHint);
setIndex_vector(cons);
refresh();
}
Admin::~Admin()
{
delete ui;
}
void Admin::show_item()
{
if(ui->listWidget_user->count()>0)
{
ui->listWidget_user->clear();
}
for(int i=0;i<Global::vec_person.size();i++)
{
QListWidgetItem *m_ulitems = new QListWidgetItem;
widget_user *m = new widget_user;
m->set(Global::vec_person[i].get_user_name());
ui->listWidget_user->addItem(m_ulitems);
m_ulitems->setSizeHint(QSize(291,53));
ui->listWidget_user->setItemWidget(m_ulitems,m);
}
}
void Admin::refresh()
{
Global::load_all();
ui->listWidget_Transactions->clear();
ui->listWidget_commodity->clear();
ui->listWidget_user->clear();
for(int i=0;i<Global::vec_person.size();i++)
{
QListWidgetItem *m_ulitems = new QListWidgetItem;
widget_user *m = new widget_user;
m->set(Global::vec_person[i].get_user_name());
ui->listWidget_user->addItem(m_ulitems);
m_ulitems->setSizeHint(QSize(291,53));
ui->listWidget_user->setItemWidget(m_ulitems,m);
}
for(int i=0;i<Global::vec_article_cloths.size();i++)
{
vec_id_kala.push_back(Global::vec_article_cloths[i].get_id());
QString o=Global::vec_article_cloths[i].get_name()+"\t\t"+Global::vec_article_cloths[i].get_seller_username();
QListWidgetItem *m_ulitems = new QListWidgetItem(o);
ui->listWidget_commodity->addItem(m_ulitems);
}
for(int i=0;i<Global::vec_article_sporting_goods.size();i++)
{
vec_id_kala.push_back(Global::vec_article_sporting_goods[i].get_id());
QString o=Global::vec_article_sporting_goods[i].get_name()+"\t\t"+Global::vec_article_sporting_goods[i].get_seller_username();
QListWidgetItem *m_ulitems = new QListWidgetItem(o);
ui->listWidget_commodity->addItem(m_ulitems);
}
for(int i=0;i<Global::vec_tran.size();i++)
{
QListWidgetItem *m_ulitems = new QListWidgetItem;
widget_transactions *m = new widget_transactions;
m->set(Global::vec_tran[i].first.first,Global::vec_tran[i].first.second,Global::vec_tran[i].second.first , Global::vec_tran[i].second.second);
ui->listWidget_Transactions->addItem(m_ulitems);
m_ulitems->setSizeHint(QSize(420,109));
ui->listWidget_Transactions->setItemWidget(m_ulitems,m);
}
}
void Admin::on_listWidget_user_itemDoubleClicked(QListWidgetItem *item)
{
int ind=ui->listWidget_user->currentRow();
//EditUser
EditUser *x = new EditUser(this);
x->set(ind);
x->setIndex_vector(index_vector);
x->show();
refresh();
}
void Admin::on_listWidget_commodity_itemDoubleClicked(QListWidgetItem *item)
{
int ind=ui->listWidget_commodity->currentRow();
add_to_cart *x=new add_to_cart;
x->set(vec_id_kala[ind]);
x->setIndex_vector(index_vector);
x->admin();
x->show();
this->close();
}
void Admin::on_pushButton_log_out_clicked()
{
this->close();
// login *x=new login();
// x->show();
}
void Admin::on_pushButton_clicked()
{
refresh();
}
int Admin::getIndex_vector() const
{
return index_vector;
}
void Admin::setIndex_vector(int newIndex_vector)
{
index_vector = newIndex_vector;
}