client: Convert /list #chan to UI advanced search
authorShane Synan <digitalcircuit36939@gmail.com>
Fri, 22 Jun 2018 01:44:50 +0000 (20:44 -0500)
committerManuel Nickschas <sputnick@quassel-irc.org>
Thu, 12 Jul 2018 22:36:39 +0000 (00:36 +0200)
Pass "/list" parameters to ChannelListDlg when opening, allowing for
"/list #channel", <Enter> to search in a similar fashion to current
stable release.

Add documentation to the showChannelList()/related functions.

Prompt when "/list" is called without a valid network selected.  This
fixes running "/list" before any networks are selected resulting in a
channel list dialog that wouldn't do anything.

src/client/client.h
src/client/clientuserinputhandler.cpp
src/qtui/channellistdlg.cpp
src/qtui/channellistdlg.h
src/qtui/mainwin.cpp
src/qtui/mainwin.h
src/uisupport/networkmodelcontroller.cpp
src/uisupport/networkmodelcontroller.h

index 7850b0f..29ee342 100644 (file)
@@ -167,15 +167,33 @@ public:
         emit showIgnoreList(ignoreRule);
     }
 
-    void displayChannelList(NetworkId networkId) {
-        emit showChannelList(networkId);
+    /**
+     * Request to show the channel list dialog for the network, optionally searching by channel name
+     *
+     * @see Client::showChannelList()
+     *
+     * @param networkId       Network ID for associated network
+     * @param channelFilters  Partial channel name to search for, or empty to show all
+     */
+    void displayChannelList(NetworkId networkId, const QString &channelFilters = {})
+    {
+        emit showChannelList(networkId, channelFilters);
     }
 
 signals:
     void requestNetworkStates();
 
     void showConfigWizard(const QVariantMap &coredata);
-    void showChannelList(NetworkId networkId);
+
+    /**
+     * Request to show the channel list dialog for the network, optionally searching by channel name
+     *
+     * @see MainWin::showChannelList()
+     *
+     * @param networkId       Network ID for associated network
+     * @param channelFilters  Partial channel name to search for, or empty to show all
+     */
+    void showChannelList(NetworkId networkId, const QString &channelFilters = {});
     void showIgnoreList(QString ignoreRule);
 
     void connected();
index 95a9988..1be2692 100644 (file)
@@ -142,8 +142,8 @@ void ClientUserInputHandler::handleIgnore(const BufferInfo &bufferInfo, const QS
 
 void ClientUserInputHandler::handleList(const BufferInfo &bufferInfo, const QString &text)
 {
-    Q_UNUSED(text)
-    Client::instance()->displayChannelList(bufferInfo.networkId());
+    // Pass along any potential search parameters
+    Client::instance()->displayChannelList(bufferInfo.networkId(), text);
 }
 
 
index 76b81bb..f8b7028 100644 (file)
@@ -84,6 +84,15 @@ void ChannelListDlg::setNetwork(NetworkId netId)
 }
 
 
+void ChannelListDlg::setChannelFilters(const QString &channelFilters)
+{
+    // Enable advanced mode if searching
+    setAdvancedMode(!channelFilters.isEmpty());
+    // Set channel search text after setting advanced mode so it's not cleared
+    ui.channelNameLineEdit->setText(channelFilters.trimmed());
+}
+
+
 void ChannelListDlg::requestSearch()
 {
     _listFinished = false;
index e8a01ff..b818778 100644 (file)
@@ -40,6 +40,16 @@ public:
 
     void setNetwork(NetworkId netId);
 
+    /**
+     * Set the channel search string, enabling advanced mode if needed
+     *
+     * Sets the channel name search text to the specified string, enabling advanced mode.  If search
+     * string is empty, advanced mode will be automatically hidden.
+     *
+     * @param channelFilters Partial channel name to search for, or empty to not filter by name
+     */
+    void setChannelFilters(const QString &channelFilters);
+
 protected slots:
     void requestSearch();
     void receiveChannelList(const NetworkId &netId, const QStringList &channelFilters, const QList<IrcListHelper::ChannelDescription> &channelList);
index 99aaff3..fd25883 100644 (file)
@@ -206,8 +206,12 @@ void MainWin::init()
     connect(Client::instance(), SIGNAL(networkRemoved(NetworkId)), SLOT(clientNetworkRemoved(NetworkId)));
     connect(Client::messageModel(), SIGNAL(rowsInserted(const QModelIndex &, int, int)),
         SLOT(messagesInserted(const QModelIndex &, int, int)));
-    connect(GraphicalUi::contextMenuActionProvider(), SIGNAL(showChannelList(NetworkId)), SLOT(showChannelList(NetworkId)));
-    connect(Client::instance(), SIGNAL(showChannelList(NetworkId)), SLOT(showChannelList(NetworkId)));
+    connect(GraphicalUi::contextMenuActionProvider(),
+            SIGNAL(showChannelList(NetworkId, const QString &)),
+            SLOT(showChannelList(NetworkId, const QString &)));
+    connect(Client::instance(),
+            SIGNAL(showChannelList(NetworkId, const QString &)),
+            SLOT(showChannelList(NetworkId, const QString &)));
     connect(GraphicalUi::contextMenuActionProvider(), SIGNAL(showNetworkConfig(NetworkId)), SLOT(showNetworkConfig(NetworkId)));
     connect(GraphicalUi::contextMenuActionProvider(), SIGNAL(showIgnoreList(QString)), SLOT(showIgnoreList(QString)));
     connect(Client::instance(), SIGNAL(showIgnoreList(QString)), SLOT(showIgnoreList(QString)));
@@ -1469,7 +1473,7 @@ void MainWin::showCoreConfigWizard(const QVariantList &backends, const QVariantL
 }
 
 
-void MainWin::showChannelList(NetworkId netId)
+void MainWin::showChannelList(NetworkId netId, const QString &channelFilters)
 {
     ChannelListDlg *channelListDlg = new ChannelListDlg();
 
@@ -1477,10 +1481,24 @@ void MainWin::showChannelList(NetworkId netId)
         QAction *action = qobject_cast<QAction *>(sender());
         if (action)
             netId = action->data().value<NetworkId>();
+        if (!netId.isValid()) {
+            // We still haven't found a valid network, probably no network selected, e.g. "/list"
+            // on the client homescreen when no networks are connected.
+            QMessageBox box(QMessageBox::Information, tr("No network selected"),
+                            QString("<b>%1</b>").arg(tr("No network selected")),
+                            QMessageBox::Ok, this);
+            box.setInformativeText(tr("Select a network before trying to view the channel list."));
+            box.exec();
+            return;
+        }
     }
 
+
     channelListDlg->setAttribute(Qt::WA_DeleteOnClose);
     channelListDlg->setNetwork(netId);
+    if (!channelFilters.isEmpty()) {
+        channelListDlg->setChannelFilters(channelFilters);
+    }
     channelListDlg->show();
 }
 
index e5b6ba2..deb2500 100644 (file)
@@ -121,7 +121,14 @@ private slots:
     void currentBufferChanged(BufferId);
     void messagesInserted(const QModelIndex &parent, int start, int end);
     void showAboutDlg();
-    void showChannelList(NetworkId netId = NetworkId());
+
+    /**
+     * Show the channel list dialog for the network, optionally searching by channel name
+     *
+     * @param networkId       Network ID for associated network
+     * @param channelFilters  Partial channel name to search for, or empty to show all
+     */
+    void showChannelList(NetworkId netId = {}, const QString &channelFilters = {});
     void showNetworkConfig(NetworkId netId = NetworkId());
     void showCoreConnectionDlg();
     void showCoreConfigWizard(const QVariantList &, const QVariantList &);
index 6a96ba6..bb6482c 100644 (file)
@@ -413,7 +413,7 @@ void NetworkModelController::handleGeneralAction(ActionType type, QAction *actio
     }
     case ShowChannelList:
         if (networkId.isValid())
-            emit showChannelList(networkId);
+            emit showChannelList(networkId, {});
         break;
     case ShowNetworkConfig:
         if (networkId.isValid())
index 73ceabb..5ffe127 100644 (file)
@@ -154,7 +154,15 @@ protected slots:
     virtual void actionTriggered(QAction *);
 
 signals:
-    void showChannelList(NetworkId);
+    /**
+     * Request to show the channel list dialog for the network, optionally searching by channel name
+     *
+     * @see MainWin::showChannelList()
+     *
+     * @param networkId       Network ID for associated network
+     * @param channelFilters  Partial channel name to search for, or empty to show all
+     */
+    void showChannelList(NetworkId, const QString &);
     void showNetworkConfig(NetworkId);
     void showIgnoreList(QString);