File indexing completed on 2024-05-05 04:47:20

0001 /****************************************************************************************
0002  * Copyright (c) 2008 Nikolaj Hald Nielsen <nhn@kde.org>                                *
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 AMAROKURL_H
0018 #define AMAROKURL_H
0019 
0020 #include "amarok_export.h"
0021 #include "BookmarkViewItem.h"
0022 #include "BookmarkGroup.h"
0023 
0024 #include <QString>
0025 #include <QStringList>
0026 
0027 
0028 class AMAROK_EXPORT AmarokUrl : public BookmarkViewItem
0029 {
0030 public:
0031     AmarokUrl();
0032     explicit AmarokUrl( const QString & urlString, const BookmarkGroupPtr &parent = BookmarkGroupPtr() );
0033     explicit AmarokUrl( const QStringList & resultRow, const BookmarkGroupPtr &parent  = BookmarkGroupPtr() );
0034 
0035     ~AmarokUrl() override;
0036 
0037     void reparent( const BookmarkGroupPtr &parent );
0038     void initFromString( const QString & urlString );
0039 
0040     QString command() const;
0041     QString prettyCommand() const;
0042     QString path() const;
0043     QMap<QString, QString> args() const;
0044 
0045     void setCommand( const QString &command );
0046     void setPath( const QString &path );
0047 
0048     /**
0049      * Sets the url argument named @param name to @param value . Overrides any possible
0050      * previous value.
0051      */
0052     void setArg( const QString &name, const QString &value );
0053 
0054     void setName( const QString &name );
0055     void setDescription( const QString &description ) override;
0056 
0057     void setCustomValue( const QString &custom );
0058     QString customValue() const;
0059 
0060     bool run();
0061 
0062     QString url() const;
0063 
0064     bool saveToDb();
0065 
0066     void setId( int id ) { m_id = id; }
0067     int id() const { return m_id; }
0068 
0069     bool isNull() const;
0070 
0071     QString name() const override;
0072     QString description() const override;
0073     BookmarkGroupPtr parent() const override { return m_parent; }
0074     void removeFromDb() override;
0075     void rename( const QString &name ) override;
0076 
0077     static QString escape( const QString &in );
0078     static QString unescape( const QString &in );
0079 
0080 private:
0081     
0082     QString m_command;
0083     QString m_path;
0084     QMap<QString, QString> m_arguments;
0085 
0086     int m_id;
0087     BookmarkGroupPtr m_parent;
0088     QString m_description;
0089     QString m_name;
0090 
0091     //this value is used for storing application specific information that should not be made user visible.
0092     QString m_customValue;
0093 };
0094 
0095 #endif