qt: update ReadableBrowser

This commit is contained in:
Jussi Kuokkanen 2019-11-17 15:18:45 +02:00
parent ce7ee06bb1
commit ae6ef819f6
2 changed files with 15 additions and 19 deletions

View File

@ -6,9 +6,14 @@
ReadableBrowser::ReadableBrowser(ReadableManager *readableManager, QWidget *parent) : QWidget(parent) {
m_mainLayout = new QVBoxLayout;
m_readableTreeView = new QTreeView;
m_readableTreeView = new ReadableTreeView;
m_browserModel = new QStandardItemModel;
// Forward ReadableTreeView::itemDragStarted to ReadableWidget
connect(m_readableTreeView, &ReadableTreeView::itemDragStarted, [=]() {
emit itemDragStarted();
});
m_browserModel = new ReadableItemModel;
m_readableManager = readableManager;
@ -17,13 +22,12 @@ ReadableBrowser::ReadableBrowser(ReadableManager *readableManager, QWidget *pare
m_mainLayout->addWidget(m_readableTreeView);
setLayout(m_mainLayout);
}
ReadableBrowser::~ReadableBrowser() {
}
void ReadableBrowser::genBrowserTree(QTreeView *treeView, QStandardItemModel *itemModel) {
void ReadableBrowser::genBrowserTree(ReadableTreeView *treeView, QStandardItemModel *itemModel) {
QStandardItem *parentItem = itemModel->invisibleRootItem();
std::function<void(tc_readable_node_t*, QStandardItem*)> traverse;
@ -74,11 +78,3 @@ QStandardItem *ReadableBrowser::addBrowserItem(tc_readable_node_t* node, QStanda
return item;
}
void ReadableBrowser::mousePressEvent(QMouseEvent *event) {
/*if (event->button() == Qt::LeftButton) {
QDrag *drag = new QDrag(this);
Qt::DropAction dropAction = drag->exec(Qt::MoveAction);
qDebug() << drag->mimeData();
}*/
}

View File

@ -7,7 +7,9 @@
#include <QDropEvent>
#include <QVBoxLayout>
#include <QTreeView>
#include <QStandardItemModel>
#include <ReadableItemModel.h>
#include <ReadableTreeView.h>
class ReadableBrowser : public QWidget {
Q_OBJECT
@ -15,16 +17,14 @@ public:
ReadableBrowser(ReadableManager *readableManager, QWidget *parent = nullptr);
~ReadableBrowser();
signals:
void itemDragStarted(QString &text);
void itemDragStarted();
private:
ReadableManager *m_readableManager; // ReadableManager instance that the browser is generated from
QVBoxLayout *m_mainLayout;
QTreeView *m_readableTreeView;
QStandardItemModel *m_browserModel;
ReadableTreeView *m_readableTreeView;
ReadableItemModel *m_browserModel;
void genBrowserTree(QTreeView *treeView, QStandardItemModel *itemModel);
void genBrowserTree(ReadableTreeView *treeView, QStandardItemModel *itemModel);
QStandardItem *addBrowserItem(tc_readable_node_t* node, QStandardItem *parent); // Return a newly created item that is a child of 'parent'
void mousePressEvent(QMouseEvent *event); // Start the drag event for an item
};