Changeset View
Changeset View
Standalone View
Standalone View
addons/filetree/katefiletreeplugin.cpp
Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Line(s) | |||||
58 | KateFileTreePlugin::~KateFileTreePlugin() | 58 | KateFileTreePlugin::~KateFileTreePlugin() | ||
59 | { | 59 | { | ||
60 | m_settings.save(); | 60 | m_settings.save(); | ||
61 | } | 61 | } | ||
62 | 62 | | |||
63 | QObject *KateFileTreePlugin::createView(KTextEditor::MainWindow *mainWindow) | 63 | QObject *KateFileTreePlugin::createView(KTextEditor::MainWindow *mainWindow) | ||
64 | { | 64 | { | ||
65 | KateFileTreePluginView *view = new KateFileTreePluginView(mainWindow, this); | 65 | KateFileTreePluginView *view = new KateFileTreePluginView(mainWindow, this); | ||
66 | connect(view, SIGNAL(destroyed(QObject *)), this, SLOT(viewDestroyed(QObject *))); | 66 | connect(view, &KateFileTreePluginView::destroyed, this, &KateFileTreePlugin::viewDestroyed); | ||
67 | m_views.append(view); | 67 | m_views.append(view); | ||
68 | 68 | | |||
69 | return view; | 69 | return view; | ||
70 | } | 70 | } | ||
71 | 71 | | |||
72 | void KateFileTreePlugin::viewDestroyed(QObject *view) | 72 | void KateFileTreePlugin::viewDestroyed(QObject *view) | ||
73 | { | 73 | { | ||
74 | // do not access the view pointer, since it is partially destroyed already | 74 | // do not access the view pointer, since it is partially destroyed already | ||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Line(s) | 130 | { | |||
145 | m_toolbar->setContextMenuPolicy(Qt::NoContextMenu); | 145 | m_toolbar->setContextMenuPolicy(Qt::NoContextMenu); | ||
146 | mainLayout->addWidget(m_toolbar); | 146 | mainLayout->addWidget(m_toolbar); | ||
147 | 147 | | |||
148 | // create filetree | 148 | // create filetree | ||
149 | m_fileTree = new KateFileTree(m_toolView); | 149 | m_fileTree = new KateFileTree(m_toolView); | ||
150 | m_fileTree->setSortingEnabled(true); | 150 | m_fileTree->setSortingEnabled(true); | ||
151 | mainLayout->addWidget(m_fileTree); | 151 | mainLayout->addWidget(m_fileTree); | ||
152 | 152 | | |||
153 | connect(m_fileTree, SIGNAL(activateDocument(KTextEditor::Document *)), | 153 | connect(m_fileTree, &KateFileTree::activateDocument, this, &KateFileTreePluginView::activateDocument); | ||
154 | this, SLOT(activateDocument(KTextEditor::Document *))); | 154 | connect(m_fileTree, &KateFileTree::viewModeChanged, this, &KateFileTreePluginView::viewModeChanged); | ||
155 | 155 | connect(m_fileTree, &KateFileTree::sortRoleChanged, this, &KateFileTreePluginView::sortRoleChanged); | |||
156 | connect(m_fileTree, SIGNAL(viewModeChanged(bool)), this, SLOT(viewModeChanged(bool))); | | |||
157 | connect(m_fileTree, SIGNAL(sortRoleChanged(int)), this, SLOT(sortRoleChanged(int))); | | |||
158 | 156 | | |||
159 | m_documentModel = new KateFileTreeModel(this); | 157 | m_documentModel = new KateFileTreeModel(this); | ||
160 | m_proxyModel = new KateFileTreeProxyModel(this); | 158 | m_proxyModel = new KateFileTreeProxyModel(this); | ||
161 | m_proxyModel->setSourceModel(m_documentModel); | 159 | m_proxyModel->setSourceModel(m_documentModel); | ||
162 | m_proxyModel->setDynamicSortFilter(true); | 160 | m_proxyModel->setDynamicSortFilter(true); | ||
163 | 161 | | |||
164 | m_documentModel->setShowFullPathOnRoots(m_plug->settings().showFullPathOnRoots()); | 162 | m_documentModel->setShowFullPathOnRoots(m_plug->settings().showFullPathOnRoots()); | ||
165 | m_documentModel->setShadingEnabled(m_plug->settings().shadingEnabled()); | 163 | m_documentModel->setShadingEnabled(m_plug->settings().shadingEnabled()); | ||
166 | m_documentModel->setViewShade(m_plug->settings().viewShade()); | 164 | m_documentModel->setViewShade(m_plug->settings().viewShade()); | ||
167 | m_documentModel->setEditShade(m_plug->settings().editShade()); | 165 | m_documentModel->setEditShade(m_plug->settings().editShade()); | ||
168 | 166 | | |||
169 | connect(KTextEditor::Editor::instance()->application(), SIGNAL(documentWillBeDeleted(KTextEditor::Document *)), | 167 | connect(KTextEditor::Editor::instance()->application(), &KTextEditor::Application::documentWillBeDeleted, | ||
170 | m_documentModel, SLOT(documentClosed(KTextEditor::Document *))); | 168 | m_documentModel, &KateFileTreeModel::documentClosed); | ||
169 | connect(KTextEditor::Editor::instance()->application(), &KTextEditor::Application::documentCreated, | ||||
170 | this, &KateFileTreePluginView::documentOpened); | ||||
171 | connect(KTextEditor::Editor::instance()->application(), &KTextEditor::Application::documentWillBeDeleted, | ||||
172 | this, &KateFileTreePluginView::documentClosed); | ||||
173 | connect(KTextEditor::Editor::instance()->application(), &KTextEditor::Application::aboutToCreateDocuments, | ||||
174 | this, &KateFileTreePluginView::slotAboutToCreateDocuments); | ||||
171 | 175 | | |||
172 | connect(KTextEditor::Editor::instance()->application(), SIGNAL(documentCreated(KTextEditor::Document *)), | 176 | connect(KTextEditor::Editor::instance()->application(), | ||
173 | this, SLOT(documentOpened(KTextEditor::Document *))); | 177 | SIGNAL(documentsCreated(QList<KTextEditor::Document *>)), | ||
174 | connect(KTextEditor::Editor::instance()->application(), SIGNAL(documentWillBeDeleted(KTextEditor::Document *)), | | |||
175 | this, SLOT(documentClosed(KTextEditor::Document *))); | | |||
176 | connect(KTextEditor::Editor::instance()->application(), SIGNAL(aboutToCreateDocuments()), | | |||
177 | this, SLOT(slotAboutToCreateDocuments())); | | |||
178 | connect(KTextEditor::Editor::instance()->application(), SIGNAL(documentsCreated(QList<KTextEditor::Document *>)), | | |||
179 | this, SLOT(slotDocumentsCreated(const QList<KTextEditor::Document *> &))); | 178 | this, SLOT(slotDocumentsCreated(const QList<KTextEditor::Document *> &))); | ||
180 | connect(KTextEditor::Editor::instance()->application(), SIGNAL(aboutToDeleteDocuments(const QList<KTextEditor::Document *> &)), | | |||
181 | m_documentModel, SLOT(slotAboutToDeleteDocuments(const QList<KTextEditor::Document *> &))); | | |||
182 | connect(KTextEditor::Editor::instance()->application(), SIGNAL(documentsDeleted(const QList<KTextEditor::Document *> &)), | | |||
183 | m_documentModel, SLOT(slotDocumentsDeleted(const QList<KTextEditor::Document *> &))); | | |||
184 | 179 | | |||
dhaumann: Are there an reasons for this comment? It likely is more irritating than helpful. | |||||
185 | connect(m_documentModel, SIGNAL(triggerViewChangeAfterNameChange()), this, SLOT(viewChanged())); | 180 | connect(KTextEditor::Editor::instance()->application(), &KTextEditor::Application::aboutToDeleteDocuments, | ||
181 | m_documentModel, &KateFileTreeModel::slotAboutToDeleteDocuments); | ||||
182 | connect(KTextEditor::Editor::instance()->application(), &KTextEditor::Application::documentsDeleted, | ||||
183 | m_documentModel, &KateFileTreeModel::slotDocumentsDeleted); | ||||
184 | | ||||
185 | connect(m_documentModel, &KateFileTreeModel::triggerViewChangeAfterNameChange, [=] { | ||||
186 | KateFileTreePluginView::viewChanged(); | ||||
187 | }); | ||||
188 | | ||||
dhaumann: Same here, can we simply delete this line? | |||||
186 | m_fileTree->setModel(m_proxyModel); | 189 | m_fileTree->setModel(m_proxyModel); | ||
187 | 190 | | |||
188 | m_fileTree->setDragEnabled(false); | 191 | m_fileTree->setDragEnabled(false); | ||
189 | m_fileTree->setDragDropMode(QAbstractItemView::InternalMove); | 192 | m_fileTree->setDragDropMode(QAbstractItemView::InternalMove); | ||
190 | m_fileTree->setDropIndicatorShown(false); | 193 | m_fileTree->setDropIndicatorShown(false); | ||
191 | 194 | | |||
192 | m_fileTree->setSelectionMode(QAbstractItemView::SingleSelection); | 195 | m_fileTree->setSelectionMode(QAbstractItemView::SingleSelection); | ||
193 | 196 | | |||
194 | connect(m_fileTree->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), m_fileTree, SLOT(slotCurrentChanged(QModelIndex, QModelIndex))); | 197 | connect(m_fileTree->selectionModel(), &QItemSelectionModel::currentChanged, | ||
198 | m_fileTree, &KateFileTree::slotCurrentChanged); | ||||
195 | 199 | | |||
196 | connect(mainWindow, SIGNAL(viewChanged(KTextEditor::View *)), this, SLOT(viewChanged(KTextEditor::View *))); | 200 | connect(mainWindow, &KTextEditor::MainWindow::viewChanged, this, &KateFileTreePluginView::viewChanged); | ||
197 | 201 | | |||
198 | // | 202 | // | ||
199 | // actions | 203 | // actions | ||
200 | // | 204 | // | ||
201 | setupActions(); | 205 | setupActions(); | ||
202 | 206 | | |||
203 | mainWindow->guiFactory()->addClient(this); | 207 | mainWindow->guiFactory()->addClient(this); | ||
204 | 208 | | |||
Show All 15 Lines | |||||
220 | } | 224 | } | ||
221 | 225 | | |||
222 | void KateFileTreePluginView::setupActions() | 226 | void KateFileTreePluginView::setupActions() | ||
223 | { | 227 | { | ||
224 | auto aPrev = actionCollection()->addAction(QLatin1String("filetree_prev_document")); | 228 | auto aPrev = actionCollection()->addAction(QLatin1String("filetree_prev_document")); | ||
225 | aPrev->setText(i18n("Previous Document")); | 229 | aPrev->setText(i18n("Previous Document")); | ||
226 | aPrev->setIcon(QIcon::fromTheme(QLatin1String("go-up"))); | 230 | aPrev->setIcon(QIcon::fromTheme(QLatin1String("go-up"))); | ||
227 | actionCollection()->setDefaultShortcut(aPrev, Qt::ALT + Qt::Key_Up); | 231 | actionCollection()->setDefaultShortcut(aPrev, Qt::ALT + Qt::Key_Up); | ||
228 | connect(aPrev, SIGNAL(triggered(bool)), m_fileTree, SLOT(slotDocumentPrev())); | 232 | connect(aPrev, &QAction::triggered, m_fileTree, &KateFileTree::slotDocumentPrev); | ||
229 | 233 | | |||
230 | auto aNext = actionCollection()->addAction(QLatin1String("filetree_next_document")); | 234 | auto aNext = actionCollection()->addAction(QLatin1String("filetree_next_document")); | ||
231 | aNext->setText(i18n("Next Document")); | 235 | aNext->setText(i18n("Next Document")); | ||
232 | aNext->setIcon(QIcon::fromTheme(QLatin1String("go-down"))); | 236 | aNext->setIcon(QIcon::fromTheme(QLatin1String("go-down"))); | ||
233 | actionCollection()->setDefaultShortcut(aNext, Qt::ALT + Qt::Key_Down); | 237 | actionCollection()->setDefaultShortcut(aNext, Qt::ALT + Qt::Key_Down); | ||
234 | connect(aNext, SIGNAL(triggered(bool)), m_fileTree, SLOT(slotDocumentNext())); | 238 | connect(aNext, &QAction::triggered, m_fileTree, &KateFileTree::slotDocumentNext); | ||
235 | 239 | | |||
236 | auto aShowActive = actionCollection()->addAction(QLatin1String("filetree_show_active_document")); | 240 | auto aShowActive = actionCollection()->addAction(QLatin1String("filetree_show_active_document")); | ||
237 | aShowActive->setText(i18n("&Show Active")); | 241 | aShowActive->setText(i18n("&Show Active")); | ||
238 | aShowActive->setIcon(QIcon::fromTheme(QLatin1String("folder-sync"))); | 242 | aShowActive->setIcon(QIcon::fromTheme(QLatin1String("folder-sync"))); | ||
239 | connect(aShowActive, SIGNAL(triggered(bool)), this, SLOT(showActiveDocument())); | 243 | connect(aShowActive, &QAction::triggered, this, &KateFileTreePluginView::showActiveDocument); | ||
240 | 244 | | |||
241 | auto aSave = actionCollection()->addAction(QLatin1String("filetree_save"), this, SLOT(slotDocumentSave())); | 245 | auto aSave = actionCollection()->addAction(QLatin1String("filetree_save"), this, SLOT(slotDocumentSave())); | ||
242 | aSave->setText(i18n("Save Current Document")); | 246 | aSave->setText(i18n("Save Current Document")); | ||
243 | aSave->setToolTip(i18n("Save the current document")); | 247 | aSave->setToolTip(i18n("Save the current document")); | ||
244 | aSave->setIcon(QIcon::fromTheme(QLatin1String("document-save"))); | 248 | aSave->setIcon(QIcon::fromTheme(QLatin1String("document-save"))); | ||
245 | 249 | | |||
246 | auto aSaveAs = actionCollection()->addAction(QLatin1String("filetree_save_as"), this, SLOT(slotDocumentSaveAs())); | 250 | auto aSaveAs = actionCollection()->addAction(QLatin1String("filetree_save_as"), this, SLOT(slotDocumentSaveAs())); | ||
247 | aSaveAs->setText(i18n("Save Current Document As")); | 251 | aSaveAs->setText(i18n("Save Current Document As")); | ||
▲ Show 20 Lines • Show All 210 Lines • Show Last 20 Lines |
Are there an reasons for this comment? It likely is more irritating than helpful.