File indexing completed on 2025-01-05 04:25:45
0001 /**************************************************************************************** 0002 * Copyright (c) 2009 Joffrey Clavel <jclavel@clabert.info> * 0003 * Copyright (c) 2009 Oleksandr Khayrullin <saniokh@gmail.com> * 0004 * Copyright (c) 2009-2010 Ludovic Deveaux <deveaux.ludovic31@gmail.com> * 0005 * * 0006 * This program is free software; you can redistribute it and/or modify it under * 0007 * the terms of the GNU General Public License as published by the Free Software * 0008 * Foundation; either version 2 of the License, or (at your option) any later * 0009 * version. * 0010 * * 0011 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0012 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0013 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License along with * 0016 * this program. If not, see <http://www.gnu.org/licenses/>. * 0017 ****************************************************************************************/ 0018 0019 #ifndef UPCOMING_EVENTS_APPLET_H 0020 #define UPCOMING_EVENTS_APPLET_H 0021 0022 // Includes 0023 #include "context/Applet.h" 0024 #include "context/DataEngine.h" 0025 #include "network/NetworkAccessManagerProxy.h" 0026 #include "UpcomingEventsWidget.h" 0027 #include "ui_upcomingEventsGeneralSettings.h" 0028 #include "ui_upcomingEventsVenueSettings.h" 0029 0030 class KConfigDialog; 0031 class QListWidgetItem; 0032 class UpcomingEventsMapWidget; 0033 class UpcomingEventsStackItem; 0034 class UpcomingEventsStack; 0035 0036 namespace Plasma 0037 { 0038 } 0039 0040 /** 0041 * \class UpcomingEventsApplet UpcomingEventsApplet.h UpcomingEventsApplet.cpp 0042 * \brief The base class of the Upcoming Events applet. 0043 * 0044 * UpcomingEventsApplet displays the upcoming events of the current artist from LastFm. 0045 */ 0046 class UpcomingEventsApplet : public Context::Applet 0047 { 0048 Q_OBJECT 0049 0050 public: 0051 /** 0052 * \brief Constructor 0053 * 0054 * UpcomingEventsApplet constructor 0055 * 0056 * \param parent : the UpcomingEventsApplet parent (used by Context::Applet) 0057 * \param args : (used by Context::Applet) 0058 */ 0059 UpcomingEventsApplet( QObject* parent, const QVariantList& args ); 0060 0061 virtual ~UpcomingEventsApplet(); 0062 0063 /** 0064 * \brief Paints the interface 0065 * 0066 * This method is called when the interface should be painted 0067 * 0068 * \param painter : the QPainter to use to do the paint 0069 * \param option : the style options object 0070 * \param contentsRect : the rect to paint within; automatically adjusted for 0071 * the background, if any 0072 */ 0073 void paintInterface( QPainter *painter, const QStyleOptionGraphicsItem* option, const QRect& contentsRect ); 0074 0075 /** 0076 * Called when any of the geometry constraints have been updated. 0077 * 0078 * This is always called prior to painting and should be used as an 0079 * opportunity to layout the widget, calculate sizings, etc. 0080 * 0081 * Do not call update() from this method; an update() will be triggered 0082 * at the appropriate time for the applet. 0083 * 0084 * \param constraints : the type of constraints that were updated 0085 */ 0086 void constraintsEvent( Plasma::Constraints constraints = Plasma::AllConstraints ); 0087 0088 Q_SIGNALS: 0089 void listWidgetAdded( UpcomingEventsListWidget *widget ); 0090 void listWidgetRemoved( UpcomingEventsListWidget *widget ); 0091 0092 protected: 0093 /** 0094 * Reimplement this method so provide a configuration interface, 0095 * parented to the supplied widget. Ownership of the widgets is passed 0096 * to the parent widget. 0097 * 0098 * \param parent : the dialog which is the parent of the configuration 0099 * widgets 0100 */ 0101 void createConfigurationInterface(KConfigDialog *parent); 0102 0103 public Q_SLOTS: 0104 /** 0105 * \brief Initialization 0106 * 0107 * Initializes the UpcomingEventsApplet with default parameters 0108 */ 0109 virtual void init(); 0110 0111 /** 0112 * Updates the data from the Upcoming Events engine 0113 * 0114 * \param name : the name 0115 * \param data : the engine from where the data are received 0116 */ 0117 void dataUpdated( const QString& name, const Plasma::DataEngine::Data& data ); 0118 0119 private: 0120 /** 0121 * The UI of the general settings page 0122 */ 0123 Ui::upcomingEventsGeneralSettings ui_GeneralSettings; 0124 0125 /** 0126 * The UI of the sticky venue settings page 0127 */ 0128 Ui::upcomingEventsVenueSettings ui_VenueSettings; 0129 0130 /** 0131 * The stack item for the upcoming events for the current playing artist 0132 */ 0133 UpcomingEventsStackItem *m_artistStackItem; 0134 0135 /** 0136 * The list widget presenting upcoming events 0137 */ 0138 UpcomingEventsListWidget *m_artistEventsList; 0139 0140 private Q_SLOTS: 0141 /** 0142 * Connects the source to the Upcoming Events engine 0143 * and calls the dataUpdated function 0144 */ 0145 void engineSourceAdded( const QString &source ); 0146 0147 /** 0148 * Show the settings windows 0149 */ 0150 void configure(); 0151 0152 /** 0153 * Returns the current time span 0154 */ 0155 QString currentTimeSpan(); 0156 0157 /** 0158 * Save the time span chosen by the user 0159 */ 0160 void saveTimeSpan(); 0161 0162 /** 0163 * Save all the upcoming events settings 0164 */ 0165 void saveSettings(); 0166 0167 /** 0168 * Show in media sources slot 0169 */ 0170 void navigateToArtist(); 0171 0172 private: 0173 enum VenueItemRoles 0174 { 0175 VenueIdRole = Qt::UserRole, 0176 VenueNameRole, 0177 VenueCityRole, 0178 VenueCountryRole, 0179 VenueStreetRole, 0180 VenuePhotoUrlRole, 0181 VenueUrlRole, 0182 VenueWebsiteRole 0183 }; 0184 0185 struct VenueData 0186 { 0187 int id; 0188 QString name; 0189 QString city; 0190 }; 0191 0192 void clearVenueItems(); 0193 void addToStackItem( UpcomingEventsStackItem *item, 0194 const LastFmEvent::List &events, 0195 const QString &name ); 0196 QList<VenueData> venueStringToDataList( const QStringList &list ); 0197 QList<VenueData> m_favoriteVenues; 0198 0199 void enableVenueGrouping( bool enable ); 0200 bool m_groupVenues; 0201 0202 UpcomingEventsStack *m_stack; 0203 UpcomingEventsMapWidget *mapView(); 0204 0205 private Q_SLOTS: 0206 void searchVenue( const QString &text ); 0207 void venueResults( const QUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ); 0208 void venuePhotoResult( const QUrl &url, QByteArray data, NetworkAccessManagerProxy::Error e ); 0209 void showVenueInfo( QListWidgetItem *item ); 0210 void venueResultDoubleClicked( QListWidgetItem *item ); 0211 void selectedVenueDoubleClicked( QListWidgetItem *item ); 0212 void handleMapRequest( QObject *widget ); 0213 void listWidgetDestroyed( QObject *obj ); 0214 void openUrl( const QString &url ); 0215 void collapseStateChanged(); 0216 void viewCalendar(); 0217 }; 0218 0219 AMAROK_EXPORT_APPLET( upcomingEvents, UpcomingEventsApplet ) 0220 0221 #endif // UPCOMINGEVENTSAPPLET_H