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_FILE_TEXT_QUOTE "\"" 00031 #define KEXICSV_DEFAULT_CLIPBOARD_TEXT_QUOTE "" 00032 #define KEXICSV_DEFAULT_FILE_DELIMITER "," 00033 #define KEXICSV_DEFAULT_CLIPBOARD_DELIMITER "\t" 00034 #define KEXICSV_DEFAULT_FILE_DELIMITER_INDEX 0 00035 00037 QStringList csvMimeTypes(); 00038 00042 class KexiCSVInfoLabel : public QWidget 00043 { 00044 public: 00045 /* Sets up a new info label \a labelText label with text like "Preview of data from file:". 00046 setFileName() can be used to display filename and setCommentAfterFileName() to display 00047 additional comment. 00048 00049 The widget's layout can look like this: 00050 00051 \pre [icon] [labeltext] [filename] [comment] 00052 */ 00053 KexiCSVInfoLabel( const QString& labelText, QWidget* parent ); 00054 00055 void setFileName( const QString& fileName ); 00056 void setLabelText( const QString& text ); 00057 void setCommentText( const QString& text ); 00058 // void setIconForFileName(); 00059 00061 void setIcon(const QString& iconName); 00062 00063 QLabel* leftLabel() const { return m_leftLabel; } 00064 KActiveLabel* fileNameLabel() const { return m_fnameLbl; } 00065 KActiveLabel* commentLabel() const { return m_commentLbl; } 00066 QFrame* separator() const { return m_separator; } 00067 00068 protected: 00069 QLabel *m_leftLabel, *m_iconLbl; 00070 KActiveLabel *m_fnameLbl, *m_commentLbl; 00071 QFrame* m_separator; 00072 }; 00073 00076 class KexiCSVDelimiterWidget : public QWidget 00077 { 00078 Q_OBJECT 00079 00080 public: 00081 KexiCSVDelimiterWidget( bool lineEditOnBottom, QWidget * parent = 0 ); 00082 00083 QString delimiter() const { return m_delimiter; } 00084 void setDelimiter(const QString& delimiter); 00085 00086 signals: 00087 void delimiterChanged(const QString& delimiter); 00088 00089 protected slots: 00091 void slotDelimiterChanged(int idx); 00092 void slotDelimiterChangedInternal(int idx); 00093 void slotDelimiterLineEditTextChanged( const QString & ); 00094 void slotDelimiterLineEditReturnPressed(); 00095 00096 protected: 00097 QString m_delimiter; 00098 QValueVector<QString> m_availableDelimiters; 00099 KComboBox* m_combo; 00100 KLineEdit* m_delimiterEdit; 00101 }; 00102 00105 class KexiCSVTextQuoteComboBox : public KComboBox 00106 { 00107 public: 00108 KexiCSVTextQuoteComboBox( QWidget * parent = 0 ); 00109 00110 QString textQuote() const; 00111 00113 void setTextQuote(const QString& textQuote); 00114 }; 00115 00116 #endif