Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Copyright (c) 2010, Stijn Leenknegt
- All rights reserved.
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- * Neither the name of the KHL nor the
- names of its contributors may be used to endorse or promote products
- derived from this software without specific prior written permission.
- THIS SOFTWARE IS PROVIDED BY Stijn Leenknegt ''AS IS'' AND ANY
- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- DISCLAIMED. IN NO EVENT SHALL Stijn Leenknegt BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
- #include "entrywidget.h"
- #include <QGraphicsGridLayout>
- #include <Plasma/Label>
- #include <Plasma/Separator>
- #include "uurrooster.h"
- EntryWidget::EntryWidget(const uurrooster_entry &entry, bool bold, QGraphicsItem* parent, Qt::WindowFlags wFlags): QGraphicsWidget(parent, wFlags)
- {
- QGraphicsGridLayout *layout = new QGraphicsGridLayout();
- Plasma::Label *lblTijd = new Plasma::Label();
- if(bold) {
- lblTijd->setText("<b><font color=\"" + entry.kleur + "\">" + entry.starttijd.toString("hh:mm") + "<br />" + entry.eindtijd.toString("hh:mm") + "</font></b>");
- } else {
- lblTijd->setText("<font color=\"" + entry.kleur + "\">" + entry.starttijd.toString("hh:mm") + "<br />" + entry.eindtijd.toString("hh:mm") + "</font>");
- }
- Plasma::Separator *sep = new Plasma::Separator();
- sep->setOrientation(Qt::Vertical);
- Plasma::Label *lblContent = new Plasma::Label();
- if(bold) {
- lblContent->setText("<b><font color=\"" + entry.kleur + "\" size=\"4\">" + entry.beschrijving + "</font></b>");
- } else {
- lblContent->setText("<font color=\"" + entry.kleur + "\" size=\"4\">" + entry.beschrijving + "</font>");
- }
- Plasma::Separator *sep2 = new Plasma::Separator();
- sep2->setOrientation(Qt::Vertical);
- Plasma::Label *lblLokaal = new Plasma::Label();
- if(bold) {
- lblLokaal->setText("<b><em><font color=\"" + entry.kleur + "\" size=\"2\">" + entry.lokaal + "</font></em></b>");
- } else {
- lblLokaal->setText("<em><font color=\"" + entry.kleur + "\" size=\"2\">" + entry.lokaal + "</font></em>");
- }
- layout->addItem(lblTijd, 0, 0);
- layout->addItem(sep, 0, 1);
- layout->addItem(lblContent, 0, 2);
- layout->addItem(sep2, 0, 3);
- layout->addItem(lblLokaal, 0, 4);
- layout->setColumnFixedWidth(0, 40);
- layout->setColumnFixedWidth(4, 100);
- layout->setRowFixedHeight(0, 50);
- //align
- layout->setColumnAlignment(0, Qt::AlignLeft);
- layout->setColumnAlignment(1, Qt::AlignLeft);
- layout->setColumnAlignment(2, Qt::AlignLeft);
- layout->setColumnAlignment(3, Qt::AlignRight);
- layout->setColumnAlignment(4, Qt::AlignLeft);
- setLayout(layout);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement