2013-03-15 17:02:43 -04:00
|
|
|
/*
|
|
|
|
* Retroshare Gxs Support
|
2012-11-19 17:14:45 -05:00
|
|
|
*
|
2013-03-15 17:02:43 -04:00
|
|
|
* Copyright 2012-2013 by Robert Fernie.
|
2012-11-19 17:14:45 -05:00
|
|
|
*
|
2013-03-15 17:02:43 -04:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License Version 2.1 as published by the Free Software Foundation.
|
2012-11-19 17:14:45 -05:00
|
|
|
*
|
2013-03-15 17:02:43 -04:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
2012-11-19 17:14:45 -05:00
|
|
|
*
|
2013-03-15 17:02:43 -04:00
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
* USA.
|
|
|
|
*
|
|
|
|
* Please report all bugs and problems to "retroshare@lunamutt.com".
|
|
|
|
*
|
|
|
|
*/
|
2012-11-19 17:14:45 -05:00
|
|
|
|
|
|
|
#ifndef _GXS_ID_CHOOSER_H
|
|
|
|
#define _GXS_ID_CHOOSER_H
|
|
|
|
|
|
|
|
#include <QComboBox>
|
2015-03-18 09:33:38 -04:00
|
|
|
#include <retroshare/rsgxsifacetypes.h>
|
2014-07-06 07:19:58 -04:00
|
|
|
|
|
|
|
// This class implement a basic RS functionality which is that ComboBox displaying Id
|
|
|
|
// should update regularly. They also should update only when visible, to save CPU time.
|
|
|
|
//
|
|
|
|
|
|
|
|
class RsGxsIfaceHelper;
|
|
|
|
class RsGxsUpdateBroadcastBase;
|
2012-11-19 17:14:45 -05:00
|
|
|
|
2014-12-23 14:07:57 -05:00
|
|
|
#define IDCHOOSER_ID_REQUIRED 0x0001
|
2012-11-19 17:14:45 -05:00
|
|
|
#define IDCHOOSER_ANON_DEFAULT 0x0002
|
2014-12-23 14:07:57 -05:00
|
|
|
#define IDCHOOSER_NO_CREATE 0x0004
|
2015-10-24 12:48:17 -04:00
|
|
|
#define IDCHOOSER_NON_ANONYMOUS 0x0008
|
2012-11-19 17:14:45 -05:00
|
|
|
|
2015-03-18 09:33:38 -04:00
|
|
|
class GxsIdChooser : public QComboBox
|
2012-11-19 17:14:45 -05:00
|
|
|
{
|
2014-12-23 14:07:57 -05:00
|
|
|
Q_OBJECT
|
2012-11-19 17:14:45 -05:00
|
|
|
|
|
|
|
public:
|
2014-07-06 07:19:58 -04:00
|
|
|
GxsIdChooser(RsGxsIfaceHelper* ifaceImpl, QWidget *parent = NULL);
|
2012-11-19 17:14:45 -05:00
|
|
|
GxsIdChooser(QWidget *parent = NULL);
|
2014-07-06 07:19:58 -04:00
|
|
|
virtual ~GxsIdChooser();
|
|
|
|
|
2014-12-23 14:07:57 -05:00
|
|
|
void setFlags(uint32_t flags) ;
|
2015-10-24 12:48:17 -04:00
|
|
|
uint32_t flags() const { return mFlags ; }
|
2014-07-06 07:19:58 -04:00
|
|
|
|
|
|
|
enum ChosenId_Ret {None, KnowId, UnKnowId, NoId} ;
|
2015-02-10 07:55:16 -05:00
|
|
|
void loadIds(uint32_t chooserFlags, const RsGxsId &defId);
|
|
|
|
void setDefaultId(const RsGxsId &defId);
|
2015-01-22 09:33:19 -05:00
|
|
|
|
2015-02-10 07:55:16 -05:00
|
|
|
bool setChosenId(const RsGxsId &gxsId);
|
2014-07-06 07:19:58 -04:00
|
|
|
ChosenId_Ret getChosenId(RsGxsId &gxsId);
|
|
|
|
|
2016-03-24 00:05:54 -04:00
|
|
|
void setEntryEnabled(int index, bool enabled);
|
|
|
|
|
|
|
|
void setIdConstraintSet(const std::set<RsGxsId>& s) ;
|
|
|
|
bool isInConstraintSet(const RsGxsId& id) const ;
|
2016-03-24 19:23:34 -04:00
|
|
|
|
|
|
|
uint32_t countEnabledEntries() const ;
|
2015-05-09 05:28:38 -04:00
|
|
|
signals:
|
|
|
|
// emitted after first load of own ids
|
|
|
|
void idsLoaded();
|
|
|
|
|
2014-07-06 07:19:58 -04:00
|
|
|
protected:
|
|
|
|
virtual void showEvent(QShowEvent *event);
|
2015-03-26 17:20:57 -04:00
|
|
|
void updateDisplay(bool reset);
|
2012-11-19 17:14:45 -05:00
|
|
|
|
2013-06-23 14:55:30 -04:00
|
|
|
private slots:
|
2014-07-06 07:19:58 -04:00
|
|
|
void fillDisplay(bool complete);
|
|
|
|
void myCurrentIndexChanged(int index);
|
2014-12-23 14:07:57 -05:00
|
|
|
void indexActivated(int index);
|
2013-06-23 14:55:30 -04:00
|
|
|
|
2012-11-19 17:14:45 -05:00
|
|
|
private:
|
2015-03-18 09:33:38 -04:00
|
|
|
void loadPrivateIds();
|
2015-10-24 12:48:17 -04:00
|
|
|
void setDefaultItem();
|
2012-11-19 17:14:45 -05:00
|
|
|
|
|
|
|
uint32_t mFlags;
|
|
|
|
RsGxsId mDefaultId;
|
2014-07-06 07:19:58 -04:00
|
|
|
bool mFirstLoad;
|
2016-03-24 00:05:54 -04:00
|
|
|
uint32_t mAllowedCount ;
|
2013-06-23 14:55:30 -04:00
|
|
|
|
2016-03-24 00:05:54 -04:00
|
|
|
std::set<RsGxsId> mConstraintIdsSet ; // leave empty if all allowed
|
2015-10-24 12:48:17 -04:00
|
|
|
RsGxsUpdateBroadcastBase *mBase;
|
2012-11-19 17:14:45 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|