void TInputLine::setData( void *rec ) { memcpy( data, rec, dataSize()-1 ); data[dataSize()-1] = EOS; selectAll( True ); }
void DefaultComboBoxEditor::handleTextFieldFocusGained(FocusEventDetails* const e) { //TODO: Implement selectAll(); }
void iKeyboard(unsigned char key) { upArrow = 0; downArrow=0; //set arrow flags off //retrieve charactre index in terms of cursor position j = x/ charSpace; i = ((height-15-lineSpace - y)/lineSpace) + s; if (glutGetModifiers() == GLUT_ACTIVE_CTRL) //ALT key operations { if (key == 1) //select all { selectAll(); } else if (key == 3 ) //copy { copy(); } else if (key==15) //file open { fOpen =1; subTemp = (char *)calloc(60,sizeof(char)); x = (width-15)/2-135; y = (height-19)/2+61; menuflag = 0; } else if (key==16) //file save as { save(); char tempfile[80]; strcpy(tempfile, syspath); strcat(tempfile, ":\\Program Files\\Rword\\saved_files\\"); strcat(tempfile, filename); ShellExecute(NULL, "print", tempfile, NULL, NULL, NULL); //print document menuflag = 0; } else if (key==19) //file save { save(); menuflag = 0; } else if (copyFlag && key==22) //paste { paste(); } else if (key == 24 ) //cut { cut(); } } else if(key >31 && key <127) //character input { if (fOpen || fsave) { subCharacter(key); //for popups } else { if (selflag) seldel(); character(key); // main character input } } else if (key == '\b') //backspace { if (fOpen || fsave) //popup { if (strlen(subTemp)) { subTemp[strlen(subTemp)-1] = '\0'; if (strlen(subTemp)>33) r--; else x -= 8; } } else { if (selflag) seldel(); else backspace(); //main } } else if (key == 127) //del { if (selflag) seldel(); else del(); } else if (key == '\r') //enter operations { if (fOpen) { if (selflag) seldel(); open(); } else if (fsave) { saveas(); //popups } else { if (selflag) seldel(); else enter(); //main } } else if (key == '\t') //incomplete { selflag = 0; tab(); } }
void DuplicateMerger::selectNone() { selectAll(false); }
void MusicMyDownloadRecordWidget::setDeleteItemAll() { selectAll(); setDeleteItemAt(); }
PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow* main_window, TransferListWidget *transferList): QWidget(parent), transferList(transferList), main_window(main_window), m_torrent(0) { setupUi(this); setAutoFillBackground(true); state = VISIBLE; // Set Properties list model PropListModel = new TorrentContentFilterModel(); filesList->setModel(PropListModel); PropDelegate = new PropListDelegate(this); filesList->setItemDelegate(PropDelegate); filesList->setSortingEnabled(true); // Torrent content filtering m_contentFilterLine = new LineEdit(this); m_contentFilterLine->setPlaceholderText(tr("Filter files...")); connect(m_contentFilterLine, SIGNAL(textChanged(QString)), this, SLOT(filterText(QString))); contentFilterLayout->insertWidget(4, m_contentFilterLine); // SIGNAL/SLOTS connect(filesList, SIGNAL(clicked(const QModelIndex&)), filesList, SLOT(edit(const QModelIndex&))); connect(selectAllButton, SIGNAL(clicked()), PropListModel, SLOT(selectAll())); connect(selectNoneButton, SIGNAL(clicked()), PropListModel, SLOT(selectNone())); connect(filesList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayFilesListMenu(const QPoint&))); connect(filesList, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(openDoubleClickedFile(const QModelIndex &))); connect(PropListModel, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged())); connect(listWebSeeds, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayWebSeedListMenu(const QPoint&))); connect(transferList, SIGNAL(currentTorrentChanged(BitTorrent::TorrentHandle *const)), this, SLOT(loadTorrentInfos(BitTorrent::TorrentHandle *const))); connect(PropDelegate, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged())); connect(stackedProperties, SIGNAL(currentChanged(int)), this, SLOT(loadDynamicData())); connect(BitTorrent::Session::instance(), SIGNAL(torrentSavePathChanged(BitTorrent::TorrentHandle *const)), this, SLOT(updateSavePath(BitTorrent::TorrentHandle *const))); connect(BitTorrent::Session::instance(), SIGNAL(torrentMetadataLoaded(BitTorrent::TorrentHandle *const)), this, SLOT(updateTorrentInfos(BitTorrent::TorrentHandle *const))); connect(filesList->header(), SIGNAL(sectionMoved(int, int, int)), this, SLOT(saveSettings())); connect(filesList->header(), SIGNAL(sectionResized(int, int, int)), this, SLOT(saveSettings())); connect(filesList->header(), SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), this, SLOT(saveSettings())); #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) // set bar height relative to screen dpi int barHeight = devicePixelRatio() * 18; #else // set bar height relative to font height QFont defFont; QFontMetrics fMetrics(defFont, 0); // need to be device-dependent int barHeight = fMetrics.height() * 5 / 4; #endif // Downloaded pieces progress bar tempProgressBarArea->setVisible(false); downloaded_pieces = new DownloadedPiecesBar(this); groupBarLayout->addWidget(downloaded_pieces, 0, 1); downloaded_pieces->setFixedHeight(barHeight); downloaded_pieces->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); // Pieces availability bar tempAvailabilityBarArea->setVisible(false); pieces_availability = new PieceAvailabilityBar(this); groupBarLayout->addWidget(pieces_availability, 1, 1); pieces_availability->setFixedHeight(barHeight); pieces_availability->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); // Tracker list trackerList = new TrackerList(this); trackerUpButton->setIcon(GuiIconProvider::instance()->getIcon("go-up")); trackerDownButton->setIcon(GuiIconProvider::instance()->getIcon("go-down")); connect(trackerUpButton, SIGNAL(clicked()), trackerList, SLOT(moveSelectionUp())); connect(trackerDownButton, SIGNAL(clicked()), trackerList, SLOT(moveSelectionDown())); horizontalLayout_trackers->insertWidget(0, trackerList); connect(trackerList->header(), SIGNAL(sectionMoved(int, int, int)), trackerList, SLOT(saveSettings())); connect(trackerList->header(), SIGNAL(sectionResized(int, int, int)), trackerList, SLOT(saveSettings())); connect(trackerList->header(), SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), trackerList, SLOT(saveSettings())); // Peers list peersList = new PeerListWidget(this); peerpage_layout->addWidget(peersList); connect(peersList->header(), SIGNAL(sectionMoved(int, int, int)), peersList, SLOT(saveSettings())); connect(peersList->header(), SIGNAL(sectionResized(int, int, int)), peersList, SLOT(saveSettings())); connect(peersList->header(), SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), peersList, SLOT(saveSettings())); // Speed widget speedWidget = new SpeedWidget(this); speed_layout->addWidget(speedWidget); // Tab bar m_tabBar = new PropTabBar(); m_tabBar->setContentsMargins(0, 5, 0, 0); verticalLayout->addLayout(m_tabBar); connect(m_tabBar, SIGNAL(tabChanged(int)), stackedProperties, SLOT(setCurrentIndex(int))); connect(m_tabBar, SIGNAL(tabChanged(int)), this, SLOT(saveSettings())); connect(m_tabBar, SIGNAL(visibilityToggled(bool)), SLOT(setVisibility(bool))); connect(m_tabBar, SIGNAL(visibilityToggled(bool)), this, SLOT(saveSettings())); // Dynamic data refresher refreshTimer = new QTimer(this); connect(refreshTimer, SIGNAL(timeout()), this, SLOT(loadDynamicData())); refreshTimer->start(3000); // 3sec editHotkeyFile = new QShortcut(QKeySequence("F2"), filesList, 0, 0, Qt::WidgetShortcut); connect(editHotkeyFile, SIGNAL(activated()), SLOT(renameSelectedFile())); editHotkeyWeb = new QShortcut(QKeySequence("F2"), listWebSeeds, 0, 0, Qt::WidgetShortcut); connect(editHotkeyWeb, SIGNAL(activated()), SLOT(editWebSeed())); connect(listWebSeeds, SIGNAL(doubleClicked(QModelIndex)), SLOT(editWebSeed())); deleteHotkeyWeb = new QShortcut(QKeySequence(QKeySequence::Delete), listWebSeeds, 0, 0, Qt::WidgetShortcut); connect(deleteHotkeyWeb, SIGNAL(activated()), SLOT(deleteSelectedUrlSeeds())); openHotkeyFile = new QShortcut(QKeySequence("Return"), filesList, 0, 0, Qt::WidgetShortcut); connect(openHotkeyFile, SIGNAL(activated()), SLOT(openSelectedFile())); }
ChatLog::ChatLog(QWidget* parent) : QGraphicsView(parent) { // Create the scene busyScene = new QGraphicsScene(this); scene = new QGraphicsScene(this); scene->setItemIndexMethod(QGraphicsScene::BspTreeIndex); setScene(scene); // Cfg. setInteractive(true); setAcceptDrops(false); setAlignment(Qt::AlignTop | Qt::AlignLeft); setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setDragMode(QGraphicsView::NoDrag); setViewportUpdateMode(MinimalViewportUpdate); setContextMenuPolicy(Qt::CustomContextMenu); setBackgroundBrush(QBrush(Qt::white, Qt::SolidPattern)); // The selection rect for multi-line selection selGraphItem = scene->addRect(0,0,0,0,selectionRectColor.darker(120),selectionRectColor); selGraphItem->setZValue(-1.0); // behind all other items // copy action (ie. Ctrl+C) copyAction = new QAction(this); copyAction->setIcon(QIcon::fromTheme("edit-copy")); copyAction->setShortcut(QKeySequence::Copy); copyAction->setEnabled(false); connect(copyAction, &QAction::triggered, this, [this]() { copySelectedText(); }); addAction(copyAction); #ifdef Q_OS_LINUX // Ctrl+Insert shortcut QShortcut* copyCtrlInsShortcut = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Insert), this); connect(copyCtrlInsShortcut, &QShortcut::activated, this, [this]() { copySelectedText(); }); #endif // select all action (ie. Ctrl+A) selectAllAction = new QAction(this); selectAllAction->setIcon(QIcon::fromTheme("edit-select-all")); selectAllAction->setShortcut(QKeySequence::SelectAll); connect(selectAllAction, &QAction::triggered, this, [this]() { selectAll(); }); addAction(selectAllAction); // This timer is used to scroll the view while the user is // moving the mouse past the top/bottom edge of the widget while selecting. selectionTimer = new QTimer(this); selectionTimer->setInterval(1000/30); selectionTimer->setSingleShot(false); selectionTimer->start(); connect(selectionTimer, &QTimer::timeout, this, &ChatLog::onSelectionTimerTimeout); // Background worker // Updates the layout of all chat-lines after a resize workerTimer = new QTimer(this); workerTimer->setSingleShot(false); workerTimer->setInterval(5); connect(workerTimer, &QTimer::timeout, this, &ChatLog::onWorkerTimeout); // selection connect(this, &ChatLog::selectionChanged, this, [this]() { copyAction->setEnabled(hasTextToBeCopied()); #ifdef Q_OS_LINUX copySelectedText(true); #endif }); retranslateUi(); Translator::registerHandler(std::bind(&ChatLog::retranslateUi, this), this); }
PropertiesWidget::PropertiesWidget(QWidget *parent, MainWindow* main_window, TransferListWidget *transferList): QWidget(parent), transferList(transferList), main_window(main_window), m_torrent(0) { setupUi(this); // Icons trackerUpButton->setIcon(GuiIconProvider::instance()->getIcon("go-up")); trackerDownButton->setIcon(GuiIconProvider::instance()->getIcon("go-down")); state = VISIBLE; // Set Properties list model PropListModel = new TorrentContentFilterModel(); filesList->setModel(PropListModel); PropDelegate = new PropListDelegate(this); filesList->setItemDelegate(PropDelegate); filesList->setSortingEnabled(true); // Torrent content filtering m_contentFilerLine = new LineEdit(this); m_contentFilerLine->setPlaceholderText(tr("Filter files...")); connect(m_contentFilerLine, SIGNAL(textChanged(QString)), this, SLOT(filterText(QString))); contentFilterLayout->insertWidget(4, m_contentFilerLine); // SIGNAL/SLOTS connect(filesList, SIGNAL(clicked(const QModelIndex&)), filesList, SLOT(edit(const QModelIndex&))); connect(selectAllButton, SIGNAL(clicked()), PropListModel, SLOT(selectAll())); connect(selectNoneButton, SIGNAL(clicked()), PropListModel, SLOT(selectNone())); connect(filesList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayFilesListMenu(const QPoint&))); connect(filesList, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(openDoubleClickedFile(const QModelIndex &))); connect(PropListModel, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged())); connect(listWebSeeds, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayWebSeedListMenu(const QPoint&))); connect(transferList, SIGNAL(currentTorrentChanged(BitTorrent::TorrentHandle *const)), this, SLOT(loadTorrentInfos(BitTorrent::TorrentHandle *const))); connect(PropDelegate, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged())); connect(stackedProperties, SIGNAL(currentChanged(int)), this, SLOT(loadDynamicData())); connect(BitTorrent::Session::instance(), SIGNAL(torrentSavePathChanged(BitTorrent::TorrentHandle *const)), this, SLOT(updateSavePath(BitTorrent::TorrentHandle *const))); connect(BitTorrent::Session::instance(), SIGNAL(torrentMetadataLoaded(BitTorrent::TorrentHandle *const)), this, SLOT(updateTorrentInfos(BitTorrent::TorrentHandle *const))); connect(filesList->header(), SIGNAL(sectionMoved(int, int, int)), this, SLOT(saveSettings())); connect(filesList->header(), SIGNAL(sectionResized(int, int, int)), this, SLOT(saveSettings())); connect(filesList->header(), SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), this, SLOT(saveSettings())); // Downloaded pieces progress bar downloaded_pieces = new DownloadedPiecesBar(this); ProgressHLayout->insertWidget(1, downloaded_pieces); // Pieces availability bar pieces_availability = new PieceAvailabilityBar(this); ProgressHLayout_2->insertWidget(1, pieces_availability); // Tracker list trackerList = new TrackerList(this); connect(trackerUpButton, SIGNAL(clicked()), trackerList, SLOT(moveSelectionUp())); connect(trackerDownButton, SIGNAL(clicked()), trackerList, SLOT(moveSelectionDown())); horizontalLayout_trackers->insertWidget(0, trackerList); connect(trackerList->header(), SIGNAL(sectionMoved(int, int, int)), trackerList, SLOT(saveSettings())); connect(trackerList->header(), SIGNAL(sectionResized(int, int, int)), trackerList, SLOT(saveSettings())); connect(trackerList->header(), SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), trackerList, SLOT(saveSettings())); // Peers list peersList = new PeerListWidget(this); peerpage_layout->addWidget(peersList); connect(peersList->header(), SIGNAL(sectionMoved(int, int, int)), peersList, SLOT(saveSettings())); connect(peersList->header(), SIGNAL(sectionResized(int, int, int)), peersList, SLOT(saveSettings())); connect(peersList->header(), SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)), peersList, SLOT(saveSettings())); // Speed widget speedWidget = new SpeedWidget(this); speed_layout->addWidget(speedWidget); // Tab bar m_tabBar = new PropTabBar(); verticalLayout->addLayout(m_tabBar); connect(m_tabBar, SIGNAL(tabChanged(int)), stackedProperties, SLOT(setCurrentIndex(int))); connect(m_tabBar, SIGNAL(tabChanged(int)), this, SLOT(saveSettings())); connect(m_tabBar, SIGNAL(visibilityToggled(bool)), SLOT(setVisibility(bool))); connect(m_tabBar, SIGNAL(visibilityToggled(bool)), this, SLOT(saveSettings())); // Dynamic data refresher refreshTimer = new QTimer(this); connect(refreshTimer, SIGNAL(timeout()), this, SLOT(loadDynamicData())); refreshTimer->start(3000); // 3sec editHotkeyFile = new QShortcut(QKeySequence("F2"), filesList, 0, 0, Qt::WidgetShortcut); connect(editHotkeyFile, SIGNAL(activated()), SLOT(renameSelectedFile())); editHotkeyWeb = new QShortcut(QKeySequence("F2"), listWebSeeds, 0, 0, Qt::WidgetShortcut); connect(editHotkeyWeb, SIGNAL(activated()), SLOT(editWebSeed())); connect(listWebSeeds, SIGNAL(doubleClicked(QModelIndex)), SLOT(editWebSeed())); deleteHotkeyWeb = new QShortcut(QKeySequence(QKeySequence::Delete), listWebSeeds, 0, 0, Qt::WidgetShortcut); connect(deleteHotkeyWeb, SIGNAL(activated()), SLOT(deleteSelectedUrlSeeds())); openHotkeyFile = new QShortcut(QKeySequence("Return"), filesList, 0, 0, Qt::WidgetShortcut); connect(openHotkeyFile, SIGNAL(activated()), SLOT(openSelectedFile())); }
void TranslationLine::focusInEvent(QFocusEvent *e) { QTextEdit::focusInEvent(e); selectAll(); }
void MainWindow::createActions() { newAction = new QAction(tr("&New"), this); newAction->setIcon(QIcon(":/images/new.png")); newAction->setShortcut(tr("Ctrl+N")); newAction->setStatusTip(tr("Create a new spreadsheet file")); connect(newAction, SIGNAL(triggered()), this, SLOT(newFile())); openAction = new QAction(tr("&Open..."), this); openAction->setIcon(QIcon(":/images/open.png")); openAction->setShortcut(tr("Ctrl+O")); openAction->setStatusTip(tr("Open an existing spreadsheet file")); connect(openAction, SIGNAL(triggered()), this, SLOT(open())); saveAction = new QAction(tr("&Save"), this); saveAction->setIcon(QIcon(":/images/save.png")); saveAction->setShortcut(tr("Ctrl+S")); saveAction->setStatusTip(tr("Save the spreadsheet to disk")); connect(saveAction, SIGNAL(triggered()), this, SLOT(save())); saveAsAction = new QAction(tr("Save &As..."), this); saveAsAction->setStatusTip(tr("Save the spreadsheet under a new " "name")); connect(saveAsAction, SIGNAL(triggered()), this, SLOT(saveAs())); for (int i = 0; i < MaxRecentFiles; ++i) { recentFileActions[i] = new QAction(this); recentFileActions[i]->setVisible(false); connect(recentFileActions[i], SIGNAL(triggered()), this, SLOT(openRecentFile())); } exitAction = new QAction(tr("E&xit"), this); exitAction->setShortcut(tr("Ctrl+Q")); exitAction->setStatusTip(tr("Exit the application")); connect(exitAction, SIGNAL(triggered()), this, SLOT(close())); cutAction = new QAction(tr("Cu&t"), this); cutAction->setIcon(QIcon(":/images/cut.png")); cutAction->setShortcut(tr("Ctrl+X")); cutAction->setStatusTip(tr("Cut the current selection's contents " "to the clipboard")); connect(cutAction, SIGNAL(triggered()), spreadsheet, SLOT(cut())); copyAction = new QAction(tr("&Copy"), this); copyAction->setIcon(QIcon(":/images/copy.png")); copyAction->setShortcut(tr("Ctrl+C")); copyAction->setStatusTip(tr("Copy the current selection's contents " "to the clipboard")); connect(copyAction, SIGNAL(triggered()), spreadsheet, SLOT(copy())); pasteAction = new QAction(tr("&Paste"), this); pasteAction->setIcon(QIcon(":/images/paste.png")); pasteAction->setShortcut(tr("Ctrl+V")); pasteAction->setStatusTip(tr("Paste the clipboard's contents into " "the current selection")); connect(pasteAction, SIGNAL(triggered()), spreadsheet, SLOT(paste())); deleteAction = new QAction(tr("&Delete"), this); deleteAction->setShortcut(tr("Del")); deleteAction->setStatusTip(tr("Delete the current selection's " "contents")); connect(deleteAction, SIGNAL(triggered()), spreadsheet, SLOT(del())); selectRowAction = new QAction(tr("&Row"), this); selectRowAction->setStatusTip(tr("Select all the cells in the " "current row")); connect(selectRowAction, SIGNAL(triggered()), spreadsheet, SLOT(selectCurrentRow())); selectColumnAction = new QAction(tr("&Column"), this); selectColumnAction->setStatusTip(tr("Select all the cells in the " "current column")); connect(selectColumnAction, SIGNAL(triggered()), spreadsheet, SLOT(selectCurrentColumn())); selectAllAction = new QAction(tr("&All"), this); selectAllAction->setShortcut(tr("Ctrl+A")); selectAllAction->setStatusTip(tr("Select all the cells in the " "spreadsheet")); connect(selectAllAction, SIGNAL(triggered()), spreadsheet, SLOT(selectAll())); findAction = new QAction(tr("&Find..."), this); findAction->setIcon(QIcon(":/images/find.png")); findAction->setShortcut(tr("Ctrl+F")); findAction->setStatusTip(tr("Find a matching cell")); connect(findAction, SIGNAL(triggered()), this, SLOT(find())); goToCellAction = new QAction(tr("&Go to Cell..."), this); goToCellAction->setIcon(QIcon(":/images/gotocell.png")); goToCellAction->setShortcut(tr("F5")); goToCellAction->setStatusTip(tr("Go to the specified cell")); connect(goToCellAction, SIGNAL(triggered()), this, SLOT(goToCell())); recalculateAction = new QAction(tr("&Recalculate"), this); recalculateAction->setShortcut(tr("F9")); recalculateAction->setStatusTip(tr("Recalculate all the " "spreadsheet's formulas")); connect(recalculateAction, SIGNAL(triggered()), spreadsheet, SLOT(recalculate())); sortAction = new QAction(tr("&Sort..."), this); sortAction->setStatusTip(tr("Sort the selected cells or all the " "cells")); connect(sortAction, SIGNAL(triggered()), this, SLOT(sort())); showGridAction = new QAction(tr("&Show Grid"), this); showGridAction->setCheckable(true); showGridAction->setChecked(spreadsheet->showGrid()); showGridAction->setStatusTip(tr("Show or hide the spreadsheet's " "grid")); connect(showGridAction, SIGNAL(toggled(bool)), spreadsheet, SLOT(setShowGrid(bool))); #if QT_VERSION < 0x040102 // workaround for a QTableWidget bug in Qt 4.1.1 connect(showGridAction, SIGNAL(toggled(bool)), spreadsheet->viewport(), SLOT(update())); #endif autoRecalcAction = new QAction(tr("&Auto-Recalculate"), this); autoRecalcAction->setCheckable(true); autoRecalcAction->setChecked(spreadsheet->autoRecalculate()); autoRecalcAction->setStatusTip(tr("Switch auto-recalculation on or " "off")); connect(autoRecalcAction, SIGNAL(toggled(bool)), spreadsheet, SLOT(setAutoRecalculate(bool))); aboutAction = new QAction(tr("&About"), this); aboutAction->setStatusTip(tr("Show the application's About box")); connect(aboutAction, SIGNAL(triggered()), this, SLOT(about())); aboutQtAction = new QAction(tr("About &Qt"), this); aboutQtAction->setStatusTip(tr("Show the Qt library's About box")); connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); }
void Matrix::init(int rows, int cols) { formula_str = ""; selectedCol=0; LeftButton=FALSE; txt_format = 'f'; num_precision = 6; x_start = 1.0; x_end = 10.0; y_start = 1.0; y_end = 10.0; dMatrix = 0; QDateTime dt = QDateTime::currentDateTime (); setBirthDate(dt.toString(Qt::LocalDate)); d_table = new QTable (rows, cols, this, "d_table"); d_table->setFocusPolicy(QWidget::StrongFocus); d_table->setFocus(); d_table->setSelectionMode (QTable::Single); d_table->setRowMovingEnabled(true); /* //!TODO: enable column moving, right now it doesn't work because of the event filter //installed on hHeader d_table->setColumnMovingEnabled(true); connect(hHeader, SIGNAL(indexChange (int, int, int)), this, SLOT(notifyChanges())); */ QColor background = QColor(255, 255, 128); d_table->setPaletteBackgroundColor(background); d_table->setBackgroundColor(background); QVBoxLayout* hlayout = new QVBoxLayout(this,0,0); hlayout->addWidget(d_table); QHeader* hHeader=(QHeader*)d_table->horizontalHeader(); hHeader->installEventFilter(this); hHeader->setMouseTracking(TRUE); QHeader* vHeader=(QHeader*)d_table->verticalHeader(); vHeader->setResizeEnabled (false); vHeader->installEventFilter(this); int w, h; if (cols>3) w=3*hHeader->sectionSize(0); else w=cols*hHeader->sectionSize(0); if (rows>11) h=11*vHeader->sectionSize(0); else h=(rows+1)*vHeader->sectionSize(0); setGeometry(50,50,w+55,h); QAccel *accel = new QAccel(this); accel->connectItem( accel->insertItem( Key_Tab ), this, SLOT(moveCurrentCell())); accel->connectItem( accel->insertItem( CTRL+Key_A ), this, SLOT(selectAll())); connect(d_table, SIGNAL(valueChanged(int,int)), this, SLOT(cellEdited(int,int))); connect(vHeader, SIGNAL(indexChange (int, int, int)), this, SLOT(notifyChanges())); }
DlgPrepare::DlgPrepare(QWidget* parent, ConfigObject<ConfigValue>* pConfig, TrackCollection* pTrackCollection) : QWidget(parent), m_pConfig(pConfig), m_pTrackCollection(pTrackCollection), m_bAnalysisActive(false), m_tracksInQueue(0), m_currentTrack(0) { setupUi(this); m_songsButtonGroup.addButton(radioButtonRecentlyAdded); m_songsButtonGroup.addButton(radioButtonAllSongs); m_pPrepareLibraryTableView = new WPrepareLibraryTableView(this, pConfig, pTrackCollection); connect(m_pPrepareLibraryTableView, SIGNAL(loadTrack(TrackPointer)), this, SIGNAL(loadTrack(TrackPointer))); connect(m_pPrepareLibraryTableView, SIGNAL(loadTrackToPlayer(TrackPointer, QString)), this, SIGNAL(loadTrackToPlayer(TrackPointer, QString))); QBoxLayout* box = dynamic_cast<QBoxLayout*>(layout()); Q_ASSERT(box); //Assumes the form layout is a QVBox/QHBoxLayout! box->removeWidget(m_pTrackTablePlaceholder); m_pTrackTablePlaceholder->hide(); box->insertWidget(1, m_pPrepareLibraryTableView); m_pPrepareLibraryTableModel = new PrepareLibraryTableModel(this, pTrackCollection); m_pPrepareLibraryTableView->loadTrackModel(m_pPrepareLibraryTableModel); /* m_pCrateView = new CrateView(this, pTrackCollection); m_pPrepareCratesTableView = new WPrepareCratesTableView(this, pTrackCollection); box = dynamic_cast<QBoxLayout*>(horizontalLayoutCrates); Q_ASSERT(box); //Assumes the form layout is a QVBox/QHBoxLayout! box->removeWidget(m_pCratesViewPlaceholder); m_pCratesViewPlaceholder->hide(); //box->insertWidget(1, m_pPrepareCratesTableView); box->insertWidget(1, m_pCrateView); m_pCrateView->show(); m_pCratesTableModel = new QSqlTableModel(this); m_pCratesTableModel->setTable("crates"); m_pCratesTableModel->removeColumn(m_pCratesTableModel->fieldIndex("id")); m_pCratesTableModel->removeColumn(m_pCratesTableModel->fieldIndex("show")); m_pCratesTableModel->removeColumn(m_pCratesTableModel->fieldIndex("count")); m_pCratesTableModel->setSort(m_pCratesTableModel->fieldIndex("name"), Qt::AscendingOrder); m_pCratesTableModel->setFilter("show = 1"); m_pCratesTableModel->select(); while (m_pCratesTableModel->canFetchMore()) { m_pCratesTableModel->fetchMore(); } TransposeProxyModel* transposeProxy = new TransposeProxyModel(this); transposeProxy->setSourceModel(m_pCratesTableModel); m_pPrepareCratesTableView->setModel(m_pCratesTableModel); */ connect(radioButtonRecentlyAdded, SIGNAL(clicked()), this, SLOT(showRecentSongs())); connect(radioButtonAllSongs, SIGNAL(clicked()), this, SLOT(showAllSongs())); radioButtonRecentlyAdded->click(); labelProgress->setText(""); pushButtonAnalyze->setEnabled(false); connect(pushButtonAnalyze, SIGNAL(clicked()), this, SLOT(analyze())); connect(pushButtonSelectAll, SIGNAL(clicked()), this, SLOT(selectAll())); connect(m_pPrepareLibraryTableView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection&)), this, SLOT(tableSelectionChanged(const QItemSelection &, const QItemSelection&))); }
void AppEditMenu::setupMenu(QMenu *editMenu, QToolBar *toolbar) { toolbar->addSeparator(); editUndoAction=editMenu->addAction(IconUtil::getIcon("undo"), tr("&Undo"), this, SLOT(undo()), QKeySequence(QKeySequence::Undo)); editUndoAction->setStatusTip(tr("Undo last edit action")); toolbar->addAction(editUndoAction); editRedoAction=editMenu->addAction(IconUtil::getIcon("redo"), tr("&Redo"), this, SLOT(redo()), QKeySequence(QKeySequence::Redo)); editRedoAction->setStatusTip(tr("Redo last undone edit action")); toolbar->addAction(editRedoAction); editMenu->addSeparator(); toolbar->addSeparator(); editCutAction=editMenu->addAction(IconUtil::getIcon("editcut"), tr("Cu&t"), this, SLOT(cut()), QKeySequence(QKeySequence::Cut)); editCutAction->setStatusTip(tr("Cut")); toolbar->addAction(editCutAction); editCopyAction=editMenu->addAction(IconUtil::getIcon("editcopy"), tr("&Copy"), this, SLOT(copy()), QKeySequence(QKeySequence::Copy)); editCopyAction->setStatusTip(tr("Copy")); toolbar->addAction(editCopyAction); //editCopyAsAction=editMenu->addAction(IconUtil::getIcon("editcopy"), tr("Copy as")); //editCopyAsAction->setMenu(createCopyAsMenu(editMenu)); editPasteAction=editMenu->addAction(IconUtil::getIcon("editpaste"), tr("&Paste"), this, SLOT(paste()), QKeySequence(QKeySequence::Paste)); editPasteAction->setStatusTip(tr("Paste")); toolbar->addAction(editPasteAction); editMenu->addSeparator(); editSelectAllAction=editMenu->addAction(IconUtil::getIcon("editselectall"), tr("Select &All"), this, SLOT(selectAll()), QKeySequence(QKeySequence::SelectAll)); editSelectAllAction->setStatusTip(tr("Select All")); editMenu->addSeparator(); toolbar->addSeparator(); editAdvancedAction = editMenu->addAction(tr("Advanced")); createEditAdvancedMenu(toolbar); editAdvancedAction->setMenu(editAdvancedMenu); editMenu->addSeparator(); editDescribeAction=editMenu->addAction(tr("Describe object"), this, SLOT(describeObject()), QKeySequence("F4")); editResolveAction=editMenu->addAction(tr("Object Menu")); createEditResolveMenu(); editResolveAction->setMenu(editResolveMenu); editMenu->addSeparator(); //toolbar->addSeparator(); editIncreaseFontSize=editMenu->addAction(tr("Increase font size"), this, SLOT(increaseFont()), QKeySequence(QKeySequence::ZoomIn)); editIncreaseFontSize->setStatusTip(tr("Increase font size")); editDecreaseFontSize=editMenu->addAction(tr("Decrease font size"), this, SLOT(decreaseFont()), QKeySequence(QKeySequence::ZoomOut)); editDecreaseFontSize->setStatusTip(tr("Decrease font size")); editResetFontSize=editMenu->addAction(tr("Reset font size"), this, SLOT(resetFont()), QKeySequence(tr("Ctrl+0", "Edit|Reset font size"))); editResetFontSize->setStatusTip(tr("Reset font size")); editMenu->addSeparator(); toolbar->addSeparator(); editFindAction=editMenu->addAction(IconUtil::getIcon("find"), tr("&Find..."), this, SLOT(showSearchWidget()), QKeySequence("Ctrl+F")); editFindAction->setStatusTip(tr("Find text")); toolbar->addAction(editFindAction); editFindPreviousAction=editMenu->addAction(IconUtil::getIcon("find_prev"), tr("Find p&revious"), this, SLOT(findPrevious()), QKeySequence("Shift+F3")); editFindPreviousAction->setStatusTip(tr("Find previous occurence of current search text")); toolbar->addAction(editFindPreviousAction); editFindNextAction=editMenu->addAction(IconUtil::getIcon("find_next"), tr("Find &next"), this, SLOT(findNext()), QKeySequence("F3")); editFindNextAction->setStatusTip(tr("Find next occurence of current search text")); toolbar->addAction(editFindNextAction); editMenu->addSeparator(); editGoToLineAction=editMenu->addAction(IconUtil::getIcon("goto_line"), tr("&Go to line..."), this, SLOT(goToLine()), QKeySequence("Ctrl+G")); editGoToLineAction->setStatusTip(tr("Go to line")); connect(editResolveMenu, SIGNAL(aboutToShow()), this, SLOT(populateResolveMenu())); }
int Q3ListBox::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = Q3ScrollView::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: highlighted((*reinterpret_cast< int(*)>(_a[1]))); break; case 1: selected((*reinterpret_cast< int(*)>(_a[1]))); break; case 2: highlighted((*reinterpret_cast< const QString(*)>(_a[1]))); break; case 3: selected((*reinterpret_cast< const QString(*)>(_a[1]))); break; case 4: highlighted((*reinterpret_cast< Q3ListBoxItem*(*)>(_a[1]))); break; case 5: selected((*reinterpret_cast< Q3ListBoxItem*(*)>(_a[1]))); break; case 6: selectionChanged(); break; case 7: selectionChanged((*reinterpret_cast< Q3ListBoxItem*(*)>(_a[1]))); break; case 8: currentChanged((*reinterpret_cast< Q3ListBoxItem*(*)>(_a[1]))); break; case 9: clicked((*reinterpret_cast< Q3ListBoxItem*(*)>(_a[1]))); break; case 10: clicked((*reinterpret_cast< Q3ListBoxItem*(*)>(_a[1])),(*reinterpret_cast< const QPoint(*)>(_a[2]))); break; case 11: pressed((*reinterpret_cast< Q3ListBoxItem*(*)>(_a[1]))); break; case 12: pressed((*reinterpret_cast< Q3ListBoxItem*(*)>(_a[1])),(*reinterpret_cast< const QPoint(*)>(_a[2]))); break; case 13: doubleClicked((*reinterpret_cast< Q3ListBoxItem*(*)>(_a[1]))); break; case 14: returnPressed((*reinterpret_cast< Q3ListBoxItem*(*)>(_a[1]))); break; case 15: rightButtonClicked((*reinterpret_cast< Q3ListBoxItem*(*)>(_a[1])),(*reinterpret_cast< const QPoint(*)>(_a[2]))); break; case 16: rightButtonPressed((*reinterpret_cast< Q3ListBoxItem*(*)>(_a[1])),(*reinterpret_cast< const QPoint(*)>(_a[2]))); break; case 17: mouseButtonPressed((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< Q3ListBoxItem*(*)>(_a[2])),(*reinterpret_cast< const QPoint(*)>(_a[3]))); break; case 18: mouseButtonClicked((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< Q3ListBoxItem*(*)>(_a[2])),(*reinterpret_cast< const QPoint(*)>(_a[3]))); break; case 19: contextMenuRequested((*reinterpret_cast< Q3ListBoxItem*(*)>(_a[1])),(*reinterpret_cast< const QPoint(*)>(_a[2]))); break; case 20: onItem((*reinterpret_cast< Q3ListBoxItem*(*)>(_a[1]))); break; case 21: onViewport(); break; case 22: clear(); break; case 23: ensureCurrentVisible(); break; case 24: clearSelection(); break; case 25: selectAll((*reinterpret_cast< bool(*)>(_a[1]))); break; case 26: invertSelection(); break; case 27: clearInputString(); break; case 28: refreshSlot(); break; case 29: doAutoScroll(); break; case 30: adjustItems(); break; } _id -= 31; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< uint*>(_v) = count(); break; case 1: *reinterpret_cast< int*>(_v) = numItemsVisible(); break; case 2: *reinterpret_cast< int*>(_v) = currentItem(); break; case 3: *reinterpret_cast< QString*>(_v) = currentText(); break; case 4: *reinterpret_cast< int*>(_v) = topItem(); break; case 5: *reinterpret_cast< SelectionMode*>(_v) = selectionMode(); break; case 6: *reinterpret_cast< bool*>(_v) = isMultiSelection(); break; case 7: *reinterpret_cast< LayoutMode*>(_v) = columnMode(); break; case 8: *reinterpret_cast< LayoutMode*>(_v) = rowMode(); break; case 9: *reinterpret_cast< int*>(_v) = numColumns(); break; case 10: *reinterpret_cast< int*>(_v) = numRows(); break; case 11: *reinterpret_cast< bool*>(_v) = variableWidth(); break; case 12: *reinterpret_cast< bool*>(_v) = variableHeight(); break; } _id -= 13; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 2: setCurrentItem(*reinterpret_cast< int*>(_v)); break; case 4: setTopItem(*reinterpret_cast< int*>(_v)); break; case 5: setSelectionMode(*reinterpret_cast< SelectionMode*>(_v)); break; case 6: setMultiSelection(*reinterpret_cast< bool*>(_v)); break; case 7: setColumnMode(*reinterpret_cast< LayoutMode*>(_v)); break; case 8: setRowMode(*reinterpret_cast< LayoutMode*>(_v)); break; case 11: setVariableWidth(*reinterpret_cast< bool*>(_v)); break; case 12: setVariableHeight(*reinterpret_cast< bool*>(_v)); break; } _id -= 13; } else if (_c == QMetaObject::ResetProperty) { _id -= 13; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 13; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 13; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 13; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 13; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 13; } #endif // QT_NO_PROPERTIES return _id; }
void CLineEdit::dropEvent(QDropEvent* a_pEvent) { qDebug("call dropEvent"); qDebug()<<a_pEvent->mimeData()->formats(); if(a_pEvent->mimeData()->hasFormat("text/uri-list")) { QList<QUrl> urls = a_pEvent->mimeData()->urls(); for(QUrl currentUrl : urls) { QString path = currentUrl.toLocalFile(); qDebug() << path; // selectAll(); // insert(path); QFileInfo newFile(path); if(newFile.exists()) { // if(m_lExtensionList.contains(newFile.suffix())) if (ETypes::TypeFromExtension(newFile.suffix()) == m_eType) { qDebug("accepted format"); // Checking if file is in project path // if(path.contains(QDir::currentPath())) QString projectPath = CProjectManager::Instance()->QGetProjectPath(); if (path.contains(projectPath)) { path.replace(projectPath+'/', ""); selectAll(); insert(path); // this->setText(path); } else { qDebug("File not in project path"); } } else { qDebug("refused format"); } } } } else if (a_pEvent->mimeData()->hasFormat("text/plain")) { QString macro = a_pEvent->mimeData()->text(); if (macro.at(0) == '#') { QStringList list = macro.split(':'); QString type = list.takeLast(); if (ETypes::TypeFromString(type) == m_eType) { QString name = list.join(""); if (LM::CMacroManager::Instance()->GetDefinition(name.toStdString()).empty()) { QMessageBox msgBox; msgBox.setText(tr("Ajout impossible : la macro ne contient pas de définition.")); msgBox.setStandardButtons(QMessageBox::Ok); msgBox.setDefaultButton(QMessageBox::Ok); msgBox.setIcon(QMessageBox::Warning); int ret = msgBox.exec(); } else { selectAll(); insert(name); } } } } else { qDebug("No file was droped"); } }
void MainWindow::createActions() { newAction = new QAction(tr("&New"), this); newAction->setIcon(QIcon(":/images/new.png")); newAction->setShortcut(QKeySequence::New); newAction->setStatusTip(tr("Create a new spreadsheet file")); connect(newAction, SIGNAL(triggered()), this, SLOT(newFile())); openAction = new QAction(tr("&Open..."), this); openAction->setIcon(QIcon(":/images/open.png")); openAction->setShortcut(QKeySequence::Open); openAction->setStatusTip(tr("Open an existing spreadsheet file")); connect(openAction, SIGNAL(triggered()), this, SLOT(open())); saveAction = new QAction(tr("&Save"), this); saveAction->setIcon(QIcon(":/images/save.png")); saveAction->setShortcut(QKeySequence::Save); saveAction->setStatusTip(tr("Save the spreadsheet to disk")); connect(saveAction, SIGNAL(triggered()), this, SLOT(save())); saveAsAction = new QAction(tr("Save &As..."), this); saveAsAction->setStatusTip(tr("Save the spreadsheet under a new " "name")); connect(saveAsAction, SIGNAL(triggered()), this, SLOT(saveAs())); for (int i = 0; i < MaxRecentFiles; ++i) { recentFileActions[i] = new QAction(this); recentFileActions[i]->setVisible(false); connect(recentFileActions[i], SIGNAL(triggered()), this, SLOT(openRecentFile())); } closeAction = new QAction(tr("&Close"), this); closeAction->setShortcut(QKeySequence::Close); closeAction->setStatusTip(tr("Close this window")); connect(closeAction, SIGNAL(triggered()), this, SLOT(close())); exitAction = new QAction(tr("E&xit"), this); exitAction->setShortcut(tr("Ctrl+Q")); exitAction->setStatusTip(tr("Exit the application")); connect(exitAction, SIGNAL(triggered()), qApp, SLOT(closeAllWindows())); selectAllAction = new QAction(tr("&All"), this); selectAllAction->setShortcut(QKeySequence::SelectAll); selectAllAction->setStatusTip(tr("Select all the cells in the spreadsheet")); connect(selectAllAction, SIGNAL(triggered()), spreadsheet, SLOT(selectAll())); showGridAction = new QAction(tr("&Show Grid"), this); showGridAction->setCheckable(true); showGridAction->setChecked(spreadsheet->showGrid()); showGridAction->setStatusTip(tr("Show or hide the spreadsheet's grid")); connect(showGridAction, SIGNAL(toggled(bool)), spreadsheet, SLOT(setShowGrid(bool))); aboutQtAction = new QAction(tr("About &Qt"), this); aboutQtAction->setStatusTip(tr("Show the Qt library's About box")); connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); }
QgsPluginManager::QgsPluginManager( QgsPythonUtils* pythonUtils, QWidget * parent, Qt::WFlags fl ) : QDialog( parent, fl ) { setupUi( this ); mPythonUtils = pythonUtils; // set the default lib dir to the qgis install directory/lib (this info is // available from the provider registry so we use it here) QgsProviderRegistry *pr = QgsProviderRegistry::instance(); /* char **argv = qApp->argv(); QString appDir = argv[0]; int bin = appDir.findRev("/bin", -1, false); QString baseDir = appDir.left(bin); QString libDir = baseDir + "/lib"; */ lblPluginDir->setText( pr->libraryDirectory().path() ); setTable(); getPluginDescriptions(); getPythonPluginDescriptions(); mModelProxy->sort( 0, Qt::AscendingOrder ); // // Create the select all and clear all buttons and add them to the // buttonBox // QPushButton * btnSelectAll = new QPushButton( tr( "&Select All" ) ); QPushButton * btnClearAll = new QPushButton( tr( "&Clear All" ) ); buttonBox->addButton( btnSelectAll, QDialogButtonBox::ActionRole ); buttonBox->addButton( btnClearAll, QDialogButtonBox::ActionRole ); // connect the slot up to catch when a bookmark is deleted connect( btnSelectAll, SIGNAL( clicked() ), this, SLOT( selectAll() ) ); // connect the slot up to catch when a bookmark is zoomed to connect( btnClearAll, SIGNAL( clicked() ), this, SLOT( clearAll() ) ); leFilter->setFocus( Qt::MouseFocusReason ); qRegisterMetaType<QgsDetailedItemData>(); // disable plugin installer button for now until we resolve some problems [MD] btnPluginInstaller->hide(); #if 0 // add installer's icon QString myCurThemePath = QgsApplication::activeThemePath() + "/plugins/plugin_installer.png"; QString myDefThemePath = QgsApplication::defaultThemePath() + "/plugins/plugin_installer.png"; if ( QFile::exists( myCurThemePath ) ) { btnPluginInstaller->setIcon( QIcon( myCurThemePath ) ); } else if ( QFile::exists( myDefThemePath ) ) { btnPluginInstaller->setIcon( QIcon( myDefThemePath ) ); } // check for plugin installer if ( checkForPluginInstaller() ) { connect( btnPluginInstaller, SIGNAL( clicked() ), this, SLOT( showPluginInstaller() ) ); } else { btnPluginInstaller->setEnabled( false ); } #endif }
void KexiComboBoxTableEdit::selectAllInInternalEditor() { selectAll(); }
} void CMainFrame::OnEditPaste() { TextView *view = getActiveTextView(); if(view == NULL) { return; } const String t = getClipboardText(); CWinDiffDoc *doc = view->getDocument(); doc->setDoc(view->getId(),DIFFDOC_BUF,t); view->refreshBoth(); } void CMainFrame::OnEditSelectAll() { APPLY_TO_ACTIVE_TEXTVIEW(selectAll()) } void CMainFrame::OnEditFind() { if(!isToolbarButtonEnabled(ID_EDIT_FIND)) { return; } CWinDiffView *view = getActiveDiffView(); if(view) { TextView &tv = view->m_textView; if(tv.hasSelection() && (tv.getSelectedRange().getLineCount() == 1)) { m_findParameters.m_findWhat = tv.getSelectedText(); } else { m_findParameters.m_findWhat = tv.getCurrentWord(); } CFindDlg dlg(m_findParameters, view);
void ExprShortTextEdit::keyPressEvent(QKeyEvent* e) { // If the completer is active pass keys it needs down if (completer && completer->popup()->isVisible()) { switch (e->key()) { case Qt::Key_Enter: case Qt::Key_Return: case Qt::Key_Escape: case Qt::Key_Tab: case Qt::Key_Backtab: e->ignore(); return; default: break; } } // Accept expression if (e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) { selectAll(); finishEdit(); return; } else if (e->key() == Qt::Key_Escape) { setText(savedText); selectAll(); finishEdit(); return; } else if (e->key() == Qt::Key_Tab) { QWidget::keyPressEvent(e); return; } else if (!editing) { editing = true; setColor(true); savedText = toPlainText(); } // use the values here as long as we are not using the shortcut to bring up the editor bool isShortcut = ((e->modifiers() & Qt::ControlModifier) && e->key() == Qt::Key_E); // CTRL+E if (!isShortcut) // dont process the shortcut when we have a completer QTextEdit::keyPressEvent(e); const bool ctrlOrShift = e->modifiers() & (Qt::ControlModifier | Qt::ShiftModifier); if (!completer || (ctrlOrShift && e->text().isEmpty())) return; bool hasModifier = (e->modifiers() != Qt::NoModifier) && !ctrlOrShift; // grab the line we're on QTextCursor tc = textCursor(); tc.movePosition(QTextCursor::StartOfLine, QTextCursor::KeepAnchor); QString line = tc.selectedText(); // matches the last prefix of a completable variable or function and extract as completionPrefix static QRegExp completion("^(?:.*[^A-Za-z0-9_$])?((?:\\$[A-Za-z0-9_]*)|[A-Za-z]+[A-Za-z0-9_]*)$"); int index = completion.indexIn(line); QString completionPrefix; if (index != -1 && !line.contains('#')) { completionPrefix = completion.cap(1); // std::cout<<"we have completer prefix '"<<completionPrefix.toStdString()<<"'"<<std::endl; } // hide the completer if we have too few characters, we are at end of word if (!isShortcut && (hasModifier || e->text().isEmpty() || completionPrefix.length() < 1 || index == -1)) { completer->popup()->hide(); } else { // copy the completion prefix in if we don't already have it in the completer if (completionPrefix != completer->completionPrefix()) { completer->setCompletionPrefix(completionPrefix); completer->popup()->setCurrentIndex(completer->completionModel()->index(0, 0)); } // display the completer QRect cr = cursorRect(); cr.setWidth(2 * (completer->popup()->sizeHintForColumn(0) + completer->popup()->sizeHintForColumn(1) + completer->popup()->verticalScrollBar()->sizeHint().width())); completer->complete(cr); hideTip(); return; } // documentation completion static QRegExp inFunction("^(?:.*[^A-Za-z0-9_$])?([A-Za-z0-9_]+)\\([^()]*$"); int index2 = inFunction.indexIn(line); if (index2 != -1) { QString functionName = inFunction.cap(1); QStringList tips = completionModel->getDocString(functionName).split("\n"); QString tip = "<b>" + tips[0] + "</b>"; for (int i = 1; i < tips.size(); i++) { tip += "<br>" + tips[i]; } showTip(tip); } else { hideTip(); } }
void DuplicateMerger::selectAll() { selectAll(true); }
void MainWindow::initMenus() { /*Create Actions*/ newFileAction=new QAction(tr("&New"), this); newFileAction->setToolTip("Create a new file"); newFileAction->setStatusTip("New Document"); newFileAction->setIcon(QIcon(":/images/filenew.png")); newFileAction->setShortcut(QKeySequence("Ctrl+N")); newFileAction->showStatusText(this->statusBar()); // newFileAction->setShortcutContext(Qt::ShortcutContext); openFileAction=new QAction(tr("O&pen"), this); openFileAction->setToolTip("Open an existing file"); openFileAction->setIcon(QIcon(":/images/fileopen.png")); openFileAction->setShortcut(QKeySequence("Ctrl+O")); saveFileAction=new QAction(tr("&Save"), this); saveFileAction->setToolTip("Save current file"); saveFileAction->setIcon(QIcon(":/images/filesave.png")); saveAsFileAction=new QAction(tr("Save &As"), this); saveAsFileAction->setIcon(QIcon(":/images/filesaveas.png")); exitFileAction=new QAction(tr("E&xit"),this); exitFileAction->setToolTip("Exit the Application"); exitFileAction->setIcon(QIcon(":/images/fileexit.png")); copyEditAction=new QAction(tr("&Copy"), this); copyEditAction->setToolTip("Copy"); copyEditAction->setIcon(QIcon(":/images/editcopy.png")); pasteEditAction=new QAction(tr("P&aste"), this); pasteEditAction->setToolTip("Paste"); pasteEditAction->setIcon(QIcon(":/images/editpaste.png")); fontEditAction=new QAction(tr("F&ont"), this); fontEditAction->setToolTip("Change Font"); fontEditAction->setIcon(QIcon(":/images/editfont.png")); cutEditAction=new QAction(tr("C&ut"), this); cutEditAction->setToolTip("Cut"); cutEditAction->setIcon(QIcon(":/images/editcut.png")); toolEditAction=new QAction(tr("Tool &Bar"),this); toolEditAction->setIcon(QIcon(":/images/edittool.png")); selectEditAction=new QAction(tr("Select All"),this); selectEditAction->setIcon(QIcon(":/images/editselect.png")); aboutHelpAction=new QAction(tr("&About"), this); aboutHelpAction->setToolTip("About this application"); aboutHelpAction->setIcon(QIcon(":/images/helpabout.png")); /*Connections*/ connect(fontEditAction,SIGNAL(triggered()),this,SLOT(changeFont())); connect(exitFileAction,SIGNAL(triggered()),this,SLOT(close())); connect(aboutHelpAction,SIGNAL(triggered()),this,SLOT(aboutMe())); connect(copyEditAction,SIGNAL(triggered()),textArea,SLOT(copy())); connect(cutEditAction,SIGNAL(triggered()),textArea,SLOT(cut())); connect(pasteEditAction,SIGNAL(triggered()),textArea,SLOT(paste())); connect(selectEditAction,SIGNAL(triggered()),textArea,SLOT(selectAll())); connect(openFileAction,SIGNAL(triggered()),this,SLOT(openFileSlot())); connect(saveFileAction,SIGNAL(triggered()),this,SLOT(saveFileSlot())); connect(newFileAction,SIGNAL(triggered()),this,SLOT(newFileSlot())); connect(saveAsFileAction,SIGNAL(triggered()),this,SLOT(saveAsFileSlot())); connect(textArea,SIGNAL(textChanged()),this,SLOT(isModified())); connect(textArea,SIGNAL(pasteAvailable(bool)),pasteEditAction,SLOT(setEnabled(bool))); toolEditAction->setCheckable(true); toolEditAction->setChecked(true); /*Menu Init*/ fileMenu = menuBar()->addMenu(tr("&File")); //fileMenu->setStyle(); fileMenu->addAction(newFileAction); fileMenu->addAction(openFileAction); fileMenu->addAction(saveFileAction); fileMenu->addAction(saveAsFileAction); fileMenu->addAction(exitFileAction); /*---*/ editMenu = menuBar()->addMenu(tr("&Edit")); editMenu->addAction(cutEditAction); editMenu->addAction(copyEditAction); editMenu->addAction(pasteEditAction); editMenu->addAction(selectEditAction); editMenu->addSeparator(); editMenu->addAction(fontEditAction); editMenu->addAction(toolEditAction); /*---*/ helpMenu = menuBar()->addMenu(tr("&Help")); helpMenu->addAction(aboutHelpAction); }
bool AddressWidget::eventFilter(QObject *object, QEvent *event) { if (object == m_bookmarkLabel && m_bookmarkLabel && event->type() == QEvent::MouseButtonPress) { QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event); if (mouseEvent && mouseEvent->button() == Qt::LeftButton) { if (m_bookmarkLabel->isEnabled()) { if (BookmarksManager::hasBookmark(getUrl())) { BookmarksManager::deleteBookmark(getUrl()); } else { BookmarkInformation *bookmark = new BookmarkInformation(); bookmark->url = getUrl().toString(QUrl::RemovePassword); bookmark->title = m_window->getTitle(); bookmark->type = UrlBookmark; BookmarkPropertiesDialog dialog(bookmark, -1, this); if (dialog.exec() == QDialog::Rejected) { delete bookmark; } } updateBookmark(); } return true; } } if (object != this && event->type() == QEvent::ContextMenu) { QContextMenuEvent *contextMenuEvent = static_cast<QContextMenuEvent*>(event); if (contextMenuEvent) { QMenu menu(this); QAction *action = menu.addAction(tr("Remove This Icon"), this, SLOT(removeIcon())); action->setData(object->objectName()); menu.exec(contextMenuEvent->globalPos()); contextMenuEvent->accept(); return true; } } if (object == this && event->type() == QEvent::KeyPress && m_window) { QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event); if (keyEvent->key() == Qt::Key_Escape) { const QUrl url = m_window->getUrl(); if (text().trimmed().isEmpty() || text().trimmed() != url.toString()) { setText((url.scheme() == QLatin1String("about") && m_window->isUrlEmpty()) ? QString() : url.toString()); if (!text().trimmed().isEmpty() && SettingsManager::getValue(QLatin1String("AddressField/SelectAllOnFocus")).toBool()) { QTimer::singleShot(0, this, SLOT(selectAll())); } } else { m_window->setFocus(); } } } return QLineEdit::eventFilter(object, event); }
ArrayList *selectAllFromTable(TableManager *tm, char *tableName) { SelectionHandler *sh = getSelectionHandler(tm, tableName); return selectAll(sh); }
void EditableTextComponent::keyTyped(const KeyEventUnrecPtr e) { if(getEnabled() && getEditable() && !(e->getModifiers() &( KeyEvent::KEY_MODIFIER_ALT | KeyEvent::KEY_MODIFIER_CONTROL | KeyEvent::KEY_MODIFIER_META ))) { if(e->getKeyChar()>31 && e->getKeyChar() < 127) { if(hasSelection()) { deleteSelectedText(); setCaretPosition(_TextSelectionStart); } insert(std::string( 1,e->getKeyChar() ), _TextSelectionStart); _TextSelectionStart = getCaretPosition(); _TextSelectionEnd = _TextSelectionStart; } if(e->getKey()== e->KEY_BACK_SPACE) { if(hasSelection()) { deleteSelectedText(); } else { //erase at the current caret position Int32 DeleteIndex(getCaretPosition()); moveCaret(-1); deleteRange(DeleteIndex-1, DeleteIndex); } } if(e->getKey()== e->KEY_DELETE) { if(hasSelection()) { deleteSelectedText(); } else if(getText().size()>0) { //erase at the current caret position deleteRange(getCaretPosition(), getCaretPosition()+1); _TextSelectionStart = getCaretPosition(); _TextSelectionEnd = _TextSelectionStart; } } } switch(e->getKey()) { case KeyEvent::KEY_RIGHT: case KeyEvent::KEY_KEYPAD_RIGHT: moveCaret(1); break; case KeyEvent::KEY_LEFT: case KeyEvent::KEY_KEYPAD_LEFT: moveCaret(-1); break; case KeyEvent::KEY_V: if(e->getModifiers() & KeyEvent::KEY_MODIFIER_CONTROL) { paste(); } break; case KeyEvent::KEY_C: if(e->getModifiers() & KeyEvent::KEY_MODIFIER_CONTROL) { copy(); } break; case KeyEvent::KEY_X: if(e->getModifiers() & KeyEvent::KEY_MODIFIER_CONTROL) { cut(); } break; case KeyEvent::KEY_A: if(e->getModifiers() & KeyEvent::KEY_MODIFIER_CONTROL) { selectAll(); } break; } Inherited::keyTyped(e); }
KexiFormView::KexiFormView(QWidget *parent, bool dbAware) : KexiDataAwareView(parent) , d(new Private) { Q_UNUSED(dbAware); d->delayedFormContentsResizeOnShow = 0; //! @todo remove? setSortedProperties(true); d->scrollView = new KexiFormScrollView( // will be added to layout this, viewMode() == Kexi::DataViewMode); // in KexiDataAwareView::init() initForm(); if (viewMode() == Kexi::DesignViewMode) { connect(form(), SIGNAL(propertySetSwitched()), this, SLOT(slotPropertySetSwitched())); connect(form(), SIGNAL(modified(bool)), this, SLOT(setDirty(bool))); connect(d->scrollView, SIGNAL(resized()), this, SLOT(setFormModified())); connect(d->dbform, SIGNAL(handleDragMoveEvent(QDragMoveEvent*)), this, SLOT(slotHandleDragMoveEvent(QDragMoveEvent*))); connect(d->dbform, SIGNAL(handleDropEvent(QDropEvent*)), this, SLOT(slotHandleDropEvent(QDropEvent*))); // action stuff plugSharedAction("formpart_taborder", form(), SLOT(editTabOrder())); plugSharedAction("formpart_adjust_size", form(), SLOT(adjustWidgetSize())); //! @todo add formpart_pixmap_collection action //! @todo add formpart_connections action plugSharedAction("edit_copy", form(), SLOT(copyWidget())); plugSharedAction("edit_cut", form(), SLOT(cutWidget())); plugSharedAction("edit_paste", form(), SLOT(pasteWidget())); plugSharedAction("edit_delete", form(), SLOT(deleteWidget())); plugSharedAction("edit_select_all", form(), SLOT(selectAll())); plugSharedAction("formpart_clear_contents", form(), SLOT(clearWidgetContent())); plugSharedAction("edit_undo", form(), SLOT(undo())); plugSharedAction("edit_redo", form(), SLOT(redo())); plugSharedAction("formpart_format_raise", form(), SLOT(bringWidgetToFront())); plugSharedAction("formpart_format_lower", form(), SLOT(sendWidgetToBack())); plugSharedAction("other_widgets_menu", form(), 0); setAvailable("other_widgets_menu", true); plugSharedAction("formpart_align_menu", form(), 0); plugSharedAction("formpart_align_to_left", form(), SLOT(alignWidgetsToLeft())); plugSharedAction("formpart_align_to_right", form(), SLOT(alignWidgetsToRight())); plugSharedAction("formpart_align_to_top", form(), SLOT(alignWidgetsToTop())); plugSharedAction("formpart_align_to_bottom", form(), SLOT(alignWidgetsToBottom())); plugSharedAction("formpart_align_to_grid", form(), SLOT(alignWidgetsToGrid())); plugSharedAction("formpart_adjust_size_menu", form(), 0); plugSharedAction("formpart_adjust_to_fit", form(), SLOT(adjustWidgetSize())); plugSharedAction("formpart_adjust_size_grid", form(), SLOT(adjustSizeToGrid())); plugSharedAction("formpart_adjust_height_small", form(), SLOT(adjustHeightToSmall())); plugSharedAction("formpart_adjust_height_big", form(), SLOT(adjustHeightToBig())); plugSharedAction("formpart_adjust_width_small", form(), SLOT(adjustWidthToSmall())); plugSharedAction("formpart_adjust_width_big", form(), SLOT(adjustWidthToBig())); plugSharedAction("format_font", form(), SLOT(changeFont())); // - setup local actions QList<QAction*> viewActions; QAction* a; a = form()->action("edit_undo"); a->setProperty("iconOnly", true); viewActions << a; a = form()->action("edit_redo"); a->setProperty("iconOnly", true); viewActions << a; setViewActions(viewActions); }
void LiteEditor::createActions() { LiteApi::IActionContext *actionContext = m_liteApp->actionManager()->getActionContext(this,"Editor"); m_undoAct = new QAction(QIcon("icon:liteeditor/images/undo.png"),tr("Undo"),this); actionContext->regAction(m_undoAct,"Undo",QKeySequence::Undo); m_redoAct = new QAction(QIcon("icon:liteeditor/images/redo.png"),tr("Redo"),this); actionContext->regAction(m_redoAct,"Redo","Ctrl+Shift+Z; Ctrl+Y"); m_cutAct = new QAction(QIcon("icon:liteeditor/images/cut.png"),tr("Cut"),this); actionContext->regAction(m_cutAct,"Cut",QKeySequence::Cut); m_copyAct = new QAction(QIcon("icon:liteeditor/images/copy.png"),tr("Copy"),this); actionContext->regAction(m_copyAct,"Copy",QKeySequence::Copy); m_pasteAct = new QAction(QIcon("icon:liteeditor/images/paste.png"),tr("Paste"),this); actionContext->regAction(m_pasteAct,"Paste",QKeySequence::Paste); m_selectAllAct = new QAction(tr("Select All"),this); actionContext->regAction(m_selectAllAct,"SelectAll",QKeySequence::SelectAll); m_exportHtmlAct = new QAction(QIcon("icon:liteeditor/images/exporthtml.png"),tr("Export HTML..."),this); #ifndef QT_NO_PRINTER m_exportPdfAct = new QAction(QIcon("icon:liteeditor/images/exportpdf.png"),tr("Export PDF..."),this); m_filePrintAct = new QAction(QIcon("icon:liteeditor/images/fileprint.png"),tr("Print..."),this); m_filePrintPreviewAct = new QAction(QIcon("icon:liteeditor/images/fileprintpreview.png"),tr("Print Preview..."),this); #endif m_gotoPrevBlockAct = new QAction(tr("Go To Previous Block"),this); actionContext->regAction(m_gotoPrevBlockAct,"GotoPreviousBlock","Ctrl+["); m_gotoNextBlockAct = new QAction(tr("Go To Next Block"),this); actionContext->regAction(m_gotoNextBlockAct,"GotoNextBlock","Ctrl+]"); m_selectBlockAct = new QAction(tr("Select Block"),this); actionContext->regAction(m_selectBlockAct,"SelectBlock","Ctrl+U"); m_gotoMatchBraceAct = new QAction(tr("Go To Matching Brace"),this); actionContext->regAction(m_gotoMatchBraceAct,"GotoMatchBrace","Ctrl+E"); m_foldAct = new QAction(tr("Fold"),this); actionContext->regAction(m_foldAct,"Fold","Ctrl+<"); m_unfoldAct = new QAction(tr("Unfold"),this); actionContext->regAction(m_unfoldAct,"Unfold","Ctrl+>"); m_foldAllAct = new QAction(tr("Fold All"),this); actionContext->regAction(m_foldAllAct,"FoldAll",""); m_unfoldAllAct = new QAction(tr("Unfold All"),this); actionContext->regAction(m_unfoldAllAct,"UnfoldAll",""); connect(m_foldAct,SIGNAL(triggered()),m_editorWidget,SLOT(fold())); connect(m_unfoldAct,SIGNAL(triggered()),m_editorWidget,SLOT(unfold())); connect(m_foldAllAct,SIGNAL(triggered()),m_editorWidget,SLOT(foldAll())); connect(m_unfoldAllAct,SIGNAL(triggered()),m_editorWidget,SLOT(unfoldAll())); m_gotoLineAct = new QAction(tr("Go To Line"),this); actionContext->regAction(m_gotoLineAct,"GotoLine","Ctrl+L"); m_lockAct = new QAction(QIcon("icon:liteeditor/images/lock.png"),tr("Locked"),this); m_lockAct->setEnabled(false); m_duplicateAct = new QAction(tr("Duplicate"),this); actionContext->regAction(m_duplicateAct,"Duplicate","Ctrl+D"); connect(m_duplicateAct,SIGNAL(triggered()),m_editorWidget,SLOT(duplicate())); m_deleteLineAct = new QAction(tr("Delete Line"),this); actionContext->regAction(m_deleteLineAct,"DeleteLine","Ctrl+Shift+K"); connect(m_deleteLineAct,SIGNAL(triggered()),m_editorWidget,SLOT(deleteLine())); m_insertLineBeforeAct = new QAction(tr("Insert Line Before"),this); actionContext->regAction(m_insertLineBeforeAct,"InsertLineBefore","Ctrl+Shift+Return"); connect(m_insertLineBeforeAct,SIGNAL(triggered()),m_editorWidget,SLOT(insertLineBefore())); m_insertLineAfterAct = new QAction(tr("Insert Line After"),this); actionContext->regAction(m_insertLineAfterAct,"InsertLineAfter","Ctrl+Return"); connect(m_insertLineAfterAct,SIGNAL(triggered()),m_editorWidget,SLOT(insertLineAfter())); m_increaseFontSizeAct = new QAction(tr("Increase Font Size"),this); actionContext->regAction(m_increaseFontSizeAct,"IncreaseFontSize","Ctrl++;Ctrl+="); m_decreaseFontSizeAct = new QAction(tr("Decrease Font Size"),this); actionContext->regAction(m_decreaseFontSizeAct,"DecreaseFontSize","Ctrl+-"); m_resetFontSizeAct = new QAction(tr("Reset Font Size"),this); actionContext->regAction(m_resetFontSizeAct,"ResetFontSize","Ctrl+0"); m_cleanWhitespaceAct = new QAction(tr("Clean Whitespace"),this); actionContext->regAction(m_cleanWhitespaceAct,"CleanWhitespace",""); m_wordWrapAct = new QAction(tr("Word Wrap"),this); m_wordWrapAct->setCheckable(true); actionContext->regAction(m_wordWrapAct,"WordWrap",""); m_codeCompleteAct = new QAction(tr("Code Complete"),this); #ifdef Q_OS_MAC actionContext->regAction(m_codeCompleteAct,"CodeComplete","Meta+Space"); #else actionContext->regAction(m_codeCompleteAct,"CodeComplete","Ctrl+Space"); #endif connect(m_codeCompleteAct,SIGNAL(triggered()),m_editorWidget,SLOT(codeCompleter())); // m_widget->addAction(m_foldAct); // m_widget->addAction(m_unfoldAct); // m_widget->addAction(m_gotoLineAct); // m_widget->addAction(m_gotoPrevBlockAct); // m_widget->addAction(m_gotoNextBlockAct); // m_widget->addAction(m_selectBlockAct); // m_widget->addAction(m_gotoMatchBraceAct); connect(m_editorWidget,SIGNAL(undoAvailable(bool)),m_undoAct,SLOT(setEnabled(bool))); connect(m_editorWidget,SIGNAL(redoAvailable(bool)),m_redoAct,SLOT(setEnabled(bool))); connect(m_editorWidget,SIGNAL(copyAvailable(bool)),m_cutAct,SLOT(setEnabled(bool))); connect(m_editorWidget,SIGNAL(copyAvailable(bool)),m_copyAct,SLOT(setEnabled(bool))); connect(m_editorWidget,SIGNAL(wordWrapChanged(bool)),m_wordWrapAct,SLOT(setChecked(bool))); connect(m_undoAct,SIGNAL(triggered()),m_editorWidget,SLOT(undo())); connect(m_redoAct,SIGNAL(triggered()),m_editorWidget,SLOT(redo())); connect(m_cutAct,SIGNAL(triggered()),m_editorWidget,SLOT(cut())); connect(m_copyAct,SIGNAL(triggered()),m_editorWidget,SLOT(copy())); connect(m_pasteAct,SIGNAL(triggered()),m_editorWidget,SLOT(paste())); connect(m_selectAllAct,SIGNAL(triggered()),m_editorWidget,SLOT(selectAll())); connect(m_selectBlockAct,SIGNAL(triggered()),m_editorWidget,SLOT(selectBlock())); connect(m_exportHtmlAct,SIGNAL(triggered()),this,SLOT(exportHtml())); #ifndef QT_NO_PRINTER connect(m_exportPdfAct,SIGNAL(triggered()),this,SLOT(exportPdf())); connect(m_filePrintAct,SIGNAL(triggered()),this,SLOT(filePrint())); connect(m_filePrintPreviewAct,SIGNAL(triggered()),this,SLOT(filePrintPreview())); #endif connect(m_gotoPrevBlockAct,SIGNAL(triggered()),m_editorWidget,SLOT(gotoPrevBlock())); connect(m_gotoNextBlockAct,SIGNAL(triggered()),m_editorWidget,SLOT(gotoNextBlock())); connect(m_gotoMatchBraceAct,SIGNAL(triggered()),m_editorWidget,SLOT(gotoMatchBrace())); connect(m_gotoLineAct,SIGNAL(triggered()),this,SLOT(gotoLine())); connect(m_increaseFontSizeAct,SIGNAL(triggered()),this,SLOT(increaseFontSize())); connect(m_decreaseFontSizeAct,SIGNAL(triggered()),this,SLOT(decreaseFontSize())); connect(m_resetFontSizeAct,SIGNAL(triggered()),this,SLOT(resetFontSize())); connect(m_cleanWhitespaceAct,SIGNAL(triggered()),m_editorWidget,SLOT(cleanWhitespace())); connect(m_wordWrapAct,SIGNAL(triggered(bool)),m_editorWidget,SLOT(setWordWrapOverride(bool))); QClipboard *clipboard = QApplication::clipboard(); connect(clipboard,SIGNAL(dataChanged()),this,SLOT(clipbordDataChanged())); clipbordDataChanged(); }
void ProgramWindow::setup() { if (parentWidget() == NULL) { resize(500,700); setAttribute(Qt::WA_DeleteOnClose, true); } QFrame * mainFrame = new QFrame(this); QFrame * headerFrame = createHeader(); QFrame * centerFrame = createCenter(); layout()->setMargin(0); layout()->setSpacing(0); QGridLayout *layout = new QGridLayout(mainFrame); layout->setMargin(0); layout->setSpacing(0); layout->addWidget(headerFrame,0,0); layout->addWidget(centerFrame,1,0); setCentralWidget(mainFrame); setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); QSettings settings; if (!settings.value("programwindow/state").isNull()) { restoreState(settings.value("programwindow/state").toByteArray()); } if (!settings.value("programwindow/geometry").isNull()) { restoreGeometry(settings.value("programwindow/geometry").toByteArray()); } installEventFilter(this); // Setup new menu bar for the programming window QMenuBar * menubar = NULL; if (parentWidget()) { QMainWindow * mainWindow = qobject_cast<QMainWindow *>(parentWidget()); if (mainWindow) menubar = mainWindow->menuBar(); } if (menubar == NULL) menubar = menuBar(); m_fileMenu = menubar->addMenu(tr("&File")); QAction *currentAction = new QAction(tr("New Code File"), this); currentAction->setShortcut(tr("Ctrl+N")); currentAction->setStatusTip(tr("Create a new program")); connect(currentAction, SIGNAL(triggered()), this, SLOT(addTab())); m_fileMenu->addAction(currentAction); currentAction = new QAction(tr("&Open Code File..."), this); currentAction->setShortcut(tr("Ctrl+O")); currentAction->setStatusTip(tr("Open a program")); connect(currentAction, SIGNAL(triggered()), this, SLOT(loadProgramFile())); m_fileMenu->addAction(currentAction); m_fileMenu->addSeparator(); m_saveAction = new QAction(tr("&Save Code File"), this); m_saveAction->setShortcut(tr("Ctrl+S")); m_saveAction->setStatusTip(tr("Save the current program")); connect(m_saveAction, SIGNAL(triggered()), this, SLOT(save())); m_fileMenu->addAction(m_saveAction); currentAction = new QAction(tr("Rename Code File"), this); currentAction->setStatusTip(tr("Rename the current program")); connect(currentAction, SIGNAL(triggered()), this, SLOT(rename())); m_fileMenu->addAction(currentAction); currentAction = new QAction(tr("Duplicate tab"), this); currentAction->setStatusTip(tr("Copies the current program into a new tab")); connect(currentAction, SIGNAL(triggered()), this, SLOT(duplicateTab())); m_fileMenu->addAction(currentAction); m_fileMenu->addSeparator(); currentAction = new QAction(tr("Remove tab"), this); currentAction->setShortcut(tr("Ctrl+W")); currentAction->setStatusTip(tr("Remove the current program from the sketch")); connect(currentAction, SIGNAL(triggered()), this, SLOT(closeCurrentTab())); m_fileMenu->addAction(currentAction); m_fileMenu->addSeparator(); m_printAction = new QAction(tr("&Print..."), this); m_printAction->setShortcut(tr("Ctrl+P")); m_printAction->setStatusTip(tr("Print the current program")); connect(m_printAction, SIGNAL(triggered()), this, SLOT(print())); m_fileMenu->addAction(m_printAction); m_fileMenu->addSeparator(); currentAction = new QAction(tr("&Quit"), this); currentAction->setShortcut(tr("Ctrl+Q")); currentAction->setStatusTip(tr("Quit the application")); currentAction->setMenuRole(QAction::QuitRole); connect(currentAction, SIGNAL(triggered()), qApp, SLOT(closeAllWindows2())); m_fileMenu->addAction(currentAction); m_editMenu = menubar->addMenu(tr("&Edit")); m_undoAction = new QAction(tr("Undo"), this); m_undoAction->setShortcuts(QKeySequence::Undo); m_undoAction->setEnabled(false); connect(m_undoAction, SIGNAL(triggered()), this, SLOT(undo())); m_editMenu->addAction(m_undoAction); m_redoAction = new QAction(tr("Redo"), this); m_redoAction->setShortcuts(QKeySequence::Redo); m_redoAction->setEnabled(false); connect(m_redoAction, SIGNAL(triggered()), this, SLOT(redo())); m_editMenu->addAction(m_redoAction); m_editMenu->addSeparator(); m_cutAction = new QAction(tr("&Cut"), this); m_cutAction->setShortcut(tr("Ctrl+X")); m_cutAction->setStatusTip(tr("Cut selection")); m_cutAction->setEnabled(false); connect(m_cutAction, SIGNAL(triggered()), this, SLOT(cut())); m_editMenu->addAction(m_cutAction); m_copyAction = new QAction(tr("&Copy"), this); m_copyAction->setShortcut(tr("Ctrl+C")); m_copyAction->setStatusTip(tr("Copy selection")); m_copyAction->setEnabled(false); connect(m_copyAction, SIGNAL(triggered()), this, SLOT(copy())); m_editMenu->addAction(m_copyAction); currentAction = new QAction(tr("&Paste"), this); currentAction->setShortcut(tr("Ctrl+V")); currentAction->setStatusTip(tr("Paste clipboard contents")); // TODO: Check clipboard status and disable appropriately here connect(currentAction, SIGNAL(triggered()), this, SLOT(paste())); m_editMenu->addAction(currentAction); m_editMenu->addSeparator(); currentAction = new QAction(tr("&Select All"), this); currentAction->setShortcut(tr("Ctrl+A")); currentAction->setStatusTip(tr("Select all text")); connect(currentAction, SIGNAL(triggered()), this, SLOT(selectAll())); m_editMenu->addAction(currentAction); m_programMenu = menubar->addMenu(tr("&Code")); QMenu *languageMenu = new QMenu(tr("Select language"), this); m_programMenu->addMenu(languageMenu); QString currentLanguage = settings.value("programwindow/language", "").toString(); QStringList languages = getAvailableLanguages(); QActionGroup *languageActionGroup = new QActionGroup(this); foreach (QString language, languages) { currentAction = new QAction(language, this); currentAction->setCheckable(true); m_languageActions.insert(language, currentAction); languageActionGroup->addAction(currentAction); languageMenu->addAction(currentAction); if (!currentLanguage.isEmpty()) { if (language.compare(currentLanguage) == 0) { currentAction->setChecked(true); } } }
DownloadFromDCWidget::DownloadFromDCWidget(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f), thread(0), downloading(false), previousLast(0), vendorModel(0), productModel(0), timer(new QTimer(this)), dumpWarningShown(false), ostcFirmwareCheck(0), currentState(INITIAL) { clear_table(&downloadTable); ui.setupUi(this); ui.progressBar->hide(); ui.progressBar->setMinimum(0); ui.progressBar->setMaximum(100); diveImportedModel = new DiveImportedModel(this); ui.downloadedView->setModel(diveImportedModel); ui.downloadedView->setSelectionBehavior(QAbstractItemView::SelectRows); ui.downloadedView->setSelectionMode(QAbstractItemView::SingleSelection); int startingWidth = defaultModelFont().pointSize(); ui.downloadedView->setColumnWidth(0, startingWidth * 20); ui.downloadedView->setColumnWidth(1, startingWidth * 10); ui.downloadedView->setColumnWidth(2, startingWidth * 10); connect(ui.downloadedView, SIGNAL(clicked(QModelIndex)), diveImportedModel, SLOT(changeSelected(QModelIndex))); progress_bar_text = ""; fill_computer_list(); ui.chooseDumpFile->setEnabled(ui.dumpToFile->isChecked()); connect(ui.chooseDumpFile, SIGNAL(clicked()), this, SLOT(pickDumpFile())); connect(ui.dumpToFile, SIGNAL(stateChanged(int)), this, SLOT(checkDumpFile(int))); ui.chooseLogFile->setEnabled(ui.logToFile->isChecked()); connect(ui.chooseLogFile, SIGNAL(clicked()), this, SLOT(pickLogFile())); connect(ui.logToFile, SIGNAL(stateChanged(int)), this, SLOT(checkLogFile(int))); ui.selectAllButton->setEnabled(false); ui.unselectAllButton->setEnabled(false); connect(ui.selectAllButton, SIGNAL(clicked()), diveImportedModel, SLOT(selectAll())); connect(ui.unselectAllButton, SIGNAL(clicked()), diveImportedModel, SLOT(selectNone())); vendorModel = new QStringListModel(vendorList); ui.vendor->setModel(vendorModel); auto dc = SettingsObjectWrapper::instance()->dive_computer_settings; if (!dc->dc_vendor().isEmpty()) { ui.vendor->setCurrentIndex(ui.vendor->findText(dc->dc_vendor())); productModel = new QStringListModel(productList[dc->dc_vendor()]); ui.product->setModel(productModel); if (!dc->dc_product().isEmpty()) ui.product->setCurrentIndex(ui.product->findText(dc->dc_product())); } if (!dc->dc_device().isEmpty()) ui.device->setEditText(dc->dc_device()); timer->setInterval(200); connect(timer, SIGNAL(timeout()), this, SLOT(updateProgressBar())); updateState(INITIAL); memset(&data, 0, sizeof(data)); QShortcut *close = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this); connect(close, SIGNAL(activated()), this, SLOT(close())); QShortcut *quit = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this); connect(quit, SIGNAL(activated()), parent, SLOT(close())); ui.ok->setEnabled(false); ui.downloadCancelRetryButton->setEnabled(true); ui.downloadCancelRetryButton->setText(tr("Download")); #if defined(BT_SUPPORT) && defined(SSRF_CUSTOM_SERIAL) ui.bluetoothMode->setText(tr("Choose Bluetooth download mode")); ui.bluetoothMode->setChecked(dc->downloadMode() == DC_TRANSPORT_BLUETOOTH); btDeviceSelectionDialog = 0; ui.chooseBluetoothDevice->setEnabled(ui.bluetoothMode->isChecked()); connect(ui.bluetoothMode, SIGNAL(stateChanged(int)), this, SLOT(enableBluetoothMode(int))); connect(ui.chooseBluetoothDevice, SIGNAL(clicked()), this, SLOT(selectRemoteBluetoothDevice())); #else ui.bluetoothMode->hide(); ui.chooseBluetoothDevice->hide(); #endif }
void TInputLine::handleEvent( TEvent& event ) { TView::handleEvent(event); int delta, anchor, i; if( (state & sfSelected) != 0 ) switch( event.what ) { case evMouseDown: if( canScroll(delta = mouseDelta(event)) ) do { if( canScroll(delta) ) { firstPos += delta; drawView(); } } while( mouseEvent( event, evMouseAuto ) ); else if (event.mouse.doubleClick) selectAll(True); else { anchor = mousePos(event); do { if( event.what == evMouseAuto && canScroll( delta = mouseDelta(event) ) ) firstPos += delta; curPos = mousePos(event); if( curPos < anchor ) { selStart = curPos; selEnd = anchor; } else { selStart = anchor; selEnd = curPos; } drawView(); } while (mouseEvent(event, evMouseMove | evMouseAuto)); } clearEvent(event); break; case evKeyDown: switch( ctrlToArrow(event.keyDown.keyCode) ) { case kbLeft: if( curPos > 0 ) curPos--; break; case kbRight: if( curPos < strlen(data) ) curPos++; break; case kbHome: curPos = 0; break; case kbEnd: curPos = strlen(data); break; case kbBack: if( curPos > 0 ) { strcpy( data+curPos-1, data+curPos ); curPos--; if( firstPos > 0 ) firstPos--; } break; case kbDel: if( selStart == selEnd ) if( curPos < strlen(data) ) { selStart = curPos; selEnd = curPos + 1; } deleteSelect(); break; case kbIns: setState(sfCursorIns, Boolean(!(state & sfCursorIns))); break; default: if( event.keyDown.charScan.charCode >= ' ' ) { if( (state & sfCursorIns) != 0 ) strcpy( data + curPos, data + curPos + 1 ); else deleteSelect(); if( strlen(data) < maxLen ) { if( firstPos > curPos ) firstPos = curPos; memmove( data + curPos + 1, data + curPos, strlen(data+curPos)+1 ); data[curPos++] = event.keyDown.charScan.charCode; } } else if( event.keyDown.charScan.charCode == CONTROL_Y) { *data = EOS; curPos = 0; } else return; } selStart = 0; selEnd = 0; if( firstPos > curPos ) firstPos = curPos; i = curPos - size.x + 3; if( firstPos < i ) firstPos = i; drawView(); clearEvent( event ); break; } }