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.
501 lines
27 KiB
501 lines
27 KiB
#include "itemProperties.h"
|
|
#include "ui_itemProperties.h"
|
|
|
|
itemProperties::itemProperties(NotebookList* nbList, QString notebookItemLocation, QWidget *parent) :
|
|
QDialog(parent),
|
|
ui(new Ui::itemProperties)
|
|
{
|
|
ui->setupUi(this);
|
|
setNotebookList(nbList);
|
|
setNotebookItemLocation(notebookItemLocation);
|
|
init();
|
|
}
|
|
|
|
itemProperties::~itemProperties()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void itemProperties::init()
|
|
{
|
|
int nb_idx = 0;
|
|
int file_idx = 0;
|
|
int sg_idx = 0;
|
|
for(nb_idx = 0; nb_idx < notebookList->nbList.size(); nb_idx++)
|
|
{
|
|
if(notebookList->nbList.at(nb_idx)->location == notebookItemLocation)
|
|
{
|
|
ui->itemNameLabel->setText("Notebook Name: ");
|
|
ui->itemLocationLabel->setText("Notebook Location: ");
|
|
ui->itemColorLabel->setText("Notebook Color: ");
|
|
ui->itemNameBox->setText(notebookList->nbList.at(nb_idx)->name);
|
|
ui->itemLocationBox->setText(notebookList->nbList.at(nb_idx)->location);
|
|
ui->itemColorComboBox->setVisible(true);
|
|
setIconsToItemColorComboBox_Notebook();
|
|
int item_idx = ui->itemColorComboBox->findText(notebookList->nbList.at(nb_idx)->color);
|
|
if(item_idx != -1) { ui->itemColorComboBox->setCurrentIndex(item_idx); }
|
|
|
|
} else {
|
|
for(file_idx = 0; file_idx < notebookList->nbList.at(nb_idx)->files.size(); file_idx++)
|
|
{
|
|
QFileInfo fileInfo(notebookList->nbList.at(nb_idx)->files.at(file_idx));
|
|
if(fileInfo.isFile())
|
|
{
|
|
// Section
|
|
if(notebookList->nbList.at(nb_idx)->files.at(file_idx) == notebookItemLocation)
|
|
{
|
|
ui->itemNameLabel->setText("Section Name: ");
|
|
ui->itemLocationLabel->setText("Section Location: ");
|
|
ui->itemColorLabel->setText("");
|
|
ui->itemNameBox->setText(fileInfo.fileName());
|
|
ui->itemLocationBox->setText(notebookList->nbList.at(nb_idx)->files.at(file_idx));
|
|
ui->itemColorComboBox->setVisible(false);
|
|
}
|
|
} else {
|
|
// Section Group
|
|
if(notebookList->nbList.at(nb_idx)->files.at(file_idx) == notebookItemLocation)
|
|
{
|
|
ui->itemNameLabel->setText("Section Group Name: ");
|
|
ui->itemLocationLabel->setText("Section Group Location: ");
|
|
ui->itemColorLabel->setText("Section Group Color: ");
|
|
ui->itemNameBox->setText(notebookList->nbList.at(nb_idx)->sectionGroupArray.at(sg_idx)->name);
|
|
ui->itemLocationBox->setText(notebookList->nbList.at(nb_idx)->sectionGroupArray.at(sg_idx)->location);
|
|
ui->itemColorComboBox->setEnabled(true);
|
|
setIconsToItemColorComboBox_SectionGroup();
|
|
int item_idx = ui->itemColorComboBox->findText(notebookList->nbList.at(nb_idx)->sectionGroupArray.at(sg_idx)->color);
|
|
if(item_idx != -1) { ui->itemColorComboBox->setCurrentIndex(item_idx); }
|
|
} else {
|
|
init_searchDirectoryRecursive(notebookList->nbList.at(nb_idx)->sectionGroupArray.at(sg_idx));
|
|
}
|
|
sg_idx++;
|
|
}
|
|
}
|
|
}
|
|
sg_idx = 0;
|
|
file_idx = 0;
|
|
}
|
|
}
|
|
|
|
void itemProperties::on_buttonBox_accepted()
|
|
{
|
|
int nb_idx = 0;
|
|
int file_idx = 0;
|
|
int file2_idx = 0;
|
|
int sg_idx = 0;
|
|
int sg2_idx = 0;
|
|
for(nb_idx = 0; nb_idx < notebookList->nbList.size(); nb_idx++)
|
|
{
|
|
if(notebookList->nbList.at(nb_idx)->location == notebookItemLocation)
|
|
{
|
|
QFileInfo notebookFileInfo(notebookList->nbList.at(nb_idx)->location);
|
|
// Rename Directory
|
|
QDir dir(notebookList->nbList.at(nb_idx)->location);
|
|
if(!QDir(notebookFileInfo.path() + QDir::separator() + ui->itemNameBox->text()).exists())
|
|
{
|
|
notebookList->nbList.at(nb_idx)->name = ui->itemNameBox->text();
|
|
dir.rename(notebookList->nbList.at(nb_idx)->location, notebookFileInfo.path() + QDir::separator() + ui->itemNameBox->text());
|
|
notebookList->nbList.at(nb_idx)->location = notebookFileInfo.path() + QDir::separator() + ui->itemNameBox->text();
|
|
notebookList->nbList.at(nb_idx)->color = ui->itemColorComboBox->currentText();
|
|
for(file2_idx = 0; file2_idx < notebookList->nbList.at(nb_idx)->files.size(); file2_idx++)
|
|
{
|
|
QFileInfo oldFileInfo(notebookList->nbList.at(nb_idx)->files.at(file2_idx));
|
|
notebookList->nbList.at(nb_idx)->files.replace(file2_idx, notebookList->nbList.at(nb_idx)->location + QDir::separator() + oldFileInfo.fileName());
|
|
QFileInfo fileInfo(notebookList->nbList.at(nb_idx)->files.at(file2_idx));
|
|
if(!fileInfo.isFile())
|
|
{
|
|
// Section Group
|
|
notebookList->nbList.at(nb_idx)->sectionGroupArray.at(sg2_idx)->location = notebookList->nbList.at(nb_idx)->location + QDir::separator()
|
|
+ oldFileInfo.fileName();
|
|
notebookList->nbList.at(nb_idx)->sectionGroupArray.at(sg2_idx)->parentDir = notebookList->nbList.at(nb_idx)->name;
|
|
accept_notebookSearchDirectoryRecursive(notebookList->nbList.at(nb_idx)->sectionGroupArray.at(sg2_idx), notebookFileInfo);
|
|
sg2_idx++;
|
|
}
|
|
}
|
|
QFile notebookFile(notebookList->nbList.at(nb_idx)->location + QDir::separator() + "notebook.noteb");
|
|
notebookFile.remove();
|
|
if (notebookFile.open(QIODevice::ReadWrite)) {
|
|
QTextStream in(¬ebookFile);
|
|
in << notebookList->nbList.at(nb_idx)->name << "\n" << notebookList->nbList.at(nb_idx)->color << "\n";
|
|
}
|
|
notebookFile.close();
|
|
break;
|
|
}
|
|
} else {
|
|
for(file_idx = 0; file_idx < notebookList->nbList.at(nb_idx)->files.size(); file_idx++)
|
|
{
|
|
QFileInfo notebookFileInfo(notebookList->nbList.at(nb_idx)->location);
|
|
QFileInfo fileInfo(notebookList->nbList.at(nb_idx)->files.at(file_idx));
|
|
if(fileInfo.isFile())
|
|
{
|
|
// Section
|
|
if(notebookList->nbList.at(nb_idx)->files.at(file_idx) == notebookItemLocation)
|
|
{
|
|
if(!QFile(notebookList->nbList.at(nb_idx)->location + QDir::separator() + ui->itemNameBox->text()).exists())
|
|
{
|
|
QFile file(notebookList->nbList.at(nb_idx)->files.at(file_idx));
|
|
file.rename(notebookList->nbList.at(nb_idx)->files.at(file_idx), notebookList->nbList.at(nb_idx)->location
|
|
+ QDir::separator() + ui->itemNameBox->text());
|
|
notebookList->nbList.at(nb_idx)->files.replace(file_idx, notebookList->nbList.at(nb_idx)->location + QDir::separator()
|
|
+ ui->itemNameBox->text());
|
|
break;
|
|
}
|
|
}
|
|
} else {
|
|
// Section Group
|
|
if(notebookList->nbList.at(nb_idx)->files.at(file_idx) == notebookItemLocation)
|
|
{
|
|
if(!QDir(notebookList->nbList.at(nb_idx)->location + QDir::separator() + ui->itemNameBox->text()).exists())
|
|
{
|
|
notebookList->nbList.at(nb_idx)->files.replace(file_idx, notebookList->nbList.at(nb_idx)->location + QDir::separator() + ui->itemNameBox->text());
|
|
notebookList->nbList.at(nb_idx)->sectionGroupArray.at(sg_idx)->name = ui->itemNameBox->text();
|
|
notebookList->nbList.at(nb_idx)->sectionGroupArray.at(sg_idx)->color = ui->itemColorComboBox->currentText();
|
|
// Rename Directory
|
|
QDir dir(notebookList->nbList.at(nb_idx)->sectionGroupArray.at(sg_idx)->location);
|
|
dir.rename(notebookList->nbList.at(nb_idx)->sectionGroupArray.at(sg_idx)->location, notebookList->nbList.at(nb_idx)->location
|
|
+ QDir::separator() + ui->itemNameBox->text());
|
|
notebookList->nbList.at(nb_idx)->sectionGroupArray.at(sg_idx)->location = notebookList->nbList.at(nb_idx)->location + QDir::separator()
|
|
+ ui->itemNameBox->text();
|
|
int file2_idx = 0;
|
|
for(file2_idx = 0; file2_idx < notebookList->nbList.at(nb_idx)->sectionGroupArray.at(sg_idx)->files.size(); file2_idx++)
|
|
{
|
|
QFileInfo fileInfo(notebookList->nbList.at(nb_idx)->sectionGroupArray.at(sg_idx)->files.at(file2_idx));
|
|
QFile file(notebookList->nbList.at(nb_idx)->sectionGroupArray.at(sg_idx)->files.at(file2_idx));
|
|
file.rename(notebookList->nbList.at(nb_idx)->files.at(file_idx), notebookList->nbList.at(nb_idx)->location
|
|
+ QDir::separator() + ui->itemNameBox->text());
|
|
notebookList->nbList.at(nb_idx)->sectionGroupArray.at(sg_idx)->files.replace(file2_idx, notebookList->nbList.at(nb_idx)->sectionGroupArray.at(sg_idx)->location
|
|
+ QDir::separator() + fileInfo.fileName());
|
|
}
|
|
// Section Group File:
|
|
QFile sectionGroupFile(notebookList->nbList.at(nb_idx)->sectionGroupArray.at(sg_idx)->location + QDir::separator() + "sectiongroup.sectgr");
|
|
sectionGroupFile.remove();
|
|
if (sectionGroupFile.open(QIODevice::ReadWrite)) {
|
|
QTextStream in(§ionGroupFile);
|
|
in << notebookList->nbList.at(nb_idx)->sectionGroupArray.at(sg_idx)->name << "\n" << notebookList->nbList.at(nb_idx)->sectionGroupArray.at(sg_idx)->color << "\n";
|
|
}
|
|
sectionGroupFile.close();
|
|
accept_notebookSearchDirectoryRecursive(notebookList->nbList.at(nb_idx)->sectionGroupArray.at(sg_idx), notebookFileInfo);
|
|
break;
|
|
} else {
|
|
notebookList->nbList.at(nb_idx)->sectionGroupArray.at(sg_idx)->name = ui->itemNameBox->text();
|
|
notebookList->nbList.at(nb_idx)->sectionGroupArray.at(sg_idx)->color = ui->itemColorComboBox->currentText();
|
|
QFile sectionGroupFile(notebookList->nbList.at(nb_idx)->sectionGroupArray.at(sg_idx)->location + QDir::separator() + "sectiongroup.sectgr");
|
|
sectionGroupFile.remove();
|
|
if (sectionGroupFile.open(QIODevice::ReadWrite)) {
|
|
QTextStream in(§ionGroupFile);
|
|
in << notebookList->nbList.at(nb_idx)->sectionGroupArray.at(sg_idx)->name << "\n" << notebookList->nbList.at(nb_idx)->sectionGroupArray.at(sg_idx)->color << "\n";
|
|
}
|
|
sectionGroupFile.close();
|
|
}
|
|
} else {
|
|
accept_sectionGroupSearchDirectoryRecursive(notebookList->nbList.at(nb_idx)->sectionGroupArray.at(sg_idx), notebookFileInfo);
|
|
}
|
|
sg_idx++;
|
|
}
|
|
}
|
|
}
|
|
sg_idx = 0;
|
|
}
|
|
setNotebookList(notebookList);
|
|
accept();
|
|
}
|
|
|
|
void itemProperties::on_buttonBox_rejected()
|
|
{
|
|
reject();
|
|
}
|
|
|
|
NotebookList* itemProperties::getNotebookList()
|
|
{
|
|
return notebookList;
|
|
}
|
|
void itemProperties::setNotebookList(NotebookList* newNotebookList)
|
|
{
|
|
notebookList = newNotebookList;
|
|
}
|
|
QString itemProperties::getNotebookItemLocation()
|
|
{
|
|
return notebookItemLocation;
|
|
}
|
|
void itemProperties::setNotebookItemLocation(QString newNotebookItemLocation)
|
|
{
|
|
notebookItemLocation = newNotebookItemLocation;
|
|
}
|
|
|
|
void itemProperties::setIconsToItemColorComboBox_Notebook()
|
|
{
|
|
ui->itemColorComboBox->addItem(SetNotebookIcon("None"), "None");
|
|
ui->itemColorComboBox->addItem(SetNotebookIcon("Red"), "Red");
|
|
ui->itemColorComboBox->addItem(SetNotebookIcon("Blue"), "Blue");
|
|
ui->itemColorComboBox->addItem(SetNotebookIcon("Purple"), "Purple");
|
|
ui->itemColorComboBox->addItem(SetNotebookIcon("Orange"), "Orange");
|
|
ui->itemColorComboBox->addItem(SetNotebookIcon("Yellow"), "Yellow");
|
|
ui->itemColorComboBox->addItem(SetNotebookIcon("Green"), "Green");
|
|
ui->itemColorComboBox->addItem(SetNotebookIcon("Cyan"), "Cyan");
|
|
ui->itemColorComboBox->addItem(SetNotebookIcon("Tan"), "Tan");
|
|
ui->itemColorComboBox->addItem(SetNotebookIcon("Teal"), "Teal");
|
|
ui->itemColorComboBox->addItem(SetNotebookIcon("Magenta"), "Magenta");
|
|
ui->itemColorComboBox->addItem(SetNotebookIcon("Red Chalk"), "Red Chalk");
|
|
ui->itemColorComboBox->addItem(SetNotebookIcon("Blue Mist"), "Blue Mist");
|
|
ui->itemColorComboBox->addItem(SetNotebookIcon("Purple Mist"), "Purple Mist");
|
|
ui->itemColorComboBox->addItem(SetNotebookIcon("Lemon Lime"), "Lemon Lime");
|
|
ui->itemColorComboBox->addItem(SetNotebookIcon("Apple"), "Apple");
|
|
ui->itemColorComboBox->addItem(SetNotebookIcon("Silver"), "Silver");
|
|
ui->itemColorComboBox->addItem(SetNotebookIcon("Black"), "Black");
|
|
}
|
|
|
|
void itemProperties::setIconsToItemColorComboBox_SectionGroup()
|
|
{
|
|
ui->itemColorComboBox->addItem(SetSectionGroupIcon("None"), "None");
|
|
ui->itemColorComboBox->addItem(SetSectionGroupIcon("Red"), "Red");
|
|
ui->itemColorComboBox->addItem(SetSectionGroupIcon("Blue"), "Blue");
|
|
ui->itemColorComboBox->addItem(SetSectionGroupIcon("Purple"), "Purple");
|
|
ui->itemColorComboBox->addItem(SetSectionGroupIcon("Orange"), "Orange");
|
|
ui->itemColorComboBox->addItem(SetSectionGroupIcon("Yellow"), "Yellow");
|
|
ui->itemColorComboBox->addItem(SetSectionGroupIcon("Green"), "Green");
|
|
ui->itemColorComboBox->addItem(SetSectionGroupIcon("Cyan"), "Cyan");
|
|
ui->itemColorComboBox->addItem(SetSectionGroupIcon("Tan"), "Tan");
|
|
ui->itemColorComboBox->addItem(SetSectionGroupIcon("Teal"), "Teal");
|
|
ui->itemColorComboBox->addItem(SetSectionGroupIcon("Magenta"), "Magenta");
|
|
ui->itemColorComboBox->addItem(SetSectionGroupIcon("Red Chalk"), "Red Chalk");
|
|
ui->itemColorComboBox->addItem(SetSectionGroupIcon("Blue Mist"), "Blue Mist");
|
|
ui->itemColorComboBox->addItem(SetSectionGroupIcon("Purple Mist"), "Purple Mist");
|
|
ui->itemColorComboBox->addItem(SetSectionGroupIcon("Lemon Lime"), "Lemon Lime");
|
|
ui->itemColorComboBox->addItem(SetSectionGroupIcon("Apple"), "Apple");
|
|
ui->itemColorComboBox->addItem(SetSectionGroupIcon("Silver"), "Silver");
|
|
ui->itemColorComboBox->addItem(SetSectionGroupIcon("Black"), "Black");
|
|
}
|
|
|
|
QIcon itemProperties::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 itemProperties::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;
|
|
}
|
|
|
|
/* Recursive Functions */
|
|
void itemProperties::init_searchDirectoryRecursive(SectionGroup* sectionGroup)
|
|
{
|
|
int sg_idx = 0;
|
|
int file_idx = 0;
|
|
for(file_idx = 0; file_idx < sectionGroup->files.size(); file_idx++)
|
|
{
|
|
QFileInfo fileInfo(sectionGroup->files.at(file_idx));
|
|
if(fileInfo.isFile())
|
|
{
|
|
// Section
|
|
if(sectionGroup->files.at(file_idx) == notebookItemLocation)
|
|
{
|
|
ui->itemNameLabel->setText("Section Name: ");
|
|
ui->itemLocationLabel->setText("Section Location: ");
|
|
ui->itemColorLabel->setText("");
|
|
ui->itemNameBox->setText(fileInfo.fileName());
|
|
ui->itemLocationBox->setText(sectionGroup->files.at(file_idx));
|
|
ui->itemColorComboBox->setVisible(false);
|
|
}
|
|
} else {
|
|
// Section Group
|
|
if(sectionGroup->files.at(file_idx) == notebookItemLocation)
|
|
{
|
|
ui->itemNameLabel->setText("Section Group Name: ");
|
|
ui->itemLocationLabel->setText("Section Group Location: ");
|
|
ui->itemColorLabel->setText("Section Group Color: ");
|
|
ui->itemNameBox->setText(sectionGroup->sectionGroupArray.at(sg_idx)->name);
|
|
ui->itemLocationBox->setText(sectionGroup->sectionGroupArray.at(sg_idx)->location);
|
|
ui->itemColorComboBox->setVisible(true);
|
|
setIconsToItemColorComboBox_SectionGroup();
|
|
int item_idx = ui->itemColorComboBox->findText(sectionGroup->sectionGroupArray.at(sg_idx)->color);
|
|
if(item_idx != -1) { ui->itemColorComboBox->setCurrentIndex(item_idx); }
|
|
} else {
|
|
init_searchDirectoryRecursive(sectionGroup->sectionGroupArray.at(sg_idx));
|
|
}
|
|
sg_idx++;
|
|
}
|
|
}
|
|
}
|
|
|
|
void itemProperties::accept_notebookSearchDirectoryRecursive(SectionGroup* sectionGroup, QFileInfo notebookFileInfo)
|
|
{
|
|
int sg_idx = 0;
|
|
int file_idx = 0;
|
|
for(file_idx = 0; file_idx < sectionGroup->files.size(); file_idx++)
|
|
{
|
|
QFileInfo oldFileInfo(sectionGroup->files.at(file_idx));
|
|
sectionGroup->files.replace(file_idx, sectionGroup->location + QDir::separator() + oldFileInfo.fileName());
|
|
QFileInfo fileInfo(sectionGroup->files.at(file_idx));
|
|
if(fileInfo.isDir())
|
|
{
|
|
// Section Group
|
|
sectionGroup->sectionGroupArray.at(sg_idx)->location = sectionGroup->location + QDir::separator() + fileInfo.fileName();
|
|
sectionGroup->sectionGroupArray.at(sg_idx)->parentDir = sectionGroup->name;
|
|
accept_notebookSearchDirectoryRecursive(sectionGroup->sectionGroupArray.at(sg_idx), notebookFileInfo);
|
|
sg_idx++;
|
|
}
|
|
}
|
|
}
|
|
|
|
void itemProperties::accept_sectionGroupSearchDirectoryRecursive(SectionGroup* sectionGroup, QFileInfo notebookFileInfo)
|
|
{
|
|
int sg_idx = 0;
|
|
int file_idx = 0;
|
|
for(file_idx = 0; file_idx < sectionGroup->files.size(); file_idx++)
|
|
{
|
|
QFileInfo notebookFileInfo(sectionGroup->location);
|
|
QFileInfo fileInfo(sectionGroup->files.at(file_idx));
|
|
if(fileInfo.isFile())
|
|
{
|
|
// Section
|
|
if(sectionGroup->files.at(file_idx) == notebookItemLocation)
|
|
{
|
|
if(!QFile(sectionGroup->location + QDir::separator() + ui->itemNameBox->text()).exists())
|
|
{
|
|
QFile file(sectionGroup->files.at(file_idx));
|
|
file.rename(sectionGroup->files.at(file_idx), sectionGroup->location
|
|
+ QDir::separator() + ui->itemNameBox->text());
|
|
sectionGroup->files.replace(file_idx, sectionGroup->location + QDir::separator()
|
|
+ ui->itemNameBox->text());
|
|
break;
|
|
}
|
|
}
|
|
} else {
|
|
// Section Group
|
|
if(sectionGroup->files.at(file_idx) == notebookItemLocation)
|
|
{
|
|
if(!QDir(sectionGroup->location + QDir::separator() + ui->itemNameBox->text()).exists())
|
|
{
|
|
sectionGroup->files.replace(file_idx, sectionGroup->location + QDir::separator() + ui->itemNameBox->text());
|
|
sectionGroup->sectionGroupArray.at(sg_idx)->name = ui->itemNameBox->text();
|
|
sectionGroup->sectionGroupArray.at(sg_idx)->color = ui->itemColorComboBox->currentText();
|
|
// Rename Directory
|
|
QDir dir(sectionGroup->sectionGroupArray.at(sg_idx)->location);
|
|
dir.rename(sectionGroup->sectionGroupArray.at(sg_idx)->location, sectionGroup->location
|
|
+ QDir::separator() + ui->itemNameBox->text());
|
|
sectionGroup->sectionGroupArray.at(sg_idx)->location = sectionGroup->location + QDir::separator()
|
|
+ ui->itemNameBox->text();
|
|
int file2_idx = 0;
|
|
for(file2_idx = 0; file2_idx < sectionGroup->sectionGroupArray.at(sg_idx)->files.size(); file2_idx++)
|
|
{
|
|
QFileInfo fileInfo(sectionGroup->sectionGroupArray.at(sg_idx)->files.at(file2_idx));
|
|
QFile file(sectionGroup->sectionGroupArray.at(sg_idx)->files.at(file2_idx));
|
|
file.rename(sectionGroup->files.at(file_idx), sectionGroup->location
|
|
+ QDir::separator() + ui->itemNameBox->text());
|
|
sectionGroup->sectionGroupArray.at(sg_idx)->files.replace(file2_idx, sectionGroup->sectionGroupArray.at(sg_idx)->location
|
|
+ QDir::separator() + fileInfo.fileName());
|
|
}
|
|
QFile sectionGroupFile(sectionGroup->sectionGroupArray.at(sg_idx)->location + QDir::separator() + "sectiongroup.sectgr");
|
|
sectionGroupFile.remove();
|
|
if (sectionGroupFile.open(QIODevice::ReadWrite)) {
|
|
QTextStream in(§ionGroupFile);
|
|
in << sectionGroup->sectionGroupArray.at(sg_idx)->name << "\n" << sectionGroup->sectionGroupArray.at(sg_idx)->color << "\n";
|
|
}
|
|
sectionGroupFile.close();
|
|
accept_notebookSearchDirectoryRecursive(sectionGroup->sectionGroupArray.at(sg_idx), notebookFileInfo);
|
|
break;
|
|
} else {
|
|
sectionGroup->sectionGroupArray.at(sg_idx)->name = ui->itemNameBox->text();
|
|
sectionGroup->sectionGroupArray.at(sg_idx)->color = ui->itemColorComboBox->currentText();
|
|
QFile sectionGroupFile(sectionGroup->sectionGroupArray.at(sg_idx)->location + QDir::separator() + "sectiongroup.sectgr");
|
|
sectionGroupFile.remove();
|
|
if (sectionGroupFile.open(QIODevice::ReadWrite)) {
|
|
QTextStream in(§ionGroupFile);
|
|
in << sectionGroup->sectionGroupArray.at(sg_idx)->name << "\n" << sectionGroup->sectionGroupArray.at(sg_idx)->color << "\n";
|
|
}
|
|
sectionGroupFile.close();
|
|
}
|
|
} else {
|
|
accept_sectionGroupSearchDirectoryRecursive(sectionGroup->sectionGroupArray.at(sg_idx), notebookFileInfo);
|
|
}
|
|
sg_idx++;
|
|
}
|
|
}
|
|
}
|
|
|