ErrorListView::ErrorListView(QWidget* parent)
  : QWidget(parent),
    m_model(0)
{
    m_model = new ErrorListModel(this);
    
    QTableView* tableView = new QTableView;
    
    tableView->setItemDelegate(new ItemDelegate);
    tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
    tableView->setAlternatingRowColors(true);
    tableView->setShowGrid(false);
    tableView->verticalHeader()->hide();
    
    tableView->setModel(m_model);
    
#ifdef STROMX_STUDIO_QT4
    tableView->horizontalHeader()->setResizeMode(ErrorListModel::TIME, QHeaderView::Interactive);
    tableView->horizontalHeader()->setResizeMode(ErrorListModel::DESCRIPTION, QHeaderView::Stretch);
#else
    tableView->horizontalHeader()->setSectionResizeMode(ErrorListModel::TIME, QHeaderView::Interactive);
    tableView->horizontalHeader()->setSectionResizeMode(ErrorListModel::DESCRIPTION, QHeaderView::Stretch);
#endif // STROMX_STUDIO_QT4
    
    QPushButton* clearButton = new QPushButton(tr("Clear error log"));
    connect(clearButton, SIGNAL(clicked()), m_model, SLOT(clear()));
    QHBoxLayout* buttonLayout = new QHBoxLayout;
    buttonLayout->addWidget(clearButton);
    buttonLayout->addStretch();
    
    QVBoxLayout* mainLayout = new QVBoxLayout;
    mainLayout->addWidget(tableView);
    mainLayout->addLayout(buttonLayout);
    setLayout(mainLayout);
}
Example #2
0
/*!
    Return a new viewType.
 */
