00001 /****************************************************************************** 00002 * This file is part of the Gluon Development Platform 00003 * Copyright (C) 2010 Shantanu Tushar <jhahoneyk@gmail.com> 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2.1 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 */ 00019 00020 #ifndef COMMENTSVIEWITEM_H 00021 #define COMMENTSVIEWITEM_H 00022 00023 #include <QGraphicsWidget> 00024 #include <QPersistentModelIndex> 00025 00026 class QGraphicsGridLayout; 00027 00028 namespace Plasma 00029 { 00030 class IconWidget; 00031 class Label; 00032 } 00033 00034 class CommentsViewItem : public QGraphicsWidget 00035 { 00036 Q_OBJECT 00037 public: 00038 CommentsViewItem( QGraphicsItem* parent = 0, Qt::WindowFlags wFlags = 0 ); 00039 virtual ~CommentsViewItem(); 00040 00041 virtual void setModelIndex( const QModelIndex& index ); 00042 QModelIndex modelIndex() const; 00043 int depth(); 00044 void setDepth( int newDepth ); 00045 int rowInLayout(); 00046 void setRowInLayout( int row ); 00047 bool replyEnabled(); 00048 void setReplyEnabled( bool enabled ); 00049 00050 signals: 00051 void replyClicked(); 00052 00053 protected: 00054 void hoverEnterEvent( QGraphicsSceneHoverEvent* event ); 00055 void hoverLeaveEvent( QGraphicsSceneHoverEvent* event ); 00056 00057 void layoutWidgets(); 00058 void setToolTips(); 00059 00060 QPersistentModelIndex m_index; 00061 Plasma::IconWidget* m_author; 00062 Plasma::Label* m_title; 00063 Plasma::Label* m_body; 00064 Plasma::Label* m_dateTime; 00065 Plasma::Label* m_rating; //TODO Use a stars widget 00066 00067 Plasma::IconWidget* m_replyButton; 00068 QGraphicsGridLayout* m_layout; 00069 int m_depth; 00070 int m_rowInLayout; 00071 00072 private: 00073 bool m_replyEnabled; 00074 }; 00075 00076 #endif // COMMENTSVIEWITEM_H