Esempio n. 1
2
// Constructor.
patchesDialog::patchesDialog( QWidget *pParent, Qt::WindowFlags wflags )
    : QDialog( pParent, wflags )
{
    // Setup UI struct...
    setupUi( this );

    m_pSynth = NULL;
    m_iChan  = 0;
    m_iBank  = 0;
    m_iProg  = 0;

    // Soundfonts list view...
    QHeaderView *pHeader = m_progListView->header();
//	pHeader->setResizeMode(QHeaderView::Custom);
    pHeader->setDefaultAlignment(Qt::AlignLeft);
//	pHeader->setDefaultSectionSize(200);
#if QT_VERSION >= 0x050000
    pHeader->setSectionsMovable(false);
#else
    pHeader->setMovable(false);
#endif
    pHeader->setStretchLastSection(true);

    m_progListView->resizeColumnToContents(0);	// Prog.
    //pHeader->resizeSection(1, 200);					// Name.

    // Initial sort order...
    m_bankListView->sortItems(0, Qt::AscendingOrder);
    m_progListView->sortItems(0, Qt::AscendingOrder);

    // UI connections...
    QObject::connect(m_bankListView,
                     SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
                     SLOT(bankChanged()));
    QObject::connect(m_progListView,
                     SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)),
                     SLOT(progChanged(QTreeWidgetItem*,QTreeWidgetItem*)));
    QObject::connect(m_progListView,
                     SIGNAL(itemActivated(QTreeWidgetItem*,int)),
                     SLOT(accept()));
    QObject::connect(m_okButton,
                     SIGNAL(clicked()),
                     SLOT(accept()));
    QObject::connect(m_cancelButton,
                     SIGNAL(clicked()),
                     SLOT(reject()));
}
Esempio n. 2
1
DISABLE_COMPILER_WARNINGS
#include <QApplication>
#include <QDragMoveEvent>
#include <QHeaderView>
#include <QKeyEvent>
#include <QMouseEvent>
RESTORE_COMPILER_WARNINGS

#include <time.h>
#include <set>

#if defined __linux__ || defined __APPLE__
#include "cfocusframestyle.h"
#endif