QAbstractItemView *ViewsToTest::createView(const QString &viewType)
{
    QAbstractItemView *view = 0;
    if (viewType == "QListView_ScrollPerItem") {
        view = new QListView();
        view->setObjectName("QListView");
        view->setHorizontalScrollMode(QAbstractItemView::ScrollPerItem);
        view->setVerticalScrollMode(QAbstractItemView::ScrollPerItem);
    } else if (viewType == "QListView_ScrollPerPixel") {
        view = new QListView();
        view->setObjectName("QListView");
        view->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
        view->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
    } else if (viewType == "QHeaderViewHorizontal") {
        view = new QHeaderView(Qt::Horizontal);
        view->setObjectName("QHeaderView");
    } else if (viewType == "QHeaderViewVertical") {
        view = new QHeaderView(Qt::Vertical);
        view->setObjectName("QHeaderView");
    } else if (viewType == "QTableView_ScrollPerItem") {
        view = new QTableView();
        view->setObjectName("QTableView");
        view->setHorizontalScrollMode(QAbstractItemView::ScrollPerItem);
        view->setVerticalScrollMode(QAbstractItemView::ScrollPerItem);
    } else if (viewType == "QTableView_ScrollPerPixel") {
        view = new QTableView();
        view->setObjectName("QTableView");
        view->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
        view->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
    } else if (viewType == "QTableViewNoGrid") {
        QTableView *table = new QTableView();
        table->setObjectName("QTableView");
        table->setShowGrid(false);
        view = table;
    } else if (viewType == "QTreeView_ScrollPerItem") {
        view = new QTreeView();
        view->setObjectName("QTreeView");
        view->setHorizontalScrollMode(QAbstractItemView::ScrollPerItem);
        view->setVerticalScrollMode(QAbstractItemView::ScrollPerItem);
        view->setSelectionBehavior(QAbstractItemView::SelectItems);
    } else if (viewType == "QTreeView_ScrollPerPixel") {
        view = new QTreeView();
        view->setObjectName("QTreeView");
        view->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
        view->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
        view->setSelectionBehavior(QAbstractItemView::SelectItems);
    }
    Q_ASSERT(view);
    return view;
}
Example #3
0
AboutPluginsDialog::AboutPluginsDialog(QWidget *parent, Qt::WindowFlags f)
    : QDialog(parent, f)
{
    QLayout *layout = nullptr;
    QVBoxLayout *vbox = new QVBoxLayout(this);

    {
        QTableView *toolView = new QTableView(this);
        toolView->setShowGrid(false);
        toolView->setSelectionBehavior(QAbstractItemView::SelectRows);
        toolView->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
        toolView->verticalHeader()->hide();
        toolView->setModel(ObjectBroker::model(QStringLiteral("com.kdab.GammaRay.ToolPluginModel")));

        QGroupBox *toolBox = new QGroupBox(tr("Loaded Plugins"), this);
        layout = new QHBoxLayout(toolBox);
        layout->addWidget(toolView);
        vbox->addWidget(toolBox);
    }

    {
        QTableView *errorView = new QTableView(this);
        errorView->setShowGrid(false);
        errorView->setSelectionBehavior(QAbstractItemView::SelectRows);
        errorView->setModel(ObjectBroker::model(QStringLiteral(
                                                    "com.kdab.GammaRay.ToolPluginErrorModel")));
        errorView->verticalHeader()->hide();
        errorView->horizontalHeader()->setResizeMode(QHeaderView::Stretch);

        QGroupBox *errorBox = new QGroupBox(tr("Failed Plugins"), this);
        layout = new QHBoxLayout(errorBox);
        layout->addWidget(errorView);
        vbox->addWidget(errorBox);
    }

    setWindowTitle(tr("GammaRay: Plugin Info"));
}
Example #4
0
SongView::SongView(QAbstractGallery *gallery, QWidget *parent, Qt::WindowFlags flags)
    : GalleryView(parent, flags)
    , model(new QGalleryQueryModel(gallery))
{
    model->setRootType(QDocumentGallery::Audio);

    model->addColumn(QDocumentGallery::trackNumber);
    model->setHeaderData(0, Qt::Horizontal, tr("Track"));

    model->addColumn(QDocumentGallery::title);
    model->setHeaderData(1, Qt::Horizontal, tr("Title"));

    model->addColumn(QDocumentGallery::duration);
    model->setHeaderData(2, Qt::Horizontal, tr("Duration"));

    model->addColumn(QDocumentGallery::artist);
    model->setHeaderData(3, Qt::Horizontal, tr("Artist"));

    model->addColumn(QDocumentGallery::albumArtist);
    model->setHeaderData(4, Qt::Horizontal, tr("Album Artist"));

    model->setSortPropertyNames(QStringList()
            << QDocumentGallery::artist
            << QDocumentGallery::albumTitle
            << QDocumentGallery::trackNumber);

    QTableView *view = new QTableView;
    view->setShowGrid(false);
    view->verticalHeader()->setVisible(false);
    view->setSelectionBehavior(QAbstractItemView::SelectRows);
    view->setModel(model.data());
    connect(view, SIGNAL(activated(QModelIndex)), this, SLOT(activated(QModelIndex)));

    QBoxLayout *layout = new QVBoxLayout;
    layout->setMargin(0);
    layout->setSpacing(0);
    layout->addWidget(view);

    setLayout(layout);
}
Example #5
0
void DkFileAssociationsPreference::createLayout() {
	
	QStringList fileFilters = Settings::param().app().openFilters;

	mModel = new QStandardItemModel(this);
	mModel->setObjectName("fileModel");
	for (int rIdx = 1; rIdx < fileFilters.size(); rIdx++)
		mModel->appendRow(getItems(fileFilters.at(rIdx), checkFilter(fileFilters.at(rIdx), Settings::param().app().browseFilters), checkFilter(fileFilters.at(rIdx), Settings::param().app().registerFilters)));

	mModel->setHeaderData(0, Qt::Horizontal, tr("Filter"));
	mModel->setHeaderData(1, Qt::Horizontal, tr("Browse"));
	mModel->setHeaderData(2, Qt::Horizontal, tr("Register"));

	QTableView* filterTableView = new QTableView(this);
	filterTableView->setModel(mModel);
	filterTableView->setSelectionBehavior(QAbstractItemView::SelectRows);
	filterTableView->verticalHeader()->hide();
	//filterTableView->horizontalHeader()->hide();
	filterTableView->setShowGrid(false);
	filterTableView->resizeColumnsToContents();
	filterTableView->resizeRowsToContents();
	filterTableView->setWordWrap(false);

	QPushButton* openDefault = new QPushButton(tr("Set as Default Viewer"), this);
	openDefault->setObjectName("openDefault");

	// now the final widgets
	QVBoxLayout* layout = new QVBoxLayout(this);
	layout->addWidget(filterTableView);

#ifdef Q_OS_WIN
	layout->addWidget(openDefault);
#else
	openDefault->hide();
#endif

}
Example #6
0
/* we create a table that has a fixed height, but can stretch to fit certain width */
QTableView *PrintLayout::createProfileTable(ProfilePrintModel *model, const int tableW)
{
	// setup a new table
	QTableView *table = new QTableView();
	QHeaderView *vHeader = table->verticalHeader();
	QHeaderView *hHeader = table->horizontalHeader();
	table->setAttribute(Qt::WA_DontShowOnScreen);
	table->setSelectionMode(QAbstractItemView::NoSelection);
	table->setFocusPolicy(Qt::NoFocus);
	table->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	table->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	hHeader->setVisible(false);
	vHeader->setVisible(false);
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
	hHeader->setResizeMode(QHeaderView::Fixed);
	vHeader->setResizeMode(QHeaderView::Fixed);
#else
	hHeader->setSectionResizeMode(QHeaderView::Fixed);
	vHeader->setSectionResizeMode(QHeaderView::Fixed);
#endif
	// set the model
	table->setModel(model);

	/* setup cell span for the table using QTableView::setSpan().
	 * changes made here reflect on ProfilePrintModel::data(). */
	const int cols = model->columnCount();
	const int rows = model->rowCount();
	// info on top
	table->setSpan(0, 0, 1, 4);
	table->setSpan(1, 0, 1, 4);
	// gas used
	table->setSpan(2, 0, 1, 2);
	table->setSpan(3, 0, 1, 2);
	// notes
	table->setSpan(6, 0, 1, 5);
	table->setSpan(7, 0, 5, 5);

	/* resize row heights to the 'profilePrintRowHeights' indexes.
	 * profilePrintTableMaxH will then hold the table height. */
	int i;
	profilePrintTableMaxH = 0;
	for (i = 0; i < rows; i++) {
		int h = profilePrintRowHeights.at(i);
		profilePrintTableMaxH += h;
		vHeader->resizeSection(i, h);
	}
	// resize columns. columns widths are percentages from the table width.
	int accW = 0;
	for (i = 0; i < cols; i++) {
		int pw = qCeil((qreal)(profilePrintColumnWidths.at(i) * tableW) / 100.0);
		accW += pw;
		if (i == cols - 1 && accW > tableW) /* adjust last column */
			pw -= accW - tableW;
		hHeader->resizeSection(i, pw);
	}
	// resize
	table->resize(tableW, profilePrintTableMaxH);
	// hide the grid and set a stylesheet
	table->setItemDelegate(new ProfilePrintDelegate(this));
	table->setShowGrid(false);
	table->setStyleSheet(
		"QTableView { border: none }"
		"QTableView::item { border: 0px; padding-left: 2px; padding-right: 2px; }");
	// return
	return table;
}