Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.75 KB | None | 0 0
  1. /*
  2.     Copyright (c) 2010, Stijn Leenknegt
  3.     All rights reserved.
  4.  
  5.     Redistribution and use in source and binary forms, with or without
  6.     modification, are permitted provided that the following conditions are met:
  7.         * Redistributions of source code must retain the above copyright
  8.         notice, this list of conditions and the following disclaimer.
  9.         * Redistributions in binary form must reproduce the above copyright
  10.         notice, this list of conditions and the following disclaimer in the
  11.         documentation and/or other materials provided with the distribution.
  12.         * Neither the name of the KHL nor the
  13.         names of its contributors may be used to endorse or promote products
  14.         derived from this software without specific prior written permission.
  15.  
  16.     THIS SOFTWARE IS PROVIDED BY Stijn Leenknegt ''AS IS'' AND ANY
  17.     EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18.     WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19.     DISCLAIMED. IN NO EVENT SHALL Stijn Leenknegt BE LIABLE FOR ANY
  20.     DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21.     (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22.     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23.     ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24.     (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25.     SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26.  
  27. */
  28.  
  29. #include "entrywidget.h"
  30.  
  31. #include <QGraphicsGridLayout>
  32. #include <Plasma/Label>
  33. #include <Plasma/Separator>
  34.  
  35. #include "uurrooster.h"
  36.  
  37.  
  38. EntryWidget::EntryWidget(const uurrooster_entry &entry, bool bold, QGraphicsItem* parent, Qt::WindowFlags wFlags): QGraphicsWidget(parent, wFlags)
  39. {
  40.     QGraphicsGridLayout *layout = new QGraphicsGridLayout();
  41.    
  42.     Plasma::Label *lblTijd = new Plasma::Label();
  43.     if(bold) {
  44.       lblTijd->setText("<b><font color=\"" + entry.kleur + "\">" + entry.starttijd.toString("hh:mm") + "<br />" + entry.eindtijd.toString("hh:mm") + "</font></b>");
  45.     } else {
  46.       lblTijd->setText("<font color=\"" + entry.kleur + "\">" + entry.starttijd.toString("hh:mm") + "<br />" + entry.eindtijd.toString("hh:mm") + "</font>");
  47.     }
  48.    
  49.     Plasma::Separator *sep = new Plasma::Separator();
  50.     sep->setOrientation(Qt::Vertical);
  51.    
  52.     Plasma::Label *lblContent = new Plasma::Label();
  53.     if(bold) {
  54.       lblContent->setText("<b><font color=\"" + entry.kleur + "\" size=\"4\">" + entry.beschrijving + "</font></b>");
  55.     } else {
  56.       lblContent->setText("<font color=\"" + entry.kleur + "\" size=\"4\">" + entry.beschrijving + "</font>");
  57.     }
  58.    
  59.     Plasma::Separator *sep2 = new Plasma::Separator();
  60.     sep2->setOrientation(Qt::Vertical);
  61.    
  62.     Plasma::Label *lblLokaal = new Plasma::Label();
  63.     if(bold) {
  64.       lblLokaal->setText("<b><em><font color=\"" + entry.kleur + "\" size=\"2\">" + entry.lokaal + "</font></em></b>");
  65.     } else {
  66.       lblLokaal->setText("<em><font color=\"" + entry.kleur + "\" size=\"2\">" + entry.lokaal + "</font></em>");
  67.     }
  68.    
  69.     layout->addItem(lblTijd, 0, 0);
  70.     layout->addItem(sep, 0, 1);
  71.     layout->addItem(lblContent, 0, 2);
  72.     layout->addItem(sep2, 0, 3);
  73.     layout->addItem(lblLokaal, 0, 4);
  74.    
  75.     layout->setColumnFixedWidth(0, 40);
  76.     layout->setColumnFixedWidth(4, 100);
  77.     layout->setRowFixedHeight(0, 50);
  78.     //align
  79.     layout->setColumnAlignment(0, Qt::AlignLeft);
  80.     layout->setColumnAlignment(1, Qt::AlignLeft);
  81.     layout->setColumnAlignment(2, Qt::AlignLeft);
  82.     layout->setColumnAlignment(3, Qt::AlignRight);
  83.     layout->setColumnAlignment(4, Qt::AlignLeft);
  84.    
  85.     setLayout(layout);
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement