Files
edgetx-gx12/companion/src/modeledit/mixerslistwidget.h
T
Max PapernoandBertrand Songis 3f5a3995cc [Companion] Inputs and Mixes lists formatting & DnD fixes: (#4919)
* Fix/improve margin/padding issues, consistent between inp/mix views, better x-platform and older Qt (closes #4599, closes #4341);
    * Allow dropping onto lines instead of only between them;
    * Fix dropped data always going to line above the actual drop target (closes #4622);
    * Always force DnD move operations between windows to copy instead (fixes deletion of any selected line in target window, and source line was never actually removed but looked like it was);
    * Add alternate-row coloring for each Input/Mixer group;
    * Fix non-contrasting selected row font color on Linux & OS X (was black on blue);
    * Add actions to change font size (size persists until app close);
    * Show inactive lines with dimmer font for input/channel name;
    * Make drop indicator more obvious;
    * Restore mouse hover highlight (Win), which also helps indicate actual drop target (also re: #4622);
    * cosmetics: Code indentation in MixersListWidget.
2017-06-10 23:35:16 +02:00

87 lines
2.5 KiB
C++

/*
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#ifndef _MIXERSLISTWIDGET_H_
#define _MIXERSLISTWIDGET_H_
#include <QtWidgets>
#include <QProxyStyle>
#include <QStyleOption>
#include <QStyledItemDelegate>
class MixersListWidget : public QListWidget
{
Q_OBJECT
public:
explicit MixersListWidget(QWidget *parent, bool expo);
void keyPressEvent(QKeyEvent *event);
void dropEvent(QDropEvent *event);
signals:
void mimeDropped(int index, const QMimeData *data, Qt::DropAction action);
void keyWasPressed(QKeyEvent *event);
public slots:
void addItem(QListWidgetItem *item, const unsigned & rowId, bool topLevel = false, bool hasSib = false);
bool dropMimeData(int index, const QMimeData *data, Qt::DropAction action);
void zoomView();
protected:
virtual QStringList mimeTypes() const;
private:
QString itemMimeFmt;
bool expo;
};
/**
@brief Provides sizing and painting of items for our mixes and inputs lists
This class draws HTML formated strings into QListWidget class
*/
class MixersDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
inline MixersDelegate(QObject *parent) : QStyledItemDelegate(parent) {}
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
QSize sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const;
private:
void SetupDocument(QTextDocument & doc, const QStyleOptionViewItem & options, const QModelIndex & index) const;
};
/**
@brief Provides custom painting of items on a per-element basis, eg. to change style of drop indicator
*/
class MixerItemViewProxyStyle: public QProxyStyle
{
public:
explicit MixerItemViewProxyStyle(QStyle * style = 0) : QProxyStyle(style) {}
void drawPrimitive(PrimitiveElement element, const QStyleOption * option, QPainter * painter, const QWidget * widget = 0) const;
};
#endif // _MIXERSLISTWIDGET_H_