1 /**************************************************************************************** 2 * Copyright (c) 2008 Nikolaj Hald Nielsen <nhn@kde.org> * 3 * * 4 * This program is free software; you can redistribute it and/or modify it under * 5 * the terms of the GNU General Public License as published by the Free Software * 6 * Foundation; either version 2 of the License, or (at your option) any later * 7 * version. * 8 * * 9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 10 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 11 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 12 * * 13 * You should have received a copy of the GNU General Public License along with * 14 * this program. If not, see <http://www.gnu.org/licenses/>. * 15 ****************************************************************************************/ 16 17 #ifndef AMAROKURL_H 18 #define AMAROKURL_H 19 20 #include "amarok_export.h" 21 #include "BookmarkViewItem.h" 22 #include "BookmarkGroup.h" 23 24 #include <QString> 25 #include <QStringList> 26 27 28 class AMAROK_EXPORT AmarokUrl : public BookmarkViewItem 29 { 30 public: 31 AmarokUrl(); 32 explicit AmarokUrl( const QString & urlString, const BookmarkGroupPtr &parent = BookmarkGroupPtr() ); 33 explicit AmarokUrl( const QStringList & resultRow, const BookmarkGroupPtr &parent = BookmarkGroupPtr() ); 34 35 ~AmarokUrl() override; 36 37 void reparent( const BookmarkGroupPtr &parent ); 38 void initFromString( const QString & urlString ); 39 40 QString command() const; 41 QString prettyCommand() const; 42 QString path() const; 43 QMap<QString, QString> args() const; 44 45 void setCommand( const QString &command ); 46 void setPath( const QString &path ); 47 48 /** 49 * Sets the url argument named @param name to @param value . Overrides any possible 50 * previous value. 51 */ 52 void setArg( const QString &name, const QString &value ); 53 54 void setName( const QString &name ); 55 void setDescription( const QString &description ) override; 56 57 void setCustomValue( const QString &custom ); 58 QString customValue() const; 59 60 bool run(); 61 62 QString url() const; 63 64 bool saveToDb(); 65 setId(int id)66 void setId( int id ) { m_id = id; } id()67 int id() const { return m_id; } 68 69 bool isNull() const; 70 71 QString name() const override; 72 QString description() const override; parent()73 BookmarkGroupPtr parent() const override { return m_parent; } 74 void removeFromDb() override; 75 void rename( const QString &name ) override; 76 77 static QString escape( const QString &in ); 78 static QString unescape( const QString &in ); 79 80 private: 81 82 QString m_command; 83 QString m_path; 84 QMap<QString, QString> m_arguments; 85 86 int m_id; 87 BookmarkGroupPtr m_parent; 88 QString m_description; 89 QString m_name; 90 91 //this value is used for storing application specific information that should not be made user visible. 92 QString m_customValue; 93 }; 94 95 #endif 96