mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
fix
This commit is contained in:
parent
d6c3c99605
commit
4a69095d5f
4 changed files with 21 additions and 17 deletions
|
@ -205,9 +205,7 @@ public:
|
|||
assert(row >= 0 && row < this->rows_.size() && column >= 0 &&
|
||||
column < this->columnCount_);
|
||||
|
||||
return this->rows_[row].items[column]->flags() |
|
||||
Qt::ItemFlag::ItemIsDragEnabled |
|
||||
Qt::ItemFlag::ItemIsDropEnabled;
|
||||
return this->rows_[row].items[column]->flags();
|
||||
}
|
||||
|
||||
QStandardItem *getItem(int row, int column)
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#include "CommandModel.hpp"
|
||||
|
||||
#include "util/StandardItemHelper.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
|
||||
// commandmodel
|
||||
|
@ -20,12 +22,8 @@ Command CommandModel::getItemFromRow(std::vector<QStandardItem *> &row,
|
|||
void CommandModel::getRowFromItem(const Command &item,
|
||||
std::vector<QStandardItem *> &row)
|
||||
{
|
||||
row[0]->setData(item.name, Qt::DisplayRole);
|
||||
row[0]->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable |
|
||||
Qt::ItemIsEditable);
|
||||
row[1]->setData(item.func, Qt::DisplayRole);
|
||||
row[1]->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable |
|
||||
Qt::ItemIsEditable);
|
||||
setStringItem(row[0], item.name);
|
||||
setStringItem(row[1], item.func);
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
|
|
@ -4,12 +4,20 @@
|
|||
|
||||
namespace chatterino {
|
||||
|
||||
static auto defaultItemFlags(bool selectable)
|
||||
{
|
||||
return Qt::ItemIsEnabled |
|
||||
(selectable ? Qt::ItemIsSelectable | Qt::ItemIsDragEnabled |
|
||||
Qt::ItemIsDropEnabled
|
||||
: Qt::ItemFlag());
|
||||
}
|
||||
|
||||
static void setBoolItem(QStandardItem *item, bool value,
|
||||
bool userCheckable = true, bool selectable = true)
|
||||
{
|
||||
item->setFlags(Qt::ItemFlags(
|
||||
Qt::ItemIsEnabled | (selectable ? Qt::ItemIsSelectable : 0) |
|
||||
(userCheckable ? Qt::ItemIsUserCheckable : 0)));
|
||||
item->setFlags(
|
||||
Qt::ItemFlags(defaultItemFlags(selectable) |
|
||||
(userCheckable ? Qt::ItemIsUserCheckable : 0)));
|
||||
item->setCheckState(value ? Qt::Checked : Qt::Unchecked);
|
||||
}
|
||||
|
||||
|
@ -17,8 +25,7 @@ static void setStringItem(QStandardItem *item, const QString &value,
|
|||
bool editable = true, bool selectable = true)
|
||||
{
|
||||
item->setData(value, Qt::EditRole);
|
||||
item->setFlags(Qt::ItemFlags(Qt::ItemIsEnabled |
|
||||
(selectable ? Qt::ItemIsSelectable : 0) |
|
||||
item->setFlags(Qt::ItemFlags(defaultItemFlags(selectable) |
|
||||
(editable ? (Qt::ItemIsEditable) : 0)));
|
||||
}
|
||||
|
||||
|
@ -28,7 +35,7 @@ static void setFilePathItem(QStandardItem *item, const QUrl &value,
|
|||
item->setData(value, Qt::UserRole);
|
||||
item->setData(value.fileName(), Qt::DisplayRole);
|
||||
item->setFlags(
|
||||
Qt::ItemFlags(Qt::ItemIsEnabled |
|
||||
Qt::ItemFlags(defaultItemFlags(selectable) |
|
||||
(selectable ? Qt::ItemIsSelectable : Qt::NoItemFlags)));
|
||||
}
|
||||
|
||||
|
@ -37,14 +44,14 @@ static void setColorItem(QStandardItem *item, const QColor &value,
|
|||
{
|
||||
item->setData(value, Qt::DecorationRole);
|
||||
item->setFlags(
|
||||
Qt::ItemFlags(Qt::ItemIsEnabled |
|
||||
Qt::ItemFlags(defaultItemFlags(selectable) |
|
||||
(selectable ? Qt::ItemIsSelectable : Qt::NoItemFlags)));
|
||||
}
|
||||
|
||||
static QStandardItem *emptyItem()
|
||||
{
|
||||
auto *item = new QStandardItem();
|
||||
item->setFlags(Qt::ItemFlags(0));
|
||||
item->setFlags(Qt::ItemFlags());
|
||||
return item;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@ CommandPage::CommandPage()
|
|||
Command{"/command", "I made a new command HeyGuys"});
|
||||
});
|
||||
|
||||
// TODO: asyncronously check path
|
||||
if (QFile(c1settingsPath()).exists())
|
||||
{
|
||||
auto button = new QPushButton("Import commands from Chatterino 1");
|
||||
|
|
Loading…
Reference in a new issue