diff --git a/FileNameRetrieval.cpp b/FileNameRetrieval.cpp new file mode 100644 index 0000000..a3e4042 --- /dev/null +++ b/FileNameRetrieval.cpp @@ -0,0 +1,19 @@ +#include +#include"boost/filesystem.hpp" +#include"FileNameRetrieval.h" +#include"FolderStructure.h" + +FileNameRetrieval::FileNameRetrieval() { } + +std::vector FileNameRetrieval::fileNameContainer() const { return fileNames; } +void FileNameRetrieval::retrieveFileNames() +{ + boost::filesystem::path directory(FolderStructure::keyDirectory); + boost::filesystem::directory_iterator beg(directory), end; + + for (; beg!=end; ++beg) + if (beg->path().extension()==".txt") + fileNames.push_back(beg->path().filename().string()); + for (auto fl: fileNames) + std::cout<< fl< +#include + +class FileNameRetrieval +{ +public: + FileNameRetrieval(); + + void retrieveFileNames(); + std::vector fileNameContainer() const; +private: + std::vector fileNames; +}; +#endif diff --git a/KeyManagementWindow.cpp b/KeyManagementWindow.cpp index a5d0a60..7bb774a 100644 --- a/KeyManagementWindow.cpp +++ b/KeyManagementWindow.cpp @@ -1,15 +1,21 @@ #include #include +#include +#include +#include #include #include #include #include #include +#include"boost/filesystem.hpp" #include"KeyManagementWindow.h" #include"Encryption.h" #include"GenerateKeys.h" #include"KeyRetrieval.h" #include"Conversions.h" +#include"FileNameRetrieval.h" +#include"FolderStructure.h" KeyManagementWindow::KeyManagementWindow(QWidget* parent) : QDialog(parent) { @@ -20,22 +26,62 @@ KeyManagementWindow::KeyManagementWindow(QWidget* parent) : QDialog(parent) void KeyManagementWindow::setContentsOfComboBox() { - KeyRetrieval kr{}; - std::vector c{kr.codeCharacterStructure()}; + selectionBox.get()->clear(); + FileNameRetrieval fnr; + fnr.retrieveFileNames(); + std::vector fn{fnr.fileNameContainer()}; - for (auto index = 0u; index!=c.size(); ++index) + for (auto fle: fn) { - std::string ch{static_cast(c[index])}; - QString bl = QString::fromStdString(ch); + QString bl{QString::fromStdString(fle)}; selectionBox.get()->addItem(bl); } } +void KeyManagementWindow::setContentOfKeyView() +{ + QString testQ; + testQ.append(selectionBox.get()->currentText()); + std::string testS{FolderStructure::keyDirectory+testQ.toStdString()}; + + KeyRetrieval kr{testS}; + std::vector asciiKeys{kr.codeCharacterStructure()}; + std::vector asciiAssignment{kr.keyStructure()}; + + auto asciiKeysIter = asciiKeys.begin(); + auto asciiAssignmentIter = asciiAssignment.begin(); + for (auto row=0; row!=rowCount; ++row) + { + for (auto column=0; column!=columnCount; ++column) + { + if (column==0) + { + std::string val{*asciiKeysIter++}; + QString s{val.c_str()}; + elementView.get()->setItem(row, column, new QTableWidgetItem(s)); + } + else + { + std::string val{*asciiAssignmentIter++}; + QString s{val.c_str()}; + elementView.get()->setItem(row, column, new QTableWidgetItem(s)); + } + } + } +} void KeyManagementWindow::setupWindow() { windowWidth = 450; windowHeight = 450; + rowCount = 96; + columnCount = 2; - elementView = unique_ptr{new QTableView}; + elementView = unique_ptr{new QTableWidget}; + + elementView.get()->setRowCount(rowCount); + elementView.get()->setColumnCount(columnCount); + tableHeader<<"character"<<"key"; + elementView.get()->setHorizontalHeaderLabels(tableHeader); + elementView.get()->verticalHeader()->setVisible(false); selectionBox = unique_ptr{new QComboBox{}}; @@ -76,9 +122,9 @@ void KeyManagementWindow::setupWindow() } void KeyManagementWindow::connections() { - QObject::connect(selectionBox.get(), SIGNAL(currentIndexChanged(int)), SLOT(test())); QObject::connect(generateNewKeys.get(), SIGNAL(clicked()), this, SLOT(generation())); QObject::connect(closeButton.get(), SIGNAL(clicked()), this, SLOT(exitApplication())); + QObject::connect(actionButton.get(), SIGNAL(clicked()), this, SLOT(setContentOfKeyView())); } void KeyManagementWindow::test() { @@ -95,12 +141,12 @@ void KeyManagementWindow::test() std::string value{encrypted[f]}; QString v{QString::fromStdString(value)}; - //valueOfKey.get()->setText(v); } void KeyManagementWindow::generation() { GenerateKeys gk{}; gk.keyMove(); gk.keyDump(); + setContentsOfComboBox(); } void KeyManagementWindow::exitApplication() { this->hide(); } diff --git a/KeyManagementWindow.h b/KeyManagementWindow.h index cf8c639..908b274 100644 --- a/KeyManagementWindow.h +++ b/KeyManagementWindow.h @@ -2,6 +2,7 @@ #define KEYMANAGEMENTWINDOW_H #include +#include #include #include"CommonWindow.h" #include"ViewingWindow.h" @@ -16,9 +17,11 @@ private slots: void test(); void generation(); void exitApplication(); + void setContentOfKeyView(); private: void setContentsOfComboBox(); void setupWindow(); void connections(); + unique_ptr qSB; }; #endif diff --git a/KeyRetrieval.cpp b/KeyRetrieval.cpp index 4c54f18..a66aba6 100644 --- a/KeyRetrieval.cpp +++ b/KeyRetrieval.cpp @@ -8,6 +8,12 @@ KeyRetrieval::KeyRetrieval() retrieveKey(); addToList(); } +KeyRetrieval::KeyRetrieval(const std::string fileName) +{ + this->fileName.assign(fileName); + retrieveKey(); + addToList(); +} void KeyRetrieval::retrieveKey() { @@ -20,6 +26,7 @@ void KeyRetrieval::retrieveKey() if (keyChar[0]!='\0') keys.push_back(keyChar); } + readKeys.close(); } void KeyRetrieval::addToList() { @@ -39,6 +46,7 @@ void KeyRetrieval::addRange(int from, const int to) for (; from<=to; ++from) codeCharacter.push_back(from); } +void KeyRetrieval::fileNameChoice(const std::string& fileName) { this->fileName.assign(fileName); } std::vector KeyRetrieval::keyStructure() { return keys; } std::vector KeyRetrieval::codeCharacterStructure() { return codeCharacter; } diff --git a/KeyRetrieval.h b/KeyRetrieval.h index cfee765..45ce679 100644 --- a/KeyRetrieval.h +++ b/KeyRetrieval.h @@ -9,11 +9,13 @@ class KeyRetrieval { public: KeyRetrieval(); + KeyRetrieval(const std::string); ~KeyRetrieval() = default; void retrieveKey(); void addToList(); void addRange(int, const int); + void fileNameChoice(const std::string&); std::vector keyStructure(); std::vector codeCharacterStructure(); diff --git a/MainWindow.cpp b/MainWindow.cpp index 318e987..bcad0eb 100644 --- a/MainWindow.cpp +++ b/MainWindow.cpp @@ -73,11 +73,14 @@ void MainWindow::connections() void MainWindow::changeCryptionType() { + /** (cryptionChoice) ? cryptionSwitch->setText("decrypt chosen") : cryptionSwitch->setText("encrypt chosen"); cryptionChoice = (cryptionChoice) ? false : true; + */ } void MainWindow::determineCryption() { + /** if (cryptionChoice) { Encryption ec{grabCryptionText()}; @@ -98,6 +101,7 @@ void MainWindow::determineCryption() cryptionSwitch.get()->setText("encrypt chosen"); cryptionChoice = true; } + */ } void MainWindow::keyManagementWindow() { kh.get()->show(); } void MainWindow::passwordManageWindow() { ph.get()->show(); } diff --git a/MainWindow.h b/MainWindow.h index 22c4283..51ba603 100644 --- a/MainWindow.h +++ b/MainWindow.h @@ -49,9 +49,6 @@ private: unique_ptr textForCryption; - unique_ptr cryptionButon; - unique_ptr cryptionSwitch; - unique_ptr fileMenu; unique_ptr editMenu; unique_ptr closeApplication; diff --git a/PasswordManagementWindow.cpp b/PasswordManagementWindow.cpp index b83447f..46eea09 100644 --- a/PasswordManagementWindow.cpp +++ b/PasswordManagementWindow.cpp @@ -10,7 +10,7 @@ void PasswordManagementWindow::setupWindow() windowWidth=450; windowHeight=450; - elementView=unique_ptr{new QTableView}; + elementView=unique_ptr{new QTableWidget}; selectionBox=unique_ptr{new QComboBox}; actionButton=unique_ptr{new QPushButton{"i3"}}; diff --git a/ViewingWindow.h b/ViewingWindow.h index 9c98f8d..2fcda6f 100644 --- a/ViewingWindow.h +++ b/ViewingWindow.h @@ -2,7 +2,8 @@ #define VIEWINGWINDOW_H_ #include -#include +#include +#include #include #include #include @@ -18,8 +19,10 @@ protected: unique_ptr subLayoutGoonOne; unique_ptr subLayoutGoonTwo; unique_ptr crypticText; - unique_ptr elementView; + unique_ptr elementView; unique_ptr closeButton; unique_ptr generateNewKeys; + QStringList tableHeader; + int rowCount, columnCount; }; #endif