void BlackListBalooEmailCompletionWidgetTest::shouldEnablePushButtonWhenTestSizeSupperiorToTwo() { KPIM::BlackListBalooEmailCompletionWidget widget; KLineEdit *searchLineEdit = widget.findChild<KLineEdit *>(QStringLiteral("search_lineedit")); QPushButton *seachButton = widget.findChild<QPushButton *>(QStringLiteral("search_button")); QVERIFY(!seachButton->isEnabled()); searchLineEdit->setText(QStringLiteral("fo")); QVERIFY(!seachButton->isEnabled()); searchLineEdit->setText(QStringLiteral("foo")); QVERIFY(seachButton->isEnabled()); searchLineEdit->setText(QStringLiteral("o ")); QVERIFY(!seachButton->isEnabled()); searchLineEdit->setText(QStringLiteral(" o ")); QVERIFY(!seachButton->isEnabled()); }
void Delegate::setEditorData(QWidget *editor, const QModelIndex &index) const { QString value = index.model()->data(index, Qt::EditRole).toString(); KLineEdit *le = static_cast<KLineEdit*>(editor); le->setText(value); }
void KrunnerHistoryComboBox::discardCompletion() { //FIXME: find a reliable way to see if the scene is empty; now defaults to // never complete bool emptyScene = false; KLineEdit* edit = static_cast<KLineEdit*>(lineEdit()); bool suggestedCompletion = (edit->text() != edit->userText()); if (emptyScene && suggestedCompletion) { // We hit TAB with an empty scene and a suggested completion: // Complete but don't lose focus edit->setText(edit->text()); } else if (suggestedCompletion) { // We hit TAB with a non-empty scene and a suggested completion: // Assume the user wants to switch input to the results scene and discard the completion edit->setText(edit->userText()); } }
void CharDataInformation::staticSetWidgetData(quint8 value, QWidget* w) { KLineEdit* edit = dynamic_cast<KLineEdit*> (w); if (edit) { QChar qchar(value, 0); if (! qchar.isPrint()) qchar = QChar(QChar::ReplacementCharacter); edit->setText( qchar ); } }
void KonqBookmarkDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { QString text = index.model()->data(index, Qt::EditRole).toString(); if(index.column() == KonqBookmarkModel::Url) { LocationBar *LocationBarEditor = qobject_cast<LocationBar*>(editor); LocationBarEditor->setText(text); } else { KLineEdit *kLineEditEditor = static_cast<KLineEdit*>(editor); kLineEditEditor->setText(text); } }
void RuleDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const { const QString rule = index.data(Qt::EditRole).toString(); if (rule.isEmpty()) { return; } KLineEdit *ruleLineEdit = static_cast<KLineEdit*>(editor->layout()->itemAt(0)->widget()); ruleLineEdit->setText(rule.mid(rule.indexOf('+', 3) + 1)); KComboBox *matchComboBox = static_cast<KComboBox*>(editor->layout()->itemAt(1)->widget()); matchComboBox->setCurrentIndex(rule.mid(2, (rule.indexOf('+', 3) - 2)).toInt()); QCheckBox *requiredCheckBox = static_cast<QCheckBox*>(editor->layout()->itemAt(2)->widget()); requiredCheckBox->setChecked(rule.at(0) == '1'); }
void KNewFileMenuPrivate::executeRealFileOrDir(const KNewFileMenuSingleton::Entry& entry) { // The template is not a desktop file // Show the small dialog for getting the destination filename QString text = entry.text; text.remove("..."); // the ... is fine for the menu item but not for the default filename text = text.trimmed(); // In some languages, there is a space in front of "...", see bug 268895 m_strategy.m_src = entry.templatePath; KUrl defaultFile(m_popupFiles.first()); defaultFile.addPath(KIO::encodeFileName(text)); if (defaultFile.isLocalFile() && QFile::exists(defaultFile.toLocalFile())) text = KIO::RenameDialog::suggestName(m_popupFiles.first(), text); KDialog* fileDialog = new KDialog(m_parentWidget); fileDialog->setAttribute(Qt::WA_DeleteOnClose); fileDialog->setModal(q->isModal()); fileDialog->setButtons(KDialog::Ok | KDialog::Cancel); QWidget* mainWidget = new QWidget(fileDialog); QVBoxLayout *layout = new QVBoxLayout(mainWidget); QLabel *label = new QLabel(entry.comment); // We don't set the text of lineEdit in its constructor because the clear button would not be shown then. // It seems that setClearButtonShown(true) must be called *before* the text is set to make it work. // TODO: should probably be investigated and fixed in KLineEdit. KLineEdit *lineEdit = new KLineEdit; lineEdit->setClearButtonShown(true); lineEdit->setText(text); _k_slotTextChanged(text); QObject::connect(lineEdit, SIGNAL(textChanged(const QString &)), q, SLOT(_k_slotTextChanged(const QString &))); layout->addWidget(label); layout->addWidget(lineEdit); fileDialog->setMainWidget(mainWidget); QObject::connect(fileDialog, SIGNAL(accepted()), q, SLOT(_k_slotRealFileOrDir())); QObject::connect(fileDialog, SIGNAL(rejected()), q, SLOT(_k_slotAbortDialog())); fileDialog->show(); lineEdit->selectAll(); lineEdit->setFocus(); }
void CharactersViewDelegate::setEditorData(QWidget* editor, const QModelIndex& index) const { switch (index.column()) { case 0: case 1: { KLineEdit* lineEdit = static_cast<KLineEdit*>(editor); lineEdit->setText(index.data(Qt::EditRole).toString()); break; } case 2: { KComboBox* comboBox = static_cast<KComboBox*>(editor); comboBox->setCurrentIndex(index.data(Qt::EditRole).toInt()); break; } default: QStyledItemDelegate::setEditorData(editor, index); } }
FileEditor::FileEditor(FileContent *fileContent, QWidget *parent) : NoteEditor(fileContent), m_fileContent(fileContent) { KLineEdit *lineEdit = new KLineEdit(parent); FocusWidgetFilter *filter = new FocusWidgetFilter(lineEdit); QPalette palette; palette.setColor(lineEdit->backgroundRole(), note()->backgroundColor()); palette.setColor(lineEdit->foregroundRole(), note()->textColor()); lineEdit->setPalette(palette); lineEdit->setFont(note()->font()); lineEdit->setText(m_fileContent->fileName()); lineEdit->selectAll(); setInlineEditor(lineEdit); connect(filter, SIGNAL(returnPressed()), this, SIGNAL(askValidation())); connect(filter, SIGNAL(escapePressed()), this, SIGNAL(askValidation())); connect(filter, SIGNAL(mouseEntered()), this, SIGNAL(mouseEnteredEditorWidget())); }
void KWQTableDelegate::setEditorData(QWidget * editor, const QModelIndex & index) const { KLineEdit *lineEdit = static_cast<KLineEdit*>(editor); lineEdit->setText(index.data(Qt::DisplayRole).toString()); }
DialogCreateTag::DialogCreateTag(QWidget *parent, TagTreeNode* parentNode, const char *name) : KDialogBase(parent, name, true, "", KDialogBase::Ok|KDialogBase::Cancel, KDialogBase::Ok, false ) , m_parentNode(parentNode) { if (parentNode) { this->setCaption(i18n("Create tag")); } else { this->setCaption(i18n("Create toplevel tag")); } QWidget* mainPanel = new QWidget(this, "mainPanel"); setMainWidget(mainPanel); QVBoxLayout* mainPanelLayout = new QVBoxLayout(mainPanel, 0, 5, "mainPanelLayout"); mainPanelLayout->setAutoAdd(true); // parent if (parentNode) { // newTagGroup QGroupBox* parentTagGroup = new QGroupBox(i18n("Parent tag"), mainPanel, "parentTagGroup"); QGridLayout* parentTagGroupLayout = new QGridLayout(parentTagGroup, 4, 4, 20, 5, "parentTagGroupLayout"); parentTagGroupLayout->setRowSpacing(0, 10); // type QLabel* typeLabel = new QLabel(i18n("Type"), parentTagGroup, "typeLabel"); parentTagGroupLayout->addWidget(typeLabel, 1, 0); KComboBox* typeComboBox = new KComboBox(false, parentTagGroup, "typeComboBox"); typeComboBox->insertItem(parentNode->tagNode()->typeName()); typeComboBox->setEnabled(false); parentTagGroupLayout->addMultiCellWidget(typeComboBox, 1, 1, 1, 2); // name QLabel* nameLabel = new QLabel(i18n("Name"), parentTagGroup, "nameLabel"); parentTagGroupLayout->addWidget(nameLabel, 2, 0); KLineEdit* nameLineEdit = new KLineEdit(parentTagGroup, "nameLineEdit"); nameLineEdit->setText(*parentNode->tagNode()->text()); nameLineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); nameLineEdit->setReadOnly(true); parentTagGroupLayout->addMultiCellWidget(nameLineEdit, 2, 2, 1, 2); // icon QLabel* iconLabel = new QLabel(i18n("Icon"), parentTagGroup, "iconLabel"); parentTagGroupLayout->addWidget(iconLabel, 3, 0); KLineEdit* iconLineEdit = new KLineEdit(parentTagGroup, "iconLineEdit"); iconLineEdit->setText(*parentNode->tagNode()->iconName()); iconLineEdit->setMinimumWidth(300); iconLineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); iconLineEdit->setReadOnly(true); parentTagGroupLayout->addWidget(iconLineEdit, 3, 1); QPushButton* iconButton = new QPushButton(i18n("Icon"), parentTagGroup, "iconButton"); QIconSet iconSet = KGlobal::iconLoader()->loadIconSet(iconLineEdit->text(), KIcon::Small, Configuration::getInstance()->tagtreeIconSize(), true); iconButton->setIconSet(iconSet); iconButton->setText(QString::null); iconButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); iconButton->setEnabled(true); parentTagGroupLayout->addWidget(iconButton, 3, 2); } // newTagGroup QGroupBox* newTagGroup = new QGroupBox(i18n("New tag"), mainPanel, "newTagGroup"); QGridLayout* newTagGroupLayout = new QGridLayout(newTagGroup, 4, 4, 20, 5, "newTagGroupLayout"); newTagGroupLayout->setRowSpacing(0, 10); // type QLabel* typeLabel = new QLabel(i18n("Type"), newTagGroup, "typeLabel"); newTagGroupLayout->addWidget(typeLabel, 1, 0); m_typeComboBox = new KComboBox(false, newTagGroup, "typeComboBox"); m_typeComboBoxEntries = new QValueList<int>; if (!parentNode) { m_typeComboBox->insertItem(TagNode::tagNodeTypeName(TagNode::TYPE_TITLE)); m_typeComboBoxEntries->append(TagNode::tagNodeTypeId(TagNode::TYPE_TITLE)); } m_typeComboBox->insertItem(TagNode::tagNodeTypeName(TagNode::TYPE_BOOLEAN)); m_typeComboBoxEntries->append(TagNode::tagNodeTypeId(TagNode::TYPE_BOOLEAN)); newTagGroupLayout->addMultiCellWidget(m_typeComboBox, 1, 1, 1, 2); // name QLabel* nameLabel = new QLabel(i18n("Name"), newTagGroup, "nameLabel"); newTagGroupLayout->addWidget(nameLabel, 2, 0); m_nameLineEdit = new KLineEdit(newTagGroup, "nameLineEdit"); m_nameLineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); QObject::connect(m_nameLineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slotNameChanged(const QString&))); newTagGroupLayout->addMultiCellWidget(m_nameLineEdit, 2, 2, 1, 2); // icon QLabel* iconLabel = new QLabel(i18n("Icon"), newTagGroup, "iconLabel"); newTagGroupLayout->addWidget(iconLabel, 3, 0); m_iconLineEdit = new KLineEdit(newTagGroup, "iconLineEdit"); m_iconLineEdit->setMinimumWidth(300); m_iconLineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); QObject::connect(m_iconLineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slotIconTextChanged(const QString&))); newTagGroupLayout->addWidget(m_iconLineEdit, 3, 1); m_iconButton = new QPushButton(i18n("Icon"), newTagGroup, "iconButton"); m_iconButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); newTagGroupLayout->addWidget(m_iconButton, 3, 2); QObject::connect(m_iconButton, SIGNAL(clicked()), this, SLOT(slotIconButtonClicked())); // spacer QWidget* spacer = new QWidget(mainPanel, "spacer"); spacer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding); // disable ok button validate(); // set the focus m_nameLineEdit->setFocus(); }
void setText( const QString& text ) { edit->setText( text ); }