Fixed edit item
[shopper.git] / src / ui / LabelEntry.h
blob57f91f8f891552ff7462dfa4aad729510415ed1d
1 /* Shopper
2 * Copyright (C) 2008 David Greaves
4 * This software is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public License
6 * as published by the Free Software Foundation; either version 2.1 of
7 * the License, or (at your option) any later version.
9 * This software is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this software; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
17 * 02110-1301 USA
20 #ifndef LABELENTRY_H
21 #define LABELENTRY_H
23 #include "shopper.h" // automake, i8n, gettext
24 #include <QString>
25 #include <QLabel>
26 #include <QLineEdit>
27 #include <QHBoxLayout>
28 #include <QMouseEvent>
30 namespace Shopper
32 // SLabel a label that emits pressed() when clicked
33 class SLabel: public QLabel
35 Q_OBJECT;
36 public:
37 SLabel(QWidget * parent = 0, Qt::WindowFlags f = 0 );
38 SLabel ( const QString & text, QWidget * parent = 0, Qt::WindowFlags f = 0 );
39 void mousePressEvent ( QMouseEvent * event );
40 virtual void setVisible(bool vis);
41 signals:
42 void pressed();
45 // LabelEntry - a label that turns into a textbox when clicked
46 class LabelEntry : public QWidget
48 Q_OBJECT;
49 public:
50 LabelEntry(QWidget *parent = 0);
51 LabelEntry(const QString & label, QWidget *parent = 0);
52 private:
53 void init(); // real constructor
54 public:
55 QString getText();
56 void setAlignment ( Qt::Alignment al );
57 void setText ( const QString & d);
58 virtual void setVisible(bool vis);
59 void setFrameStyle(int i);
60 void setSizePolicy(QSizePolicy::Policy h, QSizePolicy::Policy v);
61 void setSizePolicy(QSizePolicy p);
63 protected:
64 QString data;
65 SLabel *label;
66 QLineEdit *entry;
67 QHBoxLayout layout;
69 public slots:
70 void label_clicked();
71 void entry_finished();
72 signals:
73 void changed();
76 #endif // LABELENTRY_H