From bf8bb29938adaf3a301d36c324d4441a2ca95805 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 30 Dec 2013 00:05:03 +0100 Subject: [PATCH] GUI: Allow user to choose any available library file --- gui/projectfile.ui | 30 +----------------------------- gui/projectfiledialog.cpp | 37 +++++++++++++++++++++++++++++-------- gui/projectfiledialog.h | 4 ++++ 3 files changed, 34 insertions(+), 37 deletions(-) diff --git a/gui/projectfile.ui b/gui/projectfile.ui index 8d6f9100a..6d73e49a3 100644 --- a/gui/projectfile.ui +++ b/gui/projectfile.ui @@ -59,7 +59,7 @@ - + @@ -67,34 +67,6 @@ - - - - gtk - - - - - - - posix - - - - - - - qt - - - - - - - windows - - - diff --git a/gui/projectfiledialog.cpp b/gui/projectfiledialog.cpp index 15fbf28ae..bde3aee19 100644 --- a/gui/projectfiledialog.cpp +++ b/gui/projectfiledialog.cpp @@ -33,12 +33,33 @@ ProjectFileDialog::ProjectFileDialog(const QString &path, QWidget *parent) { mUI.setupUi(this); - QFileInfo inf(path); + const QFileInfo inf(path); QString filename = inf.fileName(); QString title = tr("Project file: %1").arg(filename); setWindowTitle(title); LoadSettings(); + // Checkboxes for the libraries.. + const QString applicationFilePath = QCoreApplication::applicationFilePath(); + const QString appPath = QFileInfo(applicationFilePath).canonicalPath(); + const QString searchPaths[] = { appPath, appPath + "/cfg", inf.canonicalPath() }; + for (int i = 0; i < 3; i++) { + QDir dir(searchPaths[i]); + dir.setSorting(QDir::Name); + dir.setNameFilters(QStringList("*.cfg")); + dir.setFilter(QDir::Files | QDir::NoDotAndDotDot); + foreach(QFileInfo item, dir.entryInfoList()) { + QString library = item.fileName(); + library.chop(4); + if (library.compare("std", Qt::CaseInsensitive) == 0) + continue; + QCheckBox *checkbox = new QCheckBox(this); + checkbox->setText(library); + mUI.librariesLayout->addWidget(checkbox); + mLibraryCheckboxes << checkbox; + } + } + connect(mUI.mButtons, SIGNAL(accepted()), this, SLOT(accept())); connect(mUI.mBtnAddInclude, SIGNAL(clicked()), this, SLOT(AddIncludeDir())); connect(mUI.mBtnAddPath, SIGNAL(clicked()), this, SLOT(AddPath())); @@ -163,10 +184,9 @@ QStringList ProjectFileDialog::GetExcludedPaths() const QStringList ProjectFileDialog::GetLibraries() const { QStringList libraries; - const QCheckBox *c[] = { mUI.mChkboxGtk, mUI.mChkboxPosix, mUI.mChkboxQt, mUI.mChkboxWindows }; - for (unsigned int i = 0; i < sizeof(c) / sizeof(c[0]); i++) { - if (c[i]->isChecked()) - libraries << c[i]->text(); + for (int i = 0; i < mLibraryCheckboxes.size(); i++) { + if (mLibraryCheckboxes[i]->isChecked()) + libraries << mLibraryCheckboxes[i]->text(); } return libraries; } @@ -214,9 +234,10 @@ void ProjectFileDialog::SetExcludedPaths(const QStringList &paths) void ProjectFileDialog::SetLibraries(const QStringList &libraries) { - QCheckBox *c[] = { mUI.mChkboxGtk, mUI.mChkboxPosix, mUI.mChkboxQt, mUI.mChkboxWindows }; - for (unsigned int i = 0; i < sizeof(c) / sizeof(c[0]); i++) - c[i]->setChecked(libraries.contains(c[i]->text())); + for (int i = 0; i < mLibraryCheckboxes.size(); i++) { + QCheckBox *checkbox = mLibraryCheckboxes[i]; + checkbox->setChecked(libraries.contains(checkbox->text())); + } } void ProjectFileDialog::AddIncludeDir() diff --git a/gui/projectfiledialog.h b/gui/projectfiledialog.h index e760e51e9..a4852a82e 100644 --- a/gui/projectfiledialog.h +++ b/gui/projectfiledialog.h @@ -22,6 +22,7 @@ #include #include #include +#include #include "ui_projectfile.h" @@ -206,6 +207,9 @@ private: * @brief Projectfile path. */ QString mFilePath; + + /** @brief Library checkboxes */ + QList mLibraryCheckboxes; }; /// @}