Fixed utf8 handling in photo comments.

Some cosmetic changes.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs-b1@5715 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2012-10-23 00:24:41 +00:00
parent bb9a80e95b
commit 6e04229d39
13 changed files with 92 additions and 130 deletions

View File

@ -7,11 +7,14 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>465</width> <width>465</width>
<height>347</height> <height>356</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Dialog</string> <string>Create Album</string>
</property>
<property name="sizeGripEnabled">
<bool>true</bool>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>

View File

@ -4,11 +4,10 @@
#include "ui_AlbumDialog.h" #include "ui_AlbumDialog.h"
AlbumDialog::AlbumDialog(const RsPhotoAlbum& album, TokenQueue* photoQueue, RsPhotoV2* rs_Photo, QWidget *parent) : AlbumDialog::AlbumDialog(const RsPhotoAlbum& album, TokenQueue* photoQueue, RsPhotoV2* rs_Photo, QWidget *parent) :
QWidget(parent), QDialog(parent),
ui(new Ui::AlbumDialog), mPhotoQueue(photoQueue), mRsPhoto(rs_Photo), mAlbum(album), mPhotoSelected(NULL) ui(new Ui::AlbumDialog), mRsPhoto(rs_Photo), mPhotoQueue(photoQueue), mAlbum(album), mPhotoSelected(NULL)
{ {
ui->setupUi(this); ui->setupUi(this);
setAttribute ( Qt::WA_DeleteOnClose, true );
connect(ui->pushButton_PublishPhotos, SIGNAL(clicked()), this, SLOT(updateAlbumPhotos())); connect(ui->pushButton_PublishPhotos, SIGNAL(clicked()), this, SLOT(updateAlbumPhotos()));
connect(ui->pushButton_DeletePhoto, SIGNAL(clicked()), this, SLOT(deletePhoto())); connect(ui->pushButton_DeletePhoto, SIGNAL(clicked()), this, SLOT(deletePhoto()));

View File

@ -1,7 +1,7 @@
#ifndef ALBUMDIALOG_H #ifndef ALBUMDIALOG_H
#define ALBUMDIALOG_H #define ALBUMDIALOG_H
#include <QWidget> #include <QDialog>
#include "retroshare/rsphotoV2.h" #include "retroshare/rsphotoV2.h"
#include "util/TokenQueue.h" #include "util/TokenQueue.h"
#include "PhotoShareItemHolder.h" #include "PhotoShareItemHolder.h"
@ -12,7 +12,7 @@ namespace Ui {
class AlbumDialog; class AlbumDialog;
} }
class AlbumDialog : public QWidget, public PhotoShareItemHolder class AlbumDialog : public QDialog, public PhotoShareItemHolder
{ {
Q_OBJECT Q_OBJECT

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>AlbumDialog</class> <class>AlbumDialog</class>
<widget class="QWidget" name="AlbumDialog"> <widget class="QDialog" name="AlbumDialog">
<property name="geometry"> <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
@ -11,7 +11,14 @@
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Album</string>
</property>
<property name="windowIcon">
<iconset resource="../images.qrc">
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
</property>
<property name="sizeGripEnabled">
<bool>true</bool>
</property> </property>
<layout class="QVBoxLayout" name="verticalLayout_3"> <layout class="QVBoxLayout" name="verticalLayout_3">
<item> <item>
@ -278,7 +285,7 @@ p, li { white-space: pre-wrap; }
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>627</width> <width>627</width>
<height>116</height> <height>107</height>
</rect> </rect>
</property> </property>
<property name="styleSheet"> <property name="styleSheet">
@ -353,6 +360,8 @@ p, li { white-space: pre-wrap; }
<container>1</container> <container>1</container>
</customwidget> </customwidget>
</customwidgets> </customwidgets>
<resources/> <resources>
<include location="../images.qrc"/>
</resources>
<connections/> <connections/>
</ui> </ui>

View File

@ -24,7 +24,7 @@ const RsPhotoComment& PhotoCommentItem::getComment()
void PhotoCommentItem::setUp() void PhotoCommentItem::setUp()
{ {
ui->labelComment->setText(QString::fromStdString(mComment.mComment)); ui->labelComment->setText(QString::fromUtf8(mComment.mComment.c_str()));
QDateTime qtime; QDateTime qtime;
qtime.setTime_t(mComment.mMeta.mPublishTs); qtime.setTime_t(mComment.mMeta.mPublishTs);
QString timestamp = qtime.toString("dd.MMMM yyyy hh:mm"); QString timestamp = qtime.toString("dd.MMMM yyyy hh:mm");

View File

@ -3,19 +3,20 @@
#include "PhotoDialog.h" #include "PhotoDialog.h"
#include "ui_PhotoDialog.h" #include "ui_PhotoDialog.h"
#include "AddCommentDialog.h"
PhotoDialog::PhotoDialog(RsPhotoV2 *rs_photo, const RsPhotoPhoto &photo, QWidget *parent) : PhotoDialog::PhotoDialog(RsPhotoV2 *rs_photo, const RsPhotoPhoto &photo, QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::PhotoDialog), mRsPhoto(rs_photo), mPhotoQueue(new TokenQueue(mRsPhoto->getTokenService(), this)), ui(new Ui::PhotoDialog), mRsPhoto(rs_photo), mPhotoQueue(new TokenQueue(mRsPhoto->getTokenService(), this)),
mPhotoDetails(photo), mCommentDialog(NULL) mPhotoDetails(photo)
{ {
ui->setupUi(this); ui->setupUi(this);
setAttribute ( Qt::WA_DeleteOnClose, true ); setAttribute ( Qt::WA_DeleteOnClose, true );
connect(ui->toolButton_AddComment, SIGNAL(clicked()), this, SLOT(createComment()));
setUp();
connect(ui->pushButton_AddComment, SIGNAL(clicked()), this, SLOT(createComment()));
connect(ui->pushButton_AddCommentDlg, SIGNAL(clicked()), this, SLOT(addComment()));
setUp();
} }
PhotoDialog::~PhotoDialog() PhotoDialog::~PhotoDialog()
@ -36,15 +37,19 @@ void PhotoDialog::setUp()
requestComments(); requestComments();
} }
void PhotoDialog::addComment() void PhotoDialog::addComment()
{ {
mCommentDialog = new AddCommentDialog(this); AddCommentDialog dlg(this);
connect(mCommentDialog, SIGNAL(accepted()), this, SLOT(createComment())); if (dlg.exec() == QDialog::Accepted) {
connect(mCommentDialog, SIGNAL(rejected()), mCommentDialog, SLOT(deleteLater())); RsPhotoComment comment;
mCommentDialog->exec(); comment.mComment = dlg.getComment().toUtf8().constData();
uint32_t token;
comment.mMeta.mGroupId = mPhotoDetails.mMeta.mGroupId;
comment.mMeta.mParentId = mPhotoDetails.mMeta.mOrigMsgId;
mRsPhoto->submitComment(token, comment);
mPhotoQueue->queueRequest(token, TOKENREQ_MSGINFO, RS_TOKREQ_ANSTYPE_ACK, 0);
}
} }
void PhotoDialog::clearComments() void PhotoDialog::clearComments()
@ -93,7 +98,7 @@ void PhotoDialog::createComment()
RsPhotoComment comment; RsPhotoComment comment;
QString commentString = ui->lineEdit->text(); QString commentString = ui->lineEdit->text();
comment.mComment = commentString.toStdString(); comment.mComment = commentString.toUtf8().constData();
uint32_t token; uint32_t token;
comment.mMeta.mGroupId = mPhotoDetails.mMeta.mGroupId; comment.mMeta.mGroupId = mPhotoDetails.mMeta.mGroupId;

View File

@ -6,7 +6,6 @@
#include "retroshare/rsphotoV2.h" #include "retroshare/rsphotoV2.h"
#include "util/TokenQueue.h" #include "util/TokenQueue.h"
#include "PhotoCommentItem.h" #include "PhotoCommentItem.h"
#include "AddCommentDialog.h"
namespace Ui { namespace Ui {
class PhotoDialog; class PhotoDialog;
@ -57,8 +56,6 @@ private:
TokenQueue* mPhotoQueue; TokenQueue* mPhotoQueue;
RsPhotoPhoto mPhotoDetails; RsPhotoPhoto mPhotoDetails;
QSet<PhotoCommentItem*> mComments; QSet<PhotoCommentItem*> mComments;
AddCommentDialog* mCommentDialog;
}; };
#endif // PHOTODIALOG_H #endif // PHOTODIALOG_H

View File

@ -10,15 +10,16 @@
<height>566</height> <height>566</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle"> <property name="windowTitle">
<string>PhotoShare</string> <string>PhotoShare</string>
</property> </property>
<property name="windowIcon">
<iconset resource="../images.qrc">
<normaloff>:/images/rstray3.png</normaloff>:/images/rstray3.png</iconset>
</property>
<property name="sizeGripEnabled">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0"> <item row="0" column="0">
<widget class="QGroupBox" name="albumGroup"> <widget class="QGroupBox" name="albumGroup">
@ -54,7 +55,7 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="0" column="1" rowspan="2" colspan="2"> <item row="0" column="1" rowspan="2" colspan="4">
<widget class="QScrollArea" name="scrollArea"> <widget class="QScrollArea" name="scrollArea">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding"> <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
@ -76,7 +77,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>325</width> <width>369</width>
<height>18</height> <height>18</height>
</rect> </rect>
</property> </property>
@ -194,8 +195,15 @@
<item row="2" column="1"> <item row="2" column="1">
<widget class="QLineEdit" name="lineEdit"/> <widget class="QLineEdit" name="lineEdit"/>
</item> </item>
<item row="2" column="3">
<widget class="QPushButton" name="pushButton_AddCommentDlg">
<property name="text">
<string>Add Comment</string>
</property>
</widget>
</item>
<item row="2" column="2"> <item row="2" column="2">
<widget class="QToolButton" name="toolButton_AddComment"> <widget class="QPushButton" name="pushButton_AddComment">
<property name="text"> <property name="text">
<string>Comment</string> <string>Comment</string>
</property> </property>
@ -203,6 +211,8 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<resources/> <resources>
<include location="../images.qrc"/>
</resources>
<connections/> <connections/>
</ui> </ui>

View File

@ -75,9 +75,6 @@ PhotoShare::PhotoShare(QWidget *parent)
mAlbumSelected = NULL; mAlbumSelected = NULL;
mPhotoSelected = NULL; mPhotoSelected = NULL;
mSlideShow = NULL;
mAlbumDialog = NULL;
mPhotoDialog = NULL;
connect( ui.toolButton_NewAlbum, SIGNAL(clicked()), this, SLOT(createAlbum())); connect( ui.toolButton_NewAlbum, SIGNAL(clicked()), this, SLOT(createAlbum()));
connect( ui.toolButton_ViewAlbum, SIGNAL(clicked()), this, SLOT(OpenAlbumDialog())); connect( ui.toolButton_ViewAlbum, SIGNAL(clicked()), this, SLOT(OpenAlbumDialog()));
@ -198,10 +195,8 @@ void PhotoShare::checkUpdate()
void PhotoShare::OpenSlideShow() void PhotoShare::OpenSlideShow()
{ {
// TODO. // TODO.
if (!mAlbumSelected) if (!mAlbumSelected) {
{
// ALERT. // ALERT.
int ret = QMessageBox::information(this, tr("PhotoShare"), int ret = QMessageBox::information(this, tr("PhotoShare"),
tr("Please select an album before\n" tr("Please select an album before\n"
@ -210,16 +205,8 @@ void PhotoShare::OpenSlideShow()
return; return;
} }
if (mSlideShow) PhotoSlideShow *dlg = new PhotoSlideShow(mAlbumSelected->getAlbum(), NULL);
{ dlg->show();
mSlideShow->show();
}
else
{
mSlideShow = new PhotoSlideShow(mAlbumSelected->getAlbum(), NULL);
mSlideShow->show();
}
} }
@ -234,45 +221,17 @@ void PhotoShare::createAlbum()
void PhotoShare::OpenAlbumDialog() void PhotoShare::OpenAlbumDialog()
{ {
if (mAlbumSelected) { if (mAlbumSelected) {
AlbumDialog dlg(mAlbumSelected->getAlbum(), mPhotoQueue, rsPhotoV2);
if(mAlbumDialog == NULL) dlg.exec();
{
mAlbumDialog = new AlbumDialog(mAlbumSelected->getAlbum(), mPhotoQueue, rsPhotoV2);
connect(mAlbumDialog, SIGNAL(destroyed()), this, SLOT(SetAlbumDialogClosed()));
mAlbumDialog->show();
}else{
// bring dialog to front
mAlbumDialog->raise();
} }
} }
return;
}
void PhotoShare::OpenPhotoDialog() void PhotoShare::OpenPhotoDialog()
{ {
if(mPhotoSelected) if (mPhotoSelected) {
{ PhotoDialog *dlg = new PhotoDialog(rsPhotoV2, mPhotoSelected->getPhotoDetails());
if(mPhotoDialog == NULL) dlg->show();
{
mPhotoDialog = new PhotoDialog(rsPhotoV2, mPhotoSelected->getPhotoDetails());
connect(mPhotoDialog, SIGNAL(destroyed()), this, SLOT(SetPhotoDialogClosed()));
mPhotoDialog->show();
} }
else
{
mPhotoDialog->raise();
}
}
}
void PhotoShare::SetAlbumDialogClosed()
{
mAlbumDialog = NULL;
}
void PhotoShare::SetPhotoDialogClosed()
{
mPhotoDialog = NULL;
} }
/*************** Edit Photo Dialog ***************/ /*************** Edit Photo Dialog ***************/

View File

@ -33,19 +33,16 @@ public:
void notifySelection(PhotoShareItem* selection); void notifySelection(PhotoShareItem* selection);
private slots: private slots:
void checkUpdate(); void checkUpdate();
void createAlbum(); void createAlbum();
void OpenAlbumDialog(); void OpenAlbumDialog();
void OpenPhotoDialog(); void OpenPhotoDialog();
void OpenSlideShow(); void OpenSlideShow();
void SetAlbumDialogClosed();
void SetPhotoDialogClosed();
void updateAlbums(); void updateAlbums();
void subscribeToAlbum(); void subscribeToAlbum();
void deleteAlbum(const RsGxsGroupId&); void deleteAlbum(const RsGxsGroupId&);
private:
private:
/* Request Response Functions for loading data */ /* Request Response Functions for loading data */
void requestAlbumList(std::list<std::string>& ids); void requestAlbumList(std::list<std::string>& ids);
void requestAlbumData(std::list<RsGxsGroupId> &ids); void requestAlbumData(std::list<RsGxsGroupId> &ids);
@ -83,13 +80,9 @@ private:
void updatePhotos(); void updatePhotos();
private: private:
AlbumItem* mAlbumSelected; AlbumItem* mAlbumSelected;
PhotoItem* mPhotoSelected; PhotoItem* mPhotoSelected;
PhotoSlideShow* mSlideShow;
AlbumDialog* mAlbumDialog;
PhotoDialog* mPhotoDialog;
TokenQueue *mPhotoQueue; TokenQueue *mPhotoQueue;

View File

@ -10,9 +10,6 @@
<height>671</height> <height>671</height>
</rect> </rect>
</property> </property>
<property name="windowTitle">
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
@ -137,8 +134,6 @@
</item> </item>
</layout> </layout>
</widget> </widget>
<resources> <resources/>
<include location="../LinksCloud/images.qrc"/>
</resources>
<connections/> <connections/>
</ui> </ui>

View File

@ -10,24 +10,16 @@
<height>557</height> <height>557</height>
</rect> </rect>
</property> </property>
<property name="windowTitle">
<string/>
</property>
<layout class="QVBoxLayout" name="verticalLayout"> <layout class="QVBoxLayout" name="verticalLayout">
<item> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>-1</number> <number>-1</number>
</property> </property>
<property name="tabsClosable">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
</widget> </widget>
<resources> <resources/>
<include location="../LinksCloud/images.qrc"/>
</resources>
<connections/> <connections/>
</ui> </ui>

View File

@ -47,7 +47,7 @@
<widget class="QStatusBar" name="statusbar"/> <widget class="QStatusBar" name="statusbar"/>
<widget class="QToolBar" name="toolBar"> <widget class="QToolBar" name="toolBar">
<property name="contextMenuPolicy"> <property name="contextMenuPolicy">
<enum>Qt::NoContextMenu</enum> <enum>Qt::CustomContextMenu</enum>
</property> </property>
<property name="movable"> <property name="movable">
<bool>true</bool> <bool>true</bool>