started GUI part for distant network search of groups

This commit is contained in:
csoler 2018-06-20 22:30:44 +02:00
parent c67084b7de
commit 91fd38d46f
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
7 changed files with 49 additions and 0 deletions

View File

@ -18,6 +18,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, * Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
****************************************************************/ ****************************************************************/
#include <iostream>
#include "GroupTreeWidget.h" #include "GroupTreeWidget.h"
#include "ui_GroupTreeWidget.h" #include "ui_GroupTreeWidget.h"
@ -119,6 +121,10 @@ GroupTreeWidget::GroupTreeWidget(QWidget *parent) :
ui->filterLineEdit->addFilter(QIcon(), tr("Description"), FILTER_DESC_INDEX , tr("Search Description")); ui->filterLineEdit->addFilter(QIcon(), tr("Description"), FILTER_DESC_INDEX , tr("Search Description"));
ui->filterLineEdit->setCurrentFilter(FILTER_NAME_INDEX); ui->filterLineEdit->setCurrentFilter(FILTER_NAME_INDEX);
ui->distantSearchLineEdit->setPlaceholderText(tr("Search entire network...")) ;
connect(ui->distantSearchLineEdit,SIGNAL(returnPressed()),this,SLOT(distantSearch())) ;
/* Initialize display button */ /* Initialize display button */
initDisplayMenu(ui->displayButton); initDisplayMenu(ui->displayButton);
@ -749,6 +755,13 @@ void GroupTreeWidget::resort(QTreeWidgetItem *categoryItem)
} }
} }
void GroupTreeWidget::distantSearch()
{
emit distantSearchRequested(ui->distantSearchLineEdit->text());
ui->distantSearchLineEdit->clear();
}
void GroupTreeWidget::sort() void GroupTreeWidget::sort()
{ {
resort(NULL); resort(NULL);

View File

@ -110,6 +110,7 @@ signals:
void treeCustomContextMenuRequested(const QPoint &pos); void treeCustomContextMenuRequested(const QPoint &pos);
void treeCurrentItemChanged(const QString &id); void treeCurrentItemChanged(const QString &id);
void treeItemActivated(const QString &id); void treeItemActivated(const QString &id);
void distantSearchRequested(const QString&) ;
protected: protected:
void changeEvent(QEvent *e); void changeEvent(QEvent *e);
@ -119,6 +120,7 @@ private slots:
void currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous); void currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous);
void itemActivated(QTreeWidgetItem *item, int column); void itemActivated(QTreeWidgetItem *item, int column);
void filterChanged(); void filterChanged();
void distantSearch();
void sort(); void sort();

View File

@ -124,6 +124,9 @@
</column> </column>
</widget> </widget>
</item> </item>
<item>
<widget class="QLineEdit" name="distantSearchLineEdit"/>
</item>
</layout> </layout>
</widget> </widget>
<customwidgets> <customwidgets>

View File

@ -94,6 +94,7 @@ GxsGroupFrameDialog::GxsGroupFrameDialog(RsGxsIfaceHelper *ifaceImpl, QWidget *p
connect(ui->groupTreeWidget, SIGNAL(treeCustomContextMenuRequested(QPoint)), this, SLOT(groupTreeCustomPopupMenu(QPoint))); connect(ui->groupTreeWidget, SIGNAL(treeCustomContextMenuRequested(QPoint)), this, SLOT(groupTreeCustomPopupMenu(QPoint)));
connect(ui->groupTreeWidget, SIGNAL(treeCurrentItemChanged(QString)), this, SLOT(changedGroup(QString))); connect(ui->groupTreeWidget, SIGNAL(treeCurrentItemChanged(QString)), this, SLOT(changedGroup(QString)));
connect(ui->groupTreeWidget->treeWidget(), SIGNAL(signalMouseMiddleButtonClicked(QTreeWidgetItem*)), this, SLOT(groupTreeMiddleButtonClicked(QTreeWidgetItem*))); connect(ui->groupTreeWidget->treeWidget(), SIGNAL(signalMouseMiddleButtonClicked(QTreeWidgetItem*)), this, SLOT(groupTreeMiddleButtonClicked(QTreeWidgetItem*)));
connect(ui->groupTreeWidget, SIGNAL(distantSearchRequested(const QString&)), this, SLOT(searchNetwork(const QString&)));
connect(ui->messageTabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(messageTabCloseRequested(int))); connect(ui->messageTabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(messageTabCloseRequested(int)));
connect(ui->messageTabWidget, SIGNAL(currentChanged(int)), this, SLOT(messageTabChanged(int))); connect(ui->messageTabWidget, SIGNAL(currentChanged(int)), this, SLOT(messageTabChanged(int)));
@ -1078,3 +1079,20 @@ void GxsGroupFrameDialog::loadRequest(const TokenQueue *queue, const TokenReques
} }
} }
} }
TurtleRequestId GxsGroupFrameDialog::distantSearch(const QString& search_string) // this should be overloaded in the child class
{
std::cerr << "Searching for \"" << search_string.toStdString() << "\". Function is not implemented yet." << std::endl;
return 0;
}
void GxsGroupFrameDialog::searchNetwork(const QString& search_string)
{
uint32_t request_id = distantSearch(search_string);
if(request_id == 0)
return ;
mSearchGroups[request_id] = ui->groupTreeWidget->addCategoryItem(tr("Search for")+ " \"" + search_string + "\"", QIcon(icon(ICON_SEARCH)), true);
}

