/*
 * Copyright 2009-2010  Stefan Gehn <stefan@srcbox.net>
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of 
 * the License, or (at your option) any later version.
 * 
 * This program 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 General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef PHOTOPAGE_HPP_
#define PHOTOPAGE_HPP_

#include <qobject.h>
#include <qgraphicswidget.h>
#include <qgraphicslayoutitem.h>
#include <qgraphicssceneevent.h>

class PhotoDraggable;


class PhotoPage: public QGraphicsWidget
{
  friend QDataStream & operator<< (QDataStream &stream, const PhotoPage &page);
  friend QDataStream & operator>> (QDataStream &stream, PhotoPage &page);

  Q_OBJECT
public:
  enum ActiveCorner {TopLeft = 0x1, TopRight = 0x2, BottomLeft = 0x4, BottomRight = 0x8};
  Q_DECLARE_FLAGS(ActiveCorners, ActiveCorner)

  PhotoPage(QGraphicsItem *parent = 0);
  virtual ~PhotoPage();

  void addDraggable(PhotoDraggable *draggable);
  void removeDraggable(PhotoDraggable *draggable);

  //! Removes all draggables from the page
	Q_SLOT void clearPage();

	int pageIndex() const { return mPageIndex; }
	void setPageIndex(int pageIndex, int pageCount);

  virtual void paint(QPainter * painter,
      const QStyleOptionGraphicsItem *option,
      QWidget *widget);

Q_SIGNALS:
	void turnPage();

protected:
	void contextMenuEvent(QGraphicsSceneContextMenuEvent * event);

private:
  QGraphicsWidget *mContentRect;
	QGraphicsWidget *mLeftEdgeWidget;
	QGraphicsWidget *mRightEdgeWidget;
	QGraphicsWidget *mPageNumberWidget;
	int mPageIndex;
};

Q_DECLARE_OPERATORS_FOR_FLAGS(PhotoPage::ActiveCorners)

QDataStream & operator<< (QDataStream &stream, const PhotoPage &page);
QDataStream & operator>> (QDataStream &stream, PhotoPage &page);


#endif /* PHOTOPAGE_HPP_ */
