Example #1
0
void FeedsView::setupAppearance() {
  // Setup column resize strategies.
  header()->setSectionResizeMode(FDS_MODEL_TITLE_INDEX, QHeaderView::Stretch);
  header()->setSectionResizeMode(FDS_MODEL_COUNTS_INDEX, QHeaderView::ResizeToContents);

  setUniformRowHeights(true);
  setAnimated(true);
  setSortingEnabled(true);
  setItemsExpandable(true);
  setExpandsOnDoubleClick(true);
  setEditTriggers(QAbstractItemView::NoEditTriggers);
  setIndentation(FEEDS_VIEW_INDENTATION);
  setAcceptDrops(false);
  setDragEnabled(true);
  setDropIndicatorShown(true);
  setDragDropMode(QAbstractItemView::InternalMove);
  setAllColumnsShowFocus(false);
  setRootIsDecorated(false);
  setSelectionMode(QAbstractItemView::SingleSelection);
  setItemDelegate(new StyledItemDelegateWithoutFocus(this));
  header()->setStretchLastSection(false);
  header()->setSortIndicatorShown(false);
}
Example #2
0
Table::Table(QWidget* parent, HSPs *hsps)
{
    QStringList *header = hsps->getKeys();

    QStringList headerFirst;
    headerFirst << "gapopen" << "mismatch" << "length"
                << "productEnd" << "productStart" << "precursorEnd"
                << "precursorStart" << "productId"<< "precursorId";

    for(unsigned i = 0; i < headerFirst.size(); i++)
    {

        unsigned index = header->indexOf(headerFirst[i]);
        if(index != -1) header->removeAt(index);
        header->prepend(headerFirst[i]);

    }

    setRowCount(hsps->numHSPs());
    setColumnCount(header->size());
    setAlternatingRowColors(true);
    setHorizontalHeaderLabels(*header);
    setEditTriggers(QAbstractItemView::NoEditTriggers);
    setSelectionBehavior(QAbstractItemView::SelectRows);
    horizontalHeader()->setHighlightSections(false);

    for(int rowIndex = 0; rowIndex < hsps->numHSPs(); rowIndex++)
    {
        for(int columnIndex = 0; columnIndex < header->size(); columnIndex++)
        {
            QTableWidgetItem *item = new QTableWidgetItem;
            item->setText(hsps->getElement(rowIndex, (*header)[columnIndex]));
            setItem(rowIndex, columnIndex, item);
        }
    }

}
Example #3
0
FileTransferWidget::FileTransferWidget(QWidget * pParent)
: KviTalTableWidget(pParent)
{
	//hide the header
	verticalHeader()->hide();
	//hide cells grids
	setShowGrid(false);
	//disable cell content editing
	setEditTriggers(QAbstractItemView::NoEditTriggers);

	//select one row at once
	setSelectionBehavior(QAbstractItemView::SelectRows);
	setSelectionMode(QAbstractItemView::SingleSelection);

	//prepare columns
	setColumnCount(3);

	QStringList colHeaders;
	colHeaders << __tr2qs_ctx("Type","filetransferwindow")
				<< __tr2qs_ctx("Information","filetransferwindow")
				<< __tr2qs_ctx("Progress","filetransferwindow");
	setHorizontalHeaderLabels(colHeaders);
	//default column widths
	setColumnWidth(0, FILETRANSFERW_CELLSIZE);
#if (QT_VERSION >= 0x050000)
	horizontalHeader()->setSectionResizeMode(0, QHeaderView::Fixed);
	horizontalHeader()->setSectionResizeMode(1, QHeaderView::Interactive);
#else
	horizontalHeader()->setResizeMode(0, QHeaderView::Fixed);
	horizontalHeader()->setResizeMode(1, QHeaderView::Interactive);
#endif
	setColumnWidth(1, 500);
	horizontalHeader()->setStretchLastSection(true);
	//focus policy
	setFocusPolicy(Qt::NoFocus);
	viewport()->setFocusPolicy(Qt::NoFocus);
}
Example #4
0
InventoryTreeView::InventoryTreeView(QWidget *parent) : QTreeView(parent)
{
    setEditTriggers(QAbstractItemView::NoEditTriggers/*EditKeyPressed*/);
    setDragDropMode(QAbstractItemView::DragDrop);
    setDragEnabled(true);
    setSelectionMode(QAbstractItemView::ExtendedSelection);
    setSelectionBehavior(QAbstractItemView::SelectItems);
    setAnimated(true);
    setAllColumnsShowFocus(true);
    //setDefaultDropAction(Qt::MoveAction);
    setDropIndicatorShown(true);
    setStyleSheet(
        "QTreeView::branch:has-siblings:!adjoins-item"
        "{"
            "border-image: url(:/images/iconBranchVLine.png) 0;"
        "}"
        "QTreeView::branch:has-siblings:adjoins-item"
        "{"
            "border-image: url(:/images/iconBranchMore.png) 0;"
        "}"
        "QTreeView::branch:!has-children:!has-siblings:adjoins-item"
        "{"
            "border-image: url(:/images/iconBranchEnd.png) 0;"
        "}"
        "QTreeView::branch:has-children:!has-siblings:closed,"
        "QTreeView::branch:closed:has-children:has-siblings"
        "{"
            "border-image: none;"
            "image: url(:/images/iconBranchClosed.png);"
        "}"
        "QTreeView::branch:open:has-children:!has-siblings,"
        "QTreeView::branch:open:has-children:has-siblings"
        "{"
            "border-image: none;"
            "image: url(:/images/iconBranchOpen.png);"
        "}");
}
Example #5
0
void HostBrower::initHostBrowser()
{
    // setup view
    QStringList headers;
    headers << tr("Host Name") << tr("IP Address")
        << tr("Listen Port") << tr("Description");
    
    setColumnCount(headers.count());
    setHorizontalHeaderLabels(headers);
    setSelectionBehavior(QAbstractItemView::SelectRows);
    setSelectionMode(QAbstractItemView::SingleSelection);
    setEditTriggers(QAbstractItemView::NoEditTriggers);    

    // setup detecter
    connect(detecter, SIGNAL(newHostDetected(const QHash<QString, int>&, QString)),
        this, SLOT(onNewHostDetected(const QHash<QString, int>&)));

    connect(detecter, SIGNAL(oldHostRemoved(const QHash<QString, int>&, QString)),
        this, SLOT(onHostRemoved(const QHash<QString, int>&)));

    connect(this, SIGNAL(cellDoubleClicked(int, int)),
        this, SLOT(onCellDoubleClicked(int, int)));

}
Example #6
0
WLibraryTableView::WLibraryTableView(QWidget* parent,
                                     UserSettingsPointer pConfig,
                                     ConfigKey vScrollBarPosKey)
        : QTableView(parent),
          m_pConfig(pConfig),
          m_vScrollBarPosKey(vScrollBarPosKey) {

    // Setup properties for table

    // Editing starts when clicking on an already selected item.
    setEditTriggers(QAbstractItemView::SelectedClicked);

    //Enable selection by rows and extended selection (ctrl/shift click)
    setSelectionBehavior(QAbstractItemView::SelectRows);
    setSelectionMode(QAbstractItemView::ExtendedSelection);

    setWordWrap(false);
    setShowGrid(false);
    setCornerButtonEnabled(false);
    setSortingEnabled(true);
    // Used by delegates (e.g. StarDelegate) to tell when the mouse enters a
    // cell.
    setMouseTracking(true);
    //Work around a Qt bug that lets you make your columns so wide you
    //can't reach the divider to make them small again.
    setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);

    verticalHeader()->hide();
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
    setAlternatingRowColors(true);

    connect(verticalScrollBar(), SIGNAL(valueChanged(int)),
            this, SIGNAL(scrollValueChanged(int)));

    setTabKeyNavigation(false);
}
Example #7
0
RostersView::RostersView(QWidget *AParent) : QTreeView(AParent)
{
    FRostersModel = NULL;

    FPressedPos = QPoint();
    FPressedIndex = QModelIndex();
    FPressedLabel = AdvancedDelegateItem::NullId;

    header()->hide();
    header()->setStretchLastSection(true);

    setIndentation(4);
    setAutoScroll(true);
    setDragEnabled(true);
    setAcceptDrops(true);
    setRootIsDecorated(false);
    setDropIndicatorShown(true);
    setEditTriggers(NoEditTriggers);
    setSelectionMode(ExtendedSelection);
    setSelectionBehavior(SelectRows);
    setContextMenuPolicy(Qt::DefaultContextMenu);
    setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);

    FAdvancedItemDelegate = new AdvancedItemDelegate(this);
    FAdvancedItemDelegate->setVertialSpacing(1);
    FAdvancedItemDelegate->setHorizontalSpacing(2);
    FAdvancedItemDelegate->setItemsRole(RDR_LABEL_ITEMS);
    FAdvancedItemDelegate->setDefaultBranchItemEnabled(true);
    FAdvancedItemDelegate->setBlinkMode(AdvancedItemDelegate::BlinkHide);
    connect(FAdvancedItemDelegate,SIGNAL(updateBlinkItems()),SLOT(onUpdateBlinkLabels()));
    setItemDelegate(FAdvancedItemDelegate);

    FDragExpandTimer.setSingleShot(true);
    FDragExpandTimer.setInterval(500);
    connect(&FDragExpandTimer,SIGNAL(timeout()),SLOT(onDragExpandTimer()));
}
Example #8
0
void ScanGallery::setAllowRename(bool on)
{
    kDebug() << "to" << on;
    setEditTriggers(on ? QAbstractItemView::DoubleClicked : QAbstractItemView::NoEditTriggers);
}
Example #9
0
LibraryTreeWidget::LibraryTreeWidget(QWidget *parent)
	: QTreeWidget(parent)
{
	setSelectionMode(QAbstractItemView::ExtendedSelection);
	setDragEnabled(true);
	viewport()->setAcceptDrops(true);
	setDropIndicatorShown(true);
	setDragDropMode(QAbstractItemView::InternalMove);

	invisibleRootItem()->setFlags(invisibleRootItem()->flags() & ~Qt::ItemIsDropEnabled);

	setHeaderHidden(true);

	setEditTriggers(QAbstractItemView::EditKeyPressed | QAbstractItemView::SelectedClicked);

	addNewFileAction_ = new QAction(tr("Add New File..."), this);
	connect(addNewFileAction_, SIGNAL(triggered()), this, SLOT(addNewFile()));

	importToLibraryAction_ = new QAction(tr("Add Existing Files..."), this);
	connect(importToLibraryAction_, SIGNAL(triggered()), this, SLOT(importToLibrary()));

//	newFontAction_ = new QAction(tr("New Font..."), this);
//	connect(newFontAction_, SIGNAL(triggered()), this, SLOT(newFont()));

	newFolderAction_ = new QAction(tr("New Folder"), this);
	connect(newFolderAction_, SIGNAL(triggered()), this, SLOT(newFolder()));

	removeAction_ = new QAction(tr("Remove"), this);
	connect(removeAction_, SIGNAL(triggered()), this, SLOT(remove()));

	renameAction_ = new QAction(tr("Rename"), this);
	//renameAction_->setShortcut(Qt::Key_F2);
	connect(renameAction_, SIGNAL(triggered()), this, SLOT(rename()));

	sortAction_ = new QAction(tr("Sort"), this);
	connect(sortAction_, SIGNAL(triggered()), this, SLOT(sort()));

	codeDependenciesAction_ = new QAction(tr("Code Dependencies..."), this);
	connect(codeDependenciesAction_, SIGNAL(triggered()), this, SLOT(codeDependencies()));

	insertIntoDocumentAction_ = new QAction(tr("Insert Into Document"), this);
	connect(insertIntoDocumentAction_, SIGNAL(triggered()), this, SLOT(insertIntoDocument()));

	projectPropertiesAction_ = new QAction(tr("Properties..."), this);
	connect(projectPropertiesAction_, SIGNAL(triggered()), this, SLOT(projectProperties()));

	automaticDownsizingAction_ = new QAction(tr("Automatic Downsizing"), this);
	automaticDownsizingAction_->setCheckable(true);
	connect(automaticDownsizingAction_, SIGNAL(triggered(bool)), this, SLOT(automaticDownsizing(bool)));

    excludeFromExecutionAction_ = new QAction(tr("Exclude from Execution"), this);
    excludeFromExecutionAction_->setCheckable(true);
    connect(excludeFromExecutionAction_, SIGNAL(triggered(bool)), this, SLOT(excludeFromExecution(bool)));

    setContextMenuPolicy(Qt::CustomContextMenu);
	connect(this, SIGNAL(customContextMenuRequested  (const QPoint&)),
			this, SLOT  (onCustomContextMenuRequested(const QPoint&)));

	connect(this, SIGNAL(itemDoubleClicked  (QTreeWidgetItem*, int)),
			this, SLOT  (onItemDoubleClicked(QTreeWidgetItem*, int)));

	connect(this, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),
			this, SLOT  (onCurrentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)));

	isModifed_ = false;
	xmlString_ = toXml().toString();

	QTimer* timer = new QTimer(this);
	connect(timer, SIGNAL(timeout()), this, SLOT(checkModification()));
	timer->start(500);
}
int QAbstractItemView::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QAbstractScrollArea::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 39)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 39;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< bool*>(_v) = hasAutoScroll(); break;
        case 1: *reinterpret_cast< int*>(_v) = autoScrollMargin(); break;
        case 2: *reinterpret_cast<int*>(_v) = QFlag(editTriggers()); break;
        case 3: *reinterpret_cast< bool*>(_v) = tabKeyNavigation(); break;
        case 4: *reinterpret_cast< bool*>(_v) = showDropIndicator(); break;
        case 5: *reinterpret_cast< bool*>(_v) = dragEnabled(); break;
        case 6: *reinterpret_cast< bool*>(_v) = dragDropOverwriteMode(); break;
        case 7: *reinterpret_cast< DragDropMode*>(_v) = dragDropMode(); break;
        case 8: *reinterpret_cast< Qt::DropAction*>(_v) = defaultDropAction(); break;
        case 9: *reinterpret_cast< bool*>(_v) = alternatingRowColors(); break;
        case 10: *reinterpret_cast< SelectionMode*>(_v) = selectionMode(); break;
        case 11: *reinterpret_cast< SelectionBehavior*>(_v) = selectionBehavior(); break;
        case 12: *reinterpret_cast< QSize*>(_v) = iconSize(); break;
        case 13: *reinterpret_cast< Qt::TextElideMode*>(_v) = textElideMode(); break;
        case 14: *reinterpret_cast< ScrollMode*>(_v) = verticalScrollMode(); break;
        case 15: *reinterpret_cast< ScrollMode*>(_v) = horizontalScrollMode(); break;
        }
        _id -= 16;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setAutoScroll(*reinterpret_cast< bool*>(_v)); break;
        case 1: setAutoScrollMargin(*reinterpret_cast< int*>(_v)); break;
        case 2: setEditTriggers(QFlag(*reinterpret_cast<int*>(_v))); break;
        case 3: setTabKeyNavigation(*reinterpret_cast< bool*>(_v)); break;
        case 4: setDropIndicatorShown(*reinterpret_cast< bool*>(_v)); break;
        case 5: setDragEnabled(*reinterpret_cast< bool*>(_v)); break;
        case 6: setDragDropOverwriteMode(*reinterpret_cast< bool*>(_v)); break;
        case 7: setDragDropMode(*reinterpret_cast< DragDropMode*>(_v)); break;
        case 8: setDefaultDropAction(*reinterpret_cast< Qt::DropAction*>(_v)); break;
        case 9: setAlternatingRowColors(*reinterpret_cast< bool*>(_v)); break;
        case 10: setSelectionMode(*reinterpret_cast< SelectionMode*>(_v)); break;
        case 11: setSelectionBehavior(*reinterpret_cast< SelectionBehavior*>(_v)); break;
        case 12: setIconSize(*reinterpret_cast< QSize*>(_v)); break;
        case 13: setTextElideMode(*reinterpret_cast< Qt::TextElideMode*>(_v)); break;
        case 14: setVerticalScrollMode(*reinterpret_cast< ScrollMode*>(_v)); break;
        case 15: setHorizontalScrollMode(*reinterpret_cast< ScrollMode*>(_v)); break;
        }
        _id -= 16;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 16;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 16;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 16;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 16;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 16;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 16;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Example #11
