mirror of
https://github.com/Lurkki14/tuxclocker.git
synced 2024-11-28 19:03:50 -06:00
qt: update ReadableBrowser
This commit is contained in:
parent
ce7ee06bb1
commit
ae6ef819f6
@ -6,9 +6,14 @@
|
|||||||
ReadableBrowser::ReadableBrowser(ReadableManager *readableManager, QWidget *parent) : QWidget(parent) {
|
ReadableBrowser::ReadableBrowser(ReadableManager *readableManager, QWidget *parent) : QWidget(parent) {
|
||||||
m_mainLayout = new QVBoxLayout;
|
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;
|
m_readableManager = readableManager;
|
||||||
|
|
||||||
@ -17,13 +22,12 @@ ReadableBrowser::ReadableBrowser(ReadableManager *readableManager, QWidget *pare
|
|||||||
m_mainLayout->addWidget(m_readableTreeView);
|
m_mainLayout->addWidget(m_readableTreeView);
|
||||||
|
|
||||||
setLayout(m_mainLayout);
|
setLayout(m_mainLayout);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ReadableBrowser::~ReadableBrowser() {
|
ReadableBrowser::~ReadableBrowser() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReadableBrowser::genBrowserTree(QTreeView *treeView, QStandardItemModel *itemModel) {
|
void ReadableBrowser::genBrowserTree(ReadableTreeView *treeView, QStandardItemModel *itemModel) {
|
||||||
QStandardItem *parentItem = itemModel->invisibleRootItem();
|
QStandardItem *parentItem = itemModel->invisibleRootItem();
|
||||||
|
|
||||||
std::function<void(tc_readable_node_t*, QStandardItem*)> traverse;
|
std::function<void(tc_readable_node_t*, QStandardItem*)> traverse;
|
||||||
@ -74,11 +78,3 @@ QStandardItem *ReadableBrowser::addBrowserItem(tc_readable_node_t* node, QStanda
|
|||||||
|
|
||||||
return item;
|
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();
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
@ -7,7 +7,9 @@
|
|||||||
#include <QDropEvent>
|
#include <QDropEvent>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
#include <QStandardItemModel>
|
|
||||||
|
#include <ReadableItemModel.h>
|
||||||
|
#include <ReadableTreeView.h>
|
||||||
|
|
||||||
class ReadableBrowser : public QWidget {
|
class ReadableBrowser : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -15,16 +17,14 @@ public:
|
|||||||
ReadableBrowser(ReadableManager *readableManager, QWidget *parent = nullptr);
|
ReadableBrowser(ReadableManager *readableManager, QWidget *parent = nullptr);
|
||||||
~ReadableBrowser();
|
~ReadableBrowser();
|
||||||
signals:
|
signals:
|
||||||
void itemDragStarted(QString &text);
|
void itemDragStarted();
|
||||||
private:
|
private:
|
||||||
ReadableManager *m_readableManager; // ReadableManager instance that the browser is generated from
|
ReadableManager *m_readableManager; // ReadableManager instance that the browser is generated from
|
||||||
|
|
||||||
QVBoxLayout *m_mainLayout;
|
QVBoxLayout *m_mainLayout;
|
||||||
QTreeView *m_readableTreeView;
|
ReadableTreeView *m_readableTreeView;
|
||||||
QStandardItemModel *m_browserModel;
|
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'
|
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
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user