diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostFilesModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostFilesModel.cpp index 987144162..dd19f600d 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostFilesModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostFilesModel.cpp @@ -306,7 +306,7 @@ void RsGxsChannelPostFilesModel::setFilter(const QStringList& strings, uint32_t& if(strings.empty()) { mFilteredFiles.clear(); - for(int i=0;i& 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 mFilteredPosts; // stores the list of displayes indices due to filtering. std::vector mPosts ; // store the list of posts updated from rsForums. - //std::map > > mPostVersions; // stores versions of posts - QColor mTextColorRead ; QColor mTextColorUnread ; QColor mTextColorUnreadChildren; diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp index 47964bab7..7246aef19 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.cpp @@ -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 diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h index 095db9698..cefb6cb09 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.h @@ -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); diff --git a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui index bc01e768c..ffdc04022 100644 --- a/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui +++ b/retroshare-gui/src/gui/gxschannels/GxsChannelPostsWidgetWithModel.ui @@ -121,7 +121,7 @@ - + ... @@ -131,12 +131,12 @@ - + ... - true + false