0
void MatrixWidget::setReadOnly(bool read_only)
{
    setEditTriggers(read_only ? QAbstractItemView::NoEditTriggers
                              : QAbstractItemView::AllEditTriggers);
    setFocusPolicy(read_only ? Qt::NoFocus : Qt::WheelFocus);
}
Example #12
0
QFontListView::QFontListView(QWidget *parent)
    : QListView(parent)
{
    setModel(new QStringListModel(parent));
    setEditTriggers(NoEditTriggers);
}
void ConfigBitsView::SetDevice(Device* newDevice, DeviceData* newDeviceData)
{
    int i, j;

    device = newDevice;
    deviceData = newDeviceData;

    model.clear();
    model.setHorizontalHeaderItem(0, new QStandardItem("Description"));
    model.setHorizontalHeaderItem(1, new QStandardItem("Setting"));
    QList<QStandardItem*> row;
    Device::ConfigWord* word;
    unsigned int* wordValue;
    unsigned int* wordVerify;
    Device::ConfigField* field;
    ConfigBitsItem* item;

    for(i = 0; i < device->configWords.count(); i++)
    {
        word = &device->configWords[i];
        wordValue = deviceData->ConfigWordPointer(word->address);

        if(verifyData != NULL)
        {
            wordVerify = verifyData->ConfigWordPointer(word->address);
        }
        else
        {
            wordVerify = NULL;
        }

        item = new ConfigBitsItem(device, word, wordValue);
        for(j = 0; j < word->fields.count(); j++)
        {
            field = &word->fields[j];

            row.append(new ConfigBitsItem(device, field->description));
            row.append(new ConfigBitsItem(device, field, word, wordValue, wordVerify));
            item->appendRow(row);
            row.clear();
        }

        row.append(item);
        if(wordVerify != NULL)
        {
            row.append(new ConfigBitsItem(device, word, wordValue, wordVerify));
        }
        else
        {
            row.append(new ConfigBitsItem(device, wordValue));
        }
        model.appendRow(row);
        row.clear();
    }

    setModel(&model);
    setItemDelegate(new ConfigBitsDelegate(&model));
    setEditTriggers(QAbstractItemView::CurrentChanged);
    setWordWrap(true);
    setRootIsDecorated(false);
    setUniformRowHeights(true);
    setDragDropMode(QAbstractItemView::NoDragDrop);

    expandAll();
    setItemsExpandable(false);
    if(columnSplit)
    {
        setColumnWidth(0, columnSplit);
    }
    else
    {
        resizeColumnToContents(0);
    }
}
tableTemplateWidget::tableTemplateWidget(QWidget *parent) :
  QTableWidget(parent)
{
  templateId = 0;
  numRow = numCol = 0;

  countWords = 0;

  isDirty = false;
  isMaked = false;

  sizeOfTemplate = NULL;

  DRC[0][0] = -1;
  DRC[0][1] = 0;

  DRC[1][0] = 0;
  DRC[1][1] = 1;

  DRC[2][0] = 1;
  DRC[2][1] = 0;

  DRC[3][0] = 0;
  DRC[3][1] = -1;

  intersections[0] = 3;
  intersections[1] = 6;
  intersections[2] = 7;
  intersections[3] = 9;
  intersections[4] = 11;
  intersections[5] = 12;
  intersections[6] = 13;
  intersections[7] = 14;
  intersections[8] = 15;

  fullCell = Qt::yellow;
  emptyCell = Qt::darkRed;

  font.setBold(true);
  font.setFamily("Tahoma");
  font.setPointSize(14);

  actionRmColumn = new QAction("Remove column", this);
  connect(actionRmColumn, SIGNAL(triggered()), this, SLOT(rmColumn()));

  actionInsColumn = new QAction("Insert column", this);
  connect(actionInsColumn, SIGNAL(triggered()), this, SLOT(insColumn()));

  actionRmRow = new QAction("Remove row", this);
  connect(actionRmRow, SIGNAL(triggered()), this, SLOT(rmRow()));

  actionInsRow = new QAction("Insert row", this);
  connect(actionInsRow, SIGNAL(triggered()), this, SLOT(insRow()));

  menu = new QMenu(this);

  if (menu)
    {
      menu->addAction(actionRmColumn);
      menu->addAction(actionInsColumn);
      menu->addSeparator();
      menu->addAction(actionRmRow);
      menu->addAction(actionInsRow);
    }

  setEditTriggers(QAbstractItemView::NoEditTriggers);
  setSelectionMode(QAbstractItemView::ContiguousSelection);

  this->horizontalHeader()->setDefaultSectionSize(40);
  this->verticalHeader()->setDefaultSectionSize(40);

  connect(this, SIGNAL(cellClicked(int, int)), this, SLOT(setClickedCell(int, int)));

  mct = new makeCrosswordThread(wi, this);

  QTextOption to;
  to.setWrapMode(QTextOption::WordWrap);
  to.setAlignment(Qt::AlignJustify);

  printDoc.setDefaultTextOption(to);
  //doc.setDefaultFont(font);
}
int QAbstractItemView::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QAbstractScrollArea::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: pressed((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
        case 1: clicked((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
        case 2: doubleClicked((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
        case 3: activated((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
        case 4: entered((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
        case 5: viewportEntered(); break;
        case 6: reset(); break;
        case 7: setRootIndex((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
        case 8: doItemsLayout(); break;
        case 9: selectAll(); break;
        case 10: edit((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
        case 11: clearSelection(); break;
        case 12: setCurrentIndex((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
        case 13: scrollToTop(); break;
        case 14: scrollToBottom(); break;
        case 15: update((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
        case 16: dataChanged((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< const QModelIndex(*)>(_a[2]))); break;
        case 17: rowsInserted((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 18: rowsAboutToBeRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 19: selectionChanged((*reinterpret_cast< const QItemSelection(*)>(_a[1])),(*reinterpret_cast< const QItemSelection(*)>(_a[2]))); break;
        case 20: currentChanged((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< const QModelIndex(*)>(_a[2]))); break;
        case 21: updateEditorData(); break;
        case 22: updateEditorGeometries(); break;
        case 23: updateGeometries(); break;
        case 24: verticalScrollbarAction((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 25: horizontalScrollbarAction((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 26: verticalScrollbarValueChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 27: horizontalScrollbarValueChanged((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 28: closeEditor((*reinterpret_cast< QWidget*(*)>(_a[1])),(*reinterpret_cast< QAbstractItemDelegate::EndEditHint(*)>(_a[2]))); break;
        case 29: commitData((*reinterpret_cast< QWidget*(*)>(_a[1]))); break;
        case 30: editorDestroyed((*reinterpret_cast< QObject*(*)>(_a[1]))); break;
        case 31: d_func()->_q_columnsAboutToBeRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 32: d_func()->_q_columnsRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 33: d_func()->_q_rowsRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 34: d_func()->_q_modelDestroyed(); break;
        case 35: d_func()->_q_layoutChanged(); break;
        case 36: d_func()->_q_fetchMore(); break;
        }
        _id -= 37;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< bool*>(_v) = hasAutoScroll(); break;
        case 1: *reinterpret_cast< int*>(_v) = autoScrollMargin(); break;
        case 2: *reinterpret_cast<int*>(_v) = QFlag(editTriggers()); break;
        case 3: *reinterpret_cast< bool*>(_v) = tabKeyNavigation(); break;
        case 4: *reinterpret_cast< bool*>(_v) = showDropIndicator(); break;
        case 5: *reinterpret_cast< bool*>(_v) = dragEnabled(); break;
        case 6: *reinterpret_cast< bool*>(_v) = dragDropOverwriteMode(); break;
        case 7: *reinterpret_cast< DragDropMode*>(_v) = dragDropMode(); break;
        case 8: *reinterpret_cast< bool*>(_v) = alternatingRowColors(); break;
        case 9: *reinterpret_cast< SelectionMode*>(_v) = selectionMode(); break;
        case 10: *reinterpret_cast< SelectionBehavior*>(_v) = selectionBehavior(); break;
        case 11: *reinterpret_cast< QSize*>(_v) = iconSize(); break;
        case 12: *reinterpret_cast< Qt::TextElideMode*>(_v) = textElideMode(); break;
        case 13: *reinterpret_cast< ScrollMode*>(_v) = verticalScrollMode(); break;
        case 14: *reinterpret_cast< ScrollMode*>(_v) = horizontalScrollMode(); break;
        }
        _id -= 15;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setAutoScroll(*reinterpret_cast< bool*>(_v)); break;
        case 1: setAutoScrollMargin(*reinterpret_cast< int*>(_v)); break;
        case 2: setEditTriggers(QFlag(*reinterpret_cast<int*>(_v))); break;
        case 3: setTabKeyNavigation(*reinterpret_cast< bool*>(_v)); break;
        case 4: setDropIndicatorShown(*reinterpret_cast< bool*>(_v)); break;
        case 5: setDragEnabled(*reinterpret_cast< bool*>(_v)); break;
        case 6: setDragDropOverwriteMode(*reinterpret_cast< bool*>(_v)); break;
        case 7: setDragDropMode(*reinterpret_cast< DragDropMode*>(_v)); break;
        case 8: setAlternatingRowColors(*reinterpret_cast< bool*>(_v)); break;
        case 9: setSelectionMode(*reinterpret_cast< SelectionMode*>(_v)); break;
        case 10: setSelectionBehavior(*reinterpret_cast< SelectionBehavior*>(_v)); break;
        case 11: setIconSize(*reinterpret_cast< QSize*>(_v)); break;
        case 12: setTextElideMode(*reinterpret_cast< Qt::TextElideMode*>(_v)); break;
        case 13: setVerticalScrollMode(*reinterpret_cast< ScrollMode*>(_v)); break;
        case 14: setHorizontalScrollMode(*reinterpret_cast< ScrollMode*>(_v)); break;
        }
        _id -= 15;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 15;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 15;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 15;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 15;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 15;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 15;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Example #16
0
lmcTransferListView::lmcTransferListView(QWidget* parent) : QListView(parent) {
	pModel = new FileModel();
	setModel(pModel);
	setItemDelegate(new FileDelegate);
	setEditTriggers(QAbstractItemView::NoEditTriggers);
}
Example #17
0
Playlist::PrettyListView::PrettyListView( QWidget* parent )
        : QListView( parent )
        , ViewCommon()
        , m_headerPressIndex( QModelIndex() )
        , m_mousePressInHeader( false )
        , m_skipAutoScroll( false )
        , m_firstScrollToActiveTrack( true )
        , m_rowsInsertedScrollItem( 0 )
        , m_showOnlyMatches( false )
        , m_pd( 0 )
{
    // QAbstractItemView basics
    setModel( The::playlist()->qaim() );

    m_prettyDelegate = new PrettyItemDelegate( this );
    connect( m_prettyDelegate, SIGNAL( redrawRequested() ), this, SLOT( redrawActive() ) );
    setItemDelegate( m_prettyDelegate );

    setSelectionMode( ExtendedSelection );
    setDragDropMode( DragDrop );
    setDropIndicatorShown( false ); // we draw our own drop indicator
    setEditTriggers ( SelectedClicked | EditKeyPressed );
    setAutoScroll( true );

    setVerticalScrollMode( ScrollPerPixel );

    setMouseTracking( true );

    // Rendering adjustments
    setFrameShape( QFrame::NoFrame );
    setAlternatingRowColors( true) ;
    The::paletteHandler()->updateItemView( this );
    connect( The::paletteHandler(), SIGNAL(newPalette(QPalette)), SLOT(newPalette(QPalette)) );

    setAutoFillBackground( false );


    // Signal connections
    connect( this, SIGNAL(doubleClicked(QModelIndex)),
             this, SLOT(trackActivated(QModelIndex)) );
    connect( selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)),
             this, SLOT(slotSelectionChanged()) );

    connect( LayoutManager::instance(), SIGNAL(activeLayoutChanged()), this, SLOT(playlistLayoutChanged()) );

    connect( model(), SIGNAL(activeTrackChanged(quint64)), this, SLOT(slotPlaylistActiveTrackChanged()) );

    connect( model(), SIGNAL(queueChanged()), viewport(), SLOT(update()) );

    //   Warning, this one doesn't connect to the normal 'model()' (i.e. '->top()'), but to '->bottom()'.
    connect( Playlist::ModelStack::instance()->bottom(), SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(bottomModelRowsInserted(QModelIndex,int,int)) );

    // Timers
    m_proxyUpdateTimer = new QTimer( this );
    m_proxyUpdateTimer->setSingleShot( true );
    connect( m_proxyUpdateTimer, SIGNAL(timeout()), this, SLOT(updateProxyTimeout()) );

    m_animationTimer = new QTimer(this);
    connect( m_animationTimer, SIGNAL(timeout()), this, SLOT(redrawActive()) );
    m_animationTimer->setInterval( 250 );

    playlistLayoutChanged();

    // We do the following call here to be formally correct, but note:
    //   - It happens to be redundant, because 'playlistLayoutChanged()' already schedules
    //     another one, via a QTimer( 0 ).
    //   - Both that one and this one don't work right (they scroll like 'PositionAtTop',
    //     not 'PositionAtCenter'). This is probably because MainWindow changes its
    //     geometry in a QTimer( 0 )? As a fix, MainWindow does a 'slotShowActiveTrack()'
    //     at the end of its QTimer slot, which will finally scroll to the right spot.
    slotPlaylistActiveTrackChanged();
}
Example #18
0
void PlaylistView::ReloadSettings() {
  QSettings s;
  s.beginGroup(Playlist::kSettingsGroup);
  glow_enabled_ = s.value("glow_effect", true).toBool();

  if (setting_initial_header_layout_ || upgrading_from_qheaderview_) {
    header_->SetStretchEnabled(s.value("stretch", true).toBool());
    upgrading_from_qheaderview_ = false;
  }

  if (currently_glowing_ && glow_enabled_ && isVisible()) StartGlowing();
  if (!glow_enabled_) StopGlowing();

  if (setting_initial_header_layout_) {
    header_->SetColumnWidth(Playlist::Column_Length, 0.06);
    header_->SetColumnWidth(Playlist::Column_Track, 0.05);
    setting_initial_header_layout_ = false;
  }

  if (upgrading_from_version_ != -1) {
    if (upgrading_from_version_ < 4) {
      header_->SetColumnWidth(Playlist::Column_Source, 0.05);
    }
    upgrading_from_version_ = -1;
  }

  column_alignment_ = s.value("column_alignments").value<ColumnAlignmentMap>();
  if (column_alignment_.isEmpty()) {
    column_alignment_ = DefaultColumnAlignment();
  }

  emit ColumnAlignmentChanged(column_alignment_);

  // Background:
  QVariant q_playlistview_background_type =
      s.value(kSettingBackgroundImageType);
  BackgroundImageType background_type(Default);
  // bg_enabled should also be checked for backward compatibility (in releases
  // <= 1.0, there was just a boolean to activate/deactivate the background)
  QVariant bg_enabled = s.value("bg_enabled");
  if (q_playlistview_background_type.isValid()) {
    background_type = static_cast<BackgroundImageType>(
        q_playlistview_background_type.toInt());
  } else if (bg_enabled.isValid()) {
    if (bg_enabled.toBool()) {
      background_type = Default;
    } else {
      background_type = None;
    }
  }
  QString background_image_filename =
      s.value(kSettingBackgroundImageFilename).toString();
  int blur_radius = s.value("blur_radius", kDefaultBlurRadius).toInt();
  int opacity_level = s.value("opacity_level", kDefaultOpacityLevel).toInt();
  // Check if background properties have changed.
  // We change properties only if they have actually changed, to avoid to call
  // set_background_image when it is not needed, as this will cause the fading
  // animation to start again. This also avoid to do useless
  // "force_background_redraw".
  if (background_image_filename != background_image_filename_ ||
      background_type != background_image_type_ ||
      blur_radius_ != blur_radius || opacity_level_ != opacity_level) {
    // Store background properties
    background_image_type_ = background_type;
    background_image_filename_ = background_image_filename;
    blur_radius_ = blur_radius;
    opacity_level_ = opacity_level;
    if (background_image_type_ == Custom) {
      set_background_image(QImage(background_image_filename));
    } else if (background_image_type_ == AlbumCover) {
      set_background_image(current_song_cover_art_);
    } else {
      // User changed background image type to something that will not be
      // painted through paintEvent: reset all background images.
      // This avoid to use old (deprecated) images for fading when selecting
      // AlbumCover or Custom background image type later.
      set_background_image(QImage());
      cached_scaled_background_image_ = QPixmap();
      previous_background_image_ = QPixmap();
    }
    setProperty("default_background_enabled",
                background_image_type_ == Default);
    emit BackgroundPropertyChanged();
    force_background_redraw_ = true;
  }

  if(!s.value("click_edit_inline", true).toBool())
      setEditTriggers(editTriggers() & ~QAbstractItemView::SelectedClicked);
  else
      setEditTriggers(editTriggers() | QAbstractItemView::SelectedClicked);
}
Example #19
0
void SuggestWidget::setModel(QAbstractItemModel *model) {
    QListView::setModel(model);
    setItemDelegate(new SuggestItemDelegate(model, this));
    setEditTriggers(QAbstractItemView::NoEditTriggers);
    setSelectionMode(QAbstractItemView::SingleSelection);
}
Example #20
0
TasksView::TasksView( QToolBar* toolBar, QWidget* parent )
    : QWidget( parent )
    // , ViewInterface()
    , m_delegate( new TasksViewDelegate( this ) )
    , m_actionNewTask( this )
    , m_actionNewSubTask( this )
    , m_actionEditTask( this )
    , m_actionDeleteTask( this )
    , m_actionExpandTree( this )
    , m_actionCollapseTree( this )
    , m_showCurrentOnly( new QButton( toolBar, QButton::Recessed ) )
    , m_showSubscribedOnly( new QButton( toolBar, QButton::Recessed ) )
    , m_treeView( new QTreeView( this ) )
{
    QVBoxLayout* layout = new QVBoxLayout( this );
    layout->setContentsMargins( 0, 0, 0, 0 );
    layout->addWidget( m_treeView );

    m_treeView->setItemDelegate( m_delegate );
    connect( m_delegate, SIGNAL( editingStateChanged() ),
             SLOT( configureUi() ) );

    // set up actions
    m_actionNewTask.setText( tr( "New &Task" ) );
    m_actionNewTask.setShortcut( QKeySequence::New );
    m_actionNewTask.setIcon( Data::newTaskIcon() );
    toolBar->addAction( &m_actionNewTask );
    connect( &m_actionNewTask, SIGNAL( triggered( bool ) ),
             SLOT( actionNewTask() ) );

    m_actionNewSubTask.setText( tr( "New &Subtask" ) );
    m_actionNewSubTask.setShortcut( Qt::META + Qt::Key_N );
    m_actionNewSubTask.setIcon( Data::newSubtaskIcon() );
    toolBar->addAction( &m_actionNewSubTask );
    connect( &m_actionNewSubTask, SIGNAL( triggered( bool ) ),
             SLOT( actionNewSubTask() ) );

    m_actionEditTask.setText( tr( "Edit Task" ) );
    m_actionEditTask.setShortcut( Qt::CTRL + Qt::Key_E );
    m_actionEditTask.setIcon( Data::editTaskIcon() );
    toolBar->addAction( &m_actionEditTask );
    connect( &m_actionEditTask, SIGNAL( triggered( bool ) ),
             SLOT( actionEditTask() ) );

    m_actionDeleteTask.setText( tr( "Delete Task" ) );
    QList<QKeySequence> deleteShortcuts;
    deleteShortcuts << QKeySequence::Delete;
#ifdef Q_WS_MAC
    deleteShortcuts << Qt::Key_Backspace;
#endif
    m_actionDeleteTask.setShortcuts(deleteShortcuts);
    m_actionDeleteTask.setIcon( Data::deleteTaskIcon() );
    toolBar->addAction( &m_actionDeleteTask );
    connect( &m_actionDeleteTask, SIGNAL( triggered( bool ) ),
             SLOT( actionDeleteTask() ) );

    m_actionExpandTree.setText( tr( "Expand All" ) );
    connect( &m_actionExpandTree, SIGNAL( triggered ( bool ) ),
             m_treeView, SLOT( expandAll() ) );

    m_actionCollapseTree.setText( tr( "Collapse All" ) );
    connect( &m_actionCollapseTree, SIGNAL( triggered ( bool ) ),
             m_treeView, SLOT( collapseAll() ) );

    // filter setup
    m_showCurrentOnly->setText( tr( "Current" ) );
    m_showCurrentOnly->setCheckable( true );
#ifdef Q_WS_MAC
    m_showCurrentOnly->setMinimumWidth( 60 );
#endif
    toolBar->addWidget( m_showCurrentOnly );
    connect( m_showCurrentOnly, SIGNAL( clicked( bool ) ),
             SLOT( taskPrefilteringChanged() ) );

    m_showSubscribedOnly->setText( tr( "Selected" ) );
    m_showSubscribedOnly->setCheckable( true );
#ifdef Q_WS_MAC
    m_showSubscribedOnly->setMinimumWidth( 70 );
#endif
    toolBar->addWidget( m_showSubscribedOnly );
    connect( m_showSubscribedOnly, SIGNAL( clicked( bool ) ),
             SLOT( taskPrefilteringChanged() ) );

    QWidget *stretch = new QWidget( this );
    stretch->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
    toolBar->addWidget( stretch );

    QSearchField* searchField = new QSearchField( this );
    connect( searchField, SIGNAL( textChanged( const QString& ) ),
             SLOT( slotFiltertextChanged( const QString& ) ) );
    toolBar->addWidget( searchField );

    m_treeView->setEditTriggers(QAbstractItemView::EditKeyPressed);
    m_treeView->setExpandsOnDoubleClick(false);
    m_treeView->setAlternatingRowColors( true );
    // The delegate does its own eliding.
    m_treeView->setTextElideMode( Qt::ElideNone );
    m_treeView->setRootIsDecorated( true );
    m_treeView->setContextMenuPolicy( Qt::CustomContextMenu );
    connect( m_treeView, SIGNAL( customContextMenuRequested( const QPoint& ) ),
             SLOT( slotContextMenuRequested( const QPoint& ) ) );

    // I hate doing this but the stupid default view sizeHints suck badly.
    setMinimumHeight( 200 );

    // A reasonable default depth.
    m_treeView->expandToDepth( 0 );
}
QCompactTable::QCompactTable(int row, int column)
    : QTableWidget(row, column)
{
    makeCompact(this);
    setEditTriggers(QAbstractItemView::NoEditTriggers);
}
Example #22
0
ClipboardBrowser::ClipboardBrowser(QWidget *parent, const ClipboardBrowserSharedPtr &sharedData)
    : QListView(parent)
    , m_loaded(false)
    , m_id()
    , m_lastFilter()
    , m_update(false)
    , m( new ClipboardModel(this) )
    , d( new ItemDelegate(viewport()) )
    , m_timerSave( new QTimer(this) )
    , m_timerScroll( new QTimer(this) )
    , m_menu( new QMenu(this) )
    , m_sharedData(sharedData ? sharedData : ClipboardBrowserSharedPtr(new ClipboardBrowserShared))
{
    setLayoutMode(QListView::Batched);
    setBatchSize(1);
    setFrameShadow(QFrame::Sunken);
    setTabKeyNavigation(false);
    setAlternatingRowColors(true);
    setSelectionMode(QAbstractItemView::ExtendedSelection);
    setWrapping(false);
    setLayoutMode(QListView::SinglePass);
    setEditTriggers(QAbstractItemView::EditKeyPressed);
    setSpacing(5);

    m_timerSave->setSingleShot(true);
    connect( m_timerSave, SIGNAL(timeout()),
             this, SLOT(saveItems()) );

    m_timerScroll->setSingleShot(true);
    m_timerScroll->setInterval(50);

    // delegate for rendering and editing items
    setItemDelegate(d);

    // set new model
    QItemSelectionModel *old_model = selectionModel();
    setModel(m);
    delete old_model;

    connect( d, SIGNAL(editingActive(bool)),
             SIGNAL(editingActive(bool)) );

    connect( m, SIGNAL(rowsRemoved(QModelIndex,int,int)),
             d, SLOT(rowsRemoved(QModelIndex,int,int)) );
    connect( m, SIGNAL(rowsInserted(QModelIndex, int, int)),
             d, SLOT(rowsInserted(QModelIndex, int, int)) );
    connect( m, SIGNAL(rowsMoved(QModelIndex, int, int, QModelIndex, int)),
             d, SLOT(rowsMoved(QModelIndex, int, int, QModelIndex, int)) );

    // save if data in model changed
    connect( m, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
             SLOT(onDataChanged(QModelIndex,QModelIndex)) );
    connect( m, SIGNAL(rowsRemoved(QModelIndex,int,int)),
             SLOT(delayedSaveItems()) );
    connect( m, SIGNAL(rowsInserted(QModelIndex, int, int)),
             SLOT(delayedSaveItems()) );
    connect( m, SIGNAL(rowsMoved(QModelIndex, int, int, QModelIndex, int)),
             SLOT(delayedSaveItems()) );

    // update on change
    connect( d, SIGNAL(rowSizeChanged(int)),
             SLOT(onRowSizeChanged(int)) );
    connect( m, SIGNAL(rowsRemoved(QModelIndex,int,int)),
             SLOT(updateCurrentPage()) );
    connect( m, SIGNAL(rowsInserted(QModelIndex, int, int)),
             SLOT(updateCurrentPage()) );
    connect( m, SIGNAL(rowsMoved(QModelIndex, int, int, QModelIndex, int)),
             SLOT(updateCurrentPage()) );
    connect( verticalScrollBar(), SIGNAL(valueChanged(int)),
             SLOT(updateCurrentPage()) );
    connect( verticalScrollBar(), SIGNAL(rangeChanged(int,int)),
             SLOT(updateCurrentPage()), Qt::QueuedConnection );

    // ScrollPerItem doesn't work well with hidden items
    setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);

    setAttribute(Qt::WA_MacShowFocusRect, 0);
}