Changeset View
Changeset View
Standalone View
Standalone View
addons/search/plugin_search.cpp
Show First 20 Lines • Show All 216 Lines • ▼ Show 20 Line(s) | |||||
217 | : QObject (mainWin), | 217 | : QObject (mainWin), | ||
218 | m_kateApp(application), | 218 | m_kateApp(application), | ||
219 | m_curResults(nullptr), | 219 | m_curResults(nullptr), | ||
220 | m_searchJustOpened(false), | 220 | m_searchJustOpened(false), | ||
221 | m_switchToProjectModeWhenAvailable(false), | 221 | m_switchToProjectModeWhenAvailable(false), | ||
222 | m_searchDiskFilesDone(true), | 222 | m_searchDiskFilesDone(true), | ||
223 | m_searchOpenFilesDone(true), | 223 | m_searchOpenFilesDone(true), | ||
224 | m_isSearchAsYouType(false), | 224 | m_isSearchAsYouType(false), | ||
225 | m_isLeftRight(false), | ||||
225 | m_projectPluginView(nullptr), | 226 | m_projectPluginView(nullptr), | ||
226 | m_mainWindow (mainWin) | 227 | m_mainWindow (mainWin) | ||
227 | { | 228 | { | ||
228 | KXMLGUIClient::setComponentName (QStringLiteral("katesearch"), i18n ("Kate Search & Replace")); | 229 | KXMLGUIClient::setComponentName (QStringLiteral("katesearch"), i18n ("Kate Search & Replace")); | ||
229 | setXMLFile( QStringLiteral("ui.rc") ); | 230 | setXMLFile( QStringLiteral("ui.rc") ); | ||
230 | 231 | | |||
231 | m_toolView = mainWin->createToolView (plugin, QStringLiteral("kate_plugin_katesearch"), | 232 | m_toolView = mainWin->createToolView (plugin, QStringLiteral("kate_plugin_katesearch"), | ||
232 | KTextEditor::MainWindow::Bottom, | 233 | KTextEditor::MainWindow::Bottom, | ||
▲ Show 20 Lines • Show All 1753 Lines • ▼ Show 20 Line(s) | 1969 | { | |||
1986 | m_ui.searchPlaceCombo->setCurrentIndex(res->searchPlaceIndex); | 1987 | m_ui.searchPlaceCombo->setCurrentIndex(res->searchPlaceIndex); | ||
1987 | m_ui.searchCombo->blockSignals(false); | 1988 | m_ui.searchCombo->blockSignals(false); | ||
1988 | m_ui.matchCase->blockSignals(false); | 1989 | m_ui.matchCase->blockSignals(false); | ||
1989 | m_ui.useRegExp->blockSignals(false); | 1990 | m_ui.useRegExp->blockSignals(false); | ||
1990 | m_ui.searchPlaceCombo->blockSignals(false); | 1991 | m_ui.searchPlaceCombo->blockSignals(false); | ||
1991 | searchPlaceChanged(); | 1992 | searchPlaceChanged(); | ||
1992 | } | 1993 | } | ||
1993 | 1994 | | |||
1995 | void KatePluginSearchView::onResize(const QSize& size) | ||||
1996 | { | ||||
1997 | bool vertical = size.width() < size.height(); | ||||
1998 | | ||||
1999 | if(!m_isLeftRight && vertical) { | ||||
2000 | m_isLeftRight = true; | ||||
2001 | | ||||
2002 | m_ui.gridLayout->addWidget(m_ui.searchCombo, 0, 1, 1, 8); | ||||
2003 | m_ui.gridLayout->addWidget(m_ui.findLabel, 0, 0); | ||||
2004 | m_ui.gridLayout->addWidget(m_ui.searchButton, 1, 0, 1, 2); | ||||
2005 | m_ui.gridLayout->addWidget(m_ui.nextButton, 1, 2); | ||||
2006 | m_ui.gridLayout->addWidget(m_ui.searchPlaceCombo, 1, 3, 1, 3); | ||||
2007 | m_ui.gridLayout->addWidget(m_ui.displayOptions, 1, 6); | ||||
2008 | m_ui.gridLayout->addWidget(m_ui.matchCase, 1, 7); | ||||
2009 | m_ui.gridLayout->addWidget(m_ui.useRegExp, 1, 8); | ||||
2010 | | ||||
2011 | m_ui.gridLayout->addWidget(m_ui.replaceCombo, 2, 1, 1, 8); | ||||
2012 | m_ui.gridLayout->addWidget(m_ui.replaceLabel, 2, 0); | ||||
2013 | m_ui.gridLayout->addWidget(m_ui.replaceButton, 3, 0, 1, 2); | ||||
2014 | m_ui.gridLayout->addWidget(m_ui.replaceCheckedBtn, 3, 2); | ||||
2015 | m_ui.gridLayout->addWidget(m_ui.expandResults, 3, 7); | ||||
2016 | m_ui.gridLayout->addWidget(m_ui.newTabButton, 3, 8); | ||||
2017 | | ||||
2018 | m_ui.gridLayout->setColumnStretch(4, 2); | ||||
2019 | m_ui.gridLayout->setColumnStretch(2, 0); | ||||
2020 | } | ||||
2021 | else if(m_isLeftRight && !vertical) { | ||||
2022 | m_isLeftRight = false; | ||||
2023 | m_ui.gridLayout->addWidget(m_ui.searchCombo, 0, 2); | ||||
2024 | m_ui.gridLayout->addWidget(m_ui.findLabel, 0, 1); | ||||
2025 | m_ui.gridLayout->addWidget(m_ui.searchButton, 0, 3); | ||||
2026 | m_ui.gridLayout->addWidget(m_ui.nextButton, 0, 4); | ||||
2027 | m_ui.gridLayout->addWidget(m_ui.searchPlaceCombo, 0, 5, 1, 4); | ||||
2028 | m_ui.gridLayout->addWidget(m_ui.matchCase, 1, 5); | ||||
2029 | m_ui.gridLayout->addWidget(m_ui.useRegExp, 1, 6); | ||||
2030 | | ||||
2031 | m_ui.gridLayout->addWidget(m_ui.replaceCombo, 1, 2); | ||||
2032 | m_ui.gridLayout->addWidget(m_ui.replaceLabel, 1, 1); | ||||
2033 | m_ui.gridLayout->addWidget(m_ui.replaceButton, 1, 3); | ||||
2034 | m_ui.gridLayout->addWidget(m_ui.replaceCheckedBtn, 1, 4); | ||||
2035 | m_ui.gridLayout->addWidget(m_ui.expandResults, 1, 8); | ||||
2036 | m_ui.gridLayout->addWidget(m_ui.newTabButton, 0, 0); | ||||
2037 | m_ui.gridLayout->addWidget(m_ui.displayOptions, 1, 0); | ||||
2038 | | ||||
2039 | m_ui.gridLayout->setColumnStretch(4, 0); | ||||
2040 | m_ui.gridLayout->setColumnStretch(2, 2); | ||||
2041 | | ||||
2042 | m_ui.findLabel->setAlignment(Qt::AlignRight); | ||||
2043 | m_ui.replaceLabel->setAlignment(Qt::AlignRight); | ||||
2044 | } | ||||
2045 | } | ||||
1994 | 2046 | | |||
1995 | bool KatePluginSearchView::eventFilter(QObject *obj, QEvent *event) | 2047 | bool KatePluginSearchView::eventFilter(QObject *obj, QEvent *event) | ||
1996 | { | 2048 | { | ||
1997 | if (event->type() == QEvent::KeyPress) { | 2049 | if (event->type() == QEvent::KeyPress) { | ||
1998 | QKeyEvent *ke = static_cast<QKeyEvent*>(event); | 2050 | QKeyEvent *ke = static_cast<QKeyEvent*>(event); | ||
1999 | QTreeWidget *tree = qobject_cast<QTreeWidget *>(obj); | 2051 | QTreeWidget *tree = qobject_cast<QTreeWidget *>(obj); | ||
2000 | if (tree) { | 2052 | if (tree) { | ||
2001 | if (ke->matches(QKeySequence::Copy)) { | 2053 | if (ke->matches(QKeySequence::Copy)) { | ||
2002 | // user pressed ctrl+c -> copy full URL to the clipboard | 2054 | // user pressed ctrl+c -> copy full URL to the clipboard | ||
2003 | QVariant variant = tree->currentItem()->data(0, ReplaceMatches::FileUrlRole); | 2055 | QVariant variant = tree->currentItem()->data(0, ReplaceMatches::FileUrlRole); | ||
2004 | QApplication::clipboard()->setText(variant.toString()); | 2056 | QApplication::clipboard()->setText(variant.toString()); | ||
2005 | event->accept(); | 2057 | event->accept(); | ||
2006 | return true; | 2058 | return true; | ||
2007 | } | 2059 | } | ||
2008 | if (ke->key() == Qt::Key_Enter || ke->key() == Qt::Key_Return) { | 2060 | if (ke->key() == Qt::Key_Enter || ke->key() == Qt::Key_Return) { | ||
2009 | if (tree->currentItem()) { | 2061 | if (tree->currentItem()) { | ||
2010 | itemSelected(tree->currentItem()); | 2062 | itemSelected(tree->currentItem()); | ||
2011 | event->accept(); | 2063 | event->accept(); | ||
2012 | return true; | 2064 | return true; | ||
2013 | } | 2065 | } | ||
2014 | } | 2066 | } | ||
2015 | } | 2067 | } | ||
2016 | // NOTE: Qt::Key_Escape is handled by handleEsc | 2068 | // NOTE: Qt::Key_Escape is handled by handleEsc | ||
2017 | } | 2069 | } | ||
2070 | if (event->type() == QEvent::Resize) { | ||||
2071 | QResizeEvent *re = static_cast<QResizeEvent*>(event); | ||||
2072 | if(obj == m_toolView) | ||||
2073 | { | ||||
2074 | onResize(re->size()); | ||||
2075 | } | ||||
2076 | } | ||||
2018 | return QObject::eventFilter(obj, event); | 2077 | return QObject::eventFilter(obj, event); | ||
2019 | } | 2078 | } | ||
2020 | 2079 | | |||
2021 | void KatePluginSearchView::searchContextMenu(const QPoint& pos) | 2080 | void KatePluginSearchView::searchContextMenu(const QPoint& pos) | ||
2022 | { | 2081 | { | ||
2023 | QSet<QAction *> actionPointers; | 2082 | QSet<QAction *> actionPointers; | ||
2024 | 2083 | | |||
2025 | QMenu* const contextMenu = m_ui.searchCombo->lineEdit()->createStandardContextMenu(); | 2084 | QMenu* const contextMenu = m_ui.searchCombo->lineEdit()->createStandardContextMenu(); | ||
▲ Show 20 Lines • Show All 220 Lines • Show Last 20 Lines |