DrewTechs
3 years ago
5 changed files with 951 additions and 0 deletions
@ -0,0 +1,199 @@ |
|||||
|
#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; |
||||
|
} |
@ -0,0 +1,50 @@ |
|||||
|
#ifndef IMPORTSECTION_H |
||||
|
#define IMPORTSECTION_H |
||||
|
|
||||
|
#include <QDialog> |
||||
|
#include <QFileDialog> |
||||
|
#include <QDir> |
||||
|
|
||||
|
namespace Ui { |
||||
|
class importSection; |
||||
|
} |
||||
|
|
||||
|
class importSection : public QDialog |
||||
|
{ |
||||
|
Q_OBJECT |
||||
|
|
||||
|
public: |
||||
|
explicit importSection(QStringList notebookColorList, QStringList notebookDirList, QStringList list, QWidget *parent = nullptr); |
||||
|
~importSection(); |
||||
|
|
||||
|
void init(); |
||||
|
|
||||
|
QStringList getDirectoryList(); |
||||
|
QStringList getNotebookColorList(); |
||||
|
QStringList getNotebookDirList(); |
||||
|
QString getNewFile(); |
||||
|
|
||||
|
void setDirectoryList(QStringList dirList); |
||||
|
void setNotebookColorList(QStringList newNbColorList); |
||||
|
void setNotebookDirList(QStringList newNbDirList); |
||||
|
void setNewFile(QString newNewFile); |
||||
|
|
||||
|
QIcon SetNotebookIcon(QString notebookColor); |
||||
|
QIcon SetSectionGroupIcon(QString sectionGroupColor); |
||||
|
|
||||
|
private slots: |
||||
|
void on_buttonBox_accepted(); |
||||
|
|
||||
|
void on_buttonBox_rejected(); |
||||
|
|
||||
|
void on_selectDirectoryButton_clicked(); |
||||
|
|
||||
|
private: |
||||
|
QStringList var_directoryList; |
||||
|
QStringList nbColorList; |
||||
|
QStringList nbDirList; |
||||
|
QString newFile; |
||||
|
Ui::importSection *ui; |
||||
|
}; |
||||
|
|
||||
|
#endif // IMPORTSECTION_H
|
@ -0,0 +1,156 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<ui version="4.0"> |
||||
|
<class>importSection</class> |
||||
|
<widget class="QDialog" name="importSection"> |
||||
|
<property name="geometry"> |
||||
|
<rect> |
||||
|
<x>0</x> |
||||
|
<y>0</y> |
||||
|
<width>506</width> |
||||
|
<height>239</height> |
||||
|
</rect> |
||||
|
</property> |
||||
|
<property name="windowTitle"> |
||||
|
<string>Import Section</string> |
||||
|
</property> |
||||
|
<layout class="QVBoxLayout" name="verticalLayout"> |
||||
|
<item> |
||||
|
<widget class="QLabel" name="notebookLabel"> |
||||
|
<property name="font"> |
||||
|
<font> |
||||
|
<pointsize>12</pointsize> |
||||
|
</font> |
||||
|
</property> |
||||
|
<property name="text"> |
||||
|
<string>Select Notebook or Section Group:</string> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item> |
||||
|
<widget class="QComboBox" name="directorySelection"> |
||||
|
<property name="font"> |
||||
|
<font> |
||||
|
<pointsize>12</pointsize> |
||||
|
</font> |
||||
|
</property> |
||||
|
<property name="iconSize"> |
||||
|
<size> |
||||
|
<width>24</width> |
||||
|
<height>24</height> |
||||
|
</size> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item> |
||||
|
<widget class="QLabel" name="notebookLabel_2"> |
||||
|
<property name="font"> |
||||
|
<font> |
||||
|
<pointsize>12</pointsize> |
||||
|
</font> |
||||
|
</property> |
||||
|
<property name="text"> |
||||
|
<string>Import Section/File:</string> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item> |
||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3"> |
||||
|
<item> |
||||
|
<widget class="QLineEdit" name="importSection_Field"> |
||||
|
<property name="font"> |
||||
|
<font> |
||||
|
<pointsize>12</pointsize> |
||||
|
</font> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item> |
||||
|
<widget class="QPushButton" name="selectDirectoryButton"> |
||||
|
<property name="font"> |
||||
|
<font> |
||||
|
<pointsize>10</pointsize> |
||||
|
</font> |
||||
|
</property> |
||||
|
<property name="text"> |
||||
|
<string>Select Directory</string> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
</layout> |
||||
|
</item> |
||||
|
<item> |
||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2"> |
||||
|
<item> |
||||
|
<layout class="QHBoxLayout" name="horizontalLayout"> |
||||
|
<item> |
||||
|
<widget class="QRadioButton" name="moveItemButton"> |
||||
|
<property name="text"> |
||||
|
<string>Move Item</string> |
||||
|
</property> |
||||
|
<property name="checked"> |
||||
|
<bool>false</bool> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
<item> |
||||
|
<widget class="QRadioButton" name="copyItemButton"> |
||||
|
<property name="text"> |
||||
|
<string>Copy Item</string> |
||||
|
</property> |
||||
|
<property name="checked"> |
||||
|
<bool>true</bool> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
</layout> |
||||
|
</item> |
||||
|
<item> |
||||
|
<widget class="QDialogButtonBox" name="buttonBox"> |
||||
|
<property name="orientation"> |
||||
|
<enum>Qt::Horizontal</enum> |
||||
|
</property> |
||||
|
<property name="standardButtons"> |
||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> |
||||
|
</property> |
||||
|
</widget> |
||||
|
</item> |
||||
|
</layout> |
||||
|
</item> |
||||
|
</layout> |
||||
|
</widget> |
||||
|
<resources/> |
||||
|
<connections> |
||||
|
<connection> |
||||
|
<sender>buttonBox</sender> |
||||
|
<signal>accepted()</signal> |
||||
|
<receiver>importSection</receiver> |
||||
|
<slot>accept()</slot> |
||||
|
<hints> |
||||
|
<hint type="sourcelabel"> |
||||
|
<x>248</x> |
||||
|
<y>254</y> |
||||
|
</hint> |
||||
|
<hint type="destinationlabel"> |
||||
|
<x>157</x> |
||||
|
<y>274</y> |
||||
|
</hint> |
||||
|
</hints> |
||||
|
</connection> |
||||
|
<connection> |
||||
|
<sender>buttonBox</sender> |
||||
|
<signal>rejected()</signal> |
||||
|
<receiver>importSection</receiver> |
||||
|
<slot>reject()</slot> |
||||
|
<hints> |
||||
|
<hint type="sourcelabel"> |
||||
|
<x>316</x> |
||||
|
<y>260</y> |
||||
|
</hint> |
||||
|
<hint type="destinationlabel"> |
||||
|
<x>286</x> |
||||
|
<y>274</y> |
||||
|
</hint> |
||||
|
</hints> |
||||
|
</connection> |
||||
|
</connections> |
||||
|
</ui> |
@ -0,0 +1,501 @@ |
|||||
|
#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++; |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,45 @@ |
|||||
|
#ifndef ITEMPROPERTIES_H |
||||
|
#define ITEMPROPERTIES_H |
||||
|
|
||||
|
#include <QDialog> |
||||
|
#include "notebook.h" |
||||
|
#include "notebooklist.h" |
||||
|
#include "notebookmanager.h" |
||||
|
|
||||
|
namespace Ui { |
||||
|
class itemProperties; |
||||
|
} |
||||
|
|
||||
|
class itemProperties : public QDialog |
||||
|
{ |
||||
|
Q_OBJECT |
||||
|
|
||||
|
public: |
||||
|
itemProperties(NotebookList* nbList, QString notebookItemLocation, QWidget *parent = nullptr); |
||||
|
~itemProperties(); |
||||
|
|
||||
|
void init(); |
||||
|
void setIconsToItemColorComboBox_Notebook(); |
||||
|
void setIconsToItemColorComboBox_SectionGroup(); |
||||
|
QIcon SetNotebookIcon(QString notebookColor); |
||||
|
QIcon SetSectionGroupIcon(QString sectionGroupColor); |
||||
|
void init_searchDirectoryRecursive(SectionGroup* sectionGroup); |
||||
|
void accept_notebookSearchDirectoryRecursive(SectionGroup* sectionGroup, QFileInfo notebookFileInfo); |
||||
|
void accept_sectionGroupSearchDirectoryRecursive(SectionGroup* sectionGroup, QFileInfo notebookFileInfo); |
||||
|
|
||||
|
NotebookList* getNotebookList(); |
||||
|
QString getNotebookItemLocation(); |
||||
|
void setNotebookList(NotebookList* newNotebookList); |
||||
|
void setNotebookItemLocation(QString newNotebookItemLocation); |
||||
|
|
||||
|
private slots: |
||||
|
void on_buttonBox_accepted(); |
||||
|
void on_buttonBox_rejected(); |
||||
|
|
||||
|
private: |
||||
|
Ui::itemProperties *ui; |
||||
|
NotebookList* notebookList; |
||||
|
QString notebookItemLocation; |
||||
|
}; |
||||
|
|
||||
|
#endif // ITEMPROPERTIES_H
|
Loading…
Reference in new issue