File indexing completed on 2024-05-05 03:50:44

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2008 Patrick Spendrin <ps_ml@gmx.de>
0004 //
0005 
0006 #ifndef FILEVIEW_FLOAT_ITEM_H
0007 #define FILEVIEW_FLOAT_ITEM_H
0008 
0009 // forward declarations
0010 class QListView;
0011 class QPersistentModelIndex;
0012 
0013 #include "AbstractFloatItem.h"
0014 
0015 namespace Marble
0016 {
0017 
0018 class MarbleWidget;
0019 
0020 /**
0021  * @short Provides a float item with a list of opened files
0022  *
0023  */
0024 class FileViewFloatItem: public AbstractFloatItem
0025 {
0026     Q_OBJECT
0027     Q_PLUGIN_METADATA(IID "org.kde.marble.FileViewFloatItem")
0028     Q_INTERFACES( Marble::RenderPluginInterface )
0029     MARBLE_PLUGIN(FileViewFloatItem)
0030 
0031  public:
0032     explicit FileViewFloatItem( const QPointF &point = QPointF( -1, 10 ),
0033                             const QSizeF &size = QSizeF( 110.0, 250.0 ) );
0034     ~FileViewFloatItem();
0035 
0036     QStringList backendTypes() const;
0037 
0038     QString name() const;
0039 
0040     QString guiString() const;
0041 
0042     QString nameId() const;
0043 
0044     QString description() const;
0045 
0046     QIcon icon () const;
0047 
0048     void initialize ();
0049 
0050     bool isInitialized () const;
0051 
0052     void changeViewport( ViewportParams *viewport );
0053 
0054     virtual QPainterPath backgroundShape() const;
0055 
0056     void paintContent( GeoPainter *painter, ViewportParams *viewport,
0057                        const QString& renderPos, GeoSceneLayer *layer = 0 );
0058 
0059  protected:
0060     bool eventFilter( QObject *object, QEvent *e );
0061 
0062  private Q_SLOTS:
0063     /** Map theme was changed, adjust controls */
0064     void selectTheme( const QString& theme );
0065 
0066     /** Enable/disable zoom in/out buttons */
0067     void updateFileView();
0068 
0069     void contextMenu(const QPoint& pos);
0070 
0071     void addFile();
0072 
0073     void removeFile();
0074 
0075  private:
0076     /** MarbleWidget this float item is installed as event filter for */
0077     MarbleWidget *m_marbleWidget;
0078 
0079     /** FileView controls */
0080     QListView *m_fileView;
0081 
0082     /** FileView embedding widget */
0083     QWidget *m_fileViewParent;
0084 
0085     /** current position */
0086     QPoint m_itemPosition;
0087 
0088     /** Radius of the viewport last time */
0089     int m_oldViewportRadius;
0090 
0091     /** Repaint needed */
0092     bool m_repaintScheduled;
0093 
0094     /** the last clicked ModelIndex */
0095     QPersistentModelIndex* m_persIndex;
0096 };
0097 
0098 }
0099 
0100 #endif // FILEVIEW_FLOAT_ITEM_H