CFileListView::CFileListView(QWidget *parent) :
	QTreeView(parent),
	_controller(CController::get()),
	_panelPosition(UnknownPanel),
	_bHeaderAdjustmentRequired(true),
	_singleMouseClickValid(false),
	_shiftPressedItemSelected(false)
{
	setMouseTracking(true);
	setItemDelegate(new CFileListItemDelegate);
	connect(this, &QTreeView::doubleClicked, [this](const QModelIndex &idx) {

		_itemUnderCursorBeforeMouseClick = QModelIndex();
		_singleMouseClickValid = false;

		for(FileListViewEventObserver* observer: _eventObservers)
		{
			if (observer->fileListReturnPressOrDoubleClickPerformed(idx))
				break;
		}
	});

	QHeaderView * headerView = header();
	assert_r(headerView);

	headerView->installEventFilter(this);

#if defined __linux__ || defined __APPLE__
	setStyle(new CFocusFrameStyle);
#endif
}
Esempio n. 3
1
void SendFileTreeWidget::retranslateUi()
{
    QStringList headers;
    headers << "#" << tr("Name") << tr("Progress") << tr("Rate") <<tr("Size") << tr("Remain") << tr("Total") <<tr("Completed") << tr("State");
    this->setHeaderLabels(headers);
    QFontMetrics fm = fontMetrics();
    QHeaderView *header = this->header();
    header->resizeSection(0, qMax(fm.width(headers.at(0)+" ## "), fm.width(" ## ")));
    header->resizeSection(1, qMax(fm.width(headers.at(1)+ "####"), fm.width(" name-for-a-file.ext ")) );
    header->resizeSection(2, qMax(fm.width(headers.at(2)+"####"), fm.width("Progress")));
    header->resizeSection(3, qMax(fm.width(headers.at(3)+"####"), fm.width(" 999Kb/s ")));
    header->resizeSection(4, qMax(fm.width(headers.at(4)+"####"), fm.width(" 999Mb ")) );
    header->resizeSection(5, qMax(fm.width(headers.at(5)+"####"), fm.width(" hh:mm:ss ")) );
    header->resizeSection(6, qMax(fm.width(headers.at(6)+"####"), fm.width(" hh:mm:ss ")) );
    header->resizeSection(7, qMax(fm.width(headers.at(6)+"####"), fm.width(" 999Mb/999Mb ")) );
    header->resizeSection(8, qMax(fm.width(headers.at(7)+"####"), fm.width(" transfing... ")) );
    header->setHighlightSections(true);
}
Esempio n. 4
0
//-----------------------------------------------------------------------------
//!
//-----------------------------------------------------------------------------
void tAbstractChannelTable::RecalculateNumberOfRowsAndFocusRow(const int listSize)
{
    TRACE_FUNCTION;
    if (m_RowHeight)
    {
        QHeaderView* pHorizontalHeader = horizontalHeader();
        int headerHeight = pHorizontalHeader->sizeHint().height();

        m_MaximumNumberOfRows = (m_TotalVisibleHeight - headerHeight) / m_RowHeight;
    }
    else
    {
        m_MaximumNumberOfRows = 1;
    }
    m_NumberOfRows = m_MaximumNumberOfRows;

    // Limit the number of rows to available data
    if (m_NumberOfRows > listSize)
    {
        m_NumberOfRows = listSize;
    }

    // Want the focus row to be just before the middle of the table
    if (m_NumberOfRows < 3)
    {
        //do we know our height yet?
        if (m_RowHeight && m_NumberOfRows == 2) // if only 1 row, focus must be 0
        {
            //yes
            m_FocusRow = 1;
        }
        else
        {
            //no, so we really don't know our focus row yet
            m_FocusRow = 0;
        }
    }
    else
    {
        m_FocusRow = (m_NumberOfRows - 1) / 2;
    }

    // Size the table
    setRowCount(m_NumberOfRows);
    emit NewFocusRow(GetFocusRow());
}
Esempio n. 5
0
void BreakpointWidget::showEvent(QShowEvent *)
{
    if (m_firstShow && m_debugController->breakpointModel()->rowCount() > 0) {
        for (int i = 0; i < m_breakpointsView->model()->columnCount(); ++i) {
            if(i == Breakpoint::LocationColumn){
                continue;
            }
            m_breakpointsView->resizeColumnToContents(i);
        }
        //for some reasons sometimes width can be very small about 200... But it doesn't matter as we use tooltip anyway.
        int width = m_breakpointsView->size().width();

        QHeaderView* header = m_breakpointsView->header();
        header->resizeSection(Breakpoint::LocationColumn, width > 400 ? width/2 : header->sectionSize(Breakpoint::LocationColumn)*2 );
        m_firstShow = false;
    }
}
// Constructor.
qjackctlInterfaceComboBox::qjackctlInterfaceComboBox ( QWidget *pParent )
	: QComboBox(pParent)
{
	QTreeView *pTreeView = new QTreeView(this);
	QHeaderView *pHeaderView = pTreeView->header();
	pHeaderView->hide();
#if QT_VERSION < 0x050000
	pHeaderView->setResizeMode(QHeaderView::ResizeToContents);
#endif
	pTreeView->setRootIsDecorated(false);
	pTreeView->setAllColumnsShowFocus(true);
	pTreeView->setSelectionBehavior(QAbstractItemView::SelectRows);
	pTreeView->setSelectionMode(QAbstractItemView::SingleSelection);
	pTreeView->setModel(new QStandardItemModel());
//	pTreeView->setMinimumWidth(320);
	QComboBox::setView(pTreeView);
}
LDFCommonTableWidget::LDFCommonTableWidget(QWidget* parent)
    : QTableWidget(parent)
{
    m_ldfFont.setFamily(QStringLiteral("Courier New"));
    m_ldfFont.setPointSize(10);

    QHeaderView* pHeader = horizontalHeader();
    //pHeader->setSectionResizeMode(QHeaderView::Stretch);
    pHeader->setSectionResizeMode(QHeaderView::Interactive);
    pHeader->setStretchLastSection(true);
    setEditTriggers(NoEditTriggers);
    verticalHeader()->setVisible(true);
    setAlternatingRowColors(true);
    setSelectionBehavior(QAbstractItemView::SelectRows);

    connect(verticalHeader(), SIGNAL(sectionMoved(int,int, int)), this, SLOT(tableItemMoved(int,int,int)));
}
Esempio n. 8
0
void LogsWidget::initView() {
    ui->programLogTableView->setModel(programLogModel);
    ui->programLogTableView->setObjectName("programLogTableView");
    //ui->programLogTableView->setAlternatingRowColors(true);
    ui->programLogTableView->setSelectionMode(QAbstractItemView::SingleSelection);
    ui->programLogTableView->setSelectionBehavior(QAbstractItemView::SelectRows);
    ui->programLogTableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
    ui->programLogTableView->setColumnHidden(0,true);
    ui->programLogTableView->setColumnHidden(1,true);
    ui->programLogTableView->setColumnHidden(5,true);
    QHeaderView* headerView = ui->programLogTableView->horizontalHeader();
    headerView->setResizeMode(2,QHeaderView::ResizeToContents);
    headerView->setStretchLastSection(true);

    ui->websiteLogTableView->setModel(blockedWebsiteLogModel);
    ui->websiteLogTableView->setObjectName("websiteLogTableView");
    //ui->websiteLogTableView->setAlternatingRowColors(true);
    ui->websiteLogTableView->setSelectionMode(QAbstractItemView::SingleSelection);
    ui->websiteLogTableView->setSelectionBehavior(QAbstractItemView::SelectRows);
    ui->websiteLogTableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
    ui->websiteLogTableView->setColumnHidden(0,true);
    ui->websiteLogTableView->setColumnHidden(1,true);
    ui->websiteLogTableView->setColumnHidden(5,true);
    headerView = ui->websiteLogTableView->horizontalHeader();
    headerView->setResizeMode(2,QHeaderView::ResizeToContents);
    headerView->setStretchLastSection(true);

    ui->browseWebLogTableView->setModel(browseWebLogModel);
    ui->browseWebLogTableView->setObjectName("browseWebLogTableView");
    //ui->browseWebLogTableView->setAlternatingRowColors(true);
    ui->browseWebLogTableView->setSelectionMode(QAbstractItemView::SingleSelection);
    ui->browseWebLogTableView->setSelectionBehavior(QAbstractItemView::SelectRows);
    ui->browseWebLogTableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
    ui->browseWebLogTableView->setColumnHidden(0,true);
    ui->browseWebLogTableView->setColumnHidden(1,true);
    headerView = ui->browseWebLogTableView->horizontalHeader();
    headerView->setResizeMode(2,QHeaderView::ResizeToContents);
    headerView->setStretchLastSection(true);

    ui->keyloggerLogTableView->setModel(keyloggerLogModel);
    ui->keyloggerLogTableView->setObjectName("keyloggerLogTableView");
    //ui->keyloggerLogTableView->setAlternatingRowColors(true);
    ui->keyloggerLogTableView->setSelectionMode(QAbstractItemView::SingleSelection);
    ui->keyloggerLogTableView->setSelectionBehavior(QAbstractItemView::SelectRows);
    ui->keyloggerLogTableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
    ui->keyloggerLogTableView->setColumnHidden(0,true);
    ui->keyloggerLogTableView->setColumnHidden(1,true);
    headerView = ui->keyloggerLogTableView->horizontalHeader();
    headerView->setResizeMode(3,QHeaderView::ResizeToContents);
    headerView->setStretchLastSection(true);
}
Esempio n. 9
0
PanelCash::PanelCash(QWidget *parent)
        :QDialog(parent)
{
      setupUi(this);
      reload_ui();

      QHeaderView *h = list_curency->header();
      h->setResizeMode(QHeaderView::ResizeToContents);
      h->setMovable(FALSE);
      list_curency->setDragEnabled(FALSE);
      
      QDoubleValidator *dv = new QDoubleValidator(0.00,9999999999.99,2,this);
      eUnit1->setValidator(dv);
      eUnit2->setReadOnly(true);
      
      init_connections();
}
Esempio n. 10
0
TabProgress::TabProgress(RandomDockDialog* parent, RandomDock* p)
  : AbstractTab(parent, p), m_timer(new QTimer(this)), m_mutex(new QMutex),
    m_update_mutex(new QMutex), m_update_all_mutex(new QMutex),
    m_context_scene(0)
{
  // Allow queued connections to work with the TableEntry struct
  qRegisterMetaType<RD_Prog_TableEntry>("RD_Prog_TableEntry");

  ui.setupUi(m_tab_widget);

  QHeaderView* horizontal = ui.table_list->horizontalHeader();
  horizontal->setResizeMode(QHeaderView::ResizeToContents);

  rowTracking = true;

  // dialog connections
  connect(m_dialog, SIGNAL(moleculeChanged(GlobalSearch::Structure*)), this,
          SLOT(highlightScene(GlobalSearch::Structure*)));
  connect(m_opt, SIGNAL(sessionStarted()), this, SLOT(startTimer()));

  // Progress table connections
  connect(m_timer, SIGNAL(timeout()), this, SLOT(updateProgressTable()));
  connect(ui.push_refresh, SIGNAL(clicked()), this, SLOT(startTimer()));
  connect(ui.push_refresh, SIGNAL(clicked()), this,
          SLOT(updateProgressTable()));
  connect(ui.spin_period, SIGNAL(editingFinished()), this,
          SLOT(updateProgressTable()));
  connect(ui.table_list, SIGNAL(currentCellChanged(int, int, int, int)), this,
          SLOT(selectMoleculeFromProgress(int, int, int, int)));
  connect(m_opt->tracker(), SIGNAL(newStructureAdded(GlobalSearch::Structure*)),
          this, SLOT(addNewEntry()));
  connect(m_opt->queue(), SIGNAL(structureUpdated(GlobalSearch::Structure*)),
          this, SLOT(newInfoUpdate(GlobalSearch::Structure*)));
  connect(this, SIGNAL(infoUpdate()), this, SLOT(updateInfo()));
  connect(ui.table_list, SIGNAL(customContextMenuRequested(QPoint)), this,
          SLOT(progressContextMenu(QPoint)));
  connect(ui.push_refreshAll, SIGNAL(clicked()), this, SLOT(updateAllInfo()));
  connect(m_opt, SIGNAL(refreshAllStructureInfo()), this,
          SLOT(updateAllInfo()));
  connect(m_opt, SIGNAL(startingSession()), this, SLOT(disableRowTracking()));
  connect(m_opt, SIGNAL(sessionStarted()), this, SLOT(enableRowTracking()));
  connect(this, SIGNAL(updateTableEntry(int, const RD_Prog_TableEntry&)), this,
          SLOT(setTableEntry(int, const RD_Prog_TableEntry&)));

  initialize();
}
Esempio n. 11
0
LinkPropertyViewImpl::LinkPropertyViewImpl(LinkPropertyView* self)
    : self(self)
{
    linkSelectionView = LinkSelectionView::mainInstance();
    
    setFrameShape(QFrame::NoFrame);
    setColumnCount(2);
    setSelectionBehavior(QAbstractItemView::SelectRows);
    setSelectionMode(QAbstractItemView::NoSelection);

    QHeaderView* hh = horizontalHeader();
    QHeaderView* vh = verticalHeader();
    hh->hide();
    vh->hide();
    hh->setSectionResizeMode(QHeaderView::Stretch);
    vh->setSectionResizeMode(QHeaderView::ResizeToContents);
    hh->setStretchLastSection(true);

    fontPointSizeDiff = 0;
    MappingPtr config = AppConfig::archive()->openMapping("LinkPropertyView");
    int storedFontPointSizeDiff;
    if(config->read("fontZoom", storedFontPointSizeDiff)){
        zoomFontSize(storedFontPointSizeDiff);
    }

    connections.add(
        BodyBar::instance()->sigCurrentBodyItemChanged().connect(
            std::bind(&LinkPropertyViewImpl::onCurrentBodyItemChanged, this, _1)));

    connections.add(
        linkSelectionView->sigSelectionChanged().connect(
            std::bind(&LinkPropertyViewImpl::updateProperties, this)));
}
Esempio n. 12
0
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()));
}
Esempio n. 13
0
TilesetView::TilesetView(MapDocument *mapDocument, QWidget *parent)
    : QTableView(parent)
    , mZoomable(new Zoomable(this))
    , mMapDocument(mapDocument)
{
    setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
    setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
    setItemDelegate(new TileDelegate(this, this));
    setShowGrid(false);

    QHeaderView *header = horizontalHeader();
    header->hide();
    header->setResizeMode(QHeaderView::ResizeToContents);
    header->setMinimumSectionSize(1);

    header = verticalHeader();
    header->hide();
    header->setResizeMode(QHeaderView::ResizeToContents);
    header->setMinimumSectionSize(1);

    // Hardcode this view on 'left to right' since it doesn't work properly
    // for 'right to left' languages.
    setLayoutDirection(Qt::LeftToRight);
    
    Preferences *prefs = Preferences::instance();
    mDrawGrid = prefs->showTilesetGrid();

    connect(mZoomable, SIGNAL(scaleChanged(qreal)), SLOT(adjustScale()));
    connect(prefs, SIGNAL(showTilesetGridChanged(bool)),
            SLOT(setDrawGrid(bool)));
}
Esempio n. 14
0
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);
	}
}
Esempio n. 15
0
Prefs_Fonts::Prefs_Fonts(QWidget* parent, ScribusDoc* doc)
	: Prefs_Pane(parent),
	m_doc(doc)
{
	setupUi(this);

	RList = PrefsManager::instance()->appPrefs.fontPrefs.GFontSub;
	UsedFonts.clear();
	CurrentPath = "";
	m_askBeforeSubstitute = true;

	setMinimumSize(fontMetrics().width( tr( "Available Fonts" )+ tr( "Font Substitutions" )+ tr( "Additional Paths" ))+180, 200);

	fontListTableView->setModel(new FontListModel(fontListTableView, m_doc));

	fontSubstitutionsTableWidget->setRowCount(RList.count());
	fontSubstitutionsTableWidget->setColumnCount(2);
	fontSubstitutionsTableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem( tr("Font Name")));
	fontSubstitutionsTableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem( tr("Replacement")));
	fontSubstitutionsTableWidget->setSortingEnabled(false);
	fontSubstitutionsTableWidget->setSelectionBehavior( QAbstractItemView::SelectRows );
	QHeaderView *header = fontSubstitutionsTableWidget->horizontalHeader();
	header->setSectionsMovable(false);
	header->setSectionsClickable(false);
	header->setSectionResizeMode(QHeaderView::Stretch);
	fontSubstitutionsTableWidget->verticalHeader()->hide();
	fontSubstitutionsTableWidget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));


	// If we're being called for global application preferences, not document
	// preferences, we let the user customize font search paths. Because things
	// go rather badly if paths are changed/removed while a doc is open, the
	// control is also not displayed if there is a document open.
	if (m_doc==0 && !ScCore->primaryMainWindow()->HaveDoc)
	{
		whyBlankLabel->resize(0,0);
		whyBlankLabel->hide();
		readPaths();
		changeButton->setEnabled(false);
		removeButton->setEnabled(false);
		connect(pathListWidget, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(SelectPath(QListWidgetItem*)));
		connect(addButton, SIGNAL(clicked()), this, SLOT(AddPath()));
		connect(changeButton, SIGNAL(clicked()), this, SLOT(ChangePath()));
		connect(removeButton, SIGNAL(clicked()), this, SLOT(DelPath()));
	}
