Sun, 18 Sep 2016 07:45:42 +0200
adds some qt stuff
sidebar container
tableview can be updated
implements textarea setposition
ui/qt/container.cpp | file | annotate | diff | comparison | revisions | |
ui/qt/container.h | file | annotate | diff | comparison | revisions | |
ui/qt/model.cpp | file | annotate | diff | comparison | revisions | |
ui/qt/model.h | file | annotate | diff | comparison | revisions | |
ui/qt/text.cpp | file | annotate | diff | comparison | revisions | |
ui/qt/text.h | file | annotate | diff | comparison | revisions | |
ui/qt/toolkit.cpp | file | annotate | diff | comparison | revisions | |
ui/qt/tree.cpp | file | annotate | diff | comparison | revisions | |
ui/qt/tree.h | file | annotate | diff | comparison | revisions |
--- a/ui/qt/container.cpp Sat Sep 17 19:57:55 2016 +0200 +++ b/ui/qt/container.cpp Sun Sep 18 07:45:42 2016 +0200 @@ -32,6 +32,7 @@ #include <QSpacerItem> #include <QStackedWidget> + /* -------------------- UiBoxContainer -------------------- */ UiBoxContainer::UiBoxContainer(QBoxLayout* box) { @@ -162,6 +163,9 @@ tabwidget->addTab(widget, str); } + +/* -------------------- UiStackContainer -------------------- */ + UiStackContainer::UiStackContainer(QStackedWidget *stack) { this->stack = stack; } @@ -196,6 +200,34 @@ } +/* -------------------- UiSidebarContainer -------------------- */ + +UiSidebarContainer::UiSidebarContainer(QSplitter *splitter) { + this->splitter = splitter; +} + +UIWIDGET ui_sidebar(UiObject *obj) { + QSplitter *splitter = new QSplitter(Qt::Horizontal); + UiContainer *ct = uic_get_current_container(obj); + ct->add(splitter, true); + + UiObject *left = uic_object_new(obj, splitter); + left->container = new UiSidebarContainer(splitter); + + UiObject *right = uic_object_new(obj, splitter); + right->container = new UiSidebarContainer(splitter); + + uic_obj_add(obj, right); + uic_obj_add(obj, left); + + return splitter; +} + +void UiSidebarContainer::add(QWidget *widget, bool fill) { + splitter->addWidget(widget); +} + + /* -------------------- layout functions -------------------- */ void ui_layout_fill(UiObject *obj, UiBool fill) {
--- a/ui/qt/container.h Sat Sep 17 19:57:55 2016 +0200 +++ b/ui/qt/container.h Sun Sep 18 07:45:42 2016 +0200 @@ -37,6 +37,7 @@ #include <QGridLayout> #include <QTabWidget> #include <QStackedWidget> +#include <QSplitter> #define ui_lb2bool(b) ((b) == UI_LAYOUT_TRUE ? TRUE : FALSE) #define ui_bool2lb(b) ((b) ? UI_LAYOUT_TRUE : UI_LAYOUT_FALSE) @@ -106,5 +107,13 @@ virtual void add(QWidget *widget, bool fill); }; +class UiSidebarContainer : public UiContainer { +public: + QSplitter *splitter; + + UiSidebarContainer(QSplitter *splitter); + virtual void add(QWidget *widget, bool fill); +}; + #endif /* CONTAINER_H */
--- a/ui/qt/model.cpp Sat Sep 17 19:57:55 2016 +0200 +++ b/ui/qt/model.cpp Sun Sep 18 07:45:42 2016 +0200 @@ -131,6 +131,10 @@ return QVariant(); } +void TableModel::update() { + emit dataChanged(QModelIndex(),QModelIndex()); +} + void TableModel::selectionChanged(const QItemSelection& selected, const QItemSelection& deselected) { UiListSelection *selection = listSelection(view->selectionModel());
--- a/ui/qt/model.h Sat Sep 17 19:57:55 2016 +0200 +++ b/ui/qt/model.h Sun Sep 18 07:45:42 2016 +0200 @@ -76,6 +76,8 @@ QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; QVariant headerData(int section, Qt::Orientation orientation, int role) const; + void update(); + public slots: void selectionChanged( const QItemSelection & selected,
--- a/ui/qt/text.cpp Sat Sep 17 19:57:55 2016 +0200 +++ b/ui/qt/text.cpp Sun Sep 18 07:45:42 2016 +0200 @@ -45,6 +45,7 @@ value->set = ui_textarea_set; value->getsubstr = ui_textarea_getsubstr; value->insert = ui_textarea_insert; + value->setposition = ui_textarea_setposition; value->position = ui_textarea_position; value->selection = ui_textarea_selection; value->length = ui_textarea_length; @@ -111,6 +112,10 @@ QTextDocument *doc = (QTextDocument*)text->obj; } +void ui_textarea_setposition(UiText *text, int pos) { + // TODO +} + int ui_textarea_position(UiText *text) { QTextDocument *doc = (QTextDocument*)text->obj; return 0; // TODO
--- a/ui/qt/text.h Sat Sep 17 19:57:55 2016 +0200 +++ b/ui/qt/text.h Sun Sep 18 07:45:42 2016 +0200 @@ -40,6 +40,7 @@ void ui_textarea_set(UiText *text, char *str); char* ui_textarea_getsubstr(UiText *text, int begin, int end); void ui_textarea_insert(UiText *text, int pos, char *str); + void ui_textarea_setposition(UiText *text, int pos); int ui_textarea_position(UiText *text); void ui_textarea_selection(UiText *text, int *begin, int *end); int ui_textarea_length(UiText *text);
--- a/ui/qt/toolkit.cpp Sat Sep 17 19:57:55 2016 +0200 +++ b/ui/qt/toolkit.cpp Sun Sep 18 07:45:42 2016 +0200 @@ -97,6 +97,10 @@ } +void ui_set_visible(UIWIDGET widget, int visible) { + +} +
--- a/ui/qt/tree.cpp Sat Sep 17 19:57:55 2016 +0200 +++ b/ui/qt/tree.cpp Sun Sep 18 07:45:42 2016 +0200 @@ -46,6 +46,8 @@ ListModel *model = new ListModel(obj, view, list, getvalue, f, udata); view->setModel(model); + // TODO: observer update + QItemSelectionModel *s = view->selectionModel(); QObject::connect( s, @@ -84,6 +86,15 @@ view->setItemsExpandable(false); view->setRootIsDecorated(false); + // TODO: observer update + UiTableView *u = new UiTableView(); + u->widget = view; + u->model = model; + list->list->observers = ui_add_observer( + list->list->observers, + (ui_callback)ui_table_update, + u); + view->setSelectionMode(QAbstractItemView::ExtendedSelection); QItemSelectionModel *s = view->selectionModel(); QObject::connect( @@ -103,6 +114,15 @@ return view; } +void ui_table_update(UiEvent *event, UiTableView *view) { + // TODO + printf("update\n"); + + //view->model->update(); + view->widget->setModel(NULL); + view->widget->setModel(view->model); +} + UIWIDGET ui_table(UiObject *obj, UiList *list, UiModelInfo *modelinfo) { UiListPtr *listptr = (UiListPtr*)ucx_mempool_malloc(obj->ctx->mempool, sizeof(UiListPtr)); listptr->list = list;
--- a/ui/qt/tree.h Sat Sep 17 19:57:55 2016 +0200 +++ b/ui/qt/tree.h Sun Sep 18 07:45:42 2016 +0200 @@ -34,7 +34,13 @@ #include <QTableView> +class UiTableView { +public: + QTreeView *widget; + TableModel *model; +}; +extern "C" void ui_table_update(UiEvent *event, UiTableView *view); #endif /* TREE_H */