void MList::setItemModel(QAbstractItemModel *itemModel) { Q_D(MList); if (d->listFilter && d->listFilter->enabled()) itemModel = d->listFilter->updateItemModel(itemModel); setSelectionModel(NULL); if (itemModel) setSelectionModel(new QItemSelectionModel(itemModel)); model()->setItemModel(itemModel); }
configTreeView::configTreeView(DomCfgItem *config,QWidget *parent):QTreeView(parent) { QAbstractItemModel *data = new ananasListViewModel(config,parent); QItemSelectionModel *selections = new QItemSelectionModel(data); m_tabEditors=0; //QTreeView *mdtree = new QTreeView; setModel(data); setHeaderHidden(true); setSelectionModel(selections); setUniformRowHeights(true); header()->setStretchLastSection(false); viewport()->setAttribute(Qt::WA_StaticContents); header()->setResizeMode(QHeaderView::Stretch); setAttribute(Qt::WA_MacShowFocusRect, false); setContextMenuPolicy(Qt::CustomContextMenu); setWindowFlags(Qt::Widget); connect(this, SIGNAL( customContextMenuRequested(const QPoint &) ), this,SLOT(showmenu(const QPoint &))); connect(this,SIGNAL(doubleClicked ( const QModelIndex & )),this,SLOT(doubleClicked ( const QModelIndex & ))); m_tabStopWidth = 4; m_lineNumbers = m_selectionBorder = m_autoIndent = m_cppHighlighter = true; crossButton = 0; menuBookmarks=((MainForm*)parent->parentWidget())->menuBookmarks; actionActiveBookmark=menuBookmarks->activeAction(); //setCrossButton( !m_closeButtonInTabs ); //connect(actionOptions, SIGNAL(triggered()), this, SLOT(slotOptions())); loadINI(); }
void QgsAttributeTableView::setModel( QgsAttributeTableFilterModel* filterModel ) { if ( mFilterModel ) { // Cleanup old model stuff if present disconnect( mFilterModel, SIGNAL( filterAboutToBeInvalidated() ), this, SLOT( onFilterAboutToBeInvalidated() ) ); disconnect( mFilterModel, SIGNAL( filterInvalidated() ), this, SLOT( onFilterInvalidated() ) ); } mFilterModel = filterModel; QTableView::setModel( filterModel ); connect( mFilterModel, SIGNAL( destroyed() ), this, SLOT( modelDeleted() ) ); delete mFeatureSelectionModel; mFeatureSelectionModel = 0; if ( filterModel ) { if ( !mFeatureSelectionManager ) { mFeatureSelectionManager = new QgsVectorLayerSelectionManager( mFilterModel->layer(), mFilterModel ); } mFeatureSelectionModel = new QgsFeatureSelectionModel( mFilterModel, mFilterModel, mFeatureSelectionManager, mFilterModel ); setSelectionModel( mFeatureSelectionModel ); mTableDelegate->setFeatureSelectionModel( mFeatureSelectionModel ); connect( mFeatureSelectionModel, SIGNAL( requestRepaint( QModelIndexList ) ), this, SLOT( repaintRequested( QModelIndexList ) ) ); connect( mFeatureSelectionModel, SIGNAL( requestRepaint() ), this, SLOT( repaintRequested() ) ); } }
/** * @brief Sets the dialogs to represent in this view. * @param model The dialogs model. */ void DialogsTreeView::set_model(DialogsModel* model) { this->model = model; DialogsTreeView::setModel(model); selectionModel()->deleteLater(); setSelectionModel(&model->get_selection_model()); }
/** * @brief Sets the sprite to represent in this view. * @param model The sprite model. */ void SpriteTreeView::set_model(SpriteModel* model) { this->model = model; SpriteTreeView::setModel(model); selectionModel()->deleteLater(); setSelectionModel(&model->get_selection_model()); }
void QgsAttributeTableView::setModel( QgsAttributeTableFilterModel *filterModel ) { mFilterModel = filterModel; QTableView::setModel( filterModel ); if ( mFilterModel ) { connect( mFilterModel, &QObject::destroyed, this, &QgsAttributeTableView::modelDeleted ); connect( mTableDelegate, &QgsAttributeTableDelegate::actionColumnItemPainted, this, &QgsAttributeTableView::onActionColumnItemPainted ); } delete mFeatureSelectionModel; mFeatureSelectionModel = nullptr; if ( filterModel ) { if ( !mFeatureSelectionManager ) { mFeatureSelectionManager = new QgsVectorLayerSelectionManager( mFilterModel->layer(), mFilterModel ); } mFeatureSelectionModel = new QgsFeatureSelectionModel( mFilterModel, mFilterModel, mFeatureSelectionManager, mFilterModel ); setSelectionModel( mFeatureSelectionModel ); mTableDelegate->setFeatureSelectionModel( mFeatureSelectionModel ); connect( mFeatureSelectionModel, static_cast<void ( QgsFeatureSelectionModel::* )( const QModelIndexList &indexes )>( &QgsFeatureSelectionModel::requestRepaint ), this, static_cast<void ( QgsAttributeTableView::* )( const QModelIndexList &indexes )>( &QgsAttributeTableView::repaintRequested ) ); connect( mFeatureSelectionModel, static_cast<void ( QgsFeatureSelectionModel::* )()>( &QgsFeatureSelectionModel::requestRepaint ), this, static_cast<void ( QgsAttributeTableView::* )()>( &QgsAttributeTableView::repaintRequested ) ); } }
void PopupMenu::onCreate(const PopupMenu * Id) { Inherited::onCreate(Id); DefaultSingleSelectionModelUnrecPtr TheModel(DefaultSingleSelectionModel::create()); setSelectionModel(TheModel); }
FileViewController::FileViewController(QObject *parent) : QObject(parent) , m_model(new VFileSystemModel(this)) , m_selectionModel(new QItemSelectionModel(m_model)) { setModel(new VFileSystemModel(this)); setSelectionModel(new QItemSelectionModel(model(), this)); }
void OptionsDialog::setup_shortcuts_list_view(){ this->sl_model.reset(new ShortcutListModel(this->app->get_shortcuts())); this->sl_selmodel.reset(new SimpleItemSelectionModel(*this->sl_model)); auto lv = this->ui->shortcuts_list_view; lv->setModel(this->sl_model.get()); lv->header()->setModel(&slhm); lv->resizeColumnToContents(0); lv->setSelectionModel(this->sl_selmodel.get()); }
void TabPanel::onCreate(const TabPanel * Id) { Inherited::onCreate(Id); if(Id != NULL) { DefaultSingleSelectionModelUnrecPtr Model(DefaultSingleSelectionModel::create()); setSelectionModel(Model); } }
void ColorView::slotSelectItemRequested(const QModelIndex& idx) { if (!selectionModel()) { setSelectionModel(new QItemSelectionModel(model())); } selectionModel()->select(idx, QItemSelectionModel::ClearAndSelect); selectionModel()->setCurrentIndex(idx, QItemSelectionModel::ClearAndSelect); scrollTo(idx, QAbstractItemView::EnsureVisible); }
void SidePane::setModel(QAbstractItemModel* model) { QAbstractItemView::setModel(model); setMinimumWidth(sizeHint().width()); if (model) { auto selModel = new NonEmptySelectionModel(model); setSelectionModel(selModel); connect(selModel, &QItemSelectionModel::selectionChanged, this, &SidePane::selectionChanged); } }
//-------------------- CalendarTreeView::CalendarTreeView( QWidget *parent ) : TreeViewBase( parent ) { header()->setContextMenuPolicy( Qt::CustomContextMenu ); setModel( new CalendarItemModel() ); setSelectionBehavior( QAbstractItemView::SelectRows ); setSelectionMode( QAbstractItemView::SingleSelection ); setSelectionModel( new QItemSelectionModel( model() ) ); setItemDelegateForColumn( 1, new EnumDelegate( this ) ); // timezone connect( header(), SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(headerContextMenuRequested(QPoint)) ); }
//-------------------- AccountTreeView::AccountTreeView( QWidget *parent ) : TreeViewBase( parent ) { header()->setContextMenuPolicy( Qt::CustomContextMenu ); setModel( new AccountItemModel( this ) ); setSelectionModel( new QItemSelectionModel( model() ) ); setSelectionMode( QAbstractItemView::SingleSelection ); setSelectionBehavior( QAbstractItemView::SelectRows ); setAcceptDrops( false ); setDropIndicatorShown( false ); connect( header(), SIGNAL( customContextMenuRequested ( const QPoint& ) ), this, SLOT( headerContextMenuRequested( const QPoint& ) ) ); }
void GPSItemList::setModelAndSelectionModel(GPSItemModel* const model, QItemSelectionModel* const selectionModel) { d->model = model; d->selectionModel = selectionModel; d->imageSortProxyModel = new GPSItemSortProxyModel(d->model, d->selectionModel); setModel(d->imageSortProxyModel); connect(d->model, SIGNAL(signalThumbnailForIndexAvailable(QPersistentModelIndex,QPixmap)), this, SLOT(slotThumbnailFromModel(QPersistentModelIndex,QPixmap))); connect(this, SIGNAL(clicked(QModelIndex)), this, SLOT(slotInternalTreeViewImageActivated(QModelIndex))); if (d->imageSortProxyModel->mappedSelectionModel()) setSelectionModel(d->imageSortProxyModel->mappedSelectionModel()); }
void QgsFeatureListView::setModel( QgsFeatureListModel *featureListModel ) { QListView::setModel( featureListModel ); mModel = featureListModel; delete mFeatureSelectionModel; mCurrentEditSelectionModel = new QItemSelectionModel( mModel->masterModel(), this ); if ( !mFeatureSelectionManager ) { mFeatureSelectionManager = new QgsVectorLayerSelectionManager( mModel->layerCache()->layer(), mModel ); } mFeatureSelectionModel = new QgsFeatureSelectionModel( featureListModel, featureListModel, mFeatureSelectionManager, this ); setSelectionModel( mFeatureSelectionModel ); connect( featureListModel->layerCache()->layer(), &QgsVectorLayer::selectionChanged, this, [ this ]() { ensureEditSelection( true ); } ); if ( mItemDelegate && mItemDelegate->parent() == this ) { delete mItemDelegate; } mItemDelegate = new QgsFeatureListViewDelegate( mModel, this ); mItemDelegate->setEditSelectionModel( mCurrentEditSelectionModel ); setItemDelegate( mItemDelegate ); mItemDelegate->setFeatureSelectionModel( mFeatureSelectionModel ); connect( mFeatureSelectionModel, static_cast<void ( QgsFeatureSelectionModel::* )( const QModelIndexList &indexes )>( &QgsFeatureSelectionModel::requestRepaint ), this, static_cast<void ( QgsFeatureListView::* )( const QModelIndexList &indexes )>( &QgsFeatureListView::repaintRequested ) ); connect( mFeatureSelectionModel, static_cast<void ( QgsFeatureSelectionModel::* )()>( &QgsFeatureSelectionModel::requestRepaint ), this, static_cast<void ( QgsFeatureListView::* )()>( &QgsFeatureListView::repaintRequested ) ); connect( mCurrentEditSelectionModel, &QItemSelectionModel::selectionChanged, this, &QgsFeatureListView::editSelectionChanged ); connect( mModel->layerCache()->layer(), &QgsVectorLayer::attributeValueChanged, this, [ = ] { repaintRequested(); } ); connect( featureListModel, &QgsFeatureListModel::rowsRemoved, this, [ this ]() { ensureEditSelection(); } ); connect( featureListModel, &QgsFeatureListModel::rowsInserted, this, [ this ]() { ensureEditSelection(); } ); connect( featureListModel, &QgsFeatureListModel::modelReset, this, [ this ]() { ensureEditSelection(); } ); }
SnippetWidget::SnippetWidget(KMComposerEditorNg *editor, KActionCollection *actionCollection, QWidget *parent) : QTreeView(parent) { header()->hide(); setAcceptDrops(true); setDragEnabled(true); setRootIsDecorated(true); setAlternatingRowColors(true); mSnippetsManager = new MailCommon::SnippetsManager(actionCollection, this, this); mSnippetsManager->setEditor(editor, "insertPlainText", SIGNAL(insertSnippet())); setModel(mSnippetsManager->model()); setSelectionModel(mSnippetsManager->selectionModel()); connect(this, &QAbstractItemView::activated, mSnippetsManager->editSnippetAction(), &QAction::trigger); connect(mSnippetsManager->model(), &QAbstractItemModel::rowsInserted, this, &QTreeView::expandAll); connect(mSnippetsManager->model(), &QAbstractItemModel::rowsRemoved, this, &QTreeView::expandAll); expandAll(); }
bool TableView::setSelectedRows(QList<int> rows) { QItemSelectionModel * selection = selectionModel(); selection->clear(); TableModel * currentModel = static_cast<TableModel *>(model()); QItemSelection totalSelection; for(int i = 0; i < rows.size(); i++) { if(!currentModel->isValidRow(rows[i])) { continue; } QModelIndex index = model()->index(rows[i], 0); QItemSelection currentSelection(index, index); totalSelection.merge(currentSelection, QItemSelectionModel::SelectCurrent); } selection->select(totalSelection, QItemSelectionModel::ClearAndSelect); setSelectionModel(selection); return true; }
void CharTableView::modelSelectionChanged(QItemSelectionModel * model) { setSelectionModel(model); }
void KexiCategorizedView::setModel(QAbstractItemModel *model) { KCategorizedView::setModel(model); setSelectionModel(new KexiCategorySingleSelectionModel(model)); }
/*virtual*/ void AbstractItemView::setModel(QAbstractItemModel *model, AbstractViewItem *prototype) { if( m_model == model || !model) return; if (m_model) { disconnect(m_model, SIGNAL(destroyed()), this, SLOT(_q_modelDestroyed())); disconnect(m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT( dataChanged(QModelIndex,QModelIndex))); disconnect(m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(rowsInserted(QModelIndex,int,int))); disconnect(m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(rowsRemoved(QModelIndex,int,int))); disconnect(m_model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), this, SLOT(rowsAboutToBeRemoved(QModelIndex,int,int))); disconnect(m_model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), this, SLOT(rowsAboutToBeInserted(QModelIndex,int,int))); disconnect(m_model, SIGNAL(columnsInserted(QModelIndex,int,int)), this, SLOT(columnsInserted(QModelIndex,int,int))); disconnect(m_model, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int)), this, SLOT(columnsAboutToBeInserted(QModelIndex,int,int))); disconnect(m_model, SIGNAL(columnsRemoved(QModelIndex,int,int)), this, SLOT(columnsRemoved(QModelIndex,int,int))); disconnect(m_model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int)), this, SLOT(columnsAboutToBeRemoved(QModelIndex,int,int))); disconnect(m_model, SIGNAL(modelReset()), this, SLOT(reset())); disconnect(m_model, SIGNAL(layoutChanged()), this, SLOT(_q_layoutChanged())); m_model = 0; } setSelectionModel(0); m_currentIndex = QModelIndex(); m_rootIndex = QModelIndex(); m_model = model; Q_ASSERT_X(m_model->index(0,0) == m_model->index(0,0), "AbstractItemView::setModel", "A model should return the exact same index " "(including its internal id/pointer) when asked for it twice in a row."); Q_ASSERT_X(m_model->index(0,0).parent() == QModelIndex(), "AbstractItemView::setModel", "The parent of a top level index should be invalid"); connect(m_model, SIGNAL(destroyed()), this, SLOT(modelDestroyed())); connect(m_model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT( dataChanged(QModelIndex,QModelIndex))); connect(m_model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)), this, SLOT(rowsAboutToBeInserted(QModelIndex,int,int))); connect(m_model, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(rowsInserted(QModelIndex,int,int))); connect(m_model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)), this, SLOT(rowsAboutToBeRemoved(QModelIndex,int,int))); connect(m_model, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(rowsRemoved(QModelIndex,int,int))); connect(m_model, SIGNAL(modelReset()), this, SLOT(reset())); connect(m_model, SIGNAL(layoutChanged()), this, SLOT(layoutChanged())); setSelectionModel(new QItemSelectionModel(m_model)); if (prototype && m_container) { m_container->setItemPrototype(prototype); m_container->reset(); } }
void LayerTreeSidebar::createForms() { QVBoxLayout *mainLayout = new QVBoxLayout(); mainLayout->setSpacing(0); mainLayout->setContentsMargins(0, 0, 0, 0); { auto view = new QTreeView(); if (d->uiController) view->setItemDelegate(new LayerModelViewDelegate(d->uiController, this)); view->setHeaderHidden(true); view->setSelectionMode(QAbstractItemView::ExtendedSelection); view->setDragDropMode(QAbstractItemView::DragDrop); view->setDefaultDropAction(Qt::MoveAction); view->setDropIndicatorShown(true); if (d->document) { view->setModel(d->document->layerScene()->itemModel()); view->setSelectionModel(d->document->layerScene()->itemSelectionModel()); connect(d->document->layerScene(), SIGNAL(thumbnailsUpdated(QPointSet)), view, SLOT(update())); } view->setContextMenuPolicy(Qt::CustomContextMenu); connect(view, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showViewContextMenu(QPoint))); view->installEventFilter(this); d->view = view; mainLayout->addWidget(view); } { auto lowerLayout = new QVBoxLayout(); lowerLayout->setSpacing(6); lowerLayout->setContentsMargins(6,6,6,6); { auto editor = new LayerPropertyEditor(d->document ? d->document->layerScene() : 0); lowerLayout->addWidget(editor); } // buttons { auto layout = new QHBoxLayout(); layout->setSpacing(0); auto addButton = new SimpleButton(":/icons/16x16/add.svg", QSize(16,16)); addButton->setMargins(4, 0, 4, 0); auto removeButton = new SimpleButton(":/icons/16x16/subtract.svg", QSize(16,16)); removeButton->setMargins(4, 0, 4, 0); auto miscButton = new SimpleButton(":/icons/16x16/menuDown.svg", QSize(16,16)); miscButton->setMargins(4, 0, 4, 0); if (d->uiController) { auto addMenu = new QMenu(this); addMenu->addAction(d->uiController->action(LayerUIController::ActionNewRaster)); addMenu->addAction(d->uiController->action(LayerUIController::ActionNewGroup)); addMenu->addAction(d->uiController->action(LayerUIController::ActionImport)); addButton->setMenu(addMenu); connect(removeButton, SIGNAL(pressed()), d->uiController, SLOT(removeLayers())); QMenu *miscMenu = new QMenu(this); miscMenu->addAction(d->uiController->action(LayerUIController::ActionMerge)); miscButton->setMenu(miscMenu); } layout->addWidget(addButton); layout->addWidget(removeButton); layout->addWidget(miscButton); layout->addStretch(1); lowerLayout->addLayout(layout); } mainLayout->addLayout(lowerLayout); } setLayout(mainLayout); }
//------------------------------------------------------------------------------ View3D::View3D(GeometryCollection* geometries, const QGLFormat& format, QWidget *parent) : QGLWidget(format, parent), m_camera(false, false), m_mouseButton(Qt::NoButton), m_explicitCursorPos(false), m_cursorPos(0), m_prevCursorSnap(0), m_backgroundColor(60, 50, 50), m_drawBoundingBoxes(true), m_drawCursor(true), m_drawAxes(true), m_drawGrid(false), m_drawAnnotations(true), m_badOpenGL(false), m_shaderProgram(), m_geometries(geometries), m_selectionModel(0), m_shaderParamsUI(0), m_incrementalFrameTimer(0), m_incrementalFramebuffer(), m_incrementalDraw(false), m_drawAxesBackground(QImage(":/resource/axes.png")), m_drawAxesLabelX(QImage(":/resource/x.png")), m_drawAxesLabelY(QImage(":/resource/y.png")), m_drawAxesLabelZ(QImage(":/resource/z.png")), m_cursorVertexArray(0), m_axesVertexArray(0), m_gridVertexArray(0), m_quadVertexArray(0), m_quadLabelVertexArray(0), m_devicePixelRatio(1.0) { connect(m_geometries, SIGNAL(layoutChanged()), this, SLOT(geometryChanged())); //connect(m_geometries, SIGNAL(destroyed()), this, SLOT(modelDestroyed())); connect(m_geometries, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(geometryChanged())); connect(m_geometries, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(dataChanged(QModelIndex,QModelIndex))); connect(m_geometries, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(geometryInserted(const QModelIndex&, int,int))); connect(m_geometries, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(geometryChanged())); setSelectionModel(new QItemSelectionModel(m_geometries, this)); setFocusPolicy(Qt::StrongFocus); setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); setFocus(); connect(&m_camera, SIGNAL(projectionChanged()), this, SLOT(restartRender())); connect(&m_camera, SIGNAL(viewChanged()), this, SLOT(restartRender())); makeCurrent(); m_shaderProgram.reset(new ShaderProgram()); connect(m_shaderProgram.get(), SIGNAL(uniformValuesChanged()), this, SLOT(restartRender())); connect(m_shaderProgram.get(), SIGNAL(shaderChanged()), this, SLOT(restartRender())); connect(m_shaderProgram.get(), SIGNAL(paramsChanged()), this, SLOT(setupShaderParamUI())); m_incrementalFrameTimer = new QTimer(this); m_incrementalFrameTimer->setSingleShot(false); connect(m_incrementalFrameTimer, SIGNAL(timeout()), this, SLOT(updateGL())); }
//------------------------------------------------------------------------------ View3D::View3D(GeometryCollection* geometries, const QGLFormat& format, QWidget *parent) : QGLWidget(format, parent), m_camera(false, false), m_mouseButton(Qt::NoButton), m_explicitCursorPos(false), m_cursorPos(0), m_prevCursorSnap(0), m_backgroundColor(60, 50, 50), m_drawBoundingBoxes(true), m_drawCursor(true), m_drawAxes(true), m_drawGrid(false), m_badOpenGL(false), m_shaderProgram(), m_geometries(geometries), m_selectionModel(0), m_shaderParamsUI(0), m_incrementalFrameTimer(0), m_incrementalFramebuffer(0), m_incrementalDraw(false), m_drawAxesBackground(QImage(":/resource/axes.png")), m_drawAxesLabelX(QImage(":/resource/x.png")), m_drawAxesLabelY(QImage(":/resource/y.png")), m_drawAxesLabelZ(QImage(":/resource/z.png")), m_cursorVertexArray(0), m_axesVertexArray(0), m_gridVertexArray(0), m_quadVertexArray(0), m_quadLabelVertexArray(0), m_devicePixelRatio(1.0) { connect(m_geometries, SIGNAL(layoutChanged()), this, SLOT(geometryChanged())); //connect(m_geometries, SIGNAL(destroyed()), this, SLOT(modelDestroyed())); connect(m_geometries, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(geometryChanged())); connect(m_geometries, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(geometryInserted(const QModelIndex&, int,int))); connect(m_geometries, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(geometryChanged())); setSelectionModel(new QItemSelectionModel(m_geometries, this)); setFocusPolicy(Qt::StrongFocus); setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); setFocus(); m_camera.setClipFar(FLT_MAX*0.5f); //using FLT_MAX appears to cause issues under OS X for Qt to handle // Setting a good value for the near camera clipping plane is difficult // when trying to show a large variation of length scales: Setting a very // small value allows us to see objects very close to the camera; the // tradeoff is that this reduces the resolution of the z-buffer leading to // z-fighting in the distance. m_camera.setClipNear(1); connect(&m_camera, SIGNAL(projectionChanged()), this, SLOT(restartRender())); connect(&m_camera, SIGNAL(viewChanged()), this, SLOT(restartRender())); makeCurrent(); m_shaderProgram.reset(new ShaderProgram()); connect(m_shaderProgram.get(), SIGNAL(uniformValuesChanged()), this, SLOT(restartRender())); connect(m_shaderProgram.get(), SIGNAL(shaderChanged()), this, SLOT(restartRender())); connect(m_shaderProgram.get(), SIGNAL(paramsChanged()), this, SLOT(setupShaderParamUI())); m_incrementalFrameTimer = new QTimer(this); m_incrementalFrameTimer->setSingleShot(false); connect(m_incrementalFrameTimer, SIGNAL(timeout()), this, SLOT(updateGL())); }
void IconView::init() { KConfig config; KConfigGroup generalGroup( &config, "General" ); m_wallpaper = generalGroup.readEntry( "Wallpaper", DEFAULT_WALLPAPER ); delete m_pixmap; m_pixmap = new QPixmap( m_wallpaper ); QPalette p; p.setBrush( QPalette::Base, QBrush( *m_pixmap ) ); setPalette( p ); m_model = new KDirModel( this ); KDirLister* lister = new KDirLister( this ); lister->openUrl( KUrl( QDir::homePath() ) ); m_model->setDirLister( lister ); m_delegate = new KFileItemDelegate( this ); m_delegate->setMaximumSize( QSize( 64, 64 ) ); m_delegate->setShadowOffset( QPointF( 1, 1 ) ); m_delegate->setShadowColor( QColor( 0xff, 0xff, 0xff ) ); m_delegate->setShadowBlur( 1 ); m_delegate->setWrapMode( QTextOption::WrapAtWordBoundaryOrAnywhere ); m_proxyModel = new KDirSortFilterProxyModel( this ); m_proxyModel->setSourceModel( m_model ); setModel( m_proxyModel ); setItemDelegate( m_delegate ); m_selectionModel = new QItemSelectionModel( m_proxyModel ); setSelectionModel( m_selectionModel ); /// create actions KAction* cut = KStandardAction::cut( this, SLOT(cut()), this ); KAction* copy = KStandardAction::copy( this, SLOT(copy()), this ); KIO::FileUndoManager* manager = KIO::FileUndoManager::self(); KAction* undo = KStandardAction::undo( manager, SLOT(undo()), this ); connect( manager, SIGNAL(undoAvailable(bool)), undo, SLOT(setEnabled(bool)) ); connect( manager, SIGNAL(undoTextChanged(const QString&)), SLOT(undoTextChanged(const QString&)) ); undo->setEnabled( manager->undoAvailable() ); KAction* paste = KStandardAction::paste( this, SLOT(paste()), this ); KAction* pasteTo = KStandardAction::paste( this, SLOT(pasteTo()), this ); pasteTo->setEnabled( false ); // Only enabled during popupMenu() QString actionText = KIO::pasteActionText(); if ( !actionText.isEmpty() ) paste->setText( actionText ); else paste->setEnabled( false ); KAction* refresh = new KAction(KIcon("user-desktop"), i18n("&Refresh Desktop"), this); connect( refresh, SIGNAL(triggered()), this, SLOT(refresh()) ); KAction* wallpaper = new KAction(KIcon("tools-wizard"), i18n("&Change Wallpaper..."), this); connect( wallpaper, SIGNAL(triggered()), this, SLOT(changeWallpaper()) ); KAction* rename = new KAction(KIcon("edit-rename"), i18n("&Rename"), this); rename->setShortcut( Qt::Key_F2 ); connect( rename, SIGNAL(triggered()), SLOT(rename()) ); KAction* trash = new KAction(KIcon("user-trash"), i18n("&Move to Trash"), this); trash->setShortcut( Qt::Key_Delete ); connect( trash, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), this, SLOT(moveToTrash(Qt::MouseButtons, Qt::KeyboardModifiers)) ); KAction* del = new KAction(KIcon("edit-delete"), i18n("&Delete"), this); del->setShortcut( Qt::SHIFT + Qt::Key_Delete ); connect( del, SIGNAL(triggered()), this, SLOT(deleteSelectedItems()) ); KAction* emptyTrash = new KAction(KIcon("trash-empty"), i18n("&Empty Trash Bin"), this); KConfig trashConfig( "trashrc", KConfig::SimpleConfig ); emptyTrash->setEnabled( !trashConfig.group( "Status" ).readEntry( "Empty", true ) ); connect( emptyTrash, SIGNAL(triggered()), this, SLOT(emptyTrashBin()) ); // Create the new menu m_newMenu = new KNewFileMenu(&m_actionCollection, "new_menu", this); connect( m_newMenu->menu(), SIGNAL(aboutToShow()), this, SLOT(aboutToShowCreateNew()) ); m_actionCollection.addAction( "undo", undo ); m_actionCollection.addAction( "cut", cut ); m_actionCollection.addAction( "copy", copy ); m_actionCollection.addAction( "paste", paste ); m_actionCollection.addAction( "pasteto", pasteTo ); m_actionCollection.addAction( "refresh", refresh ); m_actionCollection.addAction( "wallpaper", wallpaper ); m_actionCollection.addAction( "rename", rename ); m_actionCollection.addAction( "trash", trash ); m_actionCollection.addAction( "del", del ); m_actionCollection.addAction( "empty_trash", emptyTrash ); }