|
|
|
@ -120,6 +120,7 @@ UBTGAdaptableText::UBTGAdaptableText(QTreeWidgetItem* widget, QWidget* parent, c |
|
|
|
|
, mMinimumHeight(0) |
|
|
|
|
, mHasPlaceHolder(false) |
|
|
|
|
, mIsUpdatingSize(false) |
|
|
|
|
, mMaximumLength(0) |
|
|
|
|
{ |
|
|
|
|
setObjectName(name); |
|
|
|
|
connect(this,SIGNAL(textChanged()),this,SLOT(onTextChanged())); |
|
|
|
@ -131,6 +132,11 @@ UBTGAdaptableText::UBTGAdaptableText(QTreeWidgetItem* widget, QWidget* parent, c |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void UBTGAdaptableText::setMaximumLength(int length) |
|
|
|
|
{ |
|
|
|
|
mMaximumLength = length; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void UBTGAdaptableText::setPlaceHolderText(QString text) |
|
|
|
|
{ |
|
|
|
|
mHasPlaceHolder = true; |
|
|
|
@ -166,6 +172,12 @@ void UBTGAdaptableText::keyReleaseEvent(QKeyEvent* e) |
|
|
|
|
setTextColor(QColor(Qt::lightGray)); |
|
|
|
|
setPlainText(mPlaceHolderText); |
|
|
|
|
} |
|
|
|
|
if(mMaximumLength && toPlainText().length()>mMaximumLength){ |
|
|
|
|
setPlainText(toPlainText().left(mMaximumLength)); |
|
|
|
|
QTextCursor tc(document()); |
|
|
|
|
tc.setPosition(mMaximumLength); |
|
|
|
|
setTextCursor(tc); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void UBTGAdaptableText::showEvent(QShowEvent* e) |
|
|
|
@ -212,8 +224,10 @@ void UBTGAdaptableText::onTextChanged() |
|
|
|
|
setFocus(); |
|
|
|
|
} |
|
|
|
|
mIsUpdatingSize = false; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void UBTGAdaptableText::setInitialText(const QString& text) |
|
|
|
|
{ |
|
|
|
|
setText(text); |
|
|
|
|