Пример #1
0
void ExpandButtonWidget::changeIcon()
{
	isExpanded = !isExpanded;
	if (isExpanded)
		exp->setPrimitiveElement(QStyle::PE_IndicatorArrowUp);
	else
		exp->setPrimitiveElement(QStyle::PE_IndicatorArrowDown);
	emit expandView(isExpanded);
}
Пример #2
0
/*
 *  Constructs a QG_LibraryWidget as a child of 'parent', with the
 *  name 'name' and widget flags set to 'f'.
 *
 * @author Rallaz
 */
QG_LibraryWidget::QG_LibraryWidget(QWidget* parent, const char* name, Qt::WindowFlags fl)
    : QWidget(parent, fl)
{
    setObjectName(name);
	actionHandler = nullptr;

    QVBoxLayout *vboxLayout = new QVBoxLayout(this);
    vboxLayout->setSpacing(2);
    vboxLayout->setContentsMargins(2, 2, 2, 2);
    dirView = new QTreeView(this);
    dirView->setRootIsDecorated(true);
    dirView->setEditTriggers(QAbstractItemView::NoEditTriggers);
    vboxLayout->addWidget(dirView);
    ivPreview = new QListView(this);
    ivPreview->setViewMode(QListView::IconMode);
    vboxLayout->addWidget(ivPreview);
    bInsert = new QPushButton(tr("Insert"), this);
    vboxLayout->addWidget(bInsert);

    dirModel = new QStandardItemModel;
    iconModel = new QStandardItemModel;
    QStringList directoryList = RS_SYSTEM->getDirectoryList("library");
    for (int i = 0; i < directoryList.size(); ++i) {
		appendTree(nullptr, directoryList.at(i));
     }

    RS_SETTINGS->beginGroup("/Paths");
    QString customPath=RS_SETTINGS->readEntry("/Library", "");
    RS_SETTINGS->endGroup();
    if(customPath.size()>0){
            //todo: make the custom path more flexible
			appendTree(nullptr,customPath);
    }
    dirView->setModel(dirModel);
    ivPreview->setModel(iconModel);
    dirModel->setHorizontalHeaderLabels ( QStringList(tr("Directories")));

    connect(dirView, SIGNAL(expanded(QModelIndex)), this, SLOT(expandView(QModelIndex)));
    connect(dirView, SIGNAL(collapsed(QModelIndex)), this, SLOT(collapseView(QModelIndex)));
    connect(dirView, SIGNAL(clicked(QModelIndex)), this, SLOT(updatePreview(QModelIndex)));
    connect(bInsert, SIGNAL(clicked()), this, SLOT(insert()));
}