File indexing completed on 2025-01-12 06:47:26
0001 /*************************************************************************** 0002 cinputline.h - input line widgets 0003 This file is a part of KMuddy distribution. 0004 ------------------- 0005 begin : So Jun 29 2002 0006 copyright : (C) 2002 by Tomas Mecir 0007 email : kmuddy@kmuddy.com 0008 ***************************************************************************/ 0009 0010 /*************************************************************************** 0011 * * 0012 * This program is free software; you can redistribute it and/or modify * 0013 * it under the terms of the GNU General Public License as published by * 0014 * the Free Software Foundation; either version 2 of the License, or * 0015 * (at your option) any later version. * 0016 * * 0017 ***************************************************************************/ 0018 0019 #ifndef CINPUTLINE_H 0020 #define CINPUTLINE_H 0021 0022 #include <KLineEdit> 0023 0024 #include <cactionbase.h> 0025 #include <kmuddy_export.h> 0026 0027 #define CMDHISTORYSIZE 100 0028 0029 /**Input line - that's where you type your commands... 0030 *@author Tomas Mecir 0031 */ 0032 0033 class KMUDDY_EXPORT cInputLine : public KLineEdit, public cActionBase { 0034 Q_OBJECT 0035 public: 0036 cInputLine (int sess, QString objName="inputline", QWidget *parent=nullptr); 0037 ~cInputLine() override; 0038 /** initialize the input line - must be separated 0039 from the constructor, because it uses cSession, which is not 0040 available in constructor */ 0041 void initialize (); 0042 0043 void keepText (bool value); 0044 void selectKeptText (bool value); 0045 void setArrowsHistory (bool value); 0046 void setAC (bool useac); 0047 /** set auto-completion type. Types are defined in KGlobalSettings: 0048 CompletionNone=1 //No completion is used. 0049 CompletionAuto=2 //Text is automatically filled in whenever possible. 0050 CompletionMan=3 //Same as automatic except shortest match is used for completion 0051 CompletionShell=4 //Complete text much in the same way as a typical *nix shell would. 0052 CompletionPopup=5 //Lists all possible matches in a popup list-box to choose from. 0053 CompletionPopupAuto=6 //Lists all possible matches in a popup list-box to choose from, and automatically * fill the result whenever possible. 0054 Types 4 and 6 don't work. I have no idea why... 0055 */ 0056 void setACType (int typeofac); 0057 void setTelnetPaste (bool tnp); 0058 public slots: 0059 /** reimplemented handler for pasting */ 0060 virtual void paste (); 0061 protected slots: 0062 void handleEnter (const QString &text); 0063 protected: 0064 void eventNothingHandler (QString event, int session) override; 0065 QString actionStringHandler (QString action, int, QString &par1, 0066 const QString &) override; 0067 0068 // virtual void paste (); 0069 virtual void paste (const QString &t); 0070 void handleTabExpansion (); 0071 /** event filter - handles TAB expansion */ 0072 bool event (QEvent *e) override; 0073 /** keypress event - handles history Up/Down browsing*/ 0074 void keyPressEvent (QKeyEvent *e) override; 0075 /** mouse-release event - handles middle-click paste */ 0076 void mouseReleaseEvent (QMouseEvent *e) override; 0077 /** we got focus - restore selection (needed because selection is lost 0078 when switching between connections) */ 0079 void focusInEvent (QFocusEvent *e) override; 0080 /** we lost focus - store selection (needed because selection is lost 0081 when switching between connections)*/ 0082 void focusOutEvent (QFocusEvent *e) override; 0083 QString getHistory (bool next); 0084 QString menuitem[CMDHISTORYSIZE]; 0085 void addHistory (const QString &text); 0086 int menuitems; 0087 int lastid; 0088 bool keeptext; 0089 bool selectkepttext; 0090 bool arrowshistory; 0091 bool useac; 0092 int curactype; 0093 int historypos; 0094 /** telnet-style paste */ 0095 bool tnpaste; 0096 0097 /** TAB-expansion */ 0098 QStringList tabWords; 0099 bool tabExpanding; 0100 int expandPos, tabListPos; 0101 0102 /** selection start/length, stored/restored in focusIN/focusOut events */ 0103 int ss, sl; 0104 }; 0105 0106 #endif