Пример #1
0
FusionLayersSelectPage::FusionLayersSelectPage(QWidget* pParent) :
   FusionPage(pParent)
{
   QLabel* pLayerLabel = new QLabel("Available Layers for Fusion", this);

   QStringList columnNames;
   columnNames.append(LAYER_NAME_COLUMN);
   columnNames.append(LAYER_TYPE_COLUMN);

   mpLayerView = new QTreeWidget(this);
   mpLayerView->setColumnCount(columnNames.count());
   mpLayerView->setHeaderLabels(columnNames);
   mpLayerView->setSortingEnabled(true);
   mpLayerView->setSelectionMode(QAbstractItemView::ExtendedSelection);
   mpLayerView->setRootIsDecorated(false);

   QHeaderView* pHeader = mpLayerView->header();
   if (pHeader != NULL)
   {
      pHeader->setSortIndicatorShown(true);
      pHeader->setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter);
      pHeader->setStretchLastSection(false);
      pHeader->resizeSection(0, 250);
   }

   // Layout
   QVBoxLayout* pLayout = new QVBoxLayout(this);
   pLayout->setMargin(0);
   pLayout->setSpacing(5);
   pLayout->addWidget(pLayerLabel, 0, Qt::AlignLeft);
   pLayout->addWidget(mpLayerView, 10);

   // Connections
   connect(mpLayerView, SIGNAL(itemSelectionChanged()), this, SIGNAL(modified()));
}
Пример #2
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()));
}
Пример #3
0
MessageLogWindow::MessageLogWindow(const string& id, QWidget* pParent) :
   DockWindowAdapter(id, "Message Log Window", pParent),
   mpLogCombo(NULL),
   mpModel(NULL),
   mpMsgLogMgr(Service<MessageLogMgr>().get())
{
   QWidget* pWidget = new QWidget(this);

   // Message log item model
   mpModel = new MessageLogWindowModel;

   // Message tree
   QTreeView* pMessageTree = new QTreeView(pWidget);
   pMessageTree->setModel(mpModel);
   pMessageTree->setSelectionMode(QAbstractItemView::NoSelection);
   pMessageTree->setRootIsDecorated(true);

   QHeaderView* pHeader = pMessageTree->header();
   if (pHeader != NULL)
   {
      pHeader->setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter);
      pHeader->setSortIndicatorShown(false);
   }

   // Message log combo
   mpLogCombo = new QComboBox(pWidget);

   // Layout
   QVBoxLayout* pLayout = new QVBoxLayout(pWidget);
   pLayout->setMargin(10);
   pLayout->setSpacing(5);
   pLayout->addWidget(pMessageTree, 10);
   pLayout->addWidget(mpLogCombo);

   // Initialization
   setIcon(QIcon(":/icons/MessageLogWindow"));
   setWidget(pWidget);

   vector<MessageLog*> logs = mpMsgLogMgr->getLogs();
   for (vector<MessageLog*>::const_iterator iter = logs.begin(); iter != logs.end(); ++iter)
   {
      MessageLog* pLog = *iter;
      if (pLog != NULL)
      {
         QString logName = getLogDisplayName(pLog);
         if (logName.isEmpty() == false)
         {
            mpLogCombo->addItem(logName);
         }
      }
   }

   setLog(mpLogCombo->currentText());

   // Connections
   VERIFYNR(connect(mpLogCombo, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(setLog(const QString&))));
   mpMsgLogMgr.addSignal(SIGNAL_NAME(MessageLogMgr, LogAdded), Slot(this, &MessageLogWindow::messageLogAdded));
   mpMsgLogMgr.addSignal(SIGNAL_NAME(MessageLogMgr, LogRemoved), Slot(this, &MessageLogWindow::messageLogRemoved));
}
Пример #4
0
/** @brief Default constructor.
 * Initializes the object and does some UI-related things.
 *
 * @param parent pointer to the parent QWidget.
 */
