void docItem::saveItem(){ if (list.size() == 0){ if (vid == 1){ QSqlQuery query("insert into book_item (book, identifier) values (:book, :identifier)"); query.bindValue(0, QString("%1").arg(ui.spinBox_id_book->value())); query.bindValue(1, ui.lineEdit_identifier->text()); query.bindValue(2, ui.lineEdit_place->text()); query.exec(); QSqlQuery queryDocs("insert into doc_item (doc, book_item) values (:doc, :book_item)"); queryDocs.bindValue(0, QString("%1").arg(doc)); queryDocs.bindValue(1, QString("%1").arg(query.lastInsertId().toString())); queryDocs.exec(); } else if (vid == 2){ QSqlQuery queryDocs("insert into doc_item (doc, book_item) values (:doc, :book_item)"); queryDocs.bindValue(0, QString("%1").arg(doc)); queryDocs.bindValue(1, QString("%1").arg(ui.spinBox_id_book->value())); queryDocs.exec(); } } else if (list.size() > 0){ QSqlQuery queryID(QString("select doc_item.book_item from doc_item where doc_item.id = \'%1\'").arg(list.at(curr))); queryID.next(); QSqlQuery query(QString("update book_item set book = \'%1\', identifier = \'%2\' where book_item.id = \'%4\' ") .arg(ui.spinBox_id_book->value()) .arg(ui.lineEdit_identifier->text()) .arg(queryID.value(0).toInt())); query.exec(); } viewItems(); openItem(); }
void CoordinatorServer::received(const QString &message, const QByteArray &data) { QDataStream in(data); if (message == "openItem(QUrl)") { QUrl url; in >> url; openItem(url); } else if (message == "openItem(QString,QUrl)") {
void KexiProjectNavigator::slotOpenObject() { KexiProjectModelItem *it = static_cast<KexiProjectModelItem*>(d->list->currentIndex().internalPointer()); if (!it || !it->partItem()) return; emit openItem(it->partItem(), Kexi::DataViewMode); }
void FolderNavigationWidget::contextMenuEvent(QContextMenuEvent *ev) { QMenu menu; // Open current item const QModelIndex current = currentItem(); const bool hasCurrentItem = current.isValid(); QAction *actionOpen = menu.addAction(actionOpenText(m_fileSystemModel, current)); actionOpen->setEnabled(hasCurrentItem); // Explorer & teminal QAction *actionExplorer = menu.addAction(Core::FileUtils::msgGraphicalShellAction()); actionExplorer->setEnabled(hasCurrentItem); QAction *actionTerminal = menu.addAction(Core::FileUtils::msgTerminalAction()); actionTerminal->setEnabled(hasCurrentItem); QAction *actionFind = menu.addAction(msgFindOnFileSystem()); actionFind->setEnabled(hasCurrentItem); // open with... if (!m_fileSystemModel->isDir(current)) { QMenu *openWith = menu.addMenu(tr("Open with")); Core::DocumentManager::populateOpenWithMenu(openWith, m_fileSystemModel->filePath(current)); } // Open file dialog to choose a path starting from current QAction *actionChooseFolder = menu.addAction(tr("Choose Folder...")); QAction *action = menu.exec(ev->globalPos()); if (!action) return; ev->accept(); if (action == actionOpen) { // Handle open file. openItem(current); return; } if (action == actionChooseFolder) { // Open file dialog const QString newPath = QFileDialog::getExistingDirectory(this, tr("Choose Folder"), currentDirectory()); if (!newPath.isEmpty()) setCurrentDirectory(newPath); return; } if (action == actionTerminal) { Core::FileUtils::openTerminal(m_fileSystemModel->filePath(current)); return; } if (action == actionExplorer) { Core::FileUtils::showInGraphicalShell(this, m_fileSystemModel->filePath(current)); return; } if (action == actionFind) { QFileInfo info = m_fileSystemModel->fileInfo(current); if (m_fileSystemModel->isDir(current)) findOnFileSystem(info.absoluteFilePath()); else findOnFileSystem(info.absolutePath()); return; } Core::DocumentManager::executeOpenWithMenuAction(action); }
QString InfoFile::addItem(QString tag, QString value) { row++; return openItem() + "<td><b>" + tag + "</b></td>" + "<td>" + value + "</td>" + closeItem(); }
void KexiProjectNavigator::slotEditTextObject() { if (!d->editTextAction) return; KexiProjectModelItem *it = static_cast<KexiProjectModelItem*>(d->list->currentIndex().internalPointer()); if (!it || !it->partItem()) return; emit openItem(it->partItem(), Kexi::TextViewMode); }
void FolderNavigationWidget::contextMenuEvent(QContextMenuEvent *ev) { QMenu menu; // Open current item const QModelIndex current = currentItem(); const bool hasCurrentItem = current.isValid(); QAction *actionOpen = menu.addAction(actionOpenText(m_fileSystemModel, current)); actionOpen->setEnabled(hasCurrentItem); // we need dummy DocumentModel::Entry with absolute file path in it // to get EditorManager::addNativeDirAndOpenWithActions() working Core::DocumentModel::Entry fakeEntry; Core::IDocument document; document.setFilePath(Utils::FileName::fromString(m_fileSystemModel->filePath(current))); fakeEntry.document = &document; Core::EditorManager::addNativeDirAndOpenWithActions(&menu, &fakeEntry); const bool isDirectory = hasCurrentItem && m_fileSystemModel->isDir(current); QAction *actionOpenDirectoryAsProject = 0; if (isDirectory && m_fileSystemModel->fileName(current) != QLatin1String("..")) { actionOpenDirectoryAsProject = menu.addAction(tr("Open Project in \"%1\"") .arg(m_fileSystemModel->fileName(current))); } // Open file dialog to choose a path starting from current QAction *actionChooseFolder = menu.addAction(tr("Choose Folder...")); QAction *action = menu.exec(ev->globalPos()); if (!action) return; ev->accept(); if (action == actionOpen) { // Handle open file. openItem(current); } else if (action == actionOpenDirectoryAsProject) { openItem(current, true); } else if (action == actionChooseFolder) { // Open file dialog const QString newPath = QFileDialog::getExistingDirectory(this, tr("Choose Folder"), currentDirectory()); if (!newPath.isEmpty()) setCurrentDirectory(newPath); } }
void FolderNavigationWidget::contextMenuEvent(QContextMenuEvent *ev) { QMenu menu; // Open current item const QModelIndex current = currentItem(); const bool hasCurrentItem = current.isValid(); QAction *actionOpen = menu.addAction(actionOpenText(m_fileSystemModel, current)); actionOpen->setEnabled(hasCurrentItem); // Explorer & teminal QAction *actionExplorer = menu.addAction(msgGraphicalShellAction()); actionExplorer->setEnabled(hasCurrentItem); QAction *actionTerminal = menu.addAction(msgTerminalAction()); actionTerminal->setEnabled(hasCurrentItem); // open with... if (!m_fileSystemModel->isDir(current)) { QMenu *openWith = menu.addMenu(tr("Open with")); ProjectExplorerPlugin::populateOpenWithMenu(openWith, m_fileSystemModel->filePath(current)); } // Open file dialog to choose a path starting from current QAction *actionChooseFolder = menu.addAction(tr("Choose folder...")); QAction *action = menu.exec(ev->globalPos()); if (!action) return; ev->accept(); if (action == actionOpen) { // Handle open file. openItem(current); return; } if (action == actionChooseFolder) { // Open file dialog const QString newPath = QFileDialog::getExistingDirectory(this, tr("Choose folder"), currentDirectory()); if (!newPath.isEmpty()) setCurrentDirectory(newPath); return; } if (action == actionTerminal) { openTerminal(m_fileSystemModel->filePath(current)); return; } if (action == actionExplorer) { showInGraphicalShell(this, m_fileSystemModel->filePath(current)); return; } ProjectExplorerPlugin::openEditorFromAction(action, m_fileSystemModel->filePath(current)); }
void MontageView::initActions() { m_remove_action = new QAction( tr("Remove item from calibration list"), tr("Remove"), CTRL+Key_R, this ); m_remove_all_action = new QAction( tr("Remove all images from calibration list"), tr("Remove All "), CTRL+SHIFT+Key_R, this ); m_open_action = new QAction( tr("Open this image"), tr("Open"), CTRL+Key_O, this ); connect( m_remove_action, SIGNAL( activated() ), this, SLOT( removeItem() )); connect( m_remove_all_action, SIGNAL( activated() ), this, SLOT( removeAllItems() )); connect( m_open_action, SIGNAL( activated() ), this, SLOT( openItem() )); m_remove_action ->addTo( &m_item_menu ); m_remove_all_action->addTo( &m_item_menu ); m_open_action ->addTo( &m_item_menu ); m_remove_all_action->setEnabled(true); m_remove_action ->setEnabled(false); m_open_action ->setEnabled(false); }
docItem::docItem(QList<int> _list, int _curr, int _doc, QWidget *parent):QDialog(parent){ ui.setupUi(this); list = _list; curr = _curr; doc = _doc; QSqlQuery _v(QString("select docs.vid from docs where docs.id = \'%1\'").arg(doc)); _v.next(); vid = _v.value(0).toInt(); ui.spinBox_id_book->hide(); ui.tableWidget_res->setColumnHidden(0, true); ui.tableWidget_res->setColumnHidden(7, true); ui.tableWidget_res->setColumnHidden(8, true); if (vid == 1){ ui.tableWidget_res->setColumnHidden(6, true); ui.radioButton_identifier->hide(); } else if (vid == 2){ ui.lineEdit_place->hide(); ui.label_3->hide(); ui.lineEdit_identifier->setReadOnly(true); } openItem(); readSetting(); connect(ui.pushButton_close, SIGNAL(clicked()), this, SLOT(close())); connect(ui.lineEdit_search, SIGNAL(textEdited(QString)), this, SLOT(searchBook(QString))); connect(ui.tableWidget_res, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(selectBook())); connect(ui.pushButton_save, SIGNAL(clicked()), this, SLOT(saveItem())); connect(ui.pushButton_del, SIGNAL(clicked()), this, SLOT(deleteItem())); connect(ui.pushButton_toFirst, SIGNAL(clicked()), this, SLOT(toFirst())); connect(ui.pushButton_toLast, SIGNAL(clicked()), this, SLOT(toLast())); connect(ui.pushButton_toNext, SIGNAL(clicked()), this, SLOT(toNext())); connect(ui.pushButton_toPrev, SIGNAL(clicked()), this, SLOT(toPrev())); }
void TableView::keyPressEvent(QKeyEvent *event) { if(event == NULL) return; switch(event->key()) { case Qt::Key_Return: openItem(currentIndex()); break; case Qt::Key_Backspace: cdUp(); break; default: QTableView::keyPressEvent(event); break; } event->ignore(); }
void TableView::mouseDoubleClickEvent(QMouseEvent *event) { QTableView::mouseDoubleClickEvent(event); openItem(indexAt(event->pos())); }
UIImageOverview::UIImageOverview(QWidget *parent) : QWidget(parent), ui(new Ui::UIImageOverview) { QClipboard *clipboard = QApplication::clipboard(); requestHandler = new RequestHandler(this); iParser = 0; oParser = 0; _cachedResult = false; pendingThumbnails.clear(); ui->setupUi(this); #ifndef __DEBUG__ ui->btnDebug->hide(); #endif timer = new QTimer(this); settings = new QSettings("settings.ini", QSettings::IniFormat); thumbnailsizeLocked = false; closeWhenFinished = false; downloading = false; deleteFileAction = new QAction(QString("Delete File"), this); deleteFileAction->setIcon(QIcon(":/icons/resources/remove.png")); reloadFileAction = new QAction("Reload File", this); reloadFileAction->setIcon(QIcon(":/icons/resources/reload.png")); openFileAction = new QAction("Open File", this); openFileAction->setIcon(QIcon(":/icons/resources/open.png")); ui->progressBar->setMinimum(1); ui->progressBar->setMaximum(-1); ui->progressBar->setValue(0); ui->progressBar->setEnabled(true); ui->progressBar->setVisible(false); ui->progressBar->setFormat("%p%"); if (QUrl(clipboard->text()).isValid() && pluginManager->isSupported(clipboard->text())) { ui->leURI->setText(clipboard->text()); } connect(requestHandler, SIGNAL(responseError(QUrl, int)), this, SLOT(errorHandler(QUrl, int))); connect(requestHandler, SIGNAL(response(QUrl, QByteArray, bool)), this, SLOT(processRequestResponse(QUrl, QByteArray, bool))); connect(ui->leSavepath, SIGNAL(textChanged(QString)), this, SIGNAL(directoryChanged(QString))); connect(ui->listWidget, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(openFile())); connect(deleteFileAction, SIGNAL(triggered()), this, SLOT(deleteFile())); connect(reloadFileAction, SIGNAL(triggered()), this, SLOT(reloadFile())); connect(openFileAction, SIGNAL(triggered()), this, SLOT(openFile())); connect(timer, SIGNAL(timeout()), this, SLOT(triggerRescan())); connect(folderShortcuts, SIGNAL(shortcutsChanged()), this, SLOT(fillShortcutComboBox())); connect(ui->cbFolderShortcuts, SIGNAL(currentIndexChanged(QString)), this, SLOT(selectShortcut(QString))); connect(ui->leSavepath, SIGNAL(textChanged(QString)), this, SLOT(checkForFolderShortcut(QString))); connect(ui->btnAddShortcut, SIGNAL(clicked()), this, SLOT(addShortcut())); // Connections for key bindings connect(ui->listWidget, SIGNAL(openItem()), this, SLOT(openFile())); connect(ui->listWidget, SIGNAL(deleteItem()), this, SLOT(deleteFile())); connect(ui->listWidget, SIGNAL(reloadItem()), this, SLOT(reloadFile())); connect(tnt, SIGNAL(thumbnailAvailable(QString,QString)), this, SLOT(addThumbnail(QString,QString))); setTabTitle("idle"); loadSettings(); fillShortcutComboBox(); expectedThumbnailCount = 0; thumbnailCount = 0; }
void FolderNavigationWidget::slotOpenItem(const QModelIndex &viewIndex) { if (viewIndex.isValid()) openItem(m_filterModel->mapToSource(viewIndex)); }
void docItem::toLast(){ curr = list.size() - 1; openItem(); }
QString InfoFile::getInfo(MediaData md) { QString s; // General QFileInfo fi(md.filename); QString icon; switch (md.type) { case TYPE_FILE : if (md.novideo) icon = "type_audio.png"; else icon = "type_video.png"; break; case TYPE_DVD : icon = "type_dvd.png"; break; case TYPE_VCD : icon = "type_vcd.png"; break; case TYPE_AUDIO_CD : icon = "type_vcd.png"; break; case TYPE_TV : icon = "type_tv.png"; break; case TYPE_STREAM : icon = "type_url.png"; break; default : icon = "type_unknown.png"; } icon = "<img src=\"" + Images::file(icon) + "\"> "; if (md.type == TYPE_DVD) { DiscData disc_data = DiscName::split(md.filename); s += title(icon + disc_data.protocol + "://" + QString::number(disc_data.title)); } else { s += title(icon + md.displayName()); } s += openPar(tr("General")); if (fi.exists()) { //s += addItem( tr("Path"), fi.dirPath() ); s += addItem(tr("File"), fi.absoluteFilePath()); s += addItem(tr("Size"), tr("%1 KB (%2 MB)").arg(fi.size() / 1024) .arg(fi.size() / 1048576)); } else { QString url = md.filename; s += addItem(tr("URL"), url); } s += addItem(tr("Length"), Helper::formatTime((int)md.duration)); s += addItem(tr("Demuxer"), md.demuxer); s += closePar(); // Clip info QString c; if (!md.clip_name.isEmpty()) c += addItem(tr("Name"), md.clip_name); if (!md.clip_artist.isEmpty()) c += addItem(tr("Artist"), md.clip_artist); if (!md.clip_author.isEmpty()) c += addItem(tr("Author"), md.clip_author); if (!md.clip_album.isEmpty()) c += addItem(tr("Album"), md.clip_album); if (!md.clip_genre.isEmpty()) c += addItem(tr("Genre"), md.clip_genre); if (!md.clip_date.isEmpty()) c += addItem(tr("Date"), md.clip_date); if (!md.clip_track.isEmpty()) c += addItem(tr("Track"), md.clip_track); if (!md.clip_copyright.isEmpty()) c += addItem(tr("Copyright"), md.clip_copyright); if (!md.clip_comment.isEmpty()) c += addItem(tr("Comment"), md.clip_comment); if (!md.clip_software.isEmpty()) c += addItem(tr("Software"), md.clip_software); if (!md.stream_title.isEmpty()) c += addItem(tr("Stream title"), md.stream_title); if (!md.stream_url.isEmpty()) c += addItem(tr("Stream URL"), md.stream_url); if (!c.isEmpty()) { s += openPar(tr("Clip info")); s += c; s += closePar(); } // Video info if (!md.novideo) { s += openPar(tr("Video")); s += addItem(tr("Resolution"), QString("%1 x %2").arg(md.video_width).arg(md.video_height)); s += addItem(tr("Aspect ratio"), QString::number(md.video_aspect)); s += addItem(tr("Format"), md.video_format); s += addItem(tr("Bitrate"), tr("%1 kbps").arg(md.video_bitrate / 1000)); s += addItem(tr("Frames per second"), md.video_fps); s += addItem(tr("Selected codec"), md.video_codec); s += closePar(); } // Audio info s += openPar(tr("Initial Audio Stream")); s += addItem(tr("Format"), md.audio_format); s += addItem(tr("Bitrate"), tr("%1 kbps").arg(md.audio_bitrate / 1000)); s += addItem(tr("Rate"), tr("%1 Hz").arg(md.audio_rate)); s += addItem(tr("Channels"), QString::number(md.audio_nch)); s += addItem(tr("Selected codec"), md.audio_codec); s += closePar(); // Audio Tracks if (md.audios.numItems() > 0) { s += openPar(tr("Audio Streams")); row++; s += openItem(); s += "<td>" + tr("#", "Info for translators: this is a abbreviation for number") + "</td><td>" + tr("Language") + "</td><td>" + tr("Name") + "</td><td>" + tr("ID", "Info for translators: this is a identification code") + "</td>"; s += closeItem(); for (int n = 0; n < md.audios.numItems(); n++) { row++; s += openItem(); QString lang = md.audios.itemAt(n).lang(); if (lang.isEmpty()) lang = "<i><" + tr("empty") + "></i>"; QString name = md.audios.itemAt(n).name(); if (name.isEmpty()) name = "<i><" + tr("empty") + "></i>"; s += QString("<td>%1</td><td>%2</td><td>%3</td><td>%4</td>") .arg(n).arg(lang).arg(name) .arg(md.audios.itemAt(n).ID()); s += closeItem(); } s += closePar(); } // Subtitles if (md.subs.numItems() > 0) { s += openPar(tr("Subtitles")); row++; s += openItem(); s += "<td>" + tr("#", "Info for translators: this is a abbreviation for number") + "</td><td>" + tr("Type") + "</td><td>" + tr("Language") + "</td><td>" + tr("Name") + "</td><td>" + tr("ID", "Info for translators: this is a identification code") + "</td>"; s += closeItem(); for (int n = 0; n < md.subs.numItems(); n++) { row++; s += openItem(); QString t; switch (md.subs.itemAt(n).type()) { case SubData::File: t = "FILE_SUB"; break; case SubData::Vob: t = "VOB"; break; default: t = "SUB"; } QString lang = md.subs.itemAt(n).lang(); if (lang.isEmpty()) lang = "<i><" + tr("empty") + "></i>"; QString name = md.subs.itemAt(n).name(); if (name.isEmpty()) name = "<i><" + tr("empty") + "></i>"; /* s += QString("<td>%1</td><td>%2</td><td>%3</td><td>%4</td><td>%5</td>") .arg(n).arg(t).arg(lang).arg(name) .arg(md.subs.itemAt(n).ID()); */ s += "<td>" + QString::number(n) + "</td><td>" + t + "</td><td>" + lang + "</td><td>" + name + "</td><td>" + QString::number(md.subs.itemAt(n).ID()) + "</td>"; s += closeItem(); } s += closePar(); } return "<html><body bgcolor=\"white\"><font color=\"black\">" + s + "</font></body></html>"; }
void docItem::toNext(){ curr = curr + 1; openItem(); }
void docItem::toPrev(){ curr = curr - 1; openItem(); }
void docItem::toFirst(){ curr = 0; openItem(); }
void FolderNavigationWidget::contextMenuEvent(QContextMenuEvent *ev) { QMenu menu; // Open current item const QModelIndex current = currentItem(); const bool hasCurrentItem = current.isValid(); QAction *actionOpen = menu.addAction(actionOpenText(m_fileSystemModel, current)); actionOpen->setEnabled(hasCurrentItem); const bool isDirectory = hasCurrentItem && m_fileSystemModel->isDir(current); QAction *actionOpenDirectoryAsProject = 0; if (isDirectory && m_fileSystemModel->fileName(current) != QLatin1String("..")) { actionOpenDirectoryAsProject = menu.addAction(tr("Open Project in \"%1\"") .arg(m_fileSystemModel->fileName(current))); } // Explorer & teminal QAction *actionExplorer = menu.addAction(Core::FileUtils::msgGraphicalShellAction()); actionExplorer->setEnabled(hasCurrentItem); QAction *actionTerminal = menu.addAction(Core::FileUtils::msgTerminalAction()); actionTerminal->setEnabled(hasCurrentItem); QAction *actionFind = menu.addAction(Core::FileUtils::msgFindInDirectory()); actionFind->setEnabled(hasCurrentItem); // open with... if (hasCurrentItem && !isDirectory) { QMenu *openWith = menu.addMenu(tr("Open With")); Core::EditorManager::populateOpenWithMenu(openWith, m_fileSystemModel->filePath(current)); } // Open file dialog to choose a path starting from current QAction *actionChooseFolder = menu.addAction(tr("Choose Folder...")); QAction *action = menu.exec(ev->globalPos()); if (!action) return; ev->accept(); if (action == actionOpen) { // Handle open file. openItem(current); return; } if (action == actionOpenDirectoryAsProject) { openItem(current, true); return; } if (action == actionChooseFolder) { // Open file dialog const QString newPath = QFileDialog::getExistingDirectory(this, tr("Choose Folder"), currentDirectory()); if (!newPath.isEmpty()) setCurrentDirectory(newPath); return; } if (action == actionTerminal) { Core::FileUtils::openTerminal(m_fileSystemModel->filePath(current)); return; } if (action == actionExplorer) { Core::FileUtils::showInGraphicalShell(this, m_fileSystemModel->filePath(current)); return; } if (action == actionFind) { TextEditor::FindInFiles::findOnFileSystem(m_fileSystemModel->filePath(current)); return; } }
void VCart::openSelectedItems() const { openItem(m_itemList->currentItem()); }