source: projects/punch-card-project/trunk/punch-card-editor/src/qpunchcard/widget.h @ 58

Last change on this file since 58 was 58, checked in by sven, 14 years ago

GUI improvements (card widget).

  • Tested the QItemView framework in the CardEditor class. Quite nice features (all rotating/scaling/etc. work already implemented), but a strange viewport bug didn't make this fun at all... so removed again (commented out)
  • Codec:

Codec classes are now supposed to be implicit shared objects

(some kind of useless since the next entry:)

Codec Factory know performs global caching of codecs
Codecs are therefore supposed to be used as Codec* anywhere.

  • Widget:

Now has a local Codec => can display a label
Label will be rendered with some dot matrix Open Type font

(looks quite realistic)

TODO: setting codecs dynamically by focus entry/exit on

text editors (with only one text editor => always set codec like in
text editor)

Have made tests with pixmaps as punch card background,

works damned well (but one card background needs about uncompressed
5MB RAM...).

Storing card vendor names is one core feature of Douglas Jones' Punch
card format. I thought about a property editor for punch cards
(as another deck widget) for editing all card properties proposed by
Douglas Jones, but that's a lot of work that isn't really useful.
Perhaps I will just give some card backgrounds for choice in a menu,
would be pretty easy and impressive, anyway.

-- sven @ workstation

File size: 2.1 KB
Line 
1#ifndef WIDGET_H
2#define WIDGET_H
3
4namespace QPunchCard {
5        class CardWidget;
6}
7
8#include "qpunchcard/card.h"
9#include "text/codec.h"
10
11#include <QWidget>
12#include <QPointer>
13#include <QFlags>
14#include <QtDebug>
15#include <QPixmap>
16
17namespace QPunchCard {
18
19class CardWidget : public QWidget {
20        Q_OBJECT
21        //Q_ENUMS(Quality);
22        //Q_PROPERTY(Quality quality READ quality WRITE setQuality);
23        // geht irgendwie nicht... machen wirs halt erst mal so (siehe public)
24
25        const Card* card;
26        //QPointer<Card> card; // ### something like Card* const card;
27        const Codec* codec;
28
29public:
30        enum Quality { HighQuality, ThumbnailQuality };
31        Quality _quality;
32        enum Editable { Readable, Hoverable, Writable };
33        Editable _editable;
34
35        /*
36        enum ElementVisibility {
37                Default = 0x00,
38                ShowNotPunchedHoles = 0x01
39        };
40        Q_DECLARE_FLAGS(_show_elements, ElementVisibility);
41        */
42
43        QPixmap background_picture;
44
45        CardWidget(QWidget * parent = 0, Qt::WFlags f = 0);
46        CardWidget(const Card* card, QWidget * parent = 0, Qt::WFlags f = 0) : card(card) { CardWidget(parent, f); }
47
48        // card handling
49        void setCard(const Card* card) { this->card = card; }
50        void unsetCard() { card = 0; }
51        bool hasCard() { return card != 0; }
52//      void setCard(File* file, int index) { this->card = &( file->operator[](index) ); }
53        const Card* getCard() const { return card; }
54
55        // size hints
56        virtual QSize minimumSizeHint() const;
57        virtual QSize sizeHint() const;
58        virtual int heightForWidth(int i) const;
59
60        // Quality issues (Property)
61        void setQuality(Quality quality) { _quality = quality; }
62        Quality quality() const { return _quality; }
63
64        // Editable issues
65        void setEditable(Editable editable) { _editable = editable; }
66        Editable editable() const { return _editable; }
67
68        // View issues
69
70
71        // text related things
72        const Codec* getCodec() const { return codec; }
73
74        ~CardWidget() {};
75
76public slots:
77        void setCodec(const Codec* codec) { this->codec = codec; }
78        void clearCodec() { setCodec(0); }
79
80protected:
81        void paintEvent(QPaintEvent *event);
82};
83
84//Q_DECLARE_OPERATORS_FOR_FLAGS(CardWidget::ElementVisibility);
85
86QDebug operator<<(QDebug dbg, const CardWidget &c);
87
88
89}; // namespace
90#endif // WIDGET_H
Note: See TracBrowser for help on using the repository browser.
© 2008 - 2013 technikum29 • Sven Köppel • Some rights reserved
Powered by Trac
Expect where otherwise noted, content on this site is licensed under a Creative Commons 3.0 License