void AddressBookPage::setModel(AddressTableModel *_model) { this->model = _model; if(!_model) return; auto type = tab == ReceivingTab ? AddressTableModel::Receive : AddressTableModel::Send; proxyModel = new AddressBookSortFilterProxyModel(type, this); proxyModel->setSourceModel(_model); connect(ui->searchLineEdit, SIGNAL(textChanged(QString)), proxyModel, SLOT(setFilterWildcard(QString))); ui->tableView->setModel(proxyModel); ui->tableView->sortByColumn(0, Qt::AscendingOrder); // Set column widths #if QT_VERSION < 0x050000 ui->tableView->horizontalHeader()->setResizeMode(AddressTableModel::Label, QHeaderView::Stretch); ui->tableView->horizontalHeader()->setResizeMode(AddressTableModel::Address, QHeaderView::ResizeToContents); #else ui->tableView->horizontalHeader()->setSectionResizeMode(AddressTableModel::Label, QHeaderView::Stretch); ui->tableView->horizontalHeader()->setSectionResizeMode(AddressTableModel::Address, QHeaderView::ResizeToContents); #endif connect(ui->tableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(selectionChanged())); // Select row for newly created address connect(_model, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(selectNewAddress(QModelIndex,int,int))); selectionChanged(); }
BE::Contacts::Contacts(AbookAddressbook *abook): m_abook(abook), m_dirty(false) { m_currentContact = 0; QImage img(QDir::homePath() + QLatin1String("/.abook/incognito.png")); if (!img.isNull()) m_incognitoPic = QPixmap::fromImage(img.scaled(160,160,Qt::KeepAspectRatio,Qt::SmoothTransformation)); m_ui = new Ui::Contacts; m_ui->setupUi(this); #if QT_VERSION >= 0x040700 m_ui->filter->setPlaceholderText(tr("Filter")); #endif m_ui2 = new Ui::OneContact; m_ui2->setupUi(m_ui->oneContact); fields << Field(AbookAddressbook::Name, m_ui2->name, QLatin1String("name")) << Field(AbookAddressbook::Mail, m_ui2->mail, QLatin1String("email")) << Field(AbookAddressbook::Address, m_ui2->address, QLatin1String("address")) << Field(AbookAddressbook::City, m_ui2->city, QLatin1String("city")) << Field(AbookAddressbook::State, m_ui2->state, QLatin1String("state")) << Field(AbookAddressbook::ZIP, m_ui2->zip, QLatin1String("zip")) << Field(AbookAddressbook::Country, m_ui2->country, QLatin1String("country")) << Field(AbookAddressbook::Phone, m_ui2->phone, QLatin1String("phone")) << Field(AbookAddressbook::Workphone, m_ui2->workphone, QLatin1String("workphone")) << Field(AbookAddressbook::Fax, m_ui2->fax, QLatin1String("fax")) << Field(AbookAddressbook::Mobile, m_ui2->mobile, QLatin1String("mobile")) << Field(AbookAddressbook::Nick, m_ui2->nick, QLatin1String("nick")) << Field(AbookAddressbook::URL, m_ui2->url, QLatin1String("url")) << Field(AbookAddressbook::Notes, m_ui2->notes, QLatin1String("notes")) << Field(AbookAddressbook::Anniversary, m_ui2->anniversary, QLatin1String("anniversary")) << Field(AbookAddressbook::Photo, m_ui2->photo, QLatin1String("photo")); m_sortFilterProxy = new QSortFilterProxyModel(this); m_sortFilterProxy->setFilterCaseSensitivity(Qt::CaseInsensitive); m_sortFilterProxy->setFilterKeyColumn(-1); m_sortFilterProxy->setSourceModel(m_abook->model()); connect (m_ui->filter, SIGNAL(textChanged(QString)), m_sortFilterProxy, SLOT(setFilterWildcard(QString))); m_ui->filter->installEventFilter(this); QFont fnt = m_ui2->name->font(); fnt.setPointSize(fnt.pointSize()*2); m_ui2->name->setFont(fnt); for (QList<Field>::const_iterator it = fields.constBegin(), end = fields.constEnd(); it != end; ++it) { it->label->installEventFilter(this); } m_ui->contacts->setModel(m_sortFilterProxy); m_ui->contacts->setSelectionMode(QAbstractItemView::SingleSelection); connect (m_ui->contacts->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), SLOT(setContact(QModelIndex))); QModelIndex idx = m_sortFilterProxy->index(0,0); if (idx.isValid()) m_ui->contacts->setCurrentIndex(idx); m_ui->contacts->installEventFilter(this); connect (m_ui->add, SIGNAL(clicked()), SLOT(addContact())); connect (m_ui->remove, SIGNAL(clicked()), SLOT(removeCurrentContact())); connect (qApp, SIGNAL(focusChanged(QWidget*, QWidget*)), SLOT(updateFocusPolicy(QWidget*, QWidget*))); // cheat to correct the focuspolicies ;-) updateFocusPolicy(m_ui2->name, m_ui->filter); Q_FOREACH(const Field &field, fields) { if (QTextDocument *doc = field.label->findChild<QTextDocument*>()) connect(doc, SIGNAL(contentsChanged()), SLOT(updateLabel())); } }
// ------------------------------------------------------------------------------ int ctkSearchBoxTest2(int argc, char* argv[]) { QApplication app(argc, argv); QStringList stringList; stringList<<"totoa"<<"TOTOaa"<<"tic"<<"tac"<<"nice"<<"slicer"<<"monday"<<"july"<<"phone"; ctkSearchBox search3; search3.show(); search3.setText("phone"); QRegExp regExp(search3.text(),Qt::CaseInsensitive, QRegExp::Wildcard); //QStringList testFilter = stringList.filter(search3.text()); QStringList testFilter = stringList.filter(regExp); qDebug() << "Result of Test Filter : " << testFilter; if (testFilter.size() >= stringList.size()) { qDebug() << "Line : " << __LINE__<< " error with the filter : " << search3.text(); } QStringListModel listModel(stringList); QSortFilterProxyModel filterModel; filterModel.setSourceModel(&listModel); filterModel.setFilterCaseSensitivity(Qt::CaseInsensitive); filterModel.setFilterWildcard(search3.text()); QObject::connect(&search3, SIGNAL(textChanged(QString)), &filterModel, SLOT(setFilterWildcard(QString))); QListView listView; listView.setModel(&filterModel); listView.show(); if (argc < 2 || QString(argv[1]) != "-I" ) { QTimer::singleShot(200, &app, SLOT(quit())); } return app.exec(); }
QT_END_NAMESPACE Priorities::Priorities(QWidget *parent /* = 0 */): DictionaryTemplate(parent) , actualRecords(true) { m_model = new QStandardItemModel(this); m_proxymodel = new QSortFilterProxyModel(this); m_proxymodel->setSourceModel(m_model); m_proxymodel->setFilterKeyColumn(1); m_proxymodel->setFilterCaseSensitivity(Qt::CaseInsensitive); m_selectionModel = new QItemSelectionModel(m_proxymodel); treeView->setRootIsDecorated(false); treeView->setAlternatingRowColors(true); treeView->setModel(m_proxymodel); treeView->setSelectionModel(m_selectionModel); ui->m_lblCurrentUser->setText(QString("Пользователь: <b><u>" + currentUser() + "</u></b>")); dictionaryDialog->ui->comboBoxIcon->addItem(QIcon("data/picture/additionally/red.ico"), "Высокий"); dictionaryDialog->ui->comboBoxIcon->addItem(QIcon("data/picture/additionally/yellow.ico"), "Средний"); dictionaryDialog->ui->comboBoxIcon->addItem(QIcon("data/picture/additionally/green.ico"), "Низкий"); connect(this, SIGNAL(pushSelectRecordData()), SLOT(slotPushSelectRecordData())); connect(lineEditSearchToItem, SIGNAL(textEdited(QString)), m_proxymodel, SLOT(setFilterWildcard(QString))); connect(getClearButton(), SIGNAL(clicked()), SLOT(slotClearSearchToItem())); connect(dictionaryDialog, SIGNAL(saveDataChanged()), this, SLOT(slotInsertOrUpdateRecords())); connect(m_selectionModel, SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), this, SLOT(slotDataChanged(QModelIndex))); connect(treeView, SIGNAL(clicked(QModelIndex)), this, SLOT(slotDataChanged(QModelIndex))); connect(this, SIGNAL(selectionModelIndex(QModelIndex)), SLOT(slotGetSelectionModel(QModelIndex))); slotSelectRecords(actualRecords); }
CDialogIrcSettings::CDialogIrcSettings( QWidget* parent ) : QDialog( parent ), ui( new Ui::CDialogIrcSettings ) { ui->setupUi( this ); setWindowFilePath( tr( "Settings" ) ); //TODO: ui->treeWidgetColors->setItemDelegate(new ColorItemDelegate(ui->treeWidgetColors)); ui->treeWidgetShortcuts->setItemDelegate( new ShortcutItemDelegate( ui->treeWidgetShortcuts ) ); //TODO: ui->treeWidgetColors->header()->setSectionResizeMode(ColorColumns::Message, QHeaderView::ResizeToContents); ui->treeWidgetShortcuts->header()->setSectionResizeMode( ShortcutColumns::Description, QHeaderView::ResizeToContents ); ui->treeWidgetShortcuts->expandItem( ui->treeWidgetShortcuts->topLevelItem( 0 ) ); ui->treeWidgetShortcuts->expandItem( ui->treeWidgetShortcuts->topLevelItem( 1 ) ); proxyModel = new SortFilterProxyModel( ui->treeViewAliases ); sourceModel = new QStandardItemModel( proxyModel ); proxyModel->setSourceModel( sourceModel ); ui->treeViewAliases->setModel( proxyModel ); ui->treeViewAliases->setItemDelegateForColumn( 2, new CloseDelegate( ui->treeViewAliases ) ); loadSettings(); connect( ui->checkBoxConnectOnStartup, SIGNAL( toggled( bool ) ), this, SLOT( enableApply() ) ); connect( ui->fontComboBox, SIGNAL( currentFontChanged( QFont ) ), this, SLOT( enableApply() ) ); connect( ui->spinBoxFontSize, SIGNAL( valueChanged( int ) ), this, SLOT( enableApply() ) ); connect( ui->checkBoxStripNicks, SIGNAL( toggled( bool ) ), this, SLOT( enableApply() ) ); connect( ui->checkBoxHighlightSounds, SIGNAL( toggled( bool ) ), this, SLOT( enableApply() ) ); connect( ui->checkBoxTimeStamp, SIGNAL( toggled( bool ) ), this, SLOT( enableApply() ) ); connect( ui->checkBoxDarkTheme, SIGNAL( toggled( bool ) ), this, SLOT( enableApply() ) ); connect( ui->spinBoxBlockCount, SIGNAL( valueChanged( int ) ), this, SLOT( enableApply() ) ); //TODO: connect(ui->treeWidgetColors, SIGNAL(clicked(QModelIndex)), this, SLOT(enableApply())); connect( ui->treeWidgetShortcuts, SIGNAL( clicked( QModelIndex ) ), this, SLOT( enableApply() ) ); connect( ui->toolButtonAddAliases, SIGNAL( clicked() ), this, SLOT( addAlias() ) ); connect( ui->treeViewAliases, SIGNAL( clicked( QModelIndex ) ), this, SLOT( onAliasClicked( QModelIndex ) ) ); connect( ui->treeViewAliases, SIGNAL( activated( QModelIndex ) ), this, SLOT( enableApply() ) ); connect( ui->lineEditAliasesFilter, SIGNAL( textEdited( QString ) ), proxyModel, SLOT( setFilterWildcard( QString ) ) ); connect( ui->pushButtonApply, SIGNAL( clicked() ), this, SLOT( saveSettings() ) ); ui->pushButtonApply->setEnabled( false ); }
// Initialize the dialog widgets and connect the signals/slots void SatellitesDialog::createDialogContent() { ui->setupUi(dialog); ui->tabs->setCurrentIndex(0); connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate())); // Settings tab / updates group connect(ui->internetUpdatesCheckbox, SIGNAL(stateChanged(int)), this, SLOT(setUpdatesEnabled(int))); connect(ui->updateButton, SIGNAL(clicked()), this, SLOT(updateTLEs())); connect(GETSTELMODULE(Satellites), SIGNAL(updateStateChanged(Satellites::UpdateState)), this, SLOT(updateStateReceiver(Satellites::UpdateState))); connect(GETSTELMODULE(Satellites), SIGNAL(tleUpdateComplete(int, int, int)), this, SLOT(updateCompleteReceiver(int, int, int))); connect(ui->updateFrequencySpinBox, SIGNAL(valueChanged(int)), this, SLOT(setUpdateValues(int))); refreshUpdateValues(); // fetch values for last updated and so on // if the state didn't change, setUpdatesEnabled will not be called, so we force it setUpdatesEnabled(ui->internetUpdatesCheckbox->checkState()); updateTimer = new QTimer(this); connect(updateTimer, SIGNAL(timeout()), this, SLOT(refreshUpdateValues())); updateTimer->start(7000); connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())); // Settings tab / General settings group connect(ui->labelsGroup, SIGNAL(toggled(bool)), dynamic_cast<StelGui*>(StelApp::getInstance().getGui())->getGuiAction("actionShow_Satellite_Labels"), SLOT(setChecked(bool))); connect(ui->fontSizeSpinBox, SIGNAL(valueChanged(int)), GETSTELMODULE(Satellites), SLOT(setLabelFontSize(int))); connect(ui->restoreDefaultsButton, SIGNAL(clicked()), this, SLOT(restoreDefaults())); connect(ui->saveSettingsButton, SIGNAL(clicked()), this, SLOT(saveSettings())); // Settings tab / orbit lines group ui->orbitLinesGroup->setChecked(GETSTELMODULE(Satellites)->getOrbitLinesFlag()); ui->orbitSegmentsSpin->setValue(Satellite::orbitLineSegments); ui->orbitFadeSpin->setValue(Satellite::orbitLineFadeSegments); ui->orbitDurationSpin->setValue(Satellite::orbitLineSegmentDuration); connect(ui->orbitLinesGroup, SIGNAL(toggled(bool)), GETSTELMODULE(Satellites), SLOT(setOrbitLinesFlag(bool))); connect(ui->orbitSegmentsSpin, SIGNAL(valueChanged(int)), this, SLOT(setOrbitParams())); connect(ui->orbitFadeSpin, SIGNAL(valueChanged(int)), this, SLOT(setOrbitParams())); connect(ui->orbitDurationSpin, SIGNAL(valueChanged(int)), this, SLOT(setOrbitParams())); // Satellites tab filterProxyModel = new QSortFilterProxyModel(this); filterProxyModel->setSourceModel(satellitesModel); filterProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); ui->satellitesList->setModel(filterProxyModel); connect(ui->lineEditSearch, SIGNAL(textEdited(QString)), filterProxyModel, SLOT(setFilterWildcard(QString))); QItemSelectionModel* selectionModel = ui->satellitesList->selectionModel(); connect(selectionModel, SIGNAL(currentRowChanged(QModelIndex,QModelIndex)), this, SLOT(updateSelectedInfo(QModelIndex,QModelIndex))); connect(ui->satellitesList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(handleDoubleClick(QModelIndex))); connect(ui->groupsCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(listSatelliteGroup(int))); connect(ui->saveSatellitesButton, SIGNAL(clicked()), this, SLOT(saveSatellites())); connect(ui->removeSatellitesButton, SIGNAL(clicked()), this, SLOT(removeSatellites())); connectSatelliteGuiForm(); importWindow = new SatellitesImportDialog(); connect(ui->addSatellitesButton, SIGNAL(clicked()), importWindow, SLOT(setVisible())); connect(importWindow, SIGNAL(satellitesAccepted(TleDataList)), this, SLOT(addSatellites(TleDataList))); // Sources tab connect(ui->sourceList, SIGNAL(currentTextChanged(const QString&)), ui->sourceEdit, SLOT(setText(const QString&))); connect(ui->sourceEdit, SIGNAL(editingFinished()), this, SLOT(sourceEditingDone())); connect(ui->deleteSourceButton, SIGNAL(clicked()), this, SLOT(deleteSourceRow())); connect(ui->addSourceButton, SIGNAL(clicked()), this, SLOT(addSourceRow())); // About tab setAboutHtml(); updateGuiFromSettings(); }
// Initialize the dialog widgets and connect the signals/slots void SatellitesDialog::createDialogContent() { ui->setupUi(dialog); ui->tabs->setCurrentIndex(0); ui->labelAutoAdd->setVisible(false); connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())); connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate())); Satellites* plugin = GETSTELMODULE(Satellites); // Settings tab / updates group // These controls are refreshed by updateSettingsPage(), which in // turn is triggered by setting any of these values. Because // clicked() is issued only by user input, there's no endless loop. connect(ui->internetUpdatesCheckbox, SIGNAL(clicked(bool)), plugin, SLOT(enableInternetUpdates(bool))); connect(ui->checkBoxAutoAdd, SIGNAL(clicked(bool)), plugin, SLOT(enableAutoAdd(bool))); connect(ui->checkBoxAutoRemove, SIGNAL(clicked(bool)), plugin, SLOT(enableAutoRemove(bool))); connect(ui->updateFrequencySpinBox, SIGNAL(valueChanged(int)), plugin, SLOT(setUpdateFrequencyHours(int))); connect(ui->updateButton, SIGNAL(clicked()), this, SLOT(updateTLEs())); connect(ui->jumpToSourcesButton, SIGNAL(clicked()), this, SLOT(jumpToSourcesTab())); connect(plugin, SIGNAL(updateStateChanged(Satellites::UpdateState)), this, SLOT(showUpdateState(Satellites::UpdateState))); connect(plugin, SIGNAL(tleUpdateComplete(int, int, int, int)), this, SLOT(showUpdateCompleted(int, int, int, int))); updateTimer = new QTimer(this); connect(updateTimer, SIGNAL(timeout()), this, SLOT(updateCountdown())); updateTimer->start(7000); // Settings tab / General settings group // This does call Satellites::setFlagLabels() indirectly. QAction* action = dynamic_cast<StelGui*>(StelApp::getInstance().getGui())->getGuiAction("actionShow_Satellite_Labels"); connect(ui->labelsGroup, SIGNAL(clicked(bool)), action, SLOT(setChecked(bool))); connect(ui->fontSizeSpinBox, SIGNAL(valueChanged(int)), plugin, SLOT(setLabelFontSize(int))); connect(ui->restoreDefaultsButton, SIGNAL(clicked()), this, SLOT(restoreDefaults())); connect(ui->saveSettingsButton, SIGNAL(clicked()), this, SLOT(saveSettings())); // Settings tab / orbit lines group connect(ui->orbitLinesGroup, SIGNAL(clicked(bool)), plugin, SLOT(setOrbitLinesFlag(bool))); connect(ui->orbitSegmentsSpin, SIGNAL(valueChanged(int)), this, SLOT(setOrbitParams())); connect(ui->orbitFadeSpin, SIGNAL(valueChanged(int)), this, SLOT(setOrbitParams())); connect(ui->orbitDurationSpin, SIGNAL(valueChanged(int)), this, SLOT(setOrbitParams())); // Settings tab - populate all values updateSettingsPage(); // Satellites tab filterModel = new SatellitesListFilterModel(this); filterModel->setSourceModel(GETSTELMODULE(Satellites)->getSatellitesListModel()); filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive); ui->satellitesList->setModel(filterModel); connect(ui->lineEditSearch, SIGNAL(textEdited(QString)), filterModel, SLOT(setFilterWildcard(QString))); QItemSelectionModel* selectionModel = ui->satellitesList->selectionModel(); connect(selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(updateSatelliteData())); connect(ui->satellitesList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(trackSatellite(QModelIndex))); // Two-state input, three-state display connect(ui->displayedCheckbox, SIGNAL(clicked(bool)), ui->displayedCheckbox, SLOT(setChecked(bool))); connect(ui->orbitCheckbox, SIGNAL(clicked(bool)), ui->orbitCheckbox, SLOT(setChecked(bool))); connect(ui->userCheckBox, SIGNAL(clicked(bool)), ui->userCheckBox, SLOT(setChecked(bool))); // Because the previous signals and slots were connected first, // they will be executed before these. connect(ui->displayedCheckbox, SIGNAL(clicked()), this, SLOT(setFlags())); connect(ui->orbitCheckbox, SIGNAL(clicked()), this, SLOT(setFlags())); connect(ui->userCheckBox, SIGNAL(clicked()), this, SLOT(setFlags())); connect(ui->groupsListWidget, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(handleGroupChanges(QListWidgetItem*))); connect(ui->groupFilterCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(filterListByGroup(int))); connect(ui->saveSatellitesButton, SIGNAL(clicked()), this, SLOT(saveSatellites())); connect(ui->removeSatellitesButton, SIGNAL(clicked()), this, SLOT(removeSatellites())); importWindow = new SatellitesImportDialog(); connect(ui->addSatellitesButton, SIGNAL(clicked()), importWindow, SLOT(setVisible())); connect(importWindow, SIGNAL(satellitesAccepted(TleDataList)), this, SLOT(addSatellites(TleDataList))); // Sources tab connect(ui->sourceList, SIGNAL(currentTextChanged(const QString&)), ui->sourceEdit, SLOT(setText(const QString&))); connect(ui->sourceList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(saveSourceList())); connect(ui->sourceEdit, SIGNAL(editingFinished()), this, SLOT(saveEditedSource())); connect(ui->deleteSourceButton, SIGNAL(clicked()), this, SLOT(deleteSourceRow())); connect(ui->addSourceButton, SIGNAL(clicked()), this, SLOT(addSourceRow())); connect(plugin, SIGNAL(settingsChanged()), this, SLOT(toggleCheckableSources())); // About tab populateAboutPage(); populateFilterMenu(); populateSourcesList(); }
void StringFilterModel::setFilter(const QString& filter) { setFilterWildcard("*" + filter + "*"); }