Ejemplo n.º 1
0
akuTreeWidget::akuTreeWidget(QWidget *parent) : QTreeWidget(parent)
{
  setDragEnabled(false);
  setDragDropOverwriteMode(false);
  setDragDropMode(QAbstractItemView::NoDragDrop);
  setAlternatingRowColors(true);
  setSelectionMode(QAbstractItemView::ExtendedSelection);
  setAutoExpandDelay(-1);
  setRootIsDecorated(true);
  setUniformRowHeights(false);
  setSortingEnabled(true);
  setAnimated(true);
  setAllColumnsShowFocus(true);
  headerItem()->setText(0, i18n("File Name", 0));
  headerItem()->setText(1, i18n("Size", 0));
  headerItem()->setText(2, i18n("Packed Size", 0));
  headerItem()->setText(3, i18n("Ratio", 0));
  headerItem()->setText(4, i18n("Modified", 0));
  headerItem()->setText(5, i18n("Attributes", 0));
  headerItem()->setText(6, i18n("CRC", 0));
  headerItem()->setText(7, i18n("Method", 0));
  headerItem()->setText(8, i18n("Version", 0));
  headerItem()->setText(9, i18n("MIME Type", 0));
  headerItem()->setText(10,"");
  headerItem()->setIcon(10,KIcon("document-properties"));
  headerItem()->setToolTip(10, i18n("Status: a key is shown if the file is crypted"));
  header() -> moveSection(10,0);
  header() -> setResizeMode(10,QHeaderView::ResizeToContents);
  header() -> setResizeMode(4,QHeaderView::ResizeToContents);
  setupActions();
}
Ejemplo n.º 2
0
DirTreeView::DirTreeView(QWidget *parent) :
    QTreeView(parent)
  , popupMenu(this)
{
    setAcceptDrops(true);
    setAutoScroll(true);
    setAutoExpandDelay(1000);
}
Ejemplo n.º 3
0
QxFileSystemView::QxFileSystemView(QWidget* parent)
	: QTreeView(parent),
	  ignoreNextFocusOutEvent_(false)
{
	setEditTriggers(QAbstractItemView::SelectedClicked|QAbstractItemView::EditKeyPressed);
	setUniformRowHeights(true); // performance HACK
	setDragDropMode(QAbstractItemView::DragDrop);
	setAutoExpandDelay(700);
	setTextElideMode(Qt::ElideMiddle);
	// setSelectionMode(QAbstractItemView::ExtendedSelection);
}
/** Initializes the view. */
void CBookmarkIndex::initView()
{
	//qDebug("CBookmarkIndex::initView");

	header()->hide();

	setFocusPolicy(Qt::WheelFocus);

	//d'n'd related settings
	setDragEnabled( true );
	setAcceptDrops( true );
	setDragDropMode(QAbstractItemView::DragDrop);
	viewport()->setAcceptDrops(true);
	setAutoScroll(true);
	setAutoExpandDelay(800);

	setItemsExpandable(true);
	setRootIsDecorated(true);
	setAllColumnsShowFocus(true);
	setSelectionMode(QAbstractItemView::ExtendedSelection);

	//setup the popup menu
	m_popup = new QMenu(viewport());
	m_popup->setTitle(tr("Bookmarks"));

	m_actions.newFolder = newQAction(tr("New folder"), CResMgr::mainIndex::newFolder::icon, 0, this, SLOT(createNewFolder()), this);
	m_actions.changeFolder = newQAction(tr("Rename folder"),CResMgr::mainIndex::changeFolder::icon, 0, this, SLOT(changeFolder()), this);

	m_actions.changeBookmark = newQAction(tr("Change bookmark description..."), CResMgr::mainIndex::changeBookmark::icon, 0, this, SLOT(changeBookmark()), this);
	m_actions.importBookmarks = newQAction(tr("Import to folder..."), CResMgr::mainIndex::importBookmarks::icon, 0, this, SLOT(importBookmarks()), this);
	m_actions.exportBookmarks = newQAction(tr("Export from folder..."), CResMgr::mainIndex::exportBookmarks::icon, 0, this, SLOT(exportBookmarks()), this);
	m_actions.printBookmarks = newQAction(tr("Print bookmarks..."), CResMgr::mainIndex::printBookmarks::icon, 0, this, SLOT(printBookmarks()), this);

	m_actions.deleteEntries = newQAction(tr("Remove selected items..."), CResMgr::mainIndex::deleteItems::icon, 0, this, SLOT(deleteEntries()), this);


	//fill the popup menu itself
	m_popup->addAction(m_actions.newFolder);
	m_popup->addAction(m_actions.changeFolder);
	QAction* separator = new QAction(this);
	separator->setSeparator(true);
	m_popup->addAction(separator);
	m_popup->addAction(m_actions.changeBookmark);
	m_popup->addAction(m_actions.importBookmarks);
	m_popup->addAction(m_actions.exportBookmarks);
	m_popup->addAction(m_actions.printBookmarks);
	separator = new QAction(this);
	separator->setSeparator(true);
	m_popup->addAction(separator);
	m_popup->addAction(m_actions.deleteEntries);

	//qDebug("CBookmarkIndex::initView end");
}
Ejemplo n.º 5
0
MailBoxTreeView::MailBoxTreeView()
{
    setUniformRowHeights(true);
    setContextMenuPolicy(Qt::CustomContextMenu);
    setSelectionMode(QAbstractItemView::SingleSelection);
    setAllColumnsShowFocus(true);
    setAcceptDrops(true);
    setDropIndicatorShown(true);
    setHeaderHidden(true);
    // I wonder what's the best value to use here. Unfortunately, the default is to disable auto expanding.
    setAutoExpandDelay(800);
}
Ejemplo n.º 6
0
SearchEditorTreeView::SearchEditorTreeView(QWidget *parent)
    : QTreeView(parent)
{
    setDragEnabled(true);
    setAcceptDrops(false);
    setDropIndicatorShown(true);
    setDragDropMode(QAbstractItemView::InternalMove);
    setAutoScroll(true);
    setSelectionMode(QAbstractItemView::ExtendedSelection);
    setSelectionBehavior(QAbstractItemView::SelectRows);
    setSortingEnabled(false);
    setTabKeyNavigation(true);
    setAutoExpandDelay(200);
}
Ejemplo n.º 7
0
AlbumTreeView::AlbumTreeView(QWidget* const parent, Flags flags)
    : AbstractCheckableAlbumTreeView(parent, flags)
{
    setDragEnabled(true);
    setAcceptDrops(true);
    setAutoScroll(false);   // Workaround for bug 400960
    setRootIsDecorated(false);
    setDropIndicatorShown(false);
    setAutoExpandDelay(AUTOEXPANDDELAY);

    if (flags & CreateDefaultModel)
    {
        setAlbumModel(new AlbumModel(AlbumModel::IncludeRootAlbum, this));
    }
}
Ejemplo n.º 8
0
DirectoryTree::DirectoryTree(QWidget *parent)
    : QTreeView(parent)
{
    assert(NULL != parent);

    // model
    PkmPlugin *plugin = dynamic_cast<PkmPlugin*>(get_plugin().pointer());
    assert(NULL != plugin);
    DirectoryTreeModel *model = new DirectoryTreeModel(plugin->get_data_source()->get_db(), parent);
    connect(this, SIGNAL(expanded(QModelIndex)), model, SLOT(on_expanded(QModelIndex)));
    connect(this, SIGNAL(collapsed(QModelIndex)), model, SLOT(on_collapsed(QModelIndex)));
    setModel(model);

    // actions
    init_actions();

    // menus
    init_menus();

    // 双击展开而非进入编辑模式
    setExpandsOnDoubleClick(true);
    setAutoExpandDelay(600); // 拖拽时自动展开节点的延时(ms)
    setEditTriggers(EditKeyPressed);
    setMinimumWidth(140);

    // 隐藏首部
    setHeaderHidden(true);

    // 拖拽相关
    setSelectionMode(QAbstractItemView::SingleSelection); // 单选
    setDragEnabled(true); // 允许"拖"
    setAcceptDrops(true); // 允许"放"
    setDropIndicatorShown(true); // ?
    setDragDropMode(QAbstractItemView::DragDrop);
    setDefaultDropAction(Qt::MoveAction);

    // signals
    connect(this, SIGNAL(activated(QModelIndex)), this, SLOT(on_item_activated(QModelIndex)));
    // connect(this, SIGNAL(clicked(QModelIndex)), this, SLOT(on_item_activated(QModelIndex)));
    connect(selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), this, SLOT(on_item_selected(QModelIndex,QModelIndex)));
    plugin->locate_directory.connect(this, &DirectoryTree::on_locate_directory);
}
Ejemplo n.º 9
0
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;
}