You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
200 lines
6.9 KiB
200 lines
6.9 KiB
3 years ago
|
#include "importSection.h"
|
||
|
#include "ui_importSection.h"
|
||
|
|
||
|
importSection::importSection(QStringList notebookColorList, QStringList notebookDirList, QStringList list, QWidget *parent) :
|
||
|
QDialog(parent),
|
||
|
ui(new Ui::importSection)
|
||
|
{
|
||
|
setNotebookColorList(notebookColorList);
|
||
|
setNotebookDirList(notebookDirList);
|
||
|
setDirectoryList(list);
|
||
|
ui->setupUi(this);
|
||
|
init();
|
||
|
}
|
||
|
|
||
|
importSection::~importSection()
|
||
|
{
|
||
|
delete ui;
|
||
|
}
|
||
|
|
||
|
void importSection::init()
|
||
|
{
|
||
|
int idx = 0;
|
||
|
for(idx = 0; idx < getDirectoryList().size(); idx++)
|
||
|
{
|
||
|
if(!getDirectoryList().at(idx).startsWith(" "))
|
||
|
{
|
||
|
ui->directorySelection->addItem(SetNotebookIcon(nbColorList.at(idx)), getDirectoryList().at(idx));
|
||
|
} else {
|
||
|
ui->directorySelection->addItem(SetSectionGroupIcon(nbColorList.at(idx)), getDirectoryList().at(idx));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void importSection::on_selectDirectoryButton_clicked()
|
||
|
{
|
||
|
QFileDialog dialog(this);
|
||
|
dialog.setFileMode(QFileDialog::ExistingFile);
|
||
|
dialog.setNameFilter(tr("Executable File"));
|
||
|
QString fileName = dialog.getOpenFileName(this, tr("Open File"), QDir().homePath() + "/Documents", tr("File")); // Open Dialog
|
||
|
ui->importSection_Field->setText(fileName);
|
||
|
}
|
||
|
|
||
|
void importSection::on_buttonBox_accepted()
|
||
|
{
|
||
|
if(ui->importSection_Field->text() != "")
|
||
|
{
|
||
|
QFile file(ui->importSection_Field->text());
|
||
|
QFileInfo fileInfo(ui->importSection_Field->text());
|
||
|
if(file.exists())
|
||
|
{
|
||
|
setNewFile(getNotebookDirList().at(ui->directorySelection->currentIndex()) + "/" + fileInfo.fileName());
|
||
|
if(ui->moveItemButton->isChecked())
|
||
|
{
|
||
|
file.copy(newFile);
|
||
|
file.remove();
|
||
|
}
|
||
|
if(ui->copyItemButton->isChecked())
|
||
|
{
|
||
|
file.copy(newFile);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
accept();
|
||
|
}
|
||
|
void importSection::on_buttonBox_rejected()
|
||
|
{
|
||
|
reject();
|
||
|
}
|
||
|
|
||
|
QIcon importSection::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 importSection::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;
|
||
|
}
|
||
|
|
||
|
QStringList importSection::getDirectoryList()
|
||
|
{
|
||
|
return var_directoryList;
|
||
|
}
|
||
|
QStringList importSection::getNotebookColorList()
|
||
|
{
|
||
|
return nbColorList;
|
||
|
}
|
||
|
QStringList importSection::getNotebookDirList()
|
||
|
{
|
||
|
return nbDirList;
|
||
|
}
|
||
|
QString importSection::getNewFile()
|
||
|
{
|
||
|
return newFile;
|
||
|
}
|
||
|
|
||
|
void importSection::setDirectoryList(QStringList dirList)
|
||
|
{
|
||
|
var_directoryList = dirList;
|
||
|
}
|
||
|
void importSection::setNotebookColorList(QStringList newNbColorList)
|
||
|
{
|
||
|
nbColorList = newNbColorList;
|
||
|
}
|
||
|
void importSection::setNotebookDirList(QStringList newNbDirList)
|
||
|
{
|
||
|
nbDirList = newNbDirList;
|
||
|
}
|
||
|
void importSection::setNewFile(QString newNewFile)
|
||
|
{
|
||
|
newFile = newNewFile;
|
||
|
}
|