-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'issue-42' of git://github.com/fnkabit/kImageAnnotator i…
…nto fnkabit-issue-42
- Loading branch information
Showing
11 changed files
with
126 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (C) 2018 Damir Porobic <[email protected]> | ||
* Copyright (C) 2020 Damir Porobic <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
|
@@ -22,7 +22,8 @@ | |
namespace kImageAnnotator { | ||
|
||
NumberManager::NumberManager() : | ||
mFirstNumber(1) | ||
mFirstNumber(1), | ||
mNumberUpdateMode(NumberUpdateMode::UseNextNumber) | ||
{ | ||
} | ||
|
||
|
@@ -45,18 +46,33 @@ void NumberManager::addItemInner(AbstractAnnotationItem *item) | |
{ | ||
Q_ASSERT(item != nullptr); | ||
|
||
connect(item, &AbstractAnnotationItem::visibleChanged, this, &NumberManager::updateNumbers); | ||
connect(item, &AbstractAnnotationItem::visibleChanged, this, &NumberManager::updateNumbersIfRequired); | ||
mItems.append(item); | ||
updateNumbers(); | ||
|
||
if (mNumberUpdateMode == NumberUpdateMode::UseNextNumber) { | ||
updateNumbersIfRequired(); | ||
} else { | ||
initItemNumber(item); | ||
} | ||
} | ||
|
||
void NumberManager::initItemNumber(AbstractAnnotationItem *item) | ||
{ | ||
auto numberItem = dynamic_cast<BaseAnnotationNumber *>(item); | ||
numberItem->setNumber(mFirstNumber); | ||
} | ||
|
||
void NumberManager::reset() | ||
{ | ||
mItems.clear(); | ||
} | ||
|
||
void NumberManager::updateNumbers() | ||
void NumberManager::updateNumbersIfRequired() | ||
{ | ||
if (mNumberUpdateMode == NumberUpdateMode::UseStartingNumber) { | ||
return; | ||
} | ||
|
||
auto number = mFirstNumber; | ||
for (auto item : mItems) { | ||
if (item->isVisible()) { | ||
|
@@ -69,12 +85,17 @@ void NumberManager::updateNumbers() | |
void NumberManager::setFirstNumber(int number) | ||
{ | ||
mFirstNumber = number; | ||
updateNumbers(); | ||
updateNumbersIfRequired(); | ||
} | ||
|
||
int NumberManager::firstNumber() const | ||
{ | ||
return mFirstNumber; | ||
} | ||
|
||
void NumberManager::setNumberUpdateMode(NumberUpdateMode numberUpdateMode) | ||
{ | ||
mNumberUpdateMode = numberUpdateMode; | ||
} | ||
|
||
} // namespace kImageAnnotator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (C) 2018 Damir Porobic <[email protected]> | ||
* Copyright (C) 2020 Damir Porobic <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
|
@@ -22,6 +22,7 @@ | |
|
||
#include <QObject> | ||
|
||
#include "src/common/enum/NumberUpdateMode.h" | ||
#include "src/annotations/items/AnnotationNumber.h" | ||
#include "src/annotations/items/AnnotationNumberPointer.h" | ||
#include "src/annotations/items/AnnotationNumberArrow.h" | ||
|
@@ -40,15 +41,18 @@ Q_OBJECT | |
void reset(); | ||
void setFirstNumber(int number); | ||
int firstNumber() const; | ||
void setNumberUpdateMode(NumberUpdateMode numberUpdateMode); | ||
|
||
public slots: | ||
void updateNumbers(); | ||
void updateNumbersIfRequired(); | ||
|
||
private: | ||
int mFirstNumber; | ||
QList<AbstractAnnotationItem *> mItems; | ||
NumberUpdateMode mNumberUpdateMode; | ||
|
||
void addItemInner(AbstractAnnotationItem *item); | ||
void initItemNumber(AbstractAnnotationItem *item); | ||
}; | ||
|
||
} // namepsace kImageAnnotator | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright (C) 2020 Damir Porobic <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation; either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* 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. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
* Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
#ifndef KIMAGEANNOTATOR_NUMBERUPDATEMODE_H | ||
#define KIMAGEANNOTATOR_NUMBERUPDATEMODE_H | ||
|
||
#include <QMetaType> | ||
|
||
namespace kImageAnnotator { | ||
|
||
enum class NumberUpdateMode | ||
{ | ||
UseStartingNumber, | ||
UseNextNumber | ||
}; | ||
|
||
} // namespace kImageAnnotator | ||
|
||
#endif // KIMAGEANNOTATOR_NUMBERUPDATEMODE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters