Permalink
Browse files

Add selectAll() to QSearchField.

  • Loading branch information...
1 parent 5b0e0d9 commit c8f1b6fc7a49f729b1f6ad0e9d39a8e2d8aa2b51 @hatstand hatstand committed with Jun 28, 2012
Showing with 20 additions and 1 deletion.
  1. +2 −1 qsearchfield.h
  2. +9 −0 qsearchfield_mac.mm
  3. +9 −0 qsearchfield_nonmac.cpp
View
3 qsearchfield.h
@@ -20,8 +20,9 @@ class QSearchField : public QWidget
public slots:
void setText(const QString &text);
void setPlaceholderText(const QString &text);
-
void clear();
+ void selectAll();
+
signals:
void textChanged(const QString &text);
void editingFinished();
View
9 qsearchfield_mac.mm
@@ -135,6 +135,15 @@ -(void)controlTextDidEndEditing:(NSNotification*)notification {
emit textChanged(QString());
}
+void QSearchField::selectAll()
+{
+ Q_ASSERT(pimpl);
+ if (!pimpl)
+ return;
+
+ [pimpl->nsSearchField performSelector:@selector(selectText:)];
+}
+
QString QSearchField::text() const
{
Q_ASSERT(pimpl);
View
9 qsearchfield_nonmac.cpp
@@ -113,6 +113,15 @@ void QSearchField::clear()
pimpl->lineEdit->clear();
}
+void QSearchField::selectAll()
+{
+ Q_ASSERT(pimpl && pimpl->lineEdit);
+ if (!(pimpl && pimpl->lineEdit))
+ return;
+
+ pimpl->lineEdit->selectAll();
+}
+
QString QSearchField::text() const
{
Q_ASSERT(pimpl && pimpl->lineEdit);

0 comments on commit c8f1b6f

Please sign in to comment.