Skip to content

Commit

Permalink
Keywords can now be edited with double click.
Browse files Browse the repository at this point in the history
  • Loading branch information
mengu committed Apr 21, 2010
1 parent b9b3ede commit 4510438
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 39 deletions.
Binary file modified DesktopOrganizer
Binary file not shown.
10 changes: 7 additions & 3 deletions moc_organizer.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
** Meta object code from reading C++ file 'organizer.h'
**
** Created: Wed Apr 21 07:34:21 2010
** Created: Wed Apr 21 10:34:12 2010
** by: The Qt Meta Object Compiler version 61 (Qt 4.5.2)
**
** WARNING! All changes made in this file will be lost!
Expand All @@ -23,7 +23,7 @@ static const uint qt_meta_data_Organizer[] = {
2, // revision
0, // classname
0, 0, // classinfo
11, 12, // methods
12, 12, // methods
0, 0, // properties
0, 0, // enums/sets
0, 0, // constructors
Expand All @@ -40,6 +40,7 @@ static const uint qt_meta_data_Organizer[] = {
278, 10, 10, 10, 0x0a,
299, 10, 10, 10, 0x0a,
320, 312, 10, 10, 0x0a,
361, 341, 10, 10, 0x0a,

0 // eod
};
Expand All @@ -55,6 +56,8 @@ static const char qt_meta_stringdata_Organizer[] = {
"openSelectedFile()\0moveSelectedFile()\0"
"deleteSelectedFile()\0newKeyword()\0"
"checked\0showFileDialog(bool)\0"
"selectedItem,column\0"
"editKeyword(QTreeWidgetItem*,int)\0"
};

const QMetaObject Organizer::staticMetaObject = {
Expand Down Expand Up @@ -93,9 +96,10 @@ int Organizer::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
case 8: deleteSelectedFile(); break;
case 9: newKeyword(); break;
case 10: showFileDialog((*reinterpret_cast< bool(*)>(_a[1]))); break;
case 11: editKeyword((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
default: ;
}
_id -= 11;
_id -= 12;
}
return _id;
}
Expand Down
66 changes: 37 additions & 29 deletions organizer.cpp
Expand Up @@ -7,6 +7,7 @@ Organizer::Organizer(QWidget *parent)
this->filetypes["pdf"] = "evince";
this->filetypes["chm"] = "chmsee";
this->filetypes["ogg"] = "totem";
this->filetypes["ogv"] = "totem";
this->filetypes["mpg"] = "totem";
this->filetypes["mp4"] = "totem";
this->filetypes["mov"] = "totem";
Expand Down Expand Up @@ -56,9 +57,8 @@ void Organizer::startSearch(QTreeWidgetItem* clickedItem, int isDoubleClick)
else
{
ui->fileListTree->clear();
//this->removeCurrentFiles();
this->keywords.clear();
this->getAllKeywords();
qDebug("%s", qPrintable(clickedItem->text(1)));
QStringList selectedFileTypes = clickedItem->text(1).split(", ", QString::SkipEmptyParts);
this->searchPath(ui->pathEdit->text(), selectedFileTypes);
}
Expand Down Expand Up @@ -99,10 +99,7 @@ void Organizer::searchPath(QString path, QStringList selectedFileTypes)
{
if (fileInfo.fileName().toLower().indexOf(this->keywords[i].toLower()) != -1)
{
if (selectedFileTypes.contains(fileInfo.completeSuffix()) || selectedFileTypes.contains(fileInfo.suffix()))
{
this->addNewFileToFilesTree(fileInfo);
}
this->addNewFileToFilesTree(fileInfo);
}
}
}
Expand Down Expand Up @@ -179,36 +176,42 @@ void Organizer::showFilesTreeMenu(QPoint menuPoint)

