Merge pull request #1098 from manongjohn/fix_moving_styles_in_palette
Fix moving styles in palette
This commit is contained in:
commit
a999bd0801
4 changed files with 13 additions and 8 deletions
|
@ -202,15 +202,16 @@ void TPalette::Page::insertStyle(int indexInPage, TPixel32 color) {
|
|||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
void TPalette::Page::removeStyle(int indexInPage) {
|
||||
void TPalette::Page::removeStyle(int indexInPage, bool flagOnly) {
|
||||
if (indexInPage < 0 || indexInPage >= getStyleCount()) return;
|
||||
assert(m_palette);
|
||||
int styleId = getStyleId(indexInPage);
|
||||
assert(0 <= styleId && styleId < m_palette->getStyleCount());
|
||||
assert(m_palette->m_styles[styleId].first == this);
|
||||
m_palette->m_styles[styleId].first = 0;
|
||||
m_palette->m_styles[styleId].second =
|
||||
TColorStyleP(new TSolidColorStyle(TPixel32::Black));
|
||||
if (!flagOnly)
|
||||
m_palette->m_styles[styleId].second =
|
||||
TColorStyleP(new TSolidColorStyle(TPixel32::Black));
|
||||
m_styleIds.erase(m_styleIds.begin() + indexInPage);
|
||||
}
|
||||
|
||||
|
|
|
@ -163,8 +163,10 @@ public:
|
|||
//! its
|
||||
//! id at the specified position in the page.
|
||||
|
||||
void removeStyle(int indexInPage); //!< Removes the style at the specified
|
||||
//! position from this page.
|
||||
void removeStyle(
|
||||
int indexInPage,
|
||||
bool flagOnly = false); //!< Removes the style at the specified
|
||||
//! position from this page.
|
||||
int search(int styleId)
|
||||
const; //!< Returns the page position of the specified style id,
|
||||
//! or \p -1 if it cannot be found on the page.
|
||||
|
|
|
@ -212,7 +212,7 @@ public:
|
|||
int k;
|
||||
for (k = 0; k < count; k++) {
|
||||
styles.push_back(dstPage->getStyleId(h));
|
||||
dstPage->removeStyle(h);
|
||||
dstPage->removeStyle(h, true);
|
||||
}
|
||||
k = 0;
|
||||
for (i = m_srcIndicesInPage.begin(); i != m_srcIndicesInPage.end();
|
||||
|
@ -235,7 +235,7 @@ public:
|
|||
int index = *i;
|
||||
if (m_dstPageIndex == m_srcPageIndex && index < k) k--;
|
||||
styles.push_back(srcPage->getStyleId(index));
|
||||
srcPage->removeStyle(index);
|
||||
srcPage->removeStyle(index, true);
|
||||
}
|
||||
for (j = styles.begin(); j != styles.end(); ++j)
|
||||
dstPage->insertStyle(k, *j);
|
||||
|
@ -300,7 +300,7 @@ public:
|
|||
assert(page);
|
||||
int indexInPage = page->search(m_styleId);
|
||||
assert(indexInPage >= 0);
|
||||
page->removeStyle(indexInPage);
|
||||
page->removeStyle(indexInPage, true);
|
||||
m_paletteHandle->notifyPaletteChanged();
|
||||
}
|
||||
void redo() const override {
|
||||
|
|
|
@ -153,6 +153,7 @@ bool pasteStylesWithoutUndo(TPalette *palette, TPaletteHandle *pltHandle,
|
|||
// cerco il punto di inserimento (dopo lo stile corrente)
|
||||
int currentStyleIndex = pltHandle->getStyleIndex();
|
||||
int indexInPage = page->search(currentStyleIndex) + 1;
|
||||
if (pageIndex == 0 && indexInPage < 2) indexInPage = 2;
|
||||
const StyleData *data =
|
||||
dynamic_cast<const StyleData *>(QApplication::clipboard()->mimeData());
|
||||
if (!data) return false;
|
||||
|
@ -298,6 +299,7 @@ public:
|
|||
TPalette::Page *page = m_palette->getPage(m_pageIndex);
|
||||
assert(page);
|
||||
int indexInPage = page->search(m_oldStyleIndex) + 1;
|
||||
if (m_pageIndex == 0 && indexInPage < 2) indexInPage = 2;
|
||||
const StyleData *data = dynamic_cast<const StyleData *>(m_data);
|
||||
assert(data);
|
||||
std::set<int> styleIndicesInPage;
|
||||
|
|
Loading…
Reference in a new issue