示例#1
0
vector<VideoInfo *> *VideoSelector::getVideoListFromDB(void)
{
    // get a list of category's
    typedef QMap<int, QString> CategoryMap;
    CategoryMap categoryMap;
    MSqlQuery query(MSqlQuery::InitCon());
    query.prepare("SELECT intid, category FROM videocategory");

    if (query.exec())
    {
        while (query.next())
        {
            int id = query.value(0).toInt();
            QString category = query.value(1).toString();
            categoryMap.insert(id, category);
        }
    }

    query.prepare("SELECT intid, title, plot, length, filename, coverfile, "
                  "category, showlevel, subtitle, season, episode, host "
                  "FROM videometadata ORDER BY title,season,episode");

    if (query.exec() && query.size())
    {
        vector<VideoInfo*> *videoList = new vector<VideoInfo*>;
        QString artist, genre, episode;
        while (query.next())
        {
            // Exclude iso images as they aren't supported
            QString filename = query.value(4).toString();
            if (filename.endsWith(".iso") || filename.endsWith(".ISO"))
                continue;

            VideoInfo *info = new VideoInfo;

            info->id = query.value(0).toInt();
            if (query.value(9).toInt() > 0)
            {
                episode = query.value(10).toString();
                if (episode.size() < 2)
                        episode.prepend("0");
                    info->title = QString("%1 %2x%3 - %4")
                                .arg(query.value(1).toString())
                                .arg(query.value(9).toString())
                                .arg(episode)
                                .arg(query.value(8).toString());
            }
            else
                info->title = query.value(1).toString();

            info->plot = query.value(2).toString();
            info->size = 0; //query.value(3).toInt();
            QString host = query.value(11).toString();

            // try to find the file locally
            if (host.isEmpty())
            {
                // must already be a local filename?
                info->filename = filename;
            }
            else
            {
                // if the file is on this host then we should be able to find it locally
                if (host == gCoreContext->GetHostName())
                {
                    StorageGroup videoGroup("Videos", gCoreContext->GetHostName(), false);
                    info->filename = videoGroup.FindFile(filename);

                    // sanity check the file exists
                    if (!QFile::exists(info->filename))
                    {
                        LOG(VB_GENERAL, LOG_ERR,
                            QString("VideoSelector: Failed to find local file '%1'").arg(info->filename));
                        info->filename.clear();
                    }
                }

                if (info->filename.isEmpty())
                {
                    // file must not be local or doesn't exist
                    info->filename = generate_file_url("Videos", host, filename);
                }
            }

            LOG(VB_FILE, LOG_INFO,
                QString("VideoSelector: found file '%1'").arg(info->filename));

            info->coverfile = query.value(5).toString();
            info->category = categoryMap[query.value(6).toInt()];
            info->parentalLevel = query.value(7).toInt();
            if (info->category.isEmpty())
                info->category = "(None)";
            videoList->push_back(info);
        }

        return videoList;
    }

    LOG(VB_GENERAL, LOG_ERR, "VideoSelector: Failed to get any videos");

    return NULL;
}
示例#2
0
vector<VideoInfo *> *VideoSelector::getVideoListFromDB(void)
{
    // get a list of category's
    typedef QMap<int, QString> CategoryMap;
    CategoryMap categoryMap;
    MSqlQuery query(MSqlQuery::InitCon());
    query.prepare("SELECT intid, category FROM videocategory");

    if (query.exec())
    {
        while (query.next())
        {
            int id = query.value(0).toInt();
            QString category = query.value(1).toString();
            categoryMap.insert(id, category);
        }
    }

    query.prepare("SELECT intid, title, plot, length, filename, coverfile, "
                  "category, showlevel, subtitle, season, episode "
                  "FROM videometadata ORDER BY title,season,episode");

    if (query.exec() && query.size())
    {
        vector<VideoInfo*> *videoList = new vector<VideoInfo*>;
        QString artist, genre, episode;
        while (query.next())
        {
            VideoInfo *info = new VideoInfo;

            info->id = query.value(0).toInt();
            if (query.value(9).toInt() > 0)
            {
                episode = query.value(10).toString();
                if (episode.size() < 2)
                        episode.prepend("0");
                    info->title = QString("%1 %2x%3 - %4")
                                .arg(query.value(1).toString())
                                .arg(query.value(9).toString())
                                .arg(episode)
                                .arg(query.value(8).toString());
            }
            else
                info->title = query.value(1).toString();

            info->plot = query.value(2).toString();
            info->size = 0; //query.value(3).toInt();
            info->filename = query.value(4).toString();
            info->coverfile = query.value(5).toString();
            info->category = categoryMap[query.value(6).toInt()];
            info->parentalLevel = query.value(7).toInt();
            if (info->category.isEmpty())
                info->category = "(None)";
            videoList->push_back(info);
        }
        return videoList;
    }
    
    
    LOG(VB_GENERAL, LOG_ERR, "VideoSelector: Failed to get any video's");
    return NULL;
}
// Populate tree view
void AddPropertyDialog::populateTreeView()
{
	wxIcon folderIcon;
	folderIcon.CopyFromBitmap(wxArtProvider::GetBitmap(GlobalUIManager().ArtIdPrefix() + FOLDER_ICON));

	// DEF-DEFINED PROPERTIES
	{
		// First add a top-level category named after the entity class, and populate
		// it with custom keyvals defined in the DEF for that class
		std::string cName = _entity->getEntityClass()->getName();

		wxutil::TreeModel::Row defRoot = _treeStore->AddItem();

		wxDataViewItemAttr blueBold;
		blueBold.SetColour(wxColor(0,0,255));
		blueBold.SetBold(true);

		defRoot[_columns.displayName] = wxVariant(wxDataViewIconText(cName, folderIcon));
		defRoot[_columns.displayName] = blueBold;
		defRoot[_columns.propertyName] = "";
		defRoot[_columns.description] = _(CUSTOM_PROPERTY_TEXT);

		defRoot.SendItemAdded();

		// Use a CustomPropertyAdder class to visit the entityclass and add all
		// custom properties from it
		CustomPropertyAdder adder(_entity, _treeStore, _columns, defRoot.getItem());
		_entity->getEntityClass()->forEachClassAttribute(boost::ref(adder));
	}

	// REGISTRY (GAME FILE) DEFINED PROPERTIES 

	// Ask the XML registry for the list of properties
    game::IGamePtr currentGame = GlobalGameManager().currentGame();
    xml::NodeList propNodes = currentGame->getLocalXPath(PROPERTIES_XPATH);

	// Cache of property categories to GtkTreeIters, to allow properties
	// to be parented to top-level categories
	typedef std::map<std::string, wxDataViewItem> CategoryMap;
	CategoryMap categories;

	// Add each .game-specified property to the tree view
	for (xml::NodeList::const_iterator iter = propNodes.begin();
		 iter != propNodes.end();
		 ++iter)
	{
		// Skip hidden properties
		if (iter->getAttributeValue("hidden") == "1")
		{
			continue;
		}

		wxDataViewItem item;

		// If this property has a category, look up the top-level parent iter
		// or add it if necessary.
		std::string category = iter->getAttributeValue("category");

		if (!category.empty())
		{
			CategoryMap::iterator mIter = categories.find(category);

			if (mIter == categories.end())
			{
				// Not found, add to treestore
				wxutil::TreeModel::Row catRow = _treeStore->AddItem();

				catRow[_columns.displayName] = wxVariant(wxDataViewIconText(category, folderIcon));;
				catRow[_columns.propertyName] = "";
				catRow[_columns.description] = "";

				// Add to map
				mIter = categories.insert(CategoryMap::value_type(category, catRow.getItem())).first;

				catRow.SendItemAdded();
			}

			// Category sorted, add this property below it
			item = _treeStore->AddItem(mIter->second).getItem();

			_treeStore->ItemAdded(mIter->second, item);
		}
		else
		{
			// No category, add at toplevel
			item = _treeStore->AddItem().getItem();

			_treeStore->ItemAdded(_treeStore->GetRoot(), item);
		}

		// Obtain information from the XML node and add it to the treeview
		std::string name = iter->getAttributeValue("match");
		std::string type = iter->getAttributeValue("type");
		std::string description = iter->getContent();

		wxutil::TreeModel::Row row(item, *_treeStore);

		wxIcon icon;
		icon.CopyFromBitmap(PropertyEditorFactory::getBitmapFor(type));

		row[_columns.displayName] = wxVariant(wxDataViewIconText(name, icon));
		row[_columns.propertyName] = name;
		row[_columns.description] = description;

		_treeStore->ItemChanged(item);
	}
}