Esempio n. 16
0
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()));
}
Esempio n. 17
0
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
tCZoneAlarmsLayer:: tCZoneAlarmsLayer( 
    QWidget* pParent,
    CZone::tCZoneLibrary& cZoneLibrary,
    tAlarmCZoneModel& alarmCZoneModel)
: QWidget(pParent)
, m_pAlarmModel(alarmCZoneModel)
, m_cZoneLibrary(cZoneLibrary)
{
    m_pTableView = new tTableView( this );
    m_pTableView->setModel( &m_pAlarmModel );
    m_pTableView->setFocusPolicy( Qt::StrongFocus );
    m_pTableView->SetSoleFocus( true );
    m_pTableView->SetWrapping( true );
    m_pTableView->setSelectionBehavior( QAbstractItemView::SelectRows );
    QHeaderView* pVerticalHeader = m_pTableView->verticalHeader();
    pVerticalHeader->setResizeMode( QHeaderView::ResizeToContents );
    pVerticalHeader->hide();
    QHeaderView* pHorizontalHeader = m_pTableView->horizontalHeader();
    pHorizontalHeader->hide();

    if ( m_pAlarmModel.rowCount() > 0 ) 
    {
        pHorizontalHeader->setResizeMode( tAlarmCZoneModel::nameColumn, QHeaderView::Stretch );
        pHorizontalHeader->setResizeMode( tAlarmCZoneModel::statusColumn, QHeaderView::ResizeToContents);
        m_pTableView->selectRow( 0 );
    }
   
    Connect( m_pTableView, SIGNAL( clicked( const QModelIndex& ) ), this, SLOT( Clicked() ) );
    Connect( &m_pAlarmModel, SIGNAL( AlarmModelChangedSignal() ), this, SLOT( AlarmAdded() ) );

    QVBoxLayout* vLayout = new QVBoxLayout();
    vLayout->setContentsMargins( 5, 5, 5, 5 );
    vLayout->addWidget( m_pTableView );
    setLayout( vLayout );
}
Esempio n. 18
0
void MainWindow::initTableView()
{
    model = new TableModel(this);
    ui->widget_tableView->setModel(model);
    ui->widget_tableView->setAlternatingRowColors(true);

    ui->widget_tableView->setItemDelegate(new NoFocusDelegate());
    ui->widget_tableView->setSelectionMode(QAbstractItemView::NoSelection);
    ui->widget_tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
    ui->widget_tableView->horizontalHeader()->setHighlightSections(false);
    ui->widget_tableView->verticalHeader()->setVisible(false);
    ui->widget_tableView->setShowGrid(false);
    ui->widget_tableView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    ui->widget_tableView->verticalHeader()->setDefaultSectionSize(70);
    QHeaderView *headerView = ui->widget_tableView->horizontalHeader();
//    headerView->setStretchLastSection(true);  ////最后一行适应空余部分
    headerView->setSectionResizeMode(QHeaderView::Stretch); //平均列宽

    ui->widget_tableView->show();
    ui->widget_tableView->setContextMenuPolicy(Qt::CustomContextMenu);

    QStringList headerList;
    headerList << "编号顺序" << "文件名" << "缩略图" << "图片尺寸" << "图片大小" << "调整顺序" << "修改上传" << "删除";

    ImageDelegate  *m_imageDelegate = new ImageDelegate(this);
    ButtonDelegate *modifyDelegate = new ButtonDelegate(this);
    ButtonDelegate *deleteDelegate = new ButtonDelegate(this);
    MoveDelegate *m_moveDelegate = new MoveDelegate(this);;
    deleteDelegate->setTextColor(254, 107, 107);
    deleteDelegate->setButtonText("删除");
    modifyDelegate->setButtonText("替换");

    ui->widget_tableView->setItemDelegateForColumn(2, m_imageDelegate);
    ui->widget_tableView->setItemDelegateForColumn(5, m_moveDelegate);
    ui->widget_tableView->setItemDelegateForColumn(6, modifyDelegate);
    ui->widget_tableView->setItemDelegateForColumn(7, deleteDelegate);

    connect(m_moveDelegate, &MoveDelegate::left, this, &MainWindow::moveUp);
    connect(m_moveDelegate, &MoveDelegate::right, this, &MainWindow::moveDown);
    connect(deleteDelegate, &ButtonDelegate::currentRow, this, &MainWindow::deleteCurrentRow);
    connect(modifyDelegate, &ButtonDelegate::currentRow, this, &MainWindow::replace);

    model->setHorizontalHeaderList(headerList);
    model->refrushModel();
}
Esempio n. 19
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&)));
}
Esempio n. 20
0
void ByteTableView::resizeColumnsWidth()
{
    QHeaderView* header = mByteTableView->header();
    for (int i = 0; i < ByteTableModel::NoOfIds; ++i) 
    {
        if ( i == ByteTableModel::CharacterId )
        {
            mByteTableView->resizeColumnToContents( i );
            continue;
        }
        //since all indexes in one row have same number of chars it is enough to calculate one row 
        //this speeds up calculating the width from 800ms to 100ms
        const QModelIndex index = mTool->byteTableModel()->index( 0, i );
        const int indexWidthHint = mByteTableView->sizeHintForIndex( index ).width();
        const int headerWidthHint = header->sectionSizeHint( i );
        header->resizeSection(i, qMax( indexWidthHint, headerWidthHint) );
    }
}
Esempio n. 21
0
Legend::Legend(QWidget* parent) :
   QTreeWidget(parent),
   mSecondaryObjects(false)
{
   setColumnCount(1);
   setRootIsDecorated(false);
   setSelectionMode(QAbstractItemView::NoSelection);
   setSortingEnabled(false);
   setFocusPolicy(Qt::NoFocus);

   QHeaderView* pHeader = header();
   if (pHeader != NULL)
   {
      pHeader->setMovable(false);
      pHeader->setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter);
      pHeader->hide();
   }
}
Esempio n. 22
0
 void toggleColumnWidth(int logicalIndex)
 {
     QHeaderView *h = q->header();
     const int currentSize = h->sectionSize(logicalIndex);
     const int suggestedSize = suggestedColumnSize(logicalIndex);
     int targetSize = suggestedSize;
     // We switch to the size suggested by the contents, except
     // when we have that size already, in that case minimize.
     if (currentSize == suggestedSize) {
         QFontMetrics fm = q->fontMetrics();
         int headerSize = fm.width(q->model()->headerData(logicalIndex, Qt::Horizontal).toString());
         int minSize = 10 * fm.width(QLatin1Char('x'));
         targetSize = qMax(minSize, headerSize);
     }
     h->resizeSection(logicalIndex, targetSize);
     m_userHandled.remove(logicalIndex); // Reset.
     saveState();
 }
