mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-20 11:56:12 +00:00
Add new helper functions
This commit is contained in:
parent
a5224bb7f6
commit
ff348e0f1a
@ -4,10 +4,20 @@
|
|||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QCryptographicHash>
|
#include <QCryptographicHash>
|
||||||
|
#include <QTreeWidget>
|
||||||
|
#include <QString>
|
||||||
|
#include <QAbstractItemView>
|
||||||
|
|
||||||
|
|
||||||
|
static QAbstractItemView::ScrollMode scrollMode()
|
||||||
|
{
|
||||||
|
const bool use_scrollperpixel = true;
|
||||||
|
return use_scrollperpixel ? QAbstractItemView::ScrollPerPixel : QAbstractItemView::ScrollPerItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace qhelpers
|
namespace qhelpers
|
||||||
{
|
{
|
||||||
|
|
||||||
// TODO: wouldn't it be enough to setFont on the QWidget?
|
// TODO: wouldn't it be enough to setFont on the QWidget?
|
||||||
|
|
||||||
void normalizeFont(QPlainTextEdit *edit)
|
void normalizeFont(QPlainTextEdit *edit)
|
||||||
@ -34,4 +44,37 @@ namespace qhelpers
|
|||||||
return QFileInfo(filename).fileName() + "_" + fullHash.toHex().left(10);
|
return QFileInfo(filename).fileName() + "_" + fullHash.toHex().left(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void adjustColumns(QTreeWidget *tw)
|
||||||
|
{
|
||||||
|
int count = tw->columnCount();
|
||||||
|
for (int i = 0; i != count; ++i)
|
||||||
|
{
|
||||||
|
tw->resizeColumnToContents(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void appendRow(QTreeWidget *tw, const QString &str, const QString &str2,
|
||||||
|
const QString &str3, const QString &str4, const QString &str5)
|
||||||
|
{
|
||||||
|
QTreeWidgetItem *tempItem = new QTreeWidgetItem();
|
||||||
|
// Fill dummy hidden column
|
||||||
|
tempItem->setText(0, "0");
|
||||||
|
tempItem->setText(1, str);
|
||||||
|
if (!str2.isNull())
|
||||||
|
tempItem->setText(2, str2);
|
||||||
|
if (!str3.isNull())
|
||||||
|
tempItem->setText(3, str3);
|
||||||
|
if (!str4.isNull())
|
||||||
|
tempItem->setText(4, str4);
|
||||||
|
if (!str5.isNull())
|
||||||
|
tempItem->setText(5, str5);
|
||||||
|
|
||||||
|
tw->insertTopLevelItem(0, tempItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setVerticalScrollMode(QTreeWidget *tw)
|
||||||
|
{
|
||||||
|
tw->setVerticalScrollMode(scrollMode());
|
||||||
|
}
|
||||||
|
|
||||||
} // end namespace
|
} // end namespace
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
#ifndef QHELPERS_H
|
#ifndef QHELPERS_H
|
||||||
#define QHELPERS_H
|
#define QHELPERS_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
class QPlainTextEdit;
|
class QPlainTextEdit;
|
||||||
class QTextEdit;
|
class QTextEdit;
|
||||||
class QString;
|
class QString;
|
||||||
|
class QTreeWidget;
|
||||||
|
|
||||||
namespace qhelpers
|
namespace qhelpers
|
||||||
{
|
{
|
||||||
@ -11,6 +14,13 @@ namespace qhelpers
|
|||||||
void normalizeEditFont(QTextEdit *edit);
|
void normalizeEditFont(QTextEdit *edit);
|
||||||
|
|
||||||
QString uniqueProjectName(const QString &filename);
|
QString uniqueProjectName(const QString &filename);
|
||||||
|
|
||||||
|
void adjustColumns(QTreeWidget *tw);
|
||||||
|
|
||||||
|
void appendRow(QTreeWidget *tw, const QString &str, const QString &str2 = QString(),
|
||||||
|
const QString &str3 = QString(), const QString &str4 = QString(), const QString &str5 = QString());
|
||||||
|
|
||||||
|
void setVerticalScrollMode(QTreeWidget* tw);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // HELPERS_H
|
#endif // HELPERS_H
|
||||||
|
Loading…
Reference in New Issue
Block a user