tdefilemetainfowidget.h
00001 /* This file is part of the KDE libraries 00002 Copyright (C) 2001,2002 Rolf Magnus <ramagnus@kde.org> 00003 00004 library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License version 2 as published by the Free Software Foundation. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 along with this library; see the file COPYING.LIB. If not, write to 00015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00016 Boston, MA 02110-1301, USA. 00017 00018 */ 00019 00020 #ifndef __TDEFILEMETAINFOWIDGET_H__ 00021 #define __TDEFILEMETAINFOWIDGET_H__ 00022 00023 #include <tqwidget.h> 00024 #include <tqvariant.h> 00025 #include <tdefilemetainfo.h> 00026 00030 class TDEIO_EXPORT KFileMetaInfoWidget: public TQWidget 00031 { 00032 Q_OBJECT 00033 public: 00034 enum Mode 00035 { 00036 ReadOnly = 1, 00037 ReadWrite = 0, 00038 Reserve = 0xff 00039 }; 00040 00041 KFileMetaInfoWidget(KFileMetaInfoItem item, TQValidator* val = 0, 00042 TQWidget* parent = 0, const char* name = 0); 00043 00044 KFileMetaInfoWidget(KFileMetaInfoItem item, Mode mode, TQValidator* val = 0, 00045 TQWidget* parent = 0, const char* name = 0); 00046 00047 virtual ~KFileMetaInfoWidget(); 00048 00049 bool apply() 00050 { 00051 return m_item.isEditable() && m_item.setValue(m_value); 00052 } 00053 00054 void setValue(const TQVariant& value) { m_value = value; } 00055 TQVariant value()const { return m_value; } 00056 TQValidator* validator() const { return m_validator; } 00057 KFileMetaInfoItem item()const { return m_item; } 00058 00059 signals: 00060 void valueChanged(const TQVariant& value); 00061 00062 protected: 00063 void reparentValidator(TQWidget *widget, TQValidator *validator); 00064 virtual TQWidget* makeWidget(); 00065 00066 TQWidget* makeBoolWidget(); 00067 TQWidget* makeIntWidget(); 00068 TQWidget* makeDoubleWidget(); 00069 TQWidget* makeStringWidget(); 00070 TQWidget* makeDateWidget(); 00071 TQWidget* makeTimeWidget(); 00072 TQWidget* makeDateTimeWidget(); 00073 00074 private slots: 00075 void slotChanged(bool value); 00076 void slotChanged(int value); 00077 void slotChanged(double value); 00078 void slotComboChanged(const TQString &value); 00079 void slotLineEditChanged(const TQString& value); 00080 void slotMultiLineEditChanged(); 00081 void slotDateChanged(const TQDate& value); 00082 void slotTimeChanged(const TQTime& value); 00083 void slotDateTimeChanged(const TQDateTime& value); 00084 00085 private: 00086 void init(KFileMetaInfoItem item, Mode mode); 00087 00088 TQVariant m_value; // the value will be saved here until apply() is called 00089 KFileMetaInfoItem m_item; 00090 TQWidget* m_widget; 00091 TQValidator* m_validator; 00092 bool m_dirty : 1; 00093 }; 00094 00095 #endif