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