View::View (QWidget *parent)
: QTableView (parent)
{
	QHeaderView *hh = horizontalHeader ();
	hh->setSortIndicatorShown (false);
	hh->setStretchLastSection (true);
	hh->setMovable (true);
	
	setShowGrid (false);
	setEditTriggers (QAbstractItemView::DoubleClicked);
	setSelectionBehavior (QAbstractItemView::SelectRows);
	setSelectionMode (QAbstractItemView::SingleSelection);
	setAlternatingRowColors (true);
}
Пример #5
0
FeatureClassDlg::FeatureClassDlg(QWidget* pParent) :
    QDialog(pParent)
{
    // Classes
    QLabel* pClassLabel = new QLabel("Feature Classes:", this);

    QToolButton* pAddFeatureButton = new QToolButton(this);
    pAddFeatureButton->setAutoRaise(true);
    pAddFeatureButton->setIcon(QIcon(":/icons/New"));
    pAddFeatureButton->setToolTip("Add Feature");

    QToolButton* pRemoveFeatureButton = new QToolButton(this);
    pRemoveFeatureButton->setAutoRaise(true);
    pRemoveFeatureButton->setIcon(QIcon(":/icons/Delete"));
    pRemoveFeatureButton->setToolTip("Remove Feature");

    mpClassList = new QListWidget(this);
    mpClassList->setFixedWidth(150);
    mpClassList->setSelectionMode(QAbstractItemView::SingleSelection);
    mpClassList->setSortingEnabled(true);
    mpClassList->sortItems(Qt::AscendingOrder);

    // Fields
    QLabel* pFieldLabel = new QLabel("Fields:", this);

    QToolButton* pAddFieldButton = new QToolButton(this);
    pAddFieldButton->setAutoRaise(true);
    pAddFieldButton->setIcon(QIcon(":/icons/New"));
    pAddFieldButton->setToolTip("Add Field");

    QToolButton* pRemoveFieldButton = new QToolButton(this);
    pRemoveFieldButton->setAutoRaise(true);
    pRemoveFieldButton->setIcon(QIcon(":/icons/Delete"));
    pRemoveFieldButton->setToolTip("Remove Field");

    QStringList columnNames;
    columnNames.append("Name");
    columnNames.append("Type");
    columnNames.append("Default Value");

    mpFieldTree = new QTreeWidget(this);
    mpFieldTree->setColumnCount(3);
    mpFieldTree->setHeaderLabels(columnNames);
    mpFieldTree->setSelectionMode(QAbstractItemView::SingleSelection);
    mpFieldTree->setRootIsDecorated(false);
    mpFieldTree->setAllColumnsShowFocus(true);
    mpFieldTree->setSortingEnabled(true);
    mpFieldTree->sortByColumn(0, Qt::AscendingOrder);
    mpFieldTree->setItemDelegateForColumn(0, new FieldNameDelegate(mpFieldTree));
    mpFieldTree->setItemDelegateForColumn(1, new FieldTypeDelegate(mpFieldTree));
    mpFieldTree->setItemDelegateForColumn(2, new FieldValueDelegate(mpFieldTree));

    QHeaderView* pHeader = mpFieldTree->header();
    if (pHeader != NULL)
    {
        pHeader->setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter);
        pHeader->setStretchLastSection(false);
        pHeader->setSortIndicatorShown(true);
    }

    // Horizontal line
    QFrame* pLine = new QFrame(this);
    pLine->setFrameStyle(QFrame::HLine | QFrame::Sunken);

    // Dialog buttons
    QDialogButtonBox* pButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
            Qt::Horizontal, this);

    // Layout
    QHBoxLayout* pFeatureButtonLayout = new QHBoxLayout();
    pFeatureButtonLayout->setMargin(0);
    pFeatureButtonLayout->setSpacing(0);
    pFeatureButtonLayout->addWidget(pClassLabel);
    pFeatureButtonLayout->addSpacing(10);
    pFeatureButtonLayout->addStretch();
    pFeatureButtonLayout->addWidget(pAddFeatureButton);
    pFeatureButtonLayout->addWidget(pRemoveFeatureButton);

    QVBoxLayout* pFeatureClassLayout = new QVBoxLayout();
    pFeatureClassLayout->setMargin(0);
    pFeatureClassLayout->setSpacing(2);
    pFeatureClassLayout->addLayout(pFeatureButtonLayout);
    pFeatureClassLayout->addWidget(mpClassList, 10);

    QHBoxLayout* pFieldButtonLayout = new QHBoxLayout();
    pFieldButtonLayout->setMargin(0);
    pFieldButtonLayout->setSpacing(0);
    pFieldButtonLayout->addWidget(pFieldLabel);
    pFieldButtonLayout->addSpacing(10);
    pFieldButtonLayout->addStretch();
    pFieldButtonLayout->addWidget(pAddFieldButton);
    pFieldButtonLayout->addWidget(pRemoveFieldButton);

    QVBoxLayout* pFieldLayout = new QVBoxLayout();
    pFieldLayout->setMargin(0);
    pFieldLayout->setSpacing(2);
    pFieldLayout->addLayout(pFieldButtonLayout);
    pFieldLayout->addWidget(mpFieldTree, 10);

    QGridLayout* pLayout = new QGridLayout(this);
    pLayout->setMargin(10);
    pLayout->setSpacing(10);
    pLayout->addLayout(pFeatureClassLayout, 0, 0);
    pLayout->addLayout(pFieldLayout, 0, 1);
    pLayout->addWidget(pLine, 1, 0, 1, 2);
    pLayout->addWidget(pButtonBox, 2, 0, 1, 2);
    pLayout->setRowStretch(0, 10);
    pLayout->setColumnStretch(1, 10);

    // Initialization
    setWindowTitle("Feature Classes");
    resize(550, 300);
    loadFromSettings();
    updateFields();

    // Connections
    VERIFYNR(connect(pAddFeatureButton, SIGNAL(clicked()), this, SLOT(addFeatureClass())));
    VERIFYNR(connect(pRemoveFeatureButton, SIGNAL(clicked()), this, SLOT(removeFeatureClass())));
    VERIFYNR(connect(mpClassList, SIGNAL(itemChanged(QListWidgetItem*)), this,
                     SLOT(setFeatureClassData(QListWidgetItem*))));
    VERIFYNR(connect(mpClassList, SIGNAL(itemSelectionChanged()), this, SLOT(updateFields())));
    VERIFYNR(connect(pAddFieldButton, SIGNAL(clicked()), this, SLOT(addField())));
    VERIFYNR(connect(pRemoveFieldButton, SIGNAL(clicked()), this, SLOT(removeField())));
    VERIFYNR(connect(mpFieldTree, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this,
                     SLOT(setFieldData(QTreeWidgetItem*, int))));
    VERIFYNR(connect(pButtonBox, SIGNAL(accepted()), this, SLOT(accept())));
    VERIFYNR(connect(pButtonBox, SIGNAL(rejected()), this, SLOT(reject())));
}
Пример #6
0
MetadataWidget::MetadataWidget(QWidget* parent) :
   QWidget(parent),
   mpMetadata(NULL)
{
   // Metadata
   QLabel* pMetadataLabel = new QLabel("Metadata:", this);

   mpMetadataModel = new DynamicObjectItemModel(this, NULL);
   mpMetadataSortingModel = new QSortFilterProxyModel(this);
   mpMetadataSortingModel->setSortCaseSensitivity(Qt::CaseInsensitive);
   mpMetadataSortingModel->setSourceModel(mpMetadataModel);

   mpMetadataTree = new QTreeView(this);
   mpMetadataTree->setSelectionMode(QAbstractItemView::SingleSelection);
   mpMetadataTree->setRootIsDecorated(true);
   mpMetadataTree->setSortingEnabled(true);
   mpMetadataTree->sortByColumn(0, Qt::AscendingOrder);
   mpMetadataTree->setUniformRowHeights(true);
   mpMetadataTree->setModel(mpMetadataSortingModel);
   mpMetadataTree->setSelectionBehavior(QAbstractItemView::SelectRows);
   mpMetadataTree->setAllColumnsShowFocus(true);
   mpMetadataTree->setContextMenuPolicy(Qt::ActionsContextMenu);
   QAction* pCopyIdAction = new QAction("Copy item ID to clipboard", mpMetadataTree);
   mpMetadataTree->addAction(pCopyIdAction);
   QAction* pCopyValueAction = new QAction("Copy item value to clipboard", mpMetadataTree);
   mpMetadataTree->addAction(pCopyValueAction);

   QHeaderView* pHeader = mpMetadataTree->header();
   if (pHeader != NULL)
   {
      pHeader->setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter);
      pHeader->setSortIndicatorShown(true);
      pHeader->resizeSection(1, 200); // Set the default Value column width
   }

   // Filter
   mpFilterCheck = new QCheckBox("Filter:", this);
   mpFilterCombo = new QComboBox(this);
   mpFilterCombo->setEditable(false);

   // Buttons
   mpCreateFilterButton = new QToolButton(this);
   mpCreateFilterButton->setIcon(QIcon(":/icons/CreateFilter"));
   mpCreateFilterButton->setToolTip("Create Filter");
   mpCreateFilterButton->setAutoRaise(true);

   mpEditFilterButton = new QToolButton(this);
   mpEditFilterButton->setIcon(QIcon(":/icons/EditFilter"));
   mpEditFilterButton->setToolTip("Edit Filter");
   mpEditFilterButton->setAutoRaise(true);

   mpDeleteFilterButton = new QToolButton(this);
   mpDeleteFilterButton->setIcon(QIcon(":/icons/DeleteFilter"));
   mpDeleteFilterButton->setToolTip("Delete Filter");
   mpDeleteFilterButton->setAutoRaise(true);

   mpModifyButton = new QToolButton(this);
   mpModifyButton->setIcon(QIcon(":/icons/ModifyMetadata"));
   mpModifyButton->setToolTip("Modify Values");
   mpModifyButton->setAutoRaise(true);

   mpAddChildButton = new QToolButton(this);
   mpAddChildButton->setIcon(QIcon(":/icons/AddMetadataChild"));
   mpAddChildButton->setToolTip("Add Child");
   mpAddChildButton->setAutoRaise(true);

   mpAddSiblingButton = new QToolButton(this);
   mpAddSiblingButton->setIcon(QIcon(":/icons/AddMetadataSibling"));
   mpAddSiblingButton->setToolTip("Add Sibling");
   mpAddSiblingButton->setAutoRaise(true);

   mpEditButton = new QToolButton(this);
   mpEditButton->setIcon(QIcon(":/icons/EditMetadataValue"));
   mpEditButton->setToolTip("Edit");
   mpEditButton->setAutoRaise(true);

   mpDeleteButton = new QToolButton(this);
   mpDeleteButton->setIcon(QIcon(":/icons/DeleteMetadataValue"));
   mpDeleteButton->setToolTip("Delete");
   mpDeleteButton->setAutoRaise(true);

   mpClearButton = new QToolButton(this);
   mpClearButton->setIcon(QIcon(":/icons/ClearMetadata"));
   mpClearButton->setToolTip("Clear");
   mpClearButton->setAutoRaise(true);

   // Layout
   QHBoxLayout* pButtonLayout = new QHBoxLayout();
   pButtonLayout->setMargin(0);
   pButtonLayout->setSpacing(0);
   pButtonLayout->addWidget(mpCreateFilterButton);
   pButtonLayout->addWidget(mpEditFilterButton);
   pButtonLayout->addWidget(mpDeleteFilterButton);
   pButtonLayout->addSpacing(15);
   pButtonLayout->addStretch();
   pButtonLayout->addWidget(mpModifyButton);
   pButtonLayout->addSpacing(15);
   pButtonLayout->addWidget(mpAddChildButton);
   pButtonLayout->addWidget(mpAddSiblingButton);
   pButtonLayout->addWidget(mpEditButton);
   pButtonLayout->addWidget(mpDeleteButton);
   pButtonLayout->addWidget(mpClearButton);

   QGridLayout* pGrid = new QGridLayout(this);
   pGrid->setMargin(0);
   pGrid->setSpacing(5);
   pGrid->addWidget(pMetadataLabel, 0, 0, 1, 2);
   pGrid->addWidget(mpMetadataTree, 1, 0, 1, 2);
   pGrid->addWidget(mpFilterCheck, 2, 0);
   pGrid->addWidget(mpFilterCombo, 2, 1);
   pGrid->addLayout(pButtonLayout, 3, 0, 1, 2);
   pGrid->setRowStretch(1, 10);
   pGrid->setColumnStretch(1, 10);

   Service<DesktopServices> pDesktop;
   bool editWarning = pDesktop->getSuppressibleMsgDlgState(getEditWarningDialogId());

   // Initialization
   mpFilterCombo->setEnabled(false);
   mpCreateFilterButton->setEnabled(false);
   mpEditFilterButton->setEnabled(false);
   mpDeleteFilterButton->setEnabled(false);
   mpModifyButton->setEnabled(!editWarning);
   mpAddChildButton->setEnabled(editWarning);
   mpAddSiblingButton->setEnabled(false);
   mpEditButton->setEnabled(false);
   mpDeleteButton->setEnabled(false);
   mpClearButton->setEnabled(editWarning);

   // Connections
   if (editWarning == true)
   {
      VERIFYNR(connect(mpMetadataTree->selectionModel(), SIGNAL(currentChanged(const QModelIndex&, const QModelIndex&)),
         this, SLOT(currentChanged(const QModelIndex&, const QModelIndex&))));
      VERIFYNR(connect(mpMetadataTree, SIGNAL(doubleClicked(const QModelIndex&)), this,
         SLOT(editSelectedValue(const QModelIndex&))));
   }