void Organizer::openSelectedFile()
{
QTreeWidgetItem* selectedFileItem = ui->fileListTree->selectedItems()[0];
QFileInfo fileInfo(selectedFileItem->text(1));
QString fileSuffix = fileInfo.completeSuffix();
if (fileSuffix.count(".") > 1)
{
fileSuffix = fileInfo.suffix();
}
if (this->filetypes.contains(fileSuffix))
for (int i = 0; i < ui->fileListTree->selectedItems().length(); i++)
{
QStringList execArgs;
execArgs << fileInfo.absoluteFilePath();
QProcess::execute(this->filetypes.value(fileSuffix), execArgs);
qDebug("%s %s", qPrintable(this->filetypes.value(fileSuffix)), qPrintable(fileInfo.absoluteFilePath()));
QTreeWidgetItem* selectedFileItem = ui->fileListTree->selectedItems().at(i);
QFileInfo fileInfo(selectedFileItem->text(1));
QString fileSuffix = fileInfo.completeSuffix();
if (fileSuffix.count(".") > 1)
{
fileSuffix = fileInfo.suffix();
}
if (this->filetypes.contains(fileSuffix))
{
QStringList execArgs;
execArgs << fileInfo.absoluteFilePath();
QProcess::execute(this->filetypes.value(fileSuffix), execArgs);
qDebug("%s %s", qPrintable(this->filetypes.value(fileSuffix)), qPrintable(fileInfo.absoluteFilePath()));
}
}
}

void Organizer::moveSelectedFile()
{
QTreeWidgetItem* selectedFileItem = ui->fileListTree->selectedItems()[0];
QFileInfo fileInfo(selectedFileItem->text(1));
QFileDialog fileDialog(this);
fileDialog.setFileMode(QFileDialog::AnyFile);
fileDialog.setDirectory(fileInfo.absoluteDir());
fileDialog.setFileMode(QFileDialog::Directory);
QDir selectedDir;
if (fileDialog.exec())
for (int i = 0; i < ui->fileListTree->selectedItems().length(); i++)
{
selectedDir = fileDialog.directory();
qDebug("%s", qPrintable(selectedDir.dirName()));
selectedDir.rename(fileInfo.absoluteFilePath(), selectedDir.absolutePath()+"/"+fileInfo.fileName());
QTreeWidgetItem* selectedFileItem = ui->fileListTree->selectedItems().at(i);
QFileInfo fileInfo(selectedFileItem->text(1));
QFileDialog fileDialog(this);
fileDialog.setFileMode(QFileDialog::AnyFile);
fileDialog.setDirectory(fileInfo.absoluteDir());
fileDialog.setFileMode(QFileDialog::Directory);
QDir selectedDir;
if (fileDialog.exec())
{
selectedDir = fileDialog.directory();
qDebug("%s", qPrintable(selectedDir.dirName()));
selectedDir.rename(fileInfo.absoluteFilePath(), selectedDir.absolutePath()+"/"+fileInfo.fileName());
}
}
}

Expand All @@ -233,6 +236,11 @@ void Organizer::deleteSelectedFile()
}
}

void Organizer::editKeyword(QTreeWidgetItem* selectedItem, int column)
{
ui->keywordsTree->editItem(selectedItem, column);
}

