int main(int argc, char *argv[]) { Q_INIT_RESOURCE(interview); QApplication app(argc, argv); QSplitter page; QAbstractItemModel *data = new Model(1000, 10, &page); QItemSelectionModel *selections = new QItemSelectionModel(data); QTableView *table = new QTableView; table->setModel(data); table->setSelectionModel(selections); table->horizontalHeader()->setMovable(true); table->verticalHeader()->setMovable(true); // Set StaticContents to enable minimal repaints on resizes. table->viewport()->setAttribute(Qt::WA_StaticContents); page.addWidget(table); QTreeView *tree = new QTreeView; tree->setModel(data); tree->setSelectionModel(selections); tree->setUniformRowHeights(true); tree->header()->setStretchLastSection(false); tree->viewport()->setAttribute(Qt::WA_StaticContents); // Disable the focus rect to get minimal repaints when scrolling on Mac. tree->setAttribute(Qt::WA_MacShowFocusRect, false); page.addWidget(tree); QListView *list = new QListView; list->setModel(data); list->setSelectionModel(selections); list->setViewMode(QListView::IconMode); list->setSelectionMode(QAbstractItemView::ExtendedSelection); list->setAlternatingRowColors(false); list->viewport()->setAttribute(Qt::WA_StaticContents); list->setAttribute(Qt::WA_MacShowFocusRect, false); page.addWidget(list); page.setWindowIcon(QPixmap(":/images/interview.png")); page.setWindowTitle("Interview"); page.show(); return app.exec(); }
AMSamplePlatePre2013Selector::AMSamplePlatePre2013Selector(AMSamplePlatePre2013* sourcePlate, QWidget *parent) : QWidget(parent) { samplePlateTableName_ = AMDbObjectSupport::s()->tableNameForClass<AMSamplePlatePre2013>(); // Either use an external plate (if specified in sourcePlate), or make an internal one. plate_ = sourcePlate ? sourcePlate : new AMSamplePlatePre2013(this); setupUi(); notesEditor->setObjectName("notesEditor"); notesEditor->setStyleSheet("#notesEditor { background-image: url(:/notepadBackground.png); font: bold 15px \"Marker Felt\";}"); AMDetailedItemDelegate* del = new AMDetailedItemDelegate(this); // Setting a new view fixes a grayed-menu-background drawing bug on mac QListView* lview = new QListView(this); lview->setItemDelegate(del); lview->setAlternatingRowColors(true); plateComboBox->setView(lview); notesEditor->setMaximumHeight(80); this->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); connect(&plateRefreshScheduler_, SIGNAL(executed()), this, SLOT(populateSamplePlates())); plateRefreshScheduler_.schedule(); onSamplePlateChanged(/*plate_->valid()*/); connect(AMDatabase::database("user"), SIGNAL(updated(QString,int)), this, SLOT(onDatabaseUpdated(QString,int)), Qt::QueuedConnection); connect(AMDatabase::database("user"), SIGNAL(created(QString,int)), this, SLOT(onDatabaseCreated(QString,int)), Qt::QueuedConnection); connect(AMDatabase::database("user"), SIGNAL(removed(QString,int)), this, SLOT(onDatabaseRemoved(QString,int)), Qt::QueuedConnection); // GUI event connections connect(plateComboBox, SIGNAL(activated(int)), this, SLOT(onComboBoxActivated(int))); connect(nameEdit, SIGNAL(textEdited(QString)), this, SLOT(onNameEdited(QString))); connect(nameEdit, SIGNAL(editingFinished()), this, SLOT(onPlateEditingFinished())); connect(notesEditor, SIGNAL(textChanged()), this, SLOT(onNotesEdited())); connect(notesEditor, SIGNAL(editingFinished(int)), this, SLOT(onPlateEditingFinished())); notesHeaderButton->setChecked(false); notesEditor->setVisible(false); connect(notesHeaderButton, SIGNAL(clicked(bool)), notesEditor, SLOT(setVisible(bool))); // when our current sample plate is re-loaded out of the database, respond to update the GUI values connect(plate_, SIGNAL(loadedFromDb()), this, SLOT(onSamplePlateChanged()), Qt::QueuedConnection); }