128
128
m_openButton = new ActionIcon(this);
129
129
m_openButton->setElement("open");
131
QGraphicsGridLayout *layout = new QGraphicsGridLayout(this);
132
layout->setContentsMargins(4, 4, 4, 4);
133
layout->setSpacing(1);
134
layout->addItem(m_toggleButton, 0, 0);
135
layout->addItem(m_openButton, 1, 0);
131
m_showFolderButton = true;
132
m_showSelectionButton = true;
134
m_layout = new QGraphicsGridLayout(this);
135
m_layout->setContentsMargins(4, 4, 4, 4);
136
m_layout->setSpacing(1);
137
m_layout->addItem(m_toggleButton, 0, 0);
138
m_layout->addItem(m_openButton, 1, 0);
137
140
connect(parentWidget(), SIGNAL(entered(QModelIndex)), this, SLOT(entered(QModelIndex)));
138
141
connect(parentWidget(), SIGNAL(left(QModelIndex)), this, SLOT(left(QModelIndex)));
275
276
AbstractItemView *view = static_cast<AbstractItemView*>(parentWidget());
277
278
QAbstractItemModel *mod = view->model();
278
connect(mod, SIGNAL(rowsRemoved(QModelIndex, int, int)), SLOT(rowsRemoved(QModelIndex, int, int)));
279
connect(mod, SIGNAL(rowsRemoved(QModelIndex,int,int)), SLOT(rowsRemoved(QModelIndex,int,int)));
282
void ActionOverlay::setShowFolderButton(bool show)
284
if (m_showFolderButton != show) {
285
m_showFolderButton = show;
286
toggleShowActionButton(show, m_openButton, 1);
290
void ActionOverlay::setShowSelectionButton(bool show)
292
if (m_showSelectionButton!= show) {
293
m_showSelectionButton = show;
294
toggleShowActionButton(show, m_toggleButton, 0);
298
bool ActionOverlay::showFolderButton() const
300
return m_showFolderButton;
302
bool ActionOverlay::showSelectionButton() const
304
return m_showSelectionButton;
307
QSizeF ActionOverlay::iconSize() const
309
return m_openButton->geometry().size();
312
void ActionOverlay::toggleShowActionButton(bool show, ActionIcon* button, unsigned int pos)
314
if (show && m_layout->itemAt(pos, 0) != button) {
315
m_layout->addItem(button, pos, 0);
317
} else if (m_layout->itemAt(pos, 0) == button) {
319
#if QT_VERSION >= 0x040800
320
m_layout->removeItem(button);
322
/* find the index of the item: yeah, this is ugly... on the other hand, this works in Qt 4.7,
323
* and if you have a look at the 4.8 source, this is exactly what it does. */
325
for (int i = 0; i < m_layout->count(); ++i) {
326
if (m_layout->itemAt(i) == button) {
331
Q_ASSERT(index >= 0); // the button *is* part of the layout, so we have to find it
332
m_layout->removeAt(index);