Back to index

unity  6.0.0
FilterFactory.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright 2011 Canonical Ltd.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License version 3, as
00006  * published by the  Free Software Foundation.
00007  *
00008  * This program is distributed in the hope that it will be useful, but
00009  * WITHOUT ANY WARRANTY; without even the implied warranties of
00010  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00011  * PURPOSE.  See the applicable version of the GNU Lesser General Public
00012  * License for more details.
00013  *
00014  * You should have received a copy of both the GNU Lesser General Public
00015  * License version 3 along with this program.  If not, see
00016  * <http://www.gnu.org/licenses/>
00017  *
00018  * Authored by: Gordon Allott <gord.allott@canonical.com>
00019  *
00020  */
00021 
00022 #include <Nux/Nux.h>
00023 #include <NuxCore/Logger.h>
00024 
00025 #include "FilterBasicButton.h"
00026 #include "FilterFactory.h"
00027 #include "FilterGenreWidget.h"
00028 #include "FilterMultiRangeWidget.h"
00029 #include "FilterRatingsWidget.h"
00030 
00031 namespace
00032 {
00033   nux::logging::Logger logger("unity.dash.filterfactory");
00034 
00035   const std::string renderer_type_ratings = "filter-ratings";
00036   const std::string renderer_type_multirange = "filter-multirange";
00037   const std::string renderer_type_check_options = "filter-checkoption";
00038   const std::string renderer_type_check_options_compact = "filter-checkoption-compact";
00039   const std::string renderer_type_radio_options = "filter-radiooption";
00040 }
00041 
00042 namespace unity
00043 {
00044 namespace dash
00045 {
00046 
00047 FilterExpanderLabel* FilterFactory::WidgetForFilter(Filter::Ptr const& filter)
00048 {
00049   std::string filter_type(filter->renderer_name);
00050   LOG_DEBUG(logger) << "building filter of type, " << filter_type;
00051 
00052   FilterExpanderLabel* widget = nullptr;
00053   if (filter_type == renderer_type_check_options)
00054   {
00055     widget = new FilterGenre(2, NUX_TRACKER_LOCATION);
00056   }
00057   else if (filter_type == renderer_type_check_options_compact)
00058   {
00059     widget = new FilterGenre(3, NUX_TRACKER_LOCATION);
00060   }
00061   else if (filter_type == renderer_type_ratings)
00062   {
00063     widget = new FilterRatingsWidget(NUX_TRACKER_LOCATION);
00064   }
00065   else if (filter_type == renderer_type_multirange)
00066   {
00067     widget = new FilterMultiRange(NUX_TRACKER_LOCATION);
00068   }
00069   else if (filter_type == renderer_type_radio_options)
00070   {
00071     widget = new FilterGenre(2, NUX_TRACKER_LOCATION);
00072   }
00073   else
00074   {
00075     LOG_WARNING(logger) << "Do not understand filter of type \""
00076                         << filter_type
00077                         << "\"";
00078   }
00079 
00080   if (widget)
00081     widget->SetFilter(filter);
00082 
00083   return widget;
00084 }
00085 
00086 } // namespace dash
00087 } // namespace unity
00088