BookmarkPropertiesDialog::BookmarkPropertiesDialog(const QUrl &url, const QString &title, const QString &description, BookmarksItem *folder, int index, bool isUrl, QWidget *parent) : Dialog(parent), m_bookmark(nullptr), m_index(index), m_ui(new Ui::BookmarkPropertiesDialog) { m_ui->setupUi(this); m_ui->folderComboBox->setCurrentFolder(folder ? folder : BookmarksManager::getLastUsedFolder()); m_ui->titleLineEdit->setText(title); m_ui->addressLineEdit->setText(url.toString()); m_ui->addressLineEdit->setVisible(isUrl); m_ui->addressLabel->setVisible(isUrl); m_ui->descriptionTextEdit->setPlainText(description); m_ui->visitsLabel->hide(); m_ui->visitsLabelWidget->hide(); m_ui->lastVisitLabel->hide(); m_ui->lastVisitLabelWidget->hide(); m_ui->addedLabel->hide(); m_ui->addedLabelWidget->hide(); m_ui->modifiedLabel->hide(); m_ui->modifiedLabelWidget->hide(); setWindowTitle(tr("Add Bookmark")); connect(m_ui->newFolderButton, SIGNAL(clicked()), m_ui->folderComboBox, SLOT(createFolder())); connect(m_ui->buttonBox, SIGNAL(accepted()), this, SLOT(saveBookmark())); connect(m_ui->buttonBox, SIGNAL(rejected()), this, SLOT(close())); }
bool BookmarksModel::saveBookmark(WebView* view, QString folder) { if (folder.isEmpty()) { folder = m_lastFolder; } return saveBookmark(view->url(), view->title(), view->icon(), folder); }
DialogBookmarks::DialogBookmarks(QWidget *parent) : QDialog(parent), ui(new Ui::DialogBookmarks) { ui->setupUi(this); //setWindowFlags(Qt::WindowTitleHint); connect(ui->listWidget, SIGNAL(clicked(QModelIndex)), this, SLOT(selectedBookmark())); connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(newBookmark())); connect(ui->pushButton_2, SIGNAL(clicked()), SLOT(deleteBookmark())); connect(ui->lineEdit, SIGNAL(textEdited(QString)), this, SLOT(saveBookmark())); connect(ui->lineEdit_2, SIGNAL(textEdited(QString)), this, SLOT(saveBookmark())); connect(ui->lineEdit_3, SIGNAL(textEdited(QString)), this, SLOT(saveBookmark())); connect(ui->lineEdit_4, SIGNAL(textEdited(QString)), this, SLOT(saveBookmark())); connect(this, SIGNAL(finished(int)), this, SLOT(saveBookmark())); loadBookmarks(); }
BookmarkPropertiesDialog::BookmarkPropertiesDialog(BookmarksItem *bookmark, QWidget *parent) : Dialog(parent), m_bookmark(bookmark), m_index(-1), m_ui(new Ui::BookmarkPropertiesDialog) { const BookmarksModel::BookmarkType type(static_cast<BookmarksModel::BookmarkType>(bookmark->data(BookmarksModel::TypeRole).toInt())); m_ui->setupUi(this); m_ui->folderComboBox->setCurrentFolder(dynamic_cast<BookmarksItem*>(bookmark->parent())); m_ui->titleLineEdit->setText(m_bookmark->data(BookmarksModel::TitleRole).toString()); m_ui->addressLineEdit->setText(m_bookmark->data(BookmarksModel::UrlRole).toString()); m_ui->addressLineEdit->setVisible(type == BookmarksModel::UrlBookmark); m_ui->addressLabel->setVisible(type == BookmarksModel::UrlBookmark); m_ui->descriptionTextEdit->setPlainText(m_bookmark->data(BookmarksModel::DescriptionRole).toString()); m_ui->keywordLineEdit->setText(m_bookmark->data(BookmarksModel::KeywordRole).toString()); m_ui->addedLabelWidget->setText(m_bookmark->data(BookmarksModel::TimeAddedRole).isValid() ? m_bookmark->data(BookmarksModel::TitleRole).toDateTime().toString() : tr("Unknown")); m_ui->modifiedLabelWidget->setText(m_bookmark->data(BookmarksModel::TimeModifiedRole).isValid() ? m_bookmark->data(BookmarksModel::TimeModifiedRole).toDateTime().toString() : tr("Unknown")); if (type == BookmarksModel::UrlBookmark) { m_ui->lastVisitLabelWidget->setText(m_bookmark->data(BookmarksModel::TimeVisitedRole).isValid() ? m_bookmark->data(BookmarksModel::TimeVisitedRole).toString() : tr("Unknown")); m_ui->visitsLabelWidget->setText(QString::number(m_bookmark->data(BookmarksModel::VisitsRole).toInt())); } else { m_ui->visitsLabel->hide(); m_ui->visitsLabelWidget->hide(); m_ui->lastVisitLabel->hide(); m_ui->lastVisitLabelWidget->hide(); } if (bookmark->data(BookmarksModel::IsTrashedRole).toBool()) { setWindowTitle(tr("View Bookmark")); m_ui->folderLabel->hide(); m_ui->folderComboBox->hide(); m_ui->newFolderButton->hide(); m_ui->titleLineEdit->setReadOnly(true); m_ui->addressLineEdit->setReadOnly(true); m_ui->descriptionTextEdit->setReadOnly(true); m_ui->keywordLineEdit->setReadOnly(true); } else { setWindowTitle(tr("Edit Bookmark")); } connect(m_ui->newFolderButton, SIGNAL(clicked()), m_ui->folderComboBox, SLOT(createFolder())); connect(m_ui->buttonBox, SIGNAL(accepted()), this, SLOT(saveBookmark())); connect(m_ui->buttonBox, SIGNAL(rejected()), this, SLOT(close())); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); // Menu QMenu* modelMenu = menuBar()->addMenu("&Model"); modelMenu->addAction("&Open model...", this, SLOT(openModel()) ); modelMenu->addSeparator(); modelMenu->addAction("&Close model", this, SLOT(closeModel()) ); QMenu* markMenu = menuBar()->addMenu("&Bookmarks"); markMenu->addAction("&New file...", this, SLOT(closeBookmarksFile()) ); markMenu->addAction("&Open file...", this, SLOT(openBookmarksFile()) ); markMenu->addSeparator(); markMenu->addAction("&Close file", this, SLOT(closeBookmarksFile()) ); markMenu->addSeparator(); markMenu->addAction("&Save file", this, SLOT(saveBookmarksFile())); markMenu->addAction("&Save file as...", this, SLOT(saveAsBookmarksFile())); QMenu* viewMenu = menuBar()->addMenu("&View"); viewMenu->addAction("&View as points", this, SLOT(viewAsPoints()) ); viewMenu->addAction("&View as wired", this, SLOT(viewAsWired()) ); viewMenu->addAction("&View as solid", this, SLOT(viewAsSolid()) ); viewMenu->addAction("&View as solid + wired",this, SLOT(viewAsSolidWire()) ); QMenu* modeMenu = menuBar()->addMenu("&Mode"); modeMenu->addAction("&Viewer", this, SLOT(viewerMode()) ); modeMenu->addAction("&Editor", this, SLOT(editorMode()) ); modeMenu->addAction("&Ask Me!", this, SLOT(testMode()) ); // Section list panel buttons. QObject::connect(ui->addButton, SIGNAL(clicked()), this, SLOT(showAddSectionPanel())); QObject::connect(ui->editButton, SIGNAL(clicked()), this, SLOT(showEditSectionPanel())); QObject::connect(ui->deleteButton, SIGNAL(clicked()), this, SLOT(deleteCurrentSection())); QObject::connect(ui->infoButton, SIGNAL(clicked()), this, SLOT(showInfoSectionPanel())); QObject::connect(ui->listWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)), this, SLOT(listWidgetItemClicked(QListWidgetItem*))); // Add bookmark panel buttons. QObject::connect(ui->addModeButton, SIGNAL(clicked()), this, SLOT(setAddSelectionMode())); QObject::connect(ui->removeModeButton, SIGNAL(clicked()), this, SLOT(setRemoveSelectionMode())); QObject::connect(ui->saveButton, SIGNAL(clicked()), this, SLOT(saveBookmark())); QObject::connect(ui->discardButton, SIGNAL(clicked()), this, SLOT(discardBookmark())); QObject::connect(ui->brushSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(setBrushSize(int))); // Information panel buttons QObject::connect(ui->backButton, SIGNAL(clicked()), this, SLOT(showListPanel())); // Test panel buttons QObject::connect(ui->nextQuestionButton, SIGNAL(clicked()), this, SLOT(nextQuestion())); QObject::connect(ui->glwidget, SIGNAL(pickResult(std::set<unsigned int>)), this, SLOT(checkResponse(std::set<unsigned int>))); // Set window title. setWindowTitle("untitled.txt"); // Initialize variables. _bookmarkList = new BookmarkList(); clearBookmarkList(); _model = new Model(); _indexTest = 0; // Set viewer mode. viewerMode(); // Show welcome message statusBar()->showMessage("Welcome to 3D Marker."); }