view sv/main/EasaierSessionManager.h @ 58:b3c3a5fa185f

frontend with easaier's look
author benoitrigolleau
date Fri, 25 May 2007 12:36:35 +0000
parents ac5491829e61
children 87495ac7710a
line wrap: on
line source
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */

/*	Sound Access	
		EASAIER client application.	
		Silogic 2007. Laure Bajard. 
	
	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) any later version.  See the file    
	COPYING included with this distribution for more information.
*/

#ifndef _EASAIER_SESSION_MANAGER_H_
#define _EASAIER_SESSION_MANAGER_H_

#include <QObject>
#include <QFile>

#include <map>
#include <set>

#include "data/fileio/HttpClient.h"
#include "document/Document.h"
#include "view/Pane.h"
#include "data/model/QueryModel.h"

class EasaierSessionManager : public QObject
{
	Q_OBJECT
public:
	EasaierSessionManager(HttpClient* httpClient);
	virtual ~EasaierSessionManager();

	class LoadedFile : public QFile
	{
	public:
		LoadedFile() : QFile(){}
		LoadedFile(const QString & name ) : QFile(name ){}
		virtual ~LoadedFile(){}

		enum FileType {
			UNKNOWN				= 0,
			AUDIO_SOURCE_INFO	= 1, // information (metadata) about an audio file
			MODEL				= 2, // load a model in a existing layer
			METADATA			= 3, // load the model and create an associated layer
			QUERY_CONFIG		= 4, // config of the queries
			QUERY_RESULTS		= 5  // query results
		};

		inline FileType getFileType() const {return m_type;}
		inline void setFileType(const FileType type) {m_type = type;}

		inline QString getUri() const {return m_uri;}
		inline void setUri(const QString& uri) {m_uri = uri;}

	protected:
		FileType m_type;

		QString m_uri;

	};

public:

	inline void setHttpClient(HttpClient* httpClient) {m_httpClient = httpClient;}

	void loadFile(const QString& uri, LoadedFile::FileType type);

	bool newSession();
	void closeSession();
	void closeFile();

	/* open a existing session file:
	- open the audio source info file 
	- load the appropriate metadata (needed by opened layers)
	*/
	bool openSession(Document *document);

	/* open an audio source info file
	*/
	bool openAudioInfoFile(Document *document);

	/*import metadata info in a new layer*/
	void importMetadata(const QString& filename, Pane* pane);

	/* load the appropriate metadata (needed by opened layers)
	 of an audio file
	*/
	void loadRelatedModel();

	/* add the metadata  to the corresponding layers */
	bool addModelToLayers(const QString& name, const QString& filename);

	/*query the database*/
	void queryDatabase(const QString& themeName);

public slots:
	void fileLoaded(int, bool);

signals:
	void queryModelLoaded(QueryModel* queryModel);

private:


	QString							m_fileName;

	HttpClient						*m_httpClient;

	Document						*m_document;
	
	std::map<int , LoadedFile*>		m_loadFile;

	AudioSourceInfoModel			*m_audioSourceInfoModel;

	std::set<QString>				m_modelLoaded;

	Pane							*m_currentPane;

	QueryModel						*m_queryModel;
};

#endif