Freya  0.0.1
A Gtk3 MPD Client
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
src/Browser/Queue/QueueMerger.hh
Go to the documentation of this file.
00001 /***********************************************************
00002 * This file is part of Freya
00003 * - A free MPD Gtk3 MPD Client -
00004 *
00005 * Authors: Christopher Pahl, Christoph Piechula,
00006 *          Eduard Schneider
00007 *
00008 * Copyright (C) [2011-2012]
00009 * Hosted at: https://github.com/studentkittens/Freya
00010 *
00011 *              __..--''``---....___   _..._    __
00012 *    /// //_.-'    .-/";  `        ``<._  ``.''_ `. / // /
00013 *   ///_.-' _..--.'_                        `( ) ) // //
00014 *   / (_..-' // (< _     ;_..__               ; `' / ///
00015 *    / // // //  `-._,_)' // / ``--...____..-' /// / //
00016 *  Ascii-Art by Felix Lee <flee@cse.psu.edu>
00017 *
00018 * Freya is free software: you can redistribute it and/or modify
00019 * it under the terms of the GNU General Public License as published by
00020 * the Free Software Foundation, either version 3 of the License, or
00021 * (at your option) any later version.
00022 *
00023 * Freya is distributed in the hope that it will be useful,
00024 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00025 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00026 * GNU General Public License for more details.
00027 *
00028 * You should have received a copy of the GNU General Public License
00029 * along with Freya. If not, see <http://www.gnu.org/licenses/>.
00030 **************************************************************/
00031 
00032 
00033 #ifndef FREYA_QUEUE_MERGER
00034 #define FREYA_QUEUE_MERGER
00035 
00036 #include "../../MPD/AbstractItemlist.hh"
00037 #include "../../MPD/AbstractClientUser.hh"
00038 #include "QueueModelColumns.hh"
00039 
00040 #include <gtkmm.h>
00041 
00042 namespace Browser
00043 {
00053     class QueueMerger : public MPD::AbstractItemlist, public MPD::AbstractClientUser
00054     {
00055     public:
00056         QueueMerger(MPD::Client& client,
00057                     Glib::RefPtr<Gtk::ListStore>& queue_model,
00058                     QueueModelColumns& queue_columns);
00059 
00065         void add_item(MPD::AbstractComposite * pSong);
00066 
00075         void disable_merge_once();
00084         void recalculate_positions(unsigned pos = 0);
00085 
00086     private:
00087 
00094         void on_client_update(mpd_idle event, MPD::NotifyData& data);
00095 
00101         void on_connection_change(bool server_changed, bool is_connected);
00102 
00109         void set_row_contents(Gtk::TreeModel::Row& row, MPD::Song * pSong);
00110 
00116         void add_row(MPD::Song * pSong);
00117 
00123         void merge(MPD::Song * pSong);
00124 
00130         void trim(unsigned starting_with);
00131 
00132 
00140         Gtk::TreeModel::iterator get_iter_at_pos(int pos);
00141 
00142         /* -------------------- */
00143 
00144         bool mergeDisabled;
00145         bool mergeIterIsValid;
00146 
00147         bool m_ServerChanged;
00148         bool isFirstStart;
00149 
00150         Gtk::TreeModel::iterator mergeIter;
00151 
00152         unsigned lastPlaylistVersion;
00153         unsigned playlistLength;
00154         unsigned mergePos;
00155 
00156         Glib::RefPtr<Gtk::ListStore> mp_QueueModel;
00157         QueueModelColumns * mp_QueueColumns;
00158     };
00159 }
00160 
00161 #endif /* end of include guard: FREYA_QUEUE_MERGER */