KTextEditor
katemodemenulist.cpp
32 return (c <= 126 && c >= 33 && (c >= 123 || c <= 47 || (c <= 96 && c >= 58 && c != 95 && (c >= 91 || c <= 63)))) || c == 171 || c == 187;
141 "Search for syntax highlighting modes by language name or file extension (for example, C++ or .cpp)"));
168 layoutScrollBar->setContentsMargins(1, 2, 2, 2); // ScrollBar Margin = 2, Also see: KateModeMenuListData::ListView::getContentWidth()
184 connect(m_list, &KateModeMenuListData::ListView::clicked, this, &KateModeMenuList::selectHighlighting);
258 if (!hl->translatedSection.isEmpty() && (prevHlSection == nullptr || hl->translatedSection != *prevHlSection)) {
283KateModeMenuListData::ListItem *KateModeMenuList::createSectionList(const QString §ionName, const QBrush &background, bool bSeparator, int modelPosition)
346 int heightSectionMargin = m_list->visualRect(m_model->index(section->row(), 0)).height() - label->sizeHint().height();
349 label->setText(setWordWrap(label->text(), containerTextWidth - label->indent(), label->fontMetrics()));
353 section->setSizeHint(QSize(section->sizeHint().width(), label->sizeHint().height() + heightSectionMargin));
361void KateModeMenuList::setButton(QPushButton *button, AlignmentHButton positionX, AlignmentVButton positionY, AutoUpdateTextButton autoUpdateTextButton)
429 const int buttonPositionRight = m_pushButton->mapToGlobal(QPoint(0, 0)).x() + m_pushButton->geometry().width();
494void KateModeMenuList::selectHighlightingSetVisibility(QStandardItem *pItem, const bool bHideMenu)
524 KateModeMenuListData::ListItem *item = static_cast<KateModeMenuListData::ListItem *>(m_model->item(i, 0));
529 if (item->getMode()->name == nameMode || (nameMode.isEmpty() && item->getMode()->name == QLatin1String("Normal"))) {
564 m_emptyListMsg = new QLabel(i18nc("A search yielded no results", "No items matching your search"), this);
571 m_emptyListMsg->setStyleSheet(QLatin1String("font-size: ") + QString::number(fontSize) + QLatin1String("pt; color: rgba(") + QString::number(color.red())
572 + QLatin1Char(',') + QString::number(color.green()) + QLatin1Char(',') + QString::number(color.blue())
579QString KateModeMenuList::setWordWrap(const QString &text, const int maxWidth, const QFontMetrics &fontMetrics) const
602 fontMetrics.elidedText(words[i], m_list->layoutDirection() == Qt::RightToLeft ? Qt::ElideLeft : Qt::ElideRight, maxWidth) + QLatin1Char('\n');
610 && fontMetrics.horizontalAdvance(tmpLineText + QLatin1Char(' ') + words[i + 1] + QLatin1Char(' ') + words[i + 2]) > maxWidth) {
615 else if (fontMetrics.horizontalAdvance(tmpLineText + QLatin1Char(' ') + words[i + 1]) > maxWidth) {
629 if (isDelimiter(words[lastw][c].unicode()) && fontMetrics.horizontalAdvance(words[lastw].mid(0, c + 1)) <= maxWidth) {
648 newText += fontMetrics.elidedText(words[words.count() - 1], m_list->layoutDirection() == Qt::RightToLeft ? Qt::ElideLeft : Qt::ElideRight, maxWidth);
676int KateModeMenuListData::ListView::getContentWidth(const int overlayScrollbarMargin, const int classicScrollbarMargin) const
703 if (bNewName && i < searchName.length() - 1 && searchName[i].isSpace() && searchName[i + 1].isSpace()) {
736 if (text.length() == ext.length() - 2 && text.compare(QStringView(ext).mid(2), Qt::CaseInsensitive) == 0) {
753 && (event->modifiers().testFlag(Qt::ControlModifier) || event->modifiers().testFlag(Qt::AltModifier) || event->modifiers().testFlag(Qt::ShiftModifier)
768 && (event->matches(QKeySequence::MoveToNextLine) || event->matches(QKeySequence::SelectNextLine) || event->matches(QKeySequence::MoveToPreviousLine)
769 || event->matches(QKeySequence::SelectPreviousLine) || event->matches(QKeySequence::MoveToNextPage) || event->matches(QKeySequence::SelectNextPage)
770 || event->matches(QKeySequence::MoveToPreviousPage) || event->matches(QKeySequence::SelectPreviousPage) || event->key() == Qt::Key_Return
780 connect(this, &KateModeMenuListData::SearchLine::textChanged, this, &KateModeMenuListData::SearchLine::_k_queueSearch);
843 listModel->insertRow(m_bestResults.at(i).second + sizeBestResults - i - 1, m_bestResults.at(i).first);
978 KateModeMenuListData::ListItem *item = static_cast<KateModeMenuListData::ListItem *>(listModel->item(i, 0));
985 item->generateSearchName(item->getMode()->translatedName.isEmpty() ? item->getMode()->name : item->getMode()->translatedName);
995 || (bExactMatch && item->getMode()->nameTranslated().compare(searchText, m_caseSensitivity) == 0))) {
1048 } else if (bExactMatch && item->getMode()->nameTranslated().contains(searchText, m_caseSensitivity)) {
1069 if (bEmptySection && lastSection > 0 && !listModel->item(listModel->rowCount() - 1, 0)->text().isEmpty()) {
1089 i18nc("Title (in singular) of the best result in an item search. Please, that the translation doesn't have more than 34 characters, since the "
1094 i18nc("Title (in plural) of the best results in an item search. Please, that the translation doesn't have more than 34 characters, since the "
1099 int heightSectionMargin = m_parentMenu->m_defaultHeightItemSection - labelSection->sizeHint().height();
1104 // NOTE: labelSection->sizeHint().width() == labelSection->indent() + labelSection->fontMetrics().horizontalAdvance(labelSection->text())
1108 listModel->item(0, 0)->setSizeHint(QSize(listModel->item(0, 0)->sizeHint().width(), labelSection->sizeHint().height() + heightSectionMargin));
1118 if (searchText.length() == 1 && searchText.compare(QLatin1String("r"), m_caseSensitivity) == 0) {
1144 if (listView->visualRect(listModel->index(lastItem, 0)).bottom() + labelSection->sizeHint().height() + heightSectionMargin
1147 labelSection->setText(m_parentMenu->setWordWrap(labelSection->text(), maxWidthText, labelSection->fontMetrics()));
1149 listModel->item(0, 0)->setSizeHint(QSize(listModel->item(0, 0)->sizeHint().width(), labelSection->sizeHint().height() + heightSectionMargin));
1169 else if (m_parentMenu->m_scroll && listView->visualRect(listModel->index(lastItem, 0)).bottom() <= listView->geometry().height()) {
1176void KateModeMenuListData::SearchLine::setSearchResult(const int rowItem, bool &bEmptySection, int &lastSection, int &firstSection, int &lastItem)
Backend of KTextEditor::Document related public KTextEditor interfaces.
Definition katedocument.h:68
bool updateFileType(const QString &newType, bool user=false)
Definition katedocument.cpp:5691
Class of an Item of the Data Model of the List.
Definition katemodemenulist.h:373
void setMode(KateFileType *type)
Associate this item with a KateFileType object.
Definition katemodemenulist.h:393
bool generateSearchName(const QString &itemName)
Generate name of the item used for the search.
Definition katemodemenulist.cpp:689
bool matchExtension(const QString &text) const
Find matches in the extensions of the item mode, with a text.
Definition katemodemenulist.cpp:723
void setSizeList(const int height, const int width=266)
Define the size of the widget list.
Definition katemodemenulist.cpp:661
int getContentWidth() const
Get the width of the contents of the list (in pixels), that is, the list minus the scroll bar and mar...
Definition katemodemenulist.cpp:684
void keyPressEvent(QKeyEvent *event) override
Override from QListView.
Definition katemodemenulist.cpp:749
void setWidth(const int width)
Define the width of the search bar, in pixels.
Definition katemodemenulist.cpp:655
void keyPressEvent(QKeyEvent *event) override
Override from QLineEdit.
Definition katemodemenulist.cpp:765
bool selectHighlightingFromExternal()
Update the selected item in the list widget, but without changing the syntax highlighting in the docu...
Definition katemodemenulist.cpp:553
AlignmentVButton
Vertical Alignment with respect to the trigger button.
Definition katemodemenulist.h:80
void updateMenu(KTextEditor::Document *doc)
Set document to apply the syntax highlighting.
Definition katemodemenulist.cpp:1201
AlignmentHButton
Horizontal Alignment with respect to the trigger button.
Definition katemodemenulist.h:68
void showEvent(QShowEvent *event) override
Action when displaying the menu.
Definition katemodemenulist.cpp:396
void setButton(QPushButton *button, AlignmentHButton positionX=AlignHDefault, AlignmentVButton positionY=AlignTop, AutoUpdateTextButton autoUpdateTextButton=AutoUpdateTextButton(false))
Set the button that shows this menu.
Definition katemodemenulist.cpp:361
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString label(StandardShortcut id)
PositionAtCenter
void clicked(const QModelIndex &index)
void setIconSize(const QSize &size)
QWidget * indexWidget(const QModelIndex &index) const const
virtual void keyPressEvent(QKeyEvent *event) override
void scrollToTop()
QItemSelectionModel * selectionModel() const const
void setIndexWidget(const QModelIndex &index, QWidget *widget)
virtual void setModel(QAbstractItemModel *model)
void setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy)
void setVerticalScrollBar(QScrollBar *scrollBar)
void setVerticalScrollBarPolicy(Qt::ScrollBarPolicy)
void addLayout(QLayout *layout, int stretch)
void addWidget(QWidget *widget, int stretch, Qt::Alignment alignment)
int blue() const const
int green() const const
int red() const const
bool sendEvent(QObject *receiver, QEvent *event)
Bold
void setFamily(const QString &family)
QString elidedText(const QString &text, Qt::TextElideMode mode, int width, int flags) const const
int horizontalAdvance(QChar ch) const const
HLine
void setFrameStyle(int style)
void addLayout(QLayout *layout, int row, int column, Qt::Alignment alignment)
void addWidget(QWidget *widget, int fromRow, int fromColumn, int rowSpan, int columnSpan, Qt::Alignment alignment)
Deselect
virtual void clear()
virtual void select(const QItemSelection &selection, QItemSelectionModel::SelectionFlags command)
MoveToNextLine
void setAlignment(Qt::Alignment)
indent
void setMargin(int)
virtual QSize sizeHint() const const override
void setText(const QString &)
void setWordWrap(bool on)
void setContentsMargins(const QMargins &margins)
void clear()
virtual void keyPressEvent(QKeyEvent *event) override
void setMaxLength(int)
void setPlaceholderText(const QString &)
void selectAll()
text
void textChanged(const QString &text)
qsizetype count() const const
iterator insert(const_iterator before, parameter_type value)
QList< T > mid(qsizetype pos, qsizetype length) const const
Adjust
bool isRowHidden(int row) const const
void setResizeMode(ResizeMode mode)
void setRowHidden(int row, bool hide)
virtual QRect visualRect(const QModelIndex &index) const const override
int row() const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
Text
void fill(const QColor &color)
int bottom() const const
int height() const const
int height() const const
int width() const const
QModelIndex index() const const
bool isEnabled() const const
bool isSelectable() const const
int row() const const
void setBackground(const QBrush &brush)
void setEditable(bool editable)
void setEnabled(bool enabled)
void setFlags(Qt::ItemFlags flags)
void setIcon(const QIcon &icon)
void setSelectable(bool selectable)
void setSizeHint(const QSize &size)
void setText(const QString &text)
QSize sizeHint() const const
QString text() const const
void appendRow(QStandardItem *item)
void clear()
virtual QModelIndex index(int row, int column, const QModelIndex &parent) const const override
bool insertRow(int row, const QModelIndex &parent)
QStandardItem * item(int row, int column) const const
virtual int rowCount(const QModelIndex &parent) const const override
QList< QStandardItem * > takeRow(int row)
QString & append(QChar ch)
void clear()
int compare(QLatin1StringView s1, const QString &s2, Qt::CaseSensitivity cs)
const_iterator constBegin() const const
const_iterator constEnd() const const
const_iterator
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
bool isNull() const const
qsizetype length() const const
QString mid(qsizetype position, qsizetype n) const const
QString number(double n, char format, int precision)
QString & remove(QChar ch, Qt::CaseSensitivity cs)
QString & replace(QChar before, QChar after, Qt::CaseSensitivity cs)
QString simplified() const const
qsizetype size() const const
QStringList split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
bool startsWith(QChar c, Qt::CaseSensitivity cs) const const
QString trimmed() const const
AlignLeft
CaseInsensitive
ActiveWindowFocusReason
transparent
NoItemFlags
Key_Enter
ControlModifier
RightToLeft
Vertical
ScrollBarAlwaysOff
ElideLeft
PlainText
singleShot
QWidget(QWidget *parent, Qt::WindowFlags f)
font
QFontMetrics fontMetrics() const const
geometry
height
void hide()
bool isHidden() const const
layoutDirection
void setMaximumWidth(int maxw)
void setMinimumWidth(int minw)
palette
pos
void setFocus()
void setFocusProxy(QWidget *w)
void setStyleSheet(const QString &styleSheet)
void setToolTip(const QString &)
width
void setDefaultWidget(QWidget *widget)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:56 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:56 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.