-
Notifications
You must be signed in to change notification settings - Fork 0
/
Clipboard.cpp
60 lines (50 loc) · 964 Bytes
/
Clipboard.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "Clipboard.h"
void Clipboard::init(const PatternScenePtr& a_scene)
{
Q_ASSERT( m_scene.isNull() && !a_scene.isNull() );
m_scene = a_scene;
}
void Clipboard::copy()
{
auto items = m_scene->selectedItems();
if (items.size() == 0)
return;
reset();
int smallest_frame = items[0]->frame();
for (auto item: items)
{
if (smallest_frame > item->frame())
smallest_frame = item->frame();
}
for (auto item: items)
{
m_items << ClipboardItem{
item->key(),
item->frame() - smallest_frame,
item->size(),
item->libraryItem().toWeakRef()
};
}
}
void Clipboard::reset()
{
m_items.clear();
}
bool Clipboard::isValid() const
{
for (auto& item: m_items)
{
if (item.libraryItem().isNull())
return false;
}
return true;
}
int Clipboard::count() const
{
return m_items.count();
}
const ClipboardItem& Clipboard::item(int a_index) const
{
Q_ASSERT(a_index >= 0 && a_index < m_items.count());
return m_items[a_index];
}