krita
kis_resource_mediator.h
00001 /* 00002 * Copyright (c) 2003 Patrick Julien <freak@codepimps.org> 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 */ 00018 #ifndef KIS_RESOURCE_MEDIATOR_H_ 00019 #define KIS_RESOURCE_MEDIATOR_H_ 00020 00021 #include <qobject.h> 00022 #include <qmap.h> 00023 #include <qwidget.h> 00024 00025 class KoIconItem; 00026 class KisItemChooser; 00027 class KisIconItem; 00028 class KisResource; 00029 class KisResourceServerBase; 00030 00037 class KisResourceMediator : public QObject { 00038 Q_OBJECT 00039 typedef QObject super; 00040 00041 public: 00042 KisResourceMediator(KisItemChooser *chooser, 00043 QObject *parent = 0, 00044 const char *name = 0); 00045 virtual ~KisResourceMediator(); 00046 00047 public: 00048 void connectServer(KisResourceServerBase* rServer); 00049 KisResource *currentResource() const; 00050 KisIconItem *itemFor(KisResource *r) const; 00051 KisResource *resourceFor(KoIconItem *item) const; 00052 KisResource *resourceFor(KisIconItem *item) const; 00053 QWidget *chooserWidget() const; 00054 00055 public slots: 00056 00057 void setActiveItem(KoIconItem *item); 00058 00059 signals: 00060 void activatedResource(KisResource *r); 00061 00062 private slots: 00063 void rServerAddedResource(KisResource *resource); 00064 00065 private: 00066 KisItemChooser *m_chooser; 00067 QMap<KisResource*, KisIconItem*> m_items; 00068 KoIconItem *m_activeItem; 00069 }; 00070 00071 #endif // KIS_RESOURCE_MEDIATOR_H_ 00072