File indexing completed on 2023-05-30 10:45:25

0001 /*
0002     SPDX-FileCopyrightText: 2009-2011 Peter Hedlund <peter.hedlund@kdemail.net>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #ifndef KWQCARDSCENE_H
0007 #define KWQCARDSCENE_H
0008 
0009 #include <QGraphicsLineItem>
0010 #include <QGraphicsPixmapItem>
0011 #include <QGraphicsRectItem>
0012 #include <QGraphicsScene>
0013 #include <QGraphicsSimpleTextItem>
0014 #include <QGraphicsTextItem>
0015 
0016 #include "kwqpixmapitem.h"
0017 
0018 class KWQCardScene : public QGraphicsScene
0019 {
0020 Q_OBJECT
0021 public:
0022 
0023     explicit KWQCardScene(QObject *parent = nullptr);
0024 
0025     /**
0026     * The smallest the view can be when 'auto-zoom' is off
0027     * @return the minimum size the view should be
0028     */
0029     const QSize minimumSizeHint() const;
0030 
0031     void setIdentifier(const QString &);
0032     void setText(const QString &);
0033     void setTextColor(const QColor &);
0034     void setTextFont(const QFont &);
0035     void setCardColor(const QColor &);
0036     void setFrameColor(const QColor &);
0037     void setImage(const QPixmap &);
0038 
0039 Q_SIGNALS:
0040     void cardClicked();
0041 
0042 protected:
0043     void mouseReleaseEvent(QGraphicsSceneMouseEvent *) override;
0044 
0045 private:
0046     QGraphicsRectItem *m_card;
0047     QGraphicsLineItem *m_line;
0048     QGraphicsSimpleTextItem *m_identifier;
0049     QGraphicsRectItem *m_textArea;
0050     QGraphicsTextItem *m_text;
0051     KWQPixmapItem *m_pixmap;
0052 
0053     void realign(bool );
0054     void repositionText();
0055 };
0056 
0057 #endif // KWQCARDSCENE_H