Changeset View
Changeset View
Standalone View
Standalone View
src/widgets/gcodeeditorwidget.cpp
Show First 20 Lines • Show All 106 Lines • ▼ Show 20 Line(s) | |||||
107 | void GCodeEditorWidget::currentIndexChanged(int index) | 107 | void GCodeEditorWidget::currentIndexChanged(int index) | ||
108 | { | 108 | { | ||
109 | emit currentFileChanged(urlTab.key(m_tabwidget->widget(index))); | 109 | emit currentFileChanged(urlTab.key(m_tabwidget->widget(index))); | ||
110 | emit updateClientFactory(qobject_cast<KTextEditor::View *>(m_tabwidget->widget(index))); | 110 | emit updateClientFactory(qobject_cast<KTextEditor::View *>(m_tabwidget->widget(index))); | ||
111 | } | 111 | } | ||
112 | 112 | | |||
113 | void GCodeEditorWidget::dropCatch(QDropEvent *event) | 113 | void GCodeEditorWidget::dropCatch(QDropEvent *event) | ||
114 | { | 114 | { | ||
115 | if (event->mimeData()->hasUrls()) { | 115 | if (event->mimeData()->hasUrls()) { | ||
tcanabrava: QVector, QList should only be used if the item is <= a pointer.
also, modList.reserve(count) | |||||
didn't set reserve since I don't know how many files will be modified. rizzitello: didn't set reserve since I don't know how many files will be modified. | |||||
116 | emit droppedUrls(event->mimeData()->urls()); | 116 | emit droppedUrls(event->mimeData()->urls()); | ||
117 | } | 117 | } | ||
118 | | ||||
119 | } | ||||
120 | | ||||
121 | QVector<QUrl> GCodeEditorWidget::modifiedFiles() | ||||
122 | { | ||||
123 | QVector<QUrl> modList; | ||||
124 | for (auto const &doc : m_editor->documents()) { | ||||
125 | if (doc->isModified()) { | ||||
126 | modList.append(doc->url()); | ||||
127 | } | ||||
128 | } | ||||
129 | return modList; | ||||
130 | } | ||||
tcanabrava: return doc->save();
| |||||
131 | | ||||
132 | bool GCodeEditorWidget::saveFile(const QUrl &url) | ||||
133 | { | ||||
134 | auto doc = urlDoc[url]; | ||||
patrickelectric: check if urlDoc contains url.
`auto doc` is not explicit. | |||||
if no url doc->save should return false. If you think we need more checks i can add them I will use an explict QURL here. rizzitello: if no url doc->save should return false. If you think we need more checks i can add them
I… | |||||
135 | return doc->save(); | ||||
118 | } | 136 | } |
QVector, QList should only be used if the item is <= a pointer.
also, modList.reserve(count)