OpenMS  2.6.0
InputFileList.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // OpenMS -- Open-Source Mass Spectrometry
3 // --------------------------------------------------------------------------
4 // Copyright The OpenMS Team -- Eberhard Karls University Tuebingen,
5 // ETH Zurich, and Freie Universitaet Berlin 2002-2020.
6 //
7 // This software is released under a three-clause BSD license:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of any author or any participating institution
14 // may be used to endorse or promote products derived from this software
15 // without specific prior written permission.
16 // For a full list of authors, refer to the file AUTHORS.
17 // --------------------------------------------------------------------------
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 // ARE DISCLAIMED. IN NO EVENT SHALL ANY OF THE AUTHORS OR THE CONTRIBUTING
22 // INSTITUTIONS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
25 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 //
30 // --------------------------------------------------------------------------
31 // $Maintainer: Chris Bielow $
32 // $Authors: Chris Bielow $
33 // --------------------------------------------------------------------------
34 
35 #pragma once
36 
38 #include <OpenMS/VISUAL/OpenMS_GUIConfig.h>
39 
40 #include <QWidget>
41 
42 namespace Ui
43 {
44  class InputFileList;
45 }
46 
47 namespace OpenMS
48 {
49  namespace Internal
50  {
56  class InputFileList : public QWidget
57  {
58  Q_OBJECT
59 
60  public:
62  explicit InputFileList(QWidget* parent = nullptr);
65  void dragEnterEvent(QDragEnterEvent* e) override;
67  void dropEvent(QDropEvent* e) override;
68  void dragMoveEvent(QDragMoveEvent* pEvent) override;
69 
71  void getFilenames(QStringList& files) const;
73  StringList getFilenames() const;
75  void setFilenames(const QStringList& files);
76 
78  const QString& getCWD() const;
80  void setCWD(const QString& cwd, bool force = false);
81 
83  void keyPressEvent(QKeyEvent* e) override;
84 
85  public slots:
86 
88  void showFileDialog();
90  void removeSelected();
92  void removeAll();
94  void editCurrentItem();
95 
96  signals:
98  void updatedCWD(QString new_cwd);
99 
100  protected:
102  void addFiles_(const QStringList& files);
103 
105  void updateCWD_();
106 
107 
108  QString cwd_;
109 
110  private:
112  };
113  } // ns Internal
114 } // ns OpenMS
115 
116 // this is required to allow parent widgets (auto UIC'd from .ui) to have a InputFileList member
OpenMS::Internal::InputFileList::removeSelected
void removeSelected()
Removes all currently selected files from the list.
OpenMS::Internal::InputFileList::editCurrentItem
void editCurrentItem()
Shows a TOPPASInputFileDialog which edits the current item.
OpenMS::Internal::InputFileList::removeAll
void removeAll()
Removes all files from the list.
OpenMS::Internal::InputFileList::keyPressEvent
void keyPressEvent(QKeyEvent *e) override
support Ctrl+C to copy currently selected items to clipboard
OpenMS::Internal::InputFileList::updatedCWD
void updatedCWD(QString new_cwd)
emitted when a new file is added (by drag'n'drop or 'Add..' button)
OpenMS::Internal::InputFileList::~InputFileList
~InputFileList()
OpenMS::Internal::InputFileList::updateCWD_
void updateCWD_()
updates the CWD, based on the last file in the current list
OpenMS::Internal::InputFileList::getCWD
const QString & getCWD() const
get the CWD (according to most recently added file)
OpenMS::Internal::InputFileList::InputFileList
InputFileList(QWidget *parent=nullptr)
C'tor.
QWidget
ListUtils.h
OpenMS::Internal::InputFileList::dropEvent
void dropEvent(QDropEvent *e) override
support drag'n'drop of files from OS window manager
OpenMS
Main OpenMS namespace.
Definition: FeatureDeconvolution.h:46
OpenMS::Internal::InputFileList::ui_
Ui::InputFileList * ui_
Definition: InputFileList.h:111
OpenMS::Internal::InputFileList
A widget shows a list of input files (i.e. existing files on a mounted drive), which allows adding/re...
Definition: InputFileList.h:56
Ui
Definition: SwathWizardBase.h:62
OpenMS::Internal::InputFileList::dragMoveEvent
void dragMoveEvent(QDragMoveEvent *pEvent) override
OpenMS::Internal::InputFileList::getFilenames
StringList getFilenames() const
Stores the list of all filenames in the list widget in files.
OpenMS::Internal::InputFileList::cwd_
QString cwd_
current working dir, i.e. the last position a file was added from
Definition: InputFileList.h:108
OpenMS::StringList
std::vector< String > StringList
Vector of String.
Definition: ListUtils.h:70
OpenMS::Internal::InputFileList::setFilenames
void setFilenames(const QStringList &files)
Set the list of all filenames in the list widget.
OpenMS::Internal::InputFileList::dragEnterEvent
void dragEnterEvent(QDragEnterEvent *e) override
support drag'n'drop of files from OS window manager
InputFileList
OpenMS::Internal::InputFileList InputFileList
Definition: InputFileList.h:117
OpenMS::Internal::InputFileList::addFiles_
void addFiles_(const QStringList &files)
add files to the list, and update 'cwd_' by using the path of the last filename
OpenMS::Internal::InputFileList::setCWD
void setCWD(const QString &cwd, bool force=false)
set the current working directory (for opening files), but only if the current input list is not alre...
OpenMS::Internal::InputFileList::showFileDialog
void showFileDialog()
Lets the user select files via a file dialog.