KFile
kurlnavigatorbutton_p.h
Go to the documentation of this file.
00001 /***************************************************************************** 00002 * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> * 00003 * Copyright (C) 2006 by Aaron J. Seigo <aseigo@kde.org> * 00004 * * 00005 * This library is free software; you can redistribute it and/or * 00006 * modify it under the terms of the GNU Library General Public * 00007 * License as published by the Free Software Foundation; either * 00008 * version 2 of the License, or (at your option) any later version. * 00009 * * 00010 * This library is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00013 * Library General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU Library General Public License * 00016 * along with this library; see the file COPYING.LIB. If not, write to * 00017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * 00018 * Boston, MA 02110-1301, USA. * 00019 *****************************************************************************/ 00020 00021 #ifndef KURLNAVIGATORBUTTON_P_H 00022 #define KURLNAVIGATORBUTTON_P_H 00023 00024 #include "kurlnavigatorbuttonbase_p.h" 00025 #include "kurlnavigatormenu_p.h" 00026 00027 #include <kio/global.h> 00028 #include <kio/udsentry.h> 00029 #include <kurl.h> 00030 00031 #include <QPointer> 00032 00033 class KJob; 00034 class QDropEvent; 00035 class QPaintEvent; 00036 00037 namespace KIO 00038 { 00039 class Job; 00040 } 00041 00050 class KUrlNavigatorButton : public KUrlNavigatorButtonBase 00051 { 00052 Q_OBJECT 00053 00054 public: 00055 explicit KUrlNavigatorButton(const KUrl& url, QWidget* parent); 00056 virtual ~KUrlNavigatorButton(); 00057 00058 void setUrl(const KUrl& url); 00059 KUrl url() const; 00060 00061 /* Implementation note: QAbstractButton::setText() is not virtual, 00062 * but KUrlNavigatorButton needs to adjust the minimum size when 00063 * the text has been changed. KUrlNavigatorButton::setText() hides 00064 * QAbstractButton::setText() which is not nice, but sufficient for 00065 * the usage in KUrlNavigator. 00066 */ 00067 void setText(const QString& text); 00068 00073 void setActiveSubDirectory(const QString& subDir); 00074 QString activeSubDirectory() const; 00075 00077 virtual QSize sizeHint() const; 00078 00079 Q_SIGNALS: 00084 void urlsDropped(const KUrl& destination, QDropEvent* event); 00085 00086 void clicked(const KUrl& url, Qt::MouseButton button); 00087 00094 void startedTextResolving(); 00095 00101 void finishedTextResolving(); 00102 00103 protected: 00104 virtual void paintEvent(QPaintEvent* event); 00105 virtual void enterEvent(QEvent* event); 00106 virtual void leaveEvent(QEvent* event); 00107 virtual void dropEvent(QDropEvent* event); 00108 virtual void dragEnterEvent(QDragEnterEvent* event); 00109 virtual void dragMoveEvent(QDragMoveEvent* event); 00110 virtual void dragLeaveEvent(QDragLeaveEvent* event); 00111 virtual void mousePressEvent(QMouseEvent* event); 00112 virtual void mouseReleaseEvent(QMouseEvent* event); 00113 virtual void mouseMoveEvent(QMouseEvent* event); 00114 virtual void wheelEvent(QWheelEvent* event); 00115 00116 private Q_SLOTS: 00121 void requestSubDirs(); 00122 00127 void startSubDirsJob(); 00128 00134 void addEntriesToSubDirs(KIO::Job* job, const KIO::UDSEntryList& entries); 00135 00140 void openSubDirsMenu(KJob* job); 00141 00147 void replaceButton(KJob* job); 00148 00149 void urlsDropped(QAction* action, QDropEvent* event); 00150 00155 void slotMenuActionClicked(QAction* action); 00156 00157 void statFinished(KJob*); 00158 00159 private: 00163 void cancelSubDirsRequest(); 00164 00165 int arrowWidth() const; 00166 bool isAboveArrow(int x) const; 00167 bool isTextClipped() const; 00168 void updateMinimumWidth(); 00169 void initMenu(KUrlNavigatorMenu* menu, int startIndex); 00170 00171 private: 00172 bool m_hoverArrow; 00173 bool m_pendingTextChange; 00174 bool m_replaceButton; 00175 int m_wheelSteps; 00176 KUrl m_url; 00177 00178 QString m_subDir; 00179 QTimer* m_openSubDirsTimer; 00180 KIO::Job* m_subDirsJob; 00181 00183 QList<QPair<QString,QString> > m_subDirs; 00184 00185 static QPointer<KUrlNavigatorMenu> m_subDirsMenu; 00186 }; 00187 00188 #endif
KDE 4.6 API Reference