MainWindow::~MainWindow() { clearPosts(); delete welcomeLabel; delete aboutButton; // ADD YOUR CODE HERE // Delete the quit button pointer delete quitButton; }
void MainWindow::setupPosts(std::vector<Post*> posts) { clearPosts(); // ADD YOUR CODE HERE // Take in the vector of posts and for each of them: // 1. create a PostWidget // 2. add the PostWidget to the correct layout // 3. add the PostWidget to the vector so that we can delete the pointers later std::vector<Post*>::iterator it; for(it = posts.begin(); it != posts.end(); ++it) { PostWidget* pw = new PostWidget(*it); postsLayout->addWidget(pw); postWidgets.push_back(pw); } }
Gui_Groups::Gui_Groups(LinqClient* c, QWidget* parent) : QGridLayout(parent), _client(c) { Gui_Avatar* portrait = new Gui_Avatar(QString::fromStdString(_client->avatar())); QPushButton* create = new QPushButton("CREATE"); QLabel* title = new QLabel("NEW GROUP"); showgrp = new Gui_DisplayInfo; newpost = new QTextEdit; newgrp = new QLineEdit; search = new QLineEdit; newbox = new QGroupBox; memlbl = new QLabel("Members"); memlbl->setMaximumSize(80,20); grpname = new QLineEdit; newgrplayout = new QFormLayout; newgrplayout->setSpacing(15); newgrplayout->addRow(title); newgrplayout->addRow("Group name:", grpname); newgrplayout->addRow("Group description:", newgrp); newgrplayout->addRow(create); newbox->setLayout(newgrplayout); if(_client->level() < executive) newbox->hide(); search->setPlaceholderText("Search group.."); search->hide(); connect(search, SIGNAL(returnPressed()), this, SLOT(searchGroup())); post = new QPushButton("POST"); grplist = new QListWidget; memlist = new QListWidget; QLabel* grplbl = new QLabel("Groups"); grplbl->setMaximumSize(120,20); createGroups(); QFormLayout* frm = new QFormLayout; mbuttons[0] = new QPushButton; mbuttons[0]->setIcon(QPixmap("img/document185.png")); mbuttons[0]->setToolTip("New group"); mbuttons[1] = new QPushButton; mbuttons[1]->setIcon(QPixmap("img/cross108.png")); mbuttons[1]->setToolTip("Delete group"); mbuttons[2] = new QPushButton; mbuttons[2]->setIcon(QPixmap("img/mop2.png")); mbuttons[2]->setToolTip("Delete all posts"); mbuttons[3] = new QPushButton; mbuttons[3]->setIcon(QPixmap("img/exit6.png")); mbuttons[3]->setToolTip("Leave this group"); mbuttons[4] = new QPushButton; mbuttons[4]->setIcon(QPixmap("img/enter3.png")); mbuttons[4]->setToolTip("Join this group"); frm->addRow(mbuttons[0]); frm->addRow(mbuttons[3]); frm->addRow(mbuttons[4]); frm->addRow(mbuttons[1]); frm->addRow(mbuttons[2]); connect(mbuttons[0], SIGNAL(clicked()), this, SLOT(showNewGroup())); connect(create, SIGNAL(clicked()), this, SLOT(newGroup())); connect(mbuttons[1], SIGNAL(clicked()), this, SLOT(deleteGroup())); connect(mbuttons[2], SIGNAL(clicked()), this, SLOT(clearPosts())); connect(mbuttons[3], SIGNAL(clicked()), this, SLOT(leaveGroup())); connect(mbuttons[4], SIGNAL(clicked()), this, SLOT(addGroup())); mbuttons[0]->hide(); mbuttons[1]->hide(); mbuttons[2]->hide(); mbuttons[3]->hide(); mbuttons[4]->hide(); if(_client->level() >= executive) mbuttons[0]->show(); tbar = new QToolBar; tbuttons[0] = new QToolButton(tbar); tbuttons[0]->setIcon(QPixmap("img/cross108.png")); tbar->addWidget(tbuttons[0]); newpost->setStyleSheet("background: #1a1a1a; font-weight:400"); newpost->setPlaceholderText("Insert new post into this group."); newpost->hide(); post->hide(); showgrp->hide(); memlbl->hide(); memlist->hide(); memlist->setContextMenuPolicy(Qt::CustomContextMenu); connect(memlist, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(memListMenu(const QPoint&))); addWidget(newbox, 0, 1, 1, 1); addWidget(portrait, 0, 0, 1, 1, Qt::AlignTop); addWidget(showgrp, 0, 1, 3, 1); addLayout(frm, 0, 2, 1, 1, Qt::AlignRight); addWidget(newpost, 3, 1, 2, 3); addWidget(post, 5, 4, 1, 1, Qt::AlignRight); addWidget(grplbl, 1, 0, 1, 1); addWidget(grplist, 2, 0, 1, 1); addWidget(memlbl, 3, 0, 1, 1); addWidget(memlist, 4, 0, 1, 1); addWidget(search, 5, 0, 1, 1); setRowStretch(0, 0); setRowStretch(1, 10); setColumnStretch(0, 1); setColumnStretch(1, 5); connect(grplist, SIGNAL(clicked(QModelIndex)), this, SLOT(showGroup())); connect(post, SIGNAL(clicked()), this, SLOT(sendPost())); connect(this, SIGNAL(created(int)), this, SLOT(refresh(int))); }