void ReceiveCoinsDialog::setModel(WalletModel *_model) { this->model = _model; if(_model && _model->getOptionsModel()) { _model->getRecentRequestsTableModel()->sort(RecentRequestsTableModel::Date, Qt::DescendingOrder); connect(_model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit())); updateDisplayUnit(); QTableView* tableView = ui->recentRequestsView; tableView->verticalHeader()->hide(); tableView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); tableView->setModel(_model->getRecentRequestsTableModel()); // tableView->setAlternatingRowColors(true); tableView->setSelectionBehavior(QAbstractItemView::SelectRows); tableView->setSelectionMode(QAbstractItemView::ContiguousSelection); tableView->setColumnWidth(RecentRequestsTableModel::Date, DATE_COLUMN_WIDTH); tableView->setColumnWidth(RecentRequestsTableModel::Label, LABEL_COLUMN_WIDTH); tableView->setColumnWidth(RecentRequestsTableModel::Amount, AMOUNT_MINIMUM_COLUMN_WIDTH); tableView->setGridStyle(Qt::NoPen); QHeaderView * verticalHeader = tableView->verticalHeader(); verticalHeader->setDefaultSectionSize(57); tableView->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter); connect(tableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection, QItemSelection)), this, SLOT(recentRequestsView_selectionChanged(QItemSelection, QItemSelection))); // Last 2 columns are set by the columnResizingFixer, when the table geometry is ready. columnResizingFixer = new GUIUtil::TableViewLastColumnResizingFixer(tableView, AMOUNT_MINIMUM_COLUMN_WIDTH, DATE_COLUMN_WIDTH, this); }
BoardView::BoardView(QWidget *parent) :QTableView(parent) { QHeaderView *hHeader = horizontalHeader(); hHeader->setResizeMode(QHeaderView::Fixed); hHeader->setDefaultAlignment( Qt::AlignHCenter ); hHeader->setDefaultSectionSize(50); hHeader->setClickable(false); hHeader->setMovable(false); QHeaderView *vHeader = verticalHeader(); vHeader->setResizeMode(QHeaderView::Fixed); vHeader->setDefaultAlignment( Qt::AlignVCenter ); vHeader->setDefaultSectionSize(50); vHeader->setClickable(false); vHeader->setMovable(false); setSelectionMode(QAbstractItemView::SingleSelection); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setItemDelegate(new BoardDelegate(this)); setStyleSheet("QHeaderView::section {background-color: #ffffe7; border: 1px solid #74440e; color: black; }" "QTableCornerButton::section { background-color: #ffffe7; border: 1px solid #74440e; color: black; }" "QToolTip { background-color: #ffeeaf; padding: 2px; border: 1px solid #74440e; }"); }
pTableWidget::pTableWidget(QWidget *parent) : QTableWidget(parent), m_defaultSortedColumn(0) { setSortingEnabled(true); QHeaderView *header; // Horizontal header header = horizontalHeader(); header->setHighlightSections(false); header->setSortIndicatorShown(false); header->setDefaultSectionSize(50); header->show(); // Vertical header header = verticalHeader(); header->setDefaultSectionSize(21); header->hide(); // Frame //setFrameStyle(QFrame::NoFrame); setSelectionMode(QAbstractItemView::SingleSelection); setSelectionBehavior(QAbstractItemView::SelectRows); setEditTriggers(QAbstractItemView::NoEditTriggers); setAlternatingRowColors(true); setContextMenuPolicy(Qt::CustomContextMenu); connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint))); connect(horizontalHeader(), SIGNAL(sectionClicked(int)), this, SLOT(updateToolButtonNumber())); }
void amyFolderView::SetFolder(amyKeeper<amyDCMFolder> folder) { for(int i=0;i<m_PatientViewArr.size();i++) { delete m_PatientViewArr[i]; } m_Folder=folder; m_PatientViewArr.clear(); this->clear(); this->setTabPosition(QTabWidget::West); for(int i=0;i<folder->GetPatientArr().size();i++) { amyPatient::Keeper pat=folder->GetPatientArr()[i]; amyPatientTable *view=new amyPatientTable(pat.GetPointer()); QHeaderView* verticalHeader = view->verticalHeader(); verticalHeader->setResizeMode(QHeaderView::Fixed); verticalHeader->setDefaultSectionSize(64); QHeaderView* horizontalHeader = view->horizontalHeader(); horizontalHeader->hide(); horizontalHeader->setResizeMode(QHeaderView::Fixed); horizontalHeader->setDefaultSectionSize(150);; this->addTab(view,pat->info->name.c_str()); m_PatientViewArr.push_back(view); } }
void MantidMatrix::connectTableView(QTableView *view, MantidMatrixModel *model) { view->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); view->setSelectionMode(QAbstractItemView::ExtendedSelection); view->setModel(model); view->setCornerButtonEnabled(false); view->setFocusPolicy(Qt::StrongFocus); QPalette pal = view->palette(); pal.setColor(QPalette::Base, m_bk_color); view->setPalette(pal); // set header properties QHeaderView *hHeader = (QHeaderView *)view->horizontalHeader(); hHeader->setMovable(false); hHeader->setResizeMode(QHeaderView::Interactive); hHeader->setDefaultSectionSize(m_column_width); view->resizeRowToContents(0); int row_height = view->rowHeight(0); QHeaderView *vHeader = (QHeaderView *)view->verticalHeader(); vHeader->setDefaultSectionSize(row_height); vHeader->setResizeMode(QHeaderView::Fixed); vHeader->setMovable(false); }
TEventsLog::TEventsLog(QWidget *obj_MainWindow) : QWidget(obj_MainWindow) { this->obj_MainWindow=obj_MainWindow; QVBoxLayout *EventsList_IntLayout = new QVBoxLayout(); setLayout(EventsList_IntLayout); EventsList_TableView=new xTableView(this); #ifdef __i386__ EventsList_TableView->setMinimumHeight(300); EventsList_TableView->setMinimumWidth(600); #endif EventsList_IntLayout->addWidget(EventsList_TableView); EventsList_TableView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); EventsList_TableView->setStyleSheet(xTableViewStyleSheet); EventsList_TableView->verticalHeader()->setVisible(false); //EventsList_TableView->setShowGrid(false); QHeaderView *verticalHeader = EventsList_TableView->verticalHeader(); #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) verticalHeader->sectionResizeMode(QHeaderView::Fixed); #else verticalHeader->setResizeMode(QHeaderView::Fixed); #endif verticalHeader->setDefaultSectionSize(60); EventsList_TableView->setModel(&EventsList_Model); EventsList_TableView->setItemDelegate(new EventsList_ItemDelegate()); #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) EventsList_TableView->verticalHeader()->setDefaultAlignment(Qt::AlignVCenter|Qt::AlignRight); #endif Retranslate(); OscIndex=0; Load(); }
void Matrix::initTableView() { d_table_view = new QTableView(); d_table_view->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); d_table_view->setSelectionMode(QAbstractItemView::ContiguousSelection);// only one contiguous selection supported d_table_view->setModel(d_matrix_model); d_table_view->setEditTriggers(QAbstractItemView::DoubleClicked); d_table_view->setFocusPolicy(Qt::StrongFocus); d_table_view->setFocus(); QPalette pal = d_table_view->palette(); pal.setColor(QColorGroup::Base, QColor(255, 255, 128)); d_table_view->setPalette(pal); // set header properties QHeaderView* hHeader = (QHeaderView*)d_table_view->horizontalHeader(); hHeader->setMovable(false); hHeader->setResizeMode(QHeaderView::Fixed); hHeader->setDefaultSectionSize(d_column_width); int cols = numCols(); for(int i=0; i<cols; i++) d_table_view->setColumnWidth(i, d_column_width); QHeaderView* vHeader = (QHeaderView*)d_table_view->verticalHeader(); vHeader->setMovable(false); vHeader->setResizeMode(QHeaderView::ResizeToContents); d_stack->addWidget(d_table_view); // recreate keyboard shortcut d_select_all_shortcut = new QShortcut(QKeySequence(tr("Ctrl+A", "Matrix: select all")), this); connect(d_select_all_shortcut, SIGNAL(activated()), d_table_view, SLOT(selectAll())); }
TransitionEditorWindow::TransitionEditorWindow(QWidget* parent) : QWidget(parent) , ui_(new Ui::TransitionEditorWindow) , special_(false) , model_(nullptr) , transition_(nullptr) , transitionType_(TRMControlModel::Transition::TYPE_INVALID) { ui_->setupUi(this); ui_->transitionTypeComboBox->addItem(typeNames[2], 2); ui_->transitionTypeComboBox->addItem(typeNames[3], 3); ui_->transitionTypeComboBox->addItem(typeNames[4], 4); ui_->equationsTree->setColumnCount(NUM_EQUATIONS_TREE_COLUMNS); ui_->equationsTree->setHeaderLabels(QStringList() << tr("Equation")); QFontMetrics fm = fontMetrics(); int rowHeight = fm.height() + fm.ascent(); QHeaderView* vHeader = ui_->pointsTable->verticalHeader(); #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) vHeader->setSectionResizeMode(QHeaderView::Fixed); #else vHeader->setResizeMode(QHeaderView::Fixed); #endif vHeader->setDefaultSectionSize(rowHeight); ui_->pointsTable->setColumnCount(NUM_POINTS_TABLE_COLUMNS); ui_->pointsTable->setHorizontalHeaderLabels(QStringList() << tr("Type") << tr("Value") << tr("Is phantom?") << tr("Has slope?") << tr("Slope") << tr("Time")); //ui_->pointsTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch); // QDoubleValidator* validator = new QDoubleValidator(0.0, 1000.0, 1, this); // validator->setNotation(QDoubleValidator::StandardNotation); // ui_->ruleDurationLineEdit->setValidator(validator); // ui_->beatLineEdit->setValidator(validator); // ui_->mark1LineEdit->setValidator(validator); // ui_->mark2LineEdit->setValidator(validator); // ui_->mark3LineEdit->setValidator(validator); ui_->ruleDurationSpinBox->setRange(PARAMETERS_MIN, PARAMETERS_MAX); ui_->ruleDurationSpinBox->setDecimals(PARAMETERS_DECIMALS); ui_->beatSpinBox->setRange(PARAMETERS_MIN, PARAMETERS_MAX); ui_->beatSpinBox->setDecimals(PARAMETERS_DECIMALS); ui_->mark1SpinBox->setRange(PARAMETERS_MIN, PARAMETERS_MAX); ui_->mark1SpinBox->setDecimals(PARAMETERS_DECIMALS); ui_->mark2SpinBox->setRange(PARAMETERS_MIN, PARAMETERS_MAX); ui_->mark2SpinBox->setDecimals(PARAMETERS_DECIMALS); ui_->mark3SpinBox->setRange(PARAMETERS_MIN, PARAMETERS_MAX); ui_->mark3SpinBox->setDecimals(PARAMETERS_DECIMALS); connect(ui_->transitionWidget, SIGNAL(pointCreationRequested(unsigned int, float, float)), this, SLOT(createPoint(unsigned int, float, float))); }
PowerManagementRecordGui::PowerManagementRecordGui(SerialPort* p, QWidget* parent) : QDialog(parent) { socket = p; #else PowerManagementRecordGui::PowerManagementRecordGui(QTcpSocket* tcpSocket, QWidget* parent) : QDialog(parent) { socket = tcpSocket; #endif PowerManagementRecordUi.setupUi(this); requestRecordingStatus(); // Ask for the microcontroller SD card free space (process response later) getFreeSpace(); model = new QStandardItemModel(0, 2, this); PowerManagementRecordUi.fileTableView->setModel(model); PowerManagementRecordUi.fileTableView->setGridStyle(Qt::NoPen); PowerManagementRecordUi.fileTableView->setShowGrid(false); QHeaderView *verticalHeader = PowerManagementRecordUi.fileTableView->verticalHeader(); verticalHeader->setResizeMode(QHeaderView::Fixed); verticalHeader->setDefaultSectionSize(18); row = 0; // Signal to process a click on a directory item connect(PowerManagementRecordUi.fileTableView, SIGNAL(clicked(const QModelIndex)), this,SLOT(onListItemClicked(const QModelIndex))); // Send a command to refresh the directory refreshDirectory(); writeFileHandle = 0xFF; } PowerManagementRecordGui::~PowerManagementRecordGui() { } //----------------------------------------------------------------------------- /** @brief Delete File. If the delete checkbox is selected, delete the file (if it exists). */ void PowerManagementRecordGui::on_deleteButton_clicked() { QString fileName = PowerManagementRecordUi.recordFileName->text(); if ((fileName.length() > 0) && (PowerManagementRecordUi.deleteCheckBox->isChecked())) { socket->write("fX"); socket->write(fileName.toLocal8Bit().data()); socket->write("\n\r"); refreshDirectory(); getFreeSpace(); } }
void MainWindow::loadSoup() { if(this->soupLoaded){ delete this->soup; } this->soup = new QTableWidget(this->logical->size,this->logical->size,this); for(int i = 0; i<this->logical->size; i++) { for(int z = 0; z<this->logical->size; z++) { QTableWidgetItem *t = new QTableWidgetItem(this->logical->logicalSoup[i][z]); this->soup->setItem(i,z,t); } } QHeaderView *viewH; QHeaderView *viewV; viewH = new QHeaderView(Qt::Horizontal); viewV = new QHeaderView(Qt::Vertical); viewH->setDefaultSectionSize(15); viewV->setDefaultSectionSize(15); viewH->setVisible(false); viewV->setVisible(false); this->soup->setHorizontalHeader(viewH); this->soup->setVerticalHeader(viewV); this->ui->gridLayout->addWidget(this->soup); this->soupLoaded = true; }
void LoginWindow::initializeTable() { // table QHeaderView* header = this->ui->lastInvoiceTableWidget->horizontalHeader(); header->setSectionResizeMode(QHeaderView::Fixed); this->ui->lastInvoiceTableWidget->setColumnCount(4); header->setDefaultSectionSize(80); translateTable(); Uint32 column = 0; this->ui->lastInvoiceTableWidget->setColumnWidth(column++, 170); this->ui->lastInvoiceTableWidget->setColumnWidth(column++, 90); this->ui->lastInvoiceTableWidget->setColumnWidth(column++, 50); this->ui->lastInvoiceTableWidget->setColumnWidth(column++, 90); }
// Initialize CL, load contacts from database and setup table void MainWindow::initContactsList() { if(contactsDb.open()) { contactsModel = new ContactsListModel(this, contactsDb); contactsModel->setTable("contacts"); contactsModel->select(); ui->contactsList->setModel(contactsModel); ui->contactsList->hideColumn(ContactProto); ui->contactsList->hideColumn(ContactLogin); QHeaderView *vHeader = ui->contactsList->verticalHeader(); vHeader->setDefaultSectionSize(20); ui->contactsList->setContentsMargins(QMargins(0,0,0,0)); } }
void DialogProvinceDetails::SetProvinceItem( ProvinceItem * val ) { if( val == nullptr ) { return; } ui.lineEditID->setText( QString().setNum(val->GetID()) ); ui.lineEditName->setText( val->GetName() ); ui.listWidget->setSortingEnabled(true); ui.listWidget->setRowCount( val->GetItemMap().size() ); ui.listWidget->setColumnCount( 2 ); QHeaderView *verticalHeader = ui.listWidget->verticalHeader(); verticalHeader->setSectionResizeMode(QHeaderView::Fixed); verticalHeader->setDefaultSectionSize(20); int columnIndex = 0; ui.listWidget->verticalHeader()->setVisible(false); ui.listWidget->setSelectionBehavior(QAbstractItemView::SelectRows); QTableWidgetItem *id = new QTableWidgetItem("Name"); id->setBackground(Qt::lightGray); ui.listWidget->setHorizontalHeaderItem( columnIndex++, id ); QTableWidgetItem *provinces = new QTableWidgetItem("Wert"); provinces->setBackground(Qt::lightGray); ui.listWidget->setHorizontalHeaderItem( columnIndex++, provinces ); int rowIndex = 0; QMap<QString,ItemData>::ConstIterator iter; for( iter = val->GetItemMap().constBegin(); iter != val->GetItemMap().constEnd(); iter++ ) { int columnIndex = 0; ui.listWidget->setItem(rowIndex, columnIndex++, new QTableWidgetItem(iter->GetName()) ); ui.listWidget->item(rowIndex,0)->setTextAlignment(Qt::AlignCenter); ui.listWidget->setItem(rowIndex, columnIndex++, new QTableWidgetItem( iter->GetData().type() == QVariant::StringList ? iter->GetData().toStringList().join(",") : iter->GetData().toString() ) ); rowIndex++; } }
//----------------------------------------------------------------------------- //! //----------------------------------------------------------------------------- void tWorkProfilesDialog::Init() { QSize iconSize( 68, 68 ); m_pProfilesTable = new tTableWidget( 0, eColumnCount, this ); m_pProfilesTable->setFrameShape( QFrame::NoFrame ); m_pProfilesTable->SetSoleFocus( true ); m_pProfilesTable->SetWrapping( false ); QHeaderView* pHorizontalHeaderView = m_pProfilesTable->horizontalHeader(); pHorizontalHeaderView->setClickable( false ); pHorizontalHeaderView->resizeSection( eIconColumn, iconSize.width() ); pHorizontalHeaderView->setResizeMode( eNameColumn, QHeaderView::Stretch ); QString nameString = QString( tr( "Name" ) ); QSize headerTextSize = pHorizontalHeaderView->fontMetrics().size( 0, nameString ); int w = headerTextSize.width() + 10; pHorizontalHeaderView->resizeSection( eNameColumn, w ); QStringList headings; headings << "" << nameString << tr( "Enabled" ) << tr( "Active" ); m_pProfilesTable->setHorizontalHeaderLabels( headings ); pHorizontalHeaderView->setDefaultAlignment( Qt::AlignLeft ); QHeaderView* pVerticalHeaderView = m_pProfilesTable->verticalHeader(); pVerticalHeaderView->hide(); pVerticalHeaderView->setResizeMode( QHeaderView::Fixed ); pVerticalHeaderView->setDefaultSectionSize( iconSize.height() ); QVBoxLayout* pVLayout = new QVBoxLayout( this ); pVLayout->setContentsMargins( 0, 0, 0, 0 ); pVLayout->addWidget( m_pProfilesTable ); setLayout( pVLayout ); UpdateTable(); m_pProfilesTable->selectRow( m_ProfileIndex ); }
void TableView::setConfig() { scroolWidth = 16; this->setFrameStyle(0); QHeaderView *headerV = new QHeaderView(Qt::Vertical); headerV->setDefaultSectionSize(22); headerV->setVisible(false); this->setVerticalHeader(headerV); this->setSelectionMode(SingleSelection); this->setSelectionBehavior(SelectRows); this->setAlternatingRowColors(true); this->setEditTriggers(NoEditTriggers); this->setSortingEnabled(false); this->setFrameStyle(0); }
void Graficadora::llenarTabla(QMap<int, double> tablita) { this->table->clear(); int De = this->ui->le_De->text().toInt(); int A = this->ui->le_A->text().toInt(); int fila = 0; int columna = 0; QHeaderView *view = new QHeaderView(Qt::Horizontal); this->table->setRowCount((A-De)+1); this->table->setColumnCount(2); view->setDefaultSectionSize(60); view->setVisible(false); this->table->setHorizontalHeader(view); QHeaderView *vview = new QHeaderView(Qt::Vertical); vview->setVisible(false); this->table->setVerticalHeader(vview); for(int i = De; i<=A; i++) { columna = 0; QTableWidgetItem * y = new QTableWidgetItem(QString().setNum(tablita.value(i))); QTableWidgetItem * x = new QTableWidgetItem(QString().setNum(i)); this->table->setItem(fila,columna++,x); this->table->setItem(fila++,columna,y); } }
MyTableView* MainWindow::createTableView(TableModel* model) { MyTableView* retval = new MyTableView(); retval->setWindowTitle(model->getTitle()); retval->setObjectName(model->getTitle()); retval->setModel(model); retval->setTabKeyNavigation(true); connect(retval, &MyTableView::copyToClipboard, model, &TableModel::onCopyToClipboard); connect(retval, &MyTableView::pasteFromClipboard, model, &TableModel::onPasteFromClipboard); QFontMetrics metric(retval->font()); int textLineHeight = metric.lineSpacing()* 1.2; QHeaderView *verticalHeader = retval->verticalHeader(); verticalHeader->setSectionResizeMode(QHeaderView::Fixed); verticalHeader->setDefaultSectionSize(textLineHeight); this->addAsDockWidget(retval); return retval; }
int main( int argc, char* argv[] ) { QApplication app( argc, argv ); QTableWidget* tv = new QTableWidget(); tv->setRowCount( 1440 ); tv->setColumnCount( 3 ); tv->setShowGrid( false ); QHeaderView* vh = tv->verticalHeader(); vh->sectionResizeMode( QHeaderView::Fixed ); vh->setDefaultSectionSize( 4 ); QLabel* lbl = new QLabel( "abc" ); tv->setCellWidget( 1, 1, lbl ); tv->setSpan( 1, 1, 10, 1 ); tv->show(); app.exec(); }
void PreferenceDialog::chooseFont() { bool ok; QFont font; QLabel *label = NULL; if (sender() == ui->chooseViewerFont) { font = ui->viewerSample->font(); } else if (sender() == ui->chooseBoxFont) { font = ui->sampleEdit->font(); } else if (sender() == ui->chooseViewFont) { font = m_model.font(); } font = QFontDialog::getFont(&ok, font, this); if (sender() == ui->chooseViewerFont) { ui->viewerSample->setFont(font); label = ui->viewerFont; } else if (sender() == ui->chooseBoxFont) { ui->sampleEdit->setFont(font); label = ui->boxFont; } else if (sender() == ui->chooseViewFont) { QHeaderView *header = ui->sampleTable->verticalHeader(); header->setDefaultSectionSize(QFontMetrics(font).height() * 1.5); ui->sampleTable->setMinimumHeight(header->sectionSize(0) * 5); ui->sampleTable->setMaximumHeight(ui->sampleTable->minimumHeight() + 2); m_model.setFont(font); m_model.update(); label = ui->viewFont; } label->setText(tr("%1, %2pt").arg(font.family()).arg(font.pointSize())); }
// Settlers. void qtractorMidiEventListView::setEditor ( qtractorMidiEditor *pEditor ) { if (m_pItemDelegate) delete m_pItemDelegate; if (m_pListModel) delete m_pListModel; m_pListModel = new qtractorMidiEventListModel(pEditor); m_pItemDelegate = new qtractorMidiEventItemDelegate(); QTreeView::setModel(m_pListModel); QTreeView::setItemDelegate(m_pItemDelegate); QTreeView::setSelectionMode(QAbstractItemView::ExtendedSelection); QTreeView::setRootIsDecorated(false); QTreeView::setUniformRowHeights(true); QTreeView::setItemsExpandable(false); QTreeView::setAllColumnsShowFocus(true); QTreeView::setAlternatingRowColors(true); QHeaderView *pHeader = QTreeView::header(); // pHeader->setDefaultAlignment(Qt::AlignLeft); pHeader->setDefaultSectionSize(80); #if QT_VERSION >= 0x050000 // pHeader->setSectionResizeMode(QHeaderView::Custom); pHeader->setSectionResizeMode(QHeaderView::ResizeToContents); pHeader->setSectionsMovable(false); #else // pHeader->setResizeMode(QHeaderView::Custom); pHeader->setResizeMode(QHeaderView::ResizeToContents); pHeader->setMovable(false); #endif pHeader->resizeSection(2, 60); // Name pHeader->resizeSection(3, 40); // Value pHeader->setStretchLastSection(true); }
void PreferenceDialog::loadAppearance(QSettings &settings, bool import) { QPalette palette; QColor color; QFont font; //>>>> アドレスボックス palette = QPalette(); // 背景色 color = settings.value(IniKey_BoxColorBg).value<QColor>(); palette.setColor(QPalette::Base, color); // 文字色 color = settings.value(IniKey_BoxColorFg).value<QColor>(); palette.setColor(QPalette::Text, color); // フォント font = settings.value(IniKey_BoxFont).value<QFont>(); ui->boxFont->setText(tr("%1, %2pt").arg(font.family()).arg(font.pointSize())); // サンプル表示 ui->sampleEdit->setPalette(palette); ui->sampleEdit->setFont(font); //>>>> ファイルビュー // 背景色 color = settings.value(IniKey_ViewColorBgMark).value<QColor>(); m_colorMap["clrBgMark"] = color; color = settings.value(IniKey_ViewColorBgNormal).value<QColor>(); m_colorMap["clrBgNormal"] = color; // 文字色 color = settings.value(IniKey_ViewColorFgHidden).value<QColor>(); m_colorMap["clrFgHidden"] = color; color = settings.value(IniKey_ViewColorFgMark).value<QColor>(); m_colorMap["clrFgMark"] = color; color = settings.value(IniKey_ViewColorFgNormal).value<QColor>(); m_colorMap["clrFgNormal"] = color; color = settings.value(IniKey_ViewColorFgReadonly).value<QColor>(); m_colorMap["clrFgReadonly"] = color; color = settings.value(IniKey_ViewColorFgSystem).value<QColor>(); m_colorMap["clrFgSystem"] = color; // フォント font = settings.value(IniKey_ViewFont).value<QFont>(); ui->viewFont->setText(tr("%1, %2pt").arg(font.family()).arg(font.pointSize())); // サンプル表示 QHeaderView *header = ui->sampleTable->verticalHeader(); header->setDefaultSectionSize(QFontMetrics(font).height() * 1.5); ui->sampleTable->setMinimumHeight(header->sectionSize(0) * 5); ui->sampleTable->setMaximumHeight(ui->sampleTable->minimumHeight() + 2); m_model.setFont(font); m_model.update(); //>>>> テキストビューア // 文字色と背景色 if (settings.value(IniKey_ViewerInherit).toBool()) { ui->viewerInherit->setChecked(true); color = settings.value(IniKey_ViewColorBgNormal).value<QColor>(); palette.setColor(QPalette::Base, color); color = settings.value(IniKey_ViewColorFgNormal).value<QColor>(); palette.setColor(QPalette::Text, color); } else if (!import){ ui->viewerInherit->setChecked(false); color = settings.value(IniKey_ViewerColorBg).value<QColor>(); palette.setColor(QPalette::Base, color); color = settings.value(IniKey_ViewerColorFg).value<QColor>(); palette.setColor(QPalette::Text, color); } ui->viewerSample->setPalette(palette); // フォント if (!import) { font = settings.value(IniKey_ViewerFont).value<QFont>(); ui->viewerFont->setText(tr("%1, %2pt").arg(font.family()).arg(font.pointSize())); ui->viewerSample->setFont(font); } }
PreferenceDialog::PreferenceDialog(QWidget *parent) : QDialog(parent), ui(new Ui::PreferenceDialog), m_model(), m_colorMap() { m_model.setColorMap(&m_colorMap); ui->setupUi(this); ui->tabWidget->setCurrentIndex(0); // アドレスボックスの外観サンプル ui->sampleEdit->setText(QDir::homePath()); // ファイルビューの外観サンプル ui->sampleTable->setModel(&m_model); QHeaderView *header; header = ui->sampleTable->horizontalHeader(); header->setSectionResizeMode(0, QHeaderView::Stretch); header->setSectionResizeMode(1, QHeaderView::ResizeToContents); header->setSectionResizeMode(2, QHeaderView::ResizeToContents); header = ui->sampleTable->verticalHeader(); header->setDefaultSectionSize(header->defaultSectionSize() * 0.75); // シグナル&スロット connect(ui->bootSize, SIGNAL(toggled(bool)), this, SLOT(setControlsEnabled(bool))); connect(ui->sizeAbsolute, SIGNAL(toggled(bool)), this, SLOT(setControlsEnabled(bool))); connect(ui->sizeRelative, SIGNAL(toggled(bool)), this, SLOT(setControlsEnabled(bool))); connect(ui->bootPos, SIGNAL(toggled(bool)), this, SLOT(setControlsEnabled(bool))); connect(ui->posAbsolute, SIGNAL(toggled(bool)), this, SLOT(setControlsEnabled(bool))); connect(ui->posRelative, SIGNAL(toggled(bool)), this, SLOT(setControlsEnabled(bool))); connect(ui->boxClrBg, SIGNAL(clicked()), this, SLOT(selectBoxColor())); connect(ui->boxClrFg, SIGNAL(clicked()), this, SLOT(selectBoxColor())); connect(ui->chooseBoxFont, SIGNAL(clicked()), this, SLOT(chooseFont())); connect(ui->clrBgMark, SIGNAL(clicked()), this, SLOT(selectViewColor())); connect(ui->clrBgNormal, SIGNAL(clicked()), this, SLOT(selectViewColor())); connect(ui->clrFgHidden, SIGNAL(clicked()), this, SLOT(selectViewColor())); connect(ui->clrFgMark, SIGNAL(clicked()), this, SLOT(selectViewColor())); connect(ui->clrFgNormal, SIGNAL(clicked()), this, SLOT(selectViewColor())); connect(ui->clrFgReadonly, SIGNAL(clicked()), this, SLOT(selectViewColor())); connect(ui->clrFgSystem, SIGNAL(clicked()), this, SLOT(selectViewColor())); connect(ui->chooseViewFont, SIGNAL(clicked()), this, SLOT(chooseFont())); connect(ui->importAppearance, SIGNAL(clicked()), this, SLOT(importAppearance())); connect(ui->exportAppearance, SIGNAL(clicked()), this, SLOT(exportAppearance())); connect(ui->browseArchiver, SIGNAL(clicked()), this, SLOT(browseApp())); connect(ui->browseEditor, SIGNAL(clicked()), this, SLOT(browseApp())); connect(ui->browseTerminal, SIGNAL(clicked()), this, SLOT(browseApp())); connect(ui->chooseViewerFont, SIGNAL(clicked()), this, SLOT(chooseFont())); connect(ui->viewerClrBg, SIGNAL(clicked()), this, SLOT(selectViewerColor())); connect(ui->viewerClrFg, SIGNAL(clicked()), this, SLOT(selectViewerColor())); connect(ui->viewerInherit, SIGNAL(toggled(bool)), this, SLOT(setControlsEnabled(bool))); connect(ui->enableViewerIgnoreExt, SIGNAL(toggled(bool)), this, SLOT(setControlsEnabled(bool))); connect(ui->defaultIgnoreExt, SIGNAL(clicked()), this, SLOT(setIgnoreExtDefault())); // 現在の設定で各コントロールを初期化する QSettings settings; QString strValue; QSize size; QPoint point; QRadioButton *radioBtn; //>>>>> 起動と終了 // 起動時のサイズ ui->bootSize->setChecked(true); strValue = settings.value(IniKey_BootSizeSpec).toString(); radioBtn = findChild<QRadioButton*>(strValue); if (radioBtn == NULL) { radioBtn = ui->sizeRelative; } radioBtn->setChecked(true); if (strValue.isEmpty()) { ui->bootSize->setChecked(false); } size = settings.value(IniKey_BootSizeAbs).toSize(); ui->absoluteWidth->setValue(size.width()); ui->absoluteHeight->setValue(size.height()); size = settings.value(IniKey_BootSizeRel).toSize(); ui->relativeWidth->setValue(size.width()); ui->relativeHeight->setValue(size.height()); // 起動時の位置 ui->bootPos->setChecked(true); strValue = settings.value(IniKey_BootPosSpec).toString(); radioBtn = findChild<QRadioButton*>(strValue); if (radioBtn == NULL) { radioBtn = ui->posCenter; } radioBtn->setChecked(true); if (strValue.isEmpty()) { ui->bootPos->setChecked(false); } point = settings.value(IniKey_BootPosAbs).toPoint(); ui->absoluteLeft->setValue(point.x()); ui->absoluteTop->setValue(point.y()); point = settings.value(IniKey_BootPosRel).toPoint(); ui->relativeLeft->setValue(point.x()); ui->relativeTop->setValue(point.y()); // 起動時の設定削除 ui->resetOnBoot->setChecked(settings.value(IniKey_ResetOnBoot).toBool()); // アップデートの確認 ui->checkUpdates->setChecked(settings.value(IniKey_CheckUpdates).toBool()); // 終了時の確認ダイアログ ui->confirmExit->setChecked(settings.value(IniKey_ConfirmExit).toBool()); //>>>>> 色とフォント、テキストビューア loadAppearance(settings, false); ui->dark->setValue(settings.value(IniKey_Darkness).toInt()); //>>>>> ファイル操作 // 確認ダイアログの表示 ui->confirmCopy->setChecked(settings.value(IniKey_ConfirmCopy).toBool()); ui->confirmDelete->setChecked(settings.value(IniKey_ConfirmDelete).toBool()); ui->confirmMove->setChecked(settings.value(IniKey_ConfirmMove).toBool()); ui->confirmRename->setChecked(settings.value(IniKey_ConfirmRename).toBool()); // 完了ダイアログの自動クローズ ui->autoCloseCopy->setChecked(settings.value(IniKey_AutoCloseCopy).toBool()); ui->autoCloseDelete->setChecked(settings.value(IniKey_AutoCloseDelete).toBool()); ui->autoCloseMove->setChecked(settings.value(IniKey_AutoCloseMove).toBool()); ui->autoCloseRename->setChecked(settings.value(IniKey_AutoCloseRename).toBool()); // 上書き時の既定動作 strValue = settings.value(IniKey_DefaultOnCopy).toString(); if (strValue.isEmpty()) { strValue = "owDefIfNew"; } radioBtn = findChild<QRadioButton*>(strValue); if (radioBtn == NULL) { radioBtn = ui->rbOverWriteIfNew; } radioBtn->setChecked(true); ui->moveAfterCreate->setChecked(settings.value(IniKey_MoveAfterCreateFolder).toBool()); ui->openAfterCreate->setChecked(settings.value(IniKey_OpenAfterCreateFile).toBool()); //>>>>> パス設定 // エディタ ui->editorPath->setText(settings.value(IniKey_PathEditor).toString()); // ターミナル ui->terminalPath->setText(settings.value(IniKey_PathTerminal).toString()); // アーカイバ ui->archiverPath->setText(settings.value(IniKey_PathArchiver).toString()); //>>>>> テキストビューア ui->enableViewerIgnoreExt->setChecked(true); ui->enableViewerIgnoreExt->setChecked(!settings.value(IniKey_ViewerForceOpen).toBool()); ui->viewerIgnoreExt->setPlainText(settings.value(IniKey_ViewerIgnoreExt).toString()); }
void ResTable::init() { if (!(m_model = new RecollModel(prefs.restableFields))) return; tableView->setModel(m_model); tableView->setMouseTracking(true); tableView->setSelectionBehavior(QAbstractItemView::SelectRows); tableView->setItemDelegate(new ResTableDelegate(this)); tableView->setContextMenuPolicy(Qt::CustomContextMenu); new QShortcut(QKeySequence("Ctrl+o"), this, SLOT(menuEdit())); new QShortcut(QKeySequence("Ctrl+Shift+o"), this, SLOT(menuEditAndQuit())); new QShortcut(QKeySequence("Ctrl+d"), this, SLOT(menuPreview())); connect(tableView, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(createPopupMenu(const QPoint&))); QHeaderView *header = tableView->horizontalHeader(); if (header) { if (int(prefs.restableColWidths.size()) == header->count()) { for (int i = 0; i < header->count(); i++) { header->resizeSection(i, prefs.restableColWidths[i]); } } header->setSortIndicatorShown(true); header->setSortIndicator(-1, Qt::AscendingOrder); header->setContextMenuPolicy(Qt::CustomContextMenu); header->setStretchLastSection(1); connect(header, SIGNAL(sectionResized(int,int,int)), this, SLOT(saveColState())); connect(header, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(createHeaderPopupMenu(const QPoint&))); } #if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) header->setSectionsMovable(true); #else header->setMovable(true); #endif header = tableView->verticalHeader(); if (header) { header->setDefaultSectionSize(QApplication::fontMetrics().height() + ROWHEIGHTPAD); } QKeySequence seq("Esc"); QShortcut *sc = new QShortcut(seq, this); connect(sc, SIGNAL (activated()), tableView->selectionModel(), SLOT (clear())); connect(tableView->selectionModel(), SIGNAL(currentChanged(const QModelIndex&, const QModelIndex &)), this, SLOT(onTableView_currentChanged(const QModelIndex&))); connect(tableView, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(onDoubleClick(const QModelIndex&))); m_pager = new ResTablePager(this); QSettings settings; QVariant saved = settings.value("resTableSplitterSizes"); if (saved != QVariant()) { splitter->restoreState(saved.toByteArray()); } else { QList<int> sizes; sizes << 355 << 125; splitter->setSizes(sizes); } delete textBrowser; m_detail = new ResTableDetailArea(this); m_detail->setReadOnly(true); m_detail->setUndoRedoEnabled(false); m_detail->setOpenLinks(false); // signals and slots connections connect(m_detail, SIGNAL(anchorClicked(const QUrl &)), this, SLOT(linkWasClicked(const QUrl &))); splitter->addWidget(m_detail); splitter->setOrientation(Qt::Vertical); }
SalesOrderManager::SalesOrderManager(QWidget* parent) : QSplitter(parent) { model = new SalesOrderModel(this); proxyModel = new SalesOrderProxyModel(this); proxyModel->setSourceModel(model); QWidget* container = new QWidget(this); QBoxLayout* containerLayout = new QVBoxLayout(container); containerLayout->setMargin(0); QString actionTooltip("%1<br><b>%2</b>"); QToolBar* toolBar = new QToolBar(container); toolBar->setIconSize(QSize(16, 16)); QAction* refreshAction = toolBar->addAction(QIcon(":/resources/icons/refresh.png"), "&Muat Ulang", this, SLOT(refresh())); refreshAction->setShortcut(QKeySequence("F5")); refreshAction->setToolTip(actionTooltip.arg("Muat ulang daftar pesanan").arg(refreshAction->shortcut().toString())); QAction* newAction = toolBar->addAction(QIcon(":/resources/icons/plus.png"), "&Baru", this, SLOT(openEditor())); newAction->setShortcut(QKeySequence("Ctrl+N")); newAction->setToolTip(actionTooltip.arg("Pesanan baru").arg(newAction->shortcut().toString())); QAction* closeTabAction = new QAction(this); closeTabAction->setShortcuts(QList<QKeySequence>({QKeySequence("Esc"), QKeySequence("Ctrl+W")})); addAction(closeTabAction); QAction* closeAllTabsAction = new QAction(this); closeAllTabsAction->setShortcut(QKeySequence("Ctrl+Shift+W")); addAction(closeAllTabsAction); containerLayout->addWidget(toolBar); QLabel* spacer = new QLabel(toolBar); spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); toolBar->addWidget(spacer); stateComboBox = new QComboBox(toolBar); stateComboBox->setToolTip("Saring daftar pesanan berdasarkan status"); stateComboBox->addItem("Semua"); stateComboBox->addItem("Aktif"); stateComboBox->addItem("Selesai"); stateComboBox->addItem("Dibatalkan"); stateComboBox->setCurrentIndex(1); toolBar->addWidget(stateComboBox); searchEdit = new QLineEdit(toolBar); searchEdit->setToolTip("Cari di daftar pesanan"); searchEdit->setPlaceholderText("Cari"); searchEdit->setClearButtonEnabled(true); searchEdit->setMaxLength(100); searchEdit->setMaximumWidth(150); toolBar->addWidget(searchEdit); view = new QTableView(container); view->setToolTip("Klik ganda atau ketuk Enter untuk membuka pesanan"); view->setModel(proxyModel); view->setAlternatingRowColors(true); view->setSortingEnabled(true); view->setSelectionMode(QAbstractItemView::SingleSelection); view->setSelectionBehavior(QAbstractItemView::SelectRows); view->setTabKeyNavigation(false); QHeaderView* header = view->verticalHeader(); header->setVisible(false); header->setMinimumSectionSize(20); header->setMaximumSectionSize(20); header->setDefaultSectionSize(20); header = view->horizontalHeader(); header->setToolTip("Klik pada header kolom untuk mengurutkan"); header->setHighlightSections(false); containerLayout->addWidget(view); infoLabel = new QLabel(container); infoLabel->setStyleSheet("font-style:italic;padding-bottom:1px;"); infoLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); containerLayout->addWidget(infoLabel); tabWidget = new QTabWidget(this); tabWidget->setDocumentMode(true); tabWidget->setTabsClosable(true); tabWidget->setMovable(true); tabWidget->hide(); setCollapsible(0, false); setCollapsible(1, false); connect(closeTabAction, SIGNAL(triggered(bool)), SLOT(closeCurrentTab())); connect(closeAllTabsAction, SIGNAL(triggered(bool)), SLOT(closeAllTabs())); connect(tabWidget, SIGNAL(tabCloseRequested(int)), SLOT(closeTab(int))); connect(stateComboBox, SIGNAL(currentIndexChanged(int)), SLOT(refresh())); connect(searchEdit, SIGNAL(textChanged(QString)), SLOT(applyFilter())); connect(view, SIGNAL(activated(QModelIndex)), SLOT(edit())); QTimer::singleShot(0, this, SLOT(init())); }
bool Login::init(Datapipe *datapipe, const QString ¶ms) { this->datapipe = datapipe; this->params = params; QHBoxLayout *mainLayout = new QHBoxLayout(); setLayout(mainLayout); QSqlQuery query; loglevel = datapipe->getVariables()->value(_S("loglevel")).toInt(); query.prepare(datapipe->getSettings()->value(_S("login/queries/userslist")).toString()); query.bindValue(":current_base_id", datapipe->getVariables()->value(_S("current_base_id"))); if (!query.exec()) { qCritical() << _T("%1 Ошибка: %2\nЗапрос: %3\nПеременные: %4") .arg(posForLog, query.lastError().text(), query.lastQuery(), Service::join(query.boundValues())); QMessageBox message; message.setText(_T("Ошибка получения списка пользователей\nТекст: %1\n").arg(query.lastError().text())); message.exec(); return false; } model.setQuery(query); model.setHeaderData(0, Qt::Horizontal, _T("Пользователи")); view.setModel(&model); view.setSelectionMode(QAbstractItemView::SingleSelection); view.hideColumn(1); view.hideColumn(2); QHeaderView *header = view.verticalHeader(); header->setDefaultSectionSize(datapipe->getVariables()->value(_S("standart_text_height")).toInt()); header->setVisible(false); header = view.horizontalHeader(); header->setStretchLastSection(true); view.setFocusPolicy(Qt::NoFocus); mainLayout->addWidget(&view); QVBoxLayout *numpadLayout = new QVBoxLayout(); mainLayout->addLayout(numpadLayout); Numpad *npad = new Numpad(datapipe, this); npad->setEchoMode(QLineEdit::Password); numpadLayout->addWidget(npad); numpadLayout->addStretch(); connect(npad, SIGNAL(inputCommited(QString)), this, SLOT(passwordCommited(QString))); setFocusProxy(npad); this->installEventFilter(this); datapipe->getVariables()->remove(_S("user")); datapipe->getVariables()->remove(_S("user_id")); return true; }
//-------------------------------------------------------------------------------------- //! The AIS Safety and DSC distress message page //-------------------------------------------------------------------------------------- tVesselMessagesTabPage::tVesselMessagesTabPage( int numKeys, bool soleFocus, QWidget* pParent ) : QWidget( pParent ), m_NumKeys(numKeys) { m_pTableTitle = new QLabel( tr( "Messages", "[title]" ), this ); m_pTableTitle->hide(); CreateActions(); m_pMessageTable = new tTableWidget( 0, columnCount, this ); m_pMessageTable->setFrameShape( QFrame::NoFrame ); m_pMessageTable->SetSoleFocus( soleFocus ); m_pMessageTable->SetWrapping( soleFocus == true ); m_pMessageTable->hideColumn( mmsiColumn ); m_pMessageTable->hideColumn( sourceTypeColumn ); m_pMessageTable->hideColumn( uidColumn ); Connect( m_pMessageTable, SIGNAL( itemClicked( QTableWidgetItem* ) ), m_pDetailsAct, SLOT( trigger() ) ); QHeaderView* pHorizontalHeaderView = m_pMessageTable->horizontalHeader(); pHorizontalHeaderView->setClickable( false ); pHorizontalHeaderView->setResizeMode( timeColumn, QHeaderView::Fixed ); pHorizontalHeaderView->setResizeMode( messageColumn, QHeaderView::Stretch ); QString timeString = QString( tr( "Time", "[title]" ) ); QSize headerTextSize = pHorizontalHeaderView->fontMetrics().size( 0, timeString ); m_maxTimeWidth = headerTextSize.width() + 10; pHorizontalHeaderView->resizeSection( timeColumn, m_maxTimeWidth ); QStringList headings; headings << timeString << tr( "Message", "[title]" ); m_pMessageTable->setHorizontalHeaderLabels( headings ); SetHeaderFont(); // Prevents header bold font pHorizontalHeaderView->setHighlightSections( false ); pHorizontalHeaderView->setDefaultAlignment( Qt::AlignLeft ); QHeaderView* pVerticalHeaderView = m_pMessageTable->verticalHeader(); pVerticalHeaderView->hide(); pVerticalHeaderView->setResizeMode( QHeaderView::Fixed ); pVerticalHeaderView->setDefaultSectionSize( QFontMetrics( QApplication::font() ).height() * 2 + 10 ); QVBoxLayout* pVLayout = new QVBoxLayout( this ); pVLayout->setContentsMargins( 0, 0, 0, 0 ); pVLayout->addWidget( m_pTableTitle ); pVLayout->addWidget( m_pMessageTable ); setLayout( pVLayout ); m_pResizeTimer = new QTimer( this ); Connect( m_pResizeTimer, SIGNAL(timeout()), this, SLOT( Resize() ) ); RefreshTable(); m_pMessageTable->selectRow( 0 ); if ( tProductSettings::Instance().AISAllowed() == true ) { tAisEngine* pAisEngine = tGlobal<tAisEngine>::Instance(); Connect( pAisEngine, SIGNAL( NewSafetyMessage( tAisSafetyMessage ) ), this, SLOT( NewAisSafetyMessage( const tAisSafetyMessage& ) ) ); Connect( pAisEngine, SIGNAL( RemoveSafetyMessage( int ) ), this, SLOT( RemoveAisSafetyMessage( int ) ) ); }
void HoIModDesigner::FillCountryList( const QHash<QString,Nation*>& nations, QTableWidget* widget ) { if( widget == nullptr ) { return; } widget->setSortingEnabled(true); widget->setRowCount( nations.size() ); widget->setColumnCount( 10 ); QHeaderView *verticalHeader = widget->verticalHeader(); verticalHeader->setSectionResizeMode(QHeaderView::Fixed); verticalHeader->setDefaultSectionSize(20); int columnIndex = 0; widget->verticalHeader()->setVisible(false); widget->setSelectionBehavior(QAbstractItemView::SelectRows); QTableWidgetItem *id = new QTableWidgetItem("Name"); id->setBackground(Qt::lightGray); widget->setHorizontalHeaderItem( columnIndex++, id ); QTableWidgetItem *provinces = new QTableWidgetItem("Provinces"); provinces->setBackground(Qt::lightGray); widget->setHorizontalHeaderItem( columnIndex++, provinces ); QTableWidgetItem *ic = new QTableWidgetItem("IC"); ic->setBackground(Qt::lightGray); widget->setHorizontalHeaderItem( columnIndex++, ic ); QTableWidgetItem *points = new QTableWidgetItem("Points"); points->setBackground(Qt::lightGray); widget->setHorizontalHeaderItem( columnIndex++, points ); QTableWidgetItem *manpower = new QTableWidgetItem("Manpower"); manpower->setBackground(Qt::lightGray); widget->setHorizontalHeaderItem( columnIndex++, manpower ); QTableWidgetItem *leadership = new QTableWidgetItem("Leadership"); leadership->setBackground(Qt::lightGray); widget->setHorizontalHeaderItem( columnIndex++, leadership ); QTableWidgetItem *energy = new QTableWidgetItem("Energy"); energy->setBackground(Qt::lightGray); widget->setHorizontalHeaderItem( columnIndex++, energy ); QTableWidgetItem *metal = new QTableWidgetItem("Metal"); metal->setBackground(Qt::lightGray); widget->setHorizontalHeaderItem( columnIndex++, metal ); QTableWidgetItem *oil = new QTableWidgetItem("Crude oil"); oil->setBackground(Qt::lightGray); widget->setHorizontalHeaderItem( columnIndex++, oil ); QTableWidgetItem *rare = new QTableWidgetItem("Rare material"); rare->setBackground(Qt::lightGray); widget->setHorizontalHeaderItem( columnIndex++, rare ); if( nations.isEmpty() == true ) { return; } int rowIndex = 0; QHash<QString,Nation*>::ConstIterator iter; for( iter = nations.constBegin(); iter != nations.constEnd(); iter++ ) { int columnIndex = 0; TableWidgetItemNation *nameItem = new TableWidgetItemNation((*iter)->GetID(),(*iter), new TableWidgetItemComparatorString() ); widget->setItem(rowIndex, columnIndex++, nameItem ); widget->item(rowIndex,0)->setTextAlignment(Qt::AlignCenter); QTableWidgetItem *provinces = new TableWidgetItemNation(QString().setNum((*iter)->m_Provinces.size()),(*iter)); widget->setItem(rowIndex, columnIndex++, provinces ); QTableWidgetItem *ic = new TableWidgetItemNation(QString().setNum((*iter)->CalcIC()),(*iter)); widget->setItem(rowIndex, columnIndex++, ic ); QTableWidgetItem *points = new TableWidgetItemNation(QString().setNum((*iter)->CalcPoints()),(*iter)); widget->setItem(rowIndex, columnIndex++, points ); QTableWidgetItem *manpower = new TableWidgetItemNation(QString().setNum((*iter)->CalcManpower()),(*iter)); widget->setItem(rowIndex, columnIndex++, manpower ); QTableWidgetItem *leadership = new TableWidgetItemNation(QString().setNum((*iter)->CalcLeadership()),(*iter)); widget->setItem(rowIndex, columnIndex++, leadership ); QTableWidgetItem *energy = new TableWidgetItemNation(QString().setNum((*iter)->CalcEnergy()),(*iter)); widget->setItem(rowIndex, columnIndex++, energy ); QTableWidgetItem *metal = new TableWidgetItemNation(QString().setNum((*iter)->CalcMetal()),(*iter)); widget->setItem(rowIndex, columnIndex++, metal ); QTableWidgetItem *oil = new TableWidgetItemNation(QString().setNum((*iter)->CalcCrudeOil()),(*iter)); widget->setItem(rowIndex, columnIndex++, oil ); QTableWidgetItem *rare = new TableWidgetItemNation(QString().setNum((*iter)->CalcRareMaterial()),(*iter)); widget->setItem(rowIndex, columnIndex++, rare ); rowIndex++; } }
bool Cashbox::init(Datapipe *data, const QString ¶ms) { this->data = data; this->params = params; QMap<QString, QVariant>* vars = data->getVariables(); int button_width = vars->value(_S("standart_button_width")).toInt(); int button_height = vars->value(_S("standart_button_height")).toInt(); // int button_margin = vars->value(_S("standart_margins")).toInt(); loglevel = vars->value(_S("loglevel")).toInt(); QGridLayout *mainLayout = new QGridLayout(); this->setLayout(mainLayout); QSettings *settings = data->getSettings(); // model = new QSqlQueryModel(this); model.setQuery(settings->value("cashbox/queries/operations").toString()); model.setHeaderData(0, Qt::Horizontal, "Операции"); view.setModel(&model); view.hideColumn(1); QHeaderView *header = view.verticalHeader(); header->setDefaultSectionSize(button_height); header->setVisible(false); header = view.horizontalHeader(); header->setStretchLastSection(true); view.setFocusPolicy(Qt::NoFocus); mainLayout->addWidget(&view,0,1); view.setMaximumWidth(button_width * 2); QVBoxLayout *numpadLayout = new QVBoxLayout(); Numpad *npad = new Numpad(data, this); numpadLayout->addWidget(npad); numpadLayout->addStretch(1); mainLayout->addLayout(numpadLayout,0,2); connect(npad, SIGNAL(inputCommited(QString)), this, SLOT(summCommited(QString))); QVBoxLayout *totalsLayout = new QVBoxLayout(); totalsLayout->addWidget(&totals); totalsLayout->addStretch(); // totals.setMaximumWidth(button_width * 3); //totals.setMinimumWidth(Height(button_width * 3); mainLayout->addLayout(totalsLayout,0,0); updateTotals(); setFocusProxy(npad); return true; }
//================================================================================ void HoIModDesigner::CreateDockWidgets() { { QDockWidget *dock = new QDockWidget(tr("Province details"), this); dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); m_DockWidgetProvinceDetails = new QTableWidget(16,2,dock); QHeaderView *verticalHeader = m_DockWidgetProvinceDetails->verticalHeader(); verticalHeader->setSectionResizeMode(QHeaderView::Fixed); verticalHeader->setDefaultSectionSize(20); m_DockWidgetProvinceDetails->verticalHeader()->setVisible(false); m_DockWidgetProvinceDetails->setSelectionBehavior(QAbstractItemView::SelectRows); QTableWidgetItem *headerColumn1 = new QTableWidgetItem("Bezeichner"); headerColumn1->setBackground(Qt::lightGray); m_DockWidgetProvinceDetails->setHorizontalHeaderItem( 0, headerColumn1 ); QTableWidgetItem *headerColumn2 = new QTableWidgetItem("Wert"); headerColumn2->setBackground(Qt::lightGray); m_DockWidgetProvinceDetails->setHorizontalHeaderItem( 1, headerColumn2 ); dock->setWidget(m_DockWidgetProvinceDetails); addDockWidget(Qt::RightDockWidgetArea, dock); m_DockWidgetsMenu->addAction(dock->toggleViewAction()); connect(m_View->m_Scene, SIGNAL(SignalProvinceEntered(ProvinceItem*)),this, SLOT(UpdateProvinceDetail(ProvinceItem*))); } { QDockWidget *dockCountry = new QDockWidget(tr("Country list"), this); dockCountry->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); m_DockWidgetNationList = new QTableWidget(0,0,dockCountry); dockCountry->setWidget( m_DockWidgetNationList ); addDockWidget(Qt::RightDockWidgetArea, dockCountry); m_DockWidgetsMenu->addAction(dockCountry->toggleViewAction()); } { QDockWidget *dockCountry = new QDockWidget(tr("Country details"), this); dockCountry->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); m_DockWidgetNationDetails = new QTableWidget(15,2,dockCountry); QHeaderView *verticalHeader = m_DockWidgetNationDetails->verticalHeader(); verticalHeader->setSectionResizeMode(QHeaderView::Fixed); verticalHeader->setDefaultSectionSize(20); m_DockWidgetNationDetails->verticalHeader()->setVisible(false); m_DockWidgetNationDetails->setSelectionBehavior(QAbstractItemView::SelectRows); QTableWidgetItem *headerColumn1 = new QTableWidgetItem("Bezeichner"); headerColumn1->setBackground(Qt::lightGray); m_DockWidgetNationDetails->setHorizontalHeaderItem( 0, headerColumn1 ); QTableWidgetItem *headerColumn2 = new QTableWidgetItem("Wert"); headerColumn2->setBackground(Qt::lightGray); m_DockWidgetNationDetails->setHorizontalHeaderItem( 1, headerColumn2 ); dockCountry->setWidget( m_DockWidgetNationDetails ); addDockWidget(Qt::RightDockWidgetArea, dockCountry); m_DockWidgetsMenu->addAction(dockCountry->toggleViewAction()); connect(m_DockWidgetNationList, SIGNAL(itemClicked(QTableWidgetItem *)),this, SLOT(UpdateCountryDetail(QTableWidgetItem*))); } { QDockWidget *dock = new QDockWidget(tr("Province list"), this); dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); m_DockWidgetProvinceList = new QTableWidget(15000,2,dock); QHeaderView *verticalHeader = m_DockWidgetProvinceList->verticalHeader(); verticalHeader->setSectionResizeMode(QHeaderView::Fixed); verticalHeader->setDefaultSectionSize(20); m_DockWidgetProvinceList->verticalHeader()->setVisible(false); m_DockWidgetProvinceList->setSelectionBehavior(QAbstractItemView::SelectRows); QTableWidgetItem *headerColumn1 = new QTableWidgetItem("ID"); headerColumn1->setBackground(Qt::lightGray); m_DockWidgetProvinceList->setHorizontalHeaderItem( 0, headerColumn1 ); QTableWidgetItem *headerColumn2 = new QTableWidgetItem("Name"); headerColumn2->setBackground(Qt::lightGray); m_DockWidgetProvinceList->setHorizontalHeaderItem( 1, headerColumn2 ); dock->setWidget( m_DockWidgetProvinceList ); addDockWidget(Qt::RightDockWidgetArea, dock); m_DockWidgetsMenu->addAction(dock->toggleViewAction()); } { QDockWidget *dock2 = new QDockWidget(tr("Logging"), this); dock2->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea ); m_DockWidgetLogging = new LoggingTableWidget(0,0,dock2); dock2->setWidget( m_DockWidgetLogging ); addDockWidget(Qt::BottomDockWidgetArea, dock2); m_DockWidgetsMenu->addAction(dock2->toggleViewAction()); } { QDockWidget *dock2 = new QDockWidget(tr("Buildings"), this); dock2->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea ); m_DockWidgetBuildingTypes = new QTableWidget(0,0,dock2); dock2->setWidget( m_DockWidgetBuildingTypes ); addDockWidget(Qt::BottomDockWidgetArea, dock2); m_DockWidgetsMenu->addAction(dock2->toggleViewAction()); } }
MatrixDsp::MatrixDsp(QWidget *parent) : QWidget(parent) { QHeaderView *vHeader; QHeaderView *hHeader; // set up quantization and compression ratio labels whichQM = new QLabel(tr("non-uniform quantization")); whichQM->setAlignment(Qt::AlignCenter); cmpRate = new QLabel(tr("compression ratio: unavailable")); cmpRate->setAlignment(Qt::AlignCenter); qmLabel = new QLabel(tr("Quantization Table")); qmLabel->setAlignment(Qt::AlignCenter); oriLabel = new QLabel(tr("DCT (8x8 block)")); oriLabel->setAlignment(Qt::AlignCenter); qtzLabel = new QLabel(tr("Quantized 8x8 block")); qtzLabel->setAlignment(Qt::AlignCenter); // init a grid layout mainLayout = new QGridLayout(this); mainLayout->setSpacing(6); // init matrices QMMatrix = new QTableWidget(8, 8, this); vHeader = QMMatrix->verticalHeader(); vHeader->sectionResizeMode(QHeaderView::Fixed); vHeader->setDefaultSectionSize(22); vHeader->hide(); hHeader = QMMatrix->horizontalHeader(); hHeader->sectionResizeMode(QHeaderView::Fixed); hHeader->setDefaultSectionSize(40); hHeader->hide(); oriMatrix = new QTableWidget(8, 8, this); vHeader = oriMatrix->verticalHeader(); vHeader->sectionResizeMode(QHeaderView::Fixed); vHeader->setDefaultSectionSize(22); vHeader->hide(); hHeader = oriMatrix->horizontalHeader(); hHeader->sectionResizeMode(QHeaderView::Fixed); hHeader->setDefaultSectionSize(40); hHeader->hide(); qtzMatrix = new QTableWidget(8, 8, this); vHeader = qtzMatrix->verticalHeader(); vHeader->sectionResizeMode(QHeaderView::Fixed); vHeader->setDefaultSectionSize(22); vHeader->hide(); hHeader = qtzMatrix->horizontalHeader(); hHeader->sectionResizeMode(QHeaderView::Fixed); hHeader->setDefaultSectionSize(40); hHeader->hide(); // put quantization and compression ratio labels into the grid layout mainLayout->addWidget(whichQM, 0, 0, 1, 1); mainLayout->addWidget(cmpRate, 1, 0, 1, 1); mainLayout->addWidget(QMMatrix, 2, 0, 7, 1); mainLayout->addWidget(qmLabel, 9, 0, 1, 1); mainLayout->addWidget(oriMatrix, 10, 0, 7, 1); mainLayout->addWidget(oriLabel, 17, 0, 1, 1); mainLayout->addWidget(qtzMatrix, 18, 0, 7, 1); mainLayout->addWidget(qtzLabel, 25, 0, 1, 1); for (int i = 0; i < 8; i++) for (int j = 0; j < 8; j++) { oriMatrix->setItem(i, j, new QTableWidgetItem("")); qtzMatrix->setItem(i, j, new QTableWidgetItem("")); QMMatrix->setItem(i, j, new QTableWidgetItem("")); } }