View File

@ -67,6 +67,7 @@ public:
ICON_SUBSCRIBED_GROUP, ICON_SUBSCRIBED_GROUP,
ICON_POPULAR_GROUP, ICON_POPULAR_GROUP,
ICON_OTHER_GROUP, ICON_OTHER_GROUP,
ICON_SEARCH,
ICON_DEFAULT ICON_DEFAULT
}; };
@ -129,11 +130,13 @@ private slots:
void sharePublishKey(); void sharePublishKey();
void loadComment(const RsGxsGroupId &grpId, const QVector<RsGxsMessageId>& msg_versions,const RsGxsMessageId &most_recent_msgId, const QString &title); void loadComment(const RsGxsGroupId &grpId, const QVector<RsGxsMessageId>& msg_versions,const RsGxsMessageId &most_recent_msgId, const QString &title);
void searchNetwork(const QString &search_string) ;
private: private:
virtual QString text(TextType type) = 0; virtual QString text(TextType type) = 0;
virtual QString icon(IconType type) = 0; virtual QString icon(IconType type) = 0;
virtual QString settingsGroupName() = 0; virtual QString settingsGroupName() = 0;
virtual TurtleRequestId distantSearch(const QString& search_string) ;
virtual GxsGroupDialog *createNewGroupDialog(TokenQueue *tokenQueue) = 0; virtual GxsGroupDialog *createNewGroupDialog(TokenQueue *tokenQueue) = 0;
virtual GxsGroupDialog *createGroupDialog(TokenQueue *tokenQueue, RsTokenService *tokenService, GxsGroupDialog::Mode mode, RsGxsGroupId groupId) = 0; virtual GxsGroupDialog *createGroupDialog(TokenQueue *tokenQueue, RsTokenService *tokenService, GxsGroupDialog::Mode mode, RsGxsGroupId groupId) = 0;
@ -201,6 +204,8 @@ private:
Ui::GxsGroupFrameDialog *ui; Ui::GxsGroupFrameDialog *ui;
std::list<RsGroupMetaData> mCachedGroupMetas; std::list<RsGroupMetaData> mCachedGroupMetas;
std::map<uint32_t,QTreeWidgetItem*> mSearchGroups ;
}; };
#endif #endif

View File

@ -137,6 +137,8 @@ QString GxsChannelDialog::icon(IconType type)
return ":/images/folder_green.png"; return ":/images/folder_green.png";
case ICON_OTHER_GROUP: case ICON_OTHER_GROUP:
return ":/images/folder_yellow.png"; return ":/images/folder_yellow.png";
case ICON_SEARCH:
return ":/images/find.png";
case ICON_DEFAULT: case ICON_DEFAULT:
return ":/images/channels.png"; return ":/images/channels.png";
} }
@ -334,3 +336,8 @@ void GxsChannelDialog::groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo
groupItemInfo.icon = iconIt.value(); groupItemInfo.icon = iconIt.value();
} }
} }
TurtleRequestId GxsChannelDialog::distantSearch(const QString& search_string)
{
return rsGxsChannels->turtleSearchRequest(search_string.toStdString()) ;
}

View File

@ -51,6 +51,7 @@ protected:
virtual QString getHelpString() const ; virtual QString getHelpString() const ;
virtual void groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo, const RsUserdata *userdata); virtual void groupInfoToGroupItemInfo(const RsGroupMetaData &groupInfo, GroupItemInfo &groupItemInfo, const RsUserdata *userdata);
virtual TurtleRequestId distantSearch(const QString& search_string) ;
private slots: private slots:
void toggleAutoDownload(); void toggleAutoDownload();
void setDefaultDirectory(); void setDefaultDirectory();