mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-23 22:01:05 -05:00
added post editing
This commit is contained in:
parent
f8deebfc5a
commit
f1092b4a29
@ -19,6 +19,7 @@
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
#include <QMenu>
|
||||||
#include <QSignalMapper>
|
#include <QSignalMapper>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
@ -261,40 +262,6 @@ QSize ChannelPostFilesDelegate::sizeHint(const QStyleOptionViewItem& option, con
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// class RsGxsChannelPostFilesProxyModel: public QSortFilterProxyModel
|
|
||||||
// {
|
|
||||||
// public:
|
|
||||||
// RsGxsChannelPostFilesProxyModel(QObject *parent = NULL): QSortFilterProxyModel(parent) {}
|
|
||||||
//
|
|
||||||
// bool lessThan(const QModelIndex& left, const QModelIndex& right) const override
|
|
||||||
// {
|
|
||||||
// return left.data(RsGxsChannelPostFilesModel::SortRole) < right.data(RsGxsChannelPostFilesModel::SortRole) ;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override
|
|
||||||
// {
|
|
||||||
// if(filter_list.empty())
|
|
||||||
// return true;
|
|
||||||
//
|
|
||||||
// QString name = sourceModel()->data(sourceModel()->index(source_row,RsGxsChannelPostFilesModel::COLUMN_FILES_NAME,source_parent)).toString();
|
|
||||||
//
|
|
||||||
// for(auto& s:filter_list)
|
|
||||||
// if(!name.contains(s,Qt::CaseInsensitive))
|
|
||||||
// return false;
|
|
||||||
//
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// void setFilterList(const QStringList& str)
|
|
||||||
// {
|
|
||||||
// filter_list = str;
|
|
||||||
// invalidateFilter();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private:
|
|
||||||
// QStringList filter_list;
|
|
||||||
// };
|
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupId &channelId, QWidget *parent) :
|
GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupId &channelId, QWidget *parent) :
|
||||||
GxsMessageFrameWidget(rsGxsChannels, parent),
|
GxsMessageFrameWidget(rsGxsChannels, parent),
|
||||||
@ -312,11 +279,6 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI
|
|||||||
ui->channelPostFiles_TV->setSortingEnabled(true);
|
ui->channelPostFiles_TV->setSortingEnabled(true);
|
||||||
ui->channelPostFiles_TV->sortByColumn(0, Qt::AscendingOrder);
|
ui->channelPostFiles_TV->sortByColumn(0, Qt::AscendingOrder);
|
||||||
|
|
||||||
// mChannelPostFilesProxyModel = new RsGxsChannelPostFilesProxyModel(this);
|
|
||||||
// mChannelPostFilesProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
|
|
||||||
// mChannelPostFilesProxyModel->setSourceModel(mChannelPostFilesModel);
|
|
||||||
// mChannelPostFilesProxyModel->setDynamicSortFilter(true);
|
|
||||||
|
|
||||||
ui->channelFiles_TV->setModel(mChannelFilesModel = new RsGxsChannelPostFilesModel());
|
ui->channelFiles_TV->setModel(mChannelFilesModel = new RsGxsChannelPostFilesModel());
|
||||||
ui->channelFiles_TV->setItemDelegate(new ChannelPostFilesDelegate());
|
ui->channelFiles_TV->setItemDelegate(new ChannelPostFilesDelegate());
|
||||||
ui->channelFiles_TV->setPlaceholderText(tr("No files in the channel, or no channel selected"));
|
ui->channelFiles_TV->setPlaceholderText(tr("No files in the channel, or no channel selected"));
|
||||||
@ -327,6 +289,8 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI
|
|||||||
connect(ui->channelFiles_TV->header(),SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(sortColumnFiles(int,Qt::SortOrder)));
|
connect(ui->channelFiles_TV->header(),SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(sortColumnFiles(int,Qt::SortOrder)));
|
||||||
|
|
||||||
connect(ui->postsTree->selectionModel(),SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)),this,SLOT(showPostDetails()));
|
connect(ui->postsTree->selectionModel(),SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)),this,SLOT(showPostDetails()));
|
||||||
|
connect(ui->postsTree,SIGNAL(customContextMenuRequested(const QPoint&)),this,SLOT(postContextMenu(const QPoint&)));
|
||||||
|
|
||||||
connect(mChannelPostsModel,SIGNAL(channelPostsLoaded()),this,SLOT(postChannelPostLoad()));
|
connect(mChannelPostsModel,SIGNAL(channelPostsLoaded()),this,SLOT(postChannelPostLoad()));
|
||||||
|
|
||||||
ui->postName_LB->hide();
|
ui->postName_LB->hide();
|
||||||
@ -404,10 +368,28 @@ void GxsChannelPostsWidgetWithModel::sortColumnFiles(int col,Qt::SortOrder so)
|
|||||||
mChannelFilesModel->sort(col,so);
|
mChannelFilesModel->sort(col,so);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GxsChannelPostsWidgetWithModel::postContextMenu(const QPoint&)
|
||||||
|
{
|
||||||
|
QMenu menu(this);
|
||||||
|
|
||||||
|
if(IS_GROUP_PUBLISHER(mGroup.mMeta.mSubscribeFlags))
|
||||||
|
{
|
||||||
|
menu.addAction(FilesDefs::getIconFromQtResourcePath(":/images/edit_16.png"), tr("Edit"), this, SLOT(editPost()));
|
||||||
|
menu.exec(QCursor::pos());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GxsChannelPostsWidgetWithModel::editPost()
|
||||||
|
{
|
||||||
|
QModelIndex index = ui->postsTree->selectionModel()->currentIndex();
|
||||||
|
RsGxsChannelPost post = index.data(Qt::UserRole).value<RsGxsChannelPost>() ;
|
||||||
|
|
||||||
|
CreateGxsChannelMsg *msgDialog = new CreateGxsChannelMsg(post.mMeta.mGroupId,post.mMeta.mMsgId);
|
||||||
|
msgDialog->show();
|
||||||
|
}
|
||||||
|
|
||||||
void GxsChannelPostsWidgetWithModel::handlePostsTreeSizeChange(QSize s)
|
void GxsChannelPostsWidgetWithModel::handlePostsTreeSizeChange(QSize s)
|
||||||
{
|
{
|
||||||
// adjustSize();
|
|
||||||
//
|
|
||||||
int n_columns = std::max(1,(int)floor(s.width() / (COLUMN_SIZE_FONT_FACTOR_W*QFontMetricsF(font()).height())));
|
int n_columns = std::max(1,(int)floor(s.width() / (COLUMN_SIZE_FONT_FACTOR_W*QFontMetricsF(font()).height())));
|
||||||
std::cerr << "nb columns: " << n_columns << std::endl;
|
std::cerr << "nb columns: " << n_columns << std::endl;
|
||||||
|
|
||||||
|
@ -139,6 +139,8 @@ private slots:
|
|||||||
void settingsChanged();
|
void settingsChanged();
|
||||||
void handlePostsTreeSizeChange(QSize s);
|
void handlePostsTreeSizeChange(QSize s);
|
||||||
void postChannelPostLoad();
|
void postChannelPostLoad();
|
||||||
|
void editPost();
|
||||||
|
void postContextMenu(const QPoint&);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void sortColumnFiles(int col,Qt::SortOrder so);
|
void sortColumnFiles(int col,Qt::SortOrder so);
|
||||||
|
@ -364,6 +364,9 @@ p, li { white-space: pre-wrap; }
|
|||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
<widget class="RSTreeView" name="postsTree">
|
<widget class="RSTreeView" name="postsTree">
|
||||||
|
<property name="contextMenuPolicy">
|
||||||
|
<enum>Qt::CustomContextMenu</enum>
|
||||||
|
</property>
|
||||||
<property name="sizeAdjustPolicy">
|
<property name="sizeAdjustPolicy">
|
||||||
<enum>QAbstractScrollArea::AdjustToContents</enum>
|
<enum>QAbstractScrollArea::AdjustToContents</enum>
|
||||||
</property>
|
</property>
|
||||||
|
Loading…
Reference in New Issue
Block a user