Пример #1
0
/** Define the QLineEdit to use as city name editor */
void ZipCountryCompleters::setCityLineEdit(QLineEdit *city)
{
    m_City = city;
    // Completer
    QCompleter *completer = new QCompleter(this);
    completer->setModel(m_Model);
    completer->setCompletionColumn(ZipCountryModel::City);
    completer->setCaseSensitivity(Qt::CaseInsensitive);
//    m_Completer->setCompletionMode(QCompleter::UnfilteredPopupCompletion);
    completer->setCompletionMode(QCompleter::PopupCompletion);
    completer->popup()->setAlternatingRowColors(true);
    city->setCompleter(completer);
    connect(m_City, SIGNAL(textChanged(QString)), this, SLOT(cityTextChanged()));
    connect(completer, SIGNAL(activated(QModelIndex)), this, SLOT(indexActivated(QModelIndex)));

    // button
    m_CityButton = new QToolButton(m_City);
    m_CityButton->setToolTip("City button");
    m_CityButton->setToolButtonStyle(Qt::ToolButtonIconOnly);
    m_CityButton->setIconSize(QSize(16,16));
    m_CityButton->setIcon(QIcon(QDir::cleanPath(qApp->applicationDirPath() + "/../../../../../global_resources/pixmap/16x16/ok.png")));
    m_CityButton->setMinimumSize(20,20);
    m_CityButton->setMaximumSize(20,20);
    m_CityButton->setStyleSheet("QToolButton { border: none; padding: 0px; }");
    m_CityButton->show();

    int frameWidth = m_City->style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
    QSize msz = m_City->minimumSizeHint();
    m_City->setMinimumSize(qMax(msz.width(), m_CityButton->maximumHeight() + frameWidth * 2 + 2),
                          qMax(msz.height(), m_CityButton->maximumHeight() + frameWidth * 2 + 2));
    m_City->setStyleSheet(QString("padding-left: %1px;").arg(m_CityButton->sizeHint().width() + frameWidth));
    m_City->installEventFilter(this);
}
Пример #2
0
void AddressDialog::connectSlots()
{
	connect( m_ui->cityEdit, SIGNAL(textChanged(QString)), this, SLOT(cityTextChanged(QString)) );
	connect( m_ui->streetEdit, SIGNAL(textChanged(QString)), this, SLOT(streetTextChanged(QString)) );
	connect( m_ui->suggestionList, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(suggestionClicked(QListWidgetItem*)) );
	connect( m_ui->characterList, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(characterClicked(QListWidgetItem*)) );
	connect( m_ui->resetCity, SIGNAL(clicked()), this, SLOT(resetCity()) );
	connect( m_ui->resetStreet, SIGNAL(clicked()), this, SLOT(resetStreet()) );
}
Пример #3
0
void AddressDialog::resetCity()
{
	m_ui->cityEdit->setEnabled( true );
	m_ui->resetCity->setEnabled( true );
	m_ui->streetEdit->setDisabled( true );
	m_ui->resetStreet->setDisabled( true );
	m_ui->streetEdit->setText( "" );
	m_ui->cityEdit->setText( "" );
	m_mode = City;
	cityTextChanged( "" );
	m_ui->cityEdit->setFocus( Qt::OtherFocusReason );
}