Beispiel #1
0
void FSTableView::dropEvent(QDropEvent *event)
{
    QStringList list;
    foreach (QUrl url, event->mimeData()->urls())
        list.append(url.toLocalFile());

    qDebug()<<list;
    emit filesAdded(list);

    viewport()->setStyleSheet(QString());
    showColumn(0);
    showColumn(1);
    showColumn(2);


}
Beispiel #2
0
void GameList::ShowContextMenu(const QPoint& pos)
{
    QMenu headerMenu;
    QAction* filterTag = headerMenu.addAction(tr("Find tag..."));
    headerMenu.addSeparator();
    QAction* hide = headerMenu.addAction(tr("Hide Column"));
    headerMenu.addSeparator();
    QAction* resizeAll = headerMenu.addAction(tr("Resize visible Columns"));
    QAction* showAll = headerMenu.addAction(tr("Show all Columns"));

    QAction* selectedItem = headerMenu.exec(mapToGlobal(pos));
    int column = columnAt(pos.x());
    if (selectedItem == filterTag)
    {
        simpleSearch(column);
    }
    else if(selectedItem == hide)
    {
        if(column > 0)
        {
            hideColumn(column);
        }
    }
    else if(selectedItem == showAll)
    {
        for(int i = 0; i < model()->columnCount(); ++i)
        {
            showColumn(i);
        }
    }
    else if (selectedItem == resizeAll)
    {
        resizeColumnsToContents();
    }
}
void PeerListWidget::updatePeerCountryResolutionState()
{
  if (Preferences::instance()->resolvePeerCountries() != m_displayFlags) {
    m_displayFlags = !m_displayFlags;
    if (m_displayFlags) {
      loadPeers(m_properties->getCurrentTorrent());
      showColumn(PeerListDelegate::COUNTRY);
      resizeColumnToContents(PeerListDelegate::COUNTRY);
    }
    else {
        hideColumn(PeerListDelegate::COUNTRY);
    }
  }
}
Beispiel #4
0
void UPacketMonitor::onShowHideColumnToggled(bool checked)
{
    QAction *action = qobject_cast<QAction *>(sender());
    if(action)
    {
        if(checked)
        {
            showColumn(action->data().toInt());
        }
        else
        {
            hideColumn(action->data().toInt());
        }
    }
}
int QTreeView::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QAbstractItemView::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: expanded((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
        case 1: collapsed((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
        case 2: hideColumn((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 3: showColumn((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 4: expand((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
        case 5: collapse((*reinterpret_cast< const QModelIndex(*)>(_a[1]))); break;
        case 6: resizeColumnToContents((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 7: sortByColumn((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 8: expandAll(); break;
        case 9: collapseAll(); break;
        case 10: expandToDepth((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 11: columnResized((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 12: columnCountChanged((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 13: columnMoved(); break;
        case 14: reexpand(); break;
        case 15: rowsRemoved((*reinterpret_cast< const QModelIndex(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2])),(*reinterpret_cast< int(*)>(_a[3]))); break;
        case 16: d_func()->_q_endAnimatedOperation(); break;
        case 17: d_func()->_q_modelAboutToBeReset(); break;
        case 18: d_func()->_q_sortIndicatorChanged((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< Qt::SortOrder(*)>(_a[2]))); break;
        default: ;
        }
        _id -= 19;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< int*>(_v) = autoExpandDelay(); break;
        case 1: *reinterpret_cast< int*>(_v) = indentation(); break;
        case 2: *reinterpret_cast< bool*>(_v) = rootIsDecorated(); break;
        case 3: *reinterpret_cast< bool*>(_v) = uniformRowHeights(); break;
        case 4: *reinterpret_cast< bool*>(_v) = itemsExpandable(); break;
        case 5: *reinterpret_cast< bool*>(_v) = isSortingEnabled(); break;
        case 6: *reinterpret_cast< bool*>(_v) = isAnimated(); break;
        case 7: *reinterpret_cast< bool*>(_v) = allColumnsShowFocus(); break;
        case 8: *reinterpret_cast< bool*>(_v) = wordWrap(); break;
        case 9: *reinterpret_cast< bool*>(_v) = isHeaderHidden(); break;
        case 10: *reinterpret_cast< bool*>(_v) = expandsOnDoubleClick(); break;
        }
        _id -= 11;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setAutoExpandDelay(*reinterpret_cast< int*>(_v)); break;
        case 1: setIndentation(*reinterpret_cast< int*>(_v)); break;
        case 2: setRootIsDecorated(*reinterpret_cast< bool*>(_v)); break;
        case 3: setUniformRowHeights(*reinterpret_cast< bool*>(_v)); break;
        case 4: setItemsExpandable(*reinterpret_cast< bool*>(_v)); break;
        case 5: setSortingEnabled(*reinterpret_cast< bool*>(_v)); break;
        case 6: setAnimated(*reinterpret_cast< bool*>(_v)); break;
        case 7: setAllColumnsShowFocus(*reinterpret_cast< bool*>(_v)); break;
        case 8: setWordWrap(*reinterpret_cast< bool*>(_v)); break;
        case 9: setHeaderHidden(*reinterpret_cast< bool*>(_v)); break;
        case 10: setExpandsOnDoubleClick(*reinterpret_cast< bool*>(_v)); break;
        }
        _id -= 11;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 11;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 11;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Beispiel #6
0
FieldView::FieldView(QWidget* parent)
    : QTreeView(parent), m_mapper(new QSignalMapper(this))
{
    //Item action
    m_delItem = new QAction(tr("Delete Item"),this);
    m_applyValueOnSelection = new QAction(tr("Apply on Selection"),this);
    m_applyValueOnAllLines = new QAction(tr("Apply on all lines"),this);
    m_defineCode = new QAction(tr("Define Field Code"),this);
    m_resetCode = new QAction(tr("Reset Field Code"),this);

    m_showGeometryGroup = new QAction(tr("Position columns"),this);
    connect(m_showGeometryGroup,&QAction::triggered,this,[=](){
        hideAllColumns(true);
        showColumn(CharacterSheetItem::ID);
        showColumn(CharacterSheetItem::LABEL);
        showColumn(CharacterSheetItem::X);
        showColumn(CharacterSheetItem::Y);
        showColumn(CharacterSheetItem::WIDTH);
        showColumn(CharacterSheetItem::HEIGHT);
        showColumn(CharacterSheetItem::PAGE);
    });
    m_showEsteticGroup= new QAction(tr("Esthetic columns"),this);
    connect(m_showEsteticGroup,&QAction::triggered,this,[=](){
        hideAllColumns(true);
        showColumn(CharacterSheetItem::ID);
        showColumn(CharacterSheetItem::LABEL);
        showColumn(CharacterSheetItem::BGCOLOR);
        showColumn(CharacterSheetItem::BORDER);
        showColumn(CharacterSheetItem::CLIPPED);
        showColumn(CharacterSheetItem::FONT);
        showColumn(CharacterSheetItem::TEXT_ALIGN);
        showColumn(CharacterSheetItem::TEXTCOLOR);
    });
    m_showValueGroup= new QAction(tr("Value columns"),this);
    connect(m_showValueGroup,&QAction::triggered,this,[=](){
        hideAllColumns(true);
        showColumn(CharacterSheetItem::ID);
        showColumn(CharacterSheetItem::LABEL);
        showColumn(CharacterSheetItem::VALUE);
        showColumn(CharacterSheetItem::VALUES);
        showColumn(CharacterSheetItem::TYPE);
    });
    m_showIdGroup= new QAction(tr("Id columns"),this);
    connect(m_showIdGroup,&QAction::triggered,this,[=](){
        hideAllColumns(true);
        showColumn(CharacterSheetItem::ID);
        showColumn(CharacterSheetItem::LABEL);
    });

    m_showAllGroup= new QAction(tr("All columns"),this);
    connect(m_showAllGroup,&QAction::triggered,this,[=](){
        hideAllColumns(false);
    });

    setAlternatingRowColors(true);
#ifdef Q_OS_MACX
    setAlternatingRowColors(false);
#endif

    connect(this,SIGNAL(doubleClicked(QModelIndex)),this,SLOT(editColor(QModelIndex)));

    AlignmentDelegate* delegate = new AlignmentDelegate(this);
    setItemDelegateForColumn(static_cast<int>(CharacterSheetItem::TEXT_ALIGN),delegate);

    TypeDelegate* typeDelegate = new TypeDelegate(this);
    setItemDelegateForColumn(static_cast<int>(CharacterSheetItem::TYPE),typeDelegate);

    FontDelegate* fontDelegate = new FontDelegate(this);
    setItemDelegateForColumn(static_cast<int>(CharacterSheetItem::FONT),fontDelegate);

    PageDelegate* pageDelegate = new PageDelegate(this);
    setItemDelegateForColumn(static_cast<int>(CharacterSheetItem::PAGE),pageDelegate);

    setItemDelegateForColumn(CharacterSheetItem::BORDER,new BorderListEditor);

    connect(m_mapper,static_cast<void (QSignalMapper::*)(int)>(&QSignalMapper::mapped),this,[this](int i)
    {
        this->setColumnHidden(i,!this->isColumnHidden(i));
    });
}
Beispiel #7
0
bool QTable::qt_invoke( int _id, QUObject* _o )
{
    switch ( _id - staticMetaObject()->slotOffset() ) {
    case 0: setNumRows((int)static_QUType_int.get(_o+1)); break;
    case 1: setNumCols((int)static_QUType_int.get(_o+1)); break;
    case 2: setShowGrid((bool)static_QUType_bool.get(_o+1)); break;
    case 3: hideRow((int)static_QUType_int.get(_o+1)); break;
    case 4: hideColumn((int)static_QUType_int.get(_o+1)); break;
    case 5: showRow((int)static_QUType_int.get(_o+1)); break;
    case 6: showColumn((int)static_QUType_int.get(_o+1)); break;
    case 7: static_QUType_bool.set(_o,isRowHidden((int)static_QUType_int.get(_o+1))); break;
    case 8: static_QUType_bool.set(_o,isColumnHidden((int)static_QUType_int.get(_o+1))); break;
    case 9: setColumnWidth((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 10: setRowHeight((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 11: adjustColumn((int)static_QUType_int.get(_o+1)); break;
    case 12: adjustRow((int)static_QUType_int.get(_o+1)); break;
    case 13: setColumnStretchable((int)static_QUType_int.get(_o+1),(bool)static_QUType_bool.get(_o+2)); break;
    case 14: setRowStretchable((int)static_QUType_int.get(_o+1),(bool)static_QUType_bool.get(_o+2)); break;
    case 15: static_QUType_bool.set(_o,isColumnStretchable((int)static_QUType_int.get(_o+1))); break;
    case 16: static_QUType_bool.set(_o,isRowStretchable((int)static_QUType_int.get(_o+1))); break;
    case 17: setSorting((bool)static_QUType_bool.get(_o+1)); break;
    case 18: swapRows((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 19: swapRows((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(bool)static_QUType_bool.get(_o+3)); break;
    case 20: swapColumns((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 21: swapColumns((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(bool)static_QUType_bool.get(_o+3)); break;
    case 22: swapCells((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(int)static_QUType_int.get(_o+3),(int)static_QUType_int.get(_o+4)); break;
    case 23: setLeftMargin((int)static_QUType_int.get(_o+1)); break;
    case 24: setTopMargin((int)static_QUType_int.get(_o+1)); break;
    case 25: setCurrentCell((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 26: clearSelection(); break;
    case 27: clearSelection((bool)static_QUType_bool.get(_o+1)); break;
    case 28: setColumnMovingEnabled((bool)static_QUType_bool.get(_o+1)); break;
    case 29: setRowMovingEnabled((bool)static_QUType_bool.get(_o+1)); break;
    case 30: setReadOnly((bool)static_QUType_bool.get(_o+1)); break;
    case 31: setRowReadOnly((int)static_QUType_int.get(_o+1),(bool)static_QUType_bool.get(_o+2)); break;
    case 32: setColumnReadOnly((int)static_QUType_int.get(_o+1),(bool)static_QUType_bool.get(_o+2)); break;
    case 33: setDragEnabled((bool)static_QUType_bool.get(_o+1)); break;
    case 34: static_QUType_bool.set(_o,dragEnabled()); break;
    case 35: insertRows((int)static_QUType_int.get(_o+1)); break;
    case 36: insertRows((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 37: insertColumns((int)static_QUType_int.get(_o+1)); break;
    case 38: insertColumns((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 39: removeRow((int)static_QUType_int.get(_o+1)); break;
    case 40: removeRows((const QMemArray<int>&)*((const QMemArray<int>*)static_QUType_ptr.get(_o+1))); break;
    case 41: removeColumn((int)static_QUType_int.get(_o+1)); break;
    case 42: removeColumns((const QMemArray<int>&)*((const QMemArray<int>*)static_QUType_ptr.get(_o+1))); break;
    case 43: editCell((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2)); break;
    case 44: editCell((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(bool)static_QUType_bool.get(_o+3)); break;
    case 45: setRowLabels((const QStringList&)*((const QStringList*)static_QUType_ptr.get(_o+1))); break;
    case 46: setColumnLabels((const QStringList&)*((const QStringList*)static_QUType_ptr.get(_o+1))); break;
    case 47: columnWidthChanged((int)static_QUType_int.get(_o+1)); break;
    case 48: rowHeightChanged((int)static_QUType_int.get(_o+1)); break;
    case 49: columnIndexChanged((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(int)static_QUType_int.get(_o+3)); break;
    case 50: rowIndexChanged((int)static_QUType_int.get(_o+1),(int)static_QUType_int.get(_o+2),(int)static_QUType_int.get(_o+3)); break;
    case 51: columnClicked((int)static_QUType_int.get(_o+1)); break;
    case 52: doAutoScroll(); break;
    case 53: doValueChanged(); break;
    case 54: updateGeometriesSlot(); break;
    default:
	return QScrollView::qt_invoke( _id, _o );
    }
    return TRUE;
}
PeerListWidget::PeerListWidget(PropertiesWidget *parent):
  QTreeView(parent), m_properties(parent), m_displayFlags(false)
{
  // Load settings
  loadSettings();
  // Visual settings
  setUniformRowHeights(true);
  setRootIsDecorated(false);
  setItemsExpandable(false);
  setAllColumnsShowFocus(true);
  setSelectionMode(QAbstractItemView::ExtendedSelection);
  // List Model
  m_listModel = new QStandardItemModel(0, PeerListDelegate::COL_COUNT);
  m_listModel->setHeaderData(PeerListDelegate::COUNTRY, Qt::Horizontal, QVariant()); // Country flag column
  m_listModel->setHeaderData(PeerListDelegate::IP, Qt::Horizontal, tr("IP"));
  m_listModel->setHeaderData(PeerListDelegate::PORT, Qt::Horizontal, tr("Port"));
  m_listModel->setHeaderData(PeerListDelegate::FLAGS, Qt::Horizontal, tr("Flags"));
  m_listModel->setHeaderData(PeerListDelegate::CONNECTION, Qt::Horizontal, tr("Connection"));
  m_listModel->setHeaderData(PeerListDelegate::CLIENT, Qt::Horizontal, tr("Client", "i.e.: Client application"));
  m_listModel->setHeaderData(PeerListDelegate::PROGRESS, Qt::Horizontal, tr("Progress", "i.e: % downloaded"));
  m_listModel->setHeaderData(PeerListDelegate::DOWN_SPEED, Qt::Horizontal, tr("Down Speed", "i.e: Download speed"));
  m_listModel->setHeaderData(PeerListDelegate::UP_SPEED, Qt::Horizontal, tr("Up Speed", "i.e: Upload speed"));
  m_listModel->setHeaderData(PeerListDelegate::TOT_DOWN, Qt::Horizontal, tr("Downloaded", "i.e: total data downloaded"));
  m_listModel->setHeaderData(PeerListDelegate::TOT_UP, Qt::Horizontal, tr("Uploaded", "i.e: total data uploaded"));
  m_listModel->setHeaderData(PeerListDelegate::RELEVANCE, Qt::Horizontal, tr("Relevance", "i.e: How relevant this peer is to us. How many pieces it has that we don't."));
  // Proxy model to support sorting without actually altering the underlying model
  m_proxyModel = new PeerListSortModel();
  m_proxyModel->setDynamicSortFilter(true);
  m_proxyModel->setSourceModel(m_listModel);
  m_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
  setModel(m_proxyModel);
  //Explicitly set the column visibility. When columns are added/removed
  //between versions this prevents some of them being hidden due to
  //incorrect restoreState() being used.
  for (unsigned int i=0; i<PeerListDelegate::IP_HIDDEN; i++)
    showColumn(i);
  hideColumn(PeerListDelegate::IP_HIDDEN);
  hideColumn(PeerListDelegate::COL_COUNT);
  if (!Preferences::instance()->resolvePeerCountries())
    hideColumn(PeerListDelegate::COUNTRY);
  //To also mitigate the above issue, we have to resize each column when
  //its size is 0, because explicitly 'showing' the column isn't enough
  //in the above scenario.
  for (unsigned int i=0; i<PeerListDelegate::IP_HIDDEN; i++)
    if (!columnWidth(i))
      resizeColumnToContents(i);
  // Context menu
  setContextMenuPolicy(Qt::CustomContextMenu);
  connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showPeerListMenu(QPoint)));
  // List delegate
  m_listDelegate = new PeerListDelegate(this);
  setItemDelegate(m_listDelegate);
  // Enable sorting
  setSortingEnabled(true);
  // IP to Hostname resolver
  updatePeerHostNameResolutionState();
  // SIGNAL/SLOT
  connect(header(), SIGNAL(sectionClicked(int)), SLOT(handleSortColumnChanged(int)));
  handleSortColumnChanged(header()->sortIndicatorSection());
  copyHotkey = new QShortcut(QKeySequence(Qt::ControlModifier + Qt::Key_C), this, SLOT(copySelectedPeers()), 0, Qt::WidgetShortcut);
}