void toResultTableView::slotApplyColumnRules() { // TODO: call after every model reset // connect(Model, SIGNAL(modelReset()), this, SLOT(slotApplyColumnRules())); if (!NumberColumn) hideColumn(0); if (ReadableColumns) { VisibleColumns = 0; // loop through columns and hide anything starting with a ' ' for (int col = 1; col < model()->columnCount(); col++) { if (model()->headerData( col, Qt::Horizontal, Qt::DisplayRole).toString().startsWith(" ")) { hideColumn(col); } else VisibleColumns++; } } // hiding columns sends signal sectionResized ColumnsResized = false; slotResizeColumnsToContents(); if (toConfigurationNewSingle::Instance().option(ToConfiguration::Global::MultiLineResultsBool).toBool()) resizeRowsToContents(); if (ReadableColumns && VisibleColumns == 1) setColumnWidth(1, viewport()->width()); }
void DirsTreeWidget::initView() { setModel (&model_); setUniformRowHeights (true); setContextMenuPolicy (Qt::CustomContextMenu); hideColumn (kTreeViewSizeColumn); hideColumn (kTreeViewTypeColumn); hideColumn (kTreeViewDateColumn); }
void FSTableView::dragEnterEvent(QDragEnterEvent *event) { if (rootIndex().isValid() && event->mimeData()->hasUrls()) { event->acceptProposedAction(); viewport()->setStyleSheet("background-color:#ededed;background-image: url( :/drop.png);background-repeat:no-repeat;background-position:center center"); hideColumn(0); hideColumn(1); hideColumn(2); } }
void QmlProfilerStatisticsMainView::setShowExtendedStatistics(bool show) { // Not checking if already set because we don't want the first call to skip m_showExtendedStatistics = show; if (show) { showColumn(MainMedianTime); showColumn(MainMaxTime); showColumn(MainMinTime); } else { hideColumn(MainMedianTime); hideColumn(MainMaxTime); hideColumn(MainMinTime); } }
//Credit to amaroK for this //Seems like it can become the next plugin to do since amarok is really cool (just missing plugin arch) bool SongList::eventFilter(QObject *o, QEvent *e ) { if(o == header() && e->type() == QEvent::MouseButtonPress && static_cast<QMouseEvent*>(e)->button() == Qt::RightButton ) { KPopupMenu popup; //popup.setFont(this->font()); popup.setCheckable(true); popup.insertTitle(i18n("Available Columns")); int colcount=columns(); for( int i = 0; i < colcount; ++i ) //columns() references a property { popup.insertItem(columnText(i),i,i+1 ); popup.setItemChecked(i,columnWidth(i)!=0); } int col = popup.exec( static_cast<QMouseEvent *>(e)->globalPos() ); if( col != -1 ) { //TODO can result in massively wide column appearing! if( columnWidth( col ) == 0 ) { adjustColumn( col ); header()->setResizeEnabled( true, col ); } else hideColumn( col ); } //determine first visible column again, since it has changed //eat event return TRUE; } return KListView::eventFilter(o,e); }
K3b::DataDirTreeView::DataDirTreeView( K3b::View* view, K3b::DataDoc* doc, QWidget* parent ) : QTreeView( parent ), m_view(view) { d = new Private(); setSelectionMode(QAbstractItemView::SingleSelection); // setRootIsDecorated( false ); setDragDropMode( QAbstractItemView::DragDrop ); setDropIndicatorShown( true ); setDragEnabled(true); setAcceptDrops( true ); header()->hide(); m_doc = doc; d->model = new K3b::DataProjectModel( doc, this ); //d->model->setListOnlyDirs( true ); setModel( d->model ); for ( int i = K3b::DataProjectModel::TypeColumn; i < K3b::DataProjectModel::NumColumns; ++i ) { hideColumn( i ); } connect( d->model, SIGNAL(addUrlsRequested(KUrl::List,K3b::DirItem*)), SLOT(slotAddUrlsRequested(KUrl::List,K3b::DirItem*)) ); connect( d->model, SIGNAL(moveItemsRequested(QList<K3b::DataItem*>,K3b::DirItem*)), SLOT(slotMoveItemsRequested(QList<K3b::DataItem*>,K3b::DirItem*)) ); connect( selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(slotSelectionChanged(QItemSelection,QItemSelection)) ); }
ThreadListWidget::ThreadListWidget(QWidget *parent) : QTreeWidget(parent) { setColumnCount(3); currentGroup = 0; disableSortAndResize = false; QStringList headers; headers << "Subject" << "Date" << "Author" << "Ordernum"; setHeaderLabels(headers); setSelectionMode(QAbstractItemView::SingleSelection); connect(this, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem *)), this, SLOT(messageSelected(QTreeWidgetItem*,QTreeWidgetItem *))); hideColumn(3); markReadAction = new QAction("Mark thread read", this); markReadAction->setToolTip("Marks all messages in this thread read"); connect(markReadAction, SIGNAL(triggered()), this, SLOT(markReadClicked())); markUnreadAction = new QAction("Mark thread unread", this); markUnreadAction->setToolTip("Marks all messages in this thread as unread"); connect(markUnreadAction, SIGNAL(triggered()), this, SLOT(markUnreadClicked())); threadPropertiesAction = new QAction("Thread properties", this); threadPropertiesAction->setToolTip("Information and settings for selected thread"); connect(threadPropertiesAction, SIGNAL(triggered()), this, SLOT(threadPropertiesClicked())); viewInBrowserAction = new QAction("View in browser", this); viewInBrowserAction->setToolTip("View the message in external browser"); connect(viewInBrowserAction, SIGNAL(triggered()), this, SLOT(viewInBrowserClicked())); forceUpdateThreadAction = new QAction("Force update of thread", this); forceUpdateThreadAction->setToolTip("Updates all messages in selected thread"); connect(forceUpdateThreadAction, SIGNAL(triggered()), this, SLOT(forceUpdateThreadClicked())); }
/** * @brief Toggles the visibility of the column on or off. * If a signal is sent, the column name is derived from QAction::text(). Because of this, * You can only connect signals from a QAction to this slot. * @param column The name of the column to toggle */ void DatabaseList::toggleColumn(const QString column) { QSettings settings; QAction* actionUsed = (QAction*)sender(); QString columnName = column; // If we recieved a signal, find the column name from the sender if(actionUsed != 0) columnName = actionUsed->text(); // Loop through the columns looking for the one we want for(int i = 0; i < mDatabaseModel->columnCount(); i++) { if(mDatabaseModel->headerData(i, Qt::Horizontal).toString() == columnName) { // Toggle the visibility of the column if(isColumnHidden(i)) { setColumnWidth(i, settings.value("SongView/ColumnSize" + QString::number(i)).toInt()); showColumn(i); } else { settings.setValue("SongView/ColumnSize" + QString::number(i), columnWidth(i)); hideColumn(i); } } } };
void GameList::ShowContextMenu(const QPoint& pos) { QMenu headerMenu; QAction* filterTag = headerMenu.addAction(tr("Find tag...")); headerMenu.addSeparator(); QAction* hide = headerMenu.addAction(tr("Hide Column")); headerMenu.addSeparator(); QAction* resizeAll = headerMenu.addAction(tr("Resize visible Columns")); QAction* showAll = headerMenu.addAction(tr("Show all Columns")); QAction* selectedItem = headerMenu.exec(mapToGlobal(pos)); int column = columnAt(pos.x()); if (selectedItem == filterTag) { simpleSearch(column); } else if(selectedItem == hide) { if(column > 0) { hideColumn(column); } } else if(selectedItem == showAll) { for(int i = 0; i < model()->columnCount(); ++i) { showColumn(i); } } else if (selectedItem == resizeAll) { resizeColumnsToContents(); } }
EstelBrowserWidget::EstelBrowserWidget(QWidget *parent) : QTreeView(parent) { mModel = new QFileSystemModel; setModel(mModel); setRootIndex(mModel->setRootPath(QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first())); mModel->setNameFilters(QStringList()<<"*.estel"); mModel->setNameFilterDisables(false); hideColumn(1); hideColumn(2); hideColumn(3); connect(this,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(onDoubleClicked(QModelIndex))); }
void ReportEdit::refresh( const QDateTime & key ) { m_model->setQuery( QString("SELECT " "%1, " // datetime is a unique attribute "c.who, " "l.num_text, " "l.num, " "CASE WHEN l.zakaz = 0 THEN '' ELSE 'заказное' END, " "%2 " "FROM " "%3 l " "INNER JOIN " "%4 c ON l.contact_id = c.id " "WHERE " "%5 " "ORDER BY " "6 " // by time ) .arg( _dbPg ? "date_trunc( 'second', l.drec )" : "l.timestamp" ) .arg( _dbPg ? "\"time\"( l.drec )" : "substr( l.timestamp, 12 )" ) .arg( _tableName( "log" ) ) .arg( _tableName( "contact" ) ) .arg( _dbPg ? QString("date( l.drec ) = '%1'").arg( m_date.toString("yyyy-MM-dd") ) : QString("substr( l.timestamp, 1, 10 ) = '%1'").arg( m_date.toString("yyyy-MM-dd") ) ) ); hideColumn( 0 ); // datetime hideColumn( 5 ); // time resizeColumnsToContents(); if ( key.isValid() ) { for ( int i = 0; i < m_model->rowCount(); ++i ) { if ( m_model->index( i, 0 ).data().toDateTime() == key ) { const QModelIndex index = m_model->index( i, 1 ); setCurrentIndex( index ); scrollTo( index ); break; } } } }
EntityTreeWidget::EntityTreeWidget(QWidget * parent) : QTreeWidget(parent), _dragEntity(NULL) { QStringList headerList; headerList << "name" << "type"; setHeaderLabels(headerList); setHeaderHidden (true); hideColumn(1); header()->setResizeMode(0, QHeaderView::Stretch); setMouseTracking(true); setIconSize(QSize(24,24)); }
openvolume::openvolume( QWidget * parent ) : QDialog( parent ),m_ui( new Ui::openvolume() ) { m_ui->setupUi( this ) ; this->setFixedSize( this->size() ) ; this->setFont( parent->font() ) ; connect( m_ui->tableWidget,SIGNAL( itemDoubleClicked( QTableWidgetItem * ) ), this,SLOT( tableEntryDoubleClicked( QTableWidgetItem * ) ) ) ; connect( m_ui->tableWidget,SIGNAL( currentItemChanged( QTableWidgetItem *,QTableWidgetItem * ) ), this,SLOT( currentItemChanged( QTableWidgetItem *,QTableWidgetItem * ) ) ) ; connect( m_ui->pbHelp,SIGNAL( clicked() ),this,SLOT( pbHelp() ) ) ; connect( m_ui->pbUUID,SIGNAL( clicked() ),this,SLOT( pbUUID() ) ) ; connect( m_ui->pbCancel,SIGNAL( clicked() ),this,SLOT( pbCancel() ) ) ; connect( m_ui->pbOpen,SIGNAL( clicked() ),this,SLOT( pbOpen() ) ) ; this->addAction( [ this ](){ auto ac = new QAction( this ) ; ac->setShortcuts( { Qt::Key_Enter,Qt::Key_Return } ) ; connect( ac,SIGNAL( triggered() ),this,SLOT( EnterKeyPressed() ) ) ; return ac ; }() ) ; auto tw = m_ui->tableWidget ; tw->setColumnWidth( 0,183 ) ; tw->setColumnWidth( 1,90 ) ; //tw->setColumnWidth( 2,110 ) ; tw->hideColumn( 2 ) ; tw->setColumnWidth( 3,90 ) ; tw->setColumnWidth( 4,309 ) ; for( int i = 0 ; i < 5 ; i++ ){ tw->horizontalHeaderItem( i )->setFont( this->font() ) ; } tw->horizontalHeader()->setVisible( true ) ; m_ui->checkBoxUUID->setVisible( false ) ; m_ui->pbHelp->setVisible( false ) ; this->installEventFilter( this ) ; this->disableAll() ; }
void BufferView::init() { header()->setContextMenuPolicy(Qt::ActionsContextMenu); hideColumn(1); hideColumn(2); setIndentation(10); // New entries will be expanded automatically when added; no need to call expandAll() header()->hide(); // nobody seems to use this anyway setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // breaks with Qt 4.8 if (QString("4.8.0") > qVersion()) // FIXME breaks with Qt versions >= 4.10! setAnimated(true); // FIXME This is to workaround bug #663 setUniformRowHeights(true); #ifndef QT_NO_DRAGANDDROP setDragEnabled(true); setAcceptDrops(true); setDropIndicatorShown(true); #endif setSortingEnabled(true); sortByColumn(0, Qt::AscendingOrder); #if defined Q_OS_MACOS || defined Q_OS_WIN // afaik this is better on Mac and Windows disconnect(this, SIGNAL(activated(QModelIndex)), this, SLOT(joinChannel(QModelIndex))); connect(this, SIGNAL(activated(QModelIndex)), SLOT(joinChannel(QModelIndex))); #else disconnect(this, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(joinChannel(QModelIndex))); connect(this, SIGNAL(doubleClicked(QModelIndex)), SLOT(joinChannel(QModelIndex))); #endif }
void PeerListWidget::updatePeerCountryResolutionState() { if (Preferences::instance()->resolvePeerCountries() != m_displayFlags) { m_displayFlags = !m_displayFlags; if (m_displayFlags) { loadPeers(m_properties->getCurrentTorrent()); showColumn(PeerListDelegate::COUNTRY); resizeColumnToContents(PeerListDelegate::COUNTRY); } else { hideColumn(PeerListDelegate::COUNTRY); } } }
void UPacketMonitor::onShowHideColumnToggled(bool checked) { QAction *action = qobject_cast<QAction *>(sender()); if(action) { if(checked) { showColumn(action->data().toInt()); } else { hideColumn(action->data().toInt()); } } }
WordTree::WordTree(QWidget* parent) : QTreeWidget(parent), m_active_item(0), m_hebrew(false), m_trie(0) { setColumnCount(3); hideColumn(2); header()->setStretchLastSection(false); header()->setSectionResizeMode(0, QHeaderView::Stretch); header()->setSectionResizeMode(1, QHeaderView::Fixed); header()->hide(); setColumnWidth(1, 22); setIconSize(QSize(16,16)); setMouseTracking(true); setRootIsDecorated(false); setSortingEnabled(true); sortByColumn(0, Qt::AscendingOrder); setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); connect(this, &QTreeWidget::itemClicked, this, &WordTree::onItemClicked); }
void NMGMeasureListWidget::addHeaderInformation(Globals::SupportedType type) { if(type == Globals::AGGREGATION) { QStringList header; header << tr("Test"); // 0 header << tr("Name"); // 1 header << tr("Source"); // 2 header << tr("Destination"); // 3 header << tr("Duration"); // 4 header << tr("Throughput\n(sender-receiver)"); // 5 header << tr("Protocol"); // 6 header << tr("SSS"); // 7 header << tr("RSS"); // 8 header << tr("SMS"); // 9 setHeaderLabels(header); hideColumn(1); hideColumn(6); hideColumn(7); hideColumn(8); hideColumn(9); } else if(type == Globals::PACKETS) { // packets QStringList header; header << tr("Test/Flow"); // 0 header << tr("Name"); // 1 header << tr("Source\n(IP/port)"); // 2 header << tr("Destination\n(IP/port)"); // 3 header << tr("Duration"); // 4 header << tr("Packet rate\n(packets/sec)"); // 5 header << tr("Packet size\n(bytes)"); // 6 header << tr("Pattern"); // 7 setHeaderLabels(header); hideColumn(1); hideColumn(7); } }
ConfRoomView::ConfRoomView(QWidget *parent, ConfRoomModel *model) : QTableView(parent) { setSortingEnabled(true); setModel(model); setShowGrid(0); verticalHeader()->hide(); horizontalHeader()->setMovable(true); horizontalHeader()->setStretchLastSection(true); int ActionCol[] = { ACTION_MUTE, ACTION_TALK_TO, ACTION_RECORD, ACTION_ALLOW_IN, ACTION_KICK }; for(int i = 0; i < nelem(ActionCol); i++) { setColumnWidth(ActionCol[i], 32); horizontalHeader()->setResizeMode(ActionCol[i], QHeaderView::Fixed); } setColumnWidth(ADMIN, 60); horizontalHeader()->setResizeMode(ADMIN, QHeaderView::Fixed); setStyleSheet("ConfListView {" "border: none;" "background:transparent;" "color:black;" "}"); hideColumn(0); connect(this, SIGNAL(clicked(const QModelIndex &)), this, SLOT(onViewClick(const QModelIndex &))); QHeaderView *h = horizontalHeader(); connect(h, SIGNAL(sectionClicked(int)), this, SLOT(sectionHeaderClicked(int))); }
int QTreeView::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QAbstractItemView::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: expanded((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 1: collapsed((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 2: hideColumn((*reinterpret_cast< int(*)>(_a[1]))); break; case 3: showColumn((*reinterpret_cast< int(*)>(_a[1]))); break; case 4: expand((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 5: collapse((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break; case 6: resizeColumnToContents((*reinterpret_cast< int(*)>(_a[1]))); break; case 7: sortByColumn((*reinterpret_cast< int(*)>(_a[1]))); break; case 8: expandAll(); break; case 9: collapseAll(); break; case 10: expandToDepth((*reinterpret_cast< int(*)>(_a[1]))); break; case 11: columnResized((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 12: columnCountChanged((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 13: columnMoved(); break; case 14: reexpand(); break; case 15: rowsRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break; case 16: d_func()->_q_endAnimatedOperation(); break; case 17: d_func()->_q_modelAboutToBeReset(); break; case 18: d_func()->_q_sortIndicatorChanged((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< Qt::SortOrder(*)>(_a[2]))); break; default: ; } _id -= 19; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< int*>(_v) = autoExpandDelay(); break; case 1: *reinterpret_cast< int*>(_v) = indentation(); break; case 2: *reinterpret_cast< bool*>(_v) = rootIsDecorated(); break; case 3: *reinterpret_cast< bool*>(_v) = uniformRowHeights(); break; case 4: *reinterpret_cast< bool*>(_v) = itemsExpandable(); break; case 5: *reinterpret_cast< bool*>(_v) = isSortingEnabled(); break; case 6: *reinterpret_cast< bool*>(_v) = isAnimated(); break; case 7: *reinterpret_cast< bool*>(_v) = allColumnsShowFocus(); break; case 8: *reinterpret_cast< bool*>(_v) = wordWrap(); break; case 9: *reinterpret_cast< bool*>(_v) = isHeaderHidden(); break; case 10: *reinterpret_cast< bool*>(_v) = expandsOnDoubleClick(); break; } _id -= 11; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setAutoExpandDelay(*reinterpret_cast< int*>(_v)); break; case 1: setIndentation(*reinterpret_cast< int*>(_v)); break; case 2: setRootIsDecorated(*reinterpret_cast< bool*>(_v)); break; case 3: setUniformRowHeights(*reinterpret_cast< bool*>(_v)); break; case 4: setItemsExpandable(*reinterpret_cast< bool*>(_v)); break; case 5: setSortingEnabled(*reinterpret_cast< bool*>(_v)); break; case 6: setAnimated(*reinterpret_cast< bool*>(_v)); break; case 7: setAllColumnsShowFocus(*reinterpret_cast< bool*>(_v)); break; case 8: setWordWrap(*reinterpret_cast< bool*>(_v)); break; case 9: setHeaderHidden(*reinterpret_cast< bool*>(_v)); break; case 10: setExpandsOnDoubleClick(*reinterpret_cast< bool*>(_v)); break; } _id -= 11; } else if (_c == QMetaObject::ResetProperty) { _id -= 11; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 11; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 11; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 11; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 11; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 11; } #endif // QT_NO_PROPERTIES return _id; }
CSVWorld::Table::Table (const CSMWorld::UniversalId& id, bool createAndDelete, bool sorting, CSMDoc::Document& document) : mCreateAction (0), mCloneAction(0), mRecordStatusDisplay (0), DragRecordTable(document) { mModel = &dynamic_cast<CSMWorld::IdTableBase&> (*mDocument.getData().getTableModel (id)); mProxyModel = new CSMWorld::IdTableProxyModel (this); mProxyModel->setSourceModel (mModel); mDispatcher = new CSMWorld::CommandDispatcher (document, id, this); setModel (mProxyModel); horizontalHeader()->setResizeMode (QHeaderView::Interactive); verticalHeader()->hide(); setSortingEnabled (sorting); setSelectionBehavior (QAbstractItemView::SelectRows); setSelectionMode (QAbstractItemView::ExtendedSelection); int columns = mModel->columnCount(); for (int i=0; i<columns; ++i) { int flags = mModel->headerData (i, Qt::Horizontal, CSMWorld::ColumnBase::Role_Flags).toInt(); if (flags & CSMWorld::ColumnBase::Flag_Table) { CSMWorld::ColumnBase::Display display = static_cast<CSMWorld::ColumnBase::Display> ( mModel->headerData (i, Qt::Horizontal, CSMWorld::ColumnBase::Role_Display).toInt()); CommandDelegate *delegate = CommandDelegateFactoryCollection::get().makeDelegate (display, mDocument, this); mDelegates.push_back (delegate); setItemDelegateForColumn (i, delegate); } else hideColumn (i); } mEditAction = new QAction (tr ("Edit Record"), this); connect (mEditAction, SIGNAL (triggered()), this, SLOT (editRecord())); addAction (mEditAction); if (createAndDelete) { mCreateAction = new QAction (tr ("Add Record"), this); connect (mCreateAction, SIGNAL (triggered()), this, SIGNAL (createRequest())); addAction (mCreateAction); mCloneAction = new QAction (tr ("Clone Record"), this); connect(mCloneAction, SIGNAL (triggered()), this, SLOT (cloneRecord())); addAction(mCloneAction); } mRevertAction = new QAction (tr ("Revert Record"), this); connect (mRevertAction, SIGNAL (triggered()), mDispatcher, SLOT (executeRevert())); addAction (mRevertAction); mDeleteAction = new QAction (tr ("Delete Record"), this); connect (mDeleteAction, SIGNAL (triggered()), mDispatcher, SLOT (executeDelete())); addAction (mDeleteAction); mMoveUpAction = new QAction (tr ("Move Up"), this); connect (mMoveUpAction, SIGNAL (triggered()), this, SLOT (moveUpRecord())); addAction (mMoveUpAction); mMoveDownAction = new QAction (tr ("Move Down"), this); connect (mMoveDownAction, SIGNAL (triggered()), this, SLOT (moveDownRecord())); addAction (mMoveDownAction); mViewAction = new QAction (tr ("View"), this); connect (mViewAction, SIGNAL (triggered()), this, SLOT (viewRecord())); addAction (mViewAction); mPreviewAction = new QAction (tr ("Preview"), this); connect (mPreviewAction, SIGNAL (triggered()), this, SLOT (previewRecord())); addAction (mPreviewAction); /// \todo add a user option, that redirects the extended action to an input panel (in /// the bottom bar) that lets the user select which record collections should be /// modified. mExtendedDeleteAction = new QAction (tr ("Extended Delete Record"), this); connect (mExtendedDeleteAction, SIGNAL (triggered()), mDispatcher, SLOT (executeExtendedDelete())); addAction (mExtendedDeleteAction); mExtendedRevertAction = new QAction (tr ("Extended Revert Record"), this); connect (mExtendedRevertAction, SIGNAL (triggered()), mDispatcher, SLOT (executeExtendedRevert())); addAction (mExtendedRevertAction); connect (mProxyModel, SIGNAL (rowsInserted (const QModelIndex&, int, int)), this, SLOT (tableSizeUpdate())); /// \note This signal could instead be connected to a slot that filters out changes not affecting /// the records status column (for permanence reasons) connect (mProxyModel, SIGNAL (dataChanged (const QModelIndex&, const QModelIndex&)), this, SLOT (tableSizeUpdate())); connect (selectionModel(), SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)), this, SLOT (selectionSizeUpdate ())); setAcceptDrops(true); }
CSVWorld::Table::Table (const CSMWorld::UniversalId& id, bool createAndDelete, bool sorting, CSMDoc::Document& document) : DragRecordTable(document), mCreateAction (0), mCloneAction(0),mRecordStatusDisplay (0) { CSMSettings::UserSettings &settings = CSMSettings::UserSettings::instance(); QString jumpSetting = settings.settingValue ("table-input/jump-to-added"); if (jumpSetting.isEmpty() || jumpSetting == "Jump and Select") // default { mJumpToAddedRecord = true; mUnselectAfterJump = false; } else if(jumpSetting == "Jump Only") { mJumpToAddedRecord = true; mUnselectAfterJump = true; } else { mJumpToAddedRecord = false; mUnselectAfterJump = false; } mModel = &dynamic_cast<CSMWorld::IdTableBase&> (*mDocument.getData().getTableModel (id)); bool isInfoTable = id.getType() == CSMWorld::UniversalId::Type_TopicInfos || id.getType() == CSMWorld::UniversalId::Type_JournalInfos; if (isInfoTable) { mProxyModel = new CSMWorld::InfoTableProxyModel(id.getType(), this); } else { mProxyModel = new CSMWorld::IdTableProxyModel (this); } mProxyModel->setSourceModel (mModel); mDispatcher = new CSMWorld::CommandDispatcher (document, id, this); setModel (mProxyModel); #if QT_VERSION >= QT_VERSION_CHECK(5,0,0) horizontalHeader()->setSectionResizeMode (QHeaderView::Interactive); #else horizontalHeader()->setResizeMode (QHeaderView::Interactive); #endif verticalHeader()->hide(); setSortingEnabled (sorting); setSelectionBehavior (QAbstractItemView::SelectRows); setSelectionMode (QAbstractItemView::ExtendedSelection); int columns = mModel->columnCount(); for (int i=0; i<columns; ++i) { int flags = mModel->headerData (i, Qt::Horizontal, CSMWorld::ColumnBase::Role_Flags).toInt(); if (flags & CSMWorld::ColumnBase::Flag_Table) { CSMWorld::ColumnBase::Display display = static_cast<CSMWorld::ColumnBase::Display> ( mModel->headerData (i, Qt::Horizontal, CSMWorld::ColumnBase::Role_Display).toInt()); CommandDelegate *delegate = CommandDelegateFactoryCollection::get().makeDelegate (display, mDispatcher, document, this); mDelegates.push_back (delegate); setItemDelegateForColumn (i, delegate); } else hideColumn (i); } mEditAction = new QAction (tr ("Edit Record"), this); connect (mEditAction, SIGNAL (triggered()), this, SLOT (editRecord())); addAction (mEditAction); if (createAndDelete) { mCreateAction = new QAction (tr ("Add Record"), this); connect (mCreateAction, SIGNAL (triggered()), this, SIGNAL (createRequest())); addAction (mCreateAction); mCloneAction = new QAction (tr ("Clone Record"), this); connect(mCloneAction, SIGNAL (triggered()), this, SLOT (cloneRecord())); addAction(mCloneAction); } mRevertAction = new QAction (tr ("Revert Record"), this); connect (mRevertAction, SIGNAL (triggered()), mDispatcher, SLOT (executeRevert())); addAction (mRevertAction); mDeleteAction = new QAction (tr ("Delete Record"), this); connect (mDeleteAction, SIGNAL (triggered()), mDispatcher, SLOT (executeDelete())); addAction (mDeleteAction); mMoveUpAction = new QAction (tr ("Move Up"), this); connect (mMoveUpAction, SIGNAL (triggered()), this, SLOT (moveUpRecord())); addAction (mMoveUpAction); mMoveDownAction = new QAction (tr ("Move Down"), this); connect (mMoveDownAction, SIGNAL (triggered()), this, SLOT (moveDownRecord())); addAction (mMoveDownAction); mEditCellAction = new QAction( tr("Edit Cell"), this ); connect( mEditCellAction, SIGNAL(triggered()), this, SLOT(editCell()) ); addAction( mEditCellAction ); mViewAction = new QAction (tr ("View"), this); connect (mViewAction, SIGNAL (triggered()), this, SLOT (viewRecord())); addAction (mViewAction); mPreviewAction = new QAction (tr ("Preview"), this); connect (mPreviewAction, SIGNAL (triggered()), this, SLOT (previewRecord())); addAction (mPreviewAction); /// \todo add a user option, that redirects the extended action to an input panel (in /// the bottom bar) that lets the user select which record collections should be /// modified. mExtendedDeleteAction = new QAction (tr ("Extended Delete Record"), this); connect (mExtendedDeleteAction, SIGNAL (triggered()), mDispatcher, SLOT (executeExtendedDelete())); addAction (mExtendedDeleteAction); mExtendedRevertAction = new QAction (tr ("Extended Revert Record"), this); connect (mExtendedRevertAction, SIGNAL (triggered()), mDispatcher, SLOT (executeExtendedRevert())); addAction (mExtendedRevertAction); connect (mProxyModel, SIGNAL (rowsRemoved (const QModelIndex&, int, int)), this, SLOT (tableSizeUpdate())); connect (mProxyModel, SIGNAL (rowsInserted (const QModelIndex&, int, int)), this, SLOT (rowsInsertedEvent(const QModelIndex&, int, int))); /// \note This signal could instead be connected to a slot that filters out changes not affecting /// the records status column (for permanence reasons) connect (mProxyModel, SIGNAL (dataChanged (const QModelIndex&, const QModelIndex&)), this, SLOT (tableSizeUpdate())); connect (selectionModel(), SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)), this, SLOT (selectionSizeUpdate ())); setAcceptDrops(true); mDoubleClickActions.insert (std::make_pair (Qt::NoModifier, Action_InPlaceEdit)); mDoubleClickActions.insert (std::make_pair (Qt::ShiftModifier, Action_EditRecord)); mDoubleClickActions.insert (std::make_pair (Qt::ControlModifier, Action_View)); mDoubleClickActions.insert (std::make_pair (Qt::ShiftModifier | Qt::ControlModifier, Action_EditRecordAndClose)); }
MainForm::MasterBuilds::MasterBuilds(QWidget *parent) :QTreeWidget(parent){ setColumnCount(2); hideColumn(1); }
PeerListWidget::PeerListWidget(PropertiesWidget *parent): QTreeView(parent), m_properties(parent), m_displayFlags(false) { // Load settings loadSettings(); // Visual settings setUniformRowHeights(true); setRootIsDecorated(false); setItemsExpandable(false); setAllColumnsShowFocus(true); setSelectionMode(QAbstractItemView::ExtendedSelection); // List Model m_listModel = new QStandardItemModel(0, PeerListDelegate::COL_COUNT); m_listModel->setHeaderData(PeerListDelegate::COUNTRY, Qt::Horizontal, QVariant()); // Country flag column m_listModel->setHeaderData(PeerListDelegate::IP, Qt::Horizontal, tr("IP")); m_listModel->setHeaderData(PeerListDelegate::PORT, Qt::Horizontal, tr("Port")); m_listModel->setHeaderData(PeerListDelegate::FLAGS, Qt::Horizontal, tr("Flags")); m_listModel->setHeaderData(PeerListDelegate::CONNECTION, Qt::Horizontal, tr("Connection")); m_listModel->setHeaderData(PeerListDelegate::CLIENT, Qt::Horizontal, tr("Client", "i.e.: Client application")); m_listModel->setHeaderData(PeerListDelegate::PROGRESS, Qt::Horizontal, tr("Progress", "i.e: % downloaded")); m_listModel->setHeaderData(PeerListDelegate::DOWN_SPEED, Qt::Horizontal, tr("Down Speed", "i.e: Download speed")); m_listModel->setHeaderData(PeerListDelegate::UP_SPEED, Qt::Horizontal, tr("Up Speed", "i.e: Upload speed")); m_listModel->setHeaderData(PeerListDelegate::TOT_DOWN, Qt::Horizontal, tr("Downloaded", "i.e: total data downloaded")); m_listModel->setHeaderData(PeerListDelegate::TOT_UP, Qt::Horizontal, tr("Uploaded", "i.e: total data uploaded")); m_listModel->setHeaderData(PeerListDelegate::RELEVANCE, Qt::Horizontal, tr("Relevance", "i.e: How relevant this peer is to us. How many pieces it has that we don't.")); // Proxy model to support sorting without actually altering the underlying model m_proxyModel = new PeerListSortModel(); m_proxyModel->setDynamicSortFilter(true); m_proxyModel->setSourceModel(m_listModel); m_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); setModel(m_proxyModel); //Explicitly set the column visibility. When columns are added/removed //between versions this prevents some of them being hidden due to //incorrect restoreState() being used. for (unsigned int i=0; i<PeerListDelegate::IP_HIDDEN; i++) showColumn(i); hideColumn(PeerListDelegate::IP_HIDDEN); hideColumn(PeerListDelegate::COL_COUNT); if (!Preferences::instance()->resolvePeerCountries()) hideColumn(PeerListDelegate::COUNTRY); //To also mitigate the above issue, we have to resize each column when //its size is 0, because explicitly 'showing' the column isn't enough //in the above scenario. for (unsigned int i=0; i<PeerListDelegate::IP_HIDDEN; i++) if (!columnWidth(i)) resizeColumnToContents(i); // Context menu setContextMenuPolicy(Qt::CustomContextMenu); connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showPeerListMenu(QPoint))); // List delegate m_listDelegate = new PeerListDelegate(this); setItemDelegate(m_listDelegate); // Enable sorting setSortingEnabled(true); // IP to Hostname resolver updatePeerHostNameResolutionState(); // SIGNAL/SLOT connect(header(), SIGNAL(sectionClicked(int)), SLOT(handleSortColumnChanged(int))); handleSortColumnChanged(header()->sortIndicatorSection()); copyHotkey = new QShortcut(QKeySequence(Qt::ControlModifier + Qt::Key_C), this, SLOT(copySelectedPeers()), 0, Qt::WidgetShortcut); }
bool TableView::addFile(const QString& alias, openstudio::SqlFile sqlFile) { if (alias.isEmpty() || !sqlFile.connectionOpen()) return false; setSortingEnabled(false); detail::DataDictionaryTable ddTable = sqlFile.dataDictionary(); detail::DataDictionaryTable::iterator iter; for (iter=ddTable.begin();iter!=ddTable.end();++iter) { // skip runPeriod if (sqlFile.reportingFrequencyFromDB((*iter).reportingFrequency) && *(sqlFile.reportingFrequencyFromDB((*iter).reportingFrequency)) != ReportingFrequency::RunPeriod) { int row = addRow(); item(row, m_slHeaders.indexOf("Alias"))->setText(alias); item(row, m_slHeaders.indexOf("File"))->setText(openstudio::toQString(sqlFile.energyPlusSqliteFile())); item(row, m_slHeaders.indexOf("Environment Period"))->setText(openstudio::toQString((*iter).envPeriod)); item(row, m_slHeaders.indexOf("Reporting Frequency"))->setText(openstudio::toQString((*iter).reportingFrequency)); item(row, m_slHeaders.indexOf("Key Value"))->setText(openstudio::toQString((*iter).keyValue)); item(row, m_slHeaders.indexOf("Variable Name"))->setText(openstudio::toQString((*iter).name)); item(row, m_slHeaders.indexOf("File"))->setData(Qt::UserRole, RVD_TIMESERIES); } // end skip runPeriod } /* illuminance maps */ std::vector<std::string> mapNames(sqlFile.illuminanceMapNames()); std::vector<std::string>::iterator nameIter; for (nameIter=mapNames.begin(); nameIter!=mapNames.end(); ++nameIter) { // retrieve mapIndex for map name to retrieve environment period and zone name QString envPeriod = ""; QString keyValue = ""; boost::optional<int> mapIndex = sqlFile.illuminanceMapIndex(*nameIter); if (mapIndex) { boost::optional<std::string> strValue; boost::optional<int> intValue; std::stringstream s; s << "select Environment from daylightmaps where MapNumber=" << *mapIndex; strValue = sqlFile.execAndReturnFirstString(s.str()); if (strValue) envPeriod = openstudio::toQString(*strValue); s.str(""); s << "select Zone from daylightmaps where MapNumber=" << *mapIndex; intValue = sqlFile.execAndReturnFirstInt(s.str()); if (intValue) { s.str(""); s << "select ZoneName from zones where ZoneIndex=" << *intValue; strValue = sqlFile.execAndReturnFirstString(s.str()); if (strValue) keyValue = openstudio::toQString(*strValue); } } int row = addRow(); item(row, m_slHeaders.indexOf("Alias"))->setText(alias); item(row, m_slHeaders.indexOf("File"))->setText(openstudio::toQString(sqlFile.energyPlusSqliteFile())); item(row, m_slHeaders.indexOf("Environment Period"))->setText(envPeriod); // environment period /* update based on email from Dan 8/10/10 item(row, 3)->setText("Illuminance"); // reporting frequency item(row, 4)->setText(keyValue); // illuminance zone? item(row, 5)->setText(openstudio::toQString(*nameIter)); */ item(row, m_slHeaders.indexOf("Reporting Frequency"))->setText("Hourly"); // reporting frequency item(row, m_slHeaders.indexOf("Key Value"))->setText(keyValue); // illuminance zone item(row, m_slHeaders.indexOf("Variable Name"))->setText("Illuminance Map"); // Variable Name item(row, m_slHeaders.indexOf("File"))->setData(Qt::UserRole, RVD_ILLUMINANCEMAP); item(row, m_slHeaders.indexOf("Alias"))->setData(Qt::UserRole, openstudio::toQString(*nameIter)); // map name for retrieving from database } resizeColumnToContents(m_slHeaders.indexOf("Alias")); hideColumn(m_slHeaders.indexOf("File")); resizeColumnToContents(m_slHeaders.indexOf("Variable Name")); resizeColumnToContents(m_slHeaders.indexOf("Key Value")); resizeColumnToContents(m_slHeaders.indexOf("Reporting Frequency")); // resizeColumnToContents(5); setSortingEnabled(true); emit( fileAdded() ); return true; }
CSVWorld::Table::Table (const CSMWorld::UniversalId& id, CSMWorld::Data& data, QUndoStack& undoStack, bool createAndDelete) : mUndoStack (undoStack), mCreateAction (0), mEditLock (false), mRecordStatusDisplay (0) { mModel = &dynamic_cast<CSMWorld::IdTable&> (*data.getTableModel (id)); mProxyModel = new CSMWorld::IdTableProxyModel (this); mProxyModel->setSourceModel (mModel); setModel (mProxyModel); horizontalHeader()->setResizeMode (QHeaderView::Interactive); verticalHeader()->hide(); setSortingEnabled (true); setSelectionBehavior (QAbstractItemView::SelectRows); setSelectionMode (QAbstractItemView::ExtendedSelection); int columns = mModel->columnCount(); for (int i=0; i<columns; ++i) { int flags = mModel->headerData (i, Qt::Horizontal, CSMWorld::ColumnBase::Role_Flags).toInt(); if (flags & CSMWorld::ColumnBase::Flag_Table) { CSMWorld::ColumnBase::Display display = static_cast<CSMWorld::ColumnBase::Display> ( mModel->headerData (i, Qt::Horizontal, CSMWorld::ColumnBase::Role_Display).toInt()); CommandDelegate *delegate = CommandDelegateFactoryCollection::get().makeDelegate (display, undoStack, this); mDelegates.push_back (delegate); setItemDelegateForColumn (i, delegate); } else hideColumn (i); } mEditAction = new QAction (tr ("Edit Record"), this); connect (mEditAction, SIGNAL (triggered()), this, SLOT (editRecord())); addAction (mEditAction); if (createAndDelete) { mCreateAction = new QAction (tr ("Add Record"), this); connect (mCreateAction, SIGNAL (triggered()), this, SIGNAL (createRequest())); addAction (mCreateAction); } mRevertAction = new QAction (tr ("Revert Record"), this); connect (mRevertAction, SIGNAL (triggered()), this, SLOT (revertRecord())); addAction (mRevertAction); mDeleteAction = new QAction (tr ("Delete Record"), this); connect (mDeleteAction, SIGNAL (triggered()), this, SLOT (deleteRecord())); addAction (mDeleteAction); connect (mProxyModel, SIGNAL (rowsInserted (const QModelIndex&, int, int)), this, SLOT (tableSizeUpdate())); /// \note This signal could instead be connected to a slot that filters out changes not affecting /// the records status column (for permanence reasons) connect (mProxyModel, SIGNAL (dataChanged (const QModelIndex&, const QModelIndex&)), this, SLOT (tableSizeUpdate())); connect (selectionModel(), SIGNAL (selectionChanged (const QItemSelection&, const QItemSelection&)), this, SLOT (selectionSizeUpdate ())); }
bool QTable::qt_invoke( int _id, QUObject* _o ) { switch ( _id - staticMetaObject()->slotOffset() ) { case 0: setNumRows((int)static_QUType_int.get(_o+1)); break; case 1: setNumCols((int)static_QUType_int.get(_o+1)); break; case 2: setShowGrid((bool)static_QUType_bool.get(_o+1)); break; case 3: hideRow((int)static_QUType_int.get(_o+1)); break; case 4: hideColumn((int)static_QUType_int.get(_o+1)); break; case 5: showRow((int)static_QUType_int.get(_o+1)); break; case 6: showColumn((int)static_QUType_int.get(_o+1)); break; case 7: static_QUType_bool.set(_o,isRowHidden((int)static_QUType_int.get(_o+1))); break; case 8: static_QUType_bool.set(_o,isColumnHidden((int)static_QUType_int.get(_o+1))); break; case 9: setColumnWidth((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break; case 10: setRowHeight((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break; case 11: adjustColumn((int)static_QUType_int.get(_o+1)); break; case 12: adjustRow((int)static_QUType_int.get(_o+1)); break; case 13: setColumnStretchable((int)static_QUType_int.get(_o+1),(bool)static_QUType_bool.get(_o+2)); break; case 14: setRowStretchable((int)static_QUType_int.get(_o+1),(bool)static_QUType_bool.get(_o+2)); break; case 15: static_QUType_bool.set(_o,isColumnStretchable((int)static_QUType_int.get(_o+1))); break; case 16: static_QUType_bool.set(_o,isRowStretchable((int)static_QUType_int.get(_o+1))); break; case 17: setSorting((bool)static_QUType_bool.get(_o+1)); break; case 18: swapRows((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break; case 19: swapRows((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(bool)static_QUType_bool.get(_o+3)); break; case 20: swapColumns((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break; case 21: swapColumns((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(bool)static_QUType_bool.get(_o+3)); break; case 22: swapCells((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(int)static_QUType_int.get(_o+3),(int)static_QUType_int.get(_o+4)); break; case 23: setLeftMargin((int)static_QUType_int.get(_o+1)); break; case 24: setTopMargin((int)static_QUType_int.get(_o+1)); break; case 25: setCurrentCell((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break; case 26: clearSelection(); break; case 27: clearSelection((bool)static_QUType_bool.get(_o+1)); break; case 28: setColumnMovingEnabled((bool)static_QUType_bool.get(_o+1)); break; case 29: setRowMovingEnabled((bool)static_QUType_bool.get(_o+1)); break; case 30: setReadOnly((bool)static_QUType_bool.get(_o+1)); break; case 31: setRowReadOnly((int)static_QUType_int.get(_o+1),(bool)static_QUType_bool.get(_o+2)); break; case 32: setColumnReadOnly((int)static_QUType_int.get(_o+1),(bool)static_QUType_bool.get(_o+2)); break; case 33: setDragEnabled((bool)static_QUType_bool.get(_o+1)); break; case 34: static_QUType_bool.set(_o,dragEnabled()); break; case 35: insertRows((int)static_QUType_int.get(_o+1)); break; case 36: insertRows((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break; case 37: insertColumns((int)static_QUType_int.get(_o+1)); break; case 38: insertColumns((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break; case 39: removeRow((int)static_QUType_int.get(_o+1)); break; case 40: removeRows((const QMemArray<int>&)*((const QMemArray<int>*)static_QUType_ptr.get(_o+1))); break; case 41: removeColumn((int)static_QUType_int.get(_o+1)); break; case 42: removeColumns((const QMemArray<int>&)*((const QMemArray<int>*)static_QUType_ptr.get(_o+1))); break; case 43: editCell((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break; case 44: editCell((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(bool)static_QUType_bool.get(_o+3)); break; case 45: setRowLabels((const QStringList&)*((const QStringList*)static_QUType_ptr.get(_o+1))); break; case 46: setColumnLabels((const QStringList&)*((const QStringList*)static_QUType_ptr.get(_o+1))); break; case 47: columnWidthChanged((int)static_QUType_int.get(_o+1)); break; case 48: rowHeightChanged((int)static_QUType_int.get(_o+1)); break; case 49: columnIndexChanged((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(int)static_QUType_int.get(_o+3)); break; case 50: rowIndexChanged((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(int)static_QUType_int.get(_o+3)); break; case 51: columnClicked((int)static_QUType_int.get(_o+1)); break; case 52: doAutoScroll(); break; case 53: doValueChanged(); break; case 54: updateGeometriesSlot(); break; default: return QScrollView::qt_invoke( _id, _o ); } return TRUE; }