Class to represent tags
This commit is contained in:
		
					parent
					
						
							
								7130c3f6ad
							
						
					
				
			
			
				commit
				
					
						299137a250
					
				
			
		
					 2 changed files with 147 additions and 0 deletions
				
			
		
							
								
								
									
										88
									
								
								src/libdanbooru/danboorutag.cpp
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										88
									
								
								src/libdanbooru/danboorutag.cpp
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,88 @@
 | 
			
		|||
/*
 | 
			
		||||
 * <one line to give the library's name and an idea of what it does.>
 | 
			
		||||
 * Copyright 2013  Luca Beltrame <lbeltrame@kde.org>
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software; you can redistribute it and/or
 | 
			
		||||
 * modify it under the terms of the GNU General Public License as
 | 
			
		||||
 * published by the Free Software Foundation; either version 2 of
 | 
			
		||||
 * the License or (at your option) version 3 or any later version
 | 
			
		||||
 * accepted by the membership of KDE e.V. (or its successor approved
 | 
			
		||||
 * by the membership of KDE e.V.), which shall act as a proxy
 | 
			
		||||
 * defined in Section 14 of version 3 of the license.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is distributed in the hope that it will be useful,
 | 
			
		||||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 * GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include "danboorutag.h"
 | 
			
		||||
 | 
			
		||||
namespace Danbooru {
 | 
			
		||||
 | 
			
		||||
    DanbooruTag::DanbooruTag(const QVariantMap& postData, QObject* parent):
 | 
			
		||||
                            QObject(parent)
 | 
			
		||||
    {
 | 
			
		||||
        m_id = postData.value("id").toInt();
 | 
			
		||||
        m_name = postData.value("name").toString();
 | 
			
		||||
        m_count = postData.value("count").toInt();
 | 
			
		||||
        m_ambiguous = postData.value("ambiguous").toBool();
 | 
			
		||||
 | 
			
		||||
        int type = postData.value("type").toInt();
 | 
			
		||||
 | 
			
		||||
        switch (type) {
 | 
			
		||||
            case 0:
 | 
			
		||||
                m_tagType = General;
 | 
			
		||||
                break;
 | 
			
		||||
            case 1:
 | 
			
		||||
                m_tagType = Artist;
 | 
			
		||||
                break;
 | 
			
		||||
            case 2:
 | 
			
		||||
                m_tagType = Copyright;
 | 
			
		||||
                break;
 | 
			
		||||
            case 3:
 | 
			
		||||
                m_tagType = Character;
 | 
			
		||||
                break;
 | 
			
		||||
            case 4:
 | 
			
		||||
                m_tagType = Unknown;
 | 
			
		||||
                break;
 | 
			
		||||
            default:
 | 
			
		||||
                m_tagType = Unknown;
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    int DanbooruTag::id() const
 | 
			
		||||
    {
 | 
			
		||||
        return m_id;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    int DanbooruTag::count() const
 | 
			
		||||
    {
 | 
			
		||||
        return m_count;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const QString DanbooruTag::name() const
 | 
			
		||||
    {
 | 
			
		||||
        return m_name;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    bool DanbooruTag::ambiguous() const
 | 
			
		||||
    {
 | 
			
		||||
        return m_ambiguous;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    TagType DanbooruTag::type() const
 | 
			
		||||
    {
 | 
			
		||||
        return m_tagType;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}; // namespace Danbooru
 | 
			
		||||
							
								
								
									
										59
									
								
								src/libdanbooru/danboorutag.h
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										59
									
								
								src/libdanbooru/danboorutag.h
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,59 @@
 | 
			
		|||
/*
 | 
			
		||||
 * <one line to give the library's name and an idea of what it does.>
 | 
			
		||||
 * Copyright 2013  Luca Beltrame <lbeltrame@kde.org>
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software; you can redistribute it and/or
 | 
			
		||||
 * modify it under the terms of the GNU General Public License as
 | 
			
		||||
 * published by the Free Software Foundation; either version 2 of
 | 
			
		||||
 * the License or (at your option) version 3 or any later version
 | 
			
		||||
 * accepted by the membership of KDE e.V. (or its successor approved
 | 
			
		||||
 * by the membership of KDE e.V.), which shall act as a proxy
 | 
			
		||||
 * defined in Section 14 of version 3 of the license.
 | 
			
		||||
 *
 | 
			
		||||
 * This program is distributed in the hope that it will be useful,
 | 
			
		||||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
			
		||||
 * GNU General Public License for more details.
 | 
			
		||||
 *
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 *
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifndef DANBOORUTAG_H
 | 
			
		||||
#define DANBOORUTAG_H
 | 
			
		||||
 | 
			
		||||
#include <QtCore/QObject>
 | 
			
		||||
#include <QtCore/QVariant>
 | 
			
		||||
 | 
			
		||||
#include "danbooru.h"
 | 
			
		||||
 | 
			
		||||
namespace Danbooru {
 | 
			
		||||
 | 
			
		||||
    class DanbooruTag : public QObject
 | 
			
		||||
    {
 | 
			
		||||
    Q_OBJECT
 | 
			
		||||
 | 
			
		||||
    private:
 | 
			
		||||
        int m_id;
 | 
			
		||||
        int m_count;
 | 
			
		||||
        QString m_name;
 | 
			
		||||
        bool m_ambiguous;
 | 
			
		||||
        TagType m_tagType;
 | 
			
		||||
 | 
			
		||||
    public:
 | 
			
		||||
        DanbooruTag(const QVariantMap& postData, QObject* parent=0);
 | 
			
		||||
        int id() const;
 | 
			
		||||
        int count() const;
 | 
			
		||||
        const QString name() const;
 | 
			
		||||
        bool ambiguous() const;
 | 
			
		||||
        TagType type() const;
 | 
			
		||||
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
}; // namespace  Danbooru
 | 
			
		||||
 | 
			
		||||
Q_DECLARE_METATYPE(Danbooru::DanbooruTag*)
 | 
			
		||||
 | 
			
		||||
#endif // DANBOORUTAG_H
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue