[rkward] rkward: Draw division lines above and below an expanded editor, and make sure to draw the background without margin.
Thomas Friedrichsmeier
thomas.friedrichsmeier at ruhr-uni-bochum.de
Wed Nov 4 08:36:18 UTC 2015
Git commit d172d8f2843a360b380e078a540d1aaf41881840 by Thomas Friedrichsmeier.
Committed on 04/11/2015 at 08:36.
Pushed by tfry into branch 'master'.
Draw division lines above and below an expanded editor, and make sure to draw the background without margin.
M +20 -1 rkward/misc/rkaccordiontable.cpp
M +1 -0 rkward/misc/rkaccordiontable.h
M +8 -11 rkward/plugins/testing/optionset.xml
http://commits.kde.org/rkward/d172d8f2843a360b380e078a540d1aaf41881840
diff --git a/rkward/misc/rkaccordiontable.cpp b/rkward/misc/rkaccordiontable.cpp
index 97ad47d..31deb31 100644
--- a/rkward/misc/rkaccordiontable.cpp
+++ b/rkward/misc/rkaccordiontable.cpp
@@ -216,6 +216,7 @@ private:
QWidget *fallback_parent;
};
+#include <QPainter>
#include <QScrollBar>
#include <QHeaderView>
RKAccordionTable::RKAccordionTable (QWidget* parent) : QTreeView (parent) {
@@ -244,6 +245,10 @@ RKAccordionTable::RKAccordionTable (QWidget* parent) : QTreeView (parent) {
setItemsExpandable (false); // custom handling
setSizePolicy (QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
setViewportMargins (20, 0, 0, 0);
+/* QPalette pal = palette ();
+ pal.setBrush (QPalette::Highlight, pal.window ());
+ pal.setBrush (QPalette::HighlightedText, pal.windowText ());
+ setPalette (pal); */
pmodel = new RKAccordionDummyModel (0);
connect (this, SIGNAL (expanded(QModelIndex)), this, SLOT (rowExpanded(QModelIndex)));
connect (this, SIGNAL (clicked(QModelIndex)), this, SLOT (rowClicked(QModelIndex)));
@@ -259,6 +264,20 @@ RKAccordionTable::~RKAccordionTable () {
delete editor_widget_container;
}
+void RKAccordionTable::drawRow (QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const {
+ if (index.parent ().isValid ()) { // must be the editor widget
+ painter->fillRect (option.rect, palette ().background ()); // fill to paper over any padding around the widget (whereever it comes from)
+ QTreeView::drawRow (painter, option, index);
+ painter->drawLine (option.rect.bottomLeft (), option.rect.bottomRight ());
+ } else {
+ QTreeView::drawRow (painter, option, index);
+ if (isExpanded (index)) {
+// if (index.row () != 0) {
+ painter->drawLine (option.rect.topLeft (), option.rect.topRight ());
+ }
+ }
+}
+
void RKAccordionTable::setShowAddRemoveButtons (bool show) {
RK_TRACE (MISC);
show_add_remove_buttons = show;
@@ -430,7 +449,7 @@ int RKAccordionTable::rowOfButton (QObject* button) const {
// we rely on the fact that the buttons in use, here, are encapsulaped in a parent widget, which is set as indexWidget()
QObject* button_parent = button->parent ();
for (int i = model ()->rowCount () - 1; i >= 0; --i) {
- QModelIndex row = model ()->index (i, 0);
+ QModelIndex row = model ()->index (i, model ()->columnCount () - 1);
if (button_parent == indexWidget (row)) {
return i;
}
diff --git a/rkward/misc/rkaccordiontable.h b/rkward/misc/rkaccordiontable.h
index bed910f..ad02620 100644
--- a/rkward/misc/rkaccordiontable.h
+++ b/rkward/misc/rkaccordiontable.h
@@ -49,6 +49,7 @@ protected:
void resizeEvent (QResizeEvent* event); // reimplemented to make the current content widget stretch / shrink
void currentChanged (const QModelIndex& current, const QModelIndex& previous);
void mousePressEvent (QMouseEvent* event);
+ void drawRow (QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
private:
QSize sizeHintWithoutEditor () const;
int rowOfButton (QObject *button) const;
diff --git a/rkward/plugins/testing/optionset.xml b/rkward/plugins/testing/optionset.xml
index cfa78fe..bbf60e8 100644
--- a/rkward/plugins/testing/optionset.xml
+++ b/rkward/plugins/testing/optionset.xml
@@ -21,17 +21,14 @@
<tab label="Manual set">
<optionset id="mset" exp_mode="accordion">
<content>
- <frame>
- <optiondisplay index="true"/>
- <row>
- <varselector id="vars"/>
- <column>
- <varslot type="numeric" id="mx" source="vars" required="true" label="Pick an object"/> <!-- NOTE: requiredness does not work, correctly, yet -->
- <input id="summary" label="Enter a summary" size="large" initial="I am the default"/>
- <stretch/>
- </column>
- </row>
- </frame>
+ <row>
+ <varselector id="vars"/>
+ <column>
+ <varslot type="numeric" id="mx" source="vars" required="true" label="Pick an object"/> <!-- NOTE: requiredness does not work, correctly, yet -->
+ <input id="summary" label="Enter a summary" size="large" initial="I am the default"/>
+ <stretch/>
+ </column>
+ </row>
</content>
<optioncolumn id="object" connect="mx.available"/>
<optioncolumn id="objshort" label="Object" connect="mx.available.shortname"/>
More information about the rkward-tracker
mailing list