2018-11-11 10:57:05 -05:00
|
|
|
/*******************************************************************************
|
|
|
|
* gui/common/LineEditClear.h *
|
|
|
|
* *
|
|
|
|
* Copyright (C) 2012, Retroshare Team <retroshare.project@gmail.com> *
|
|
|
|
* *
|
|
|
|
* This program is free software: you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU Affero General Public License as *
|
|
|
|
* published by the Free Software Foundation, either version 3 of the *
|
|
|
|
* License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU Affero General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU Affero General Public License *
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
|
|
|
* *
|
|
|
|
*******************************************************************************/
|
2012-04-05 17:03:03 -04:00
|
|
|
|
|
|
|
#ifndef LINEEDITCLEAR_H
|
|
|
|
#define LINEEDITCLEAR_H
|
|
|
|
|
|
|
|
#include <QLineEdit>
|
2012-10-29 06:59:26 -04:00
|
|
|
#include <QMap>
|
2012-04-05 17:03:03 -04:00
|
|
|
|
|
|
|
class QToolButton;
|
2012-10-29 06:59:26 -04:00
|
|
|
class QActionGroup;
|
2017-07-19 13:39:21 -04:00
|
|
|
//#if QT_VERSION < 0x040700
|
|
|
|
#if QT_VERSION < 0x050000//PlaceHolder text only shown when not have focus in Qt4
|
2012-10-29 06:59:26 -04:00
|
|
|
class QLabel;
|
|
|
|
#endif
|
2012-04-05 17:03:03 -04:00
|
|
|
|
|
|
|
class LineEditClear : public QLineEdit
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
LineEditClear(QWidget *parent = 0);
|
|
|
|
|
2012-10-29 06:59:26 -04:00
|
|
|
void addFilter(const QIcon &icon, const QString &text, int id, const QString &description = "");
|
|
|
|
void setCurrentFilter(int id);
|
|
|
|
int currentFilter();
|
|
|
|
|
2012-11-05 19:28:11 -05:00
|
|
|
void showFilterIcon();
|
|
|
|
|
2012-10-29 06:59:26 -04:00
|
|
|
//#if QT_VERSION < 0x040700
|
|
|
|
// for Qt version with setPlaceholderText too to set the tooltip of the lineedit
|
|
|
|
void setPlaceholderText(const QString &text);
|
|
|
|
//#endif
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void filterChanged(int id);
|
|
|
|
|
2012-04-05 17:03:03 -04:00
|
|
|
protected:
|
|
|
|
void resizeEvent(QResizeEvent *);
|
2017-07-19 13:39:21 -04:00
|
|
|
//#if QT_VERSION < 0x040700
|
|
|
|
#if 0//PlaceHolder text only shown when not have focus in Qt4
|
2012-10-29 06:59:26 -04:00
|
|
|
void focusInEvent(QFocusEvent *event);
|
|
|
|
void focusOutEvent(QFocusEvent *event);
|
|
|
|
#endif
|
|
|
|
void reposButtons();
|
|
|
|
void activateAction(QAction *action);
|
2012-04-05 17:03:03 -04:00
|
|
|
|
|
|
|
private slots:
|
2012-10-29 06:59:26 -04:00
|
|
|
void updateClearButton(const QString &text);
|
|
|
|
void filterTriggered(QAction *action);
|
2012-04-05 17:03:03 -04:00
|
|
|
|
|
|
|
private:
|
2012-10-29 06:59:26 -04:00
|
|
|
QToolButton *mClearButton;
|
|
|
|
QToolButton *mFilterButton;
|
|
|
|
QActionGroup *mActionGroup;
|
|
|
|
QMap<int, QString> mDescription;
|
|
|
|
|
2017-07-19 13:39:21 -04:00
|
|
|
//#if QT_VERSION < 0x040700
|
|
|
|
#if QT_VERSION < 0x050000//PlaceHolder text only shown when not have focus in Qt4
|
2012-10-29 06:59:26 -04:00
|
|
|
QLabel *mFilterLabel;
|
|
|
|
#endif
|
2012-04-05 17:03:03 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // LINEEDITCLEAR_H
|