kexi
kexicsvwidgets.h
00001 /* This file is part of the KDE project 00002 Copyright (C) 2005 Jaroslaw Staniek <js@iidea.pl> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 * Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef KEXI_CSVWIDGETS_H 00021 #define KEXI_CSVWIDGETS_H 00022 00023 #include <qvaluevector.h> 00024 #include <kcombobox.h> 00025 00026 class KLineEdit; 00027 class KActiveLabel; 00028 class QLabel; 00029 00030 #define KEXICSV_DEFAULT_TEXT_QUOTE "\"" 00031 #define KEXICSV_DEFAULT_FILE_DELIMITER "," 00032 #define KEXICSV_DEFAULT_CLIPBOARD_DELIMITER "\t" 00033 #define KEXICSV_DEFAULT_FILE_DELIMITER_INDEX 0 00034 00036 QStringList csvMimeTypes(); 00037 00041 class KexiCSVInfoLabel : public QWidget 00042 { 00043 public: 00044 /* Sets up a new info label with following parts: 00045 - \a labelText label with text like "Preview of data from file:" 00046 - \a fileName (active) label that can contain a filename or be empty. 00047 If \a setIconForFilename is true, icon will be set using a pixmap get 00048 from a mime type for \a fileName. */ 00049 KexiCSVInfoLabel( const QString& labelText, QWidget* parent ); 00050 00051 void setFileName( const QString& fileName ); 00052 void setLabelText( const QString& text ); 00053 // void setIconForFileName(); 00054 00056 void setIcon(const QString& iconName); 00057 00058 QLabel* leftLabel() const { return m_leftLabel; } 00059 KActiveLabel* fileNameLabel() const { return m_fnameLbl; } 00060 QFrame* separator() const { return m_separator; } 00061 00062 protected: 00063 QLabel *m_leftLabel, *m_iconLbl; 00064 KActiveLabel *m_fnameLbl; 00065 QFrame* m_separator; 00066 }; 00067 00070 class KexiCSVDelimiterWidget : public QWidget 00071 { 00072 Q_OBJECT 00073 00074 public: 00075 KexiCSVDelimiterWidget( bool lineEditOnBottom, QWidget * parent = 0 ); 00076 00077 QString delimiter() const { return m_delimiter; } 00078 void setDelimiter(const QString& delimiter); 00079 00080 signals: 00081 void delimiterChanged(const QString& delimiter); 00082 00083 protected slots: 00085 void slotDelimiterChanged(int idx); 00086 void slotDelimiterChangedInternal(int idx); 00087 void slotDelimiterLineEditTextChanged( const QString & ); 00088 void slotDelimiterLineEditReturnPressed(); 00089 00090 protected: 00091 QString m_delimiter; 00092 QValueVector<QString> m_availableDelimiters; 00093 KComboBox* m_combo; 00094 KLineEdit* m_delimiterEdit; 00095 }; 00096 00099 class KexiCSVTextQuoteComboBox : public KComboBox 00100 { 00101 public: 00102 KexiCSVTextQuoteComboBox( QWidget * parent = 0 ); 00103 00104 QString textQuote() const; 00105 00107 void setTextQuote(const QString& textQuote); 00108 }; 00109 00110 #endif