Changeset View
Changeset View
Standalone View
Standalone View
addons/kate-ctags/kate_ctags_view.cpp
Show All 14 Lines | |||||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | * General Public License for more details. | 16 | * General Public License for more details. | ||
17 | * | 17 | * | ||
18 | * You should have received a copy of the GNU General Public | 18 | * You should have received a copy of the GNU General Public | ||
19 | * License along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 | * License along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
20 | */ | 20 | */ | ||
21 | 21 | | |||
22 | #include "kate_ctags_view.h" | 22 | #include "kate_ctags_view.h" | ||
23 | #include "kate_ctags_plugin.h" | ||||
23 | #include "kate_ctags_debug.h" | 24 | #include "kate_ctags_debug.h" | ||
24 | 25 | | |||
25 | #include <QFileInfo> | 26 | #include <QFileInfo> | ||
26 | #include <QFileDialog> | 27 | #include <QFileDialog> | ||
27 | #include <QKeyEvent> | 28 | #include <QKeyEvent> | ||
28 | 29 | | |||
29 | #include <KXMLGUIFactory> | 30 | #include <KXMLGUIFactory> | ||
30 | #include <KActionCollection> | 31 | #include <KActionCollection> | ||
Show All 30 Lines | 44 | { | |||
61 | QAction *defin = actionCollection()->addAction(QLatin1String("ctags_lookup_current_as_definition")); | 62 | QAction *defin = actionCollection()->addAction(QLatin1String("ctags_lookup_current_as_definition")); | ||
62 | defin->setText(i18n("Go to Definition")); | 63 | defin->setText(i18n("Go to Definition")); | ||
63 | connect(defin, &QAction::triggered, this, &KateCTagsView::gotoDefinition); | 64 | connect(defin, &QAction::triggered, this, &KateCTagsView::gotoDefinition); | ||
64 | 65 | | |||
65 | QAction *lookup = actionCollection()->addAction(QLatin1String("ctags_lookup_current")); | 66 | QAction *lookup = actionCollection()->addAction(QLatin1String("ctags_lookup_current")); | ||
66 | lookup->setText(i18n("Lookup Current Text")); | 67 | lookup->setText(i18n("Lookup Current Text")); | ||
67 | connect(lookup, &QAction::triggered, this, &KateCTagsView::lookupTag); | 68 | connect(lookup, &QAction::triggered, this, &KateCTagsView::lookupTag); | ||
68 | 69 | | |||
70 | QAction *updateDB = actionCollection()->addAction(QLatin1String("ctags_update_global_db")); | ||||
71 | updateDB->setText(i18n("Configure ...")); | ||||
72 | connect(updateDB, &QAction::triggered, this, [this, plugin] (bool) { | ||||
73 | if (m_mWin) { | ||||
anthonyfieroni: Dynamic_cast is pretty expensive to not check against nullptr, use static_cast instead. | |||||
74 | KateCTagsPlugin *p = static_cast<KateCTagsPlugin*>(plugin); | ||||
75 | QDialog *confWin = new QDialog(m_mWin->window()); | ||||
76 | confWin->setAttribute(Qt::WA_DeleteOnClose); | ||||
77 | auto confPage = p->configPage(0, confWin); | ||||
78 | auto controls = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel, Qt::Horizontal, confWin); | ||||
79 | connect(confWin, &QDialog::accepted, confPage, &KTextEditor::ConfigPage::apply); | ||||
80 | connect(controls, &QDialogButtonBox::accepted, confWin, &QDialog::accept); | ||||
81 | connect(controls, &QDialogButtonBox::rejected, confWin, &QDialog::reject); | ||||
82 | auto layout = new QVBoxLayout(confWin); | ||||
83 | layout->addWidget(confPage); | ||||
84 | layout->addWidget(controls); | ||||
85 | confWin->setLayout(layout); | ||||
86 | confWin->show(); | ||||
87 | confWin->exec(); | ||||
88 | } | ||||
89 | }); | ||||
anthonyfieroni: Add attribute to confWin deleteOnClose and make it parent of others. | |||||
90 | | ||||
69 | // popup menu | 91 | // popup menu | ||
70 | m_menu = new KActionMenu(i18n("CTags"), this); | 92 | m_menu = new KActionMenu(i18n("CTags"), this); | ||
71 | actionCollection()->addAction(QLatin1String("popup_ctags"), m_menu); | 93 | actionCollection()->addAction(QLatin1String("popup_ctags"), m_menu); | ||
72 | 94 | | |||
73 | m_gotoDec=m_menu->menu()->addAction(i18n("Go to Declaration: %1",QString()), this, SLOT(gotoDeclaration())); | 95 | m_gotoDec=m_menu->menu()->addAction(i18n("Go to Declaration: %1",QString()), this, SLOT(gotoDeclaration())); | ||
74 | m_gotoDef=m_menu->menu()->addAction(i18n("Go to Definition: %1",QString()), this, SLOT(gotoDefinition())); | 96 | m_gotoDef=m_menu->menu()->addAction(i18n("Go to Definition: %1",QString()), this, SLOT(gotoDefinition())); | ||
75 | m_lookup=m_menu->menu()->addAction(i18n("Lookup: %1",QString()), this, SLOT(lookupTag())); | 97 | m_lookup=m_menu->menu()->addAction(i18n("Lookup: %1",QString()), this, SLOT(lookupTag())); | ||
76 | 98 | | |||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | |||||
120 | 142 | | |||
121 | m_commonDB = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1String("/katectags/common_db"); | 143 | m_commonDB = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + QLatin1String("/katectags/common_db"); | ||
122 | } | 144 | } | ||
123 | 145 | | |||
124 | 146 | | |||
125 | /******************************************************************/ | 147 | /******************************************************************/ | ||
126 | KateCTagsView::~KateCTagsView() | 148 | KateCTagsView::~KateCTagsView() | ||
127 | { | 149 | { | ||
150 | if (m_mWin && m_mWin->guiFactory()) { | ||||
128 | m_mWin->guiFactory()->removeClient( this ); | 151 | m_mWin->guiFactory()->removeClient( this ); | ||
152 | } | ||||
129 | 153 | | |||
130 | delete m_toolView; | 154 | delete m_toolView; | ||
131 | } | 155 | } | ||
132 | 156 | | |||
133 | /******************************************************************/ | 157 | /******************************************************************/ | ||
134 | void KateCTagsView::aboutToShow() | 158 | void KateCTagsView::aboutToShow() | ||
135 | { | 159 | { | ||
136 | QString currWord = currentWord(); | 160 | QString currWord = currentWord(); | ||
▲ Show 20 Lines • Show All 478 Lines • Show Last 20 Lines |
Dynamic_cast is pretty expensive to not check against nullptr, use static_cast instead.