root/trunk/qt4-gui/src/widgets/infofield.cpp

Revision 5849, 1.6 kB (checked in by flynd, 13 months ago)

Changed timestamps in info dialog to not cut year. Also moved the datetime handling to infofield class.

Line 
1// -*- c-basic-offset: 2 -*-
2/*
3 * This file is part of Licq, an instant messaging client for UNIX.
4 * Copyright (C) 2007 Licq developers
5 *
6 * Licq is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * Licq is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with Licq; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19 */
20
21#include "infofield.h"
22
23#include <QDateTime>
24
25using namespace LicqQtGui;
26/* TRANSLATOR LicqQtGui::InfoField */
27
28InfoField::InfoField(bool ro, QWidget* parent)
29  : QLineEdit(parent)
30{
31  myBaseRo = palette().color(QPalette::Disabled, QPalette::Base);
32  myBaseRw = palette().color(QPalette::Active, QPalette::Base);
33
34  setReadOnly(ro);
35}
36
37void InfoField::setReadOnly(bool ro)
38{
39  QPalette pal(palette());
40  pal.setColor(QPalette::Base, ro ? myBaseRo : myBaseRw);
41  setPalette(pal);
42
43  QLineEdit::setReadOnly(ro);
44}
45
46void InfoField::setText(const char* data)
47{
48  setText(QString::fromLocal8Bit(data));
49}
50
51void InfoField::setText(unsigned long data)
52{
53  setText(QString::number(data));
54}
55
56void InfoField::setDateTime(uint timestamp)
57{
58  if (timestamp == 0)
59    setText(tr("Unknown"));
60  else
61    setText(QDateTime::fromTime_t(timestamp).toString());
62}
Note: See TracBrowser for help on using the browser.