void CompetitorList::setClubId(int id) { m_clubId = id; CompetitorTableModel *model = dynamic_cast<CompetitorTableModel *>(ui->competitorTable->model()); if(!model) { QSortFilterProxyModel* proxyModel = dynamic_cast<QSortFilterProxyModel *>(ui->competitorTable->model()); if(proxyModel) { model = dynamic_cast<CompetitorTableModel*>(proxyModel->sourceModel()); } } if(model) { model->setParentId(id); } ui->competitorTable->reset(); }
CopyInputDialog::CopyInputDialog(QWidget* parent) : QDialog(parent) { setWindowTitle(i18n("Copy Input")); QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel); QWidget *mainWidget = new QWidget(this); QVBoxLayout *mainLayout = new QVBoxLayout; setLayout(mainLayout); mainLayout->addWidget(mainWidget); QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok); okButton->setDefault(true); okButton->setShortcut(Qt::CTRL | Qt::Key_Return); connect(buttonBox, &QDialogButtonBox::accepted, this, &CopyInputDialog::accept); connect(buttonBox, &QDialogButtonBox::rejected, this, &CopyInputDialog::reject); mainLayout->addWidget(buttonBox); setWindowModality(Qt::WindowModal); _ui = new Ui::CopyInputDialog(); _ui->setupUi(mainWidget); connect(_ui->selectAllButton, &QPushButton::clicked, this, &Konsole::CopyInputDialog::selectAll); connect(_ui->deselectAllButton, &QPushButton::clicked, this, &Konsole::CopyInputDialog::deselectAll); _ui->filterEdit->setClearButtonEnabled(true); _ui->filterEdit->setFocus(); _model = new CheckableSessionModel(parent); _model->setCheckColumn(1); _model->setSessions(SessionManager::instance()->sessions()); QSortFilterProxyModel* filterProxyModel = new QSortFilterProxyModel(this); filterProxyModel->setDynamicSortFilter(true); filterProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); filterProxyModel->setSourceModel(_model); filterProxyModel->setFilterKeyColumn(-1); connect(_ui->filterEdit, &QLineEdit::textChanged, filterProxyModel, &QSortFilterProxyModel::setFilterFixedString); _ui->sessionList->setModel(filterProxyModel); _ui->sessionList->setColumnHidden(0, true); // Hide number column _ui->sessionList->header()->hide(); }
CustomFieldsListWidget::CustomFieldsListWidget(QWidget *parent) : QWidget(parent) { QVBoxLayout *topLayout = new QVBoxLayout(this); mCustomFieldList = new QTreeView(this); mCustomFieldList->setObjectName(QStringLiteral("customfieldlist")); mCustomFieldList->setSortingEnabled(true); mCustomFieldList->setRootIsDecorated(false); ContactEditor::CustomFieldsListDelegate *customFieldDelegate = new ContactEditor::CustomFieldsListDelegate(mCustomFieldList, this); mCustomFieldList->setItemDelegate(customFieldDelegate); topLayout->addWidget(mCustomFieldList); mModel = new CustomFieldsModel(this); QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this); proxyModel->setDynamicSortFilter(true); proxyModel->setSourceModel(mModel); mCustomFieldList->setModel(proxyModel); mCustomFieldList->setColumnHidden(2, true); // hide the 'key' column }
void KLinkItemSelectionModelTest::testAdditionalLink() { #if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0) { auto idx = m_mainModel->index(6, 0); m_mainSelectionModel->select(idx, QItemSelectionModel::Select); } QVERIFY(!m_mainSelectionModel->selection().isEmpty()); QVERIFY(!m_subSelectionModel->selection().isEmpty()); QCOMPARE(m_mainSelectionModel->selection().indexes().first().row(), 6); QCOMPARE(m_subSelectionModel->selection().indexes().first().row(), 1); { QSortFilterProxyModel additionalProxy; additionalProxy.setFilterRegExp(QRegExp(QStringLiteral("^[3-9]"))); additionalProxy.setSourceModel(m_mainModel); KLinkItemSelectionModel additionalLink; additionalLink.setModel(&additionalProxy); additionalLink.setLinkedItemSelectionModel(m_mainSelectionModel); QVERIFY(!additionalLink.selection().isEmpty()); QCOMPARE(additionalLink.selection().indexes().first().row(), 3); auto idx = additionalProxy.index(4, 0); QVERIFY(idx.isValid()); additionalLink.select(idx, QItemSelectionModel::ClearAndSelect); QVERIFY(!additionalLink.selection().isEmpty()); QCOMPARE(additionalLink.selection().indexes().first().row(), 4); QVERIFY(!m_mainSelectionModel->selection().isEmpty()); QVERIFY(!m_subSelectionModel->selection().isEmpty()); QCOMPARE(m_mainSelectionModel->selection().indexes().first().row(), 7); QCOMPARE(m_subSelectionModel->selection().indexes().first().row(), 2); } QVERIFY(!m_mainSelectionModel->selection().isEmpty()); QVERIFY(!m_subSelectionModel->selection().isEmpty()); QCOMPARE(m_mainSelectionModel->selection().indexes().first().row(), 7); QCOMPARE(m_subSelectionModel->selection().indexes().first().row(), 2); #endif }
/*! */ void PlayerTypeDialog::createTable() { QVBoxLayout * layout = new QVBoxLayout(); layout->setMargin( 4 ); M_item_view = new QTableView(); //M_item_view->setRootIsDecorated( false ); //M_item_view->setGridStyle( Qt::NoPen ); M_item_view->verticalHeader()->hide(); M_item_view->setShowGrid( false ); M_item_view->setAlternatingRowColors( true ); M_item_view->setSortingEnabled( true ); M_item_view->setEditTriggers( QAbstractItemView::NoEditTriggers ); M_item_view->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); M_item_view->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); M_item_view->horizontalHeader()->setSortIndicatorShown( false ); M_item_view->horizontalHeader()->setResizeMode( QHeaderView::ResizeToContents ); QFont font = M_item_view->font(); font.setPointSize( 10 ); M_item_view->setFont( font ); createModel(); QSortFilterProxyModel * proxy = new PlayerTypeSortProxy( this ); proxy->setSourceModel( M_model ); M_item_view->setModel( proxy ); //std::cerr << "table row count = " << M_model->rowCount() << std::endl; connect( M_item_view, SIGNAL( doubleClicked( const QModelIndex & ) ), this, SLOT( handleDoubleClick( const QModelIndex & ) ) ); layout->addWidget( M_item_view ); this->setLayout( layout ); }
void tst_ModelTest::standardItemModel() { QStandardItemModel model(10,10); QSortFilterProxyModel proxy; ModelTest t1(&model); ModelTest t2(&proxy); proxy.setSourceModel(&model); model.insertRows(2, 5); model.removeRows(4, 5); model.insertColumns(2, 5); model.removeColumns(4, 5); model.insertRows(0,5, model.index(1,1)); model.insertColumns(0,5, model.index(1,3)); }
void ModelDescriptorListWidget::setExperimentType(const QString &experimentType) { //NOTE: QAbstractItemModel::match() seems to search children, we only want root level items searched! QSortFilterProxyModel *proxyModel = qobject_cast<QSortFilterProxyModel *>(QTreeView::model()); if(!experimentType.isEmpty()) { for(int row=0; row < proxyModel->rowCount(QModelIndex()); row++) { QModelIndex index = proxyModel->index(row, 0, QModelIndex()); if(!index.data(Qt::DisplayRole).toString().compare(experimentType, Qt::CaseInsensitive)) { setRootIndex(index); setRootIsDecorated(false); return; } } } setRootIndex(QModelIndex()); setRootIsDecorated(true); expandAll(); }
bool FrmFrameDetails::initModel(const Mode mode, /*const int frameId*/const Sample* sample, const Options options) { if (model!=0) delete model; model = new DragDropModel(this); QObject::connect(model, SIGNAL(ExpandThis(const QModelIndex &)), treeView, SLOT(expand(const QModelIndex &))); //new interface if (modelInterface!=0) delete modelInterface; modelInterface=new ModelInterface(model); QObject::connect(this, SIGNAL(hideFrameDetails(bool)), modelInterface, SLOT(removeFilters())); //fills the actual model if (!setupItems(mode,sample,/*frameId,*/options)) return false; //Using a proxy model for filtering purposes! QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this); proxyModel->setSourceModel(model); treeView->setModel(proxyModel); treeView->setItemDelegate(new QSqlRelationalDelegate(treeView)); for (int col=0; col < treeView->model()->columnCount(); ++col) { if (col!=3) treeView->header()->setResizeMode(col,QHeaderView::ResizeToContents); } treeView->setExpandsOnDoubleClick(true); treeView->expandAll(); //TODO: hide columns: problem - selected indexes in drag and drop //treeView->hideColumn(2); //treeView->hideColumn(4); //treeView->hideColumn(6); //treeView->hideColumn(7); return true; }
void SGGeometryTab::setObjectBaseName(const QString &baseName) { if (m_interface) disconnect(m_interface, 0, m_ui->wireframeWidget, 0); m_model = ObjectBroker::model(baseName + '.' + "sgGeometryModel"); QSortFilterProxyModel *proxy = new QSortFilterProxyModel(this); proxy->setDynamicSortFilter(true); proxy->setSourceModel(m_model); m_ui->tableView->setModel(proxy); QItemSelectionModel *selectionModel = new QItemSelectionModel(proxy); m_ui->tableView->setSelectionModel(selectionModel); m_interface = ObjectBroker::object<SGGeometryExtensionInterface*>(baseName + ".sgGeometry"); m_ui->wireframeWidget->setModel(m_model); m_ui->wireframeWidget->setHighlightModel(selectionModel); connect(m_interface, SIGNAL(geometryChanged(uint,QByteArray,int)), m_ui->wireframeWidget, SLOT(onGeometryChanged(uint, QByteArray,int))); }
void MethodsTab::setObjectBaseName(const QString &baseName) { m_objectBaseName = baseName; QSortFilterProxyModel *proxy = new QSortFilterProxyModel(this); proxy->setDynamicSortFilter(true); proxy->setSourceModel(ObjectBroker::model(baseName + '.' + "methods")); m_ui->methodView->setModel(proxy); m_ui->methodView->sortByColumn(0, Qt::AscendingOrder); m_ui->methodView->setSelectionModel(ObjectBroker::selectionModel(proxy)); m_ui->methodView->header()->setResizeMode(QHeaderView::ResizeToContents); m_ui->methodSearchLine->setProxy(proxy); connect(m_ui->methodView, SIGNAL(doubleClicked(QModelIndex)), SLOT(methodActivated(QModelIndex))); connect(m_ui->methodView, SIGNAL(customContextMenuRequested(QPoint)), SLOT(methodContextMenu(QPoint))); m_ui->methodLog->setModel(ObjectBroker::model(baseName + '.' + "methodLog")); m_interface = ObjectBroker::object<MethodsExtensionInterface*>(baseName + ".methodsExtension"); }
//! [4a] void AddressWidget::editEntry() { QTableView *temp = static_cast<QTableView*>(currentWidget()); QSortFilterProxyModel *proxy = static_cast<QSortFilterProxyModel*>(temp->model()); QItemSelectionModel *selectionModel = temp->selectionModel(); QModelIndexList indexes = selectionModel->selectedRows(); QString name; QString address; int row = -1; foreach (QModelIndex index, indexes) { row = proxy->mapToSource(index).row(); QModelIndex nameIndex = table->index(row, 0, QModelIndex()); QVariant varName = table->data(nameIndex, Qt::DisplayRole); name = varName.toString(); QModelIndex addressIndex = table->index(row, 1, QModelIndex()); QVariant varAddr = table->data(addressIndex, Qt::DisplayRole); address = varAddr.toString(); }
void ContactsTable::onDeleteContact() { //remove selected contacts from inbox model (and database) QSortFilterProxyModel* model = dynamic_cast<QSortFilterProxyModel*>(ui->contact_table->model()); //model->setUpdatesEnabled(false); QItemSelectionModel* selection_model = ui->contact_table->selectionModel(); QModelIndexList sortFilterIndexes = selection_model->selectedRows(); if (sortFilterIndexes.count() == 0) return; if (QMessageBox::question(this, tr("Delete Contact"), tr("Are you sure you want to delete selected contact(s)?")) == QMessageBox::Button::No) return; QModelIndexList indexes; for(const QModelIndex& sortFilterIndex : sortFilterIndexes) indexes.append(model->mapToSource(sortFilterIndex)); qSort(indexes); auto sourceModel = model->sourceModel(); auto app = bts::application::instance(); auto profile = app->get_profile(); for (int i = indexes.count() - 1; i > -1; --i) { auto contact_id = ((AddressBookModel*)sourceModel)->getContact(indexes.at(i)).wallet_index; if(profile->isIdentityPresent(((AddressBookModel*)sourceModel)->getContact(indexes.at(i)).dac_id_string)) { auto priv_key = profile->get_keychain().get_identity_key(((AddressBookModel*)sourceModel)->getContact(indexes.at(i)).dac_id_string); app->remove_receive_key(priv_key); profile->removeIdentity(((AddressBookModel*)sourceModel)->getContact(indexes.at(i)).dac_id_string); /// notify identity observers IdentityObservable::getInstance().notify(); } sourceModel->removeRows(indexes.at(i).row(), 1); Q_EMIT contactDeleted(contact_id); //emit signal so that ContactGui is also deleted } //model->setUpdatesEnabled(true); //TODO Remove fullname/bitname for deleted contacts from QCompleter qSort(sortFilterIndexes); selectNextRow(sortFilterIndexes.takeLast().row(), indexes.count()); }
LogBrowser::LogBrowser(QWidget *parent) : QWidget(parent) , m_nextID(0) , m_actorFilterActive(false) , m_actorFilterCheck(0) { m_log = new LogModel(this); m_log->setResultType(Log::MostRecentSubjects); QSortFilterProxyModel *filter = new QSortFilterProxyModel(this); filter->setSourceModel(m_log); filter->setSortCaseSensitivity(Qt::CaseInsensitive); filter->setDynamicSortFilter(true); filter->setFilterKeyColumn(0); QLineEdit *searchBox = new QLineEdit(this); searchBox->setPlaceholderText(tr("Search")); connect(searchBox, SIGNAL(textEdited(QString)), filter, SLOT(setFilterFixedString(QString))); QListView *view = new QListView(this); view->setResizeMode(QListView::Adjust); connect(view, SIGNAL(activated(QModelIndex)), this, SLOT(handleActivation(QModelIndex))); m_logView = view; m_logView->setModel(filter); QVBoxLayout *layout = new QVBoxLayout(this); m_filterLayout = new QHBoxLayout(this); layout->addWidget(searchBox); layout->addLayout(m_filterLayout); layout->addWidget(m_logView); m_actionMapper = new QSignalMapper(this); connect(m_actionMapper, SIGNAL(mapped(int)), this, SLOT(applyFilter(int))); DataModel::Event emptyEvent; addEventFilter(DataModel::EventList() << emptyEvent, "All")->setChecked(true); }
EngineListView::EngineListView( GLWidget *glWidget, QWidget *parent ) : QListView(parent), d(new EngineListViewPrivate) { d->glWidget = glWidget; EngineItemModel *m = new EngineItemModel(d->glWidget, this); if(model()) { delete model(); } // This should sort the engine names for user views // It should also update dynamically as people edit names // Somehow it doesn't work right from the start! QSortFilterProxyModel *sortModel = new QSortFilterProxyModel(this); sortModel->setSourceModel(m); setModel(sortModel); sortModel->setSortCaseSensitivity(Qt::CaseInsensitive); sortModel->setSortLocaleAware(true); sortModel->setDynamicSortFilter(true); sortModel->sort(0, Qt::AscendingOrder); connect(this, SIGNAL(clicked(QModelIndex)), this, SLOT(selectEngine(QModelIndex))); // This might work for having the proxy model emit the signal, but let's keep it as-is connect(m, SIGNAL(dataChanged(QModelIndex, QModelIndex)), glWidget, SLOT(update())); // improves display performance setUniformItemSizes(true); setAlternatingRowColors(true); // looks better }
RecipientDialog::RecipientDialog(QWidget* parent, QAbstractListModel* model) : QDialog(parent) { setModal( true ); setWindowTitle( i18n("Select Recipient") ); // Add the layout to the widget QVBoxLayout* dialogLayout = new QVBoxLayout(this); // Add the nickname list widget QSortFilterProxyModel *sortModel = new QSortFilterProxyModel(this); sortModel->setSortCaseSensitivity(Preferences::self()->sortCaseInsensitive() ? Qt::CaseInsensitive : Qt::CaseSensitive); sortModel->setSourceModel(model); sortModel->sort(0, Qt::AscendingOrder); QListView* nicknameList = new QListView(this); nicknameList->setUniformItemSizes(true); nicknameList->setModel(sortModel); nicknameInput = new KLineEdit(this); dialogLayout->addWidget(nicknameList); dialogLayout->addWidget(nicknameInput); connect(nicknameList, &QListView::clicked, this, &RecipientDialog::newNicknameSelected); connect(nicknameList, &QListView::doubleClicked, this, &RecipientDialog::newNicknameSelectedQuit); QDialogButtonBox* buttonBox = new QDialogButtonBox(this); dialogLayout->addWidget(buttonBox); QPushButton* button = buttonBox->addButton(QDialogButtonBox::Ok); button->setToolTip(i18n("Select nickname and close the window")); button->setIcon(SmallIcon("dialog-ok")); button->setShortcut(Qt::CTRL | Qt::Key_Return); button->setDefault(true); button = buttonBox->addButton(QDialogButtonBox::Cancel); button->setToolTip(i18n("Close the window without changes")); button->setIcon(SmallIcon("dialog-cancel")); KWindowConfig::restoreWindowSize(windowHandle(), KConfigGroup(KSharedConfig::openConfig(), "DCCRecipientDialog")); connect(buttonBox, &QDialogButtonBox::accepted, this, &RecipientDialog::slotOk); connect(buttonBox, &QDialogButtonBox::rejected, this, &RecipientDialog::slotCancel); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), m_ui(new Ui::MainWindow) { m_ui->setupUi(this); m_undoStack = new QUndoStack(this); m_tableModel = std::make_shared<StatsTableModel>(); QSortFilterProxyModel * proxySort = new QSortFilterProxyModel(); proxySort->setSourceModel(m_tableModel.get()); m_ui->tableData->setAlternatingRowColors(true); m_ui->tableData->setSortingEnabled(true); m_ui->tableData->setModel(proxySort); proxySort->setSortCaseSensitivity(Qt::CaseInsensitive); m_ui->newDocument->setShortcut(QKeySequence(QKeySequence::New)); m_ui->openDocument->setShortcut(QKeySequence(QKeySequence::Open)); m_ui->saveDocument->setShortcut(QKeySequence(QKeySequence::Save)); m_ui->saveDocumentAs->setShortcut(QKeySequence(QKeySequence::SaveAs)); m_ui->actionInsertRow->setShortcut(QKeySequence(QKeySequence(Qt::Key_Insert))); m_ui->actionDeleteRow->setShortcut(QKeySequence(QKeySequence::Delete)); m_undoAction = m_undoStack->createUndoAction(this, tr("&Undo")); m_undoAction->setShortcuts(QKeySequence::Undo); m_redoAction = m_undoStack->createRedoAction(this, tr("&Redo")); m_redoAction->setShortcuts(QKeySequence::Redo); m_ui->menu->addAction(m_undoAction); m_ui->menu->addAction(m_redoAction); connect(m_tableModel.get(), SIGNAL(editRow(int, QString, int)), this, SLOT(onEditRow(int, QString, int))); m_document.reset(new StatsDocument(this, *m_tableModel)); }
MessageHandlerWidget::MessageHandlerWidget(QWidget *parent) : QWidget(parent), ui(new Ui::MessageHandlerWidget) { ObjectBroker::registerClientObjectFactoryCallback<MessageHandlerInterface*>(createClientMessageHandler); MessageHandlerInterface *handler = ObjectBroker::object<MessageHandlerInterface*>(); connect(handler, SIGNAL(fatalMessageReceived(QString,QString,QTime,QStringList)), this, SLOT(fatalMessageReceived(QString,QString,QTime,QStringList))); ui->setupUi(this); QSortFilterProxyModel *proxy = new QSortFilterProxyModel(this); proxy->setSourceModel(ObjectBroker::model("com.kdab.GammaRay.MessageModel")); ui->messageSearchLine->setProxy(proxy); ui->messageView->setModel(proxy); ui->messageView->setIndentation(0); ui->messageView->setSortingEnabled(true); ///FIXME: implement this ui->backtraceView->hide(); }
ClubsEditor::ClubsEditor(QWidget *parent) : QWidget(parent) , ui(new Ui::ClubsEditor) , m_printClubRegAction(0) { ui->setupUi(this); m_printClubRegAction = new QAction("Print Registration...", this); ui->clubList->setModel(new ClubListModel(ui->clubList)); // ui->clubList->setDragEnabled(true); // ui->clubList->setDragDropMode(QAbstractItemView::InternalMove); // ui->clubList->setDropIndicatorShown(true); // ui->clubList->setAcceptDrops(true); // ui->clubList->setSelectionMode(QAbstractItemView::ExtendedSelection); ui->clubList->setContextMenuPolicy(Qt::CustomContextMenu); CompetitorTableModel *sourceModel = new CompetitorTableModel(JMApp()->competitorController(), this); QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this); proxyModel->setSourceModel(sourceModel); ui->competitorsList->tableView()->setSortingEnabled(true); ui->competitorsList->tableView()->setModel(proxyModel); ui->competitorsList->setTableItemDelegate(new CompetitorItemDelegate); ui->competitorsList->setController(JMApp()->competitorController()); connect(ui->addClubBtn, &QPushButton::clicked, this, &ClubsEditor::addClub); connect(ui->removeClubBtn, &QPushButton::clicked, this, &ClubsEditor::removeClub); connect(this, &ClubsEditor::clubAdded, ui->clubEditor, &ClubEditor::editClub); connect(this, &ClubsEditor::clubSelect, ui->clubEditor, &ClubEditor::editClub); connect(ui->clubList->selectionModel(), &QItemSelectionModel::currentChanged, this, &ClubsEditor::clubSelected); connect(JMApp()->clubController(), &ClubController::tournamentChanged, this, &ClubsEditor::tournamentChanged); connect(ui->clubList, &QWidget::customContextMenuRequested, this, &ClubsEditor::clubContextMenu); connect(m_printClubRegAction, &QAction::triggered, this, &ClubsEditor::printClubRegistration); }
std::shared_ptr<const UICommon::GameFile> GameList::GetSelectedGame() const { QAbstractItemView* view; QSortFilterProxyModel* proxy; if (currentWidget() == m_list) { view = m_list; proxy = m_list_proxy; } else { view = m_grid; proxy = m_grid_proxy; } QItemSelectionModel* sel_model = view->selectionModel(); if (sel_model->hasSelection()) { QModelIndex model_index = proxy->mapToSource(sel_model->selectedIndexes()[0]); return m_model->GetGameFile(model_index.row()); } return {}; }
QString GameList::GetSelectedGame() const { QAbstractItemView* view; QSortFilterProxyModel* proxy; if (currentWidget() == m_table) { view = m_table; proxy = m_table_proxy; } else { view = m_list; proxy = m_list_proxy; } QItemSelectionModel* sel_model = view->selectionModel(); if (sel_model->hasSelection()) { QModelIndex model_index = proxy->mapToSource(sel_model->selectedIndexes()[0]); return m_model->GetPath(model_index.row()); } return QStringLiteral(); }
DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false), currentHeaderClicked(-1), searchBox(new QLineEdit(this)) { setUniformRowHeights(true); setItemDelegateForColumn(TreeItemDT::RATING, new StarWidgetsDelegate()); QSortFilterProxyModel *model = new QSortFilterProxyModel(this); model->setSortRole(TreeItemDT::SORT_ROLE); model->setFilterKeyColumn(-1); // filter all columns setModel(model); setSortingEnabled(false); setContextMenuPolicy(Qt::DefaultContextMenu); header()->setContextMenuPolicy(Qt::ActionsContextMenu); QAction *showSearchBox = new QAction(tr("Show Search Box"), this); showSearchBox->setShortcut( Qt::CTRL + Qt::Key_F); showSearchBox->setShortcutContext(Qt::ApplicationShortcut); addAction(showSearchBox); searchBox->installEventFilter(this); searchBox->hide(); connect(showSearchBox, SIGNAL(triggered(bool)), this, SLOT(showSearchEdit())); connect(searchBox, SIGNAL(textChanged(QString)), model, SLOT(setFilterFixedString(QString))); }
IssueSelector::IssueSelector( SimpleRedmineClient* redmine, MainWindow* mainWindow ) : Window( "qrc:/IssueSelector.qml", mainWindow ), redmine_( redmine ) { ENTER(); // Issue selector window initialisation setModality( Qt::ApplicationModal ); setFlags( Qt::Dialog ); setTitle( "Issue Selector" ); // Set the models issuesProxyModel_.setSourceModel( &issuesModel_ ); issuesProxyModel_.setSortRole( IssueModel::IssueRoles::IdRole ); issuesProxyModel_.setDynamicSortFilter( true ); issuesProxyModel_.setFilterCaseSensitivity( Qt::CaseInsensitive ); issuesProxyModel_.setFilterRole( IssueModel::IssueRoles::SubjectRole ); ctx_->setContextProperty( "issuesModel", &issuesProxyModel_ ); QSortFilterProxyModel* projectProxyModel = new QSortFilterProxyModel( this ); projectProxyModel->setSourceModel( &projectModel_ ); projectProxyModel->setSortRole( SimpleModel::SimpleRoles::IdRole ); projectProxyModel->setDynamicSortFilter( true ); ctx_->setContextProperty( "projectModel", projectProxyModel ); // Connect the project selected signal to the projectSelected slot connect( qml("project"), SIGNAL(activated(int)), this, SLOT(projectSelected(int)) ); // Connect the issue selected signal to the issueSelected slot connect( qml("issues"), SIGNAL(activated(int)), this, SLOT(issueSelected(int)) ); // Connect the search accepted signal to the filterIssues slot connect( qml("search"), SIGNAL(textChanged()), this, SLOT(filterIssues()) ); // Connect the closed signal to the close slot connect( this, &Window::closed, [=](){ close(); } ); RETURN(); }
QmitkModulesDialog::QmitkModulesDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f) { this->setWindowTitle("MITK Modules"); QVBoxLayout* layout = new QVBoxLayout(); this->setLayout(layout); QTableView* tableView = new QTableView(this); QmitkModuleTableModel* tableModel = new QmitkModuleTableModel(tableView); QSortFilterProxyModel* sortProxyModel = new QSortFilterProxyModel(tableView); sortProxyModel->setSourceModel(tableModel); sortProxyModel->setDynamicSortFilter(true); tableView->setModel(sortProxyModel); tableView->verticalHeader()->hide(); tableView->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); tableView->setSelectionBehavior(QAbstractItemView::SelectRows); tableView->setSelectionMode(QAbstractItemView::ExtendedSelection); tableView->setTextElideMode(Qt::ElideMiddle); tableView->setSortingEnabled(true); tableView->sortByColumn(0, Qt::AscendingOrder); tableView->horizontalHeader()->setResizeMode(0, QHeaderView::ResizeToContents); tableView->horizontalHeader()->setResizeMode(2, QHeaderView::ResizeToContents); tableView->horizontalHeader()->setResizeMode(5, QHeaderView::ResizeToContents); tableView->horizontalHeader()->setStretchLastSection(true); tableView->horizontalHeader()->setCascadingSectionResizes(true); layout->addWidget(tableView); QDialogButtonBox* btnBox = new QDialogButtonBox(QDialogButtonBox::Close); layout->addWidget(btnBox); this->resize(800, 600); connect(btnBox, SIGNAL(rejected()), this, SLOT(reject())); }
void MethodsTab::setObjectBaseName(const QString &baseName) { m_objectBaseName = baseName; QSortFilterProxyModel *proxy = new QSortFilterProxyModel(this); proxy->setDynamicSortFilter(true); proxy->setSourceModel(ObjectBroker::model(baseName + '.' + "methods")); proxy->setSortCaseSensitivity(Qt::CaseInsensitive); proxy->setSortRole(ObjectMethodModelRole::MethodSignature); m_ui->methodView->setModel(proxy); m_ui->methodView->sortByColumn(0, Qt::AscendingOrder); m_ui->methodView->setSelectionModel(ObjectBroker::selectionModel(proxy)); m_ui->methodView->header()->setResizeMode(QHeaderView::ResizeToContents); new SearchLineController(m_ui->methodSearchLine, proxy); connect(m_ui->methodView, SIGNAL(doubleClicked(QModelIndex)), SLOT(methodActivated(QModelIndex))); connect(m_ui->methodView, SIGNAL(customContextMenuRequested(QPoint)), SLOT(methodContextMenu(QPoint))); m_ui->methodLog->setModel(ObjectBroker::model(baseName + '.' + "methodLog")); m_interface = ObjectBroker::object<MethodsExtensionInterface*>(baseName + ".methodsExtension"); new PropertyBinder(m_interface, "hasObject", m_ui->methodLog, "visible"); }
void UBFeaturesWidget::deleteElements( const QMimeData & mimeData ) { if ( !mimeData.hasUrls() ) return; QList<QUrl> urls = mimeData.urls(); foreach ( QUrl url, urls ) { if ( controller->isTrash( url ) ) { controller->deleteItem( url ); } else { UBFeature elem = controller->moveItemToFolder( url, controller->getTrashElement() ); controller->removeFromFavorite( url ); featuresModel->addItem( elem ); featuresModel->deleteFavoriteItem( UBFeaturesController::fileNameFromUrl( url ) ); } } QSortFilterProxyModel *model = dynamic_cast<QSortFilterProxyModel *>( featuresListView->model() ); model->invalidate(); }
/*! */ void PlayerTypeDialog::createTable() { QVBoxLayout * layout = new QVBoxLayout(); layout->setMargin( 4 ); M_item_view = new QTableView(); //M_item_view->setRootIsDecorated( false ); //M_item_view->setGridStyle( Qt::NoPen ); M_item_view->verticalHeader()->hide(); M_item_view->setShowGrid( false ); M_item_view->setAlternatingRowColors( true ); #if QT_VERSION >= 0x040200 M_item_view->setSortingEnabled( true ); #endif M_item_view->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); M_item_view->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff ); M_item_view->horizontalHeader()->setResizeMode( QHeaderView::ResizeToContents ); QFont font = M_item_view->font(); font.setPointSize( 9 ); M_item_view->setFont( font ); createModel(); QSortFilterProxyModel * proxy = new PlayerTypeSortProxy( this ); proxy->setSourceModel( M_model ); M_item_view->setModel( proxy ); //std::cerr << "table row count = " << M_model->rowCount() << std::endl; layout->addWidget( M_item_view ); this->setLayout( layout ); }
void NewDatasetController::slotGroupSelected(const QModelIndex &index) { NewDatasetView *newDatasetView = qobject_cast<NewDatasetView*>(view); if(group.isEmpty() || group!=newDatasetView->getGroupsTable()->model()->index(index.row(), 0 ,index).data().toString()) { newDatasetView->resetInfo(); group = newDatasetView->getGroupsTable()->model()->index(index.row(), 0 ,index).data().toString(); QString type = newDatasetView->getGroupsTable()->model()->index(index.row(), 1 ,index).data().toString(); GroupDAO *db = new GroupDAO(); GroupOfSubject* groupItem = db->getGroupByName(group); QVector<ASubject*> subjects = groupItem->getAllSubjects(); QString txt = "Subjects in the Group "+group+" ("+QString::number(subjects.size())+"):\n"; for(int i=0; i<subjects.size(); ++i) { txt.append(subjects.at(i)->getName()+"\n"); } newDatasetView->setGroupInfo(txt); QSortFilterProxyModel *proxyModel = qobject_cast<QSortFilterProxyModel*>(newDatasetView->getProtocolsTable()->model()); DatasetProtocolTableModel *model = qobject_cast<DatasetProtocolTableModel*>(proxyModel->sourceModel()); model->loadModelData(type); } }
ConnectionsTab::ConnectionsTab(PropertyWidget* parent): QWidget(parent), ui(new Ui::ConnectionsTab) { m_interface = ObjectBroker::object<ConnectionsExtensionInterface*>(parent->objectBaseName() + ".connectionsExtension"); ui->setupUi(this); QSortFilterProxyModel *proxy = new ConnectionsClientProxyModel(this); proxy->setDynamicSortFilter(true); proxy->setSourceModel(ObjectBroker::model(parent->objectBaseName() + ".inboundConnections")); ui->inboundView->setModel(proxy); ui->inboundView->sortByColumn(0, Qt::AscendingOrder); ui->inboundSearchLine->setProxy(proxy); connect(ui->inboundView, SIGNAL(customContextMenuRequested(QPoint)), SLOT(inboundContextMenu(QPoint))); proxy = new ConnectionsClientProxyModel(this); proxy->setDynamicSortFilter(true); proxy->setSourceModel(ObjectBroker::model(parent->objectBaseName() + ".outboundConnections")); ui->outboundView->setModel(proxy); ui->outboundView->sortByColumn(0, Qt::AscendingOrder); ui->outboundSearchLine->setProxy(proxy); connect(ui->outboundView, SIGNAL(customContextMenuRequested(QPoint)), SLOT(outboundContextMenu(QPoint))); }
LocaleInspectorWidget::LocaleInspectorWidget(QWidget *parent) : QWidget(parent), ui(new Ui::LocaleInspectorWidget) { QAbstractItemModel *localeModel = ObjectBroker::model(QStringLiteral("com.kdab.GammaRay.LocaleModel")); QAbstractItemModel *accessorModel = ObjectBroker::model(QStringLiteral("com.kdab.GammaRay.LocaleAccessorModel")); QSortFilterProxyModel *proxy = new QSortFilterProxyModel(this); proxy->setSourceModel(localeModel); ui->setupUi(this); ui->localeTable->setModel(proxy); ui->accessorTable->setModel(accessorModel); ui->localeSearchLine->setProxy(proxy); ui->accessorTable->resizeColumnsToContents(); ui->localeTable->resizeColumnsToContents(); connect(localeModel, SIGNAL(modelReset()), ui->localeTable, SLOT(resizeColumnsToContents())); connect(accessorModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), ui->accessorTable, SLOT(resizeColumnsToContents())); QMetaObject::invokeMethod(this, "initSplitterPosition", Qt::QueuedConnection); connect(accessorModel, SIGNAL(rowsInserted(QModelIndex,int,int)), SLOT(initSplitterPosition())); }
void SettingsDialog::initLangs() { QString datapath = lnPrefix->text(); datapath += "tessdata"; TessTools tt; QList<QString> languages = tt.getLanguages(datapath); // Clean combobox with languages int langsCount = cbLang->count(); if (langsCount > 0) for (int i = langsCount; i >= 0; i--) { cbLang->removeItem(0); } QString lang; foreach(lang, languages) if (getLangName(lang) == "") cbLang->addItem(lang, lang); else cbLang->addItem(getLangName(lang), lang); // sort language list QSortFilterProxyModel* proxy = new QSortFilterProxyModel(cbLang); proxy->setSourceModel(cbLang->model()); cbLang->model()->setParent(proxy); cbLang->setModel(proxy); cbLang->model()->sort(0); cbLang->setCurrentIndex(1); // do not show empty combobox if there is lang QSettings settings(QSettings::IniFormat, QSettings::UserScope, SETTING_ORGANIZATION, SETTING_APPLICATION); if (settings.contains("Tesseract/Lang")) { int langindex = cbLang->findData( settings.value("Tesseract/Lang").toString()); cbLang->setCurrentIndex(langindex); } }