[Kst] branches/work/kst/portto4/kst/src/widgets
Joshua Netterfield
drmrshdw at gmail.com
Thu Aug 4 16:24:43 UTC 2011
SVN commit 1244984 by joshuanetterfield:
Better size hints for columns in completion table.
Better logic in equation line edit.
M +23 -0 cclineedit.cpp
M +4 -1 cclineedit_p.h
--- branches/work/kst/portto4/kst/src/widgets/cclineedit.cpp #1244983:1244984
@@ -34,6 +34,7 @@
#include <QHash>
#include <QMenu>
#include <QTimer>
+#include <QLabel>
namespace Kst {
@@ -162,6 +163,9 @@
for(int i=0;i<operatorNextList.size();i++) {
last1=qMax(last1,hack->text().lastIndexOf(operatorNextList[i],hack->cursorPosition()-1));
}
+ last1=qMax(last1,hack->text().lastIndexOf("PI ",hack->cursorPosition()-1,Qt::CaseInsensitive));
+ last1=qMax(last1,hack->text().lastIndexOf("e ",hack->cursorPosition()-1,Qt::CaseInsensitive));
+
for(int i=0;i<functionNextList.size();i++) {
last2=qMax(last2,hack->text().lastIndexOf(functionNextList[i],hack->cursorPosition()-1));
}
@@ -866,6 +870,23 @@
QVariant CCTableModel::data(const QModelIndex &index, int role) const
{
+ if(role==Qt::SizeHintRole) { //evil problems have evil solutions -_-
+ if(index.column()>=columnCount(QModelIndex())) {
+ return QVariant();
+ }
+ if(s_minSizeCache[index.column()]!=QSize(-1,-1)) {
+ return s_minSizeCache[index.column()];
+ }
+ QLabel tmp;
+ int wid=0;
+ for(int i=0;i<_visibleData[index.column()].size();i++) {
+ tmp.setText(_visibleData[index.column()][i]);
+ wid=qMax(wid,tmp.sizeHint().width());
+ }
+ QSize s=tmp.sizeHint();
+ s.setWidth(wid*1.1);
+ return const_cast<CCTableModel*>(this)->s_minSizeCache[index.column()]=s;
+ }
if(role!=Qt::DisplayRole) return QVariant(); // Return unvalid QVariant
Q_ASSERT(index.column()<columnCount(QModelIndex()));
if(index.column()==-1) {
@@ -1002,6 +1023,8 @@
}
hide();
}
+ completer->verifyPrefix();
+ updateSuggestions();
}
void CCTableView::showEvent(QShowEvent *)
--- branches/work/kst/portto4/kst/src/widgets/cclineedit_p.h #1244983:1244984
@@ -59,11 +59,14 @@
class CCTableModel : public QAbstractTableModel {
Q_OBJECT
QList<QStringList> _visibleData;
+ QSize s_minSizeCache[32];
public:
explicit CCTableModel(const QList<QStringList>& visibleData) : _visibleData(visibleData)
{
-
+ for(int i=0;i<32;i++) {
+ s_minSizeCache[i]=QSize(-1,-1);
}
+ }
int rowCount(const QModelIndex &parent) const;
int columnCount(const QModelIndex &parent) const;
More information about the Kst
mailing list