SearchListView::SearchListView(QWidget* parent) : QWidget(parent), ui(new Ui::SearchListView) { ui->setupUi(this); // Create the reference list mList = new SearchListViewTable(); mList->setContextMenuPolicy(Qt::CustomContextMenu); // Create the search list mSearchList = new SearchListViewTable(); mSearchList->setContextMenuPolicy(Qt::CustomContextMenu); mSearchList->hide(); // Set global variables mSearchBox = ui->searchBox; mCurList = mList; mSearchStartCol = 0; // Create list layout mListLayout = new QVBoxLayout(); mListLayout->setContentsMargins(0, 0, 0, 0); mListLayout->setSpacing(0); mListLayout->addWidget(mList); mListLayout->addWidget(mSearchList); // Create list placeholder mListPlaceHolder = new QWidget(); mListPlaceHolder->setLayout(mListLayout); // Insert the placeholder ui->mainSplitter->insertWidget(0, mListPlaceHolder); // Set the main layout mMainLayout = new QVBoxLayout(); mMainLayout->setContentsMargins(0, 0, 0, 0); mMainLayout->addWidget(ui->mainSplitter); setLayout(mMainLayout); // Minimal size for the search box ui->mainSplitter->setStretchFactor(0, 1000); ui->mainSplitter->setStretchFactor(0, 1); // Disable main splitter for(int i = 0; i < ui->mainSplitter->count(); i++) ui->mainSplitter->handle(i)->setEnabled(false); // Setup signals connect(mList, SIGNAL(keyPressedSignal(QKeyEvent*)), this, SLOT(listKeyPressed(QKeyEvent*))); connect(mList, SIGNAL(contextMenuSignal(QPoint)), this, SLOT(listContextMenu(QPoint))); connect(mList, SIGNAL(doubleClickedSignal()), this, SLOT(doubleClickedSlot())); connect(mSearchList, SIGNAL(keyPressedSignal(QKeyEvent*)), this, SLOT(listKeyPressed(QKeyEvent*))); connect(mSearchList, SIGNAL(contextMenuSignal(QPoint)), this, SLOT(listContextMenu(QPoint))); connect(mSearchList, SIGNAL(doubleClickedSignal()), this, SLOT(doubleClickedSlot())); connect(mSearchBox, SIGNAL(textChanged(QString)), this, SLOT(searchTextChanged(QString))); }
void LibraryWidget::setupUi() { ui->treeWidget->setItemDelegate(new ProjectTreeDelegate()); connect(ui->treeWidget, SIGNAL(itemSelectionChanged()), this, SLOT(selectionchanged())); ui->treeWidget->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->treeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(listContextMenu(QPoint))); QLibraryTreeWidgetItem *root = new QLibraryTreeWidgetItem(); root->setData(0,BibGlobals::Role_ResourceType,BibGlobals::Resource_SearchResults); root->setIcon(0, KIcon(QLatin1String("system-search"))); ui->treeWidget->addTopLevelItem(root); root->setText(0, i18n("Search Results")); connect(ui->searchWidget, SIGNAL(newSearchStarted()), this, SIGNAL(showSearchResults())); }
/*! Mimic the look of the text editor toolbar as defined in e.g. EditorView::EditorView */ EditorToolBar::EditorToolBar(QWidget *parent) : Utils::StyledBar(parent), m_editorList(new QComboBox(this)), m_closeButton(new QToolButton), m_lockButton(new QToolButton), m_goBackAction(new QAction(QIcon(QLatin1String(":/help/images/previous.png")), EditorManager::tr("Go Back"), parent)), m_goForwardAction(new QAction(QIcon(QLatin1String(":/help/images/next.png")), EditorManager::tr("Go Forward"), parent)), m_activeToolBar(0), m_toolBarPlaceholder(new QWidget), m_defaultToolBar(new QWidget(this)), m_isStandalone(false) { QHBoxLayout *toolBarLayout = new QHBoxLayout(this); toolBarLayout->setMargin(0); toolBarLayout->setSpacing(0); toolBarLayout->addWidget(m_defaultToolBar); m_toolBarPlaceholder->setLayout(toolBarLayout); m_toolBarPlaceholder->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); m_defaultToolBar->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); m_activeToolBar = m_defaultToolBar; m_editorsListModel = EditorManager::instance()->openedEditorsModel(); connect(m_goBackAction, SIGNAL(triggered()), this, SIGNAL(goBackClicked())); connect(m_goForwardAction, SIGNAL(triggered()), this, SIGNAL(goForwardClicked())); m_editorList->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); m_editorList->setMinimumContentsLength(20); m_editorList->setModel(m_editorsListModel); m_editorList->setMaxVisibleItems(40); m_editorList->setContextMenuPolicy(Qt::CustomContextMenu); m_lockButton->setAutoRaise(true); m_lockButton->setProperty("type", QLatin1String("dockbutton")); m_lockButton->setVisible(false); m_closeButton->setAutoRaise(true); m_closeButton->setIcon(QIcon(":/core/images/closebutton.png")); m_closeButton->setProperty("type", QLatin1String("dockbutton")); m_closeButton->setEnabled(false); m_toolBarPlaceholder->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); m_backButton = new QToolButton(this); m_backButton->setDefaultAction(m_goBackAction); m_forwardButton= new QToolButton(this); m_forwardButton->setDefaultAction(m_goForwardAction); QHBoxLayout *toplayout = new QHBoxLayout(this); toplayout->setSpacing(0); toplayout->setMargin(0); toplayout->addWidget(m_backButton); toplayout->addWidget(m_forwardButton); toplayout->addWidget(m_editorList); toplayout->addWidget(m_toolBarPlaceholder, 1); // Custom toolbar stretches toplayout->addWidget(m_lockButton); toplayout->addWidget(m_closeButton); setLayout(toplayout); // this signal is disconnected for standalone toolbars and replaced with // a private slot connection connect(m_editorList, SIGNAL(activated(int)), this, SIGNAL(listSelectionActivated(int))); connect(m_editorList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(listContextMenu(QPoint))); connect(m_lockButton, SIGNAL(clicked()), this, SLOT(makeEditorWritable())); connect(m_closeButton, SIGNAL(clicked()), this, SLOT(closeView()), Qt::QueuedConnection); ActionManager *am = ICore::instance()->actionManager(); connect(am->command(Constants::CLOSE), SIGNAL(keySequenceChanged()), this, SLOT(updateActionShortcuts())); connect(am->command(Constants::GO_BACK), SIGNAL(keySequenceChanged()), this, SLOT(updateActionShortcuts())); connect(am->command(Constants::GO_FORWARD), SIGNAL(keySequenceChanged()), this, SLOT(updateActionShortcuts())); }