27 #include <QApplication>
29 #include <QVBoxLayout>
32 #include <QDesktopWidget>
46 setObjectName (
"HistoryDockWidget");
47 setStatusTip (tr (
"Browse and search the command history."));
50 p, SLOT (new_file (
const QString&)));
52 connect (
this, SIGNAL (
information (
const QString&)),
53 p, SLOT (report_status_message (
const QString&)));
56 p, SLOT (execute_command_in_terminal (
const QString&)));
71 tr (
"Double-click a command to transfer it to the terminal."));
75 SIGNAL (customContextMenuRequested (
const QPoint &)),
this,
76 SLOT (
ctxMenu (
const QPoint &)));
79 _filter->setToolTip (tr (
"Enter text to filter the command history"));
82 _filter->setInsertPolicy (QComboBox::NoInsert);
84 QComboBox::AdjustToMinimumContentsLengthWithIcon);
85 QSizePolicy sizePol (QSizePolicy::Expanding, QSizePolicy::Preferred);
86 _filter->setSizePolicy (sizePol);
87 _filter->completer ()->setCaseSensitivity (Qt::CaseSensitive);
89 QLabel *filter_label =
new QLabel (tr (
"Filter"));
93 setWindowIcon (QIcon (
":/actions/icons/logo.png"));
97 QVBoxLayout *vbox_layout =
new QVBoxLayout ();
98 QHBoxLayout *hbox_layout =
new QHBoxLayout ();
99 hbox_layout->addWidget (filter_label);
101 hbox_layout->addWidget (
_filter);
102 vbox_layout->addLayout (hbox_layout);
104 vbox_layout->setMargin (2);
106 widget ()->setLayout (vbox_layout);
108 setFocusProxy (
_filter->lineEdit ());
112 _filter->addItems (settings->value (
"history_dock_widget/mru_list").toStringList ());
115 settings->value (
"history_dock_widget/filter_active",
false).toBool ();
120 connect (
_filter, SIGNAL (editTextChanged (
const QString&)),
124 connect (
_filter->lineEdit (), SIGNAL (editingFinished ()),
131 QSize screen = QDesktopWidget ().screenGeometry ().size ();
132 int w = screen.width ();
134 int h = fm.height ();
143 settings->setValue (
"history_dock_widget/filter_active",
147 for (
int i = 0; i <
_filter->count (); i++)
148 mru.append (
_filter->itemText (i));
149 settings->setValue (
"history_dock_widget/mru_list", mru);
170 int index =
_filter->findText (text);
184 menu.addAction (tr (
"Evaluate"),
this,
187 tr (
"Create script"),
this,
196 QModelIndexList rows = selectionModel->selectedRows ();
197 QModelIndexList::iterator it;
198 bool prev_valid_row =
false;
199 for (it = rows.begin (); it != rows.end (); it++)
201 if ((*it).isValid ())
205 text += (*it).data ().toString ();
206 prev_valid_row =
true;
209 QApplication::clipboard ()->setText (text);
215 QModelIndexList rows = selectionModel->selectedRows ();
216 QModelIndexList::iterator it;
217 for (it = rows.begin () ; it != rows.end (); it++)
219 if ((*it).isValid ())
229 QModelIndexList rows = selectionModel->selectedRows ();
231 bool prev_valid_row =
false;
232 for (QModelIndexList::iterator it = rows.begin (); it != rows.end (); it++)
234 if ((*it).isValid ())
238 text += (*it).data ().toString ();
239 prev_valid_row =
true;
243 if (text.length () > 0)
265 lst.append (hist_entry);
269 bool at_bottom = scroll_bar->maximum () - scroll_bar->value () < 1;
289 if (
_filter->lineEdit ()->hasFocus ()
290 &&
_filter->lineEdit ()->hasSelectedText ())
292 QClipboard *clipboard = QApplication::clipboard ();
293 clipboard->setText (
_filter->lineEdit ()->selectedText ());
300 if (
_filter->lineEdit ()->hasFocus ())
302 QClipboard *clipboard = QApplication::clipboard ();
303 QString str = clipboard->text ();
304 if (str.length () > 0)
305 _filter->lineEdit ()->insert (str);
312 if (
_filter->lineEdit ()->hasFocus ())
314 _filter->lineEdit ()->selectAll ();
static uint32_t state[624]
void update_filter_history()
QStringListModel * _history_model
Stores the current history_model.
void set_history(const QStringList &hist)
history_dock_widget(QWidget *parent=0)
void ctxMenu(const QPoint &pos)
void handle_double_click(QModelIndex modelIndex)
QListView * _history_list_view
void information(const QString &message)
std::complex< double > w(std::complex< double > z, double relerr=0)
void handle_contextmenu_copy(bool flag)
static QSettings * get_settings(void)
void command_double_clicked(const QString &command)
Emitted, whenever the user double-clicked a command in the history.
void command_create_script(const QString &commands)
Emitted whenever the user selects command and chooses Create script from popupmenu.
void append_history(const QString &hist_entry)
void filter_activate(bool enable)
QCheckBox * _filter_checkbox
static QIcon icon(const QString &icon_name, bool fallback=true)
void handle_contextmenu_create_script(bool flag)
QSortFilterProxyModel _sort_filter_proxy_model
void handle_contextmenu_evaluate(bool flag)