File indexing completed on 2024-07-14 15:13:56

0001 /***************************************************************************
0002     This class provides the network search toolbar.
0003                              -------------------
0004     begin                : Su Dec 23 2018
0005     copyright            : (C) 2018-2019 by Alexander Reinholdt
0006     email                : alexander.reinholdt@kdemail.net
0007  ***************************************************************************/
0008 
0009 /***************************************************************************
0010  *   This program is free software; you can redistribute it and/or modify  *
0011  *   it under the terms of the GNU General Public License as published by  *
0012  *   the Free Software Foundation; either version 2 of the License, or     *
0013  *   (at your option) any later version.                                   *
0014  *                                                                         *
0015  *   This program is distributed in the hope that it will be useful, but   *
0016  *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
0017  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
0018  *   General Public License for more details.                              *
0019  *                                                                         *
0020  *   You should have received a copy of the GNU General Public License     *
0021  *   along with this program; if not, write to the                         *
0022  *   Free Software Foundation, Inc., 51 Franklin Street, Suite 500, Boston,*
0023  *   MA 02110-1335, USA                                                    *
0024  ***************************************************************************/
0025 
0026 #ifndef SMB4KNETWORKSEARCHBAR_H
0027 #define SMB4KNETWORKSEARCHBAR_H
0028 
0029 // application specific includes
0030 #include "core/smb4kglobal.h"
0031 
0032 // Qt includes
0033 #include <QToolBar>
0034 #include <QList>
0035 #include <QListIterator>
0036 
0037 
0038 class Smb4KNetworkSearchToolBar : public QToolBar
0039 {
0040   Q_OBJECT
0041   
0042   public:
0043     /**
0044      * Constructor
0045      */
0046     Smb4KNetworkSearchToolBar(QWidget *parent = 0);
0047     
0048     /**
0049      * Destructor
0050      */
0051     ~Smb4KNetworkSearchToolBar();
0052     
0053     /**
0054      * Sets the focus to the search combo box
0055      */
0056     void prepareInput();
0057     
0058     /**
0059      * Set the active state
0060      * 
0061      * @param active          The state
0062      */
0063     void setActiveState(bool active);
0064     
0065     /**
0066      * Set the search result
0067      * 
0068      * @param list            The list of search results
0069      */
0070     void setSearchResults(const QList<SharePtr> &list);
0071     
0072     /**
0073      * Clear the search
0074      */
0075     void clearSearch();
0076     
0077     /**
0078      * Set the completion strings. This function should be invoked before the
0079      * search toolbar is shown.
0080      * 
0081      * @param strings         The list of completion strings
0082      */
0083     void setCompletionStrings(const QStringList &strings);
0084     
0085     /**
0086      * Get the completion strings.
0087      * 
0088      * @returns the completion strings
0089      */
0090     QStringList completionStrings() const;
0091     
0092   Q_SIGNALS:
0093     /**
0094      * Emitted when the search toolbar is to be closed (should be hidden)
0095      */
0096     void close();
0097     
0098     /**
0099      * Emitted when a search should be done
0100      */
0101     void search(const QString &item);
0102     
0103     /**
0104      * Emitted when a search should be stopped
0105      */
0106     void abort();
0107     
0108     /**
0109      * Emitted when either the up or down action was clicked
0110      */
0111     void jumpToResult(const QString &url);
0112     
0113     /**
0114      * Emitted when the search is cleared
0115      */
0116     void clearSearchResults();
0117     
0118   protected Q_SLOTS:
0119     /**
0120      * Called when the return key was pressed
0121      */
0122     void slotReturnKeyPressed();
0123     
0124     /**
0125      * Called when the search dual action is toggled
0126      */
0127     void slotSearchActionTriggered();
0128     
0129     /**
0130      * Called when the close button was pressed
0131      */
0132     void slotCloseButtonPressed();
0133     
0134     /**
0135      * Called when the down action was triggered
0136      */
0137     void slotDownActionTriggered();
0138     
0139     /**
0140      * Called when the up action was triggered
0141      */
0142     void slotUpActionTriggered();
0143     
0144     /**
0145      * Called when the search is cleared
0146      */
0147     void slotClearSearch();
0148     
0149   private:
0150     /**
0151      * The search results
0152      */
0153     QStringList m_searchResults;
0154     
0155     /**
0156      * String list iterator
0157      */
0158     QStringListIterator m_iterator;
0159 };
0160 
0161 #endif
0162