Commit 7fd7f69a authored by Ignat Semenov's avatar Ignat Semenov
Browse files

icon arrangement mega-patch for usability and maintainability

This splits the enum IconView::Flow into two enums
- IconView::Layout { Rows, Columns }
- IconView::Alignment { Left, Right }

Note that Qt::Alignment is not used to emphasize the fact that
these two properties are orthogonal (layoutDirection() is used
e.g. to place the scrollbar at the correct side of the screen,
whereas IconView::Alignment is about the side of the screen
the user want their icons to stick to.

This patch greatly improves the readability of the IconView
layouting code, as well as the user-friendliness of the
applet's Display configuration page, with a distinct separation
of the two layout-related factors.

Corresponding context menu actions have been added. They update
the configuration dialog combos when selected if the dialog is
open at that moment.

CCBUG:306537
parent b77e0f66
......@@ -89,6 +89,8 @@ K_EXPORT_PLASMA_APPLET(folderview, FolderView)
Q_DECLARE_METATYPE(Qt::SortOrder)
Q_DECLARE_METATYPE(ProxyModel::FilterMode)
Q_DECLARE_METATYPE(IconView::Flow)
Q_DECLARE_METATYPE(IconView::Layout)
Q_DECLARE_METATYPE(IconView::Alignment)
Q_DECLARE_METATYPE(FolderView::LabelType)
MimeModel::MimeModel(QObject *parent)
......@@ -394,12 +396,10 @@ void FolderView::init()
m_labelType = static_cast<FolderView::LabelType>(cg.readEntry("labelType", static_cast<int>(FolderView::None)));
m_showSelectionMarker = KGlobalSettings::singleClick();
if (isContainment()) {
m_flow = layoutDirection() == Qt::LeftToRight ? IconView::VerLeftToRight : IconView::VerRightToLeft;
} else {
m_flow = layoutDirection() == Qt::LeftToRight ? IconView::HorLeftToRight : IconView::HorRightToLeft;
}
m_flow = static_cast<IconView::Flow>(cg.readEntry("flow", static_cast<int>(m_flow)));
m_layout = isContainment() ? IconView::Columns : IconView::Rows;
m_alignment = layoutDirection() == Qt::LeftToRight ? IconView::Left : IconView::Right;
m_layout = static_cast<IconView::Layout>(cg.readEntry("layout", static_cast<int>(m_layout)));
m_alignment = static_cast<IconView::Alignment>(cg.readEntry("alignment", static_cast<int>(m_alignment)));
m_model->setFilterMode(m_filterType);
m_model->setMimeTypeFilterList(m_filterFilesMimeList);
......@@ -571,9 +571,11 @@ void FolderView::configChanged()
updateSortActionsState();
}
const int flow = static_cast<IconView::Flow>(cg.readEntry("flow", static_cast<int>(m_flow)));
if (flow != m_flow) {
m_flow = static_cast<IconView::Flow>(flow);
const IconView::Layout layout = static_cast<IconView::Layout>(cg.readEntry("layout", static_cast<int>(m_layout)));
const IconView::Alignment alignment = static_cast<IconView::Alignment>(cg.readEntry("alignment", static_cast<int>(m_alignment)));
if ((m_layout != layout) || (m_alignment != alignment)) {
m_layout = layout;
m_alignment = alignment;
updateFlowActionsState();
}
......@@ -742,7 +744,8 @@ void FolderView::createConfigurationInterface(KConfigDialog *parent)
addActionGroupToCombo(m_sortingGroup, uiDisplay.sortCombo);
addActionGroupToCombo(m_sortingOrderGroup, uiDisplay.directionCombo);
addActionGroupToCombo(m_flowGroup, uiDisplay.flowCombo);
addActionGroupToCombo(m_layoutGroup, uiDisplay.layoutCombo);
addActionGroupToCombo(m_alignmentGroup, uiDisplay.alignmentCombo);
uiFilter.filterCombo->addItem(i18n("Show All Files"), QVariant::fromValue(ProxyModel::NoFilter));
uiFilter.filterCombo->addItem(i18n("Show Files Matching"), QVariant::fromValue(ProxyModel::FilterShowMatches));
......@@ -760,7 +763,8 @@ void FolderView::createConfigurationInterface(KConfigDialog *parent)
setCurrentItem(uiDisplay.sortCombo, m_sortColumn);
setCurrentItem(uiDisplay.directionCombo, m_sortOrder);
setCurrentItem(uiDisplay.flowCombo, m_flow);
setCurrentItem(uiDisplay.layoutCombo, m_layout);
setCurrentItem(uiDisplay.alignmentCombo, m_alignment);
setCurrentItem(uiLocation.titleCombo, m_labelType);
setCurrentItem(uiFilter.filterCombo, m_filterType);
......@@ -780,8 +784,10 @@ void FolderView::createConfigurationInterface(KConfigDialog *parent)
// Hide the icon arrangement controls when we're not acting as a containment,
// since this option doesn't make much sense in the applet.
if (!isContainment()) {
uiDisplay.flowLabel->hide();
uiDisplay.flowCombo->hide();
uiDisplay.layoutLabel->hide();
uiDisplay.layoutCombo->hide();
uiDisplay.alignmentLabel->hide();
uiDisplay.alignmentCombo->hide();
}
parent->addPage(widgetLocation, i18nc("Title of the page that lets the user choose which location should the folderview show", "Location"), "folder");
......@@ -801,7 +807,8 @@ void FolderView::createConfigurationInterface(KConfigDialog *parent)
connect(uiDisplay.previewsAdvanced, SIGNAL(clicked()), this, SLOT(showPreviewConfigDialog()));
connect(uiDisplay.showPreviews, SIGNAL(toggled(bool)), uiDisplay.previewsAdvanced, SLOT(setEnabled(bool)));
connect(uiDisplay.flowCombo, SIGNAL(currentIndexChanged(int)), parent, SLOT(settingsModified()));
connect(uiDisplay.layoutCombo, SIGNAL(currentIndexChanged(int)), parent, SLOT(settingsModified()));
connect(uiDisplay.alignmentCombo, SIGNAL(currentIndexChanged(int)), parent, SLOT(settingsModified()));
connect(uiDisplay.sortCombo, SIGNAL(currentIndexChanged(int)), parent, SLOT(settingsModified()));
connect(uiDisplay.directionCombo, SIGNAL(currentIndexChanged(int)), parent, SLOT(settingsModified()));
connect(uiDisplay.sizeSlider, SIGNAL(valueChanged(int)), parent, SLOT(settingsModified()));
......@@ -882,8 +889,11 @@ void FolderView::configAccepted()
const bool dirsFirst = uiDisplay.foldersFirst->isChecked();
cg.writeEntry("sortDirsFirst", dirsFirst);
const IconView::Flow flow = uiDisplay.flowCombo->itemData(uiDisplay.flowCombo->currentIndex()).value<IconView::Flow>();
cg.writeEntry("flow", static_cast<int>(flow));
const IconView::Layout layout = uiDisplay.layoutCombo->itemData(uiDisplay.layoutCombo->currentIndex()).value<IconView::Layout>();
cg.writeEntry("layout", static_cast<int>(layout));
const IconView::Alignment alignment = uiDisplay.alignmentCombo->itemData(uiDisplay.alignmentCombo->currentIndex()).value<IconView::Alignment>();
cg.writeEntry("alignment", static_cast<int>(alignment));
cg.writeEntry("alignToGrid", uiDisplay.alignToGrid->isChecked());
cg.writeEntry("clickForFolderPreviews", uiDisplay.clickToView->isChecked());
......@@ -1034,7 +1044,8 @@ void FolderView::updateIconViewState()
m_iconView->setDrawShadows(m_drawShadows);
m_iconView->setIconSize(iconSize());
m_iconView->setTextLineCount(m_numTextLines);
m_iconView->setFlow(m_flow);
m_iconView->setLayout(m_layout);
m_iconView->setAlignment(m_alignment);
m_iconView->setWordWrap(m_numTextLines > 1);
m_iconView->setAlignToGrid(m_alignToGrid);
m_iconView->setIconsMoveable(!m_iconsLocked);
......@@ -1568,24 +1579,27 @@ void FolderView::createActions()
lockIcons->setChecked(m_iconsLocked);
connect(lockIcons, SIGNAL(toggled(bool)), SLOT(toggleIconsLocked(bool)));
m_flowGroup = new QActionGroup(this);
connect(m_flowGroup, SIGNAL(triggered(QAction*)), SLOT(flowChanged(QAction*)));
QAction *arrangeHorLeftToRight = m_flowGroup->addAction(i18nc("Arrange icons", "Left to Right, Top to Bottom"));
QAction *arrangeHorRightToLeft = m_flowGroup->addAction(i18nc("Arrange icons", "Right to Left, Top to Bottom"));
QAction *arrangeVerLeftToRight = m_flowGroup->addAction(i18nc("Arrange icons", "Top to Bottom, Left to Right"));
QAction *arrangeVerRightToLeft= m_flowGroup->addAction(i18nc("Arrange icons", "Top to Bottom, Right to Left"));
m_layoutGroup = new QActionGroup(this);
connect(m_layoutGroup, SIGNAL(triggered(QAction*)), SLOT(layoutChanged(QAction*)));
QAction *layoutRows = m_layoutGroup->addAction(i18nc("Layout icons", "In rows"));
QAction *layoutColumns = m_layoutGroup->addAction(i18nc("Layout icons", "In columns"));
layoutRows->setCheckable(true);
layoutRows->setData(QVariant::fromValue(IconView::Rows));
arrangeHorLeftToRight->setCheckable(true);
arrangeHorLeftToRight->setData(QVariant::fromValue(IconView::HorLeftToRight));
layoutColumns->setCheckable(true);
layoutColumns->setData(QVariant::fromValue(IconView::Columns));
arrangeHorRightToLeft->setCheckable(true);
arrangeHorRightToLeft->setData(QVariant::fromValue(IconView::HorRightToLeft));
m_alignmentGroup = new QActionGroup(this);
connect(m_alignmentGroup, SIGNAL(triggered(QAction*)), SLOT(alignmentChanged(QAction*)));
QAction *alignLeft = m_alignmentGroup->addAction(i18nc("Align icons", "To the left"));
QAction *alignRight = m_alignmentGroup->addAction(i18nc("Align icons", "To the right"));
arrangeVerLeftToRight->setCheckable(true);
arrangeVerLeftToRight->setData(QVariant::fromValue(IconView::VerLeftToRight));
alignLeft->setCheckable(true);
alignLeft->setData(QVariant::fromValue(IconView::Left));
arrangeVerRightToLeft->setCheckable(true);
arrangeVerRightToLeft->setData(QVariant::fromValue(IconView::VerRightToLeft));
alignRight->setCheckable(true);
alignRight->setData(QVariant::fromValue(IconView::Right));
KAction *unsorted = new KAction(i18nc("Sort icons", "Unsorted"), this);
unsorted->setData(int(FolderView::Unsorted));
......@@ -1626,10 +1640,11 @@ void FolderView::createActions()
connect(dirsFirst, SIGNAL(toggled(bool)), SLOT(toggleDirectoriesFirst(bool)));
QMenu *flowMenu = new QMenu(i18n("Arrange Icons"));
flowMenu->addAction(arrangeVerLeftToRight);
flowMenu->addAction(arrangeVerRightToLeft);
flowMenu->addAction(arrangeHorLeftToRight);
flowMenu->addAction(arrangeHorRightToLeft);
flowMenu->addAction(layoutRows);
flowMenu->addAction(layoutColumns);
flowMenu->addSeparator();
flowMenu->addAction(alignLeft);
flowMenu->addAction(alignRight);
QMenu *sortMenu = new QMenu(i18n("Sort Icons"));
sortMenu->addAction(sortByName);
......@@ -1663,10 +1678,10 @@ void FolderView::createActions()
m_actionCollection.addAction("auto_align", alignToGrid);
m_actionCollection.addAction("dirs_first", dirsFirst);
m_actionCollection.addAction("icons_menu", iconsMenuAction);
m_actionCollection.addAction("arrange_hor_ltr", arrangeHorLeftToRight);
m_actionCollection.addAction("arrange_hor_rtl", arrangeHorRightToLeft);
m_actionCollection.addAction("arrange_ver_ltr", arrangeVerLeftToRight);
m_actionCollection.addAction("arrange_ver_rtl", arrangeVerRightToLeft);
m_actionCollection.addAction("layout_rows", layoutRows);
m_actionCollection.addAction("layout_columns", layoutColumns);
m_actionCollection.addAction("align_left", alignLeft);
m_actionCollection.addAction("align_right", alignRight);
m_actionCollection.addAction("unsorted", unsorted);
m_actionCollection.addAction("sort_name", sortByName);
m_actionCollection.addAction("sort_size", sortBySize);
......@@ -1880,19 +1895,37 @@ void FolderView::toggleDirectoriesFirst(bool enable)
m_delayedSaveTimer.start(5000, this);
}
void FolderView::flowChanged(QAction* action)
void FolderView::layoutChanged(QAction* action)
{
const IconView::Flow flow = action->data().value<IconView::Flow>();
const IconView::Layout layout = action->data().value<IconView::Layout>();
if (flow != m_flow) {
m_flow = flow;
if (layout != m_layout) {
m_layout = layout;
if (m_iconView) {
m_iconView->setFlow(m_flow);
m_iconView->setLayout(m_layout);
}
if (isUserConfiguring()) {
setCurrentItem(uiDisplay.flowCombo, m_flow);
setCurrentItem(uiDisplay.layoutCombo, m_layout);
}
config().writeEntry("flow", static_cast<int>(m_flow));
config().writeEntry("layout", static_cast<int>(m_layout));
emit configNeedsSaving();
m_delayedSaveTimer.start(5000, this);
}
}
void FolderView::alignmentChanged(QAction* action)
{
const IconView::Alignment alignment = action->data().value<IconView::Alignment>();
if (alignment != m_alignment) {
m_alignment = alignment;
if (m_iconView) {
m_iconView->setAlignment(m_alignment);
}
if (isUserConfiguring()) {
setCurrentItem(uiDisplay.alignmentCombo, m_alignment);
}
config().writeEntry("alignment", static_cast<int>(m_alignment));
emit configNeedsSaving();
m_delayedSaveTimer.start(5000, this);
}
......@@ -1936,8 +1969,11 @@ void FolderView::sortingOrderChanged(QAction *action)
void FolderView::updateFlowActionsState()
{
foreach (QAction *action, m_flowGroup->actions()) {
action->setChecked(action->data().value<IconView::Flow>() == m_flow);
foreach (QAction *action, m_layoutGroup->actions()) {
action->setChecked(action->data().value<IconView::Layout>() == m_layout);
}
foreach (QAction *action, m_alignmentGroup->actions()) {
action->setChecked(action->data().value<IconView::Alignment>() == m_alignment);
}
}
......
......@@ -133,7 +133,8 @@ protected slots:
void toggleAlignToGrid(bool align);
void toggleClickToViewFolders(bool enable);
void toggleDirectoriesFirst(bool enable);
void flowChanged(QAction *action);
void layoutChanged(QAction *action);
void alignmentChanged(QAction *action);
void sortingChanged(QAction *action);
void sortingOrderChanged(QAction *action);
void aboutToShowCreateNew();
......@@ -205,7 +206,8 @@ private:
QStringList m_filterFilesMimeList;
QPointer<KNewFileMenu> m_newMenu;
KActionCollection m_actionCollection;
QActionGroup *m_flowGroup;
QActionGroup *m_layoutGroup;
QActionGroup *m_alignmentGroup;
QActionGroup *m_sortingGroup;
QActionGroup *m_sortingOrderGroup;
int m_sortColumn;
......@@ -226,7 +228,8 @@ private:
QStringList m_previewPlugins;
int m_customIconSize;
int m_numTextLines;
IconView::Flow m_flow;
IconView::Layout m_layout;
IconView::Alignment m_alignment;
QBasicTimer m_delayedSaveTimer;
DirLister *m_dirLister;
};
......
......@@ -82,7 +82,8 @@ IconView::IconView(QGraphicsWidget *parent)
m_clickToViewFolders(true),
m_showSelectionMarker(true),
m_drawIconShrinked(false),
m_flow(layoutDirection() == Qt::LeftToRight ? HorLeftToRight : HorRightToLeft),
m_layout(Rows),
m_alignment(layoutDirection() == Qt::LeftToRight ? Left : Right),
m_popupCausedWidget(0),
m_dropOperation(0),
m_dropActions(0),
......@@ -209,10 +210,10 @@ bool IconView::wordWrap() const
return m_wordWrap;
}
void IconView::setFlow(Flow flow)
void IconView::setLayout(IconView::Layout layout)
{
if (m_flow != flow) {
m_flow = flow;
if (m_layout != layout) {
m_layout = layout;
// Schedule a full relayout
if (!m_layoutBroken && m_validRows > 0) {
......@@ -223,9 +224,28 @@ void IconView::setFlow(Flow flow)
}
}
IconView::Flow IconView::flow() const
IconView::Layout IconView::layout() const
{
return m_flow;
return m_layout;
}
void IconView::setAlignment(IconView::Alignment alignment)
{
if (m_alignment != alignment) {
m_alignment = alignment;
// Schedule a full relayout
if (!m_layoutBroken && m_validRows > 0) {
m_validRows = 0;
m_delayedLayoutTimer.start(10, this);
emit busy(true);
}
}
}
IconView::Alignment IconView::alignment() const
{
return m_alignment;
}
void IconView::setAlignToGrid(bool on)
......@@ -320,7 +340,7 @@ void IconView::updateGridSize()
if (!containment || !containment->isContainment()) {
getContentsMargins(&left, &top, &right, &bottom);
QSize minSize = size + QSize(20 + left + right, 20 + top + bottom);
if (m_flow == HorLeftToRight || m_flow == HorRightToLeft) {
if (m_layout == Rows) {
minSize.rwidth() += m_scrollBar->geometry().width();
}
setMinimumSize(minSize);
......@@ -566,7 +586,7 @@ QPoint inline IconView::nextGridPosition(const QPoint &lastPos, const QSize &gri
int margin = 10;
QRect r = contentRect.adjusted(margin, margin, -margin, -margin);
if (m_flow == HorLeftToRight || m_flow == HorRightToLeft) {
if (m_layout == Rows) {
if (layoutDirection() == Qt::LeftToRight) {
r.adjust(0, 0, -m_scrollBar->geometry().width(), 0);
} else {
......@@ -574,7 +594,7 @@ QPoint inline IconView::nextGridPosition(const QPoint &lastPos, const QSize &gri
}
}
const int xOrigin = (m_flow == HorLeftToRight || m_flow == VerLeftToRight) ?
const int xOrigin = (m_alignment == Left) ?
r.left() : r.right() - grid.width() + 1;
if (lastPos.isNull()) {
......@@ -583,30 +603,26 @@ QPoint inline IconView::nextGridPosition(const QPoint &lastPos, const QSize &gri
QPoint pos = lastPos;
switch (m_flow) {
case HorLeftToRight:
pos.rx() += grid.width() + spacing;
if (pos.x() + grid.width() >= r.right()) {
pos.ry() += grid.height() + spacing;
pos.rx() = xOrigin;
}
break;
case HorRightToLeft:
pos.rx() -= grid.width() + spacing;
if (pos.x() < r.left()) {
pos.ry() += grid.height() + spacing;
pos.rx() = xOrigin;
if (m_layout == Rows) {
if (m_alignment == Left) {
pos.rx() += grid.width() + spacing;
if (pos.x() + grid.width() >= r.right()) {
pos.ry() += grid.height() + spacing;
pos.rx() = xOrigin;
}
} else { // Right
pos.rx() -= grid.width() + spacing;
if (pos.x() < r.left()) {
pos.ry() += grid.height() + spacing;
pos.rx() = xOrigin;
}
}
break;
case VerLeftToRight:
case VerRightToLeft:
} else { // Columns
pos.ry() += grid.height() + spacing;
if (pos.y() + grid.height() >= r.bottom()) {
if (m_flow == VerLeftToRight) {
if (m_alignment == Left) {
pos.rx() += grid.width() + spacing;
} else { // RightToLeft
} else { // Right
pos.rx() -= grid.width() + spacing;
}
pos.ry() = r.top();
......@@ -648,7 +664,7 @@ void IconView::layoutItems()
const QSize grid = gridSize();
int maxWidth = rect.width();
int maxHeight = rect.height();
if (m_flow == HorLeftToRight || m_flow == HorRightToLeft) {
if (m_layout == Rows) {
maxWidth -= m_scrollBar->geometry().width();
}
m_columns = columnsForWidth(maxWidth);
......@@ -774,7 +790,7 @@ QRect IconView::adjustedContentsRect(int *rowCount, int *colCount) const
r.setHeight(r.height() - dy);
// Take the origin into account
if (m_flow == HorRightToLeft || m_flow == VerRightToLeft) {
if (m_alignment == Right) {
r.translate(dx, 0);
}
......@@ -792,7 +808,7 @@ void IconView::alignIconsToGrid()
const Plasma::Containment *containment = qobject_cast<Plasma::Containment*>(parentWidget());
if (!containment || !containment->isContainment()) {
// Don't limit the max rows/columns in the scrolling direction
if (m_flow == HorLeftToRight || m_flow == HorRightToLeft) {
if (m_layout == Rows) {
lastRow = INT_MAX;
} else {
lastCol = INT_MAX;
......@@ -1512,7 +1528,7 @@ void IconView::resizeEvent(QGraphicsSceneResizeEvent *e)
updateScrollBarGeometry();
if (m_validRows > 0) {
if (m_flow == HorRightToLeft || m_flow == VerRightToLeft) {
if (m_alignment == Right) {
// When the origin is the top-right corner, we need to shift all
// the icons horizontally so they gravitate toward the right side.
int dx = e->newSize().width() - e->oldSize().width();
......@@ -1780,19 +1796,17 @@ void IconView::keyPressEvent(QKeyEvent *event)
int hMultiplier = 1;
int vMultiplier = 1;
switch (m_flow) //Perform flow related calculations
{
case HorRightToLeft:
hMultiplier = -1;
case HorLeftToRight: //Fall through because in both RightToLeft and LeftToRight, we move m_columns time vertically
//Perform flow related calculations
if (m_layout == Rows) {
vMultiplier = m_columns;
break;
case VerLeftToRight:
if (m_alignment == Right) {
hMultiplier = -1;
}
} else { // Columns
hMultiplier = m_rows;
break;
case VerRightToLeft:
hMultiplier = m_rows*(-1);
break;
if (m_alignment == Right) {
hMultiplier *= -1;
}
}
newItem = currentIndex.row() + hdirection*hMultiplier + vdirection*vMultiplier;
......@@ -2361,7 +2375,7 @@ void IconView::dropEvent(QGraphicsSceneDragDropEvent *event)
}
// If the flow is vertical, check the top and bottom sides
if (m_flow == VerLeftToRight || m_flow == VerRightToLeft) {
if (m_layout == Columns) {
if (boundingRect.top() < cr.top()) {
delta.ry() += cr.top() - boundingRect.top();
}
......@@ -2426,7 +2440,7 @@ void IconView::changeEvent(QEvent *event)
// a panel to the opposite edge, or when the user enables/disables panel autohide.
bool widthChanged = int(m_margins[Plasma::LeftMargin] + m_margins[Plasma::RightMargin]) != int(left + right);
bool heightChanged = int(m_margins[Plasma::TopMargin] + m_margins[Plasma::BottomMargin]) != int(top + bottom);
bool horizontalFlow = (m_flow == HorLeftToRight || m_flow == HorRightToLeft);
bool horizontalFlow = (m_layout == Rows);
bool needRelayout = false;
if ((horizontalFlow && widthChanged) || (!horizontalFlow && heightChanged)) {
......@@ -2451,7 +2465,7 @@ void IconView::changeEvent(QEvent *event)
} else {
QPoint delta;
if (m_flow == HorLeftToRight || m_flow == VerLeftToRight) {
if (m_alignment == Left) {
// Gravitate toward the upper left corner
delta.rx() = int(left - m_margins[Plasma::LeftMargin]);
} else {
......@@ -2595,7 +2609,7 @@ void IconView::selectFirstOrLastIcon(bool firstIcon)
int isFirst = firstIcon ? 1 : -1; //Useful in calculations to decide whether to select First or Last icon
QModelIndex toSelect;
if (m_flow == HorRightToLeft || m_flow == VerRightToLeft) {
if (m_alignment == Right) {
dirn=-1;
}
......@@ -2764,7 +2778,7 @@ void IconView::timerEvent(QTimerEvent *event)
else if (event->timerId() == m_delayedRelayoutTimer.timerId()) {
m_delayedRelayoutTimer.stop();
bool horizontalFlow = (m_flow == HorLeftToRight || m_flow == HorRightToLeft);
bool horizontalFlow = (m_layout == Rows);
if (m_layoutBroken) {
// Relayout all icons that have ended up outside the view
const QRect cr = contentsRect().toRect();
......
......@@ -60,6 +60,8 @@ class IconView : public AbstractItemView
public:
enum Flow { HorLeftToRight, VerLeftToRight, HorRightToLeft, VerRightToLeft };
enum Layout { Rows, Columns };
enum Alignment { Left, Right };
Q_PROPERTY(QSize gridSize READ gridSize WRITE setGridSize)
Q_PROPERTY(bool wordWrap READ wordWrap WRITE setWordWrap)
......@@ -68,7 +70,8 @@ public:
Q_PROPERTY(bool showSelectionMarker READ showSelectionMarker WRITE setShowSelectionMarker)
Q_PROPERTY(bool iconsMoveable READ iconsMoveable WRITE setIconsMoveable)
Q_PROPERTY(bool customLayout READ customLayout WRITE setCustomLayout)
Q_PROPERTY(Flow flow READ flow WRITE setFlow)
Q_PROPERTY(Layout layout READ layout WRITE setLayout)
Q_PROPERTY(Alignment alignment READ alignment WRITE setAlignment)
public:
IconView(QGraphicsWidget *parent);
......@@ -87,8 +90,11 @@ public:
void setTextLineCount(int rows);
int textLineCount() const;
void setFlow(Flow flow);
Flow flow() const;
void setLayout(Layout layout);
Layout layout() const;
void setAlignment(Alignment alignment);
Alignment alignment() const;
void setAlignToGrid(bool on);
bool alignToGrid() const;
......@@ -261,7 +267,8 @@ private:
QPointF m_buttonDownPos;
QPointF m_mouseMovedPos;
QTime m_pressTime;
Flow m_flow;
Layout m_layout;
Alignment m_alignment;
QString m_errorMessage;
QPoint m_lastDeletedPos;
QPoint m_currentLayoutPos;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment