Refactor Clipboard methods (#5627)
* Moves mimeType from StringPairDrag to Clipboard * Simplifies decodeKey and decodeValue methods * Adds method to copy a string to clipboard * Adds method to copy a string pair to the Clipboard * Adds convenience methods to Clipboard.h to retrieve the QMimeData from the clipboard and checking whether a particular mime type format is present on it * Uses only the TCOV copy/paste methods on the song editor To keep consistency on the behavior of the TCOV copy and paste operations, we now only use the TCOV::copy() and TCOV::paste() methods for copying both individual and multiple TCOs. * Removes obsolete TrackContentObject::cut() and merge copy() and paste() methods to single function TrackContentObject::copyStateTo() * Adds Clipboard::getString method to get data for particular mime type * Makes AutomatableModelView.cpp use the Clipboard class instead of calling Qt clipboard directly
This commit is contained in:
@@ -29,25 +29,40 @@
|
||||
#include <QDomElement>
|
||||
|
||||
|
||||
class JournallingObject;
|
||||
|
||||
class Clipboard
|
||||
namespace Clipboard
|
||||
{
|
||||
public:
|
||||
typedef QMap<QString, QDomElement> Map;
|
||||
|
||||
static void copy( JournallingObject * _object );
|
||||
static const QDomElement * getContent( const QString & _node_name );
|
||||
|
||||
static const char * mimeType()
|
||||
enum class MimeType
|
||||
{
|
||||
return( "application/x-lmms-clipboard" );
|
||||
StringPair,
|
||||
Default
|
||||
};
|
||||
|
||||
// Convenience Methods
|
||||
const QMimeData * getMimeData();
|
||||
bool hasFormat( MimeType mT );
|
||||
|
||||
// Helper methods for String data
|
||||
void copyString( const QString & str, MimeType mT );
|
||||
QString getString( MimeType mT );
|
||||
|
||||
// Helper methods for String Pair data
|
||||
void copyStringPair( const QString & key, const QString & value );
|
||||
QString decodeKey( const QMimeData * mimeData );
|
||||
QString decodeValue( const QMimeData * mimeData );
|
||||
|
||||
inline const char * mimeType( MimeType type )
|
||||
{
|
||||
switch( type )
|
||||
{
|
||||
case MimeType::StringPair:
|
||||
return "application/x-lmms-stringpair";
|
||||
break;
|
||||
case MimeType::Default:
|
||||
default:
|
||||
return "application/x-lmms-clipboard";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
static Map content;
|
||||
|
||||
} ;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -45,16 +45,8 @@ public:
|
||||
|
||||
static bool processDragEnterEvent( QDragEnterEvent * _dee,
|
||||
const QString & _allowed_keys );
|
||||
static QString decodeMimeKey( const QMimeData * mimeData );
|
||||
static QString decodeMimeValue( const QMimeData * mimeData );
|
||||
static QString decodeKey( QDropEvent * _de );
|
||||
static QString decodeValue( QDropEvent * _de );
|
||||
|
||||
static const char * mimeType()
|
||||
{
|
||||
return( "application/x-lmms-stringpair" );
|
||||
}
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
@@ -155,9 +155,10 @@ public:
|
||||
MidiTime startTimeOffset() const;
|
||||
void setStartTimeOffset( const MidiTime &startTimeOffset );
|
||||
|
||||
// Will copy the state of a TCO to another TCO
|
||||
static void copyStateTo( TrackContentObject *src, TrackContentObject *dst );
|
||||
|
||||
public slots:
|
||||
void copy();
|
||||
void paste();
|
||||
void toggleMute();
|
||||
|
||||
|
||||
@@ -266,7 +267,6 @@ public:
|
||||
|
||||
public slots:
|
||||
virtual bool close();
|
||||
void cut();
|
||||
void remove();
|
||||
void update() override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user