DownloadLogImpl::DownloadLogImpl(QWidget * parent, Qt::WindowFlags f)
	: QDialog(parent, f)
{
	setupUi(this);
#ifdef Q_OS_MACX
	resize(900, 450);
#endif
	// add the headers
	QStringList headers;
	headers << tr("Date/Time") << tr("Video Title") << tr("URL");
	lsvLog->setHeaderLabels(headers);
	// resize sections (header)
	QHeaderView *header = lsvLog->header();
	header->resizeSection(0, 150);
	header->resizeSection(1, 250);
	// connect signals
	connect(lsvLog, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), this, SLOT(itemDoubleClicked(QTreeWidgetItem*, int)));
}
Esempio n. 24
0
    Q_SLOT void resizeColumns() // Needs moc, see BaseTreeView::setModel
    {
        QHeaderView *h = q->header();
        QTC_ASSERT(h, return);

        if (m_settings && !m_settingsKey.isEmpty()) {
            for (int i = 0, n = h->count(); i != n; ++i) {
                int targetSize;
                if (m_userHandled.contains(i))
                    targetSize = m_userHandled.value(i);
                else
                    targetSize = suggestedColumnSize(i);
                const int currentSize = h->sectionSize(i);
                if (targetSize > 0 && targetSize != currentSize)
                    h->resizeSection(i, targetSize);
            }
        }
    }
