Files
c-evo-evo/widget/src/DpiComCtrls.cpp
T

94 lines
3.3 KiB
C++

// This file is part of c-evo-evo.
//
// This software is governed by the CeCILL license under French law and
// abiding by the rules of distribution of free software. You can use,
// modify and/or redistribute the software under the terms of the CeCILL
// license as circulated by CEA, CNRS and INRIA at the following URL
// "http://www.cecill.info".
//
// As a counterpart to the access to the source code and rights to copy,
// modify and redistribute granted by the license, users are provided only
// with a limited warranty and the software's author, the holder of the
// economic rights, and the successive licensors have only limited
// liability.
//
// In this respect, the user's attention is drawn to the risks associated
// with loading, using, modifying and/or developing or reproducing the
// software by the user in light of its specific status of free software,
// that may mean that it is complicated to manipulate, and that also
// therefore means that it is reserved for developers and experienced
// professionals having in-depth computer knowledge. Users are therefore
// encouraged to load and test the software's suitability as regards their
// requirements in conditions enabling the security of their systems and/or
// data to be ensured and, more generally, to use and operate it in the
// same conditions as regards security.
//
// The fact that you are presently reading this means that you have had
// knowledge of the CeCILL license and that you accept its terms.
#include "Dpi/DpiComCtrls.h"
#include <QHeaderView>
namespace Dpi {
ListView::ListView(QWidget *parent) : QTreeWidget(parent)
{
setRootIsDecorated(false);
connect(header(), &QHeaderView::sectionClicked, this, &ListView::columnClicked);
connect(this, &QTreeWidget::itemSelectionChanged, this, &ListView::selectionChanged);
}
void ListView::setViewStyle(ViewStyle value)
{
m_viewStyle = value;
switch (value) {
case ViewStyle::Report:
setHeaderHidden(false);
setIndentation(0);
break;
case ViewStyle::List:
case ViewStyle::SmallIcon:
case ViewStyle::Icon:
setHeaderHidden(true);
break;
}
}
void ListView::setCheckboxes(bool value)
{
m_checkboxes = value;
for (int i = 0; i < topLevelItemCount(); ++i) {
QTreeWidgetItem *it = topLevelItem(i);
it->setFlags(value ? (it->flags() | Qt::ItemIsUserCheckable)
: (it->flags() & ~Qt::ItemIsUserCheckable));
}
}
ToolBar::ToolBar(QWidget *parent) : QToolBar(parent) {}
int ToolBar::buttonHeight() const { return iconSize().height(); }
void ToolBar::setButtonHeight(int value) { setIconSize(QSize(iconSize().width(), value)); }
int ToolBar::buttonWidth() const { return iconSize().width(); }
void ToolBar::setButtonWidth(int value) { setIconSize(QSize(value, iconSize().height())); }
CoolBar::CoolBar(QWidget *parent) : QSplitter(Qt::Horizontal, parent)
{
setChildrenCollapsible(false);
}
void CoolBar::addBand(const CoolBand &band)
{
if (!band.widget)
return;
band.widget->setMinimumSize(band.minWidth, band.minHeight);
addWidget(band.widget);
}
void CoolBar::beginUpdate() { setUpdatesEnabled(false); }
void CoolBar::endUpdate() { setUpdatesEnabled(true); }
PageControl::PageControl(QWidget *parent) : QTabWidget(parent) {}
} // namespace Dpi