Пример #7
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);
}
Пример #8
0
int main(int argc, char *argv[])
{
	QApplication app(argc, argv);
	QWidget * main_wg = new QWidget;

	// cria um objeto "splitter" para compartilhar widgets:    
	QSplitter *splitter = new QSplitter(main_wg);

	// cria um "model" usando o "StandardModel"
	QStandardItemModel *model = new QStandardItemModel;

	const int totCols = 3;
	int col;
	// define os títulos das colunas:
	for (col = 0; col < totCols; ++col) 
	{
		model->setHorizontalHeaderItem(col, 
			new QStandardItem( QString("COL-%1").arg(col+1) ) );
	}
	
	// alimenta linhas, colunas e sub-níveis:	
	QStandardItem *parentItem = model->invisibleRootItem();
	
	const int iniLevel = 0;
	const int totLevels= 3;
	QString prevRows("");
	QVector<QSize> vec_ColsRows; // colunas, linhas de cada nível 
	vec_ColsRows.reserve( totLevels );	
				// quantidade-colunas, quantidade-linhas
	vec_ColsRows << QSize(3,10) << QSize(3,3) << QSize(3,2) ;
	populate_model ( parentItem, vec_ColsRows,
						 iniLevel, prevRows);
	
	// Neste exemplo,
	// O "model" foi alimentado com linhas, colunas e sub-níveis:
	// E serão criadas 4 "views" (uma "tree", uma "table", uma "list" e uma "comboBox")
	// relacionadas ao mesmo "model";
	// Cada "view" exibe os dados de uma determinada maneira;

	// 1- ==== a primeira "view" é uma "tree":
	QTreeView *tree = new QTreeView(splitter);
	tree->setModel(model);
	// habilita classificação na tree:
	tree->setSortingEnabled(true);
	// classifica
	tree->sortByColumn(0);	
	// expande toda a árvore:
	tree->expandAll();
	// força largura de todas as colunas
	// para exibição completa do texto dos seus itens
	for (col = 0; col < totCols; ++col)
		tree->resizeColumnToContents(col);

	// configura o header para permitir mudança na ordem de classificacão:
	QHeaderView * hdrTree = tree->header();
	hdrTree->setClickable (true);
	hdrTree->setSortIndicator(0,Qt::AscendingOrder);
	hdrTree->setSortIndicatorShown(true);
	hdrTree->setMovable(true); // permite mover colunas do header

	// 2- ==== a segunda "view" é uma "table"
	QTableView *table = new QTableView(splitter);
	table->setModel(model);
	table->setAlternatingRowColors(true);
	// habilita classificação na table:
	table->setSortingEnabled(true);
	// classifica
	table->sortByColumn(0);	

	// configura o header para permitir mudança na ordem de classificacão:
	QHeaderView * hdrTable = table->horizontalHeader();
	hdrTable->setClickable (true);
	hdrTable->setSortIndicator(0,Qt::AscendingOrder);
	hdrTable->setSortIndicatorShown(true);
	hdrTable->setMovable(true); // permite mover colunas do header
			
	// 3- ==== a terceira view é uma "list": 
	QListView *list = new QListView(splitter);
	list->setModel(model);

	// 4- ==== a quarta "view" é uma "comboBox"
	QComboBox *combo = new QComboBox;
	combo->setModel(model);

	// configura a "splitter" definindo a largura de cada "view"
	int width = 800;	
	QList< int > cols;
	cols << int(width* 0.45) << int(width*0.45) << int(width*0.1);
	splitter->setSizes(cols);	

	// layout para agrupar a "combo" e a "splitter":
	QGridLayout * glayMain = new QGridLayout;
	main_wg->setLayout( glayMain);
	glayMain->addWidget( combo, 0, 1); // linha 0, coluna 0;
	glayMain->setRowMinimumHeight(1, glayMain->verticalSpacing() * 4); // linha 1: linha de separação
	glayMain->addWidget( splitter, 2, 0, 1, 3 ); // linha 2, coluna 0, rowSpan 1, colSpan 3

	main_wg->setWindowTitle("06_standard - 4 'views' usando o mesmo 'model' (StandardModel) - recursivo");
	main_wg->resize(800,500);	

	main_wg->show();
	return app.exec();
}
Пример #9
0
ShapeFileOptionsWidget::ShapeFileOptionsWidget(ShapeFile* pShapefile, const vector<AoiElement*>& aois, 
                                               RasterElement* pRaster) :
   QWidget(NULL), mpShapeFile(pShapefile), mAois(aois), mpGeoref(pRaster)
{
   // Filenames
   QLabel* pFilePathLabel = new QLabel("File Path:", this);
   QLabel* pBaseNameLabel = new QLabel("Base Name:", this);
   QLabel* pShpLabel = new QLabel("SHP:", this);
   QLabel* pShxLabel = new QLabel("SHX:", this);
   QLabel* pDbfLabel = new QLabel("DBF:", this);

   QFont ftBold = QApplication::font();
   ftBold.setBold(true);

   pFilePathLabel->setFont(ftBold);
   pBaseNameLabel->setFont(ftBold);
   pShpLabel->setFont(ftBold);
   pShxLabel->setFont(ftBold);
   pDbfLabel->setFont(ftBold);

   mpFilePathEdit = new QLineEdit(this);
   mpFilePathEdit->setReadOnly(true);

   mpBaseNameEdit = new QLineEdit(this);
   mpBaseNameEdit->setFixedWidth(150);

   mpShpFileLabel = new QLabel(this);
   mpShxFileLabel = new QLabel(this);
   mpDbfFileLabel = new QLabel(this);

   // Browse button
   QIcon icnBrowse(":/icons/Open");
   QPushButton* pBrowseButton = new QPushButton(icnBrowse, QString(), this);
   pBrowseButton->setFixedWidth(27);

   // Shape type
   QLabel* pShapeLabel = new QLabel("Shape:", this);
   pShapeLabel->setFont(ftBold);

   mpShapeCombo = new QComboBox(this);
   mpShapeCombo->setEditable(false);
   mpShapeCombo->setFixedWidth(150);
   vector<string> comboText = StringUtilities::getAllEnumValuesAsDisplayString<ShapefileTypes::ShapeType>();
   for (vector<string>::iterator it = comboText.begin(); it != comboText.end(); ++it)
   {
      mpShapeCombo->addItem(QString::fromStdString(*it));
   }

   // Feature list
   QLabel* pFeatureLabel = new QLabel("Features:", this);

   QStringList columnNames;
   columnNames.append("Feature");

   mpFeatureTree = new CustomTreeWidget(this);
   mpFeatureTree->setColumnCount(columnNames.count());
   mpFeatureTree->setHeaderLabels(columnNames);
   mpFeatureTree->setSelectionMode(QAbstractItemView::SingleSelection);
   mpFeatureTree->setRootIsDecorated(false);
   mpFeatureTree->setSortingEnabled(true);

   QHeaderView* pHeader = mpFeatureTree->header();
   if (pHeader != NULL)
   {
      pHeader->setSortIndicatorShown(true);
      pHeader->setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter);
      pHeader->setStretchLastSection(false);
   }

   // Feature buttons
   QPushButton* pAddFeatureButton = new QPushButton("Add Feature", this);
   QPushButton* pRemoveFeatureButton = new QPushButton("Remove Feature", this);
   QPushButton* pClearFeatureButton = new QPushButton("Clear Features", this);

   // Field buttons
   QPushButton* pAddFieldButton = new QPushButton("Add Field", this);
   QPushButton* pRemoveFieldButton = new QPushButton("Remove Field", this);

   // Layout
   QHBoxLayout* pFilePathLayout = new QHBoxLayout();
   pFilePathLayout->setMargin(0);
   pFilePathLayout->setSpacing(5);
   pFilePathLayout->addWidget(mpFilePathEdit, 10);
   pFilePathLayout->addWidget(pBrowseButton);

   QHBoxLayout* pNameShapeLayout = new QHBoxLayout();
   pNameShapeLayout->setMargin(0);
   pNameShapeLayout->setSpacing(5);
   pNameShapeLayout->addWidget(mpBaseNameEdit);
   pNameShapeLayout->addSpacing(20);
   pNameShapeLayout->addWidget(pShapeLabel);
   pNameShapeLayout->addWidget(mpShapeCombo);
   pNameShapeLayout->addStretch();

   QVBoxLayout* pButtonLayout = new QVBoxLayout();
   pButtonLayout->setMargin(0);
   pButtonLayout->setSpacing(5);
   pButtonLayout->addWidget(pAddFeatureButton);
   pButtonLayout->addWidget(pRemoveFeatureButton);
   pButtonLayout->addWidget(pClearFeatureButton);
   pButtonLayout->addStretch(10);
   pButtonLayout->addWidget(pAddFieldButton);
   pButtonLayout->addWidget(pRemoveFieldButton);

   QGridLayout* pGrid = new QGridLayout(this);
   pGrid->setMargin(10);
   pGrid->setSpacing(5);
   pGrid->addWidget(pFilePathLabel, 0, 0);
   pGrid->addLayout(pFilePathLayout, 0, 1, 1, 3);
   pGrid->addWidget(pBaseNameLabel, 1, 0);
   pGrid->addLayout(pNameShapeLayout, 1, 1, 1, 3);
   pGrid->addWidget(pShpLabel, 2, 0);
   pGrid->addWidget(mpShpFileLabel, 2, 1, 1, 3);
   pGrid->addWidget(pShxLabel, 3, 0);
   pGrid->addWidget(mpShxFileLabel, 3, 1, 1, 3);
   pGrid->addWidget(pDbfLabel, 4, 0);
   pGrid->addWidget(mpDbfFileLabel, 4, 1, 1, 3);
   pGrid->setRowMinimumHeight(5, 12);
   pGrid->addWidget(pFeatureLabel, 6, 0, 1, 4);
   pGrid->addWidget(mpFeatureTree, 7, 0, 1, 2);
   pGrid->setColumnMinimumWidth(2, 2);
   pGrid->addLayout(pButtonLayout, 7, 3);
   pGrid->setRowStretch(7, 10);
   pGrid->setColumnStretch(1, 10);

   // Initialization
   setWindowTitle("Shape File");

   if (mpShapeFile != NULL)
   {
      // Filename
      const string& filename = mpShapeFile->getFilename();
      if (!filename.empty())
      {
         QFileInfo fileInfo(QString::fromStdString(filename));
         mpFilePathEdit->setText(fileInfo.absolutePath());
         mpBaseNameEdit->setText(fileInfo.completeBaseName());
      }

      updateFilenames();

      // Shape
      int index = ShapefileTypes::getIndex(mpShapeFile->getShape());
      if (index < 0)
      {
         index = 0;
      }
      mpShapeCombo->setCurrentIndex(index);

      // Features
      const vector<Feature*>& features = mpShapeFile->getFeatures();
      for (unsigned int i = 0; i < features.size(); i++)
      {
         Feature* pFeature = features[i];
         if (pFeature != NULL)
         {
            QTreeWidgetItem* pItem = new QTreeWidgetItem(mpFeatureTree);
            if (pItem != NULL)
            {
               pItem->setText(0, QString::number(i + 1));
               mFeatures.insert(pItem, pFeature);
            }
         }
      }

      // Fields
      updateFieldValues();
   }

   // Connections
   connect(mpFilePathEdit, SIGNAL(textChanged(const QString&)), this, SLOT(updateFilenames()));
   connect(pBrowseButton, SIGNAL(clicked()), this, SLOT(browse()));
   connect(mpBaseNameEdit, SIGNAL(textChanged(const QString&)), this, SLOT(updateFilenames()));
   connect(mpShapeCombo, SIGNAL(activated(const QString&)), this, SLOT(setShape(const QString&)));
   connect(pAddFeatureButton, SIGNAL(clicked()), this, SLOT(addFeature()));
   connect(pRemoveFeatureButton, SIGNAL(clicked()), this, SLOT(removeFeature()));
   connect(pClearFeatureButton, SIGNAL(clicked()), this, SLOT(clearFeatures()));
   connect(pAddFieldButton, SIGNAL(clicked()), this, SLOT(addField()));
   connect(pRemoveFieldButton, SIGNAL(clicked()), this, SLOT(removeField()));
   connect(mpFeatureTree, SIGNAL(cellTextChanged(QTreeWidgetItem*, int)), this, SLOT(setFieldValue(QTreeWidgetItem*, int)));
}
Пример #10
0
FileDescriptorWidget::FileDescriptorWidget(QWidget* parent) :
   QWidget(parent),
   mpFileDescriptor(NULL),
   mReadOnly(true),
   mModified(false),
   mpTreeWidget(NULL),
   mpFileBrowser(NULL),
   mpGcpGroup(NULL),
   mpGcpTree(NULL)
{
   // Item tree widget
   QStringList columnNames;
   columnNames.append("Item");
   columnNames.append("Value");

   mpTreeWidget = new CustomTreeWidget(this);
   mpTreeWidget->setColumnCount(columnNames.count());
   mpTreeWidget->setHeaderLabels(columnNames);
   mpTreeWidget->setRootIsDecorated(true);
   mpTreeWidget->setSelectionMode(QAbstractItemView::SingleSelection);
   mpTreeWidget->setGridlinesShown(Qt::Horizontal | Qt::Vertical, true);
   mpTreeWidget->setSortingEnabled(false);

   QHeaderView* pHeader = mpTreeWidget->header();
   if (pHeader != NULL)
   {
      pHeader->setSortIndicatorShown(false);
      pHeader->setMovable(false);
      pHeader->setStretchLastSection(true);
      pHeader->setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter);
      pHeader->resizeSection(0, 150);
   }

   // Band file browser
   mpFileBrowser = new FileBrowser(mpTreeWidget);
   mpFileBrowser->setBrowseCaption("Select Band File");
   mpFileBrowser->hide();

   // GCP group box
   mpGcpGroup = new QGroupBox("Ground Control Points (GCP)", this);

   // GCP tree widget
   columnNames.clear();
   columnNames.append("Name");
   columnNames.append("Column");
   columnNames.append("Row");
   columnNames.append("Latitude");
   columnNames.append("Longitude");

   mpGcpTree = new CustomTreeWidget(mpGcpGroup);
   mpGcpTree->setColumnCount(columnNames.count());
   mpGcpTree->setHeaderLabels(columnNames);
   mpGcpTree->setRootIsDecorated(false);
   mpGcpTree->setSelectionMode(QAbstractItemView::SingleSelection);
   mpGcpTree->setGridlinesShown(Qt::Horizontal | Qt::Vertical, true);
   mpGcpTree->setSortingEnabled(true);

   pHeader = mpGcpTree->header();
   if (pHeader != NULL)
   {
      pHeader->setSortIndicatorShown(true);
      pHeader->setMovable(false);
      pHeader->setStretchLastSection(false);
      pHeader->setDefaultAlignment(Qt::AlignLeft | Qt::AlignVCenter);
      pHeader->resizeSection(0, 75);
      pHeader->resizeSection(1, 75);
      pHeader->resizeSection(2, 75);
   }

   // Layout
   QVBoxLayout* pGcpLayout = new QVBoxLayout(mpGcpGroup);
   pGcpLayout->setMargin(10);
   pGcpLayout->setSpacing(10);
   pGcpLayout->addWidget(mpGcpTree, 10);

   QVBoxLayout* pLayout = new QVBoxLayout(this);
   pLayout->setMargin(0);
   pLayout->setSpacing(10);
   pLayout->addWidget(mpTreeWidget);
   pLayout->addWidget(mpGcpGroup);

   // Connections
   VERIFYNR(connect(mpTreeWidget, SIGNAL(itemChanged(QTreeWidgetItem*, int)), this,
      SLOT(descriptorItemChanged(QTreeWidgetItem*, int))));
}
Пример #11
0
// Constructor.
qjackctlClientListView::qjackctlClientListView (
	qjackctlConnectView *pConnectView, bool bReadable )
	: QTreeWidget(pConnectView)
{
	m_pConnectView = pConnectView;

	m_pAutoOpenTimer   = 0;
	m_iAutoOpenTimeout = 0;

	m_pDragItem = NULL;
	m_pDragItem = NULL;

	m_pAliases = NULL;
	m_bRenameEnabled = false;

	QHeaderView *pHeader = QTreeWidget::header();
	pHeader->setDefaultAlignment(Qt::AlignLeft);
//	pHeader->setDefaultSectionSize(120);
#if QT_VERSION >= 0x050000
//	pHeader->setSectionResizeMode(QHeaderView::Custom);
	pHeader->setSectionsMovable(false);
	pHeader->setSectionsClickable(true);
#else
//	pHeader->setResizeMode(QHeaderView::Custom);
	pHeader->setMovable(false);
	pHeader->setClickable(true);
#endif
	pHeader->setSortIndicatorShown(true);
	pHeader->setStretchLastSection(true);

	QTreeWidget::setRootIsDecorated(true);
	QTreeWidget::setUniformRowHeights(true);
//	QTreeWidget::setDragEnabled(true);
	QTreeWidget::setAcceptDrops(true);
	QTreeWidget::setDropIndicatorShown(true);
	QTreeWidget::setAutoScroll(true);
	QTreeWidget::setSelectionMode(QAbstractItemView::SingleSelection);
	QTreeWidget::setSizePolicy(
		QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
	QTreeWidget::setSortingEnabled(true);
	QTreeWidget::setMinimumWidth(120);
	QTreeWidget::setColumnCount(1);

	QString sText;
	if (bReadable)
		sText = tr("Readable Clients / Output Ports");
	else
		sText = tr("Writable Clients / Input Ports");
	QTreeWidget::headerItem()->setText(0, sText);
	QTreeWidget::sortItems(0, Qt::AscendingOrder);
	QTreeWidget::setToolTip(sText);

	// Trap for help/tool-tips events.
	QTreeWidget::viewport()->installEventFilter(this);

	QObject::connect(QTreeWidget::itemDelegate(),
		SIGNAL(commitData(QWidget*)),
		SLOT(renamedSlot()));

	setAutoOpenTimeout(800);
}