Esempio n. 25
0
void MainWindow::restoreWindowState(bool bStartHidden)
{
	QHeaderView* hdr = treeTransfers->header();
	QVariant state = g_settings->value("state/mainheaders");
	
	if(state.isNull())
		hdr->resizeSection(0, 300);
	else
		hdr->restoreState(state.toByteArray());
	
	state = g_settings->value("state/mainsplitter");
	if(state.isNull())
		splitterQueues->setSizes(QList<int>() << 80 << 600);
	else
		splitterQueues->restoreState(state.toByteArray());
	
	state = g_settings->value("state/statssplitter");
	if(!state.isNull())
		splitterStats->restoreState(state.toByteArray());
	
	connect(hdr, SIGNAL(sectionResized(int,int,int)), this, SLOT(saveWindowState()));
	connect(splitterQueues, SIGNAL(splitterMoved(int,int)), this, SLOT(saveWindowState()));
	
	QPoint pos = g_settings->value("state/mainwindow_pos").toPoint();
	QSize size = g_settings->value("state/mainwindow_size").toSize();
	
	if(size.isEmpty())
	{
		qDebug() << "Maximizing the main window";
		if(!bStartHidden)
			showMaximized();
	}
	else
	{
		QWidget::move(pos);
		resize(size);
		if(!bStartHidden)
			show();
	}
	
	if(bStartHidden)
		actionDisplay->setChecked(false);
	resizeEvent(0);
}
Esempio n. 26
0
void
CLOAD_WORKSHEET::
CreateTable(QTabWidget * tabWidget, QString tabName, quint64 rowCount)
{
    quint64 columnCount = 12;

    // Table attributes
    QTableWidget * tableWidget = new QTableWidget();
    QHeaderView * header = tableWidget->horizontalHeader();
    header->setSectionResizeMode(QHeaderView::Stretch);
    header->setStretchLastSection(true);
    tableWidget->setAlternatingRowColors(true);
    tableWidget->setRowCount(rowCount);
    tableWidget->setColumnCount(columnCount);

    // set table column header
    tableWidget->setHorizontalHeaderItem(0,new QTableWidgetItem("Name"));
    tableWidget->setHorizontalHeaderItem(1,new QTableWidgetItem("Value"));
    tableWidget->setHorizontalHeaderItem(2,new QTableWidgetItem("Value Range"));
    tableWidget->setHorizontalHeaderItem(3,new QTableWidgetItem("    Type   "));
    tableWidget->setHorizontalHeaderItem(4,new QTableWidgetItem("Conversion"));
    tableWidget->setHorizontalHeaderItem(5,new QTableWidgetItem("Byte Offset"));
    tableWidget->setHorizontalHeaderItem(6,new QTableWidgetItem("Bit Offset"));
    tableWidget->setHorizontalHeaderItem(7,new QTableWidgetItem("Bit Size"));
    tableWidget->setHorizontalHeaderItem(8,new QTableWidgetItem("Field Used"));
    tableWidget->setHorizontalHeaderItem(9,new QTableWidgetItem("Low Byte First"));
    tableWidget->setHorizontalHeaderItem(10,new QTableWidgetItem("Group"));
    tableWidget->setHorizontalHeaderItem(11,new QTableWidgetItem("Encoding Factor"));

    tableWidget->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents);
    tableWidget->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents);
    tableWidget->horizontalHeader()->setSectionResizeMode(3, QHeaderView::ResizeToContents);
    tableWidget->horizontalHeader()->setSectionResizeMode(4, QHeaderView::ResizeToContents);
    tableWidget->horizontalHeader()->setSectionResizeMode(5, QHeaderView::ResizeToContents);
    tableWidget->horizontalHeader()->setSectionResizeMode(6, QHeaderView::ResizeToContents);
    tableWidget->horizontalHeader()->setSectionResizeMode(7, QHeaderView::ResizeToContents);
    tableWidget->horizontalHeader()->setSectionResizeMode(8, QHeaderView::ResizeToContents);
    tableWidget->horizontalHeader()->setSectionResizeMode(9, QHeaderView::ResizeToContents);
    tableWidget->horizontalHeader()->setSectionResizeMode(10, QHeaderView::ResizeToContents);
    tableWidget->horizontalHeader()->setSectionResizeMode(11, QHeaderView::ResizeToContents);

    // add tab
    tabWidget->addTab(tableWidget, tabName);    
}
Esempio n. 27
0
void MashStepTableModel::contextMenu(const QPoint &point)
{
   QObject* calledBy = sender();
   QHeaderView* hView = qobject_cast<QHeaderView*>(calledBy);

   int selected = hView->logicalIndexAt(point);
   unitDisplay currentUnit;
   unitScale  currentScale;

   // Since we need to call generateVolumeMenu() two different ways, we need
   // to figure out the currentUnit and Scale here

   currentUnit  = displayUnit(selected);
   currentScale = displayScale(selected);

   QMenu* menu;
   QAction* invoked;

   switch(selected)
   {
      case MASHSTEPAMOUNTCOL:
         menu = Brewtarget::setupVolumeMenu(parentTableWidget,currentUnit, currentScale);
         break;
      case MASHSTEPTEMPCOL:
      case MASHSTEPTARGETTEMPCOL:
         menu = Brewtarget::setupTemperatureMenu(parentTableWidget,currentUnit);
         break;
      case MASHSTEPTIMECOL:
         menu = Brewtarget::setupTimeMenu(parentTableWidget,currentScale);
         break;
      default:
         return;
   }

   invoked = menu->exec(hView->mapToGlobal(point));
   if ( invoked == 0 )
      return;

   QWidget* pMenu = invoked->parentWidget();
   if ( pMenu == menu )
      setDisplayUnit(selected,(unitDisplay)invoked->data().toInt());
   else
      setDisplayScale(selected,(unitScale)invoked->data().toInt());
}
Esempio n. 28
0
TableView::TableView()
   : QWidget()
{
   if (! this->createConnection()) {
      QString msg = "** Create Database Error";
      throw msg;
   }

   setWindowTitle(tr("Table View Model"));
   setMinimumSize(300, 350);

   //
   QSqlTableModel *model = new QSqlTableModel(this, m_db);

   QStringList tempX = m_db.tables();
   model->setTable(tempX.at(0));

   QSqlError error = model->lastError();

   if ( error.isValid() )  {
      ksMsg( this, "Table View - SQL Error", error.text() );
   }

   model->setEditStrategy(QSqlTableModel::OnManualSubmit);
   model->setSort(2, Qt::AscendingOrder);
   model->select();

   model->setHeaderData(0, Qt::Horizontal, QObject::tr("ID"));
   model->setHeaderData(1, Qt::Horizontal, QObject::tr("First name"));
   model->setHeaderData(2, Qt::Horizontal, QObject::tr("Last name"));

   //
   QTableView *view = new QTableView;
   view->setModel(model);
   view->resizeColumnsToContents();

   QHeaderView *temp = view->horizontalHeader();
   temp->setStretchLastSection(true);

   QHBoxLayout *mainLayout = new QHBoxLayout;
   mainLayout->addWidget(view);
   setLayout(mainLayout);  
}
Esempio n. 29
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);



    }


}
Esempio n. 30
0
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;
}