/* DrewTechs * Note Binder * @Version 1.0 */ #include "newSectionDialog.h" #include "ui_newSectionDialog.h" /* Constructors */ newSectionDialog::newSectionDialog(QStringList notebookColorList, QStringList notebookDirList, QStringList list, QList applicationLaunchers, QWidget *parent) : QDialog(parent) , ui(new Ui::newSectionDialog) { setNotebookColorList(notebookColorList); setNotebookDirList(notebookDirList); setDirectories(list); setApplicationLauncher(applicationLaunchers); ui->setupUi(this); init(); } /* Destructor */ newSectionDialog::~newSectionDialog() { delete ui; } void newSectionDialog::on_buttonBox_accepted() { if(ui->fileNameBox->text() != "" && ui->directorySelection->currentText() != "") // Cannot have Empty Filename { applicationLauncher(); accept(); } else { reject(); } } void newSectionDialog::on_buttonBox_rejected() { reject(); } void newSectionDialog::addItemsToDirectory() { int idx = 0; for(idx = 0; idx < getDirectories().size(); idx++) { if(!getDirectories().at(idx).startsWith(" ")) { ui->directorySelection->addItem(SetNotebookIcon(notebookcolorlist.at(idx)), getDirectories().at(idx)); } else { ui->directorySelection->addItem(SetSectionGroupIcon(notebookcolorlist.at(idx)), getDirectories().at(idx)); } } } void newSectionDialog::init() { QStringList extensionItems; QStringList extensions; int appLauncher_idx = 0; for(appLauncher_idx = 0; appLauncher_idx < applicationLaunchers.size(); appLauncher_idx++) { int extensions_idx = 0; for(extensions_idx = 0; extensions_idx < applicationLaunchers.at(appLauncher_idx)->getApplicationExtensions().size(); extensions_idx++) { extensions.append(applicationLaunchers.at(appLauncher_idx)->getSingleApplicationExtension(extensions_idx)); extensionItems.append(applicationLaunchers.at(appLauncher_idx)->getApplicationName() + " (" + applicationLaunchers.at(appLauncher_idx)->getSingleApplicationExtension(extensions_idx) + ")"); } } setExtensionList(extensions); ui->fileExtensionBox->addItems(extensionItems); addItemsToDirectory(); } void newSectionDialog::applicationLauncher() { QString fileName, fileExtension; fileName = ui->fileNameBox->text(); // File Name without the Extension QStringList extensionItems = getExtensionList(); int idx = 0; for(idx = 0; idx < extensionItems.size(); idx++) { if(idx == ui->fileExtensionBox->currentIndex()) { int itemLocation; fileName += extensionItems.at(idx); itemLocation = ui->directorySelection->currentIndex(); fullFileName = notebookdirList.at(itemLocation); fullFileName += QDir::separator() + fileName; setFullFileName(fullFileName); } } } QIcon newSectionDialog::SetNotebookIcon(QString notebookColor) { QIcon icon; QString iconPath = "../NoteBinder/Icons"; if(!QDir(iconPath).exists()) { return icon; } if(notebookColor == "Red") { icon = QIcon(iconPath + "/NotebookIcon_Red.png"); } else if(notebookColor == "Blue") { icon = QIcon(iconPath + "/NotebookIcon_Blue.png"); } else if(notebookColor == "Purple") { icon = QIcon(iconPath + "/NotebookIcon_Purple.png"); } else if(notebookColor == "Orange") { icon = QIcon(iconPath + "/NotebookIcon_Orange.png"); } else if(notebookColor == "Yellow") { icon = QIcon(iconPath + "/NotebookIcon_Yellow.png"); } else if(notebookColor == "Green") { icon = QIcon(iconPath + "/NotebookIcon_Green.png"); } else if(notebookColor == "Cyan") { icon = QIcon(iconPath + "/NotebookIcon_Cyan.png"); } else if(notebookColor == "Tan") { icon = QIcon(iconPath + "/NotebookIcon_Tan.png"); } else if(notebookColor == "Teal") { icon = QIcon(iconPath + "/NotebookIcon_Teal.png"); } else if(notebookColor == "Red Chalk") { icon = QIcon(iconPath + "/NotebookIcon_RedChalk.png"); } else if(notebookColor == "Blue Mist") { icon = QIcon(iconPath + "/NotebookIcon_BlueMist.png"); } else if(notebookColor == "Purple Mist") { icon = QIcon(iconPath + "/NotebookIcon_PurpleMist.png"); } else if(notebookColor == "Magenta") { icon = QIcon(iconPath + "/NotebookIcon_Magenta.png"); } else if(notebookColor == "Lemon Lime") { icon = QIcon(iconPath + "/NotebookIcon_LemonLime.png"); } else if(notebookColor == "Apple") { icon = QIcon(iconPath + "/NotebookIcon_Apple.png"); } else if(notebookColor == "Silver") { icon = QIcon(iconPath + "/NotebookIcon_Silver.png"); } else if(notebookColor == "Black") { icon = QIcon(iconPath + "/NotebookIcon_Black.png"); } else { // If it's either White/None or an invalid value, set to the white icon icon = QIcon(iconPath + "/NotebookIcon_White.png"); } return icon; } QIcon newSectionDialog::SetSectionGroupIcon(QString sectionGroupColor) { QIcon icon; QString iconPath = "../NoteBinder/Icons"; if(!QDir(iconPath).exists()) { return icon; } if(sectionGroupColor == "Red") { icon = QIcon(iconPath + "/SectionGroupIcon_Red.png"); } else if(sectionGroupColor == "Blue") { icon = QIcon(iconPath + "/SectionGroupIcon_Blue.png"); } else if(sectionGroupColor == "Purple") { icon = QIcon(iconPath + "/SectionGroupIcon_Purple.png"); } else if(sectionGroupColor == "Orange") { icon = QIcon(iconPath + "/SectionGroupIcon_Orange.png"); } else if(sectionGroupColor == "Yellow") { icon = QIcon(iconPath + "/SectionGroupIcon_Yellow.png"); } else if(sectionGroupColor == "Green") { icon = QIcon(iconPath + "/SectionGroupIcon_Green.png"); } else if(sectionGroupColor == "Cyan") { icon = QIcon(iconPath + "/SectionGroupIcon_Cyan.png"); } else if(sectionGroupColor == "Tan") { icon = QIcon(iconPath + "/SectionGroupIcon_Tan.png"); } else if(sectionGroupColor == "Teal") { icon = QIcon(iconPath + "/SectionGroupIcon_Teal.png"); } else if(sectionGroupColor == "Red Chalk") { icon = QIcon(iconPath + "/SectionGroupIcon_RedChalk.png"); } else if(sectionGroupColor == "Blue Mist") { icon = QIcon(iconPath + "/SectionGroupIcon_BlueMist.png"); } else if(sectionGroupColor == "Purple Mist") { icon = QIcon(iconPath + "/SectionGroupIcon_PurpleMist.png"); } else if(sectionGroupColor == "Magenta") { icon = QIcon(iconPath + "/SectionGroupIcon_Magenta.png"); } else if(sectionGroupColor == "Lemon Lime") { icon = QIcon(iconPath + "/SectionGroupIcon_LemonLime.png"); } else if(sectionGroupColor == "Apple") { icon = QIcon(iconPath + "/SectionGroupIcon_Apple.png"); } else if(sectionGroupColor == "Silver") { icon = QIcon(iconPath + "/SectionGroupIcon_Silver.png"); } else if(sectionGroupColor == "Black") { icon = QIcon(iconPath + "/SectionGroupIcon_Black.png"); } else { // If it's either White/None or an invalid value, set to the white icon icon = QIcon(iconPath + "/SectionGroupIcon_White.png"); } return icon; } /* Getter Functions */ QStringList newSectionDialog::getDirectories() const { return var_directoryList; } QStringList newSectionDialog::getNotebookDirList() const { return notebookdirList; } QStringList newSectionDialog::getNotebookColorList() const { return notebookcolorlist; } QStringList newSectionDialog::getExtensionList() const { return extensionList; } QString newSectionDialog::getFullFileName() const { return fullFileName; } /* Setter Functions */ void newSectionDialog::setApplicationLauncher(QList newApplicationLaunchers) { applicationLaunchers = newApplicationLaunchers; } void newSectionDialog::setDirectories(QStringList dirList) { var_directoryList = dirList; } void newSectionDialog::setNotebookDirList(QStringList nbDirList) { notebookdirList = nbDirList; } void newSectionDialog::setNotebookColorList(QStringList nbColorList) { notebookcolorlist = nbColorList; } void newSectionDialog::setExtensionList(QStringList newExtensionList) { extensionList = newExtensionList; } void newSectionDialog::setFullFileName(QString newFullFileName) { fullFileName = newFullFileName; }