void Organizer::deleteKeyword()
{
QTreeWidgetItem* selectedKeyword = ui->keywordsTree->selectedItems()[0];
Expand Down
1 change: 1 addition & 0 deletions organizer.h
Expand Up @@ -40,6 +40,7 @@ public slots:
void deleteSelectedFile();
void newKeyword();
void showFileDialog(bool checked);
void editKeyword(QTreeWidgetItem* selectedItem, int column);

private:
Ui::Organizer *ui;
Expand Down
30 changes: 26 additions & 4 deletions organizer.ui
Expand Up @@ -46,7 +46,7 @@
<string>Videos</string>
</property>
<property name="text">
<string>*.ogg, *.mpg, *.mp4, *.mov, *.avi</string>
<string>*.ogg, *.ogv, *.mpg, *.mp4, *.mov, *.avi</string>
</property>
</item>
<item>
Expand Down Expand Up @@ -113,12 +113,18 @@
<x>220</x>
<y>0</y>
<width>961</width>
<height>861</height>
<height>881</height>
</rect>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::MultiSelection</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<attribute name="headerShowSortIndicator" stdset="0">
<bool>true</bool>
</attribute>
Expand Down Expand Up @@ -298,22 +304,38 @@
<hints>
<hint type="sourcelabel">
<x>28</x>
<y>68</y>
<y>58</y>
</hint>
<hint type="destinationlabel">
<x>16</x>
<y>104</y>
</hint>
</hints>
</connection>
<connection>
<sender>keywordsTree</sender>
<signal>itemDoubleClicked(QTreeWidgetItem*,int)</signal>
<receiver>Organizer</receiver>
<slot>editKeyword(QTreeWidgetItem*,int)</slot>
<hints>
<hint type="sourcelabel">
<x>202</x>
<y>722</y>
</hint>
<hint type="destinationlabel">
<x>215</x>
<y>721</y>
</hint>
</hints>
</connection>
</connections>
<slots>
<slot>addNewKeyword()</slot>
<slot>startSearch(QTreeWidgetItem*,int)</slot>
<slot>openFileOrDirectory(QTreeWidgetItem*,int)</slot>
<slot>showKeywordsTreeMenu(QPoint)</slot>
<slot>keywordEdited(QTreeWidgetItem*,int)</slot>
<slot>showFilesTreeMenu(QPoint)</slot>
<slot>showFileDialog(bool)</slot>
<slot>editKeyword(QTreeWidgetItem*,int)</slot>
</slots>
</ui>
9 changes: 6 additions & 3 deletions ui_organizer.h
@@ -1,7 +1,7 @@
/********************************************************************************
** Form generated from reading ui file 'organizer.ui'
**
** Created: Wed Apr 21 07:35:16 2010
** Created: Wed Apr 21 10:34:09 2010
** by: Qt User Interface Compiler version 4.5.2
**
** WARNING! All changes made in this file will be lost when recompiling ui file!
Expand Down Expand Up @@ -76,8 +76,10 @@ class Ui_Organizer
keywordsTree->setEditTriggers(QAbstractItemView::EditKeyPressed);
fileListTree = new QTreeWidget(centralWidget);
fileListTree->setObjectName(QString::fromUtf8("fileListTree"));
fileListTree->setGeometry(QRect(220, 0, 961, 861));
fileListTree->setGeometry(QRect(220, 0, 961, 881));
fileListTree->setContextMenuPolicy(Qt::CustomContextMenu);
fileListTree->setSelectionMode(QAbstractItemView::MultiSelection);
fileListTree->setSortingEnabled(true);
fileListTree->header()->setProperty("showSortIndicator", QVariant(true));
pushButton = new QPushButton(centralWidget);
pushButton->setObjectName(QString::fromUtf8("pushButton"));
Expand Down Expand Up @@ -111,6 +113,7 @@ class Ui_Organizer
QObject::connect(actionClose, SIGNAL(triggered()), Organizer, SLOT(close()));
QObject::connect(fileListTree, SIGNAL(customContextMenuRequested(QPoint)), Organizer, SLOT(showFilesTreeMenu(QPoint)));
QObject::connect(pushButton, SIGNAL(clicked(bool)), Organizer, SLOT(showFileDialog(bool)));
QObject::connect(keywordsTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), Organizer, SLOT(editKeyword(QTreeWidgetItem*,int)));

QMetaObject::connectSlotsByName(Organizer);
} // setupUi
Expand All @@ -130,7 +133,7 @@ class Ui_Organizer
___qtreewidgetitem1->setText(1, QApplication::translate("Organizer", "*.pdf, *.chm", 0, QApplication::UnicodeUTF8));
___qtreewidgetitem1->setText(0, QApplication::translate("Organizer", "Books", 0, QApplication::UnicodeUTF8));
QTreeWidgetItem *___qtreewidgetitem2 = fileTypesTree->topLevelItem(1);
___qtreewidgetitem2->setText(1, QApplication::translate("Organizer", "*.ogg, *.mpg, *.mp4, *.mov, *.avi", 0, QApplication::UnicodeUTF8));
___qtreewidgetitem2->setText(1, QApplication::translate("Organizer", "*.ogg, *.ogv, *.mpg, *.mp4, *.mov, *.avi", 0, QApplication::UnicodeUTF8));
___qtreewidgetitem2->setText(0, QApplication::translate("Organizer", "Videos", 0, QApplication::UnicodeUTF8));
QTreeWidgetItem *___qtreewidgetitem3 = fileTypesTree->topLevelItem(2);
___qtreewidgetitem3->setText(1, QApplication::translate("Organizer", "*.doc, *.odt, *.txt", 0, QApplication::UnicodeUTF8));
Expand Down

0 comments on commit 4510438

Please sign in to comment.