1 /*
2  * This file is part of Licq, an instant messaging client for UNIX.
3  * Copyright (C) 1999-2009, 2013 Licq developers <licq-dev@googlegroups.com>
4  *
5  * Licq is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * Licq is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with Licq; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18  */
19 
20 #ifndef INFOFIELD_H
21 #define INFOFIELD_H
22 
23 #include <QColor>
24 #include <QLineEdit>
25 
26 
27 namespace LicqQtGui
28 {
29 
30 /**
31  * LineEdit widget with a few convenience functions added
32  */
33 class InfoField : public QLineEdit
34 {
35   Q_OBJECT
36 
37 public:
38   /**
39    * Constructor
40    *
41    * @param ro Initial state of read only property
42    * @param parent Parent widget
43    */
44   InfoField(bool ro = false, QWidget* parent = NULL);
45 
46   /**
47    * Set read only property
48    *
49    * @param ro False to make widget editable
50    */
51   void setReadOnly(bool ro);
52 
53   /**
54    * Set field text from char string
55    *
56    * @param data New value for field
57    */
58   void setText(const char* data);
59 
60   /**
61    * Set field text from numeral
62    *
63    * @param data New value for field
64    */
65   void setText(unsigned long data);
66 
67   /**
68    * Set text
69    *
70    * @param text New value for field
71    */
72   void setText(QString text);
73 
74   /**
75    * Set field to a timestamp
76    *
77    * @param timestamp Timestamp in UTC to set
78    */
79   void setDateTime(uint timestamp);
80 
81 protected:
82   /**
83    * A key was pressed, overloaded to get keyboard shortcuts
84    *
85    * @param event Key event
86    */
87   virtual void keyPressEvent(QKeyEvent* event);
88 
89 private:
90   QColor myBaseRo;
91   QColor myBaseRw;
92 };
93 
94 } // namespace LicqQtGui
95 
96 #endif
97