File indexing completed on 2024-04-28 03:53:10

0001 /*
0002     This file is part of the KDE libraries
0003 
0004     SPDX-FileCopyrightText: 2007 Aaron Seigo <aseigo@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #ifndef KLINEEDIT_P_H
0010 #define KLINEEDIT_P_H
0011 
0012 #include "klineedit.h"
0013 
0014 class KCompletionBox;
0015 class KLineEditUrlDropEventFilter;
0016 
0017 class KLineEditPrivate
0018 {
0019 public:
0020     explicit KLineEditPrivate(KLineEdit *parent)
0021         : q_ptr(parent)
0022     {
0023     }
0024 
0025     ~KLineEditPrivate();
0026 
0027     void _k_textChanged(const QString &text);
0028     void _k_completionMenuActivated(QAction *act);
0029     void _k_tripleClickTimeout(); // resets possibleTripleClick
0030     void _k_restoreSelectionColors();
0031     void _k_completionBoxTextChanged(const QString &text);
0032 
0033     void updateUserText(const QString &text);
0034 
0035     /**
0036      * Checks whether we should/should not consume a key used as a shortcut.
0037      * This makes it possible to handle shortcuts in the focused widget before any
0038      * window-global QAction is triggered.
0039      */
0040     bool overrideShortcut(const QKeyEvent *e);
0041 
0042     void init();
0043 
0044     bool copySqueezedText(bool copy) const;
0045 
0046     /**
0047      * Properly sets the squeezed text whenever the widget is
0048      * created or resized.
0049      */
0050     void setSqueezedText();
0051 
0052     QMap<KCompletion::CompletionMode, bool> disableCompletionMap;
0053 
0054     QColor previousHighlightColor;
0055     QColor previousHighlightedTextColor;
0056 
0057     QPalette::ColorRole bgRole;
0058 
0059     QString squeezedText;
0060     QString userText;
0061     QString lastStyleClass;
0062 
0063     QMetaObject::Connection m_matchesConnection;
0064     KCompletionBox *completionBox;
0065 
0066     KLineEditUrlDropEventFilter *urlDropEventFilter;
0067 
0068     QAction *noCompletionAction;
0069     QAction *shellCompletionAction;
0070     QAction *autoCompletionAction;
0071     QAction *popupCompletionAction;
0072     QAction *shortAutoCompletionAction;
0073     QAction *popupAutoCompletionAction;
0074     QAction *defaultAction;
0075 
0076     KLineEdit *const q_ptr;
0077 
0078     int squeezedEnd;
0079     int squeezedStart;
0080 
0081     static bool s_initialized;
0082     static bool s_backspacePerformsCompletion; // Configuration option
0083 
0084     bool userSelection : 1;
0085     bool autoSuggest : 1;
0086     bool disableRestoreSelection : 1;
0087     bool handleURLDrops : 1;
0088     bool trapReturnKeyEvents : 1;
0089     bool enableSqueezedText : 1;
0090     bool completionRunning : 1;
0091     bool italicizePlaceholder : 1;
0092     bool threeStars : 1;
0093     bool possibleTripleClick : 1; // set in mousePressEvent, deleted in tripleClickTimeout
0094     Q_DECLARE_PUBLIC(KLineEdit)
0095 };
0096 
0097 #endif