mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-01-12 07:59:29 -05:00
added show unread only button. Merged list/grid buttons
This commit is contained in:
parent
3ba9a1eb5d
commit
89444537b1
@ -306,7 +306,7 @@ void RsGxsChannelPostFilesModel::setFilter(const QStringList& strings, uint32_t&
|
||||
if(strings.empty())
|
||||
{
|
||||
mFilteredFiles.clear();
|
||||
for(int i=0;i<mFiles.size();++i)
|
||||
for(uint32_t i=0;i<mFiles.size();++i)
|
||||
mFilteredFiles.push_back(i);
|
||||
}
|
||||
else
|
||||
@ -314,7 +314,7 @@ void RsGxsChannelPostFilesModel::setFilter(const QStringList& strings, uint32_t&
|
||||
mFilteredFiles.clear();
|
||||
//mFilteredPosts.push_back(0);
|
||||
|
||||
for(int i=0;i<mFiles.size();++i)
|
||||
for(uint32_t i=0;i<mFiles.size();++i)
|
||||
{
|
||||
bool passes_strings = true;
|
||||
|
||||
|
@ -169,35 +169,30 @@ void RsGxsChannelPostsModel::getFilesList(std::list<ChannelPostFileInfo>& files)
|
||||
files.push_back(it.second);
|
||||
}
|
||||
|
||||
void RsGxsChannelPostsModel::setFilter(const QStringList& strings, uint32_t& count)
|
||||
void RsGxsChannelPostsModel::setFilter(const QStringList& strings,bool only_unread, uint32_t& count)
|
||||
{
|
||||
preMods();
|
||||
|
||||
beginRemoveRows(QModelIndex(),0,rowCount()-1);
|
||||
endRemoveRows();
|
||||
|
||||
if(strings.empty())
|
||||
mFilteredPosts.clear();
|
||||
//mFilteredPosts.push_back(0);
|
||||
|
||||
for(size_t i=0;i<mPosts.size();++i)
|
||||
{
|
||||
mFilteredPosts.clear();
|
||||
for(size_t i=0;i<mPosts.size();++i)
|
||||
bool passes_strings = true;
|
||||
|
||||
for(auto& s:strings)
|
||||
passes_strings = passes_strings && QString::fromStdString(mPosts[i].mMeta.mMsgName).contains(s,Qt::CaseInsensitive);
|
||||
|
||||
if(strings.empty())
|
||||
passes_strings = true;
|
||||
|
||||
if(passes_strings && (!only_unread || (IS_MSG_UNREAD(mPosts[i].mMeta.mMsgStatus) || IS_MSG_NEW(mPosts[i].mMeta.mMsgStatus))))
|
||||
mFilteredPosts.push_back(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
mFilteredPosts.clear();
|
||||
//mFilteredPosts.push_back(0);
|
||||
|
||||
for(size_t i=0;i<mPosts.size();++i)
|
||||
{
|
||||
bool passes_strings = true;
|
||||
|
||||
for(auto& s:strings)
|
||||
passes_strings = passes_strings && QString::fromStdString(mPosts[i].mMeta.mMsgName).contains(s,Qt::CaseInsensitive);
|
||||
|
||||
if(passes_strings)
|
||||
mFilteredPosts.push_back(i);
|
||||
}
|
||||
}
|
||||
count = mFilteredPosts.size();
|
||||
|
||||
std::cerr << "After filtering: " << count << " posts remain." << std::endl;
|
||||
|
@ -134,7 +134,7 @@ public:
|
||||
void setMsgReadStatus(const QModelIndex &i, bool read_status);
|
||||
void setAllMsgReadStatus(bool read_status);
|
||||
|
||||
void setFilter(const QStringList &strings, uint32_t &count) ;
|
||||
void setFilter(const QStringList &strings, bool only_unread,uint32_t &count) ;
|
||||
|
||||
#ifdef TODO
|
||||
void setAuthorOpinion(const QModelIndex& indx,RsOpinion op);
|
||||
@ -232,8 +232,6 @@ private:
|
||||
std::vector<int> mFilteredPosts; // stores the list of displayes indices due to filtering.
|
||||
std::vector<RsGxsChannelPost> mPosts ; // store the list of posts updated from rsForums.
|
||||
|
||||
//std::map<RsGxsMessageId,std::vector<std::pair<time_t,RsGxsMessageId> > > mPostVersions; // stores versions of posts
|
||||
|
||||
QColor mTextColorRead ;
|
||||
QColor mTextColorUnread ;
|
||||
QColor mTextColorUnreadChildren;
|
||||
|
@ -290,12 +290,14 @@ GxsChannelPostsWidgetWithModel::GxsChannelPostsWidgetWithModel(const RsGxsGroupI
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->list_TB->setIcon(FilesDefs::getIconFromQtResourcePath(":icons/svg/listlayout.svg"));
|
||||
ui->grid_TB->setIcon(FilesDefs::getIconFromQtResourcePath(":icons/svg/gridlayout.svg"));
|
||||
whileBlocking(ui->grid_TB)->setChecked(true);
|
||||
ui->viewType_TB->setIcon(FilesDefs::getIconFromQtResourcePath(":icons/svg/gridlayout.svg"));
|
||||
ui->viewType_TB->setToolTip(tr("Click to switch to list view"));
|
||||
connect(ui->viewType_TB,SIGNAL(clicked()),this,SLOT(switchView()));
|
||||
|
||||
connect(ui->list_TB,SIGNAL(clicked()),this,SLOT(switchView()));
|
||||
connect(ui->grid_TB,SIGNAL(clicked()),this,SLOT(switchView()));
|
||||
ui->showUnread_TB->setIcon(FilesDefs::getIconFromQtResourcePath(":/images/message-state-unread.png"));
|
||||
ui->showUnread_TB->setChecked(false);
|
||||
ui->showUnread_TB->setToolTip(tr("Show unread posts only"));
|
||||
connect(ui->showUnread_TB,SIGNAL(toggled(bool)),this,SLOT(switchOnlyUnread(bool)));
|
||||
|
||||
ui->postsTree->setModel(mChannelPostsModel = new RsGxsChannelPostsModel());
|
||||
ui->postsTree->setItemDelegate(mChannelPostsDelegate = new ChannelPostDelegate());
|
||||
@ -485,16 +487,16 @@ void GxsChannelPostsWidgetWithModel::switchView()
|
||||
|
||||
if(mChannelPostsModel->getMode() == RsGxsChannelPostsModel::TREE_MODE_GRID)
|
||||
{
|
||||
whileBlocking(ui->list_TB)->setChecked(true);
|
||||
whileBlocking(ui->grid_TB)->setChecked(false);
|
||||
ui->viewType_TB->setIcon(FilesDefs::getIconFromQtResourcePath(":icons/svg/listlayout.svg"));
|
||||
ui->viewType_TB->setToolTip(tr("Click to switch to grid view"));
|
||||
|
||||
mChannelPostsDelegate->setWidgetGrid(false);
|
||||
mChannelPostsModel->setMode(RsGxsChannelPostsModel::TREE_MODE_LIST);
|
||||
}
|
||||
else
|
||||
{
|
||||
whileBlocking(ui->list_TB)->setChecked(false);
|
||||
whileBlocking(ui->grid_TB)->setChecked(true);
|
||||
ui->viewType_TB->setIcon(FilesDefs::getIconFromQtResourcePath(":icons/svg/gridlayout.svg"));
|
||||
ui->viewType_TB->setToolTip(tr("Click to switch to list view"));
|
||||
|
||||
mChannelPostsDelegate->setWidgetGrid(true);
|
||||
mChannelPostsModel->setMode(RsGxsChannelPostsModel::TREE_MODE_GRID);
|
||||
@ -749,10 +751,8 @@ void GxsChannelPostsWidgetWithModel::postChannelPostLoad()
|
||||
mChannelPostsModel->getFilesList(files);
|
||||
mChannelFilesModel->setFiles(files);
|
||||
|
||||
//ui->channelFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_FILE);
|
||||
//ui->channelFiles_TV->resizeColumnToContents(RsGxsChannelPostFilesModel::COLUMN_FILES_SIZE);
|
||||
ui->channelFiles_TV->setAutoSelect(true);
|
||||
|
||||
ui->channelFiles_TV->sortByColumn(0, Qt::AscendingOrder);
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidgetWithModel::updateDisplay(bool complete)
|
||||
@ -1057,15 +1057,17 @@ void GxsChannelPostsWidgetWithModel::setViewMode(int viewMode)
|
||||
#endif
|
||||
}
|
||||
|
||||
void GxsChannelPostsWidgetWithModel::switchOnlyUnread(bool)
|
||||
{
|
||||
filterChanged(ui->filterLineEdit->text());
|
||||
std::cerr << "Switched to unread/read"<< std::endl;
|
||||
}
|
||||
void GxsChannelPostsWidgetWithModel::filterChanged(QString s)
|
||||
{
|
||||
QStringList ql = s.split(' ',QString::SkipEmptyParts);
|
||||
uint32_t count;
|
||||
mChannelPostsModel->setFilter(ql,count);
|
||||
mChannelPostsModel->setFilter(ql,ui->showUnread_TB->isChecked(),count);
|
||||
mChannelFilesModel->setFilter(ql,count);
|
||||
|
||||
//mChannelPostFilesProxyModel->setFilterKeyColumn(RsGxsChannelPostFilesModel::COLUMN_FILES_NAME);
|
||||
//mChannelPostFilesProxyModel->setFilterRegExp(s) ;// triggers a re-display. s is actually not used.
|
||||
}
|
||||
|
||||
#ifdef TODO
|
||||
|
@ -152,6 +152,7 @@ private slots:
|
||||
void copyMessageLink();
|
||||
void updateZoomFactor(bool zoom_or_unzoom);
|
||||
void switchView();
|
||||
void switchOnlyUnread(bool b);
|
||||
|
||||
public slots:
|
||||
void sortColumnFiles(int col,Qt::SortOrder so);
|
||||
|
@ -121,7 +121,7 @@
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="grid_TB">
|
||||
<widget class="QToolButton" name="showUnread_TB">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
@ -131,12 +131,12 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="list_TB">
|
||||
<widget class="QToolButton" name="viewType_TB">
|
||||
<property name="text">
|
||||
<string>...</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
Loading…
Reference in New Issue
Block a user