File indexing completed on 2024-05-05 04:49:25

0001 /****************************************************************************************
0002  * Copyright (c) 2009 Casey Link <unnamedrambler@gmail.com>                             *
0003  *                                                                                      *
0004  * This program is free software; you can redistribute it and/or modify it under        *
0005  * the terms of the GNU General Public License as published by the Free Software        *
0006  * Foundation; either version 2 of the License, or (at your option) any later           *
0007  * version.                                                                             *
0008  *                                                                                      *
0009  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0010  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0011  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0012  *                                                                                      *
0013  * You should have received a copy of the GNU General Public License along with         *
0014  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0015  ****************************************************************************************/
0016 
0017 #ifndef BOOKMARKPOPUP_H
0018 #define BOOKMARKPOPUP_H
0019 
0020 #include <QLineEdit>
0021 #include <QPaintEvent>
0022 #include <QTimer>
0023 #include <QWidget>
0024 
0025 #include <QIcon>
0026 
0027 class BookmarkTriangle;
0028 
0029 class BookmarkPopup : public QWidget
0030 {
0031     Q_OBJECT
0032 
0033 public:
0034     explicit BookmarkPopup ( QWidget* parent, const QString &label, BookmarkTriangle* triangle );
0035 
0036     QSize sizeHint () const override;
0037     virtual QSizePolicy sizePolicy () const;
0038     QSize minimumSizeHint () const override;
0039 
0040     void mouseReleaseEvent ( QMouseEvent * event ) override;
0041     void mouseMoveEvent ( QMouseEvent * event ) override;
0042     void enterEvent ( QEvent* ) override;
0043     void leaveEvent ( QEvent* ) override;
0044 
0045     virtual void displayNeeded ( bool value );
0046 
0047 protected:
0048 
0049     void paintEvent ( QPaintEvent* event ) override;
0050 
0051 protected Q_SLOTS:
0052     virtual void editValueChanged();
0053     virtual void hideTimerAction();
0054 
0055 private:
0056 
0057     bool isOverDeleteIcon ( QPoint arg1 );
0058     bool isOverTitleLabel ( QPoint arg1 );
0059 
0060     void adjustWidth ();
0061     void startHideTimer ();
0062 
0063     QTimer *m_timer;
0064     QString m_label;
0065     QIcon m_deleteIcon;
0066     QRect m_deleteIconRect;
0067     QLineEdit *m_edit;
0068     int m_width;
0069     BookmarkTriangle *m_triangle;
0070     int m_height;
0071     int m_lineHeight;
0072 
0073     bool m_displayNeeded;
0074     bool m_hasMouseOver;
0075     bool m_overDelete;
0076     bool m_isEditMode;
0077 
0078 
0079 };
0080 
0081 #endif // BOOKMARKPOPUP_H