Newer
Older
Kevin Whitaker
committed
/*
* Copyright (C) 2017 Kevin Whitaker <eyecreate@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#ifndef REQUESTINTERFACE_H
#define REQUESTINTERFACE_H
#include <Wt/WContainerWidget>
#include "../WebInterface.h"
#include <Wt/WPushButton>
#include <Wt/WHBoxLayout>
#include <Wt/WVBoxLayout>
#include <Wt/WGridLayout>
#include <Wt/WLineEdit>
#include "TrackDetails.h"
Kevin Whitaker
committed
class RequestInterface : public Wt::WContainerWidget
{
public:
RequestInterface(WebInterface* app);
WebInterface* app;
Kevin Whitaker
committed
class RequestItem : public Wt::WContainerWidget
{
public:
TrackDetails* track;
Wt::WHBoxLayout* layout;
Wt::WPushButton* voteBtn;
RequestInterface* parent;
void requestClicked() {
this->parent->trackRequestClicked(track->extractTrackFromDetails());
};
RequestItem(RequestInterface* parent, AudioTrack track) {
this->track = new TrackDetails();
this->track->updateWithTrackDetails(track);
Kevin Whitaker
committed
this->track->changeBackgroundColor(Wt::WColor("gainsboro"));
layout = new Wt::WHBoxLayout();
voteBtn = new Wt::WPushButton();
this->parent = parent;
this->setLayout(layout);
voteBtn->setTextFormat(Wt::XHTMLText);
voteBtn->decorationStyle().font().setFamily(Wt::WFont::Default,"FontAwesome");
voteBtn->setText("");
layout->addWidget(this->track,1,Wt::AlignmentFlag::AlignMiddle | Wt::AlignmentFlag::AlignLeft);
layout->addWidget(voteBtn,0,Wt::AlignmentFlag::AlignMiddle | Wt::AlignmentFlag::AlignRight);
voteBtn->clicked().connect(this, &RequestItem::requestClicked);
};
Kevin Whitaker
committed
~RequestItem(){
this->clear();
}
};
Wt::WVBoxLayout* mainLayout;
Kevin Whitaker
committed
Wt::WContainerWidget* searchHeader;
Wt::WHBoxLayout* searchLayout;
Wt::WLineEdit* searchBox;
Wt::WPushButton* searchBtn;
Kevin Whitaker
committed
Wt::WContainerWidget* resultBody;
Wt::WGridLayout* resultLayout;
Kevin Whitaker
committed
std::list<RequestItem*> foundItems;
void trackRequestClicked(AudioTrack track);
Kevin Whitaker
committed
void searchClicked();
Kevin Whitaker
committed
int getRequestCountForUser(User user);
void updateRequestButtonState();
Kevin Whitaker
committed
};
#endif // REQUESTINTERFACE_H