forked from sqlitebrowser/sqlitebrowser
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
345 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
#include "FileExtensionManager.h" | ||
#include "ui_FileExtensionManager.h" | ||
|
||
FileExtensionManager::FileExtensionManager(QStringList init, QWidget *parent) : | ||
QDialog(parent), | ||
ui(new Ui::FileExtensionManager) | ||
{ | ||
ui->setupUi(this); | ||
|
||
int i = 0; | ||
foreach(QString itemString, init) | ||
{ | ||
QString description = itemString.left(itemString.indexOf('(')).trimmed(); | ||
QString extension = itemString; | ||
extension = extension.remove (0, itemString.indexOf('(')+1).remove(')').simplified().trimmed(); | ||
if ( extension.compare("*") != 0 ) //We exclude "All files" from the table | ||
{ | ||
QTableWidgetItem *newItemDescription = new QTableWidgetItem(description); | ||
QTableWidgetItem *newItemExtension = new QTableWidgetItem(extension); | ||
ui->tableExtensions->insertRow(i); | ||
ui->tableExtensions->setItem(i, 0, newItemDescription); | ||
ui->tableExtensions->setItem(i, 1, newItemExtension); | ||
i++; | ||
} | ||
} | ||
|
||
connect(ui->buttonAdd, SIGNAL(clicked(bool)), this, SLOT(addItem())); | ||
connect(ui->buttonRemove, SIGNAL(clicked(bool)), this, SLOT(removeItem())); | ||
|
||
connect(ui->buttonDown, SIGNAL(clicked(bool)), this, SLOT(downItem())); | ||
connect(ui->buttonUp, SIGNAL(clicked(bool)), this, SLOT(upItem())); | ||
} | ||
|
||
FileExtensionManager::~FileExtensionManager() | ||
{ | ||
delete ui; | ||
} | ||
|
||
void FileExtensionManager::addItem() | ||
{ | ||
int i = ui->tableExtensions->rowCount(); | ||
ui->tableExtensions->insertRow(i); | ||
QTableWidgetItem *newItemDescription = new QTableWidgetItem(tr("Description")); | ||
QTableWidgetItem *newItemExtension = new QTableWidgetItem(tr("*.extension")); | ||
ui->tableExtensions->setItem(i, 0, newItemDescription); | ||
ui->tableExtensions->setItem(i, 1, newItemExtension); | ||
} | ||
|
||
void FileExtensionManager::removeItem() | ||
{ | ||
QList<int> selectedRows; | ||
foreach (QTableWidgetItem *item, ui->tableExtensions->selectedItems()) | ||
{ | ||
if (selectedRows.contains(item->row()) == false) | ||
{ | ||
selectedRows.append(item->row()); | ||
} | ||
} | ||
|
||
qSort(selectedRows); | ||
|
||
for (int i = selectedRows.size()-1; i >= 0; --i) | ||
{ | ||
ui->tableExtensions->removeRow(selectedRows[i]); | ||
} | ||
} | ||
|
||
void FileExtensionManager::upItem() | ||
{ | ||
if (ui->tableExtensions->selectedItems().isEmpty()) return; | ||
|
||
int selectedRow = ui->tableExtensions->selectedItems().first()->row(); | ||
if(selectedRow == 0) | ||
return; | ||
|
||
QTableWidgetItem *t1, *t2; | ||
t1 = ui->tableExtensions->takeItem(selectedRow, 0); | ||
t2 = ui->tableExtensions->takeItem(selectedRow, 1); | ||
ui->tableExtensions->removeRow(selectedRow); | ||
ui->tableExtensions->insertRow(selectedRow-1); | ||
ui->tableExtensions->setItem(selectedRow-1, 0, t1); | ||
ui->tableExtensions->setItem(selectedRow-1, 1, t2); | ||
ui->tableExtensions->selectRow(selectedRow-1); | ||
} | ||
|
||
void FileExtensionManager::downItem() | ||
{ | ||
if (ui->tableExtensions->selectedItems().isEmpty()) return; | ||
|
||
int selectedRow = ui->tableExtensions->selectedItems().first()->row(); | ||
if(selectedRow == ui->tableExtensions->rowCount() - 1) | ||
return; | ||
|
||
QTableWidgetItem *t1, *t2; | ||
t1 = ui->tableExtensions->takeItem(selectedRow, 0); | ||
t2 = ui->tableExtensions->takeItem(selectedRow, 1); | ||
ui->tableExtensions->removeRow(selectedRow); | ||
ui->tableExtensions->insertRow(selectedRow+1); | ||
ui->tableExtensions->setItem(selectedRow+1, 0, t1); | ||
ui->tableExtensions->setItem(selectedRow+1, 1, t2); | ||
ui->tableExtensions->selectRow(selectedRow+1); | ||
} | ||
|
||
QStringList FileExtensionManager::getDBFileExtensions() | ||
{ | ||
QStringList result; | ||
for (int i = 0; i < ui->tableExtensions->rowCount(); ++i) | ||
{ | ||
result.append(QString("%1 (%2)").arg(ui->tableExtensions->item(i, 0)->text()).arg(ui->tableExtensions->item(i, 1)->text())); | ||
} | ||
return result; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#ifndef FILEEXTENSIONMANAGER_H | ||
#define FILEEXTENSIONMANAGER_H | ||
|
||
#include <QDialog> | ||
|
||
namespace Ui { | ||
class FileExtensionManager; | ||
} | ||
|
||
class FileExtensionManager : public QDialog | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit FileExtensionManager(QStringList init, QWidget *parent = nullptr); | ||
~FileExtensionManager(); | ||
|
||
QStringList getDBFileExtensions(); | ||
|
||
private: | ||
Ui::FileExtensionManager *ui; | ||
|
||
public slots: | ||
void addItem(); | ||
void removeItem(); | ||
void upItem(); | ||
void downItem(); | ||
}; | ||
|
||
#endif // FILEEXTENSIONMANAGER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>FileExtensionManager</class> | ||
<widget class="QDialog" name="FileExtensionManager"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>578</width> | ||
<height>463</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Dialog</string> | ||
</property> | ||
<layout class="QVBoxLayout" name="verticalLayout"> | ||
<item> | ||
<layout class="QHBoxLayout" name="horizontalLayout"> | ||
<item> | ||
<widget class="QPushButton" name="buttonUp"> | ||
<property name="text"> | ||
<string>&Up</string> | ||
</property> | ||
<property name="icon"> | ||
<iconset resource="icons/icons.qrc"> | ||
<normaloff>:/icons/up</normaloff>:/icons/up</iconset> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QPushButton" name="buttonDown"> | ||
<property name="text"> | ||
<string>&Down</string> | ||
</property> | ||
<property name="icon"> | ||
<iconset resource="icons/icons.qrc"> | ||
<normaloff>:/icons/down</normaloff>:/icons/down</iconset> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<spacer name="horizontalSpacer"> | ||
<property name="orientation"> | ||
<enum>Qt::Horizontal</enum> | ||
</property> | ||
<property name="sizeHint" stdset="0"> | ||
<size> | ||
<width>40</width> | ||
<height>20</height> | ||
</size> | ||
</property> | ||
</spacer> | ||
</item> | ||
<item> | ||
<widget class="QPushButton" name="buttonAdd"> | ||
<property name="text"> | ||
<string>&Add</string> | ||
</property> | ||
<property name="icon"> | ||
<iconset resource="icons/icons.qrc"> | ||
<normaloff>:/icons/field_add</normaloff>:/icons/field_add</iconset> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QPushButton" name="buttonRemove"> | ||
<property name="text"> | ||
<string>&Remove</string> | ||
</property> | ||
<property name="icon"> | ||
<iconset resource="icons/icons.qrc"> | ||
<normaloff>:/icons/field_delete</normaloff>:/icons/field_delete</iconset> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</item> | ||
<item> | ||
<widget class="QTableWidget" name="tableExtensions"> | ||
<property name="sizeAdjustPolicy"> | ||
<enum>QAbstractScrollArea::AdjustToContents</enum> | ||
</property> | ||
<attribute name="horizontalHeaderStretchLastSection"> | ||
<bool>true</bool> | ||
</attribute> | ||
<attribute name="verticalHeaderDefaultSectionSize"> | ||
<number>100</number> | ||
</attribute> | ||
<attribute name="verticalHeaderMinimumSectionSize"> | ||
<number>100</number> | ||
</attribute> | ||
<column> | ||
<property name="text"> | ||
<string>Description</string> | ||
</property> | ||
</column> | ||
<column> | ||
<property name="text"> | ||
<string>Extensions</string> | ||
</property> | ||
</column> | ||
</widget> | ||
</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> | ||
</widget> | ||
<resources> | ||
<include location="icons/icons.qrc"/> | ||
</resources> | ||
<connections> | ||
<connection> | ||
<sender>buttonBox</sender> | ||
<signal>accepted()</signal> | ||
<receiver>FileExtensionManager</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>FileExtensionManager</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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.