! \class ImportProjectDialog \brief Dialog for importing project files. \ingroup frontend */
| 42 | \ingroup frontend |
| 43 | */ |
| 44 | ImportProjectDialog::ImportProjectDialog(MainWin* parent, ProjectType type) |
| 45 | : QDialog(parent) |
| 46 | , m_mainWin(parent) |
| 47 | , m_projectType(type) |
| 48 | , m_aspectTreeModel(new AspectTreeModel(parent->project())) { |
| 49 | // main widget |
| 50 | auto* mainWidget = new QWidget(this); |
| 51 | ui.setupUi(mainWidget); |
| 52 | ui.lUnusedObjects->hide(); |
| 53 | ui.chbUnusedObjects->hide(); |
| 54 | |
| 55 | m_cbFileName = new KUrlComboBox(KUrlComboBox::Mode::Files, this); |
| 56 | m_cbFileName->setMaxItems(7); |
| 57 | auto* l = dynamic_cast<QHBoxLayout*>(ui.gbProject->layout()); |
| 58 | if (l) |
| 59 | l->insertWidget(1, m_cbFileName); |
| 60 | |
| 61 | auto* vLayout = new QVBoxLayout(this); |
| 62 | vLayout->addWidget(mainWidget); |
| 63 | |
| 64 | ui.tvPreview->setAnimated(true); |
| 65 | ui.tvPreview->setAlternatingRowColors(true); |
| 66 | ui.tvPreview->setSelectionBehavior(QAbstractItemView::SelectRows); |
| 67 | ui.tvPreview->setSelectionMode(QAbstractItemView::ExtendedSelection); |
| 68 | ui.tvPreview->setUniformRowHeights(true); |
| 69 | |
| 70 | ui.bOpen->setIcon(QIcon::fromTheme(QStringLiteral("document-open"))); |
| 71 | |
| 72 | m_cbAddTo = new TreeViewComboBox(ui.gbImportTo); |
| 73 | m_cbAddTo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
| 74 | ui.gbImportTo->layout()->addWidget(m_cbAddTo); |
| 75 | |
| 76 | QList<AspectType> list{AspectType::Folder}; |
| 77 | m_cbAddTo->setTopLevelClasses(list); |
| 78 | m_aspectTreeModel->setSelectableAspects(list); |
| 79 | m_cbAddTo->setModel(m_aspectTreeModel); |
| 80 | |
| 81 | m_bNewFolder = new QPushButton(ui.gbImportTo); |
| 82 | m_bNewFolder->setIcon(QIcon::fromTheme(QStringLiteral("list-add"))); |
| 83 | m_bNewFolder->setToolTip(i18n("Add new folder")); |
| 84 | ui.gbImportTo->layout()->addWidget(m_bNewFolder); |
| 85 | |
| 86 | // dialog buttons |
| 87 | m_buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); |
| 88 | vLayout->addWidget(m_buttonBox); |
| 89 | |
| 90 | // ok-button is only enabled if some project objects were selected (s.a. ImportProjectDialog::selectionChanged()) |
| 91 | m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); |
| 92 | |
| 93 | // Signals/Slots |
| 94 | connect(m_cbFileName, &KUrlComboBox::urlActivated, this, [=](const QUrl& url) { |
| 95 | fileNameChanged(url.path()); |
| 96 | }); |
| 97 | connect(ui.bOpen, &QPushButton::clicked, this, &ImportProjectDialog::selectFile); |
| 98 | connect(m_bNewFolder, &QPushButton::clicked, this, &ImportProjectDialog::newFolder); |
| 99 | connect(m_buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); |
| 100 | connect(m_buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject); |
| 101 |
nothing calls this directly
no test coverage detected