KFile
kurlnavigator.h
Go to the documentation of this file.
00001 /***************************************************************************** 00002 * Copyright (C) 2006-2010 by Peter Penz <peter.penz@gmx.at> * 00003 * Copyright (C) 2006 by Aaron J. Seigo <aseigo@kde.org> * 00004 * Copyright (C) 2007 by Kevin Ottens <ervin@kde.org> * 00005 * Copyright (C) 2007 by Urs Wolfer <uwolfer @ kde.org> * 00006 * * 00007 * This library is free software; you can redistribute it and/or * 00008 * modify it under the terms of the GNU Library General Public * 00009 * License as published by the Free Software Foundation; either * 00010 * version 2 of the License, or (at your option) any later version. * 00011 * * 00012 * This library is distributed in the hope that it will be useful, * 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00015 * Library General Public License for more details. * 00016 * * 00017 * You should have received a copy of the GNU Library General Public License * 00018 * along with this library; see the file COPYING.LIB. If not, write to * 00019 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * 00020 * Boston, MA 02110-1301, USA. * 00021 *****************************************************************************/ 00022 00023 #ifndef KURLNAVIGATOR_H 00024 #define KURLNAVIGATOR_H 00025 00026 #include <kfile_export.h> 00027 00028 #include <kurl.h> 00029 #include <QtGui/QWidget> 00030 #include <QtCore/QByteArray> 00031 00032 class KFilePlacesModel; 00033 class KUrlComboBox; 00034 class QMouseEvent; 00035 00076 class KFILE_EXPORT KUrlNavigator : public QWidget 00077 { 00078 Q_OBJECT 00079 00080 public: 00082 KUrlNavigator(QWidget* parent = 0); 00083 00091 KUrlNavigator(KFilePlacesModel* placesModel, const KUrl& url, QWidget* parent); 00092 virtual ~KUrlNavigator(); 00093 00099 KUrl locationUrl(int historyIndex = -1) const; 00100 00121 void saveLocationState(const QByteArray& state); 00122 00129 QByteArray locationState(int historyIndex = -1) const; 00130 00139 bool goBack(); 00140 00149 bool goForward(); 00150 00158 bool goUp(); 00159 00167 void goHome(); 00168 00174 void setHomeUrl(const KUrl& url); 00175 00176 KUrl homeUrl() const; 00177 00184 void setUrlEditable(bool editable); 00185 00191 bool isUrlEditable() const; 00192 00202 void setShowFullPath(bool show); 00203 00208 bool showFullPath() const; 00209 00219 void setActive(bool active); 00220 00225 bool isActive() const; 00226 00233 void setPlacesSelectorVisible(bool visible); 00234 00236 bool isPlacesSelectorVisible() const; 00237 00242 KUrl uncommittedUrl() const; 00243 00249 int historySize() const; 00250 00256 int historyIndex() const; 00257 00262 KUrlComboBox* editor() const; 00263 00268 void setCustomProtocols(const QStringList& protocols); 00269 00273 QStringList customProtocols() const; 00274 00279 #ifndef KDE_NO_DEPRECATED 00280 KDE_DEPRECATED const KUrl& url() const; 00281 #endif 00282 00293 #ifndef KDE_NO_DEPRECATED 00294 KDE_DEPRECATED KUrl url(int index) const; 00295 #endif 00296 00303 #ifndef KDE_NO_DEPRECATED 00304 KDE_DEPRECATED KUrl historyUrl(int historyIndex) const; 00305 #endif 00306 00311 #ifndef KDE_NO_DEPRECATED 00312 KDE_DEPRECATED const KUrl& savedRootUrl() const; 00313 #endif 00314 00320 #ifndef KDE_NO_DEPRECATED 00321 KDE_DEPRECATED QPoint savedPosition() const; 00322 #endif 00323 00325 #ifndef KDE_NO_DEPRECATED 00326 KDE_DEPRECATED void setHomeUrl(const QString& homeUrl); 00327 #endif 00328 00329 public Q_SLOTS: 00337 void setLocationUrl(const KUrl& url); 00338 00344 void requestActivation(); 00345 00346 /* @see QWidget::setFocus() */ 00347 void setFocus(); 00348 00353 #ifndef KDE_NO_DEPRECATED 00354 KDE_DEPRECATED void setUrl(const KUrl& url); 00355 #endif 00356 00361 #ifndef KDE_NO_DEPRECATED 00362 KDE_DEPRECATED void saveRootUrl(const KUrl& url); 00363 #endif 00364 00369 #ifndef KDE_NO_DEPRECATED 00370 KDE_DEPRECATED void savePosition(int x, int y); 00371 #endif 00372 00373 Q_SIGNALS: 00379 void activated(); 00380 00386 void urlChanged(const KUrl& url); 00387 00395 void urlAboutToBeChanged(const KUrl& newUrl); 00396 00401 void editableStateChanged(bool editable); 00402 00407 void historyChanged(); 00408 00415 void urlsDropped(const KUrl& destination, QDropEvent* event); 00416 00420 void returnPressed(); 00421 00427 void tabRequested(const KUrl& url); 00428 00436 // KDE5: remove, as the signal has been replaced by 00437 // urlsDropped(const KUrl& destination, QDropEvent* event) 00438 #ifndef KDE_NO_DEPRECATED 00439 KDE_DEPRECATED void urlsDropped(const KUrl::List& urls, 00440 const KUrl& destination); 00441 #endif 00442 00443 protected: 00444 /* 00445 * If the Escape key is pressed, the navigation bar should switch 00446 * to the breadcrumb view. 00447 * @see QWidget::keyPressEvent() 00448 */ 00449 virtual void keyPressEvent(QKeyEvent* event); 00450 00454 virtual void keyReleaseEvent(QKeyEvent* event); 00455 00456 /* 00457 * Paste the clipboard content as URL, if the middle mouse 00458 * button has been clicked. 00459 * @see QWidget::mouseReleaseEvent() 00460 */ 00461 virtual void mouseReleaseEvent(QMouseEvent* event); 00462 00463 /* @see QWidget::resizeEvent() */ 00464 virtual void resizeEvent(QResizeEvent* event); 00465 00466 virtual bool eventFilter(QObject* watched, QEvent* event); 00467 00468 private: 00469 Q_PRIVATE_SLOT(d, void slotReturnPressed()) 00470 Q_PRIVATE_SLOT(d, void slotProtocolChanged(const QString& protocol)) 00471 Q_PRIVATE_SLOT(d, void switchView()) 00472 Q_PRIVATE_SLOT(d, void dropUrls(const KUrl& destination, QDropEvent*)) 00473 Q_PRIVATE_SLOT(d, void slotNavigatorButtonClicked(const KUrl& url, Qt::MouseButton button)) 00474 Q_PRIVATE_SLOT(d, void openContextMenu()) 00475 Q_PRIVATE_SLOT(d, void openPathSelectorMenu()) 00476 Q_PRIVATE_SLOT(d, void updateButtonVisibility()) 00477 Q_PRIVATE_SLOT(d, void switchToBreadcrumbMode()) 00478 Q_PRIVATE_SLOT(d, void slotPathBoxChanged(const QString& text)) 00479 Q_PRIVATE_SLOT(d, void updateContent()) 00480 00481 private: 00482 class Private; 00483 Private* const d; 00484 00485 Q_DISABLE_COPY(KUrlNavigator) 00486 }; 00487 00488 #endif
KDE 4.6 API Reference