Skip to content

Commit 67c89d8

Browse files
committed
Note selection cleared on click
1 parent 58d4ebc commit 67c89d8

File tree

5 files changed

+28
-12
lines changed

5 files changed

+28
-12
lines changed

src/Interface/Application/Connection.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ ConnectionLine::ConnectionLine(PortWidget* fromPort, PortWidget* toPort, const C
279279
setFlags(ItemIsSelectable | ItemIsMovable | ItemSendsGeometryChanges | ItemIsFocusable);
280280

281281
setZValue(defaultZValue());
282-
setToolTip("<font color=\"#000000\" size=2>Left - Highlight\nDouble-Left - Menu\ni - Datatype info");
282+
setToolTip("<font color=\"#EEEEEE\" size=2>Left - Highlight<br>Double-Left - Menu<br>i - Datatype info");
283283
setAcceptHoverEvents(true);
284284

285285
menu_ = new ConnectionMenu(this);

src/Interface/Application/ModuleProxyWidget.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ void ModuleProxyWidget::disableModuleGUI(bool disabled)
243243

244244
void ModuleProxyWidget::mousePressEvent(QGraphicsSceneMouseEvent *event)
245245
{
246+
clearNoteCursor();
246247
auto taggingOn = data(TagLayerKey).toBool();
247248
auto currentTag = data(CurrentTagKey).toInt();
248249
if (taggingOn && currentTag > NoTag)

src/Interface/Application/NetworkEditor.cc

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,7 @@ SearchResultItem::SearchResultItem(const QString& text, const QColor& color, std
739739
: FloatingTextItem(text, action, parent)
740740
{
741741
setDefaultTextColor(color);
742+
setHtml("<div style='background:rgba(150, 150, 150, 30%);'>" + toPlainText() + "</div>");
742743
items_.insert(this);
743744
}
744745

@@ -805,10 +806,11 @@ class NetworkSearchEngine
805806
auto id = mod->getModuleWidget()->getModuleId();
806807
if (boost::ifind_first(id, text.toStdString()))
807808
{
809+
auto tag = mod->data(TagDataKey).toInt();
808810
results.emplace_back("Module",
809811
QString::fromStdString(id),
810812
[mod]() { mod->showAndColor(Qt::green); },
811-
tagColor_(mod->data(TagDataKey).toInt()));
813+
tag != NoTag ? tagColor_(tag) : Qt::white);
812814
}
813815

814816
auto metadata = mod->getModuleWidget()->metadataToString();
@@ -855,7 +857,6 @@ class NetworkSearchEngine
855857
auto doc = note->document();
856858
QTextCursor cur(doc->find(text));
857859
note->setTextCursor(cur);
858-
//QTimer::singleShot(4000, &cur, SLOT(networkTimedOut()));
859860
}
860861

861862
QGraphicsScene* scene_;
@@ -875,18 +876,21 @@ void NetworkEditor::searchTextChanged(const QString& text)
875876

876877
NetworkSearchEngine engine(scene(), tagColor_);
877878
auto results = engine.search(text);
879+
auto textScale = 1.0 / currentScale_;
878880
if (!results.empty())
879881
{
880882
auto title = new SearchResultItem("Search results:", Qt::green, {});
881-
title->setPos(positionOfFloatingText(title->num(), true, 20, 30));
883+
title->setPos(positionOfFloatingText(title->num(), true, 20, textScale * 20));
882884
scene()->addItem(title);
885+
title->scale(textScale, textScale);
883886
}
884887
for (const auto& result : results)
885888
{
886889
auto searchItem = new SearchResultItem(std::get<ItemType>(result) + ": " + std::get<ItemName>(result),
887890
std::get<ItemColor>(result), std::get<ItemAction>(result));
888-
searchItem->setPos(positionOfFloatingText(searchItem->num(), true, 50, 30));
891+
searchItem->setPos(positionOfFloatingText(searchItem->num(), true, 50, textScale * 20));
889892
scene()->addItem(searchItem);
893+
searchItem->scale(textScale, textScale);
890894
}
891895
}
892896
}

src/Interface/Application/Note.cc

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
using namespace SCIRun::Gui;
3939
using namespace SCIRun::Core::Logging;
4040

41-
HasNotes::HasNotes(const std::string& name, bool positionAdjustable) :
41+
HasNotes::HasNotes(const std::string& name, bool positionAdjustable) :
4242
noteEditor_(QString::fromStdString(name), positionAdjustable, 0),
4343
destroyed_(false)
4444
{
@@ -80,8 +80,8 @@ void HasNotes::setCurrentNote(const Note& note, bool updateEditor)
8080
}
8181
}
8282

83-
NoteDisplayHelper::NoteDisplayHelper(NoteDisplayStrategyPtr display) :
84-
item_(0), scene_(0), note_(0),
83+
NoteDisplayHelper::NoteDisplayHelper(NoteDisplayStrategyPtr display) :
84+
item_(0), scene_(0), note_(0),
8585
notePosition_(Default),
8686
defaultNotePosition_(Top), //TODO
8787
displayStrategy_(display),
@@ -124,6 +124,16 @@ void NoteDisplayHelper::updateNoteImpl(const Note& note)
124124
note_->setZValue(item_->zValue() - 1);
125125
}
126126

127+
void NoteDisplayHelper::clearNoteCursor()
128+
{
129+
if (note_)
130+
{
131+
auto cur = note_->textCursor();
132+
cur.clearSelection();
133+
note_->setTextCursor(cur);
134+
}
135+
}
136+
127137
QPointF NoteDisplayHelper::relativeNotePosition()
128138
{
129139
if (note_ && item_)
@@ -157,4 +167,4 @@ Note NoteDisplayHelper::currentNote() const
157167
if (note_)
158168
return Note(note_->toHtml(), note_->toPlainText(), note_->font().pointSizeF(), notePosition_);
159169
return Note();
160-
}
170+
}

src/Interface/Application/Note.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ namespace Gui {
5151
None,
5252
Tooltip,
5353
Top,
54-
Left,
55-
Right,
54+
Left,
55+
Right,
5656
Bottom
5757
};
5858

5959
// TODO: refactor. Combine with ModuleNoteXML, and bring together various Note-related classes to support consistent read/write.
60-
// IDEA: subclass QGraphicsTextItem properly and add a way to associate with a HasNotes object (either module or connection).
60+
// IDEA: subclass QGraphicsTextItem properly and add a way to associate with a HasNotes object (either module or connection).
6161
// Then serialization will be uniform for all notes.
6262

6363
struct Note
@@ -92,6 +92,7 @@ namespace Gui {
9292
void updateNoteImpl(const Note& note);
9393
void updateNotePosition();
9494
void setDefaultNotePositionImpl(NotePosition position);
95+
void clearNoteCursor();
9596
QGraphicsItem* item_;
9697
QGraphicsScene* scene_;
9798
PositionProviderPtr positioner_;

0 commit comments

Comments
 (0)