Merge pull request #819 from csoler/v0.6-EditPosts

V0.6 edit posts
This commit is contained in:
csoler 2017-05-14 21:29:04 +02:00 committed by GitHub
commit 1824da11b0
7 changed files with 93 additions and 50 deletions

View File

@ -97,11 +97,12 @@ SubFileItem::SubFileItem(const RsFileHash &hash, const std::string &name, const
void SubFileItem::Setup() void SubFileItem::Setup()
{ {
connect( playButton, SIGNAL( clicked( void ) ), this, SLOT( play ( void ) ) ); connect( playButton, SIGNAL( clicked( ) ), this, SLOT( play ( ) ) );
connect( downloadButton, SIGNAL( clicked( void ) ), this, SLOT( download ( void ) ) ); connect( downloadButton, SIGNAL( clicked( ) ), this, SLOT( download ( ) ) );
connect( cancelButton, SIGNAL( clicked( void ) ), this, SLOT( cancel ( void ) ) ); connect( cancelButton, SIGNAL( clicked( ) ), this, SLOT( cancel( ) ) );
connect( copyLinkButton, SIGNAL( clicked( void ) ), this, SLOT( copyLink ( void ) ) ); connect( deleteButton, SIGNAL( clicked( ) ), this, SLOT( del( ) ) );
connect( saveButton, SIGNAL( clicked( void ) ), this, SLOT( save ( void ) ) ); connect( copyLinkButton, SIGNAL( clicked( ) ), this, SLOT( copyLink ( ) ) );
connect( saveButton, SIGNAL( clicked( ) ), this, SLOT( save ( ) ) );
/* once off check - if remote, check if we have it /* once off check - if remote, check if we have it
* NB: This check might be expensive - and it'll happen often! * NB: This check might be expensive - and it'll happen often!
@ -129,12 +130,19 @@ void SubFileItem::Setup()
} }
} }
deleteButton->setVisible(mFlag & SFI_FLAG_DELETE);
smaller(); smaller();
updateItemStatic(); updateItemStatic();
updateItem(); updateItem();
} }
void SubFileItem::del()
{
emit wantsToBeDeleted();
}
bool SubFileItem::done() bool SubFileItem::done()
{ {
return (mMode >= SFI_STATE_LOCAL); return (mMode >= SFI_STATE_LOCAL);

View File

@ -41,6 +41,7 @@ const uint32_t SFI_TYPE_CHANNEL = 0x0010;
const uint32_t SFI_TYPE_ATTACH = 0x0020; const uint32_t SFI_TYPE_ATTACH = 0x0020;
const uint32_t SFI_FLAG_CREATE = 0x1000; const uint32_t SFI_FLAG_CREATE = 0x1000;
const uint32_t SFI_FLAG_DELETE = 0x2000;
//! This create a gui widget that allows users to access files shared by user //! This create a gui widget that allows users to access files shared by user
@ -86,10 +87,14 @@ private slots:
void toggle(); void toggle();
void cancel(); void cancel();
void del();
void save(); void save();
void updateItem(); void updateItem();
signals:
void wantsToBeDeleted();
private: private:
void Setup(); void Setup();

View File

@ -6,12 +6,21 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>464</width> <width>547</width>
<height>71</height> <height>128</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gridLayout_4"> <layout class="QGridLayout" name="gridLayout_4">
<property name="margin"> <property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<property name="spacing"> <property name="spacing">
@ -26,27 +35,6 @@
<enum>QFrame::Sunken</enum> <enum>QFrame::Sunken</enum>
</property> </property>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="fileLabel">
<property name="font">
<font>
<weight>75</weight>
<italic>true</italic>
<bold>true</bold>
</font>
</property>
<property name="text">
<string notr="true">File Name</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0"> <item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
@ -210,6 +198,41 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QPushButton" name="deleteButton">
<property name="toolTip">
<string>Remove this item</string>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/denied16.png</normaloff>:/images/denied16.png</iconset>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="fileLabel">
<property name="font">
<font>
<weight>75</weight>
<italic>true</italic>
<bold>true</bold>
</font>
</property>
<property name="text">
<string notr="true">File Name</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>

View File

@ -351,7 +351,7 @@ void CreateGxsChannelMsg::addAttachment(const RsFileHash &hash, const std::strin
/* add widget in for new destination */ /* add widget in for new destination */
uint32_t flags = SFI_TYPE_CHANNEL; uint32_t flags = SFI_TYPE_CHANNEL | SFI_FLAG_DELETE;
if (local) if (local)
{ {
flags |= SFI_STATE_LOCAL; flags |= SFI_STATE_LOCAL;
@ -363,6 +363,8 @@ void CreateGxsChannelMsg::addAttachment(const RsFileHash &hash, const std::strin
SubFileItem *file = new SubFileItem(hash, fname, "", size, flags, srcId); // destroyed when fileFrame (this subfileitem) is destroyed SubFileItem *file = new SubFileItem(hash, fname, "", size, flags, srcId); // destroyed when fileFrame (this subfileitem) is destroyed
connect(file,SIGNAL(wantsToBeDeleted()),this,SLOT(deleteAttachment())) ;
mAttachments.push_back(file); mAttachments.push_back(file);
QLayout *layout = fileFrame->layout(); QLayout *layout = fileFrame->layout();
layout->addWidget(file); layout->addWidget(file);
@ -375,6 +377,24 @@ void CreateGxsChannelMsg::addAttachment(const RsFileHash &hash, const std::strin
return; return;
} }
void CreateGxsChannelMsg::deleteAttachment()
{
// grab the item who sent the request
SubFileItem *file_item = qobject_cast<SubFileItem *>(QObject::sender());
for(std::list<SubFileItem*>::iterator it(mAttachments.begin());it!=mAttachments.end();)
if(*it == file_item)
{
SubFileItem *item = *it ;
it = mAttachments.erase(it) ;
fileFrame->layout()->removeWidget(file_item) ;
delete item ;
}
else
++it;
}
void CreateGxsChannelMsg::addExtraFile() void CreateGxsChannelMsg::addExtraFile()
{ {
/* add a SubFileItem to the attachment section */ /* add a SubFileItem to the attachment section */

View File

@ -60,6 +60,7 @@ protected:
private slots: private slots:
void addExtraFile(); void addExtraFile();
void checkAttachmentReady(); void checkAttachmentReady();
void deleteAttachment();
void cancelMsg(); void cancelMsg();
void sendMsg(); void sendMsg();

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>581</width> <width>875</width>
<height>479</height> <height>659</height>
</rect> </rect>
</property> </property>
<property name="acceptDrops"> <property name="acceptDrops">
@ -60,7 +60,7 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="currentIndex"> <property name="currentIndex">
<number>0</number> <number>1</number>
</property> </property>
<widget class="QWidget" name="channelPostTab"> <widget class="QWidget" name="channelPostTab">
<attribute name="title"> <attribute name="title">
@ -302,8 +302,8 @@ p, li { white-space: pre-wrap; }
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>523</width> <width>767</width>
<height>24</height> <height>42</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">

View File

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>828</width> <width>880</width>
<height>557</height> <height>557</height>
</rect> </rect>
</property> </property>
@ -184,20 +184,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QToolButton" name="editButton">
<property name="toolTip">
<string>Edit current post</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../images.qrc">
<normaloff>:/images/edit_24.png</normaloff>:/images/edit_24.png</iconset>
</property>
</widget>
</item>
<item> <item>
<spacer name="horizontalSpacer"> <spacer name="horizontalSpacer">
<property name="orientation"> <property name="orientation">