Пример #1
0
MashStepTableModel::MashStepTableModel(QTableView* parent)
   : QAbstractTableModel(parent),
     mashObs(0),
     parentTableWidget(parent)
{
   setObjectName("mashStepTableModel");

   QHeaderView* headerView = parentTableWidget->horizontalHeader();
   headerView->setContextMenuPolicy(Qt::CustomContextMenu);
   connect(headerView, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(contextMenu(const QPoint&)));
}
Пример #2
0
MainWindow::MainWindow(QWidget *parent)
  : QMainWindow(parent)
  , m_ui(new Ui::MainWindow)
  , m_ignoreTableSelection(false)
{
  m_fileModel = new FileSystemModel(this);
  m_model = new QSortFilterProxyModel(m_fileModel);
  m_model->setSourceModel(m_fileModel);

  m_ui->setupUi(this);

  m_ui->m_fileTree->setModel(m_model);

  for (int i = 1; i < m_model->columnCount(QModelIndex()); ++i)
    m_ui->m_fileTree->hideColumn(i);

  m_ui->m_fileTable->setModel(m_model);

  QAbstractItemDelegate * proxyDelegate = new ProxyItemDelegate(m_ui->m_fileTable->itemDelegate(), m_ui->m_fileTable);
  m_ui->m_fileTable->setItemDelegate(proxyDelegate);

  m_ui->m_fileTable->setRootIndex(QModelIndex());

  m_ui->m_fileTable->verticalHeader()->setDefaultSectionSize(18);

  QHeaderView * tableHeader = m_ui->m_fileTable->horizontalHeader();
  tableHeader->resizeSections(QHeaderView::Interactive);

  QAction * resizeToContent = new QAction(QStringLiteral("Resize to content"), tableHeader);
  VERIFY(QObject::connect(resizeToContent, &QAction::triggered,
                          this, &MainWindow::onResizeColumns));

  tableHeader->setContextMenuPolicy(Qt::ActionsContextMenu);
  tableHeader->addAction(resizeToContent);

  VERIFY(QObject::connect(m_ui->m_rootEditor, SIGNAL(returnPressed()), this, SLOT(onRootSpecified())));
  VERIFY(QObject::connect(m_ui->m_rootDlgButton, SIGNAL(clicked()), this, SLOT(onRootDialogCall())));
  VERIFY(QObject::connect(m_ui->m_fileTree->selectionModel(), &QItemSelectionModel::selectionChanged,
                          this, &MainWindow::onTreeSelectionChanged));

  VERIFY(QObject::connect(m_ui->m_fileTable->selectionModel(), &QItemSelectionModel::selectionChanged,
                          this, &MainWindow::onTableSelectionChanged));

  QAction * regExpAction = new QAction(QStringLiteral("Set filter regexp"), this);
  m_ui->m_fileTable->addAction(regExpAction);
  m_ui->m_fileTree->addAction(regExpAction);
  VERIFY(QObject::connect(regExpAction, &QAction::triggered,
                          this, &MainWindow::onSetRegExp));

  LoadState();
}
Пример #3
0
YeastTableModel::YeastTableModel(QTableView* parent, bool editable)
   : QAbstractTableModel(parent),
     editable(editable),
     _inventoryEditable(false),
     parentTableWidget(parent),
     recObs(0)
{
   yeastObs.clear();
   setObjectName("yeastTableModel");

   QHeaderView* headerView = parentTableWidget->horizontalHeader();
   headerView->setContextMenuPolicy(Qt::CustomContextMenu);
   connect(headerView, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(contextMenu(const QPoint&)));
}
Пример #4
0
MiscTableModel::MiscTableModel(QTableView* parent, bool editable)
   : QAbstractTableModel(parent),
     editable(editable),
     _inventoryEditable(false),
     recObs(0),
     parentTableWidget(parent)
{
   miscObs.clear();
   setObjectName("miscTableModel");

   QHeaderView* headerView = parentTableWidget->horizontalHeader();
   headerView->setContextMenuPolicy(Qt::CustomContextMenu);
   parentTableWidget->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
   parentTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
    parentTableWidget->setWordWrap(false);

   connect(headerView, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(contextMenu(const QPoint&)));
}
//=====================CLASS FermentableTableModel==============================
FermentableTableModel::FermentableTableModel(QTableView* parent, bool editable)
    : QAbstractTableModel(parent),
      parentTableWidget(parent),
      editable(editable),
      _inventoryEditable(false),
      recObs(0),
      displayPercentages(false),
      totalFermMass_kg(0)
{
    fermObs.clear();
    // for units and scales
    setObjectName("fermentableTable");

    // Will this work here? Yes. Yes it will. Bwahahahahahaha
    QHeaderView* headerView = parentTableWidget->horizontalHeader();
    headerView->setContextMenuPolicy(Qt::CustomContextMenu);
    parentTableWidget->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
    parentTableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
    parentTableWidget->setWordWrap(false);
    connect(headerView, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(contextMenu(const QPoint&)));
}
Пример #6
0
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);
}
Пример #7
0
ListingTable::ListingTable(PartCategory* partCat, Filter* filter, QWidget* parent)
		: QTableView(parent), partCat(partCat), model(new PartTableModel(partCat, filter, this)), ignoreSectionResize(false)
{
	setModel(model);

	QHeaderView* hheader = horizontalHeader();

	verticalHeader()->hide();

	hheader->setStretchLastSection(true);
    hheader->setCascadingSectionResizes(false);
    hheader->setMovable(true);


    setSelectionBehavior(SelectRows);

    setDragEnabled(true);
    setDragDropMode(DragOnly);

    setAutoScroll(true);
    setSortingEnabled(true);

    sortByColumn(0, Qt::AscendingOrder);

    setContextMenuPolicy(Qt::CustomContextMenu);
    hheader->setContextMenuPolicy(Qt::CustomContextMenu);

	connect(this, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(partActivatedSlot(const QModelIndex&)));
	connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(contextMenuRequested(const QPoint&)));
	connect(hheader, SIGNAL(customContextMenuRequested(const QPoint&)),
			this, SLOT(headerContextMenuRequested(const QPoint&)));


	System* sys = System::getInstance();
	EditStack* editStack = sys->getEditStack();

	connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit()));

	connect(partCat, SIGNAL(recordEdited(unsigned int, PartCategory::DataMap)), this, SLOT(updateData()));
	connect(partCat, SIGNAL(recordCreated(unsigned int, PartCategory::DataMap)), this, SLOT(updateData()));
	connect(partCat, SIGNAL(recordsRemoved(QList<unsigned int>)), this, SLOT(updateData()));

	connect(editStack, SIGNAL(undone(EditCommand*)), this, SLOT(updateData()));
	connect(editStack, SIGNAL(redone(EditCommand*)), this, SLOT(updateData()));

	connect(selectionModel(), SIGNAL(currentRowChanged(const QModelIndex&, const QModelIndex&)),
			this, SLOT(currentChanged(const QModelIndex&, const QModelIndex&)));
	connect(selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),
    		this, SLOT(selectionChangedSlot(const QItemSelection&, const QItemSelection&)));
	connect(model, SIGNAL(updateRequested()), this, SLOT(updateData()));


	QSettings s;

	s.beginGroup(QString("gui_geometry_%1").arg(partCat->getTableName()));

	if (!s.contains("lt_state")  ||  !restoreState(s.value("lt_state").toByteArray())) {
		unsigned initialTotalWidth = 1000;
		int nc = model->columnCount();

		for (unsigned int i = 0 ; i < nc-1 ; i++) {
			setColumnWidth(i, initialTotalWidth / nc);
		}
	}

	s.endGroup();
}
Пример #8
0
MainWindow::MainWindow(QWidget* parent, QString imageFilename) : QMainWindow(parent),
                                                                 mUi(new Ui::MainWindow),
                                                                 mContextMenu(this) {
    mUi->setupUi(this);

    //setup context menu for the treeview
    mContextMenu.addAction(mUi->actionImport);
    mContextMenu.addAction(mUi->actionExport);
    mContextMenu.addSeparator();
    mContextMenu.addAction(mUi->actionRename);
    mContextMenu.addAction(mUi->actionDelete);
    mContextMenu.addSeparator();
    mContextMenu.addAction(mUi->actionEditProperties);

    //setup context menu for the header
    mHeaderContextMenu.addAction(mUi->actionColumnName);
    mHeaderContextMenu.addAction(mUi->actionColumnSize);
    mHeaderContextMenu.addAction(mUi->actionColumnPermissions);
    mHeaderContextMenu.addAction(mUi->actionColumnAlias);
    mHeaderContextMenu.addAction(mUi->actionColumnDateAccessed);
    mHeaderContextMenu.addAction(mUi->actionColumnDateCreated);
    mHeaderContextMenu.addAction(mUi->actionColumnDateModified);
    mHeaderContextMenu.addAction(mUi->actionColumnUser);
    mHeaderContextMenu.addAction(mUi->actionColumnGroup);

    //get YaffsManager instance and create model
    mYaffsManager = YaffsManager::getInstance();
    newModel();
    updateWindowTitle();

    QHeaderView* headerView = mUi->treeView->header();
    headerView->setContextMenuPolicy(Qt::CustomContextMenu);
    headerView->setResizeMode(YaffsItem::NAME, QHeaderView::Stretch);
    headerView->setResizeMode(YaffsItem::SIZE, QHeaderView::ResizeToContents);
    headerView->setResizeMode(YaffsItem::PERMISSIONS, QHeaderView::ResizeToContents);
    headerView->setResizeMode(YaffsItem::ALIAS, QHeaderView::ResizeToContents);
    headerView->setResizeMode(YaffsItem::DATE_ACCESSED, QHeaderView::ResizeToContents);
    headerView->setResizeMode(YaffsItem::DATE_CREATED, QHeaderView::ResizeToContents);
    headerView->setResizeMode(YaffsItem::DATE_MODIFIED, QHeaderView::ResizeToContents);
    headerView->setResizeMode(YaffsItem::USER, QHeaderView::ResizeToContents);
    headerView->setResizeMode(YaffsItem::GROUP, QHeaderView::ResizeToContents);
#ifdef QT_DEBUG
    headerView->setResizeMode(YaffsItem::OBJECTID, QHeaderView::ResizeToContents);
    headerView->setResizeMode(YaffsItem::PARENTID, QHeaderView::ResizeToContents);
    headerView->setResizeMode(YaffsItem::HEADERPOS, QHeaderView::ResizeToContents);
#endif  //QT_DEBUG

    mUi->treeView->hideColumn(YaffsItem::DATE_CREATED);
    mUi->treeView->hideColumn(YaffsItem::DATE_ACCESSED);

    mUi->actionColumnName->setEnabled(false);
    mUi->actionColumnName->setChecked(!mUi->treeView->isColumnHidden(YaffsItem::NAME));
    mUi->actionColumnSize->setChecked(!mUi->treeView->isColumnHidden(YaffsItem::SIZE));
    mUi->actionColumnPermissions->setChecked(!mUi->treeView->isColumnHidden(YaffsItem::PERMISSIONS));
    mUi->actionColumnAlias->setChecked(!mUi->treeView->isColumnHidden(YaffsItem::ALIAS));
    mUi->actionColumnDateAccessed->setChecked(!mUi->treeView->isColumnHidden(YaffsItem::DATE_ACCESSED));
    mUi->actionColumnDateCreated->setChecked(!mUi->treeView->isColumnHidden(YaffsItem::DATE_CREATED));
    mUi->actionColumnDateModified->setChecked(!mUi->treeView->isColumnHidden(YaffsItem::DATE_MODIFIED));
    mUi->actionColumnUser->setChecked(!mUi->treeView->isColumnHidden(YaffsItem::USER));
    mUi->actionColumnGroup->setChecked(!mUi->treeView->isColumnHidden(YaffsItem::GROUP));

    connect(headerView, SIGNAL(customContextMenuRequested(QPoint)), SLOT(on_treeViewHeader_customContextMenuRequested(QPoint)));
    connect(mUi->actionExpandAll, SIGNAL(triggered()), mUi->treeView, SLOT(expandAll()));
    connect(mUi->actionCollapseAll, SIGNAL(triggered()), mUi->treeView, SLOT(collapseAll()));
    connect(mUi->treeView, SIGNAL(selectionChanged()), SLOT(on_treeView_selectionChanged()));

    if (imageFilename.length() > 0) {
        show();
        openImage(imageFilename);
    } else {
        mUi->statusBar->showMessage(windowTitle() + " v" + VERSION);
    }

    mFastbootDialog = NULL;

    setupActions();
}