File indexing completed on 2024-05-12 05:47:41

0001 /*
0002  * SPDX-FileCopyrightText: 2006 Peter Penz <peter.penz19@gmail.com>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef TREEVIEWCONTEXTMENU_H
0008 #define TREEVIEWCONTEXTMENU_H
0009 
0010 #include <KFileItem>
0011 
0012 #include <QObject>
0013 
0014 class QMimeData;
0015 class FoldersPanel;
0016 
0017 /**
0018  * @brief Represents the context menu which appears when doing a right
0019  *        click on an item of the treeview.
0020  */
0021 class TreeViewContextMenu : public QObject
0022 {
0023     Q_OBJECT
0024 
0025 public:
0026     /**
0027      * @parent        Pointer to the folders panel the context menu
0028      *                belongs to.
0029      * @fileInfo      Pointer to the file item the context menu
0030      *                is applied. If 0 is passed, the context menu
0031      *                is above the viewport.
0032      */
0033     TreeViewContextMenu(FoldersPanel *parent, const KFileItem &fileInfo);
0034 
0035     ~TreeViewContextMenu() override;
0036 
0037     /** Opens the context menu modal. */
0038     void open(const QPoint &pos);
0039 
0040 private Q_SLOTS:
0041     /** Cuts the item m_fileItem. */
0042     void cut();
0043 
0044     /** Copies the item m_fileItem. */
0045     void copy();
0046 
0047     /** Paste the clipboard to m_fileItem. */
0048     void paste();
0049 
0050     /** Renames the item m_fileItem. */
0051     void rename();
0052 
0053     /** Moves the item m_fileItem to the trash. */
0054     void moveToTrash();
0055 
0056     /** Deletes the item m_fileItem. */
0057     void deleteItem();
0058 
0059     /** Shows the properties of the item m_fileItem. */
0060     void showProperties();
0061 
0062     /**
0063      * Sets the 'Show Hidden Files' setting for the
0064      * folders panel to \a show.
0065      */
0066     void setShowHiddenFiles(bool show);
0067 
0068     /**
0069      * Sets the 'Limit folders panel to home' setting for the
0070      * folders panel to \a enable.
0071      */
0072     void setLimitFoldersPanelToHome(bool enable);
0073 
0074     /**
0075      * Sets the 'Automatic Scrolling' setting for the
0076      * folders panel to \a enable.
0077      */
0078     void setAutoScrolling(bool enable);
0079 
0080 private:
0081     void populateMimeData(QMimeData *mimeData, bool cut);
0082 
0083 private:
0084     FoldersPanel *m_parent;
0085     KFileItem m_fileItem;
0086 };
0087 
0088 #endif