Changeset View
Changeset View
Standalone View
Standalone View
src/widgets/gcodeeditorwidget.cpp
Show First 20 Lines • Show All 109 Lines • ▼ Show 20 Line(s) | |||||
110 | void GCodeEditorWidget::currentIndexChanged(int index) | 110 | void GCodeEditorWidget::currentIndexChanged(int index) | ||
111 | { | 111 | { | ||
112 | emit currentFileChanged(urlTab.key(m_tabwidget->widget(index))); | 112 | emit currentFileChanged(urlTab.key(m_tabwidget->widget(index))); | ||
113 | emit updateClientFactory(qobject_cast<KTextEditor::View *>(m_tabwidget->widget(index))); | 113 | emit updateClientFactory(qobject_cast<KTextEditor::View *>(m_tabwidget->widget(index))); | ||
114 | } | 114 | } | ||
115 | 115 | | |||
116 | void GCodeEditorWidget::dropCatch(QDropEvent *event) | 116 | void GCodeEditorWidget::dropCatch(QDropEvent *event) | ||
117 | { | 117 | { | ||
118 | if (event->mimeData()->hasUrls()) { | 118 | 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. | |||||
119 | emit droppedUrls(event->mimeData()->urls()); | 119 | emit droppedUrls(event->mimeData()->urls()); | ||
120 | } | 120 | } | ||
121 | | ||||
122 | } | ||||
123 | | ||||
124 | QVector<QUrl> GCodeEditorWidget::modifiedFiles() | ||||
125 | { | ||||
126 | QVector<QUrl> modList; | ||||
127 | for (auto const &doc : m_editor->documents()) { | ||||
128 | if (doc->isModified()) { | ||||
129 | modList.append(doc->url()); | ||||
130 | } | ||||
131 | } | ||||
132 | return modList; | ||||
133 | } | ||||
tcanabrava: return doc->save();
| |||||
134 | | ||||
135 | bool GCodeEditorWidget::saveFile(const QUrl &url) | ||||
136 | { | ||||
137 | if (!urlDoc.contains(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… | |||||
138 | return false; | ||||
139 | } | ||||
140 | KTextEditor::Document *doc = urlDoc[url]; | ||||
141 | return doc->save(); | ||||
121 | } | 142 | } |
QVector, QList should only be used if the item is <= a pointer.
also, modList.reserve(count)