From 57f4d38841c40cad3c206abdd16eebaed753aa1c Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Sun, 18 Mar 2018 18:18:57 +0100 Subject: Update all fiels to adhere to style-guide --- src/filelist.cc | 176 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 95 insertions(+), 81 deletions(-) (limited to 'src/filelist.cc') diff --git a/src/filelist.cc b/src/filelist.cc index c4e5c4b..6cad785 100644 --- a/src/filelist.cc +++ b/src/filelist.cc @@ -34,153 +34,167 @@ FileList::FileList() { - setContextMenuPolicy(Qt::CustomContextMenu); + setContextMenuPolicy(Qt::CustomContextMenu); - connect(this, SIGNAL(customContextMenuRequested(const QPoint &)), - this, SLOT(popupMenu(const QPoint &))); + connect(this, SIGNAL(customContextMenuRequested(const QPoint&)), + this, SLOT(popupMenu(const QPoint&))); - connect(this, SIGNAL(itemDoubleClicked(QListWidgetItem *)), - this, SLOT(selectionChanged(QListWidgetItem *))); + connect(this, SIGNAL(itemDoubleClicked(QListWidgetItem*)), + this, SLOT(selectionChanged(QListWidgetItem*))); - createMenus(); + createMenus(); } void FileList::addFiles() { - QStringList files = QFileDialog::getOpenFileNames(this, tr("Open file"), - path, tr("Audio Files (*.wav)")); - QStringList::Iterator i = files.begin(); - while(i != files.end()) { - QString file = *i; - QFileInfo fi(file); - QString name = fi.baseName(); - path = fi.absolutePath(); - - QListWidgetItem *item = new QListWidgetItem(); - setItemFile(item, file); - setItemName(item, name); - setItemMaster(item, false); - addItem(item); - - emit fileAdded(file, name); - - i++; - } + QStringList files = QFileDialog::getOpenFileNames(this, tr("Open file"), + path, tr("Audio Files (*.wav)")); + QStringList::Iterator i = files.begin(); + while(i != files.end()) + { + QString file = *i; + QFileInfo fi(file); + QString name = fi.baseName(); + path = fi.absolutePath(); + + QListWidgetItem* item = new QListWidgetItem(); + setItemFile(item, file); + setItemName(item, name); + setItemMaster(item, false); + addItem(item); + + emit fileAdded(file, name); + + i++; + } } -void FileList::setMasterFile(QListWidgetItem *i) +void FileList::setMasterFile(QListWidgetItem* i) { - QString filename = itemFile(i); + QString filename = itemFile(i); - for(int idx = 0; idx < count(); idx++) { - setItemMaster(item(idx), false); - } + for(int idx = 0; idx < count(); idx++) + { + setItemMaster(item(idx), false); + } - setItemMaster(i, true); - emit masterFileChanged(filename); + setItemMaster(i, true); + emit masterFileChanged(filename); } -void FileList::selectionChanged(QListWidgetItem *i) +void FileList::selectionChanged(QListWidgetItem* i) { - setMasterFile(i); + setMasterFile(i); } void FileList::createMenus() { - menu = new QMenu(); + menu = new QMenu(); - setMasterAction = new QAction("Set as Master (dbl-click)", this); - connect(setMasterAction, SIGNAL(triggered()), this, SLOT(setMaster())); + setMasterAction = new QAction("Set as Master (dbl-click)", this); + connect(setMasterAction, SIGNAL(triggered()), this, SLOT(setMaster())); - editAction = new QAction("Edit name", this); - connect(editAction, SIGNAL(triggered()), this, SLOT(editName())); + editAction = new QAction("Edit name", this); + connect(editAction, SIGNAL(triggered()), this, SLOT(editName())); - removeAction = new QAction("Remove", this); - connect(removeAction, SIGNAL(triggered()), this, SLOT(removeFile())); + removeAction = new QAction("Remove", this); + connect(removeAction, SIGNAL(triggered()), this, SLOT(removeFile())); - removeAllAction = new QAction("Remove all", this); - connect(removeAllAction, SIGNAL(triggered()), this, SLOT(removeAllFiles())); + removeAllAction = new QAction("Remove all", this); + connect(removeAllAction, SIGNAL(triggered()), this, SLOT(removeAllFiles())); - menu->addAction(setMasterAction); - menu->addAction(editAction); - menu->addAction(removeAction); - menu->addSeparator(); - menu->addAction(removeAllAction); + menu->addAction(setMasterAction); + menu->addAction(editAction); + menu->addAction(removeAction); + menu->addSeparator(); + menu->addAction(removeAllAction); } -void FileList::popupMenu(const QPoint & pos) +void FileList::popupMenu(const QPoint& pos) { - activeItem = itemAt(pos); - if(!activeItem) return; - menu->popup(mapToGlobal(pos)); + activeItem = itemAt(pos); + if(!activeItem) + { + return; + } + menu->popup(mapToGlobal(pos)); } void FileList::setMaster() { - setMasterFile(activeItem); + setMasterFile(activeItem); } void FileList::removeFile() { - QString file = itemFile(activeItem); - QString name = itemName(activeItem); + QString file = itemFile(activeItem); + QString name = itemName(activeItem); - printf("Removing: %s\n", file.toStdString().c_str()); - delete activeItem;//takeItem(row(activeItem)); - activeItem = NULL; - setCurrentRow(-1); + printf("Removing: %s\n", file.toStdString().c_str()); + delete activeItem;//takeItem(row(activeItem)); + activeItem = NULL; + setCurrentRow(-1); - emit fileRemoved(file, name); + emit fileRemoved(file, name); } void FileList::removeAllFiles() { - activeItem = NULL; + activeItem = NULL; - clear(); + clear(); - emit allFilesRemoved(); + emit allFilesRemoved(); } void FileList::editName() { - ItemEditor *e = new ItemEditor(activeItem, itemName(activeItem)); - connect(e, SIGNAL(updateItem(QListWidgetItem *, QString)), - this, SLOT(setItemName(QListWidgetItem *, QString))); + ItemEditor* e = new ItemEditor(activeItem, itemName(activeItem)); + connect(e, SIGNAL(updateItem(QListWidgetItem*, QString)), + this, SLOT(setItemName(QListWidgetItem*, QString))); } // Item utility functions. -QString FileList::itemFile(QListWidgetItem *i) +QString FileList::itemFile(QListWidgetItem* i) { - return i->data(Qt::ToolTipRole).toString(); + return i->data(Qt::ToolTipRole).toString(); } -void FileList::setItemFile(QListWidgetItem *i, QString file) +void FileList::setItemFile(QListWidgetItem* i, QString file) { - i->setData(Qt::ToolTipRole, file); - i->setData(Qt::DisplayRole, itemName(i) + "\t" + file); + i->setData(Qt::ToolTipRole, file); + i->setData(Qt::DisplayRole, itemName(i) + "\t" + file); } -QString FileList::itemName(QListWidgetItem *i) +QString FileList::itemName(QListWidgetItem* i) { - return i->data(Qt::UserRole).toString(); + return i->data(Qt::UserRole).toString(); } -void FileList::setItemName(QListWidgetItem *i, QString name) +void FileList::setItemName(QListWidgetItem* i, QString name) { - QString oldname = itemName(i); + QString oldname = itemName(i); - i->setData(Qt::UserRole, name); - i->setData(Qt::DisplayRole, name + "\t" + itemFile(i)); + i->setData(Qt::UserRole, name); + i->setData(Qt::DisplayRole, name + "\t" + itemFile(i)); - if(oldname != "" && oldname != name) emit nameChanged(itemFile(i), name); + if(oldname != "" && oldname != name) + { + emit nameChanged(itemFile(i), name); + } } -void FileList::setItemMaster(QListWidgetItem *i, bool master) +void FileList::setItemMaster(QListWidgetItem* i, bool master) { - if(master) i->setIcon(QPixmap(":icons/master.png")); - else i->setIcon(QPixmap(":icons/file.png")); + if(master) + { + i->setIcon(QPixmap(":icons/master.png")); + } + else + { + i->setIcon(QPixmap(":icons/file.png")); + } } -- cgit v1.2.3