summaryrefslogtreecommitdiffstats
path: root/tdeui/krestrictedline.cpp
diff options
context:
space:
mode:
authorTimothy Pearson <[email protected]>2011-11-06 15:56:40 -0600
committerTimothy Pearson <[email protected]>2011-11-06 15:56:40 -0600
commite16866e072f94410321d70daedbcb855ea878cac (patch)
treeee3f52eabde7da1a0e6ca845fb9c2813cf1558cf /tdeui/krestrictedline.cpp
parenta58c20c1a7593631a1b50213c805507ebc16adaf (diff)
downloadtdelibs-e16866e072f94410321d70daedbcb855ea878cac.tar.gz
tdelibs-e16866e072f94410321d70daedbcb855ea878cac.zip
Actually move the kde files that were renamed in the last commit
Diffstat (limited to 'tdeui/krestrictedline.cpp')
-rw-r--r--tdeui/krestrictedline.cpp81
1 files changed, 81 insertions, 0 deletions
diff --git a/tdeui/krestrictedline.cpp b/tdeui/krestrictedline.cpp
new file mode 100644
index 000000000..85c52d54c
--- /dev/null
+++ b/tdeui/krestrictedline.cpp
@@ -0,0 +1,81 @@
+/*
+ *
+ *
+ * Implementation of KRestrictedLine
+ *
+ * Copyright (C) 1997 Michael Wiedmann, <[email protected]>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#include <tqkeycode.h>
+
+#include "krestrictedline.h"
+
+KRestrictedLine::KRestrictedLine( TQWidget *parent,
+ const char *name,
+ const TQString& valid )
+ : KLineEdit( parent, name )
+{
+ qsValidChars = valid;
+}
+
+KRestrictedLine::~KRestrictedLine()
+{
+ ;
+}
+
+
+void KRestrictedLine::keyPressEvent( TQKeyEvent *e )
+{
+ // let TQLineEdit process "special" keys and return/enter
+ // so that we still can use the default key binding
+ if (e->key() == Key_Enter || e->key() == Key_Return || e->key() == Key_Delete || e->ascii() < 32)
+ {
+ TQLineEdit::keyPressEvent(e);
+ return;
+ }
+
+ // do we have a list of valid chars &&
+ // is the pressed key in the list of valid chars?
+ if (!qsValidChars.isEmpty() && !qsValidChars.contains(e->ascii()))
+ {
+ // invalid char, emit signal and return
+ emit (invalidChar(e->key()));
+ return;
+ }
+ else
+ // valid char: let TQLineEdit process this key as usual
+ TQLineEdit::keyPressEvent(e);
+
+ return;
+}
+
+
+void KRestrictedLine::setValidChars( const TQString& valid)
+{
+ qsValidChars = valid;
+}
+
+TQString KRestrictedLine::validChars() const
+{
+ return qsValidChars;
+}
+
+void KRestrictedLine::virtual_hook( int id, void* data )
+{ KLineEdit::virtual_hook( id, data ); }
+
+#include "krestrictedline.moc"